122 Commits

Author SHA1 Message Date
Behdad Esfahbod
e2299a16b0 [otBase] Minor
Part of fixing https://github.com/behdad/fonttools/issues/518
2016-03-12 20:42:16 -08:00
Behdad Esfahbod
407c246433 [otBase] Minor renamings
Part of fixing https://github.com/behdad/fonttools/issues/537
2016-03-12 20:42:13 -08:00
Behdad Esfahbod
c02ced3393 [otBase] Minor
Part of fixing https://github.com/behdad/fonttools/issues/537
2016-03-12 20:42:08 -08:00
Behdad Esfahbod
6b46d8e553 [otBase] Move code around
Part of fixing https://github.com/behdad/fonttools/issues/537
2016-03-12 20:42:05 -08:00
Behdad Esfahbod
4b94fd55cb Simplify overflow handling code
The code that is being removed is untested and does not seem to make
fixing an overflow any easier.  The fixer code just needs to know
which subtable caused the overflow and does not care about the item
within.  As such, no point in trying to find a "right" item.

In fact, leaving item as is, is more useful in debugging overflows
as it reflects which item's offset actually overflowed.

Part of fixing https://github.com/behdad/fonttools/issues/537
2016-03-12 20:11:34 -08:00
Cosimo Lupo
d82a31dd57 return NotImplemented from __ne__ if __eq__ returns NotImplemented
otherwise `not NotImplemented` (always False) is returned from __ne__ when `type(self) != type(other)`, leading to illogic results like:

>>> from fontTools.ttLib.tables.DefaultTable import DefaultTable
>>> t = DefaultTable('test')
>>> t == 0
False
>>> t != 0
False

The latter of course should return True.
2016-03-11 15:10:50 +00:00
Behdad Esfahbod
a0d6ab6a07 [ttLib] Fix bug in OTLOffsetOverflowError generation
Part of fixing https://github.com/behdad/fonttools/issues/537

Now on to fixing the actualy overflow.
2016-03-04 06:06:33 -08:00
Behdad Esfahbod
d87d6aa39e [ot] Make sure GSUB/GPOS top arrays don't share bytes
Fixes https://github.com/behdad/fonttools/issues/518
Fixes https://github.com/behdad/fonttools/issues/372
2016-02-10 18:00:48 +07:00
Behdad Esfahbod
0baeb5921b [otBase] Shuffle 2016-02-10 17:26:53 +07:00
Behdad Esfahbod
f65fc6f872 [otBase] Simplify _doneWriting() slightly
Should have NO functional change.
2016-02-10 17:03:46 +07:00
Dave Crossland
17007a36d6 otBase.py log level adjustment
Change log level of 'Attempting to fix OTLOffsetOverflowError' from warning to debug to close #499
2016-02-02 10:06:10 -05:00
Cosimo Lupo
10bf8ecd85 [otBase] replace print with logger 2016-01-27 19:02:48 +00:00
Behdad Esfahbod
f65f7bbe2b [otBase] Output object index for arrays, when exception occurs
Ie, now we get:
...
    assert 0 <= value < 0x10000, value
AssertionError: (None, 'LookupListIndex', 'SubstLookupRecord[0]', 'ChainContextSubst[1]', 'Lookup[3]', 'LookupList')
2016-01-23 21:30:45 +01:00
Behdad Esfahbod
1fbad696c9 Print out object hierarchy, when an Exception happens while compiling otData tables
The common stacktrace like this:

  File "fonttools/Lib/fontTools/ttLib/__init__.py", line 202, in save
    self._writeTable(tag, writer, done)
  File "fonttools/Lib/fontTools/ttLib/__init__.py", line 631, in _writeTable
    tabledata = self.getTableData(tag)
  File "fonttools/Lib/fontTools/ttLib/__init__.py", line 644, in getTableData
    return self.tables[tag].compile(self)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 86, in compile
    self.table.compile(writer, font)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 681, in compile
    conv.write(writer, font, table, value)
  File "fonttools/Lib/fontTools/ttLib/tables/otConverters.py", line 354, in write
    value.compile(subWriter, font)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 661, in compile
    conv.write(writer, font, table, value, i)
  File "fonttools/Lib/fontTools/ttLib/tables/otConverters.py", line 354, in write
    value.compile(subWriter, font)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 661, in compile
    conv.write(writer, font, table, value, i)
  File "fonttools/Lib/fontTools/ttLib/tables/otConverters.py", line 354, in write
    value.compile(subWriter, font)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 661, in compile
    conv.write(writer, font, table, value, i)
  File "fonttools/Lib/fontTools/ttLib/tables/otConverters.py", line 277, in write
    value.compile(writer, font)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 681, in compile
    conv.write(writer, font, table, value)
  File "fonttools/Lib/fontTools/ttLib/tables/otConverters.py", line 175, in write
    writer.writeUShort(value)
  File "fonttools/Lib/fontTools/ttLib/tables/otBase.py", line 457, in writeUShort
    assert 0 <= value < 0x10000, value
AssertionError: None

now has this as the last line:

AssertionError: (None, 'LookupListIndex', 'SubstLookupRecord', 'ChainContextSubst', 'Lookup', 'LookupList')

which means a value of None was tried for writing a LookupListIndex from a ChainContextSubset...

It's a hack, but a very useful one.
2016-01-23 14:20:33 +01:00
Behdad Esfahbod
501480fa70 Revert "[ot] Instead of deleting unnecessary Format, set it to None"
This reverts commit 6851f66d1810a4d3f484f2a82e39960e1a677f42.

See https://github.com/typesupply/compositor/issues/7
Fixes https://github.com/behdad/fonttools/issues/475
2016-01-22 14:03:23 +01:00
Behdad Esfahbod
8a17e925bf Revert "[ot] Deprecate, and add properties for, count values"
This reverts commit d8803873f6d4efbcb227867fe0ac6bca370597bc.

The commit wasn't fully correct as it was not installing properties
for counts in format-switching subtables.
2016-01-14 12:55:42 +00:00
Behdad Esfahbod
d8803873f6 [ot] Deprecate, and add properties for, count values
Part of fixing https://github.com/behdad/fonttools/issues/447

Our own modules still set the counts.  Will fix in subsequent
commits.
2016-01-14 12:33:09 +00:00
Behdad Esfahbod
6851f66d18 [ot] Instead of deleting unnecessary Format, set it to None
Fixes https://github.com/typesupply/compositor/issues/7
2016-01-14 10:47:48 +00:00
Behdad Esfahbod
e0d27461be [XML] Assume None where an attribute is missing
This is what the compile() does, so do the same in toXML(), such that
we can save to XML whatever can be saved to binary.  Eg. saving what
we read through XML!

Fixes https://github.com/behdad/fonttools/issues/298
Also relevant to https://github.com/behdad/fonttools/issues/447
2016-01-13 19:05:45 +00:00
Behdad Esfahbod
d992180f1a [otTables] Fix device names after f0eb7e98ca0642f17ac82433db8c957fffd6a9d3 2016-01-13 17:19:29 +00:00
Behdad Esfahbod
f0eb7e98ca [otTables] Don't create a subclass for equivalent types
Before, equivalent types, eg. otTables.BacktrackCoverage, etc,
where a subclass of their equivalent parent type, eg. otTables.Coverage
With this change, they are the same type.

The otBase and otConverters changes were needed to make the above
happen and still generate correct XML for SubTable type.
2016-01-13 16:44:52 +00:00
Behdad Esfahbod
6c4d14dbce Enable writing of Count values that are never set
This can happen with empty MarkMark / MarkBase tables.
2015-12-08 20:41:54 +01:00
Behdad Esfahbod
5133e3777e Undo accidentally commit changes 2015-12-07 15:15:51 +01:00
Behdad Esfahbod
c65c16d3f6 Fix previous commit
Humm, no idea how I had committed it locally before.
2015-12-07 12:05:24 +01: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
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07: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
Behdad Esfahbod
c7187c3b20 Optimize reading array of GlyphIDs 2015-07-03 01:15:16 -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
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
Behdad Esfahbod
b30e12ae00 More whitespace 2015-04-26 02:01:01 -04:00
Behdad Esfahbod
bd67253118 Some more whitespace fixes from pep8 tool 2015-04-26 01:59:01 -04:00
Behdad Esfahbod
1ae29591ef from __future__ import absolute_import
Such that our Python 2 is closer to Python 3.

Part of https://github.com/behdad/fonttools/issues/77
2014-01-14 15:07:50 +08:00
Behdad Esfahbod
95f795f40a Move offset overflow fixing logic where it belongs 2013-12-20 21:52:28 -05:00
Behdad Esfahbod
b76d6ff14a [merge] Remove BaseTable.__hash__ need 2013-12-20 20:24:27 -05:00
Behdad Esfahbod
398770d51c [merge] Map GSUB/GPOS feature / lookup indices properly 2013-12-19 15:30:24 -05:00
Behdad Esfahbod
ee6340f475 Only track one parent per Writer
We were not using the extra parents anyway.
2013-12-17 06:31:37 -05:00
Behdad Esfahbod
ab0ca1bd6b Minor simplification 2013-12-17 06:19:15 -05:00
Behdad Esfahbod
6188b5b5f0 Remove unused variable 2013-12-17 06:11:41 -05:00
Behdad Esfahbod
dea08f2ba1 Minor optimization 2013-12-17 06:04:28 -05:00
Behdad Esfahbod
f6502635b9 Minor 2013-12-17 05:59:05 -05:00
Behdad Esfahbod
9e482332ba Fix subtable-split logic
Though, the split logic isn't implemented for GPOS, so I have not
been successful in actually exercising it so far.
2013-12-17 05:46:51 -05:00
Behdad Esfahbod
5fec22bfcd Compute correct LookupType when compiling font
Also ensures that all subtables of a lookup have the same
lookup type.
2013-12-17 02:42:18 -05:00
Behdad Esfahbod
dafdb2933a Further optimize table loading
Again, both faster and more memory efficient
2013-12-17 00:58:02 -05:00
Behdad Esfahbod
b4070bd629 Minor optimization of table loading
Is both faster and more memory efficient.
2013-12-17 00:44:33 -05:00