fonttools icon indicating copy to clipboard operation
fonttools copied to clipboard

Missed CFF2 check? ttFont.py line 968 routine sortedTagList()

Open tshinnic opened this issue 6 years ago • 2 comments

I asked this question on fonttools group, and it was suggested to bring it here.

ttFont.py routine sortedTagList() switches table orders on write between recommended table orderings for OpenType with TrueType outlines vs. OpenType with CFF outlines . There is a line that currently checks only for "CFF ". I believe that line should also check for "CFF2" as well.

However... the question was raised in the discussion "why reorder tables?" I replied that Microsoft's docs specify a suggested ordering for efficiency, that differs between TrueType / OpenType fonts. Thus the lists feeding into sortedTagList() and thus reorderFontTables() on (re)writing font files.

However... in inspecting ~700 font files on my Win10 box (+3rd party fonts), I haven't found a single font file that has these suggested orderings. Not even in a few fonts 10-15-20 years old.

It appears that all (?) font files in wide circulation have table directories simply alphabetically sorted - no magic suggested ordering imposed at all. None. Check your ttx -l listings to see if you can come up with a counterexample.

Which makes the question asked by Denis Jacquerye (@moyogo) much more interesting than documentation would, um, suggest. Why do anything other than sort table names alphabetically on write?

Nobody noticed the broken test because nobody cares. Rather than fix the line, remove the magic code?

tshinnic avatar Feb 13 '19 00:02 tshinnic

Ah, fun. All the documentation about ordering may be right, so I might be wrong. Could the difference be that two different orders are being discussed?

There is the order of table names as written into the table directory. As above, that is uniformly alphabetically ordered.

Separately, there is the order of tables as written to the file. OSes reading them in a suggested order might affect the 'efficiency' Microsoft mentions.

There are fonts with tables written in alphabetical directory order. About 1/6? Most CFF files follow the suggested write orderings perfectly. The majority of truetype files give a nod to the suggested write orderings, with about 1/6 near perfect.

It looks like the table write ordering suggestions are being followed with intent, with lots of deviations/idiosyncrasies as per normal chaotic development.

I suppose the issue regresses to just that one line being broken. Sorry for the confusion.

tshinnic avatar Feb 13 '19 18:02 tshinnic

Is easy enough to add CFF2 to that list.

behdad avatar Aug 19 '22 17:08 behdad

The table order recommended is largely irrelevant these days, and it has not been updated for CFF2. I suggest closing this issue.

If anything GDEF/GSUB/GPOS should come before glyf/CFF/CFF2 for best performance. Currently they don't.

In HarfBuzz we sort tables by their size.

behdad avatar Oct 28 '22 20:10 behdad