Part of https://github.com/behdad/fonttools/issues/236
Now we fallback to ASCII for unknown encodings. Not sure if this might be a bad idea.
The main user-visible difference is that if there's an ASCII-only text in an unknown
encoding, we still "decode" it and use unicode="True" instead of unicode="False".
Or is assuming that any unsupported encoding is ASCII-compatible too intrusive?
This will make it impossible to process fonts with super-broken
name tables. But we do not handle arbitrary broken fonts anyway,
so this is arguably better than silently ignoring junk content.
Resolves a review comment in #235.
In the unit test, replace calls of deprecated unittest.assertEquals()
by calls of unittest.assertEqual().
There was a bug before Python 3.4 where an extra byte was included
in e.end when the error callback was called. That hided a bug in
the code.
Fixes build with Python 3.4+
When dumping the Macintosh Skia font to XML, the TTX tool crashed
with a Python exception. After this change, the font can be dumped
fine. This was caused by a name record with platformID=1 (Macintosh)
and platEncID=2 (Traditional Chinese).
The first arg to run-tests.sh is used as a regex to narrow down
tests to run. We should extend this to consider all args as
regexes.
Eg:
./run-tests.sh xml
The Python libraries come with two ways of writing unittests:
module unittest, and module doctest. In some cases, unittest
is more natural (less cumbersome) than doctest.
Wrote tests on xmlWriter for illustration.
https://github.com/behdad/fonttools/issues/54
There's a new attribute named unicode that can choose whether the
text in the XML entry is to be interpretted as Unicode, or as the
target encoding.
If a contextual lookup recurses twice on the same index, that index
most be marked chaotic for the second recursion.
Also, when a non-1-to-1 recursion happens, only mark glyph locations
after current to be chaotic, not everything.
I believe this fixes a bug that before we were not inclusive enough.
Now we might have introduced more false positives, but we are at least
correct.
Improves NotoNastaliqDraft closure_glyphs() time from 60s to 50s.
This was originally introduced in 1d4fa13b4. I'm fairly confident
new code is correct.
Dynamic-Programming-based algorithm. Previously we had a greedy
algorithm only.
Unfortunately the savings are truly negligible. In the order of ~20
bytes for each of the Roboto faces, less so for Noto fonts. Even on
a 20MB font, it produced less than 100 bytes saving compared to our
greedy packing. Either I made a huge mistake, or this is so not worth
it. Anyway, the code is there, but disabled.