Record TGlyphCursorUtf8
Unit
Declaration
type TGlyphCursorUtf8 = record
Description
Cursor to go through a UTF8 text glyph by glyph.
A glyph is a graphical unit to be displayed. It can be formed by one or more Unicode codepoints.
Example drawing wavy text using TGlyphCursorUtf8
on a TBGRACanvas2D:
uses ..., BGRAUTF8, BGRACanvas2D; procedure WavyText(ctx: TBGRACanvas2D; AText: string; X,Y, AWavePosDeg, AWaveStepDeg, AWaveSize: single); var cursor : TGlyphCursorUtf8; glyph: TGlyphUtf8; glyphText: string; begin cursor := TGlyphCursorUtf8.New(AText, fbmAuto); while not cursor.EndOfString do begin glyph := cursor.GetNextGlyph; if glyph.MirroredGlyphUtf8 <> '' then glyphText := glyph.MirroredGlyphUtf8 else glyphText := glyph.GlyphUtf8; ctx.fillText(glyphText, x,y + AWaveSize*Sin(AWavePosDeg*Pi/180)); x += ctx.measureText(glyphText).width; AWavePosDeg += AWaveStepDeg; end; end;
Overview
Methods
function EndOfString: boolean; |
|
function GetNextGlyph: TGlyphUtf8; |
|
class function New(const textUTF8: string; ABidiMode: TFontBidiMode): TGlyphCursorUtf8; static; |
|
procedure Rewind; |
Description
Methods
function EndOfString: boolean; |
|
Indicate whether the end of the string has bee reached |
function GetNextGlyph: TGlyphUtf8; |
|
Advance and retrieve the next glyph |
class function New(const textUTF8: string; ABidiMode: TFontBidiMode): TGlyphCursorUtf8; static; |
|
Initialize a record with the given parameters |
procedure Rewind; |
|
Start all over again from the first character |