6467 Commits

Author SHA1 Message Date
Cosimo Lupo
bc8f1cfac4 varLib.errors: more informative message with unsupported/inconsistent formats 2022-06-21 17:27:12 +01:00
Cosimo Lupo
fa54b0fd62 otTables: add methods to Format enums to query the variable variants 2022-06-21 17:27:12 +01:00
Cosimo Lupo
97bcda9d35 otBase: define method to get variable attrs with associated VarIndexBase + {offset} 2022-06-21 17:27:11 +01:00
Cosimo Lupo
396353e8e3 otConverters: parse 'VarIndexBase + {offset}' from converters' description 2022-06-21 17:27:11 +01:00
Cosimo Lupo
871ee3d527 otData: add 'VarIndexBase + {offset}' to description of all COLR variable fields 2022-06-21 17:27:11 +01:00
Cosimo Lupo
82460bd368 otConverters: define a base class for all fixed-size floats with toInt/fromInt methods
this will be useful when computing deltas for COLR table fields that use Fixed or F2Dot14 (ItemVariationStore internally treats fixed-value floats as 16 or 32-bit integers)
2022-06-21 17:27:11 +01:00
Cosimo Lupo
676a66fad3 otTables: make DeltaSetIndexMap TTX dump less verbose by omitting no-op entries
though we still emit the empty <Map index=.../> elements; they help identify chunks of delta-set indices, and define the length of the array upon loading from XML
2022-06-21 17:27:11 +01:00
Cosimo Lupo
0cbdc8536b [otBase/varLib.merger] don't recurse in ensureDecompiled, merger is already working recursively 2022-06-21 17:27:11 +01:00
Cosimo Lupo
c612b2637f colorLib.unbuilder: ensure unbuildColrV1 flattens nested PaintColrLayers 2022-06-21 17:27:11 +01:00
Cosimo Lupo
fc982c643b colorLib: add option to disable PaintColrLayers' reuse of layers from LayerList
When building COLR masters, layer reuse may lead to different number of layers between masters, becasue some master may reuse specific layers while others may not. Add a flag to disable this optimization; will need to be run again after the VF COLR font has been merged
2022-06-21 17:27:11 +01:00
Behdad Esfahbod
0d7d7d4e11 [varLib.iup] Rewrite force-set conditions & limit DP lookback length
This does two things:

Fixes forced-set computation, which was wrong in multiple ways.
Debugged it. Is solid now... Famous last words.

Speeds up DP time by limiting DP lookback length. For Noto Sans,
IUP time drops from 23s down to 9s, with only a slight size increase
in the final font. This basically turns the algorithm from O(n^3) into
O(n).
2022-06-20 17:09:36 -06:00
Jens Kutilek
d0020b2536
Add check for missing glyphs to featureVars (#2654)
* Add check for missing glyphs to featureVars
2022-06-17 15:24:54 +02:00
Cosimo Lupo
c34ff0d474 [varLib.merger/errors] fix undefined exception name
The exception UnsupportedFormat was defined and then redefined with the same name in varLib.errors, and imported twice from varLib.merger, probably as result of a sweeping find/replace.
Rename it 'InconsistentFormats' as originally intended.
2022-06-17 11:24:56 +01:00
Cosimo Lupo
d6b5ce7669 [varLib.instancer] add --no-recalc-timestamp option
same as varLib.mutator
2022-06-14 15:16:12 +01:00
Cosimo Lupo
7b3a8d3d2c [mutator] rename --no-recalc-timestamp, like in pyftsusbet; simplify option parsing 2022-06-14 15:11:47 +01:00
Garret Rieger
b2c00d7883 Add flag to mutator to allow recalc timestamp to be disabled. 2022-06-13 22:03:32 +00:00
Cosimo Lupo
8d992508a4 varLib.errors: fix confusing error message when FeatureCount is different
see https://github.com/googlefonts/fontmake/issues/894
2022-06-13 12:14:25 +01:00
Cosimo Lupo
513b7d9a36 varLib.errors: use getBestFullName to print name of master ttf 2022-06-13 12:08:40 +01:00
Cosimo Lupo
3ceabeda7c
Merge pull request #2645 from fonttools/svg_compression
Clean up svgDoc compression #2
2022-06-10 15:53:47 +01:00
Jany Belluz
f19aa60e65
Merge pull request #2634 from fonttools/ds-avoid-isinstance
[designspaceLib] Check for descriptor types with hasattr()
2022-06-09 17:50:47 +01:00
Jany Belluz
99a2ad010d
Merge pull request #2640 from fonttools/ds-add-to-all
[designspaceLib] Add new classes to __all__
2022-06-09 17:50:22 +01:00
Cosimo Lupo
119b7732cc SVG: strip timestamp to make compressed gzip reproducible
we tell GzipFile to write the MTIME field to zero so that the compressed output is reproducible and doesn't change depending on when the data is compressed.
2022-06-09 16:29:29 +01:00
Cosimo Lupo
be623e257f Clean up svgDoc compression
This is based on bungeman's https://github.com/fonttools/fonttools/pull/2627

Previously, an entire `SVG ` table would be marked as compressed if any
of the decoded SVG documents in it were compressed. Then on encoding all
SVG documents would be considered for compression. The XML format had no
means to indicate if compression was desired.

Instead, mark each svgDoc with its compression status. When decoding
mark the svgDoc as compressed if the data was compressed. When encoding
try to compress the svgDoc if it is marked as compressed. In the XML
format the data itself is always uncompressed, but allow an optional
`compressed` boolean attribute (defaults to false) to indicate the
svgDoc should be compressed when encoded.

We also try to make sure that older code that relies on docList containing
sequences of three items (doc, startGID, endGID) will continue to work
without modification.
2022-06-09 15:15:05 +01:00
Cosimo Lupo
a367e8acf5
Merge pull request #2626 from googlefonts/table_sharing
Enable sharing across subtables of extension for harfbuzz packing.
2022-06-09 11:02:29 +01:00
Jany Belluz
737abf5020
[designspaceLib] Add DiscreteAxisDescriptor default in docstring 2022-06-08 10:03:04 +01:00
Jany Belluz
86cdcbb9e5 [designspaceLib] Add new classes to __all__ 2022-06-06 09:19:17 +01:00
Behdad Esfahbod
5295ebe966
Update Lib/fontTools/subset/__init__.py
Co-authored-by: Jany Belluz <jany.belluz@daltonmaag.com>
2022-06-03 05:48:03 -06:00
Behdad Esfahbod
a1fabd0fcb [subset] Update default feature tags
Corresponding to HarfBuzz commits:
40193adbfc
40d7d56e53
2022-06-03 05:41:31 -06:00
Jany Belluz
ec4bcf54c9 Check for descriptor types with hasattr() to allow custom classes that don't inherit the default descriptors 2022-06-01 12:00:52 +01:00
Garret Rieger
086799357a Enable sharing across subtables of extension for harfbuzz packing.
Harfbuzz repacker can handle subtables shared across extension lookups so there's no need to disallow such sharing. Add a parameter to _doneWriting to allow sharing to be enabled when preparing the object graph for passing to harfbuzz.
2022-05-25 23:55:43 +00:00
Nikolaus Waxweiler
42e4d66184
Merge pull request #2609 from fonttools/ds5-add-some-polish
[designspaceLib] Add some polish to the v5 paths
2022-05-04 16:13:03 +01:00
Nikolaus Waxweiler
fc174a9170 Undo warning 2022-05-04 14:54:07 +01:00
Nikolaus Waxweiler
26bf33bb60 Use assert instead of standalone error 2022-05-04 14:37:08 +01:00
Cosimo Lupo
b488d10768
Merge pull request #2611 from tshinnic/svglib_parser_real_number_format
Handle one more valid real number format in svgLib parse_path()
2022-05-04 08:27:24 +01:00
Cosimo Lupo
a09e80b1b1
Merge pull request #2596 from tshinnic/path_arc_rx_ry_nonnegative
Protect SVG path parsing from negative rx ry on arc commands
2022-05-04 08:14:15 +01:00
Thomas Shinnick
5abfef15e1 Handle one more valid real number format in svgLib parse_path()
Using svg.draw(pen) and parse_path() from svgLib threw exception
     ValueError: could not convert string to float: 'a'
on a SVG <path> string generated by Inkscape. Altering the path
string might object to other string bits like 'Z' or 'v', or
give even stranger exceptions.

Finally tracked it down to the path containing particular valid
numbers like "-4e-5" or "1e-4". Changing these to "-4.0e-5" or
"1.0e-4" would stop the exceptions. The parse_path() was not
accepting valid SVG real numbers.

The specification for real number formats is a bit of a mess in
CSS land right now, but the reassuringly concrete spec is:
    https://www.w3.org/TR/css-syntax-3/#number-token-diagram
which allows a real number having an exponent but without having
a fractional part, such as the number "1e3".

This change updates an RE to make fractional parts optional,
and adds a test for this valid SVG number format.
2022-05-03 17:48:14 -05:00
Nikolaus Waxweiler
ada9828121 Add some proper exceptions 2022-04-29 16:56:50 +01:00
Cosimo Lupo
0e43b0e2c3 [subset] Fix subsetting SinglePosFormat2 when ValueFormat=0
If a font has SinglePosFormat2 subtable with ValueFormat=0, then it contains a Value list with all None values.
Even though we don't build such inefficient tables, they do exist in the wild, as #2602 demostrates so we should handle those nicely, by downgrading them to Format1 with a single None value
2022-04-27 16:03:23 +01:00
Cosimo Lupo
ba8880e9f1 Bump version: 4.33.3 → 4.33.4.dev0 2022-04-26 10:51:16 +01:00
Cosimo Lupo
b9621ff427 Release 4.33.3 2022-04-26 10:51:15 +01:00
Nikolaus Waxweiler
d8bf4c3123 Fix typo to actually transfer font references 2022-04-26 10:15:37 +01:00
mike maxfield
47bbe6f7ca correct naming of dataclasses '__post_init__' method 2022-04-23 16:18:41 -06:00
Thomas Shinnick
812d05c122 Protect SVG path parsing from negative rx ry on arc commands
SVG documentation has an explicit requirement that _consumers_
of path arc commands accept and *correct* certain bad values.
This includes using the absolute value of the arc command's rx
and ry radius parameters.

See "9.5.1. Out-of-range elliptical arc parameters"
https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands

Lib\fontTools\svgLib\path\parser.py is missing any guard against
negative values for rx and ry parameter. Adding an abs() to each
value read will implement the SVG specification.

A problem was seen here while most programs and browsers handle
bad arc commands just fine. A bug report has been registered with
Inkscape (!) to protect any other non-SVG compliant programs.
See https://gitlab.com/inkscape/inbox/-/issues/6857 for more details.
2022-04-23 01:36:30 -05:00
Cosimo Lupo
37767203b0 Bump version: 4.33.2 → 4.33.3.dev0 2022-04-22 19:26:47 +01:00
Cosimo Lupo
e569154033 Release 4.33.2 2022-04-22 19:26:47 +01:00
Cosimo Lupo
350f893e17 [otBase] demote repacker ERROR to WARNING, only 1 per loop; don't exit at firstfail
Fixes https://github.com/fonttools/fonttools/issues/2594
2022-04-22 19:05:54 +01:00
Cosimo Lupo
f68ce14d7a [otBase] log the name of uharfbuzz exception 2022-04-22 15:31:34 +01:00
Cosimo Lupo
fe81aa729a Bump version: 4.33.1 → 4.33.2.dev0 2022-04-22 11:38:46 +01:00
Cosimo Lupo
04b835d04f Release 4.33.1 2022-04-22 11:38:46 +01:00
Cosimo Lupo
20de0784c2 send DeprecationWarning if FONTTOOLS_GPOS_COMPACT_MODE env var is set
and factor out shared code to read the env var
2022-04-22 11:32:43 +01:00