995 Commits

Author SHA1 Message Date
Behdad Esfahbod
5a08924075 Add high-level API for LigatureSubst
Ala MultipleSubst and AlternateSubst.  For now, just support compiling it.
2015-12-07 12:01:42 +01:00
Behdad Esfahbod
505c1a5ea7 Fixup previous change
ecbe8f2c37 (commitcomment-14464749)
2015-11-18 00:08:49 -08:00
Behdad Esfahbod
ecbe8f2c37 Fix decompile of Neirizi 2015-11-17 23:24:03 -08:00
Cosimo Lupo
8019069f7c [sfnt] make SFNTReader.tables an OrderedDict sorted by table offset
Fixes https://github.com/behdad/fonttools/issues/408
2015-11-13 17:38:50 +00:00
Cosimo Lupo
49d929681e [_p_o_s_t] remove max indices "reserved for future use"
the third (2015) edition of ISO/IEC 14496-22 "Open Font Format" increased
the limit from 32767 to 65535 (and thus eliminated the reserved numbers).

`array.array` will take care of raising the right `OverflowError` exception
so we don't need any further checking.
2015-11-10 00:11:28 +00:00
James Godfrey-Kittle
f5b9ec0186 [TTGlyphPen] Add a new e2e test 2015-11-05 14:11:51 -08:00
Behdad Esfahbod
d6e186d40f Simplify AlternateSubst slightly 2015-10-27 14:11:04 -07:00
Cosimo Lupo
f41838edfe [macUtils] use macRes.ResourceReader to read 'sfnt' resources 2015-10-26 04:40:04 +00:00
Cosimo Lupo
d7f6e1df00 [ttLib] remove 'haveMacSupport' flag, allow other platforms to read sfnt resources (from data fork)
On non-Mac filesystems the resource fork is absent.
2015-10-26 03:34:03 +00:00
Cosimo Lupo
e1e2178a52 [ttLib] drop support for pre-OSX "mac" platform
- only check for 'darwin' for 'haveMacSupport'
- remove 'makeSuitcase' arg from TTFont.save();
- don't setMacCreatorAndType
2015-10-25 14:42:43 +00:00
Sascha Brawer
d8d5ab2c29 Test OTTableReader.getSubReader()
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().
2015-10-18 00:09:32 +02:00
Sascha Brawer
582852119c Implement OTTableReader.readUShortArray()
There is currently only one single call site in the codebase,
but this function will be needed a lot for parsing `morx` and
other AAT tables.
2015-10-17 06:47:52 +02:00
Behdad Esfahbod
29cc978f43 Improve assertion message 2015-10-15 20:01:56 -03:00
Sascha Brawer
520918375f [otTables] Support uint8 type in otTables 2015-10-16 00:17:22 +02:00
Sascha Brawer
1288a58eb1 Test core functions of OTTableReader and OTTableWriter 2015-10-16 00:05:52 +02:00
Sascha Brawer
b5e29cca9a [GSUB] Parse old-syntax MultipleSubst that has no index attribute
Apparently, earlier versions of TTX had produced XML whose
MultipleSubst.Sequence element came without an index attribute.
Resolves https://github.com/behdad/fonttools/issues/385
2015-10-13 17:44:53 +02:00
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