3 Replies Latest reply on Jun 19, 2010 6:57 AM by Peter Kahrel

    [AS or JS] How Can I Access/Gather Font Informations?


      Hello all,


      is it possible to gather font information that is embedded in the font file of a specific font via scripting? E.g. Kerning pairs with values, widths, side bearings of certain characters etc.?




        • 1. Re: [AS or JS] How Can I Access/Gather Font Informations?
          [Jongware] Most Valuable Participant

          I would not say it's totally impossible -- but it might come close.


          InDesign does not give access to such low-level information, but it does give you the full path & filename of any specific font. I tested it once and was able to read the number of characters of an Opentype font -- but it didn't work under all circumstances, for all fonts. Apparently, there are a few different 'tastes' of OTF.


          To get the very specific and low-level data you need, you would need to write a complete Opentype data parser in Javascript or AppleScript, and to do that, you need to understand the file format of Opentype in extreme detail, just to be able to locate the kerning pair table (it might be a straight table, or it might contain Opentype class kernings).

          I dunno where to look for character widths; but to get side bearings, you'd even have to go a step further: these are only defined by virtue of the character outline, so you have to compare the minimum and maximum values as defined for the character paths against its reported total width.


          I'm addressing just Opentype here, but there are a number of other "standard" font file formats. If you want a complete solution, you would need to do the same for TTF (Mac old style) and for Type 1 fonts as well.

          • 2. Re: [AS or JS] How Can I Access/Gather Font Informations?
            [Jongware] Most Valuable Participant

            Incidentally, to-day I re-installed Just van Rossum's excellent TTX again (this time on my Windows 7 machine). I gave it a quick test to see if it works (it does), and (re-)discovered that the items you seek -- standard kerning pairs, widths, and side bearings -- are all written out in clear human readable XML notation.

            Didn't spot any Opentype pair kerning classes though, so perhaps that's not supported, or I didn't see them in my cursory inspection, or (also possible) there simply weren't any in the font I tested with.


            TTX supports per-table disassembly, so you can have it write out a complete data file once, check which tables contain the info you seek, and next time have it only output those tables.

            1 person found this helpful
            • 3. Re: [AS or JS] How Can I Access/Gather Font Informations?
              Peter Kahrel Adobe Community Professional & MVP



              You can get just ascender and descender values, that's about it. Not even x- and cap-height, though you can script your way around that and find them. As Jongware said, anything else gets very tricky.


              Please go to http://www.adobe.com/support/feature.html and ask Adobe to expose more font chracteristics to scripting. The more of us ask, the better the chance we'll get something.