72 Commits

Author SHA1 Message Date
Khaled Hosny
cf08265cd5 Black 2024-02-06 15:47:35 +02:00
Harry Dalton
70ca6dec9b Identify the culprit glif in read errors with a loose backport of PEP678
This commit annotates errors from GlyphSet.readGlyph() with the details
of the glyph that originated them (e.g. name, path to glif). This is
implemented with a loose backport of PEP678, to avoid adding a wrapper
error that would be less specific and would break API compatibility.

In addition, this commit adds a test to ensure that the new details are
present (specifically, in the case of parsing invalid XML).
2023-03-14 15:58:18 +00:00
Harry Dalton
1f3380300b Wrap XML library exceptions with glifLib types when parsing glifs
This allows dependent projects to catch errors parsing glifs without
requiring logic to account for which XML library fonttools is using
internally (e.g. for implementing fonttools/ufoLib2#264).

This commit also adds tests to ensure that the exception we expose when
glifs have invalid syntax remains stable across future releases.
2023-03-09 16:11:32 +00:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Cosimo Lupo
5ca57917c6 fix UFOFormatVersion tuple's __str__ in python 3.11
python 3.11 doesn't like when a mixin overrides a dunder method like __str__, for some reasons it keep using Enum.__str__, see
https://github.com/fonttools/fonttools/pull/2655
2022-07-06 11:13:55 +01:00
Behdad Esfahbod
6b4e2e7147 [ufoLib / interpolatable] Wire up outputImpliedClosingLine parameter
ufoLib's glyph draw() was passing outputImpliedClosingLine=False to
PointToSegmentPen(). This was causing incompatible nodes in
interpolatable tool for certain fonts, like this in NotoSansDevanagari:

Glyph dabhadeva was not compatible:
    Node count differs in path 1: 23 in NotoSansDevanagari-Bold, 24 in NotoSansDevanagari-CondensedBold
    Node count differs in path 1: 24 in NotoSansDevanagari-CondensedBold, 23 in NotoSansDevanagari-CondensedLight

Because a final lineto before a closepath was being elided or not in
some masters but not others.  Wire up the parameter and control it
from interpolatable tool to fix this.
2022-04-01 13:14:39 -06:00
Nikolaus Waxweiler
128326cd50 Expand reserved names and fix illegal characters 2022-01-18 10:13:22 +00:00
Simon Cozens
0f03e6529a
[docs] Fix sphinx warnings (#2453)
* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
2021-12-02 15:31:49 +00:00
Nikolaus Waxweiler
04664089cc Minor: wording 2021-10-07 14:44:20 +01:00
Nikolaus Waxweiler
cd32e1d16b Use set comprehension 2021-10-07 14:18:12 +01:00
Nikolaus Waxweiler
827004608c userNameToFileName should not have a mutable default parameter 2021-10-07 14:18:12 +01:00
Nikolaus Waxweiler
a7e4d86540 Use a set for file names for clash checking 2021-10-07 12:03:47 +01:00
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Nikolaus Waxweiler
863b022523 Add docstring to GlyphSet 2020-11-23 14:37:01 +00:00
Nikolaus Waxweiler
8ca141852d UFOReader: always expect contents.plist 2020-11-23 14:34:16 +00:00
Nikolaus Waxweiler
8d2a3ae6d2 Add expectContentsFile parameter to GlyphSet
For use when reading existing UFOs, to comply with the specification stating that a contents.plist file must exist in a glyph set.

Closes https://github.com/fonttools/fonttools/issues/2111.
2020-11-23 13:57:32 +00:00
Nikolaus Waxweiler
04e1269b41 [glifLib] Hard-require x and y coordinates 2020-10-03 12:43:28 +01:00
justvanrossum
c785c0ea9b fixed typo 2020-08-08 19:59:10 +02:00
Frederik Berlaen
d0767138f7 make sure a list of possible case-insensitive file names is send
not a dict where the key is the case sensitive file name
2020-06-20 17:45:27 +02:00
Tom Archer
0b93480808 Change startwith or statement to use tupple of strings rather than or. 2020-05-22 15:56:48 +01:00
Tom Archer
b88f717885 Get test working that shows duplicates are removed 2020-05-22 09:53:40 +01:00
Tom Archer
2b654a1d2a Add code that removes duplicates when parsing groups.plist 2020-05-20 11:59:16 +01:00
Cosimo Lupo
0a26a8d287
glifLib: document default when formatVersion=None 2020-05-11 18:50:45 +01:00
Cosimo Lupo
c57e843d1f
UFOReader: close underlying fs object if UFOLibError raised in constructor 2020-05-07 16:53:38 +01:00
Cosimo Lupo
57f4904363
ufoLib/glifLib: use TupleEnum instead of namedtuple for {UFO,GLIF}FormatVersion
Also add dedicated Unsupported{UFO,GLIF}Format exceptions in
fontTools.ufoLib.errors module
2020-05-07 16:53:38 +01:00
Cosimo Lupo
f120be17e4
ufoLib/utils: define _VersionTupleEnumMixin class 2020-05-07 16:53:38 +01:00
Cosimo Lupo
c066cfc4d5
WIP: ufoLib: support UFO formatVersionMinor and GLIF formatMinor 2020-05-05 18:52:30 +01:00
Nikolaus Waxweiler
f30e41b863 [ufoLib] Only write fontinfo.plist when there is content 2020-04-30 11:11:43 +01:00
Cosimo Lupo
8423e01a18
ufoLib: don't crash if UFO2 has openTypeHheaCaretOffset=0.0
validators are picky so give them integers when they want integers
2020-02-15 13:25:45 +00:00
Cosimo Lupo
337bb66211
glifLib: strip comments when parsing with lxml
they are already ignored when parsing via built-in ElementTree
2019-12-16 12:05:13 +00:00
Jens Kutilek
6c3edaded2
ufoLib groupnames conversion 2 → 3 (#1762)
* If a group name is the same as a glyph name, it cannot be a kerning group name
* Add test
2019-11-22 09:51:35 +01:00
Nikolaus Waxweiler
473cf5e0c6 userNameToFileName: add str annotation for userName 2019-09-14 22:26:48 +01:00
Nikolaus Waxweiler
cf2fd0671b Assume layer and glyph names are always str 2019-09-14 22:11:20 +01:00
Nikolaus Waxweiler
562052bb86 Don't allow byte layer names 2019-09-14 21:55:46 +01:00
Nikolaus Waxweiler
dcb1fb67ce Remove stale comment 2019-09-14 20:41:17 +01:00
Nikolaus Waxweiler
20b1e06100 Remove integerTypes, it's just an int now 2019-09-13 18:53:10 +01:00
Nikolaus Waxweiler
9825553e06 Use !r in-string formatter syntax instead of repr(value) 2019-09-13 18:45:19 +01:00
Nikolaus Waxweiler
b51a2b616e Minor: revert docstring change 2019-09-13 18:28:08 +01:00
Nikolaus Waxweiler
51c8a7a3e1 Remove some unused imports 2019-09-13 18:27:05 +01:00
Nikolaus Waxweiler
54dc6b2dcc Minor: adjust docstring 2019-09-13 18:27:05 +01:00
Nikolaus Waxweiler
0f5b6e2e83 Reduce use of py23 2019-09-13 18:27:05 +01:00
Nikolaus Waxweiler
66dec63231 Trim now redundant code in ufoLib.utils 2019-09-13 18:27:05 +01:00
Nikolaus Waxweiler
bc344380e8 Upgrade syntax to Python 3.6+ 2019-09-13 18:27:05 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
justvanrossum
faadb91c8b remove leftover comma, should fix #1666 2019-07-22 15:53:42 +02:00
Miguel Sousa
ddff29cb5d Fix DeprecationWarning: invalid escape sequence 2019-04-01 14:04:14 -07:00
Khaled Hosny
e0b517a6e7 A couple ufoLib.pointPen → pens.pointPen 2019-02-14 23:38:11 +02:00
Chris Simpkins
7458cebda1 [ufoLib glifLib] minor typo fix 2019-01-23 11:21:06 -05:00
Cosimo Lupo
42ab9aba57
[ufoLib] rename deprecated fs.setbytes -> writebytes
Follow up of #1445
Fixes #1424
2019-01-15 11:07:04 +00:00