TPdfWriter.GetFontFolder Event
Use this event if you want to provide your own font information for embedding for a particular object instance.
For changing the font folder for the full application, use GetFontFolderGlobal instead. Normally FlexCel will search for fonts on [System]\Fonts folder and %%localappdata%%\Microsoft\Windows\Fonts. If your fonts are in other location, you can tell FlexCel where they are here. If you prefer just to give FlexCel the full data on the font, you can use GetFontData event instead.
Note that you can return more than one path by separating them with semicolons. For example if you return "c:\fonts1;c:\fonts2" FlexCel will search both in fonts1 and fonts2. Every folder you specify here must have at least one font.
FlexCel will search in the folders you return here, and in **all subfolders** of that folders for ttf files.
In Android, we use a "@folder" syntax to refer to assets. So for example to specify that the fonts are in the "fonts" folder asset, return "@fonts" here. If the fonts are in a normal folder, just return the folder.
Remarks
FlexCel by default won't try to scan folders if the graphics library used by FlexCel returns the TTF tables directly. If you are using SKIA or CoreGraphics, this event might not be called. To ensure this event is called no matter what underlying graphics engine is used, you will need to set TFlexCelConfig.ForcePdfFontsFromDisk to true.
Syntax
Unit: FlexCel.Pdf
property TPdfWriter.GetFontFolder: TGetFontFolderEventHandler
Examples
The following code will setup a GetFontFolder event that searches for a font first in c:\MyFonts, and if the font isn't there, it will search in the default FlexCel search path:
procedure LocatePDFWriterFontFolder(const sender: TObject; const e: TGetFontFolderEventArgs);
begin
e.FontPath := 'c:\MyFonts;' + e.FontPath;;
end;
...
pdf := TPdfWriter.Create;
try
pdf.GetFontFolder:= LocatePDFWriterFontFolder;
// Note: If the font is in c:\MyFonts, you need to tell the Operating System
// to search in that folder too.
MyFont := TUIFont.CreateNew('MyFont', $C);
try
redBrush := TUISolidBrush.CreateNew(Colors.Red);
try
pdf.DrawString('Hello', MyFont, redBrush, $64, $64);
finally
redBrush.Free;
end;
finally
MyFont.Free;
end;
finally
pdf.Free;
end;