Is it just me or is Calibri's kerning only partly done?
Thanks Si.
In OpenType window the kern feature just says:
feature kern { # Kerning
# Latin
lookup kern1 {
lookupflag IgnoreMarks;
} kern1;
language TRK ; # Turkish
language ROM ; # Romanian
language IPPH;
script grek; # Greek
lookup kern1;
script cyrl; # Cyrillic
lookup kern1;
language SRB ; # Serbian
} kern;
Where are the actual pairs and their values???
(Sorry if I'm being thick.)
Calibri and the other MS ClearType fonts were originally made with GPOS kerning only. When MS Office decided to adopt some of these fonts as defaults, they requested that kern tables be added, since Office apps did not yet -- and still do not! -- support GPOS kerning for European scripts. The kern tables contain filtered flattened kerning from the GPOS sources, including only encoded glyphs; even so, the size of some of the kern tables is very large, and it is quite possible that apps might fail to support all the kern pairs.
In general, I'd recommend against including both GPOS and kern table kerning, unless a client specifically requests it and has some pressing technical need.
The full kerning in Calibri is implemented in the GPOS table, using the OTL kern feature rather than the kern table. The kern table contains a subset of the full kerning, for use by applications that do not support GPOS kerning.
But I'm wondering how are you checking the contents of the kern table, Nick? I've made a dump of the Calibri Regular kern table, and it contains 26,706 kern pairs, including plenty of lowercase letters in the first glyph position.
Anyone want to see them all? :)
And I get the same as Nick for the first glyphs. Here they are for Calibri version 2.00
A AE AEacute Aacute Abreve Acircumflex Adieresis Agrave Amacron Aogonek Aring Aringacute Atilde B C Cacute Ccaron Ccedilla Ccircumflex Cdotaccent D Dcaron Dcroat E Eacute Ebreve Ecaron Ecircumflex Edieresis Edotaccent Egrave Emacron Eogonek Eth F G Gbreve Gcircumflex Gcommaaccent Gdotaccent H Hcircumflex J Jcircumflex K Kcommaaccent L Lacute Lcommaaccent O Ograve
On the other hand, the size of the kern table returned by "ftxdumperfuser -l calibri.ttf" is 84906 bytes. So is the size of the file obtained by using "sfntedit -x kern calibri.ttf". And finally, if I remove the _k_e_r_n.py and _k_e_r_n.pyc files of ttx, the hex dump of the kern table that ttx produces also gives 84906 bytes.
In any case, FontForge gives 14148 kerning pairs. On the other hand, the file Calibri.kern.xml given by "ftxdumperfuser -A a calibri.ttf" reports just one table:
<KERNTable version="0" subtableCount="1" >
<kernSubtable format="1" length="19366" coverage="0x0001" tupleIndex="14148" kernVertical="no" kernCrossStream="no" kernVariation="no" >
</kernSubtable>
</KERNTable>
The length does not make much sense for 14148 pairs.
I added a few traces to the file _k_e_r_n.py to better see what is going on (and to see that ttx identified a bug before desisting on decompiling). Here is a trace on calibri.ttf
Dumping "calibri.ttf" to "calibri.ttx"...
len(data)=84906
nTables=1, version=0
4 bytes consumed
Decompiling table 0
Length=19366 (encoded with 2 bytes; note 19366+2**16= 84902)
decompiling data[:19366]
Version: 0, length: 19366, coverage: 1
6 bytes consumed
8 other bytes consumed for nPairs, searchRange and rangeShift
nPairs=14148 (each is 6 bytes: 84888 bytes + 14 = 84902 bytes)
buggy kern table
Dumping 'kern' table...
The culprit is rather clear: a table length that is read as 2 bytes whereas the actual length is larger than 65535.
I get the same trouble with Cambria.ttf and Constantia.ttf
Michel
>>>Anyone want to see them all? :)
John, I was expecting to see all 26,706 kern pairs in the kern table when I opened it in a new metrics window but there are only 4,860 kern pairs and all this is for v5.62. Why doesn't it open all of them up like the other Microsoft ClearType fonts?
By the way Michel, you completely lost me after your second post!
Anyway.
Michel, you completely lost me after your second post!
Well, when I look with FontForge, it first tells me that there is a kern table but I also get the message that it will not read it because there is also a kern feature in GPOS. If I generate the corresponding afm file, I get 34863 kerning pairs (taken from GPOS).
To force FontForge to read the kern table, I remove the GPOS table from Calibri with "sfntedit -d GPOS Calibri.ttf" and generate again the afm file. This time I get the 14148 kerning pairs of the old style kern table plus a warning that the kern table does not comply with the specs.
The rest was simply to find more precisely the cheat, or the bug, or at least the reason why ttx would output only 3225 pairs with first glyph from A to Ograve.
Michel
EDIT: According to the spec, the subtable should be 19366 bytes long and there is just one. It starts with 14 bytes of info and then there is 6 bytes per kerning pair. (19366 - 14) / 6 = 3225. After that, ttx stops decompiling.
The basic issue is that the ancient kern table spec uses a USHORT for the 'length' field (for the length of the entire kern table including all subtables). Why it was specified this way is a complete mystery to me, since the length of the entire *table* is already given by the font's Table Directory (header). It's not even redundant, since the Table Directory length is a ULONG, allowing for a much larger table. But that's how it is.
So, for tools or other processes that make use of the length field, you can do the math with the table & subtable header lengths, etc. and figure out that the number of pairs in a format 0 subtable is theoretically limited by that field to a maximum of 10920 (which I'm sure the inventors thought would be more than enough at the time, but nowadays, not so much).
But, many tools and some operating systems ignore or at least don't choke on kern tables where the length field is not correct, and can calculate the actual length of a format 0 subtable by using 'nPairs' field.
I just ran a test with FontLab. I removed the GPOS table and opened the resulting font with FontLab. It found 3225 kerning pairs, the same as ttx does. My guess is that the GPOS kern feature has been removed from the font and all the kerning pairs put in an old style kern table. On that table spot crashes, ttx and FontLab do not do their best to circumvent the hack. The only solution I see is to open the font with FontForge, generate anew the ttf, and open the resulting font with FontLab. You should then see all the kerning pairs.
Captured from web.archive.org on 12 Sep 2019. view this capture