public bool TextIterNext(FontTextIterator iter, FontGlyphSquad *quad) { iter.Str = iter.Next; if (iter.Str.IsNullOrEmpty) { return(false); } iter.Codepoint = Char.ConvertToUtf32(iter.Str.String, iter.Str.Location); iter.X = iter.NextX; iter.Y = iter.NextY; var glyph = GetGlyph(iter.Font, iter.Codepoint, iter.iSize, iter.iBlur, iter.BitmapOption); if (glyph != null) { GetQuad(iter.Font, iter.PrevGlyphIndex, glyph, iter.Scale, iter.Spacing, ref iter.NextX, ref iter.NextY, quad); } iter.PrevGlyphIndex = glyph != null ? glyph->Index : -1; if (Char.IsSurrogatePair(iter.Str.String, iter.Str.Location)) { iter.Next.Location += 2; } else { ++iter.Next.Location; } return(true); }
public int TextIterInit(FontTextIterator iter, float x, float y, StringSegment str, int bitmapOption) { var state = GetState(); float width = 0; if (state.Font < 0 || state.Font >= _fontsNumber) { return(0); } iter.Font = _fonts[state.Font]; if (iter.Font.Data == null) { return(0); } iter.iSize = (short)(state.Size * 10.0f); iter.iBlur = (short)state.Blur; iter.Scale = iter.Font.FontInfo.__tt_getPixelHeightScale(iter.iSize / 10.0f); if ((state.Align & Alignment.Left) != 0) { } else if ((state.Align & Alignment.Right) != 0) { var bounds = new Bounds(); width = TextBounds(x, y, str, ref bounds); x -= width; } else if ((state.Align & Alignment.Center) != 0) { var bounds = new Bounds(); width = TextBounds(x, y, str, ref bounds); x -= width * 0.5f; } y += GetVertAlign(iter.Font, state.Align, iter.iSize); iter.X = iter.NextX = x; iter.Y = iter.NextY = y; iter.Spacing = state.Spacing; iter.Str = str; iter.Next = str; iter.Codepoint = 0; iter.PrevGlyphIndex = -1; iter.BitmapOption = bitmapOption; return(1); }