979 Commits

Author SHA1 Message Date
Sascha Brawer
c5d6c6f58a Merge pull request #381 from anthrotype/trak
[trak] add AAT 'trak' table support
2015-10-01 14:43:43 +02:00
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
f8e59445c1 [woff2] minor 2015-09-09 12:16:49 +01: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
Cosimo Lupo
ed03d57170 [woff2] make dummy glyphOrder based on gids when decompiling glyf table
Using TTFont.getGlyphOrder() would also require to decompile post and cmap tables.
But we don't need the actual glyph names in order to apply the WOFF2 glyf transform.
2015-09-08 17:01:59 +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
Cosimo Lupo
ef71757a42 [woff2] cache reconstructed glyf data if requested to reconstruct loca before glyf 2015-08-19 22:58:17 +01:00
Cosimo Lupo
ef7310a293 [woff2_test] assert glyf isn't reconstructed twice if loca is accessed before 2015-08-19 22:55:24 +01:00
Cosimo Lupo
18d02aece9 [ttLib] convert KeyView object to list for py23 compatibility 2015-08-19 17:57:37 +01:00
Cosimo Lupo
3142e3319e add reordersTables() method to SFNTWriter and WOFF2Writer (return True for the latter) 2015-08-19 17:56:46 +01:00
Cosimo Lupo
1a34f0bd38 [woff2_test] no need to reorder tables when saving test WOFF2 fonts
the WOFF2 encoder currently must reorder them alphabetically in any case (for compatibility with the legacy OTS), so we don't need to do it twice
2015-08-19 17:00:43 +01:00
Cosimo Lupo
ebb64da7c0 [woff2_test] fix test failing in py3 2015-08-19 16:40:45 +01:00
Cosimo Lupo
4c8960bb9a [woff2_test] use OrderedDict like sfnt module 2015-08-19 16:36:32 +01:00
Cosimo Lupo
f083209590 [woff2] use OrderedDict like sfnt module 2015-08-19 16:36:03 +01:00
Cosimo Lupo
4fe88a41f3 [TTFont] fix reorderTable logic 2015-08-19 15:47:07 +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
6ba67ab699 [TTFont] changed behaviour of 'reorderTables' argument of save function
Reorder to OT spec recommended order if reorederTables == True (default).
Don't reorder if reorderTables == None.
Keep the input font original table order if reorderTables == False (and
the font has a reader object from which to get the original order).
2015-08-19 14:36:58 +01:00
Cosimo Lupo
099c260b36 [sfnt] use OrderedDict for SFNT{Reader,Writer}.tables dictionaries 2015-08-19 14:36:51 +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
f7064535ba [woff2_test] rename py3 deprecated 'assertRaisesRegexp' to 'assertRaisesRegex' 2015-08-11 17:47:17 +01:00
Cosimo Lupo
77b1a4aa8e rename 'test_data' folder to 'testdata' so it matches #334 2015-08-11 16:31:09 +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
2a713bfd79 [woff2/woff2_test] replace 'StringIO' with 'BytesIO' 2015-08-07 18:23:55 +01:00