Record TGlyphCursorUtf8

Hierarchy
Fields
Properties

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

Public function EndOfString: boolean;
Public function GetNextGlyph: TGlyphUtf8;
Public class function New(const textUTF8: string; ABidiMode: TFontBidiMode): TGlyphCursorUtf8; static;
Public procedure Rewind;

Description

Methods

Public function EndOfString: boolean;

Indicate whether the end of the string has bee reached

Public function GetNextGlyph: TGlyphUtf8;

Advance and retrieve the next glyph

Public class function New(const textUTF8: string; ABidiMode: TFontBidiMode): TGlyphCursorUtf8; static;

Initialize a record with the given parameters

Public procedure Rewind;

Start all over again from the first character