PSTokenizer is now an indipendent object behaving like a StringIO.StringIO: it has `read` and `close` methods, as well as `buf`, `pos` and `len` attributes.
The input data is a string of bytes, and the output tokens are ascii-decoded unicode strings.
(I removed "__main__" as it was using a non-py23 EasyDialogs module)
See https://github.com/behdad/fonttools/issues/393.
Related to https://github.com/behdad/fonttools/issues/391.
Also removing unused stats collection. The need for setting up
an object to collect these (unused) stats made it hard to write
tests on code that called OTTableReader.getSubReader().
NameRecord.__str__ returns a unicode string, but on Python2 the built-in str()
expects a bytestring, therefore it raises
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
We should probably change that as well.
If the referenced name record already exists, the string is modified in place.
If it doesn't exist, a new record is created with the given IDs and string.
If nTracks == 0, nSizes is also == 0, the `else` part is sufficient.
There's a limit case when nTracks can be > 0, and nSizes == 0, but it's
unlikely or useless.
The current argument parser in subset.py must strip out spaces in values,
in order to allow specifying comma- or whitespace-separated lists (for
example, cf. [line 2289](https://github.com/behdad/fonttools/blob/master/Lib/fontTools/subset.py#L2289))
Because of that, users cannot correctly specify table tags whose length
is less than 4 by enclosing the space in quotes.
For example, 'SVG ' table will be alwyas dropped even if I pass
`--drop-tables-='SVG '` and `--no-subset-tables+='SVG '`.
As a workaround, this patch removes the spaces from the 'SVG ' and 'cvt '
tags in the constant lists of the Option class, and it only tests that
`tag.strip()` is contained in those list.
Of course, this also means `--drop-tables-='SVG '` is now the same as
`--drop-tables-='SVG' as far as the subsetter is concerned.
Fixes https://github.com/behdad/fonttools/issues/376
Related https://github.com/behdad/fonttools/issues/265
This should make the unit tests more readable, and it also prevents
failures where a changed fromXML() implementation fails to ignore
interspersed whitespace. This has recently caused some developer
nuisance; see https://github.com/behdad/fonttools/pull/367.
Instead of having a custom parser implementation, it would be nicer
to call the actual XMLReader. However, XMLReader has a deeply built-in
assumption that it is processing an entire TTX file. Changing this
assumption would certainly be possible, but it would need a re-write
of the XMLReader code; having a custom parser just for unit tests
seems less involved.
Resolves https://github.com/behdad/fonttools/issues/355
For making sure that `pyftsubset` still works after this change,
I have done the following steps:
* invoked Adobe's `makeotf` tool to build a custom font with a
MultipleSubst lookup. This lookup decomposes two two ligatures,
`c_t` and `f_f_i`, into their respective components.
* invoked the `pyftsubset` tool to produce a subset font with just
the `c_t` ligature;
* checked with `ttx` that the newly produced subset font contains
the requested `c_t` ligature and its components `c` and `t`,
but does not contain not any of `f_f_i`, `f`, or `i`.