Behdad Esfahbod
5fd0a3f0b9
[>64k:layout] Templatize GSUBGPOSFormat1
2022-07-12 13:42:52 -06:00
Behdad Esfahbod
ca5c8a6419
[>64k:layout:Coverage] Implement format 3/4
...
Implements rest of https://github.com/be-fonts/boring-expansion-spec/issues/30
2022-07-12 13:42:52 -06:00
Behdad Esfahbod
25de6fb4e7
[>64k:layout:ClassDef] Implement format 3/4
...
This implements part of https://github.com/be-fonts/boring-expansion-spec/issues/30
2022-07-12 13:42:52 -06:00
Behdad Esfahbod
9286526f37
[>64k:layout] Templatize Coverage & ClassDef
...
Have not added new formats yet.
2022-07-12 13:42:52 -06:00
Behdad Esfahbod
e8cce9d1b3
[>64k:layout] Add SmallTypes & MediumTypes
2022-07-12 13:42:52 -06:00
Behdad Esfahbod
8a971d01e9
[layout] Use is_source_of instead of is_iterator
2022-07-08 12:01:48 -06:00
Behdad Esfahbod
0dc0da054d
[iter] Add hb_is_sorted_iterator(_of)
2022-07-08 12:01:38 -06:00
Garret Rieger
587969af42
[subset] Drop scripts that are not in the layout_scripts list.
2022-06-30 21:37:42 +00:00
Behdad Esfahbod
b96622d15c
[layout] Use a cache for main input ClassDef of (Chain)ContextLookupFormat2
...
This commit adds a per-lookup caching infrastructure to GSUB/GPOS, and
uses it to cache input ClassDef.get_class value for (Chain)ContextLookupFormat2.
For fonts heavy on use of heave class-based2 context matching, this shows
a good speedup. For NotoNastaliqUrdu for example, I observe 17% speedup.
Unfortunately not many other lookups can use a cache like this :(.
https://github.com/harfbuzz/harfbuzz/pull/3636
2022-06-07 09:14:38 -06:00
Behdad Esfahbod
e6409d3905
Revert "[layout] Use a cache for main input ClassDef of (Chain)ContextLookups"
...
This reverts commit 57d1c08739
.
Err. This was an accident.
2022-06-05 06:57:37 -06:00
Behdad Esfahbod
57d1c08739
[layout] Use a cache for main input ClassDef of (Chain)ContextLookups
2022-06-05 06:54:19 -06:00
Behdad Esfahbod
f13a79548f
[subset] Convert another use of hashmap to unique_ptr
2022-06-03 01:17:20 -06:00
Behdad Esfahbod
997d9cc466
[map] Make unique_ptr hashable
2022-06-02 18:47:42 -06:00
Behdad Esfahbod
5af5a56593
[VarStore] Implement writing 32bit var-store
...
Untested.
Finishes fixing https://github.com/harfbuzz/harfbuzz/issues/2965
2022-05-31 03:58:35 -06:00
Behdad Esfahbod
75112098ac
[VarStore] Implement reading 32bit var-store
...
Untested.
Part of https://github.com/harfbuzz/harfbuzz/issues/2965
Serializing is incomplete.
2022-05-31 03:58:29 -06:00
Behdad Esfahbod
e5d6da7905
[varStore] rename shortCount to wordCount
2022-05-30 07:48:58 -06:00
Behdad Esfahbod
371e14d99c
Combine uses of map has() then get() with has(.., &..)
2022-05-28 13:40:30 -06:00
Behdad Esfahbod
6010feeeb5
[varStore] Rename variable as per review
...
https://github.com/harfbuzz/harfbuzz/pull/3605
2022-05-24 09:01:02 -06:00
Behdad Esfahbod
d9acc045f1
[VarStore] Sprinkle cache_t type around
...
It's available so no need to use void*.
2022-05-21 15:12:14 -06:00
Behdad Esfahbod
da38312e42
[VarStore] Pepper cache with likely()
2022-05-21 15:12:14 -06:00
Behdad Esfahbod
cf8f00e354
[VarStore] Don't use NAN
...
Is faster.
With this, I'm seeing 25 to 28% speedup in glyph_h_advances benchmark
of benchmark-font for var/hb tests.
2022-05-21 15:12:14 -06:00
Behdad Esfahbod
880f50f7e4
Refactor varstore cache
2022-05-21 15:12:14 -06:00
Behdad Esfahbod
f2a2fb91a3
[GPOS] Cache VarStore region scalars
2022-05-21 15:12:14 -06:00
Behdad Esfahbod
5fbc70c59b
[VarStore] Add cache API
2022-05-21 15:12:14 -06:00
Garret Rieger
3ab2c7935f
[subset-perf] Signficiantly speed up ClassDef*::subset.
...
Eliminates the usage of a glyph -> klass hash map and replaces it with a vector storing the mapping. This allows us to use the vector directly as the iterator driving the serialize. Approximately 1% speedup for Noto Nastaliq.
2022-05-19 12:37:28 -06:00
Garret Rieger
0b1c2ff96a
[subset-perf] Remove extra map lookup in ClassDef subset methods.
2022-05-18 18:25:36 -06:00
Garret Rieger
13ace77f1d
[subset-perf] Use glyph_map instead of set in ClassDefFormat.
2022-05-18 18:25:36 -06:00
Garret Rieger
adae2f2272
[subset-perf] Cache a glyph map for gsub.
...
This allows us in some cases to avoid using glyph_set_gsub as a filter.
2022-05-18 18:25:36 -06:00
Behdad Esfahbod
cedf739646
Add some commented-out code
2022-05-18 16:53:26 -06:00
Garret Rieger
48dfbd54a3
[subset] minor cleanup.
2022-05-18 15:24:54 -06:00
Garret Rieger
482c6e5dc4
[subset-perf] Speed up Coverage::serialize by caching iterator.
2022-05-18 15:24:54 -06:00
Behdad Esfahbod
14b18725f0
In Coverage::iter_t, assume iterators are from same Coverage object
...
No need to support otherwise.
2022-05-18 15:14:32 -06:00
Behdad Esfahbod
27141735c3
[subset] Add Coverage::__end__ implementation
2022-05-18 15:12:49 -06:00
Behdad Esfahbod
c476f58adb
[subset] Write CoverageFormat2::intersects_coverage() as bsearch()
2022-05-18 14:20:23 -06:00
Behdad Esfahbod
63c6695108
[ot-layout] Cosmetic
...
The implementation of HBUINT16 operator == is slower than just
comparing to ints.
2022-05-18 13:53:52 -06:00
Behdad Esfahbod
777debd748
[subset] Rewrite CoverageFormat2::intersects as dagger
2022-05-18 13:46:06 -06:00
Behdad Esfahbod
cf5001fac7
[subset] Optimize CoverageFormat2::intersected_coverage_glyphs
2022-05-18 13:38:29 -06:00
Behdad Esfahbod
6f37c20798
[subset] Minor rewrite in CoverageFormat2::serialize()
2022-05-18 13:25:42 -06:00
Behdad Esfahbod
175319cd89
[gsubgpos] Clean up OT::ClassDefFormat2::intersected_class_glyphs 0 case
2022-05-11 13:47:17 -06:00
Behdad Esfahbod
137af3612b
[gsubgpos] Simplify OT::ClassDefFormat2::intersected_class_glyphs()
2022-05-11 13:39:30 -06:00
Behdad Esfahbod
3261e05bdb
[subset] Optimize ClassDef1::intersected_class_glyphs() for class0
2022-05-11 13:16:31 -06:00
Behdad Esfahbod
a792e16e48
[ot-layout] Change max nesting level of lookups from 6 to 64
2022-03-24 13:08:51 -06:00
Qunxin Liu
7cb002cb58
[subset] bug fix in prune_langsys
...
we should not cache visited langsys cause 2 different Record<Langsys>
could have different Tag while pointing to the same Langsys, a langsys
is redundant in Record<Langsys> A does not mean it's redundant in Record
B. Same thing for visited_script.
Also adding the number of features in the LangSys's feature list to the
visited langsys count so it's more accurate.
Plus some improvement in langsys compare()
2022-03-16 13:08:13 -06:00
Behdad Esfahbod
de2cef42b4
[bimap] Remove init/fini
2022-01-18 09:21:31 -07:00
luz paz
e2e305066a
Fix various typos
...
Found via `codespell -q 3 -S ./perf/texts -L actualy,ba,beng,fo,gir,inout,nd,ot,pres,ro,te,teh,timne`
2022-01-16 05:39:03 -08:00
Garret Rieger
067f90a820
[subset] Fix for fuzzer timeout.
...
Fixes https://oss-fuzz.com/testcase-detail/5549945449480192
In prune_langsys: move LangSys visited check up before any work is done for a LangSys. In this particular case the compare() method is responsible for the majority of the time spent and wasn't being guarded with a visisted check.
2021-12-14 17:34:21 -07: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
Behdad Esfahbod
394f772937
[map] Allow storing classes in the hashmap
...
Fixes https://github.com/harfbuzz/harfbuzz/issues/3293
The trick was to change the type of the invalid key/value to be non-class.
2021-11-19 11:49:23 -07:00
Garret Rieger
a75b96f7e5
[sanitize] In lookup sanitize don't try to access subtable 0 if it isn't there.
2021-11-16 15:00:50 -08: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
Behdad Esfahbod
6d555ce82e
[meta] Use std::forward instead of hb_forward()
2021-11-02 00:18:22 -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
Behdad Esfahbod
14a2df7bc2
Add stub HBUINT15
2021-09-19 23:06:09 -04:00
Behdad Esfahbod
c852b86841
Rename HBGlyphID to HBGlyphID16
2021-09-19 16:30:12 -04:00
Garret Rieger
b63ac57174
[subset] bail if collection region indices is in error.
2021-07-29 18:30:37 -07:00
Behdad Esfahbod
30579f5a37
[set] Document & use open-ended del_range()
2021-07-29 11:19:13 -06:00
Behdad Esfahbod
2d54c34680
[subset/VarStore] Fix OOM in fuzzer test
...
The test in question is the one added in c68a00b92e
.
Culprit is that it's allocating lots of memory because of region_indices that
are out-of-range anyway. So, try to filter those out first.
2021-07-29 00:49:36 -06:00
Behdad Esfahbod
ff1fe25a5d
[VarStore] Rename internal get_scalars() to get_region_scalars()
2021-07-29 00:49:36 -06:00
Behdad Esfahbod
f0a1892ff9
[serialize] Remove unnecessary pointer indirection
2021-07-28 17:36:22 -06:00
Behdad Esfahbod
1c511ed6f6
[subset] Simplify VarStore serialization
2021-07-28 17:33:26 -06:00
Behdad Esfahbod
ad4c692492
[subset] Simplify VarStore serialize
2021-07-28 17:22:14 -06:00
Behdad Esfahbod
25dee60977
[sanitize] Revert some from c68a00b92e
...
That overflow check was already happening in arrayZ.sanitize().
2021-07-28 13:58:24 -06:00
Behdad Esfahbod
c68a00b92e
[subset] Fix possible overflows in VarRegionList serialize
...
Fixes https://oss-fuzz.com/testcase-detail/5362189182566400
2021-07-27 13:28:09 -06:00
Behdad Esfahbod
03cd9c5cba
Align lfind() API to match bfind()
2021-07-22 11:38:27 -07:00
Garret Rieger
6269866bdd
[subset] Keep bimap consistent if only one of the internal maps is in error.
2021-07-19 13:42:00 -06:00
Garret Rieger
48edbef96f
[subset] bail if region_map is in error.
...
Fixes fuzzer case https://oss-fuzz.com/testcase-detail/5499162606043136 .
2021-07-19 13:42:00 -06:00
Garret Rieger
0da9158f62
[subset] Remove OffsetTo::serialize().
...
Convert remaining uses of it to serialize_serialize() which correctly uses the object packer.
2021-06-30 14:05:48 -07:00
Garret Rieger
be50779cda
[subset] correct ClassDef format determination.
...
It was possible for glyph_min to be a glyph mapped to class zero which threw off the number of glyph calculation.
2021-04-30 14:46:57 -06:00
Qunxin Liu
84dbfacfec
[subset] fix collect_variation_idx in PairPosFormat2
2021-04-23 18:52:24 -07:00
Garret Rieger
596f4258d0
[subset] copy Lookup::markFilteringSet when subseting.
2021-04-02 15:33:52 -06:00
Behdad Esfahbod
092094f705
Use as_array() and range loops in a few places
2021-04-01 16:02:54 -06:00
Garret Rieger
55e7f3fe32
[subset] Match FeatureVariationRecord dropping from fontTools.
...
Only drop records with no matching features that are at the end of the list. See: cab7d13dc0
2021-04-01 15:26:02 -06:00
Garret Rieger
f0c78e0282
[subset] don't drop features referenced in a feature variation substitution.
2021-04-01 15:26:02 -06:00
Garret Rieger
dae99b7769
[subset] don't keep FeatureVariationRecord's with no subsittutions.
2021-04-01 15:26:02 -06:00
Behdad Esfahbod
4dba749d83
Add SortedArray{16,32}Of<>
2021-03-31 16:09:39 -06:00
Behdad Esfahbod
5639e253f9
Add Array16Of<>
2021-03-31 16:04:43 -06:00
Behdad Esfahbod
2520a82df9
s/LArrayOf/Array32Of/g
2021-03-31 15:41:54 -06:00
Behdad Esfahbod
5efe360986
Rename (Unsized)OffsetListOf
2021-03-31 15:33:22 -06:00
Behdad Esfahbod
6c4e0491d7
s/OffsetArrayOf/Array16OfOffset16To/g
2021-03-31 15:31:32 -06:00
Behdad Esfahbod
2a54c9f744
.
2021-03-31 15:26:42 -06:00
Behdad Esfahbod
ad28f973f3
Rename offset types to be explicit about their size
...
Add Offset16To<>, Offset24To<>, and Offset32To<> for most use-cases.
2021-03-31 13:00:07 -06:00
Behdad Esfahbod
bd2950b393
Make VariationStore::get_delta(outer, inner) private
2021-03-31 11:36:36 -06:00
Behdad Esfahbod
934675a429
Use VarIdx in VariationDevice
2021-03-31 11:34:41 -06:00
Behdad Esfahbod
9ed5f04a70
[subset] Simplify recent out-of-memory fixes
...
By checking return status of map->set().
2021-03-29 18:14:30 -06:00
Garret Rieger
8741914a80
[subset] fix memory leak when map insert fails.
2021-03-29 18:02:32 -06:00
Qunxin Liu
56ca435787
[subset] fix for collect_features and remove_redundant_lamngsys
...
previously remove_redundant_sys () is missing in harfbuzz, after
redundant langsys removal, some features are removed as well in
prune_features() in fonttools. This change is trying to get the same
result between harfbuzz and fonttools.
2021-03-17 14:24:04 -07:00
Qunxin Liu
0e1c0fa404
[subset] optimize glyph closure method: step 5
...
add testcase and some fixes
2021-03-17 15:22:07 -06:00
Qunxin Liu
62423504ee
[subset] optimize glyph closure method: step 3
...
Add function intersects_coverage_glyphs that collects
set of matching glyphs in Coverage table
2021-03-17 15:22:07 -06:00
Qunxin Liu
ef78d0f923
[subset] optimize glyph closure method: step 2
...
Add function intersects_class_glyphs that collects
set of glyphs matching class in ClassDef table
2021-03-17 15:22:07 -06:00
Garret Rieger
2df39bcae7
[subset] don't allocate a set to use as a glyph filter for PairPosFormat2.
2021-03-16 14:49:35 -07:00
Garret Rieger
190b7a98f8
[subset] Update PairPosFormat2 subsetting to match fontTools updated subsetting ( https://github.com/fonttools/fonttools/pull/2221 )
...
- subset class def 1 against the coverage table.
- Don't re-use class 0 in class def 2.
- Ignore class 0 glyphs for the purposes of determing format 1 vs format 2 encoding for ClassDef.
Add an additional test case which demonstrates these issues.
2021-03-16 14:49:35 -07:00
Behdad Esfahbod
3622120fab
[subset] Make ClassDef format2 .intersects() return false if range value 0
...
We treat Class0 as "doesn't intersect". That's the only meaningful
interpretation. If one allos Class0 to mean "intersects", then the
intersects() result should be true iff glyphset is non-empty.
Related to https://github.com/harfbuzz/harfbuzz/issues/2703
2021-03-10 12:21:43 -07:00
Behdad Esfahbod
6c4bb60829
Fix narrowing errors with recent changes
2021-02-22 23:05:55 -07:00
Behdad Esfahbod
f4f35a4d5f
[constexpr] Use initializer instead of assignment
2021-02-22 22:32:42 -07:00
Behdad Esfahbod
6a3fd94f3b
Merge pull request #2699 from googlefonts/gpos_8
...
[subset] Add a more complex layout subsetting test case and fix the issues it exposed.
2021-02-09 20:49:04 -05:00
Behdad Esfahbod
ca0b7afee9
[set] Use hb_fill()
2021-01-21 12:22:00 -07:00
Behdad Esfahbod
6463ee02d6
Speed up ClassDef/Coverage intersect methods
...
Just avoiding overhead as measured by Garret.
Should rewrite as dagger in the future and confirm that it has the
same benefits. Later on, rewrite as lfind() maybe.
Fixes https://github.com/harfbuzz/harfbuzz/issues/2826
2021-01-21 11:16:04 -08:00
Garret Rieger
e583505334
[subset] Use plan->glyphset_gsub instead of plan->glyphset for GSUB/GPOS
...
This matches fontTools behaviour. glyphset_gsub does not contain gids added from closing over composite glyphs in glyf, since these cannot particpate in GSUB/GPOS processing.
2020-09-29 11:16:15 -07:00
Garret Rieger
9825e3dd2e
[ENOMEM] fix access to unitialized memory.
...
If the serialize() call fails to write the object then we can't safely read varstore_prime fields. Fixes https://oss-fuzz.com/testcase-detail/5137462782066688 .
2020-09-02 11:01:07 -07:00