124 Commits

Author SHA1 Message Date
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
Cosimo Lupo
18d02aece9 [ttLib] convert KeyView object to list for py23 compatibility 2015-08-19 17:57:37 +01:00
Cosimo Lupo
3142e3319e add reordersTables() method to SFNTWriter and WOFF2Writer (return True for the latter) 2015-08-19 17:56:46 +01:00
Cosimo Lupo
4fe88a41f3 [TTFont] fix reorderTable logic 2015-08-19 15:47:07 +01:00
Behdad Esfahbod
9aed8e1e9d Merge pull request #270 from anthrotype/woff2_14
implement WOFF2 encoder/decoder as standalone module
2015-08-19 15:33:44 +01:00
Cosimo Lupo
6ba67ab699 [TTFont] changed behaviour of 'reorderTables' argument of save function
Reorder to OT spec recommended order if reorederTables == True (default).
Don't reorder if reorderTables == None.
Keep the input font original table order if reorderTables == False (and
the font has a reader object from which to get the original order).
2015-08-19 14:36:58 +01: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
d50af59a52 [ttLib] pass if _getGlyphNamesFromCmap raises KeyError on 'cmap'
when _getGlyphNamesFromCmap gets called by the cmap parser itself, the
partially loaded subtable is removed and then restored later.
However, when a TTFont instance is imported from XML rather than from
binary file, its 'reader' attribute is None, and so the line:

tempcmap = self['cmap'].getcmap(3, 1)

will make TTFont.__getitem__ raise KeyError. It's better to fail nicely,
and return a dummy glyphOrder based on maxp numGlyphs.
2015-08-07 18:23:41 +01:00
Cosimo Lupo
bf0e336d31 replace all 'StringIO' with 'BytesIO' 2015-08-07 17:25:22 +01:00
Cosimo Lupo
4fd6373b92 [TTFont] keep input file open if we didn't open it 2015-06-26 18:30:18 +01:00
Cosimo Lupo
356c923411 [TTFont] wrap input file in a temporary stream to allow overwriting
Fixes https://github.com/behdad/fonttools/issues/302
2015-06-26 12:19:42 +01:00
Behdad Esfahbod
27ade7643b Default itemSize to 16 in getSearchRange()
For compat with original fonttools.

Fixes https://github.com/typesupply/woffTools/issues/1
2015-06-24 16:07:06 -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
4362cb49f3 In getGlyphSet(), pull glyph advance from hmtx even for CFF fonts
That's the right thing to do.

Also fixes this:
https://github.com/robofab-developers/robofab/issues/28
2015-01-08 12:53:58 -08:00
Behdad Esfahbod
8ef5adc4af Move draw() implementation to a better place 2015-01-08 12:28:42 -08:00
moyogo
450faba7c3 Res is not available in Python 3 2014-11-21 17:07:55 +00:00
Khaled Hosny
f329808703 Fix: 'list' object has no attribute 'tolist' 2014-09-21 19:18:46 +03:00
Behdad Esfahbod
aeeb884b4c [ttx] Always add raw=True attribute when dumping DefaultTable to XML
Needed to avoid surprises when we add new table implementations.
Recently we added VDMX table, and that broke build of projects using
VDMX with DefaultTable, eg:

https://github.com/behdad/fonttools/issues/151
2014-08-24 13:01:27 -04:00
Behdad Esfahbod
e6adebdc4a Make glyf-table glyph loading lazy by default
When I added the font.lazy setting, I made glyf table non-lazy
by default.  This is helpful to users who typically access glyphs
like:

	glyf_table.glyphs[glyfname]

instead of the correct way:

	glyf_table[glyfname]

and also forget to call expand() on the glyph.  However, this
significantly slows down most scripts that load the font without
lazy=True...  As such, add a third mode to laziness.  By default
lazy=None and does NOT expand glyphs.  If lazy=False is passed
in, all glyphs are loaded.

I hope this is an acceptable middle ground and not too confusing.
2014-07-14 20:02:37 -04:00
Behdad Esfahbod
9f23ee4cc8 Change cmap-based duplicate-name resolution from n^2 to linear time
Similar to 85be2e0a9773acec3c6d14c345b1fd94ab3aa5c3, though much
harder to hit.
2014-06-02 18:09:47 -04:00
Behdad Esfahbod
62dd7b2a0e Refactor getSearchRange() 2014-05-27 16:01:47 -04:00
Behdad Esfahbod
3012076942 Minor 2014-05-19 12:43:37 -06:00
Behdad Esfahbod
497863a190 Allow disabling 'head' table modified-timestamp recalculation
Part of:
https://github.com/behdad/fonttools/issues/115
https://github.com/behdad/fonttools/issues/46
2014-05-01 15:13:22 -07:00
Behdad Esfahbod
4bb028e44f Fix identifierToTag for Python 3 2014-03-28 15:18:14 -07:00
Behdad Esfahbod
50d6c7298a Minor 2014-03-28 14:32:24 -07:00
Behdad Esfahbod
d0a31f5a43 Make tag parameter to table constructor optional
If not provided, extract from class name.
2014-03-28 14:04:01 -07: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
9c5e2ce1b6 Add a get() method to TTFont ala dict.get() 2013-12-19 11:38:56 -05:00
Behdad Esfahbod
283fb26820 By default, don't load fonts lazily
Lazy loading has implications on how people use objects.
So, by default, don't load lazily.  This only affects
GSUB/GDEF/GPOS/etc and is closer to what fonttools used
to do traditionally.

Turn lazy loading on in subset and inspect.
2013-12-16 00:52:29 -05:00
Behdad Esfahbod
e5bee3716e Allow converting 'glyphXXX' to glyphID
There was an inconsistency: when allowVID was False, we were allowing
gid->glyphXXX, but not the reverse.  This was allowing some fonts to
be loaded, but then not to be written back.  Fix that.
2013-12-04 22:46:29 -05:00
Behdad Esfahbod
ebefbbaa58 Minor 2013-12-04 22:07:18 -05:00
Behdad Esfahbod
dc87372c88 Use True/False instead of 1/0 2013-12-04 21:28:50 -05:00
Behdad Esfahbod
9e6ef94b55 Use "is None" instead of "== None"
The latter hits the __eq__ method and can fail because we now
do not allow comparing objects of different types.

For example, was failing subsetting Andika-R.ttf.
2013-12-04 16:35:10 -05:00
Behdad Esfahbod
153ec40209 Fix a few pychecker warnings
Fixes https://github.com/behdad/fonttools/issues/58
2013-12-04 01:15:46 -05:00
Behdad Esfahbod
e388db566b py23 Use new-style classes
Such that we get the same semantics in both Python 2 and 3.
2013-11-28 18:53:30 -05:00
Behdad Esfahbod
5cf4008336 py23 tostr()/tobytes() and using them
ttf->xml seems to be mostly working now.
2013-11-28 17:32:43 -05:00
Behdad Esfahbod
960280bbd6 py23 Use more Tag() 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
319c5fd10e py23 introduce byteord() and use it 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
d2f5d2f8b4 py23 use Tag in ttLib/__init__ 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
32c10eecff py23 from __future__ import division and adjust divisions 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
30e691edd0 py23 from __future__ import print_function 2013-11-27 17:27:45 -05:00
Behdad Esfahbod
b7a2d797a4 py23 Use bytechr() instead of chr() 2013-11-27 15:25:00 -05:00
Behdad Esfahbod
bb0beb7385 2to3 Use py23 to close some of the bytes/str/unicode gaps 2013-11-27 15:25:00 -05:00
Behdad Esfahbod
c2297cd41d 2to3 --fix=dict with manual cleanup 2013-11-27 14:01:45 -05:00
Behdad Esfahbod
14fb031125 Remove most uses of module string 2013-11-27 14:01:44 -05:00
Behdad Esfahbod
223273f792 2to3 --fix=except 2013-11-27 14:01:37 -05:00
Behdad Esfahbod
b92c08059d 2to3 --fix=imports with manual fixups 2013-11-27 05:05:46 -05:00
Behdad Esfahbod
3ec6a25823 2to3 --fix=print with manual fixup 2013-11-27 04:57:33 -05:00
Behdad Esfahbod
ac1b435946 2to3 --fix=idioms 2013-11-27 04:15:34 -05:00