Commit Graph

10335 Commits

Author SHA1 Message Date
Behdad Esfahbod c1f4b57c06 [ot-tags] Optimize language comparison
Now that we know both strings are of equal len of 2 or 3, optimize.

Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Before:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.50 ns         8.47 ns     81221549
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         79.6 ns         79.3 ns      8785804
BM_hb_ot_tags_from_script_and_language/COMMON en_US         40.0 ns         39.9 ns     17462768
BM_hb_ot_tags_from_script_and_language/LATIN en_US          39.2 ns         39.1 ns     17886793
BM_hb_ot_tags_from_script_and_language/COMMON none          4.31 ns         4.30 ns    162805417
BM_hb_ot_tags_from_script_and_language/LATIN none           4.32 ns         4.31 ns    162656688

After:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.27 ns         8.24 ns     81868701
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         56.1 ns         56.0 ns     12353284
BM_hb_ot_tags_from_script_and_language/COMMON en_US         24.3 ns         24.2 ns     28955030
BM_hb_ot_tags_from_script_and_language/LATIN en_US          24.5 ns         24.4 ns     28664868
BM_hb_ot_tags_from_script_and_language/COMMON none          4.35 ns         4.34 ns    161190014
BM_hb_ot_tags_from_script_and_language/LATIN none           4.36 ns         4.34 ns    161319000
2022-05-17 15:19:40 -06:00
Behdad Esfahbod dde48d78c1 Fix compiler warning 2022-05-17 15:07:49 -06:00
Behdad Esfahbod 15be0deda0 [ot-tags] Optimize lang_matches()
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Before:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.67 ns         8.64 ns     80324382
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         91.2 ns         90.9 ns      7674131
BM_hb_ot_tags_from_script_and_language/COMMON en_US         41.1 ns         41.0 ns     17174093
BM_hb_ot_tags_from_script_and_language/LATIN en_US          41.3 ns         41.2 ns     17000876
BM_hb_ot_tags_from_script_and_language/COMMON none          4.56 ns         4.55 ns    153914130
BM_hb_ot_tags_from_script_and_language/LATIN none           4.53 ns         4.52 ns    153830303

After:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.24 ns         8.21 ns     84078465
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         77.5 ns         77.2 ns      9059230
BM_hb_ot_tags_from_script_and_language/COMMON en_US         38.8 ns         38.7 ns     17790692
BM_hb_ot_tags_from_script_and_language/LATIN en_US          37.6 ns         37.5 ns     18648293
BM_hb_ot_tags_from_script_and_language/COMMON none          4.50 ns         4.49 ns    155573267
BM_hb_ot_tags_from_script_and_language/LATIN none           4.49 ns         4.47 ns    156456653
2022-05-17 14:57:08 -06:00
Behdad Esfahbod dd3c858f84 [ot-tags] Speed up hb_ot_tags_from_language()
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

"After that, bulk of the time I suppose is spent in binary-searching the
language table. I suggest we split the language table in 2-letter and
3-letter tags, to speed-up the vast majority of cases that are
2-letter."

benchmark-ot, before:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        112 ns          111 ns      6286271
BM_hb_ot_tags_from_script_and_language/COMMON en_US       60.6 ns         60.4 ns     11671176
BM_hb_ot_tags_from_script_and_language/LATIN en_US        61.3 ns         61.1 ns     11442645
BM_hb_ot_tags_from_script_and_language/COMMON none        4.75 ns         4.74 ns    146997235
BM_hb_ot_tags_from_script_and_language/LATIN none         4.65 ns         4.64 ns    150938747

After:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN       89.5 ns         89.2 ns      7747649
BM_hb_ot_tags_from_script_and_language/COMMON en_US       38.5 ns         38.4 ns     18199432
BM_hb_ot_tags_from_script_and_language/LATIN en_US        39.0 ns         38.9 ns     18049238
BM_hb_ot_tags_from_script_and_language/COMMON none        4.53 ns         4.52 ns    154895110
BM_hb_ot_tags_from_script_and_language/LATIN none         4.54 ns         4.52 ns    154762105
2022-05-17 14:28:28 -06:00
Behdad Esfahbod 9baccb9860 [ot-tags] Speed up hb_ot_tags_from_complex_language()
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

2. All the subtag_matches outside the switch match long strings (>= 6 or so).
   As such, check the tag for such length before going into any of them.

benchmark-ot, before:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        172 ns          171 ns      4083155
BM_hb_ot_tags_from_script_and_language/COMMON en_US        120 ns          119 ns      5849947
BM_hb_ot_tags_from_script_and_language/LATIN en_US         113 ns          112 ns      5840326
BM_hb_ot_tags_from_script_and_language/COMMON none        4.66 ns         4.64 ns    151396224
BM_hb_ot_tags_from_script_and_language/LATIN none         4.66 ns         4.64 ns    149019593

After:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        112 ns          112 ns      6357763
BM_hb_ot_tags_from_script_and_language/COMMON en_US       60.5 ns         60.3 ns     11475091
BM_hb_ot_tags_from_script_and_language/LATIN en_US        54.9 ns         54.8 ns     12575690
BM_hb_ot_tags_from_script_and_language/COMMON none        4.61 ns         4.59 ns    152388450
BM_hb_ot_tags_from_script_and_language/LATIN none         4.66 ns         4.64 ns    151497600
2022-05-17 13:34:34 -06:00
Behdad Esfahbod fb413f5202 [subset/cff] Don't use bitfields for hot bools
The struct has room because of alignment, and these bools are hot.
2022-05-16 17:38:18 -06:00
Behdad Esfahbod a4d98b63ea [subset/cff1] Collect glyph-to-sid map to avoid an O(n^2) algorithm
Saves 13 for largest benchmark:

BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/10000                    -0.1313         -0.1308            75            65            75            65

BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/4096                 -0.1009         -0.1004            54            48            54            48
BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/10000                -0.1067         -0.1066            70            62            69            62
2022-05-16 17:38:18 -06:00
Behdad Esfahbod b87f48e948 [cff1] get_sid() move bounds check into each implementation 2022-05-16 17:38:18 -06:00
Behdad Esfahbod e1e359b4da [cff1] Tighten up range_list_t a bit 2022-05-16 16:36:28 -06:00
Behdad Esfahbod 3fbac0942d [cff1] Lazy-load & sort glyph names
Improves subset benchmarks by up to 70% for small CFF1 subset of
non-CID fonts!

BM_subset/subset_glyphs/SourceSansPro-Regular.otf/10                              -0.7067         -0.7071             1             0             1             0
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/64                              -0.4817         -0.4824             1             0             1             0
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/512                             -0.1948         -0.1956             2             2             2             2
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/2000                            -0.0767         -0.0761             6             6             6             6
2022-05-16 16:36:28 -06:00
Behdad Esfahbod b58bfd9818 [font] Minor move of code to silence gcc-12 warning
See mailing list discussion.
2022-05-16 11:21:45 -06:00
Behdad Esfahbod 602e0ca79d [cff] Minor restructure of struct
Surprisingly this shows tiny benchmark improvement consistently.
2022-05-16 10:14:34 -06:00
Behdad Esfahbod acdab17ed3 [cff] Cosmetic in parsed_values_t 2022-05-13 14:14:36 -06:00
Behdad Esfahbod b46c7faa9c [cff] Check buf_len, not buf
Ouch!
2022-05-13 14:02:54 -06:00
Garret Rieger 19a8db8545 [subset] fix potential integer overflow in gname_t::cmp. 2022-05-13 13:55:39 -06:00
Behdad Esfahbod 2d2f66e1a3 [cff-common] In INDEX, return empty bytes if length is zero
Before it was possible to return non-null arrayZ.
2022-05-13 13:53:17 -06:00
Behdad Esfahbod a2f132f1fc [cff] Check glyph-name's length, not arrayZ
As the latter can be non-null while still zero-length.
2022-05-13 13:49:39 -06:00
Thomas Devoogdt c657c4e1f8 [meta] fix type traits on gcc 4.9 #3526
Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
2022-05-13 11:26:12 -06:00
Behdad Esfahbod e61234c5f7 [vector] Add tests for move constructor/assignment 2022-05-12 13:20:10 -06:00
Behdad Esfahbod 7fa580bc4f [map] Fix map copy/move constructors to actually work
Ouch!
2022-05-12 13:05:32 -06:00
Behdad Esfahbod a09dd87ca3 [set] Fix set copy/move constructors to actually work
Ouch!
2022-05-12 12:58:07 -06:00
Behdad Esfahbod 76fc27713f [vector] Remove explicit std::move
Was confusing compilers. Let them figure it out themselves.

Makes NotoNastaliqu subsetting/1000 benchmark more than twice faster:

Benchmark                                                                       Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------------------
BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/1000                    -0.5064         -0.5065           111            55           110            55
BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/1000                -0.5494         -0.5493           132            59           131            59
2022-05-12 12:14:07 -06:00
Behdad Esfahbod c81198b5bc [set] Tweak move operators a bit
Should be equivalent.
2022-05-12 12:14:02 -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 c78d8ba60b [subset] Allocate same size as source table for GSUB/GPOS/name 2022-05-11 13:05:41 -06:00
Behdad Esfahbod 2e7f1ae48f [subset] Use vector.allocated size instead of tracking buf_size 2022-05-11 12:52:27 -06:00
Behdad Esfahbod f08537963b [cff-subset] Pre-alloc vector for operator decoding 2022-05-11 12:14:49 -06:00
Behdad Esfahbod aeb50b8942 [subset] Retain buffer across table subset operations 2022-05-11 12:14:49 -06:00
Behdad Esfahbod bff78e6515 [cff] Convert interpretation environment to use constructor 2022-05-10 16:50:38 -06:00
Behdad Esfahbod de053e2efb [cff] Convert subr_subset_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 96140db485 [cff] Convert cff2_extents_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 54544f2a57 [cff] Convert cff1_extents_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 377befd0c7 [cff] Convert get_seac_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 8fd70362fa [cff] Use hb_ubytes_t() instead of Null(hb_ubytes_t) 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 9033c7f99d [cff-common] Optimize INDEX::operator[]
Previous try showed slowdown in benchmarks, suprisingly.

Rewrite it keeping the function, hopefully allowing better optimization.
2022-05-10 14:58:53 -06:00
Behdad Esfahbod 3aace2431b Revert "[cff-common] Optimize INDEX::operator[]"
This reverts commit 9edb03ac7a.
2022-05-10 14:54:04 -06:00
Behdad Esfahbod b31ef081db Revert "[cff] Add an unlikely()"
This reverts commit 9ba9adb7ed.

This shows slowdown in benchmarks.
2022-05-10 14:52:40 -06:00
Behdad Esfahbod 9ba9adb7ed [cff] Add an unlikely() 2022-05-10 14:43:00 -06:00
Behdad Esfahbod 9edb03ac7a [cff-common] Optimize INDEX::operator[] 2022-05-10 14:43:00 -06:00
Behdad Esfahbod 0a42410dc8 [cff2] Change extents/shape stack to be just a number
Do the blending immediately.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3559

Benchmark on AdobeVFPrototype shows 35% speedup. Now we're faster
than FreeType:

Benchmark                                                           Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------
BM_Font/glyph_extents/AdobeVFPrototype.otf/hb                    -0.3792         -0.3792          1584           983          1581           982
BM_Font/glyph_extents/AdobeVFPrototype.otf/ft                    +0.0228         +0.0224          1220          1248          1218          1245
BM_Font/glyph_extents/AdobeVFPrototype.otf/var/hb                -0.3513         -0.3518          1616          1048          1613          1046
BM_Font/glyph_extents/AdobeVFPrototype.otf/var/ft                +0.0172         +0.0169          1232          1254          1230          1251
2022-05-10 13:41:12 -06:00
Garret Rieger 8f9f0c494b [subset] Enforce cmap12 group ordering constraints in collect_mapping.
Fixes fuzzer issue: https://oss-fuzz.com/testcase-detail/6365271012540416
2022-05-10 12:15:09 -06:00
Behdad Esfahbod 1b14d2ff13 [cff] Fix arg-stack peek() impl 2022-05-09 18:15:31 -06:00
Behdad Esfahbod 6106ef8c0f [cff] Tighten up arg-stack access 2022-05-09 18:15:11 -06:00
Behdad Esfahbod 8c616a6efe [cff] Allocate stack inline instead of using hb_vector_t
Speeds up glyph_extents and glyph_shape benchmarks for CFF by 10
to 16 percent!
2022-05-09 17:50:59 -06:00
Behdad Esfahbod c941ece60f [cff] Use using instead of typedef 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 64d63cebe2 [cff-common] Use existing types for str_buff_vec_t 2022-05-09 17:34:58 -06:00
Behdad Esfahbod e1838ec1f8 [cff-common] Remove unused method 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 8aa54aaca2 [cff] Replace byte_str_t with hb_bytes_t use 2022-05-09 17:34:58 -06:00
Behdad Esfahbod fe1d85a55a [cff] Remove custom byte_str_t impl 2022-05-09 17:34:58 -06:00
Behdad Esfahbod c8a5f1e3c0 [cff-common] Indent 2022-05-09 17:34:58 -06:00
Behdad Esfahbod be7b2905cb [cff-common] Remove unused INDEX::serialize() method 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 60390169b6 [cff-common] Write str_buf_t::total_size() as dagger 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 258afb45b7 [cff-common] Use range-based loop in str_buff_vec_t 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 8bb1a3ce9a [cff-common] Write INDEX offset-size calc using hb_bit_storage() 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 2ccfe84eff [cff-common] Add assert to INDEX::set_offset_at() 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 4bcab9e99a [cff-common] Use byte_str_t() instead of Null(byte_str_t) 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 94f7a26322 [cff-common] Fix get_size() for Null object
The special-casing didn't make sense.
2022-05-09 17:34:58 -06:00
Behdad Esfahbod c9cc7d5d21 [cff-common] Inline once-used method in INDEX 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 11482a3a39 [cff-common] Remove unused method from INDEX 2022-05-09 17:34:58 -06:00
Behdad Esfahbod d1bb3b08f6 [cff-common] Hide more INDEX internals 2022-05-09 17:34:58 -06:00
Behdad Esfahbod d3b21387fd [cff-common] Remove redundant operator implementation 2022-05-09 17:34:58 -06:00
Behdad Esfahbod a96b408d80 [cff-common] Hide INDEX internals 2022-05-09 17:34:58 -06:00
Behdad Esfahbod 335b1d83cf [cff-common] No need to check max-offset in INDEX
The length_at() function makes sure out-of-range offsets
are discarded. We just need to check the last offset.
2022-05-09 17:34:58 -06:00
Garret Rieger b051f3fa83 [subset] Fix cpal subsetting when there are partial palette overlaps.
The existing code doesn't correctly handle the case where palettes partially overlap in the color record array. This changes the subsetting to only share entries in the color record array when palettes have the same first color index. Partially overlapping palettes will be converted to disjoint segments in the color record array.

Updates one of the color tests to use multiple palettes.

Also fixes fuzzer: https://oss-fuzz.com/testcase-detail/5568200165687296.
2022-05-09 12:25:05 -06:00
Behdad Esfahbod 2884eb97bf [cff-common] Remove special-casing of count=0 in INDEX serialize
The generic code-path now can handle count=0.
2022-05-06 13:33:13 -06:00
Behdad Esfahbod fc7f51aece [cff-common] Reduce iterator calls 2022-05-06 13:33:13 -06:00
Behdad Esfahbod c857b8e3c6 [cff-common] Set INDEX min_size to 2
That is what it is, for an empty INDEX.
2022-05-06 13:33:13 -06:00
Behdad Esfahbod dd71d2c1c3 [gvar] Protect against offset underflow 2022-05-06 13:02:26 -06:00
Behdad Esfahbod 9a6dabd61a [gvar] Remove sanitize check for data array
We are not checking in sanitize that offset array is ascending,
so this check was bogus.
2022-05-06 12:43:45 -06:00
Behdad Esfahbod 38478d1061 [gvar] DEFINE_SIZE_ARRAY instead of DEFINE_SIZE_MIN 2022-05-06 12:43:45 -06:00
Behdad Esfahbod 90d278c92e [gvar] Remove requirement that num_glyphs matches the font's 2022-05-06 12:43:45 -06:00
Behdad Esfahbod ca8a0f3ea3 [gvar] Protect against out-of-range access
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47281
Fixes https://oss-fuzz.com/testcase-detail/5508865908670464
2022-05-06 11:54:38 -06:00
Behdad Esfahbod f10ddb8dd8 [cmap] Use -1 as Unicode sentinel, not U+FFFF in Format12 serialize 2022-05-05 11:21:24 -06:00
Behdad Esfahbod 8a19968c8b [cmap] Use iterator bool operator 2022-05-05 11:17:23 -06:00
Behdad Esfahbod 8bfeea4828 [subset] Compute set max using previous() 2022-05-05 11:13:57 -06:00
Behdad Esfahbod 00cb8c629d [subset] Don't go into glyf table if it's empty 2022-05-05 11:13:57 -06:00
Behdad Esfahbod 4fe69bc413 [subset] Use del_range in _remove_invalid_gids 2022-05-05 11:13:57 -06:00
Behdad Esfahbod 2a42edccbe [subset] Cosmetic; use set bulk array population instead of for loop 2022-05-05 10:35:54 -06:00
Behdad Esfahbod 43938ecdc2 [subset] Remove outdated comment
I tried something like that. It was slower because of the allocations.
2022-05-04 16:59:28 -06:00
Behdad Esfahbod 50db78ba83 [subset] In cmap planning, remove a qsort() 2022-05-04 16:18:27 -06:00
Behdad Esfahbod 052812b6ba
Merge pull request #3561 from googlefonts/cmap_opt
[subset] Further cmap subsetting speed optimizations
2022-05-04 15:38:30 -06:00
Garret Rieger 7cb36e4222 [subset] Re-introduce size threshold in choosing unicode collection method.
Threshold is needed since the unicodes set might be an inverted set.
2022-05-04 21:22:26 +00:00
Garret Rieger 42c54eba83 [subset] Presize unicode to gid list to unicodes + glyphs size. 2022-05-04 20:21:43 +00:00
Garret Rieger 7c7c01d28c [subset] Remove switch to alternate unicode collection at large subset sizes.
Benchmarks show that the first path is always faster even at large subset sizes:

BM_subset_codepoints/subset_roboto/10_median                              +0.0324         +0.0325             0             0             0             0
BM_subset_codepoints/subset_roboto/64_median                              +0.0253         +0.0255             0             1             0             1
BM_subset_codepoints/subset_roboto/512_median                             +0.0126         +0.0128             1             1             1             1
BM_subset_codepoints/subset_roboto/4000_median                            +0.0500         +0.0491             6             7             6             7
BM_subset_codepoints/subset_amiri/10_median                               +0.0338         +0.0332             1             1             1             1
BM_subset_codepoints/subset_amiri/64_median                               +0.0238         +0.0234             1             1             1             1
BM_subset_codepoints/subset_amiri/512_median                              +0.0066         +0.0063             8             8             8             8
BM_subset_codepoints/subset_amiri/4000_median                             -0.0011         -0.0012            13            13            13            13
BM_subset_codepoints/subset_noto_nastaliq_urdu/10_median                  +0.0226         +0.0226             0             0             0             0
BM_subset_codepoints/subset_noto_nastaliq_urdu/64_median                  +0.0047         +0.0044            20            20            20            20
BM_subset_codepoints/subset_noto_nastaliq_urdu/512_median                 +0.0022         +0.0021           165           166           165           166
BM_subset_codepoints/subset_noto_nastaliq_urdu/1000_median                -0.0021         -0.0023           166           166           166           165
BM_subset_codepoints/subset_noto_devangari/10_median                      +0.0054         +0.0054             0             0             0             0
BM_subset_codepoints/subset_noto_devangari/64_median                      +0.0024         +0.0019             0             0             0             0
BM_subset_codepoints/subset_noto_devangari/512_median                     +0.0089         +0.0090             5             5             5             5
BM_subset_codepoints/subset_noto_devangari/1000_median                    -0.0028         -0.0019             5             5             5             5
BM_subset_codepoints/subset_mplus1p/10_median                             +0.0001         +0.0002             0             0             0             0
BM_subset_codepoints/subset_mplus1p/64_median                             +0.0073         +0.0075             1             1             1             1
BM_subset_codepoints/subset_mplus1p/512_median                            +0.0034         +0.0034             1             1             1             1
BM_subset_codepoints/subset_mplus1p/4096_median                           -0.1248         -0.1248             7             6             7             6
BM_subset_codepoints/subset_mplus1p/10000_median                          -0.0885         -0.0885            13            12            13            12
BM_subset_codepoints/subset_notocjk/10_median                             +0.0031         +0.0032             2             2             2             2
BM_subset_codepoints/subset_notocjk/64_median                             -0.0010         -0.0010             2             2             2             2
BM_subset_codepoints/subset_notocjk/512_median                            -0.0023         -0.0023             9             9             9             9
BM_subset_codepoints/subset_notocjk/4096_median                           -0.1725         -0.1726            28            23            28            23
BM_subset_codepoints/subset_notocjk/32768_median                          -0.0277         -0.0287           140           137           140           136
BM_subset_codepoints/subset_notocjk/100000_median                         -0.0929         -0.0926           162           147           162           147
2022-05-03 22:45:39 +00:00
Garret Rieger f0c04114bc [subset] Embed unicode to gid list vector in subset plan. 2022-05-03 22:02:59 +00:00
Behdad Esfahbod 15fa8afb21 Add fast-path for big-endian 32-bit byteswap
Speeds up cmap format-12 decoding by some 40% as measured by
the newly added test in perf/benchmark-font!
2022-05-02 16:46:41 -06:00
Behdad Esfahbod 3fff2e9182 [perf/benchmark-font] Cosmetic 2022-05-02 16:42:10 -06:00
Behdad Esfahbod 307d2d8bb6 [cmap] Sprinkle some 'unlikely's 2022-05-02 16:30:22 -06:00
Garret Rieger 85ec5cbcef [subset] In _populate_unicodes_to_retain populate unicodes in order.
Allows the set insert to take advantage of page lookup cache.
2022-05-02 22:29:43 +00:00
Garret Rieger 088133d939 [subset] cache cp to new gid list in subset plan.
This avoids having to recompute the ordered list multiple times during cmap generation.
2022-05-02 21:29:16 +00:00
Garret Rieger 6922a2561f [subset] Change serialize_rangeoffset_glyid back to using iterator. 2022-04-29 23:30:32 +00:00
Garret Rieger c66fd50c26 [subset] in cmap4 serialization save cp to gid iter to memory.
Iterator accesses are slow and it's iterated multiple times.
2022-04-29 23:18:53 +00:00
Garret Rieger 17b98563dc [subset] In cmap4 serialization reduce unnessecary calls into the iterator.
Gives ~20% speedup for large subsets.
2022-04-29 22:49:02 +00:00
Garret Rieger 5e241094bf [subset] In unicodes cache cleanup if set insert fails. 2022-04-29 22:45:16 +00:00
Garret Rieger a424a92ce5 [subset] s/void */intptr_t. 2022-04-29 22:14:03 +00:00
Garret Rieger aad67f5629 [subset] cache results of collect_unicodes. 2022-04-29 22:05:34 +00:00
Garret Rieger b4236b7de6 [subset] Optimize Cmap4 collect_unicodes.
Use set add_range() instead of individual add() calls.
2022-04-29 19:22:00 +00:00
Behdad Esfahbod 067225a86d [set] Optimize const page_for() using last_page_lookup caching
Similar to previous commit.

This speeds up SetLookup benchmark by 50%, but that's because that
lookup always hits the same page...
2022-04-29 13:04:36 -06:00
Behdad Esfahbod c283e41ce3 [set] Optimize non-const page_for() using last_page_lookup caching
This speeds up SetOrderedInsert tests by 15 to 40 percent, and the
subset_mplus1p benchmarks by 9 to 27 percent.
2022-04-29 12:45:48 -06:00
Behdad Esfahbod d8292b8446 [CFF] Fix parsing of empty Index
https://github.com/harfbuzz/harfbuzz/issues/3545#issuecomment-1111047941
2022-04-27 12:38:35 -06:00
David Corbett 6454cec085 [USE] Classify U+10A38 as CONS_MOD_BELOW 2022-04-24 11:41:32 -06:00
Khaled Hosny f7aee78e90 4.2.1 2022-04-24 05:47:57 +02: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 8575a8f50c Add _hb_codepoint_is_regional_indicator() 2022-04-21 11:15:34 -06:00
Behdad Esfahbod c1ee7d28f3 Typo
Co-authored-by: Khaled Hosny <khaled@aliftype.com>
2022-04-21 11:15:34 -06:00
Behdad Esfahbod 4d48fae4f2 Enforce Regional_Indicators native direction to LTR
And undo the morx direction reversal change introduced in
https://github.com/harfbuzz/harfbuzz/pull/3315
23159084b4

This fixes original bug https://github.com/harfbuzz/harfbuzz/issues/3314

And the reversion in morx code fixes regressions:
https://github.com/harfbuzz/harfbuzz/issues/3528
https://github.com/harfbuzz/harfbuzz/issues/3535

Supersedes:
https://github.com/harfbuzz/harfbuzz/pull/3529
2022-04-21 11:15:34 -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
Simon Cozens 9e59c401e0 [myanmar] Reword confusing comment about masks 2022-04-20 11:25:15 -06:00
Behdad Esfahbod 903cf8cfce [check-static-inits] Unbreak test 2022-04-13 15:31:51 -06:00
Behdad Esfahbod ec925ece05 [khmer] Reinstate a pause after basic features
This was removed as part of 044d7a06db,
which caused the regression.  Just adding a pause fixes the shaping.
Debugged by just tracing the good/bad shaping and observing the
lookup orders intermingling in the bad shaping.

Test:
hb-shape LeelawUI.ttf --unicodes U+1780,U+17D2,U+179A,U+17BB

Fixes https://github.com/harfbuzz/harfbuzz/issues/3531
2022-04-13 11:54:08 -06:00
Khaled Hosny 88bb746b42 [blob] Return nullptr from create_from_file_or_fail
Fix a couple of cases where it would return empty blob, possibly
missed in bdfed8f113.
2022-04-01 02:38:23 +02:00
Behdad Esfahbod b179d357a9 [main] Fix unused-variable warnings 2022-03-30 12:59:52 -06:00
Khaled Hosny 9d5730b958 4.2.0 2022-03-30 15:08:34 +02: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 61486746d3 Revert "[indic] Clear syllables before presentation features"
This reverts commit 90f09b1e87.

This regressed Indic shaping. See:
https://github.com/harfbuzz/harfbuzz/issues/3513
2022-03-28 15:57:07 -06:00
Behdad Esfahbod e8f3397f4e [matcher] Simplify syllable initialization 2022-03-28 13:23:37 -06:00
Behdad Esfahbod 94f5c630fc [aat] Remove morx deleted-glyphs before GPOS processing
Fixes new Apple Color Emoji glyphs sequences rendering.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3512
2022-03-28 13:10:56 -06:00
David Corbett 0dcbdbde9c [indic] Categorize U+0D04 as Consonant_Placeholder 2022-03-26 21:02:08 -06:00
Behdad Esfahbod a665e29ed7 [use] Avoid O(n^2) in the machine
Fixes https://github.com/harfbuzz/harfbuzz/issues/3502
2022-03-25 15:17:55 -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 fa15fc44bb [subset] Require exact harfbuzz version in .pc file
Fixes https://github.com/harfbuzz/harfbuzz/issues/1446
2022-03-25 15:00:36 -06:00
Behdad Esfahbod b619b05f39 [subset] Adjust name in .pc file 2022-03-25 15:00:36 -06:00
Khaled Hosny 1229078660 [set] Fix annotation 2022-03-25 22:41:25 +02:00
Behdad Esfahbod 3a78cf92c8 [gvar] Fix decoding of private vs shared points
Fixes https://github.com/harfbuzz/harfbuzz/issues/3506
2022-03-25 13:25:28 -06:00
Behdad Esfahbod a02fb4a0dc [glyf] Don't bail rendering glyf even if gvar failed
Part of https://github.com/harfbuzz/harfbuzz/issues/3506
2022-03-25 13:25:28 -06:00
Behdad Esfahbod 0a38878549 [set] Minor touch-up on the previous commit 2022-03-25 09:42:36 -06:00
Andrew John 0182988229
[set] Add call to export set contents to an array. (#3500)
[set] Add hb_set_next_many.
2022-03-25 09:36:44 -06:00
aneejit1 a55a42444d
Meson build writes to the source directory (issue #3507 ) (#3508)
Don't write to source directory if files did not change

Remove writes to the source directory which cause a meson build failure
if the source directory is read-only.

https://github.com/harfbuzz/harfbuzz/pull/3508
2022-03-24 14:16:41 -06:00
Behdad Esfahbod bf2a845a17 [ot-layout] Comment 2022-03-24 13:09:53 -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
Garret Rieger 444c2375a1 [reorg] Use relative includes for hb-ot-layout-gsubgpos.hh 2022-03-23 18:05:24 -06:00
Garret Rieger b342adeb96 [reorg] Move GSUB into OT::Layout::GSUB namespace. 2022-03-23 18:05:24 -06:00
Garret Rieger a9910e258f [reorg] Move SubstLookup and GSUB into the new layout. 2022-03-23 18:05:24 -06:00
Garret Rieger 90af2143d5 [reorg] Move ReverseChainSingleSubst to new layout. 2022-03-23 18:05:24 -06:00
Garret Rieger 403feb3804 [reorg] Move LigatureSubst to new layout. 2022-03-23 18:05:24 -06:00
Garret Rieger 6a369389d6 [reorg] Move AlternateSubst to new layout. 2022-03-23 18:05:24 -06:00
Garret Rieger dea0681db2 [reorg] Move MultipleSubst into new layout. 2022-03-23 18:05:24 -06:00
Behdad Esfahbod 7243bf3e41 [reorg] Use relative include 2022-03-23 18:05:24 -06:00
Behdad Esfahbod c180f93766 [reorg] Move sanitize/dispatch and size macros to top 2022-03-23 18:05:24 -06:00
Garret Rieger f577d02f4a [reorg] Fix check-* scripts to work with sources files in directories. 2022-03-23 18:05:24 -06:00
Garret Rieger 3ef180db44 [reorg] Move SingleSubst opentype fields to top of the classes. 2022-03-23 18:05:24 -06:00
Garret Rieger 7dfd9e7001 [reorganization] WIP move single substitution into separate files. 2022-03-23 18:05:24 -06:00
Khaled Hosny c36844d6d9 4.1.0 2022-03-23 07:20:59 +02:00
Behdad Esfahbod d35c73cd37 [buffer] Whitespace 2022-03-22 13:09:50 -06:00
Behdad Esfahbod 1449498e1d [ot-font] Vertically center glyph in vertical writing fallback
Fixes https://github.com/harfbuzz/harfbuzz/issues/537
2022-03-21 21:40:07 -06:00
Behdad Esfahbod bf03d7e962 [ot-font] Use ascent+descent for fallback vertical advance
This matches what FreeType does.

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/537
2022-03-21 21:27:31 -06:00
Behdad Esfahbod df42d28d18 [hmtx] Change default advance for horizontal direction to upem/2 again 2022-03-21 21:17:15 -06:00
Behdad Esfahbod 6d0e67dee0 [ot-font] Only use vmtx side-bearing if table exists
Part of fixing https://github.com/harfbuzz/harfbuzz/issues/537
2022-03-21 21:07:28 -06:00
Behdad Esfahbod f41945e313 [cmap] In collect_unicodes() of format 12/13, limit to max Unicode
Fixes fuzzer timeout:
https://oss-fuzz.com/testcase-detail/5062368881672192
2022-03-21 18:24:30 -06:00
Behdad Esfahbod 03085132ba [buffer] Fix out-buffer under memory-alloc failure
This was broken in July refactoring of the buffer, and exposed to
ReverseChainSingleSubstFormat1 in 3807061d63

Fixes:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38800
https://bugs.chromium.org/p/chromium/issues/detail?id=1303552
2022-03-21 18:09:06 -06:00
Khaled Hosny 116cc69236 [set] Fix documentation 2022-03-22 00:15:23 +02:00
Behdad Esfahbod 90f09b1e87 [indic] Clear syllables before presentation features
Fixes https://github.com/harfbuzz/harfbuzz/issues/3488
2022-03-21 15:42:08 -06:00
Behdad Esfahbod 4289684cdb [set] Fix-up previous commits 2022-03-21 15:37:05 -06:00
Andy John 1176620ba4 Move fn, fix doc. 2022-03-21 15:32:59 -06:00
Andy John 7d802994be Remove null checks. 2022-03-21 15:32:59 -06:00
Andy John ef588ea97b Add option to insert a sorted arrays of values to sets. 2022-03-21 15:32:59 -06:00
Andy John 7a1e79c3ba Fix typo. 2022-03-21 14:34:22 -06:00
Andy John 4ee00f943f Use bit shifting instead of multiplying and dividing. 2022-03-21 14:34:22 -06:00
Andy John 3125f5ae33 Add log base 2 versions of constants. 2022-03-21 14:34:22 -06:00
Behdad Esfahbod 1ffe637a0e [coretext] Remove dead code
Fixes https://github.com/harfbuzz/harfbuzz/issues/3484
2022-03-21 10:37:42 -06:00
TheBluuDot 7bdc20ec81 restores unintended addition in 43be5ba
restores two lines in restore in _hb_allocate_lig_id function that were unintentionally deleted in 43be5ba
2022-03-19 15:12:25 -04: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 cad2fe8e63 [baseline] Fix HB_NO_METRICS build
Fixes https://github.com/harfbuzz/harfbuzz/issues/3482
2022-03-15 10:49:29 -06:00
Behdad Esfahbod a8a89b80b4 [layout] Whitespace 2022-03-15 10:48:03 -06:00
Behdad Esfahbod 21f5ef56f5 [metrics] Simplify x-height fallback 2022-03-15 10:45:50 -06:00
Behdad Esfahbod 6bf8f0a38f [baseline] Use ot-metrics fallback API 2022-03-15 10:44:41 -06:00
Dominik Röttsches 965cf1d665 Make load_num_glyphs_from_loca conditional on HB_NO_BORING_EXPANSION
Fixes build errors complaining about this function being unused.
2022-03-14 15:16:35 +02:00
David Corbett 49fb8f9072 [USE] Treat visible viramas like dependent vowels 2022-03-13 14:45:27 -06:00
Khaled Hosny 1f79ba9407 4.0.1 2022-03-11 20:19:04 +02:00
Qunxin Liu a35757c6bc [repacker] expose hb_subset_repack() API, hb_object_t and hb_link_t structs 2022-03-10 17:26:20 -07:00
Matthias Clasen e7ab42b246 [layout] Fix handling of baseline variations
For BASE table format 1.1, the handling of design
space vs user space coordinates was inconsistent.
We were applying design -> user transformation
twice for the deltas, leading to wrong baseline
values.

Patch by Ebrahim Byagowi <ebrahim@gnu.org>

Fixes: #3476
2022-03-10 09:29:56 -07:00
David Corbett e5707a440c Update IANA Language Subtag Registry to 2022-03-02 2022-03-08 13:28:25 -07:00
David Corbett 13bb46cfd5 [USE] Remove obsolete overrides 2022-03-06 16:04:18 -07:00
David Corbett c33468d48e [USE] Treat all gc=Cn as independent clusters 2022-03-06 10:44:37 -07:00
David Corbett e497a8f142 [USE] Remove obsolete symbol/punctuation overrides 2022-03-06 10:44:37 -07:00
David Corbett 854219e056 [USE] Simplify `not_ccs_default_ignorable` 2022-03-06 10:44:37 -07:00
David Corbett 6e059a46b7 [USE] Allow any non-numeric tail in symbol cluster 2022-03-06 10:44:37 -07:00
David Corbett 5b0a59812d [USE] Restore the category WJ 2022-03-06 10:44:37 -07:00
Florian Pircher 05b3bdb0b3 [aat] Update OT to AAT mappings for hist and vrtr 2022-03-05 20:36:40 -07:00
luz paz cf3a0f7ab5 Fixed various misc. typos
Found via `codespell -q 3 -S ./perf/texts -L actualy,als,ba,beng,clen,crasher,dependant,eachother,fo,gir,inout,ist,nd,ned,ot,pres,ro,statics,te,teh,timne`
2022-03-06 04:59:24 +02:00
Khaled Hosny 8d1b000a3e 4.0.0 2022-03-01 21:27:32 +02:00
Khaled Hosny 6e466256e4 [doc] Typo 2022-03-01 12:01:18 +02:00
Garret Rieger f6071c16b0
[subset] Rename codepoint -> unicode in subset plan api 2022-02-28 23:45:40 +02:00
Khaled Hosny 1b5a2e0809 [doc] Various fixes to newly added documentation 2022-02-28 10:11:42 -07:00
Behdad Esfahbod 222301bfa4
Merge pull request #3429 from harfbuzz/external_plan
[subset] expose subset plan in public subsetting API
2022-02-24 12:55:01 -07:00
Behdad Esfahbod 651c280d0b [style] Move the negation into the constant 2022-02-18 18:21:46 -06:00
Matthias Clasen 16b232be0e [hb-style] Fix the sign of slant ratios
We want negative slant angles to yield
positive slant ratios. Fix that.

Test included.
2022-02-18 18:10:34 -06:00
Matthias Clasen e76061a737 [hb-style] Fix synthetic slant values
When reporting the slant ratio of a font
that has synthetic slant set, we were
reporting twice the expected value.
Fix that. Test included.
2022-02-18 17:53:54 -06:00
Behdad Esfahbod 56f11ec938 [buffer] Add HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT
Fixes https://github.com/harfbuzz/harfbuzz/issues/3454
2022-02-18 17:52:27 -06:00
Garret Rieger fc1548cf71 [subset] document return values. 2022-02-17 17:16:31 -08:00
Matthias Clasen f6efe34f5e [ot-metrics] Synthesize missing metrics
Add a variant of hb_ot_metrics_get_position that
synthesizes missing values.

New api: hb_ot_metrics_get_position_with_fallback
2022-02-17 18:34:59 -06:00
Behdad Esfahbod f8e9e315bb
Merge pull request #3437 from matthiasclasen/synthesize-missing-baselines
[BASE] Synthesize missing baselines
2022-02-17 14:34:46 -06:00
Behdad Esfahbod 8e900f2cda Revert "hb-algs.hh: Fix build on Visual Studio 2015"
This reverts commit 52c536bb8d.

See https://github.com/harfbuzz/harfbuzz/pull/3448
2022-02-17 13:29:04 -06:00
Matthias Clasen 95bb2ff719 [ot-layout] Add central baselines
Add HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_CENTRAL
and HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_CENTRAL
which are the centers of the ideographic em-box
and face box.
2022-02-16 17:37:35 -06:00
Matthias Clasen f81578fd86 [ot-layout] Synthesize missing baselines
Add a variation of hb_ot_layout_get_baseline that
synthesizes missing baselines, using heuristics in part
taken from the CSS Inline Layout Module, Level 3.

Includes some new tests for synthesized baselines.
The base2.ttf is a subset of Noto Sans Bengali that
includes just the Bengali Ka.

New API: hb_ot_layout_get_baseline_with_fallback
2022-02-16 17:37:33 -06:00
Behdad Esfahbod 5de67c8961 [ot-layout] Remove commented-out prototypes
Not gonna happen.
2022-02-16 17:08:19 -06:00
Behdad Esfahbod d2998faad3
Merge pull request #3410 from harfbuzz/boring-expansion
[Boring Expansion] >64k loca & hmtx tables

This does two things:

The num-glyphs reported by the face now is the maximum reported by the maxp and that deduced from the length of the loca table; I think this is the right thing to do anyway; According to OpenType such loca tables are invalid.

The interpretation hmtx tables that have excessive bytes at the end, again, invalid according to OpenType, has changed. Previously we were interpreting those excessive bytes as extra lsb values. Now we interpret them as extra advance values, the last of which is repeated for all missing glyphs. Again, these are tables that are invalid according to OpenType, and the advances are for glyph indices beyond maxp table's num-glyphs.

The combined effect is that the font can have shapes and advances for gid's beyond the maxp limit of 64k. In fact, maxp table becomes optional.
2022-02-16 14:37:09 -06:00
Behdad Esfahbod 98079109e6 [ot-layout] Add +hb_ot_layout_get_horizontal_baseline_tag_for_script()
New API:
+hb_ot_layout_get_horizontal_baseline_tag_for_script()
2022-02-16 13:54:22 -06:00