Getting Font Name from TTF font file

Discussion in 'Programming' started by orengelo, Feb 24, 2007.

  1. #1
    Hello everyone, is there any way to extract the font-name from a ttf file using PHP or PERL. Google turned up nothing and so did yahoo and msn.

    Any help much appreciated.


    Thanks
     
    orengelo, Feb 24, 2007 IP
  2. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if you mean just the name of the font file, so by example the fontfile name is "myfont.ttf" and you want returned "myfont", that could be done in PHP like this:
    $fontname = str_replace(".ttf", "", $filename);
    PHP:
    (where $filename is "myfont.ttf", and $fontname will contain "myfont")

    If you mean something else, let me know :)
     
    DeViAnThans3, Feb 25, 2007 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    It is too hard, but possible.

    There are many formats and styles.

    Some place the font name before the copyright, some after, some at the beginning of the file, some in the middle and some after.

    Try opening some files you have in notepad and you can see if a pattern exists.

    Peace,
     
    Barti1987, Feb 25, 2007 IP