After experimenting with uharfbuzz for a while, I found out it was hard
to handle top-to-bottom texts, so I gave up an idea to put an ascender
or a descender value in the arguments. Instead, I simply expose 'offset',
'width' and 'height', which is way more straightforward than the
previous design.
In addition, 'contain' option is added to easily compensate and render
glyphs such as combining accents or excessively tall letters.
This was removing semantically-significant difference amongst glyphs
such as two identical glyphs one in Noto Sans Tamil one in Noto Sans
Grantha as in the following issue:
Part of fixing https://github.com/fonttools/fonttools/issues/2475
Part of fixing https://github.com/fonttools/fonttools/issues/2475
Old code was mistakenly only adding the synthetic-generated feature
to the first language-system. In the case of merging Noto Grantha
and Noto Tamil fonts, Noto Tamil had two script systems: 'taml' and
'tml2', and we were adding the synthetic 'locl' feature only to the
DefaultLangSys of the 'taml' script, not the 'tml2' script. That was
the main bug.
A second issue was that the lookup was being added twice to the same
(synthetic) feature. Check before adding lookup, to avoid that.
Using a RoundingPen as a filter doesn't work for TrueType quadratic splines (qCurveTo), because the rounding would occur too early, before these get split into atomic quadratic Bezier segments (by the superclass BasePen.qCurveTo method), thus leaving unwanted floating-point coordinates in the SVG output.
So here we add a 'ntos' parameter (by default simpli calls str()) that takes a Callable[[float], str] and can be used to customize the formatting of the numbers in SVG path coordinates.
Two small changes that significantly speed up subsetting of large fonts
such as Noto Sans CJK:
1. When emptying a charstring, simply empty its program rather than
attempting to decompile it first. (Only relevant when retaining GIDs.)
2. When reindexing charstrings, swap an accidentally-quadratic
implementation for one that is linear in the number of retained glyphs.