895 Commits

Author SHA1 Message Date
Cosimo Lupo
12bde8e97a [_n_a_m_e_test] use toUnicode() instead of built-in str() for py2 compat
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.
2015-10-01 11:41:46 +01:00
Cosimo Lupo
898199f2bc [_n_a_m_e_test] add test_setName test case 2015-10-01 10:12:29 +01:00
Cosimo Lupo
a0a400d9c1 [name] add setName method to table__n_a_m_e
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.
2015-10-01 10:11:48 +01:00
Cosimo Lupo
d20dec29db [trak] remove redundant if-else block
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.
2015-10-01 09:29:04 +01:00
Cosimo Lupo
4f5419fdec [ttLib] add _t_r_a_k to list of available tables 2015-09-30 20:19:35 +01:00
Cosimo Lupo
380104c228 [_t_r_a_k_test] add tests for trak table 2015-09-30 20:19:35 +01:00
Cosimo Lupo
4eb134f5e4 [trak] add AAT 'trak' table support 2015-09-30 20:16:47 +01:00
Sascha Brawer
a596845801 [ltag] Use tobytes() instead of string.encode("ascii")
Addresses review comment 7f70a79fc8 (commitcomment-13471742)
2015-09-28 17:25:01 +02:00
Sascha Brawer
3182162cbe Merge pull request #379 from moyogo/meta
meta table: 'dlng' and 'slng' data is text
2015-09-25 08:12:20 +02:00
moyogo
2917e34dcb meta: test 'dlng' and 'slng' 2015-09-24 17:03:40 +01:00
moyogo
dc65ccfb27 meta: text 'should be' utf-8 2015-09-24 17:03:34 +01:00
moyogo
0ba22c0ba2 meta: add test for text data 2015-09-24 11:00:42 +01:00
Cosimo Lupo
cef10ec654 [ttProgram] if can't disassemble bytecode, warn and dump toXML as it is
Fixes https://github.com/behdad/fonttools/issues/347
2015-09-24 09:32:49 +01:00
moyogo
95059ebdee meta: handle dlng and slng as text 2015-09-21 19:48:41 +01:00
Sascha Brawer
2bd315c49b Use XML snippets in all unit tests for fromXML() methods 2015-09-11 17:11:25 +02:00
Sascha Brawer
d63885e337 [otTables] Use XML snippets for testing fromXML() methods
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.
2015-09-11 15:44:29 +02:00
Cosimo Lupo
258bd6d8f3 [otTables] skip if element is not tuple when parsing MultipleSubst XML
the content of XML elements can be strings as well as (name, attrs, content)
tuples, so we can't use list comprehension here
2015-09-11 11:41:14 +01:00
Sascha Brawer
96da5a0f71 Support TTX format for MultipleSubst of FontTools 3.0 and earlier
Fix a backwards compatibility problem introduced by
1356a6775b
(pull request https://github.com/behdad/fonttools/pull/364), where new versions
of FontTools would not be able to process `<MultipleSubst>` elements
in TTX files generated by older FontTools releases.

Resolves https://github.com/behdad/fonttools/issues/355.
2015-09-11 08:19:20 +02:00
Sascha Brawer
1356a6775b [otTables] Simplify API for MultipleSubst
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`.
2015-09-10 14:56:07 +02:00
Sascha Brawer
8d8288a862 [otTables] Add unit tests for SimpleSubst, LigatureSubst and AlternateSubst 2015-09-10 10:05:23 +02:00
Sascha Brawer
044ea07863 Merge pull request #358 from brawer/ltag
Build ltag table also with Python 2.7
2015-09-09 20:32:22 +02:00
Sascha Brawer
7f70a79fc8 Build ltag table also with Python 2.7
Before this change, TTX (when running in Python 2.7) would fail
to compile a font if the input contained an `ltag` section.
With Python 3, it worked perfectly fine even before this change.

Resolves https://github.com/behdad/fonttools/issues/357
2015-09-09 20:24:08 +02:00
Cosimo Lupo
df06ce4981 [otConverters] use enumerate in writeArray, as sets don't support indexing
the feaLib parser returns glyph classes as set objects
2015-09-09 18:16:44 +01:00
Sascha Brawer
5f5b07b8d7 Merge pull request #349 from brawer/glyphnames-beyond-bmp
Support non-BMP characters for synthetic glyph names
2015-09-09 15:03:06 +02:00
Cosimo Lupo
563f32f877 [glyf] add 'padding' attribute to glyf table; assert is in (0, 1, 2, 4)
The default (1) keeps the current behaviour (i.e. only pad when we can
use short offsets). Optional values are 0 (no padding), 2 and 4.
2015-09-09 11:15:26 +01:00
Sascha Brawer
f38cc9f821 Write XML for alternate glyphs (GSUB lookup type 3) in deterministic order
Before this change, the XML output for GSUB lookups of type 3
was not deterministic; multiple runs of TTX on the same font
could therefore emit the alternates in a different order.

Since alternate glyphs are sets, this change makes no semantic
difference to the output. However, a deterministic ordering
is needed for tests that compare GSUB tables in TTX format.
2015-09-07 11:21:17 +02:00
Sascha Brawer
07458f62dd Support non-BMP characters for synthetic glyph names
When a font supplies no glyph names in its 'post' table, fontTools
builds synthetic glyph names by reversing the 'cmap' table.
After this change, the library looks at all 'cmap' subtables for
Unicode, irrespective of format or platform. For example, glyph #4
in NotoSansOldItalic-Regular.ttf gets now named "u10300" instead of
"glyph00004".

Moved the code for building a reversed 'cmap' table into the cmap class,
for easier testing.
2015-09-04 12:20:54 +02:00
Behdad Esfahbod
89f0c0ce7f Speed up hdmx loading by using custom glyphnamed-list
The data-structure can be used in more places, but it's most beneficial in
this table since hdmx tables can have tens of ppem's, each having a dictionary
keyed by glyphnames...
2015-08-23 20:40:51 +01:00
Behdad Esfahbod
9aed8e1e9d Merge pull request #270 from anthrotype/woff2_14
implement WOFF2 encoder/decoder as standalone module
2015-08-19 15:33:44 +01:00
Cosimo Lupo
4d6a94dfaa [_v_h_e_a] don't recalc vertical bounds if recalcBBoxes == False 2015-08-17 10:23:03 +01:00
Cosimo Lupo
915b8c303a Merge pull request #332 from miguelsousa/mixed_indents
fix "indentation contains mixed spaces and tabs" errors reported by Landscape
2015-08-09 13:21:30 +01:00
Miguel Sousa
d28a942683 fix two misc errors reported by Landscape 2015-08-09 00:40:31 -07:00
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Cosimo Lupo
77ffbab995 [glyf] pad glyph data upon compile if self has attribute 'padding' 2015-08-07 18:23:41 +01:00
Cosimo Lupo
bf0e336d31 replace all 'StringIO' with 'BytesIO' 2015-08-07 17:25:22 +01:00
Cosimo Lupo
4bfbdc8852 [xmlReader] initialise OTTableWriter instance with self.longOffset = False
Fixes https://github.com/behdad/fonttools/issues/323
2015-07-24 15:55:58 +01:00
Sascha Brawer
48cfcb076f Add ‘meta’ to the list of supported tables 2015-07-03 15:13:04 +02:00
Sascha Brawer
3a6e5aca55 Merge pull request #315 from brawer/meta
Implement Apple’s “meta” table
2015-07-03 11:43:27 +02:00
Sascha Brawer
11d3770ca6 Implement Apple’s “meta” table
Because I could not find any fonts with “dlng” (design languages) or
“slng” (supported languages) sub-tables, these are not implemented yet.
We could easily implement them according to spec, but it is unclear
to what extent the spec is matching reality.
2015-07-03 11:36:50 +02:00
Behdad Esfahbod
c7187c3b20 Optimize reading array of GlyphIDs 2015-07-03 01:15:16 -07:00
Behdad Esfahbod
7d38ebb143 Minor 2015-07-03 01:01:10 -07:00
Behdad Esfahbod
0097e40ced Minor 2015-07-03 00:55:54 -07:00
Behdad Esfahbod
089241a587 Minor 2015-07-03 00:53:15 -07:00
Behdad Esfahbod
a7e9d634d7 Minor 2015-07-03 00:50:34 -07:00
Behdad Esfahbod
1fbbbdd358 Micro-optimization for previous commit 2015-07-03 00:49:28 -07:00
Behdad Esfahbod
754a20d987 Implement lazy array for loading otData-driven arrays
Speeds up subsetting of GPOS table with many pairs by huge factor
(counted 5).
2015-07-02 18:00:41 -07:00
Behdad Esfahbod
92093990cc [ot] Minor 2015-07-02 15:01:20 -07:00
Behdad Esfahbod
aa9b3b6d43 [ot] Add readArray() and writeArray()
To be used soon to optimize partial / glyph array loading.
2015-07-02 15:01:15 -07:00
Behdad Esfahbod
64f1179230 Minor moving code around in prep for optimization work 2015-07-02 15:01:11 -07:00
Sascha Brawer
db1773af5d Remove redundant line
It should have been removed in #4792d7419cd44a6fb3988b760b87dcb494db8488
2015-07-01 12:21:07 +02:00