If your system is using CP 1252 by default, then to render this glyph you, for example, have to render the character value '0xC2'. Unlike normal font where the mapping between glyphs and character is static, symbol fonts mapping varies based on the system default code page for non-unicode application aka CP_ACP.įor example, Pretend your symbol font have this glyph : '%'. Symbol font are specials in the way that windows processes them. That is because those small 0 to 255 "ASCII" code will vary depending on your system locale. Even checking the OS/2 table for the code page bit 32 isn't enough in many case.ģ) You can not simply use the magic 0xF000 number and add it to your small 0-255 number to get the character that will give you the glyph mapping you are going for. I do not know how to know for sure that a font is a symbol font. To this date, I still do not know how to differentiate them. I know for a fact that certain old arabic fonts also use that encoding. ( )Ģ) You can not assume that "cmap header encoding id is 0, at least in TTF format 4" means symbol fonts. The location of each block is defined by the OffsetTable which begins generally at byte 0 of the font file. I figured I should pitch in and provide some answers.ġ) You can not assume that 'loca' is following the 'cmap'. I went through this nightmare years ago too and I know a lot about all this stuff now. The reference code is written in C, so in order to write it in C# I read all the data to byte buffers, and "manually" read each element from it. I used the official documentation a lot: and the reference code. I subtracted 0xF000 from each character code and tested on Wingdings and Webdings fonts and it worked just fine. It seems that in symbol fonts (you can tell if a font is a symbol font if the cmap header encoding id is 0, at least in TTF format 4, which is the Microsoft format) the characters are added 0xF000 to their actual index, so instead of the regular ASCII codes, you get a Unicode value in the far end of the Unicode table. You would also need to read the head table for the location format flag (offset 34), and the maxp table for the number of glyphs field (offset 4). The documentation will tell you to use a "trick" possible since the glyph location data comes right after the arrays in cmap table. Here's what I've found during development: What are they?Īfter struggling a lot with GetFontData and the lack of documentation (well, not exactly lack of, but it is really not well organized, and some data is indeed missing), I found a way writing my own CharMap. How can I fill in that missing data? I was looking through the Windows' fonts and text APIs, but couldn't find anything to help me, so I must be missing some relevant APIs. Basically, you can say I am trying to write my own charmap from scratch. I want to use the font as the "regular" way, meaning, I want to see the same data as in charmap.exe (and in a side note I would also like to know if a font is a unicode font or ascii font, as charmap shows). I see that while all the characters appear, some characters appear more than once (total of 480 glyphs in that non-unicode font), and the positions are not the same as in charmap (for instance, medium sized circle glyph, in charmap located as 0x97, and in the font it is glyph 0xF097 and I also think it is the one in 0x2014). I used the font "Wingdings 2" as a test case, and compared it to what I see in Windows' charmap.exe. I'm using GetFontUnicodeRanges to get the available characters, then I create a bitmap with all the available characters and their index next to each one. I'm trying to display all glyphs in a font.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |