Search code examples
fontsfreetype

Invalid charmap encoding in FreeType


I can't get a TrueType font to work in FreeType 2.4.11. It seems this font with symbols has no Unicode charmap, but only an Apple Roman and an MS Symbol map. I have tried to explicitly choose any of them and then print chars 0-255 but only a couple of characters are valid with the Apple Roman encoding and none with MS Symbol, the rest show as rectangles.

The font is called GSDFastk.ttf and is available as part of a free demo data from the Swedish Land Survey: http://www.lantmateriet.se/Global/Kartor%20och%20geografisk%20information/Kartor/demodata/Fastighetsk/demo_fk_adm_mapinfo.zip

It works fine in e.g. Wordpad and in ESRI ArcMap but not in our tool with FreeType. I guess this has something to do with private user areas and character index offsets, so I tried adding some offsets (e.g. 0xf000) but to no avail.

Does anyone know why the character mapping doesn't work and how I could fix it?

Best regards, Andreas


Solution

  • I used the TTX tool to look at the font in more detail and it turned out that the Apple Roman character map was invalid. So I chose the MS_SYMBOL character maps instead and had to apply an 0xf000 offset since it uses the Private User Area. So the general (I hope) solution was to Always add the 0xf000 offset for MS_SYMBOL character maps.