Foxit PDF SDK 5.3

How to display fonts correctly using Foxit PDF SDK?

To display the fonts correctly, you must use the FSCRT_Library_AddFontFile or use FSCRT_Library_SetFontMapperHandler.

Here is how to use FSCRT_Library_SetFontMapperHandler in C++. declare the following structure:

static FSCRT_FONTMAPPERHANDLER ExternalFontMapper; 
static string FallbackFontPath; 
static FS_RESULT MapExternalFont(FS_LPVOID clientData, FS_LPCSTR fontName, FS_DWORD fontStyles, FS_INT32 weight, FS_INT32 charset, FSCRT_FILE *fontFile, FS_INT32 *faceIndex){

 //This call back will trigger when an external font is needed. The values fontName, fontStyles, weight, charset will be provided and it is up to the programmer to write the condition on which font file is to be set to be used. An simple example is 

if(fontName=="randomFontName") {//set font file randomFontName.ttf}.

 //Here is how to set the font file, call FSCRT_File_Create with FSCRT_File_Write, FSCRT_File_CreateCacheFile, FSCRT_File_CreateFromMemory, or FSCRT_File_CreateFromFileName to create the handle for FSCRT_FILE. Please see fs_base_r.h or fs_codec_r.h for details 

//faceIndex can be set to 0 for default 

return 0; 


// Apply the font mapper after unlocking the library. 

ExternalFontMapper.MapFont = MapExternalFont; 
ExternalFontMapper.clientData = 0; 

//clientData is your own data that you want to pass to MapExternalFont when it is triggered 


Note: This article refers to a deprecated version of a Foxit Product. If you are still using Foxit PDF SDK 5.3 or older, please refer to your download package documents for Developer Guide and API Reference.

Get a trial version of the new Foxit PDF SDK and see our latest generation SDK’s brand new features!

Updated on April 5, 2017

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: