Parsing information from TrueType font

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Parsing information from TrueType font

Post 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
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: Parsing information from TrueType font

Post by spamyboy »

Could I possibly call freetype2 on linux system using PHP to get info about the font?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Parsing information from TrueType font

Post by Weirdan »

can't you use a command-line utility like this: http://packages.debian.org/sid/fonttools ?
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: Parsing information from TrueType font

Post by spamyboy »

an I use it with PHP?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Parsing information from TrueType font

Post by Weirdan »

shell_exec + simplexml ?
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: Parsing information from TrueType font

Post 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"
          }
        }
[..]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Parsing information from TrueType font

Post by Weirdan »

What are you trying to do? It might be that there's better approach.
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: Parsing information from TrueType font

Post by spamyboy »

Basically I need to generate Character/Glyph Map of all available characters in the font.
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: Parsing information from TrueType font

Post 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
Post Reply