TGlyphCache

TGlyphCache very significantly improves text rendering performance over directly accessing TFontReader. It does this by parsing font files only once for each accessed character and caching the returned glyphs at the specified font height, and Y-axis inverted too as is needed for rendering in the Image32 library.

Reference

Methods Properties
In TGlyphCache:
Clear Ascent
Create Descent
Destroy FontHeight
GetAngledTextGlyphs FontReader
GetCharInfo InvertY
GetCharOffsets Kerning
GetTextGlyphs LineHeight
GetTextWidth

const
  text = 'some text';
var
  image       : TImage32;
  rec         : TRect;
  arialReader  : TFontReader;
  arial14Cache: TGlyphCache;
begin
  ... 
  //The following line of code assumes compiling to the Windows platform.
  //For cross-platform applications, consider storing the font in the
  //application's resource section, and loading it from there.
  arialReader := TFontReader.Create('Arial'); 
  //create a font cache for arialReader (with font height 14)
  arial14Cache := TGlyphCache.Create(arialReader, DpiAware(14));
  try
    //now do something with arial14Cache
    DrawText(image, rec, text, taCenter, tvaMiddle, arial14Cache);
  finally
    //clean up
    arialReader.Free;
    arial14Cache.Free;
  end;