Author Topic: TrID update for OpenType Font  (Read 3513 times)

jenderek

  • Sr. Member
  • ****
  • Posts: 371
TrID update for OpenType Font
« on: June 21, 2017, 01:54:18 AM »
Hello,

when i run trid on on hundreds of Open Type fonts all are identified
as "OpenType - CFF compact font format" ( see appended output\trid-old.txt ).

The newest file(1) command version (http://darwinsys.com/file/) identifies such
examples correct also as "OpenType Font" ( see appended output/file-new.txt )

I manually make some additional changes in ttf.trid.xml.

According to documentation print mime type by line
   <Mime>application/font-sfnt</Mime>
But this should become "font/otf" in near future.

According to specifications such OpenType fonts start with scalable font (sfnt)
version 'OTTO' (0x4F54544F) instead 0x00010000. Afterwards the number of tables
is stored as short value. At first glance font with maximal 65535 tables could
exist, but real fonts contains only dozens of tables. The highest number i found
is 17 in cmunbmr.otf font example and lowest number is 9 like in
GohaTibebZemen.otf. So high byte of big endian short value is null. This is
expressed by XMl construct.

      <Pattern>
         <Bytes>4F54544F00</Bytes>
         <ASCII> O T T O</ASCII>
         <Pos>0</Pos>
      </Pattern>

So i mention this facts in remark line:
<Rem>
variant with sfnt version 'OTTO' at offset 0 and number of tables less 18 stored at 4.
</Rem>

Because Open Type font is predecessor of True Type font, these fonts share some
data structures. So expected to see here again pattern of table Directory
entries. But the above pattern for sfnt version an tables numbers was the only
pattern in trid definition file. Of course this is sufficient to detect OTF
files. But i decided to create a new trid definition file by tridscan to get
more patterns that can be used to compare with True Type font and also font
collections.

Often tag names consist of four characters like "NAME", "HMTX".

The Apple specification mentions 46 different table names, but not all possible
tables are used at same time. So only 8 tables are always found in all fonts
instead 6 in old definition. This is described by GlobalStrings section. The
string "$HMTX" describes that table before horizontal metrics table "HMTX" has a
size that all ends with 24h="$". This is probably an accident. So i reduce in
GlobalStrings section also string "6HHEA" to existing 4 byte table name "HHEA".

With updated definition file with above modifications all fonts are still
 recognized ( see appended output\trid-new.txt ).

trid definition and output are stored in archive otf.zip.
I hope that my XML file can be used in future version of triddefs.

With best wishes
J?rg Jenderek

Mark0

  • Administrator
  • Hero Member
  • *****
  • Posts: 2686
    • Mark0's Home Page
Re: TrID update for OpenType Font
« Reply #1 on: June 21, 2017, 09:15:02 PM »
Thanks for the info!
I think I will try to keep/make a very generic definition without getting too specific, in this case.
« Last Edit: June 21, 2017, 09:28:21 PM by Mark0 »