140 Commits

Author SHA1 Message Date
Cosimo Lupo
0951e2063e
ensure all modules do from __future__ import absolute_import, unicode_literals 2018-07-14 19:25:18 +01:00
Cosimo Lupo
a9a37818cb
glifLib: use ufoLib.etree 2018-07-13 18:49:21 +01:00
Cosimo Lupo
8011e828dd
glifLib: call plistlib.totree with intent_level=2
since 'lib' element is itself contained in 'glyph' root element
2018-07-11 18:32:37 +01:00
Cosimo Lupo
a8124a0eef
plistlib: use double-quotes in xml declaration
for consistency with glifLib
2018-07-11 13:29:54 +01:00
Cosimo Lupo
584666ffe9
glifLib: use new plistlib load/dump/totree/fromtree 2018-07-11 12:29:18 +01:00
Cosimo Lupo
cdbb2d6b30
glifLib: use double quotes in XML declaration like old ufoLib
fixes #158
2018-07-10 18:56:30 +01:00
Cosimo Lupo
4cb26a3521
_glifTreeFromString: ensure we pass UTF-8 bytes to etree.fromstring
Fixes https://travis-ci.org/robofab-developers/fontParts/jobs/402178235#L499

Instead of passing a unicode string to lxml.etree.fromstring, which must not have
an XML declaration containing an explicit encoding, we now pass a UTF-8 bytes string.
The latter may or may not have the xml declaration. If it doesn't, UTF-8 is implied
by lxml parser (libxml2 defaults to UTF-8 internally).
2018-07-10 15:39:58 +01:00
Cosimo Lupo
586b83c1f1
Merge pull request #157 from anthrotype/xml-declaration
add the default xml declaration in writeGlyphToString
2018-07-10 13:47:00 +02:00
Cosimo Lupo
864bb26eb4
glifLib: avoid re-encoding str to utf-8 when writing to file
the writeGlyphToString will still return a unicode string, like it's always done.
However, in the writeGlyph method we can call a private _writeGlyphToBytes and
write UTF-8 bytes directly instead of decoding them, then re-encoding them as
we write to the file.
2018-07-10 12:37:15 +01:00
Cosimo Lupo
8ad8f7631c
glifLib: writeGlyphToString must include the xml declaration
This is a regression from ufoLib v2.1.1, see

https://github.com/adobe-type-tools/afdko/pull/462#issuecomment-403577134
https://travis-ci.org/adobe-type-tools/afdko/jobs/401751859#L8427
2018-07-09 20:16:18 +01:00
Ben Kiel
e1227441e4
Grammer 2018-07-04 15:02:26 -05:00
Ben Kiel
53b4352a3b
Turn on validation by default in glyphLib 2018-07-04 13:56:44 -05:00
Tal Leming
1d6dddc8f5 Unneeded import. 2018-06-14 13:34:19 -04:00
Tal Leming
c008e20854 Use lxml for reading. 2018-06-14 13:28:20 -04:00
Tal Leming
5ec6b5ef65 Use len(element). 2018-06-14 11:55:54 -04:00
Tal Leming
dab4800f12 Add indentation to the self-closing prevention. 2018-06-14 10:59:51 -04:00
Ben Kiel
e9df5bec13 fix writing lib with lxml 2018-06-14 09:22:24 -05:00
Tal Leming
5f39650425 Write the note the old way. 2018-06-14 08:43:30 -04:00
Tal Leming
4c52a516f4 Height before width. 2018-06-14 08:39:53 -04:00
Tal Leming
3cfb942441 Trick lxml into not writing self-closing tags for outline and contour elements. 2018-06-14 08:36:52 -04:00
Ben Kiel
3ae4f10092 Make attrs OrderedDicts
Get encoding right for py2 and py3
2018-06-14 00:31:29 -05:00
Tal Leming
213b90a4ba Found some attrib type errors. 2018-06-13 21:34:41 -04:00
Ben Kiel
c8608c2fd7 Need to pass an OrderedDict to get correct order. 2018-06-13 16:42:33 -05:00
Ben Kiel
f3b0703d03 Need to force text to a string and not bytes for Py3 2018-06-13 15:48:29 -05:00
Tal Leming
739ec8a169 Use lxml for writing. 2018-06-13 14:22:51 -04:00
Tal Leming
382271c706 Typo and fallback. 2018-06-13 12:46:40 -04:00
Tal Leming
5867e9bc8b Don't rebuild the list of existing file names each time a glyph is written. That's expensive. 2018-06-13 12:37:49 -04:00
Tal Leming
efd2575a6a Remove some validation escaping. 2018-06-12 20:40:32 -04:00
Ben Kiel
f81e9b8c6f Fix tests, needed named arg. 2018-06-12 09:15:36 -05:00
Ben Kiel
83303d56a7 Add in more valiator switches 2018-06-11 23:13:00 -05:00
Tal Leming
4c75212ee6 Relax the point data validation. 2018-06-11 21:44:50 -04:00
Ben Kiel
a7aa115fd8 Update glyphLib.
Update tests.
Fix errors.
Add documenation.
2018-06-11 15:03:54 -05:00
Ben Kiel
5f8b600221 Catch additonal calls to GlyphSet that need validation. Inital start of adding validation on/off to GlyphSet 2018-06-11 12:05:36 -05:00
Frederik Berlaen
4549c6a2d4 an anchor is a move point with a name
check if the point has a name

if no name is given its a single move point in a contour
2018-01-26 23:18:25 +01:00
Adrien Tétar
8946a5f753 More 2017-11-17 13:18:44 +01:00
Adrien Tétar
a2ffce8596 typo 2017-11-04 22:59:01 +01:00
Adrien Tétar
99c5c4fff5 Use dedicated Error 2017-11-04 22:56:12 +01:00
Adrien Tétar
f0d67574ab Some optimizations to glifLib 2017-11-04 22:18:20 +01:00
Ben Kiel
0bc4ab9497 Remove duplicate variable assignment 2017-02-27 10:18:02 -06:00
Denis Moyogo Jacquerye
e6a1a658f0 glifLib: try importing from fontTools.misc.xmlWriter first
fixes #41
2016-10-13 21:42:51 +01:00
Cosimo Lupo
ee38446982 glifLib.py: use +IGNORE_EXCEPTION_DETAIL to make doctest work on both Python2 and 3
http://python3porting.com/problems.html#handling-expected-exceptions
2016-09-11 17:00:13 +01:00
Denis Moyogo Jacquerye
bb21cb7c3a userNameToFileName expects userName to be unicode strings, let it raise
if not
2016-07-11 13:49:59 +01:00
Cosimo Lupo
f92dcf36c1 don't write layerinfo.plist if 'lib' element is empty 2016-06-28 13:52:23 +01:00
Cosimo Lupo
f6689faf5b glifLib: don't raise AttributeError if element.text attribute is None
When an element tree is built from code, or it is parsed from a string that was not pretty-printed (i.e. without indentation), the 'text' attribute of an Element instance can be None. So we must ensure it's not None before calling `strip()` method.
2016-06-25 19:04:24 +01:00
Cosimo Lupo
971a92bfe8 glifLib: use len() to check if ElementTree.Element is empty or contains children 2016-06-05 19:07:45 +01:00
Adrien Tétar
81e6c235af glifLib: fixup contour validation code 2016-05-31 09:59:02 -07:00
Denis Moyogo Jacquerye
b8f4145d76 glifLib: raise error when text is in <glyph> and in <outline> 2016-05-31 14:33:58 +01:00
Denis Moyogo Jacquerye
16e2c0f308 use unicode_literals 2016-05-31 11:23:05 +01:00
Adrien Tétar
8044d2fb88 Use ElementTree in glifLib and drop embedded XML parsing infrastructure 2016-05-20 11:11:15 -07:00
Cosimo Lupo
ace2a4a6bc [glifLib] use use repr() to stringify floats for py23 compat
Closes #19
2016-03-17 16:06:03 +00:00