LazFreeType: add font kerning
Original Reporter info from Mantis: circular
-
Reporter name:
Original Reporter info from Mantis: circular
- Reporter name:
Description:
Font kerning consists in putting closer letters that fit together like AV.
Note that the format of FreeType has evolved with time, and the patch here is for the 'kern' table. Some fonts may not provide it and provide only the newer 'GPOS' table. This could be implemented in a future patch.
The patch also fixes some dynamic array out of bounds issues for the result of CharsWidth and CharsPosition. The result was initially sized using UTF8Length function but it might happen that the using UTF8CodepointToUnicode would give a different number of characters. Also the CharsWidth function was repeating the entries charlen times but that doesn't make sense as the array is not sized with the byte length but with UTF8Length. Hence calling the function with multibytes characters would cause a bound error. Those functions are tested as well by the test program (cf the colored lines).
This patch also fixes the size of TT_FWord which is supposed to be word-sized as its name suggests but was defined as Integer. Luckily, it has not been used directly for serialization so this change has no side effect as far as I can tell.
Steps to reproduce:
Apply the patch and run attached project to see the difference with/without kerning, and with/without kerning fallback.
Additional information:
Tested with Liberation Sans, Liberation Serif, DejaVu Sans, Arial and Ubuntu.
FreeSans even though it has a 'kern' table seem to have no kerning, which is consistent with how it is displayed in LibreOffice.
Mantis conversion info:
- Mantis ID: 37058
- Version: 2.0.8
- Fixed in revision: r63145 (#60d719d7)
- Monitored by: » circular (circular)