138 Commits

Author SHA1 Message Date
Cosimo Lupo
b1fae3fe32 ttx/ttLib: use from fontTools import version as before 2016-10-10 15:26:04 +01:00
Cosimo Lupo
e0a10698aa [ttLib] must cast 'sfntVersion' to native string type (bytes on py2, str on py3) to normalize repr() output 2016-09-28 18:08:08 +01:00
Cosimo Lupo
5dabba6699 [ttLib] get 'ttLibVersion' from fontTools.version.__version__, but only write MAJOR.MINOR
otherwise it risks changing too often... ;)
2016-09-27 00:28:01 +01:00
Cosimo Lupo
f998cf1126 [ttLib] use boolean instead of int
I know it's same, but this looks more 'pythonic'
2016-02-02 18:26:50 +00:00
Cosimo Lupo
84d6f076a3 [ttLib] call XMLWriter.close() only if 'fileOrPath' is a path, not when it's a file
This allows to call `TTFont.saveXML` with an already open file/stream (e.g. sys.stdout or a StringIO) without it being abruptly closed at the end.

We do the same elsewhere when we reiceive file handles instead of path names, so we might do it here too.
2016-02-02 18:25:43 +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
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
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
Cosimo Lupo
9049d5f866 Merge pull request #425 from anthrotype/xmlreader-fileobj
make XMLReader accept file objects
2015-12-08 13:08:19 +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
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
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