295 Commits

Author SHA1 Message Date
Behdad Esfahbod
1d0f3c27fc [subset] Handle a null-offset error in MarkLigPos
As reported by @rsheeter.
2023-10-23 21:39:28 -06:00
Cosimo Lupo
5d6e1c750c
[subset] keep East Asian spacing vhal, halt, chws, vchw by default
https://github.com/harfbuzz/harfbuzz/issues/4451
2023-10-19 10:46:47 +01:00
Behdad Esfahbod
31c531dd04 [subset] Fix extension of subset font (again)
Fixes https://github.com/fonttools/fonttools/issues/1298#issuecomment-1768849326
2023-10-18 10:11:51 -06:00
Cosimo Lupo
532a771b98 fix minor typo [skip ci] 2023-09-15 16:58:17 +02:00
Cosimo Lupo
9f61271dc1 subset: parse OT-SVG with resolve_entities=False
to guard against XXE attacks as recommended in https://codeql.github.com/codeql-query-help/python/py-xxe/
2023-09-15 16:50:38 +02:00
Behdad Esfahbod
d27cc3abf8 Revert "Merge pull request #3214 from fonttools/subset-speed-regression"
This reverts commit f7965ba0086ebad9e3fa103935dc2edf41ffe780, reversing
changes made to 31319a7ef218237eea7cd6713ec29032a5cdd752.
2023-07-20 10:16:04 -06:00
Cosimo Lupo
f0d601a5f2
[subset] Revert use of NameVisitor in subsetter which may be causing speed regression
Intended to fix #3213

Revert "Implement Cosimo feedback"

This reverts commit cfede76fd93012a79457232d79884b3c885bf81b.

Revert "remove redundant CPAL name removal code"

This reverts commit b5639410abe9b57d9764639839621d9f1995c873.

Revert "convert name table _prune_pre_subset to prune_post_subset"

This reverts commit 0a6e8bf1c308c843fbbf65e06e4eb5734aa941a2.

Revert "Use NameRecordVisitor in subsetter"

This reverts commit edf8891fba54015c5d37a6397b7b95f14dfe5662.
2023-07-20 10:26:28 +01:00
Marc Foley
cfede76fd9 Implement Cosimo feedback 2023-07-10 15:01:40 +01:00
Marc Foley
b5639410ab remove redundant CPAL name removal code 2023-06-28 17:18:12 +01:00
Marc Foley
0a6e8bf1c3 convert name table _prune_pre_subset to prune_post_subset 2023-06-28 17:02:34 +01:00
Marc Foley
edf8891fba Use NameRecordVisitor in subsetter 2023-06-27 15:23:56 +01:00
Behdad Esfahbod
65598197c8 [subset] Remove quotation marks from command-line samples
Those have confused Windows users before.

Fixes https://github.com/fonttools/fonttools/issues/3149
2023-06-05 09:42:17 -06:00
Cosimo Lupo
20319e02f9
fix 'TypeError: lxml.etree._Attrib is not a mapping' on pypy3
https://github.com/fonttools/fonttools/actions/runs/5070601982/jobs/9105864056#step:5:3610
2023-05-24 16:39:26 +01:00
Khaled Hosny
7089635305 [subset] Make sure GDEF is processed before GSUB and GPOS
See https://github.com/fonttools/fonttools/pull/3114#pullrequestreview-1437266522
2023-05-22 23:22:44 +03:00
Khaled Hosny
04975b9a14 [subset] Prune GDEF.MarkGlyphSetsDef
Remove empty sets and fixup Lookup.MarkFilteringSet to use the new
indices.
2023-05-22 13:28:50 +03:00
Jany Belluz
760c7376fe [subset] Compute xAvgCharWidth even when --no-prune-unicode-ranges is given 2023-03-01 16:28:51 +00:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Jack McCabe
eeba234ee0 [subset] PR feedback implementation 2022-09-30 15:59:11 +01:00
Jack McCabe
14ce08bd75 [subset] extend CPALv1 test 2022-09-30 15:41:14 +01:00
Jack McCabe
70112b947d [subset] prevent CPAL nameIDs from being dropped 2022-09-30 12:36:28 +01:00
Jack McCabe
b945fd6305 [subset] Fix enumeration of palette entry labels 2022-09-30 11:40:39 +01:00
Cosimo Lupo
276f6aaf44 [subset] keep and don't prune CPAL if OT-SVG table is present
Fixes #2814

or at least is a workaround until a proper 'fix'
2022-09-14 12:55:40 -06:00
Cosimo Lupo
25a05c72ab subset: add --no-lazy option to load font eagerly as TTFont(lazy=False) 2022-09-08 15:42:34 +01:00
Behdad Esfahbod
27965842eb [subset] Fix subsetting of variable fonts
Fixes https://github.com/fonttools/fonttools/issues/2769
2022-08-24 10:12:32 -06:00
Behdad Esfahbod
3eed84da01
Merge pull request #2756 from fonttools/makeOutputFileName-fragment
[cliTools.makeOutputFileName] Add fragment argument
2022-08-22 06:29:19 -06:00
Behdad Esfahbod
24c9fb6ffa [cliTools] Rename fragment to suffix 2022-08-22 06:26:30 -06:00
Behdad Esfahbod
68f31b580c
Merge pull request #2755 from fonttools/scaleUpem-cff
[scaleUpem] Support CFF/CFF2
2022-08-22 06:23:54 -06:00
Behdad Esfahbod
82a523cc17 [subset/CFF] Remove FDSelect workaround from 2014
Fixes https://github.com/fonttools/fonttools/issues/139
2022-08-20 02:41:24 +02:00
Behdad Esfahbod
e146ddfd86 [cliTools.makeOutputFileName] Add fragment argument
And use it from subsetter and instancer.

Related to https://github.com/fonttools/fonttools/issues/1156
2022-08-19 12:20:21 -06:00
Behdad Esfahbod
d4d8c4ac5b [scaleUpem] Support CFF/CFF2 2022-08-19 11:03:23 -06:00
Cosimo Lupo
dbe60eae80 [subset/svg] use broader ImportError instead of ModuleNotFoundError
Fixes https://github.com/fonttools/fonttools/issues/2696
2022-07-18 11:32:44 +02: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
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
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
bb1dbf4198 drop the 'X' from recalcAvgCharWidth method name 2022-04-21 19:02:39 +01:00
Cosimo Lupo
12942feb6b [subset] use recalcXAvgCharWidth method 2022-04-21 18:46:11 +01:00
Cosimo Lupo
af6804bed5 make USE_HARFBUZZ_REPACKER a 3-state option, defaults to auto
if explicitly enabled, it will raise ImportError if uharfbuzz is not found, and will propagate the uharfbuzz error instead of silently falling back to the pure-python serializer
2022-04-21 18:11:20 +01:00
Cosimo Lupo
1bb9607b72 [subset] add --no-harfbuzz-repacker CLI flag 2022-04-21 15:46:12 +01:00
Cosimo Lupo
315705a58f [subset] fix subsetting OT-SVG when glyph id attribute is on the root <svg> element
Fixes https://github.com/fonttools/fonttools/issues/2548
2022-03-18 13:18:53 +00:00
aschmitz
d9f9466d63 subset: speed up subsetting of large fonts
Two small changes that significantly speed up subsetting of large fonts
such as Noto Sans CJK:

1. When emptying a charstring, simply empty its program rather than
attempting to decompile it first. (Only relevant when retaining GIDs.)

2. When reindexing charstrings, swap an accidentally-quadratic
implementation for one that is linear in the number of retained glyphs.
2021-12-09 23:44:57 -06:00
Cosimo Lupo
9b613b67c2
Merge pull request #2462 from fonttools/fix-subset-colr
subset/COLR: fix struct.error while subsetting Bungee COLR
2021-12-03 11:33:37 +00:00
Cosimo Lupo
780f2428b6 subset: when subsetting COLR only include glyphs after COLR closure, excluding glyf closure
Fixes #2461
2021-12-02 18:12:04 +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
Khaled Hosny
8e9ab24c11 [cffLib] Move desubroutinize from subset module to CFFFontSet
This way we can use it from both subset and merge modules.
2021-11-17 21:03:49 +02:00
Cosimo Lupo
247fa84b98 only rename glyph element ids when clash actually occurs 2021-11-16 14:28:14 +00:00
Cosimo Lupo
155ff60797 use any([<list comprehension>]) to avoid short-circuit function with side effect 2021-11-16 14:06:24 +00:00
Cosimo Lupo
07455790b1 simplify ranges() generator 2021-11-16 14:06:24 +00:00
Cosimo Lupo
66ec30c073 subset/svg: decorate xpath with lru_cache 2021-11-16 14:06:24 +00:00
Cosimo Lupo
d45da5df4c factor out method to resolve href targets as per review 2021-11-16 12:27:12 +00:00