Commit Graph

245 Commits

Author SHA1 Message Date
Garret Rieger bc899650c7 [subset] Fix for issue #3397.
cur_intersected_glyphs gets modified during recursion leading to incorrect filtering of sub tables in some cases. So don't use cur_intersected_glyphs. Instead just add an additional entry onto the parent_active_glyphs () stack.

Additionaly expands NotoNastaliqUrdu tests to include coverage of the issue from #3397.
2022-01-28 14:20:33 -08:00
Qunxin Liu 706014f69d [subset] (Chain)ContextSubst glyph_closure fix
- When pos_glyphs is empty, use current full glyphs set as input for
subsequent recursive closure process
- Also increase max_lookup_visit_count to 35000 cause a real font file hit
previous limit 20000 and some lookups are dropped unexpectedly
2021-12-10 11:08:36 -07:00
Qunxin Liu 51655a078e [subset] COLR : only include glyphs after COLR closure 2021-12-06 13:29:21 -07:00
Qunxin Liu 74b46b29e7 [subset] MATH: don't serialize coverage table when iterator is empty
when iterator is empty, just set coverage offset to 0.
serialize() in coverage will at lease write out a 16-bit format header.
2021-12-03 08:00:33 -07:00
Garret Rieger 9121ed0cec [subset] Improve sharing of Ligature subtables.
Ligature subtables use virtual links to enforce an ordering constraint between the subtables and the coverage table. Unfortunately this has the sideeffect of prevent the subtables from being shared by another Ligature with a different coverage table since object equality compares all links real and virtual. This change makes virtual links stored separately from real links and updates the equality check to only check real links. If an object is de-duped any virtual links it has are merged into the object that replaces it.
2021-12-01 08:37:04 -07:00
Garret Rieger 95329081c2 [subset] further optimize cmap4 packing. 2021-11-28 07:47:49 -07:00
Garret Rieger 599143824c [subset] Don't pad glyphs when using long loca. 2021-11-26 18:01:04 -07:00
Garret Rieger d9660fd58a [subset] Make cmap4 packing more optimal.
The current CMAP4 implementation uses whatever the current codepoint ranges are and then encodes them as indivudal glyph ids or as a delta if possible. However, it's often possible to save bytes by splitting up existing ranges and encoding parts of them using deltas where the cost of splitting the range is less than encoding each glyph individual.
2021-11-26 13:21:50 -07:00
Qunxin Liu 903a6baece [subset] layout_features filtering fix
we should not use get_size (), which returns length * item_size
2021-11-25 11:24:41 -07:00
Khaled Hosny 69d8f27c69 [meson] Require 0.55.0
We implicitly require it for building ragel subproject. This new version
requirement should satisfied in both Fedora 33 and Debian bullseye, and
not be too cutting edge for us.
2021-11-22 03:11:36 +02:00
Qunxin Liu 84dc4e85e8 [subset] avoid writing out duplicate extra glyph names in post table
Add check for possible duplicate with other name index
2021-11-19 17:22:35 -07:00
Qunxin Liu ca418cac74 [subset] keep features that have FeatureParams and the tag is "size" 2021-11-19 13:31:25 -07:00
Qunxin Liu e88fc41ef3 [subset] inputSequence could be empty, change the sanity check 2021-11-19 12:57:43 -07:00
Qunxin Liu 540f19b6fe [subset] fix bug in (Chain)ContextFormat2
Only keep rulesets for glyphs class numbers that survived in coverage
2021-11-02 16:05:55 -07:00
Garret Rieger e260eeb9be [subset] Update test goldens for gdef.glyphset. 2021-11-02 16:56:52 -06:00
Qunxin Liu 60e203644b [subset] use glyphset_gsub instead of glyphset for GDEF 2021-11-02 16:56:52 -06:00
Garret Rieger e39647c0f1 [subset] update subset goldens to fix tests. 2021-11-02 16:26:02 -06:00
Qunxin Liu 364b6b3989 [subset] Don't assume FeatureList is sorted
Though the spec said FeatureRecords are sorted alphabetically by feature
tag, there're font files with unsorted FeatureList. And harfbuzz is not
able to subset these files correctly because we use binary search in
finding featureRecords when collecting lookups. Also
find_duplicate_features needs to be updated to handle this.
2021-11-02 15:15:02 -07:00
Garret Rieger 49c9392412 [subset] During LigatureSubstFormat1 subsetting always place Coverage last.
In Windows 7 on Chrome if the coverage table comes before any of the LigatureSet or Ligature subtables the font won't load. This changes the packing order to always place the Coverage table last. Virtual links are used to ensure the repacker maintains the desired ordering.

Coincidentally fontTools also does the same thing (a3f988fbf6/Lib/fontTools/ttLib/tables/otTables.py (L1137)) to reduce overflows during packing.
2021-11-02 12:19:13 -06:00
Behdad Esfahbod 4262636926
Merge pull request #3248 from googlefonts/connected_components
[repacker] Keep connected subgraphs in the same space.
2021-10-23 13:18:22 -07:00
Qunxin Liu 8c583db9b5 [subset] COLRv1: update subset() method for new strutc ClipList and VarIdxMap
Also fix issues in struct PaintTransform definition
2021-10-23 11:22:39 -07:00
Garret Rieger 79937d24b7 [repacker] Add repacker test that requires space splitting. 2021-10-05 12:53:21 -07:00
Garret Rieger d5beb96e06 [repacker] add repacker isolation test on real font. 2021-09-22 18:18:50 -06:00
Qunxin Liu ca7b9daef0 [subset] subset MATH table 2021-09-22 18:08:30 -04:00
Garret Rieger c2cc566c9d [subset] Fix subset_offset_array adding unused space to serializer.
ArrayOf.serialize_append allocates space for the new item, but ArrayOf.pop() does not recover the allocated space. So in the case where the revert path was entered the extra space added by serialize_append gets left in the serialization buffer. This moves the snapshot to before ArrayOf.serialize_append is called so that revert cleans up the buffer extend.
2021-09-22 16:07:18 -06:00
Qunxin Liu 8c5c81746d [subset] fix find_duplicate_features
We should check each feature against all other features with the same
tag for duplicates.
2021-09-22 15:35:38 -06:00
Qunxin Liu 37379f8f7d [subset] fox for (Chain)ContextFormat3: subset lookupRecord
skip copying a lookupRecord if lookup referenced in the lookupRecord is
not retained after subset
2021-09-08 13:55:21 -06:00
Qunxin Liu 34e0b28fae [subset] make glyph-names option match fonttools behavior
Don't encode psNames that are contained in standard glyph names set
2021-08-20 01:30:23 -06:00
Garret Rieger 44802c8ec4 [subset] use layout-features=* for layout subsetting tests w/ synthetic test fonts. 2021-08-12 14:57:18 -06:00
Behdad Esfahbod 58bfe40794 [util] Move hb-subset away from main-font-text 2021-08-11 20:12:36 -06:00
Khaled Hosny f122698810 [test] Improve generate-expected-outputs.py diff output 2021-08-12 02:02:10 +02:00
Garret Rieger e39c3bde7b [subset] fix bug in parsing glyf flags.
the bytes of the flag stream were being treated as signed integers instead of unsigned as specified in the spec.
2021-08-10 12:57:07 -06:00
Behdad Esfahbod f3acb977ec [test/shaping;util] Use ';' instead of ':' to separate test fields
Accept that in --batch mode. Also in batch mode don't send the 0th arg.

Related discussion: https://github.com/harfbuzz/harfbuzz/pull/3102
2021-08-10 11:08:36 -06:00
Behdad Esfahbod b83fd3a564 [util] Refactor batch-processing code into batch.hh 2021-08-10 02:32:55 -06:00
Garret Rieger c2ee1fdd40 [subset] remove unsed table_entry struct. 2021-08-05 11:47:07 -06:00
Garret Rieger dea0fe5717 [subset] discard extra copies of a table in face builder.
Fixes #2361. Stores tables in the builder in a hashmap so you end up with at most one copy of each table. Table serialization order is now based on tag sort order instead of order of insertion into the builder.
2021-08-05 11:47:07 -06:00
Garret Rieger 2c024dc3cb [subset] prune redundant cmap12 subtables.
If the post subset cmap12 table is equivalent to another cmap subtable don't include the 12 table in the final subset. Matches change https://github.com/fonttools/fonttools/pull/2146 from fontTools.
2021-08-04 17:36:24 -06:00
Khaled Hosny 84946e4d2c [test] Suggest updating the expectation if ttx matches
https://github.com/harfbuzz/harfbuzz/issues/3089#issuecomment-892208892
2021-08-04 17:35:19 -06:00
Khaled Hosny f698fe5aee [test] Always fail subset tests if hashes don’t match
Regardless of the pre sentience or absence of fonttools.
2021-08-04 10:26:14 -06:00
Khaled Hosny 9f544e5008 [test] Don’t skip subset tests early
Check for FontTools only when the checksums are mismatching.
2021-08-04 04:20:14 +02:00
Khaled Hosny b084153317 [test] Remove subset tests from the slow suite 2021-08-04 04:12:31 +02:00
Khaled Hosny 7ccc52b075 [test] Compare sha256 hash before TTX dumps
Most of time the files are identical, so instead of comparing the TTX
dump we can check sha256 hashes of the files first and if they match, we
don’t have to check the TTX dumps at all, making the subset tests orders
of magnitude faster.

time meson test --suite=subset down from:
real    0m19.418s
user    0m38.171s
sys     0m3.587s

to:
real	0m3.102s
user	0m8.622s
sys	0m1.701s

The expected files have been replaced by hb-subset output so they are
bit-identical where FontTools output might not.

The generate-expected-outputs.py now compares the hb-subset output with
fontttols subset and errors of they don’t match.
2021-08-04 04:10:38 +02:00
Khaled Hosny 770fbd5aa6 Revert "[test] Speed-up subset tests by saving TTX dump"
This reverts commit 278f44dcee.
2021-08-04 04:10:37 +02:00
Khaled Hosny 10e73d188a [test] Add batch mode to hb-subset and use it
time meson test --suite=subset down from:
real	0m22.822s
user	0m44.561s
sys	0m9.255s

to:
real	0m19.418s
user	0m38.171s
sys	0m3.587s

Does not seem to help much, but it is something.

Part of https://github.com/harfbuzz/harfbuzz/issues/3089
2021-08-01 22:08:28 -06:00
Behdad Esfahbod 7cbcdaf68a Whitespace 2021-07-30 11:26:46 -06:00
Khaled Hosny f6c67a5fcf [test] Open file in UTF-8
It is 2021 and Python still does not default to UTF-8 on Windows!
2021-07-30 02:20:19 +02:00
Khaled Hosny bafbade087 [test] Force FontTools to use \n on all platforms
On Windows in helfuly uses \r\n.
2021-07-30 01:42:45 +02:00
Khaled Hosny 278f44dcee [test] Speed-up subset tests by saving TTX dump
Speed-up subset tests by saving TTX dump of expected output instead of
generating it each time the tests are run.

Cuts down meson test --suite=subset on my system from:
real	0m38.977s
user	1m12.024s
sys	0m10.547s

to:
real	0m22.291s
user	0m44.548s
sys	0m9.221s

Part of https://github.com/harfbuzz/harfbuzz/issues/3089
2021-07-30 00:00:35 +02:00
Garret Rieger acbd8b27dc [subset] temporarily disable COLRv1 subsetting.
Currently COLRv1 spec is being changed so the subsetting implementation is out of sync. Disable subsetting by failing sanitization for COLRv1 tables and disable all colrv1 tests.
2021-07-28 11:36:34 -06:00
Qunxin Liu 71b5509c19 [subset] support option --glyph-names 2021-07-23 13:57:39 -07:00