Read FONTNAME from ttf, otf and pfm font files

Just starting out? Need help? Post your questions and find answers here.
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

Read FONTNAME from ttf, otf and pfm font files

Post by Amor_2001 »

Hello.
I want to write a program to read the font names from ttf, otf and pfm font files.
Unfortunately, I have yet no idea.
Could someone make me ready procedures available?

Thank you.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Read FONTNAME from ttf, otf and pfm font files

Post by eesau »

www.microsoft.com/typography/tt/ttf_spec/ttch02.doc - TTF file format specification
http://www.microsoft.com/typography/otspec/otff.htm - OTF file format specification
http://partners.adobe.com/public/develo ... 78.PFM.pdf - Some info on PFM file format

Maybe these can help you started?
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

Re: Read FONTNAME from ttf, otf and pfm font files

Post by Amor_2001 »

Thank you.
I have looked into similar documentation, but this is difficult for me to put into source code.
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: Read FONTNAME from ttf, otf and pfm font files

Post by Thade »

Image
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

Re: Read FONTNAME from ttf, otf and pfm font files

Post by Amor_2001 »

:) :) :) :)
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Read FONTNAME from ttf, otf and pfm font files

Post by ABBKlaus »

There are some routines inside PurePDF to extract TTF informations.
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

Re: Read FONTNAME from ttf, otf and pfm font files

Post by Amor_2001 »

@ABBKlaus
Can you please tell me what and where to find it there? I have found nothing to extract the Font Names in PurePdf. Only to set the properties.

Thanks
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Read FONTNAME from ttf, otf and pfm font files

Post by ABBKlaus »

its inside ipdf_TTF_Handle_Name. I have used Tutorial22 Font.pb which uses Tahoma.ttf :

Code: Select all

Procedure.s ipdf_TTF_Handle_Name(List Fonts.PDF_FontStructure(),*name.TTF_name_Header,PID,PSID,LID,NID)
  Protected count=ipdf_EndianW(*name\count)&$FFFF
  Protected stringOffset=*name+ipdf_EndianW(*name\stringOffset)&$FFFF
  Protected platformID,platformSpecificID,languageID,nameID,offset,length
  Protected i,j,name$,res$
  
  Debug "count="+Str(count)
  If count>0
    For i=0 To count-1
      platformID=ipdf_EndianW(*name\NameRecord[i]\platformID)&$FFFF
      platformSpecificID=ipdf_EndianW(*name\NameRecord[i]\platformSpecificID)&$FFFF
      languageID=ipdf_EndianW(*name\NameRecord[i]\languageID)&$FFFF
      nameID=ipdf_EndianW(*name\NameRecord[i]\nameID)&$FFFF
      offset=ipdf_EndianW(*name\NameRecord[i]\offset)&$FFFF
      length=ipdf_EndianW(*name\NameRecord[i]\length)&$FFFF
      ;Debug "platformID="+Str(platformID)
      ;Debug "platformSpecificID="+Str(platformSpecificID)
      ;Debug "languageID="+Str(languageID)
      ;Debug "nameID="+Str(nameID)
      ;Debug "offset="+Str(offset)
      ;Debug "length="+Str(length)
      If length>0
        If platformID=3
          name$=""
          For j=0 To Int(length/2)-1
            name$+Chr(ipdf_EndianW(PeekU(stringOffset+offset+2*j))&$FFFF)
          Next
        Else
          name$=PeekS(stringOffset+offset,length,#PB_Ascii)
        EndIf
        Debug "ipdf_TTF_Handle_Name:["+Str(Len(name$))+"]"+name$
        ;CallDebugger
      EndIf
      If PID=platformID And PSID=platformSpecificID And LID=languageID And NID=nameID
        res$=name$
        Break
      EndIf
    Next
  EndIf
  ProcedureReturn res$
EndProcedure
Debug Output wrote:ipdf_TTF_Handle_Name:[50]© 2004 Microsoft Corporation. All rights reserved.
ipdf_TTF_Handle_Name:[6]Tahoma
ipdf_TTF_Handle_Name:[7]Regular
Post Reply