Page 1 of 1
Parsing information from TrueType font
Posted: Mon Mar 14, 2011 9:40 am
by spamyboy
I have a question on stackoverflow about parsing data from TrueType font. Has anyone done that before? I need to extract as much as possible data, most importantly the cmap. Can anyone explain me how do I proceed from the point as described in the stackoverflow?
http://stackoverflow.com/questions/5290 ... etype-font
Re: Parsing information from TrueType font
Posted: Mon Mar 14, 2011 12:53 pm
by spamyboy
Could I possibly call freetype2 on linux system using PHP to get info about the font?
Re: Parsing information from TrueType font
Posted: Mon Mar 14, 2011 6:38 pm
by Weirdan
can't you use a command-line utility like this:
http://packages.debian.org/sid/fonttools ?
Re: Parsing information from TrueType font
Posted: Mon Mar 14, 2011 7:29 pm
by spamyboy
an I use it with PHP?
Re: Parsing information from TrueType font
Posted: Tue Mar 15, 2011 4:49 am
by Weirdan
shell_exec + simplexml ?
Re: Parsing information from TrueType font
Posted: Tue Mar 15, 2011 9:42 am
by spamyboy
I used the code that you have suggested. Now I am able to access the
cmap, which is great. Now, how do I convert these characters to image generated with GD or whatever.
Code: Select all
object(SimpleXMLElement)#4 (3) {
["tableVersion"]=>
object(SimpleXMLElement)#5 (1) {
["@attributes"]=>
array(1) {
["version"]=>
string(1) "0"
}
}
["cmap_format_4"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#6 (3) {
["@attributes"]=>
array(3) {
["platformID"]=>
string(1) "0"
["platEncID"]=>
string(1) "3"
["language"]=>
string(1) "0"
}
["map"]=>
array(222) {
[0]=>
object(SimpleXMLElement)#9 (1) {
["@attributes"]=>
array(2) {
["code"]=>
string(4) "0x20"
["name"]=>
string(5) "space"
}
}
[1]=>
object(SimpleXMLElement)#11 (1) {
["@attributes"]=>
array(2) {
["code"]=>
string(4) "0x21"
["name"]=>
string(6) "exclam"
}
}
[..]
Re: Parsing information from TrueType font
Posted: Tue Mar 15, 2011 10:30 am
by Weirdan
What are you trying to do? It might be that there's better approach.
Re: Parsing information from TrueType font
Posted: Tue Mar 15, 2011 10:52 am
by spamyboy
Basically I need to generate Character/Glyph Map of all available characters in the font.
Re: Parsing information from TrueType font
Posted: Tue Mar 15, 2011 11:28 am
by spamyboy
There is this discussion on stackoverflow that might be of a help for someone to help me to solve this issue.
Code: Select all
http://stackoverflow.com/questions/5313474/otf-ttf-font-cmap-table/5313566#5313566