This is a patch which does two things:
Extract some kerning data from TTF/OTF fonts, from the GPOS table. The font I was primarily working with was FreeSerif, which stores its data in "Pair Positioning Adjustment: Format 2", with only one ValueRecord per glyph pair. I'm not sure how far I got on the Format 1 table spec, and I'm pretty sure I didn't do anything to support the two ValueRecord entries.
https://www.microsoft.com/typography/otspec/gpos.htm#PP
Read in kerning data when loading a font, and then utilize it for string width analysis. Also use it when generating pdf Tj string, to actually display kerning data. Also had to make some minor mods to html justification.
In my testing with FreeSerif, the kerning differences can be readily seen, especially with words like AWAY, etc.
Dear David,
I'm checking your patch under the latest realease (6.2.10), it seems very interesting (I hope it will get merged soon) !
There seem to be an issue with that patch, on line 921 of tcpdf_fonts.php - the regexp is using a too recent php implementation (AFAIK tcpdf runs at least on php 5.3 - this syntax was added in 5.4) :
Same on lines 5339 & 5353 :
if(isset($u16) && $u16) $txt3.=TCPDF_STATIC::_escape(TCPDF_FONTS::arrUTF8ToUTF16BE([$unicode[$i]], false));if(isset($u16) && $u16) $txt3=TCPDF_STATIC::_escape(TCPDF_FONTS::arrUTF8ToUTF16BE([$unicode[0]], false));
I've also noticed that $int_len and $getUINT were not declared at line 782 (seems on purpose - as it gets declared directly when starting the function) :
TCPDF_FONTS::parseTtfGposTable($font, $gpo, $length, $kern, $gtc, $int_len, $getUINT);
Last edit: Mathieu Masseboeuf 2015-07-30