1026 Commits

Author SHA1 Message Date
Cosimo Lupo
769efc3d0d [ttLib] replace print statements with logger; deprecate 'quiet' and 'verbose' arguments; deprecate 'debugmsg' func
Previously, when TTX was run in verbose mode, the messages printed to the console would also show the time
each one was logged -- e.g. "blah blah  (15:23:24)" -- using the 'debugmsg' function which is defined here.
Even though the logging package would allow to do the same thing (via 'datefmt' and "%(asctime)s"), I decided
drop this, as I think it's not very interesting...
I'll replace it with the overall elapsed time in seconds, in a follow-up commit.
2016-01-27 19:01:12 +00:00
Cosimo Lupo
328c72f2d8 [OS/2 test] add tests for getUnicodeRanges, setUnicodeRanges and recalcUnicodeRanges 2016-01-27 18:38:32 +00:00
Cosimo Lupo
20d7849697 [OS/2] add Unicode ranges data from OT spec, plus methods to get/set bits manually, or recalc/prune automatically 2016-01-27 18:37:29 +00:00
Cosimo Lupo
81b290a47b [ttLib] raise if saving TTFont to the same input file when lazy is True 2016-01-25 10:21:09 +00:00
Cosimo Lupo
3f7c67ed50 [ttLib] skip reading the whole file in memory if lazy == True
As discussed in #482.
2016-01-25 10:06:52 +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
justvanrossum
56f863564e added GlyphCoordinatest().toInt() method; made compileCoordinates() actually work with float coords. 2016-01-20 19:23:16 +01:00
Cosimo Lupo
be489d07a6 _n_a_m_e: make NameRecord.__str__ call toStr with errors='backslashreplace'
the Python docs say that the return value of `__str__` must be a "string" object -- which means bytes in Python 2 and unicode in Python 3. Previously, str(namerecord) would always call 'toUnicode' method, even on Python 2.

https://docs.python.org/2/reference/datamodel.html#object.__str__

https://docs.python.org/3/reference/datamodel.html#object.__str__
2016-01-19 13:20:36 +00:00
Cosimo Lupo
818dd6ce1e _n_a_m_e: add toStr method to NameRecord
as discussed in https://github.com/typesupply/compositor/pull/10
2016-01-19 12:31:46 +00:00
Behdad Esfahbod
1ddfcee5a1 Minor simplification 2016-01-15 22:25:49 +01:00
Sascha Brawer
0f8882bcc3 [otlLib] Move creation of ValueRecords from feaLib to otlLib 2016-01-14 16:27:04 +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
Cosimo Lupo
0227945781 _t_r_a_k: do not import unicode_literals as it makes struct fail on some old Python 2.7.x
On the latest Python 2.7.10, struct accepts both unicode and str as 'fmt'.
However on Travis for py27 we use the built-in OSX Python, which on OSX 10.9 is Python 2.7.5.

Travis log: https://travis-ci.org/anthrotype/fonttools/jobs/96473892#L3010

Python issue: https://bugs.python.org/issue19099
2015-12-12 19:28:59 +00:00
Cosimo Lupo
8bc30bc4d2 ttLib.__init__: replace '>>>' with '>>' in docstring to avoid triggering pytest doctests discovery
the docstring references an example 'afont.ttf' file which obviously doesn't exist.
2015-12-12 18:11:59 +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
Cosimo Lupo
9f6055d5d9 Merge pull request #427 from anthrotype/recalc-bbox-expand
_g_l_y_f: expand glyphs inside `compile` if recalcBBoxes==True
2015-12-08 13:08:40 +00:00
Cosimo Lupo
9049d5f866 Merge pull request #425 from anthrotype/xmlreader-fileobj
make XMLReader accept file objects
2015-12-08 13:08:19 +00:00
Cosimo Lupo
738866492d _g_l_y_f: expand glyphs inside compile if recalcBBoxes==True; delete empty self.data lingering around
Fixes https://github.com/behdad/fonttools/issues/410.

See also:
ecbe8f2c37 (commitcomment-14464893)
2015-12-08 09:35:00 +00:00
Ben Kiel
e53d2068ca Update doc
Added text for woff2
2015-12-07 13:26:16 -06:00
Cosimo Lupo
af62ebf2b6 ttLib: rename 'fileName' arg to 'fileOrPath' in importXML function for consistency with saveXML method 2015-12-07 18:26:48 +00:00
Behdad Esfahbod
5133e3777e Undo accidentally commit changes 2015-12-07 15:15:51 +01:00
Cosimo Lupo
bc690a565d Merge pull request #422 from anthrotype/vdmx-sort
[V_D_M_X_] sort records by yPelHeight when writing toXML
2015-12-07 11:15:10 +00:00
Cosimo Lupo
983c21c745 [V_D_M_X_] sort records by yPelHeight when writing toXML 2015-12-07 11:07:56 +00: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
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