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