1212 Commits

Author SHA1 Message Date
Sascha Brawer
31b02d0bed [AAT] Support morx tables with Rearrangement subtables 2017-09-04 21:26:53 +02:00
Sascha Brawer
49fc88244b [AAT] Write AATLookups to XML in alphabetical order again
The XML output for other tables is also sorted alphabetically
by glyph name, not by glyph order.

This reverts commit c77e9fe12d5879aeb79c05f8ececebb3275524b7.
2017-09-01 15:56:21 +02:00
Sascha Brawer
c77e9fe12d [AAT] Write AATLookups to XML in glyph order
Before this change, the AAT lookups were alphabetically sorted by glyph name,
but it seems more natural to write XML in the usual glyph order. No changes to
the binary format (which already was in glyph order); this only affects how
XML output is produced.
2017-08-31 17:50:45 +02:00
Sascha Brawer
92124ee5a6 [AAT] Implement anchor point table
The AAT `ankr` anchor point table is an auxiliary table for `kerx`,
used to store anchor overrides in case the glyph itself does not
supply the needed anchors as control points. Among the fonts that
come pre-installed with MacOS 10.12.6, `ankr` is used by a handful
of non-Latin fonts such as “Myanmar MN”, “Devanagari Sangam MN”,
and “Arial HB”.

https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
2017-08-31 11:45:18 +02:00
Sascha Brawer
90f257cc60 [AAT] Support mort and morx tables with non-contextual substitutions
Other metamorphosis types are not yet supported and will raise an error
upon decompilation. The TTX tool catches the error and continues to emit
a hexdump of the table contents, just as before this change.
2017-08-30 14:46:34 +02:00
Sascha Brawer
7bb171ed4a [AAT] Do not assume that StructWithLength is always 32 bits long
Most AAT tables encode struct lengths into 32 bits but some use only 16.
Therefore, take the size of the encoded struct length from otData.
2017-08-29 09:49:39 +02:00
Sascha Brawer
5d8a9df7fb [AAT] Make StructLength a computed value 2017-08-29 09:34:25 +02:00
Sascha Brawer
13fe9b5c34 [AAT] Make lcar ligature carets table a format-switching table
For consistency with other AAT tables, and to support additional
formats in the (rather unlikely) case those would ever be defined.
2017-08-25 14:53:43 +02:00
Sascha Brawer
f5793401ce [AAT] Implement bsln baseline table
The AAT baseline table uses arrays whose length is constant instead of
getting encoded in the data. Extended otBase to support such arrays.
2017-08-25 03:55:06 -07:00
Sascha Brawer
61d2cde14a [AAT] Add comments to explain why we call seek() on subreader
https://github.com/fonttools/fonttools/issues/1031
2017-08-19 20:41:43 -07:00
Sascha Brawer
2f69d2959c [AAT] Fix decompilation of AppleChancery and other AAT fonts
Fixes https://github.com/fonttools/fonttools/issues/1031.
2017-08-19 20:41:43 -07:00
Sascha Brawer
a47f658855 [AAT] Support the opbd table with optical bounds
Interestingly, this can handle the examples from the AAT specification
(which are part of the unit tests), and also most AAT fonts on my disk.
However, some other AAT fonts such as Apple Chancery cannot be decompiled.
The failure seems to be a general problem with how fonttools decompiles
AAT lookups of format 4, and unrelated to this present change.
2017-08-18 08:39:44 -07:00
Cosimo Lupo
1aef1683df [otConverters] must also implement _LazyList.__radd__
We can't set, e.g. `__radd__ = NotImplemented` as it's not a callable.
NotImplemented is what is returned from a rich comparison method
when self doesn't know how to compare with the other object.

_LazyList object may also occur on the right hand side of a `+`
operator, when the left operand is a list. Also in this case we
want to first unpack the _LazyList and return a new list containing
elements from both.
2017-08-18 15:53:56 +01:00
Behdad Esfahbod
6ef48bd26f [ot] Make LazyList return regular lists in __add__ 2017-08-17 11:32:13 -07:00
Sascha Brawer
d05617b4bd [AAT] Support prop table with glyph properties 2017-08-17 11:09:53 -07:00
Cosimo Lupo
a1c2cf1137 [TupleVariation] write axis coord values as float in toXML()
https://github.com/fonttools/fonttools/pull/1026#pullrequestreview-56807115
2017-08-17 11:13:00 +01:00
Cosimo Lupo
ed0d09be22 Merge pull request #1026 from anthrotype/avar-tests
[varLib] add tests for avar; always include default maps
2017-08-17 11:12:37 +01:00
Behdad Esfahbod
03cf8fc157 Fix hhea/vhea compile with metrics tables 2017-08-16 16:42:59 -07:00
Sascha Brawer
d11e7d98e8 [AAT] Support lcar table 2017-08-16 11:47:27 -07:00
Sascha Brawer
ff7cf27777 [AAT] Fix binary search headers of AATLookup formats 2 and 6
In format 2 and 6, AAT lookups contain a binary search header with
the number of elements in the lookup table. Before this change, the
element count would also include the special trailing end-of-table
value that is required by the font format specification.  However,
the binary search header should only count the actual elements
without the trailer.

Also, in the examples from the AAT specification, the special
end-of-table entries use 0xFFFF for glyph ID keys, and zeroes
for the filler values. Before this change, we had filled the
values with 0xFF bytes.
2017-08-16 19:43:25 +02:00
Cosimo Lupo
9a49610d9a [_a_v_a_r] normalize output of toXML() by roundtripping float->fixed->float
Otherwise dumping avar table to TTX after it's been generated by
varLib could produce different float strings than when dumping the
same avar table after compiling and decompiling.
2017-08-16 18:33:55 +01:00
Sascha Brawer
77876e8df4 [AAT] Add table definitions for lcar table
After this change, fonttools is able to dump the `lcar` table of
the AppleChancery font to XML. However, the resulting XML cannot
be compiled back to TrueType, yet. So, something is still broken
with the implementation of AAT lookups. Need to do more testing
before the support for table `lcar` can be added to fonttools.
2017-08-16 02:42:55 +02:00
Sascha Brawer
49ee69b401 [AAT] Store value converter as a member variable of AATLookup 2017-08-15 23:40:47 +02:00
Sascha Brawer
4cf76edd87 [AAT] Delegate XML reading and writing to value class converter
Before this change, the code assumed that all values of AAT lookups
get internally represented as strings, which is correct for GlyphID
values but not generally the case.

Also renaming the XML element from `Substitution` to `Lookup`
because AAT lookups have other uses beyond glyph substitutions.
2017-08-15 19:40:50 +02:00
Sascha Brawer
228550a1d2 [AAT] Do not prune AATLookup values
Before this change, the decoder would silently remove "redundant" values
when decompiling AAT lookups. However, it is perfectly valid for a lookup
to map a glyph ID to itself, and also not all AAT lookups have glyph IDs as
their value range.
2017-08-15 18:33:57 +02:00
Behdad Esfahbod
8b4f0bb1e4 [morx] Write StructLength properly
Code looks like a hack, but is solid.
2017-08-14 12:34:56 -07:00
Behdad Esfahbod
338374e170 [morx] Minor 2017-08-14 12:34:56 -07:00
Sascha Brawer
7ee4fc8896 [morx] Remove morx table from table list
Temporarily removing the `morx` table from the table list so that
the rest of the AAT work can be merged into master.
2017-08-14 21:34:15 +02:00
Sascha Brawer
020f7391ef [morx] Parametrize AATLookup value type in otData 2017-08-14 21:34:15 +02:00
Sascha Brawer
e8f21cb571 [morx] Parametrize AATLookup.read() for different value types 2017-08-14 21:34:15 +02:00
Sascha Brawer
ce5d9de936 [morx] Pass font to format-specific AATLookup.read() methods
To use self.valueConverter.read(), we will need to pass the font.
2017-08-14 21:34:15 +02:00
Sascha Brawer
191c620951 [morx] Parametrize AATLookup.write() for different value types 2017-08-14 21:34:15 +02:00
Sascha Brawer
61874d3600 [morx] Generalize AATLookup to other value types
With AAT, the same lookup data structure can be used for various
types of values. In the morx table, the values are glyph IDs or
glyph classes, which both are encoded as 16-bit unsigned integers.
In other AAT tables, however, the values can be different data types
with different encodings. By passing a `valueWriter` callback and
explicit `valueSize`, we prepare for eventually templatizing
the building of AATLookups.

Also, assert that the called writer wrote the exact number of bytes
that was predicted when figuring out what format should be used for
encoding an AATLookup.
2017-08-14 21:34:15 +02:00
Sascha Brawer
7f2007f46c [morx] Write AATLookup format 8 2017-08-14 21:34:15 +02:00
Sascha Brawer
91827e663f [morx] Write AATLookup format 2 2017-08-14 21:34:15 +02:00
Sascha Brawer
bdf29b4169 [morx] Separate building from writing lookup tables
For AAT lookup format 2 (and other formats too), we need to shuffle
the data before we can estimate the encoded size. After this restructuring,
this data shuffling only needs to happen once.
2017-08-14 21:34:15 +02:00
Sascha Brawer
68dc15375b [morx] Fix output for AATLookup format 6
We now produce the correct binary search headers, and add a fake item
for terminating the binary search.
2017-08-14 21:34:15 +02:00
Sascha Brawer
57f01b27cb [morx] Preliminary code for writing AATLookups
Needs more work.
2017-08-14 21:34:15 +02:00
Behdad Esfahbod
f188187b08 [morx] Implement StructWithLength.write() 2017-08-14 21:34:15 +02:00
Sascha Brawer
4b5b8ea53d [morx] Implement AATLookup.xmlRead 2017-08-14 21:34:15 +02:00
Sascha Brawer
b40ba05f6f [morx] Group AATLookup substitutions into a parent XML element 2017-08-14 21:34:15 +02:00
Behdad Esfahbod
75b0eaa5bb [morx] Fix SubStruct xmlWrite() 2017-08-14 21:34:15 +02:00
Sascha Brawer
7f774ae84c [morx] Change MorphType to uint8, to comply with the spec 2017-08-14 21:34:15 +02:00
Sascha Brawer
b00e2dfec4 [morx] Recognize MorphType as another type of lookup
Currently, this makes no difference at all. Later, we'll use this
for dispatching AAT lookup types in the same way how we already
dispatch OpenType lookup types.
2017-08-14 21:34:15 +02:00
Sascha Brawer
f56b71937d Add missing parts from morx branch
After this change, the `morx` table in Zapfino.ttf can be ttx'ed again.
2017-08-14 21:34:15 +02:00
Sascha Brawer
483bb67b60 Rebase morx branch to current master 2017-08-14 21:34:15 +02:00
Masaya Nakamura
3708f2c8d3 Don't cache charString bounds
https://github.com/fonttools/fonttools/pull/970#discussion_r117903692
2017-08-01 10:54:47 +09:00
Masaya Nakamura
68c7275945 [hhea,vhea] Refactor 2017-08-01 10:53:28 +09:00
Masaya Nakamura
69199b3225 [hhea,vhea] Ensure charString has bounds 2017-08-01 10:53:27 +09:00
Masaya Nakamura
1b773c17d7 [hhea,vhea] Fix advance{Width,Height}Max calculations
Before this commit, empty glyphs were wrongly ignored.
2017-08-01 10:51:48 +09:00