Khaled Hosny
e116058bba
[directwrite] Use correct UTF-16 string length
...
Fixes https://github.com/harfbuzz/harfbuzz/issues/2474
2021-04-15 09:30:40 -06:00
Ben Denckla
668acff1f0
similarly improve comments on Hebrew ccc 18 & 19
...
Should have committed this along with commit 9658435a25
but forgot.
2021-04-13 11:01:22 -06:00
Ben Denckla
43d955207b
improve comments on Hebrew ccc 18 & 19
...
improve comments to reflect that:
ccc 18 includes both "flavors" of qamats: qamats [gadol] and qamats qatan
ccc 19 includes both "flavors" of holam: holam [not haser for vav] and holam haser for vav
This code and its comments may have been written before these code points were added to Unicode.
I.e. originally, these comments may have been complete, but they may have become incomplete in the meantime.
2021-04-13 11:01:22 -06:00
Qunxin Liu
9dc9f0385d
[subset] fix for fuzzer testcase: https://oss-fuzz.com/testcase-detail/5858518134554624
2021-04-09 11:07:28 -06:00
Qunxin Liu
430a67ceab
[subset] COLRv1 struct definitions
2021-04-08 11:27:01 -06:00
Qunxin Liu
553ffaf682
[subset] fix for fuzzer testcase: https://oss-fuzz.com/testcase-detail/6382598554255360
...
avoid writing to null pointer
2021-04-08 09:54:48 -06:00
Garret Rieger
8b686afeb5
[subset] add unlikely().
2021-04-06 12:34:44 -06:00
Garret Rieger
64122b5a44
[subset] don't visit lookup if covered glyph set has failed.
...
If covered glyph set is in error then the same lookup can be recursed into repeatedly potentially causing a fuzzer timeout. Fixes: https://oss-fuzz.com/testcase-detail/5416421032067072 .
2021-04-06 12:34:44 -06:00
Garret Rieger
6f98a8ed46
[subset] Anchor should only use format 1 when hints are dropped.
...
Refactor Anchor to have a subset method instead of copy. This also allows
use to use serialize_subset in several places which simplifies calculating
offset bases.
2021-04-06 11:50:44 -06:00
Garret Rieger
71d6d15600
[subset] clamp distance to prevent shifting outside of the limits of int64.
...
Fixes https://oss-fuzz.com/testcase-detail/4961171477233664 .
2021-04-06 11:48:39 -06:00
Khaled Hosny
fcacd17748
[ot] Update _hb_glyph_info_is_default_ignorable_and_not_hidden()
...
Used _hb_glyph_info_substituted() similar to the change made to
_hb_glyph_info_is_default_ignorable() in
7686ff854b
.
2021-04-06 11:47:06 -06:00
Garret Rieger
596f4258d0
[subset] copy Lookup::markFilteringSet when subseting.
2021-04-02 15:33:52 -06:00
Behdad Esfahbod
d3a2f999e4
Fix up build
...
This was left out; oops.
2021-04-02 08:33:03 -06:00
Garret Rieger
c35d786397
[subset] never drop the 'pref' feature.
...
Never ever drop feature 'pref', even if it's empty. Harfbuzz uses it to choose the shaper for Khmer.
2021-04-01 16:27:35 -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
Garret Rieger
b10741ca7f
[subset] when closing glyphs in context lookups don't use a current glyph set if a lookup is already applied.
2021-03-31 21:03:33 -06:00
Garret Rieger
8ef4257dc8
[sanitize] change max ops to track number of bytes processed.
...
Counting bytes as the operations is likely to be a better proxy for how
much work processing the table will cost vs. the current approach of
counting the number of sub-objects.
This should allow checks for max features, max scripts, etc. to be removed.
I tested this change against the full collection of fonts at https://github.com/google/fonts
and a max ops factor of 3 was sufficient to successfully sanitize all of them.
2021-03-31 19:03:30 -06:00
Behdad Esfahbod
70110f6aaa
Modify OffsetTo<>::sanitize() overflow check
...
The code in question was introduced in 70eb2ff682
.
Rewrite it to not call sanitizer check_range() as we want to use
check_range() for byte accounting.
Part of https://github.com/harfbuzz/harfbuzz/pull/2923
2021-03-31 17:04: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
1fc6b69aed
s/UnsizedOffsetArrayOf/UnsizedArray16OfOffsetTo/g
2021-03-31 15:30:35 -06:00
Behdad Esfahbod
2a54c9f744
.
2021-03-31 15:26:42 -06:00
Behdad Esfahbod
c539afb08b
[CFF] Use NNOffsetTo<> instead of OffsetTo<>
...
I'm pretty sure that's what is intended.
2021-03-31 13:28:25 -06:00
Behdad Esfahbod
9b4b58493b
Fixup for recent OffsetTo<> changes
2021-03-31 13:27:21 -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
Garret Rieger
c5c13006a1
[subset] fix memory leaks found in https://oss-fuzz.com/testcase-detail/5179935334465536
2021-03-31 12:37:45 -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
0f7f7536b9
[hvar] Change variation-index types from "unsigned int" to uint32_t
2021-03-31 11:31:49 -06:00
Behdad Esfahbod
9ffc46b8ff
Add VarIdx
2021-03-31 11:26:18 -06:00
Behdad Esfahbod
2179281c40
Add Offset24
2021-03-31 11:20:21 -06:00
Andrzej Perczak
cab9d5a57d
hb-config: Include config-override earlier
...
Currently config-override.h is included at the end of this file. This caused a problem for me while undefing HB_DISABLE_DEPRECATED, namely HB_IF_NOT_DEPRECATED was defined before actual undef took place and broke the whole build. I believe it would break builds for some other defines, too. Moving config-override.h include right after predefined configs is more sane and fixes all potential problems with includes.
2021-03-30 20:50:02 -06:00
Garret Rieger
adca4ce071
[subset] fixes https://oss-fuzz.com/testcase-detail/6173520787800064 .
...
Caused by incorrect bounds check in glyph closure for context lookups.
2021-03-30 15:44:41 -06:00
Garret Rieger
9f77a0c1ff
[subset] use hb_set_clear to avoid calling clear() on null pool set.
2021-03-30 15:12:52 -06:00
Garret Rieger
752e393ad2
[subset] avoid calling clear on null pool set.
2021-03-30 15:12:52 -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
Behdad Esfahbod
a8f9f85a91
[map] Return success from ->set()
2021-03-29 18:13:22 -06:00
Garret Rieger
8741914a80
[subset] fix memory leak when map insert fails.
2021-03-29 18:02:32 -06:00
Behdad Esfahbod
2397689387
Remove hb_success_t
...
Was not rolled-out yet. So just expand.
2021-03-29 17:49:16 -06:00
Behdad Esfahbod
7a2eda7817
Move code around
2021-03-29 17:49:12 -06:00
Behdad Esfahbod
bcb57dccaa
[sanitize] Add short-circuit to ArrayOfM1
...
Like the sibling ArrayOf types.
2021-03-29 17:49:08 -06:00
Garret Rieger
52df6b9fd8
[subset] check for set insertion success.
2021-03-29 17:41:07 -06:00
Garret Rieger
c6adb90a27
[subset] fix nullptr deref.
2021-03-29 17:41:07 -06:00
Garret Rieger
9a3537e5f6
[subset] invert err() return value. Undo previous change to check_success.
2021-03-29 17:15:22 -06:00
Garret Rieger
cdba5d44c2
[subset] fix incorrect handling of return value in check_success in the error case.
2021-03-29 17:15:22 -06:00
Behdad Esfahbod
05e845c49a
Make previous commit gcc-only
2021-03-29 16:02:10 -07:00
Behdad Esfahbod
b5e4032392
-Wno-unused-result
...
GCC doesn't let one turn off the warning using "(void) foo()".
People have introduced macros that do "unused << foo()" instead.
Until we do something similar, silence gcc.
Clang on the other hand understands "(void) foo()".
2021-03-29 15:57:36 -07:00
Qunxin Liu
95230e291d
[subset] support subsetting GSUB8
2021-03-29 15:54:11 -06:00
David Corbett
d18915f920
Reformat gen-tag-table.py
2021-03-28 10:21:46 -07:00
Garret Rieger
3c8273ab68
Check for alloc failures on the gsub/gpos_langsys maps in subset plan creation.
2021-03-25 16:53:56 -06:00
Behdad Esfahbod
29708e959a
[aat] Fix offsetToIndex math for out-of-bounds values
...
Previously, some bad font data was accidentally being interpretted as
legit if it happened to not fall out of memory bounds. The intention
of the code was what this commit does. I'm surprised we weren't getting
a "arithmetic between signed and unsigned values" warning / error
before.
2021-03-22 15:22:15 -07:00
Garret Rieger
46bf03d691
[subset] add NODISCARD to error checking methods on serializer.
2021-03-18 14:35:36 -07:00
Garret Rieger
3827a3eb56
[subset] rename serializer::set_error() to err().
2021-03-18 11:20:03 -07:00
Garret Rieger
f561fa6e4c
Change priority queue to use (priority, value) instead of (value, priority).
2021-03-18 11:13:47 -07:00
Garret Rieger
b14475d2ae
[subset] further changes to serializer error handling.
...
- Rename enum type and enum members.
- in_errors() now returns true for any error having been set. hb-subset now looks for offset overflow only errors to divert to repacker.
- Added INT_OVERFLOW and ARRAY_OVERFLOW enum values.
2021-03-18 10:51:26 -07:00
Garret Rieger
73ed59f7a6
[subset] store errors in the serializer as a flag set.
...
Make check_assign/check_equal specify the type of error to set.
2021-03-17 15:58:34 -07:00
Garret Rieger
b9ecc7420d
[subset] init offset_overflow in hb_serialize_context_t.
2021-03-17 15:53:58 -07:00
Garret Rieger
cf79fc342d
[subset] limit priority bumps to 16.
2021-03-17 15:53:58 -07:00
Garret Rieger
e2f14e81bd
[subset] fix memory leaks in test-repacker.
2021-03-17 15:53:58 -07:00
Garret Rieger
d3e2ba7c01
[subset] comment cleanup in hb-repacker.hh
2021-03-17 15:53:58 -07:00
Garret Rieger
832f2b599b
[subset] Refactor _subset () to reduce nesting and eliminate the use of 'goto'.
2021-03-17 15:53:58 -07:00
Garret Rieger
bb5c80a7c2
[subset] add error tracking to the repacker.
...
Also check for allocation failures as needed.
2021-03-17 15:53:58 -07:00
Garret Rieger
6e9468fcfb
[subset] cleanup memory leaks in the repacker.
2021-03-17 15:53:58 -07:00
Garret Rieger
a7a86a6eb4
[subset] Add prioritization offset resolution.
...
Vertices can now be prioritized to force them to sort closer to their parent. The resolver will attempt to use this for overflows on non-shared vertices.
2021-03-17 15:53:58 -07:00
Garret Rieger
b452b2c76c
[subset] refactor repacker graph to cache edge count and distances of vertices.
2021-03-17 15:53:57 -07:00
Garret Rieger
75414e82b5
[subset] Add table duplication overflow resolution.
2021-03-17 15:53:57 -07:00
Garret Rieger
8286bd8094
[subset] use vectors instead of hashmaps throughout the repacker since all keys will be mapped for these use cases.
2021-03-17 15:53:57 -07:00
Garret Rieger
519ae96617
[subset] switch sort_shortest_distance() to use priority queue.
2021-03-17 15:53:57 -07:00
Garret Rieger
5d3511e5b1
[subset] Change compute_distances() to use a priority queue.
2021-03-17 15:53:57 -07:00
Garret Rieger
59ac0a0d0a
[subset] Use priority for comparison in heap.
2021-03-17 15:53:57 -07:00
Garret Rieger
4c8dd41ed9
[subset] re-write compute distances to use an array lookup for the distance map.
2021-03-17 15:53:57 -07:00
Garret Rieger
5c4e0ffd97
[subset] Add a basic priority queue datastructure (binary heap).
2021-03-17 15:53:57 -07:00
Garret Rieger
dd8e5d0e1b
[subset] Only run the repacker for GSUB/GPOS.
2021-03-17 15:53:57 -07:00
Garret Rieger
aaa7873d42
[subset] add topological sort by closest distance via Dijkstra's algorithm.
2021-03-17 15:53:57 -07:00
Garret Rieger
8ebe5d734f
Implement will_overflow ().
2021-03-17 15:53:57 -07:00
Garret Rieger
6b1ea4cbe7
[subset] hook up the repacker to run if offset overflows are encountered during subsetting.
2021-03-17 15:53:57 -07:00
Garret Rieger
f4c78cc7dd
[subset] Implement Kahn's algo for topological sorting instead of BFS.
2021-03-17 15:53:57 -07:00
Garret Rieger
00f393dc3f
[subset] finish up BFS sort implementation.
2021-03-17 15:53:57 -07:00
Garret Rieger
1584d3cb8f
[subset] Start a proof of concept implementation of the GSUB/GPOS offset overflow resolver.
2021-03-17 15:53:57 -07: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
b8a58a0c0b
[subset] optimize glyph closure method: step 4
...
optimize recurse_lookups in Context/ChainContext
glyph closure, only the glyphs that the parent lookup
can apply the recursion to can participate in recursing
the lookup.
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
Qunxin Liu
b4fc593c3c
[subset] optimize glyph closure method: step1
...
Previous GSUB glyph closure is done by recursively visiting
all reachable lookup tables that apply to any glyphs in the
current/input glyph set, but actually only the glyphs that
the parent lookup can apply the recursion to can participate
in recursing the lookup. This is step 1 for glyph closure
optimization:
1. Add stack of currently active glyph set pointers into hb_closure_context_t
2. Update closure() method in simple GSUB tables to use
this stack in order not to change current glyph set at different stages
of recursion
3. Add function may_have_non_1to1() to GSUB tables
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
bb54e1047d
[subset] Also filter class1 by coverage when collecting variation indices 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
Khaled Hosny
03538e872a
2.8.0
2021-03-16 19:28:35 +02:00
Behdad Esfahbod
9e397ff2fb
[buffer] Fix order of HB_INTERNAL HB_DISCARD
...
Sucks that has to be specified in this order. But that is what it is for now.
Was only exhibiting problem on C++>=17 since that's when the [[nodiscard]]
was introduced.
2021-03-15 16:51:17 -06:00
Behdad Esfahbod
8450f43ae1
[buffer] HB_NODISCARD next_glyph()
2021-03-15 16:01:35 -06:00
Behdad Esfahbod
f4bc7673db
[buffer] Implement copy_glyph() in terms of output_info()
2021-03-15 16:01:35 -06:00
Behdad Esfahbod
f73982a699
[buffer] Implement replace_glyph() in terms of replace_glyphs(1,1)
...
I get exact same binary size with this, suggesting that compiler is
optimizing these as needed.
2021-03-15 16:01:35 -06:00
Behdad Esfahbod
862f913489
[buffer] Implement output_glyph() in terms of replace_glyphs(0,1)
...
To my surprise, saves ~20kb in my build (non-size-optimized) build.
The output_glyph() method is never used in the fast paths, so doesn't
matter if is not fully optimized for the special case it is.
2021-03-15 16:01:35 -06:00