Question

I am currently attempting to get kerning information out of a font file. I have got kerning pairs so far using Font Forge. It gives you a list of kerning pairs like so:

pos \Y \s -184;
pos \Y \A -154;
pos \o \period -49;
pos \r \period -150;
pos \r \comma -170;

The problem now lies in the fact that instead of giving me an ascii code or something, for punctuation an other non alphabetic characters it just gives the name of the character, e.g. comma, period etc.

Can anyone think of a way of converting the name 'comma' to the actual comma ',' character? I'm a bit stumped.

Was it helpful?

Solution

Going from the human readable character name to the character value would require a mapping between the two representations. You could do this yourself or search for a library that does it for you. I was not able to find a c library, but something like this java library may do the trick:

http://sisc-scheme.org/manual/javadoc/sisc/reader/CharUtil.html

The other option is to take a closer look at Font Forge to see if it has options to output the information you want directly.

http://fontforge.org/

OTHER TIPS

There is no built in way to do so. The closest class that could have provided such information is CharUnicodeInfo, but it does not map names to characters.

You'd have to build custom map like following:

   var nameToChar = new Dictionary<string,char>()
     { {"period", '.'} };

   var ch = nameToChar["period"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top