1050 Commits

Author SHA1 Message Date
Cosimo Lupo
ed29a07670 [O_S_2f_2] skip updateFirstAndLastCharIndex if cmap table class is DefaultTable
Fixes https://github.com/behdad/fonttools/issues/497
2016-02-01 18:04:39 +00:00
Cosimo Lupo
c4d2ebca66 remove deprecated use of 'quiet' option in test modules 2016-02-01 13:39:39 +00:00
Cosimo Lupo
e40dffd86d [_c_m_a_p] don't set self.data = headerdata + data inside cmap_format_14.compile
self.data is usually set by decompileHeader as "the data after the header"; while here
it also included `headerdata`. This produced corrupt data if the compile method was called
again, as the header data is added again to self.data.

Moreover, in none of the subtable classes' `compile` methods, the re-compiled data is
stored in self.data, so we shall not do that for format 14 either.

Fixes #389
2016-01-31 21:00:11 +00:00
Cosimo Lupo
7fafe1f9a7 [sfnt] add compress function to optionally use zopfli instead of zlib 2016-01-31 14:20:17 +00:00
Cosimo Lupo
48db539c44 [ttProgram] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
af91f9e791 [otTables] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
6f8e1502ff [otConverters] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
10bf8ecd85 [otBase] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
2b30dc2134 [_n_a_m_e] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
0ce31f7b0a [_l_o_c_a] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
7d36de99ef [_k_e_r_n] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
abe3202412 [_h_m_t_x] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
f85e2f295d [_h_e_a_d] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
dff078ed51 [_g_l_y_f] replace print and warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
ff853c38b8 [_c_m_a_p] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
77658c952f [_a_v_a_r_test] use StringIO to capture logger's output in test case 2016-01-27 19:02:48 +00:00
Cosimo Lupo
9b21ea6a09 [_a_v_a_r] replace warnings with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
c5659b28a2 [S_V_G_] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
e46be4d7d6 [O_S_2f_2] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
7d67e9c257 [E_B_L_C_] replace print with logger 2016-01-27 19:01:12 +00:00
Cosimo Lupo
74cb889f4e [E_B_D_T_] replace print with logger 2016-01-27 19:01:12 +00:00
Cosimo Lupo
85f9f442ea [BitmapGlyphMetrics] replace print with logger 2016-01-27 19:01:12 +00:00
Cosimo Lupo
6a92ae085b [woff2] replace print with logger 2016-01-27 19:01:12 +00:00
Cosimo Lupo
967b994449 [sfnt] replace print with logger 2016-01-27 19:01:12 +00:00
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