Commit Graph

268 Commits

Author SHA1 Message Date
Behdad Esfahbod 4119f73c21 [subset/layout] Rename dispatch_closure_lookups_recurse_func to dispatch_recurse_func<> 2022-06-08 18:42:09 +01:00
Behdad Esfahbod 21346af01d [layout-cache] Adjust cost-function for recent change 2022-06-07 14:41:39 -06:00
Behdad Esfahbod bfee6839b0 [layout-cache] Cache lookahead, not input, classdef in ChainContextFormat2
From the commit:

+    /* For ChainContextFormat2 we cache the LookaheadClassDef instead of InputClassDef.
+     * The reason is that most heavy fonts want to identify a glyph in context and apply
+     * a lookup to it. In this scenario, the length of the input sequence is one, whereas
+     * the lookahead / backtrack are typically longer.  The one glyph in input sequence is
+     * looked-up below and no input glyph is looked up in individual rules, whereas the
+     * lookahead and backtrack glyphs are tried.  Since we match lookahead before backtrack,
+     * we should cache lookahead.  This decisions showed a 20% improvement in shaping of
+     * the Gulzar font.

https://github.com/harfbuzz/harfbuzz/pull/3636
2022-06-07 11:41:05 -06:00
Behdad Esfahbod 39820af72f [layout] Add HB_NO_OT_LAYOUT_LOOKUP_CACHE to disable caching lookups
Enabled when optimize-size profile is enabled.
2022-06-07 10:27:55 -06:00
Behdad Esfahbod c8fb048f79 [gsubgpos] Document caching 2022-06-07 09:20:27 -06:00
Behdad Esfahbod 5963cf4469 [gsubgpos] Merge cache_enter and cache_leave entry points
Saves a pointer per subtable
2022-06-07 09:17:14 -06:00
Behdad Esfahbod d4c09e9a87 [gsubgpos] Remove apply_cached() entry point
Just use a bool to apply()
2022-06-07 09:17:14 -06: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 f9b643f6b2 [layout] s/hb_get_subtables_context_t/hb_accelerate_subtables_context_t/g 2022-06-04 09:27:31 -06:00
Behdad Esfahbod a42c624fca Convert one final use of hashmap to unique_ptr 2022-06-03 01:22:34 -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 bca710e8ad [gsubgpos] Use map has() instead of get() when appropriate 2022-06-02 12:06:25 -06:00
Behdad Esfahbod e9407a2bd2 Use shared_ptr<hb_set_t> in one place
See if valgrind is happy...
2022-06-02 12:00:43 -06:00
Behdad Esfahbod 9a2a857043 [ot-shape] Don't verify buffer if shaping failed
Fixes all of fuzzing verify failures, which were result of buffer failure
on super-long results, which fails unsafe-to-break because shorter strings
don't fail shaping.
2022-05-31 06:35:42 -06:00
Behdad Esfahbod f4a8b70016 More member initialization 2022-05-30 05:30:37 -06:00
Behdad Esfahbod 97aa1ce6ba [gsubgpos] Move some member initialization 2022-05-29 10:56:41 -06:00
Behdad Esfahbod 3eb7eff487 Remove varstore cache use if HB_NO_VAR 2022-05-21 15:25:53 -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 202e6c4699 [subset] Remove unnecessary test 2022-05-18 17:12:43 -06:00
Behdad Esfahbod 4cfc2d668e [subset] Use a std::move on set_t when feasible 2022-05-18 15:32:19 -06:00
Behdad Esfahbod 6695bf0560 [gsubgpos] Remove wrong condition in Context application
Fixes https://github.com/harfbuzz/harfbuzz/issues/3545
2022-04-22 13:48:41 -06:00
Behdad Esfahbod a85461b9b6 Add link to Context LookupFlag discussion
https://github.com/harfbuzz/harfbuzz/discussions/3538
2022-04-20 12:13:40 -06:00
Behdad Esfahbod 044d7a06db [indic-like] Add per-lookup per-syllable flag
This allows mix-and-matching per-syllable and other lookups.
In fact, removes the clear-syllables call completely.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3513
2022-03-28 17:39:54 -06:00
Behdad Esfahbod e8f3397f4e [matcher] Simplify syllable initialization 2022-03-28 13:23:37 -06:00
Behdad Esfahbod ccd9161bfd [apply-lookup] Try to fix the logic for contextual lookups
Fixes https://github.com/harfbuzz/harfbuzz/issues/1611

Notably, this fixes Myles's AdditionFont:
https://litherum.blogspot.com/2019/03/addition-font.html

Test with AdditionFont, eg.:
$ util/hb-view AdditionFont.otf =1112112+1113134=
2022-03-25 15:14:40 -06:00
Behdad Esfahbod bf2a845a17 [ot-layout] Comment 2022-03-24 13:09:53 -06:00
Garret Rieger 4e2f409bce [subset] Don't hold references to members of the active_glyph_stack.
These references may get invalidated after the vector for the stack is resized. Fixes: https://oss-fuzz.com/testcase-detail/5422577634377728
2022-01-31 22:58:53 +02:00
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
Garret Rieger f3c1f4f0da [subset] convert active_glyphs_stack to be a vector of hb_set_t instead of hb_set_t*. 2022-01-28 14:20:33 -08:00
Behdad Esfahbod 60006d3687 [gsubgpos] Adjust chaining unsafe-to-concat application
Fixes three tests.
2022-01-22 11:53:18 -07:00
Behdad Esfahbod 78481b32c0 [gsubgpos] Combine input/backtrack/lookahead unsafe-to-concat
I feel like this is correct logic. Still have to prove.

Errors unchanged at 10.
2022-01-22 11:53:18 -07:00
Behdad Esfahbod 3122c2cdc4 [buffer] Add HB_GLYPH_FLAG_UNSAFE_TO_CONCAT
Fixes https://github.com/harfbuzz/harfbuzz/issues/1463
2022-01-22 11:53:18 -07:00
Behdad Esfahbod ac1bb3e39e [machinery] Move accelerators to constructor/destructor 2022-01-20 12:10:05 -07:00
Behdad Esfahbod e062376ef1 [machinery] Make accelerator lazy-loader call Xinit/Xfini
Instead of init/fini. To isolate those functions. To be turned into
constructor/destructors, ideally one per commit (after some SFINAE
foo.)
2022-01-19 17:09:34 -07:00
Behdad Esfahbod c8195dbc01
Merge pull request #3365 from harfbuzz/gdef-fix
GDEF fix
2022-01-19 06:56:05 -08:00
Behdad Esfahbod 5a91db1135 [map] Remove constexpr invalid items
These were non-workable in the general case, eg std::string.
2022-01-13 12:44:48 -07:00
Behdad Esfahbod fa12f1ae25 Rename method 2022-01-12 15:08:34 -07:00
Behdad Esfahbod 9408e0d6d1 Rename variable 2022-01-12 15:07:34 -07:00
Behdad Esfahbod 96c969c820 Preserve glyph props 2022-01-12 15:06:40 -07:00
Garret Rieger 77507a1d8d [subset] Don't double count visit lookups in closure_lookups
Each recursed lookup was getting counted once in closure_lookups() and then again in hb_closure_lookups_context_t::recurse.
2021-12-10 15:13:49 -07:00
Garret Rieger d67025705f [subset] reset the visited lookup count before each closure iteration. 2021-12-10 15:13:49 -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 98fefd5ded
Merge pull request #3301 from harfbuzz/hashmap-classes
Hashmap classes
2021-11-19 13:34:53 -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
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