TFontCache dramatically improves text rendering performance over directly accessing TFontReader objects. Font files only need to be parsed once for each character accessed, and the glyph data returned is cached for later reuse.
const text = 'some text'; var image : TImage32; rec : TRect; arialReader : TFontReader; arial14Cache: TFontCache; 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 := TFontCache.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;
Copyright ©2010-2023 Angus Johnson - Image32 4.8 - Help file built on 18 Jan 2025