Custom Font Loader to Load Fonts from S3 or Similar Sources

Gembox allows the usage of private fonts for which you can define a base directory:
FontSettings.FontsBaseDirectory = ".";

This will require extra extra steps though, when the app is deployed in a container and the fonts are coming from an S3 bucket or similar external source and not the file system of the container. Is there an option to provide a loader class implementation that will take care of the font loading from other sources? Or another solution?

Hi,

Currently, there is no option to provide a loader class implementation that will take care of the font loading from other sources.

Here are the reasons why:

  • To construct a list of logical font families and the underlying typefaces, GemBox must parse all font files in the directory. To minimize communication steps between the custom loader and GemBox, the loader would probably contain just a single method: GetFontFilesInZipArchive which is basically the same as copying the files to a certain directory, so no palpable extra functionality is provided with this feature.

  • Font files are parsed lazily (some tables are parsed only when needed). When a font file is located in a directory (or embedded in an assembly), it is easy and memory-efficient to parse it lazily (just open a FileStream, position it to the offset of the table, and start parsing). In the case of a custom loader, data of all font files must be held in memory the entire time although it is not needed all of the time (and some font file data may not be needed at all).

  • WPF, which is in some cases used for text shaping, works only with fonts located in a directory (and fonts embedded in an assembly).

Regards,
Stipo

Hi,

thanks for the thorough explanation. We’ll stay with copying the fonts into the container then.

Best regards,
Stefan