Commit Graph

9420 Commits

Author SHA1 Message Date
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 7b8464b655 [serialize] Check for overflow in allocate_size()
If size was > INT_MAX, then the out-of-room check was failing to perform
as intended.

Part of fixing https://oss-fuzz.com/testcase-detail/5362189182566400
2021-07-27 13:26:00 -06:00
Behdad Esfahbod bf2c87bfe6 Add hb_memcpy() that does len=0 check 2021-07-27 13:26:00 -06:00
Khaled Hosny 5f801da945 [hb-ms-features] Move code out of header file 2021-07-27 21:07:32 +02:00
Khaled Hosny 990c15dbe5 [hb-ms-features] Rename types to be less general 2021-07-27 21:07:32 +02:00
Khaled Hosny 69199211b7 [uniscribe/directwrite] Move feature setup to shared file
Fixes https://github.com/harfbuzz/harfbuzz/issues/3070
2021-07-27 21:07:32 +02:00
Garret Rieger fc7f778120
[subset] add a note to hb-subset on what is and isn't supported (#3076) 2021-07-27 11:21:19 -07:00
Khaled Hosny 791a1bf3a4 Don’t disable getenv on Windows
The condition is inverted, regression from
40ec187dec.
2021-07-27 15:22:13 +02:00
Behdad Esfahbod 4762fcb415
Merge pull request #3067 from googlefonts/glyph_names
[subset] support option --glyph-names
2021-07-26 11:48:55 -07:00
Behdad Esfahbod aeec278453
Merge pull request #3068 from harfbuzz/hoi
[variations] Support multiple axes with same tag, aka HOI
2021-07-26 11:31:54 -07:00
Khaled Hosny ec99fdb7e8 [sebset] Use [s|g]et_flag for retain_all_layout_features
Looks like this was missed when adding hb_subset_input_[s|g]et_flag()
2021-07-26 19:32:28 +02:00
Khaled Hosny acc7100a3f [docs] Improve subset documentation 2021-07-26 02:18:23 +02:00
Khaled Hosny 3e2734cf91 [docs] Don’t use GTK-Doc syntax for internal functions
We don’t generate docs for them, reduces the number of warnings.
2021-07-26 02:18:18 +02:00
Qunxin Liu 71b5509c19 [subset] support option --glyph-names 2021-07-23 13:57:39 -07:00
Behdad Esfahbod b235511ed8
Merge pull request #3021 from googlefonts/stable_api
[subset] update hb_subset api with final changes before going stable.
2021-07-23 12:15:15 -07:00
Behdad Esfahbod a9a607d360 [variations] Support multiple axes with same tag, aka HOI
The axes in fvar are in arbitrary order, NOT sorted. Hence have to
lsearch all entries.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1673
Fixes https://github.com/harfbuzz/harfbuzz/issues/2743

Test from https://github.com/ctrlcctrlv/FontForge-Higher-Order-Interpolation
2021-07-23 11:58:58 -07:00
Garret Rieger 1fde80ad28 [subset] update comments referencing hb_subset_input_t parameter. 2021-07-22 16:45:48 -07:00
Garret Rieger c581d11eba [set] in hb_set_set() avoid calling memcpy on nullptr. 2021-07-22 14:04:39 -07:00
Garret Rieger 2b9cb29923 [subset] cleanup no_subset_tables on destruction. 2021-07-22 13:26:03 -07:00
Garret Rieger 89fc399eba [subset] Add hb-subset section documentation. 2021-07-22 13:00:34 -07:00
Garret Rieger 792e2ed61c [subset] convert no get/set prune unicode ranges to enum. 2021-07-22 12:41:48 -07:00
Behdad Esfahbod 0a44feaeda [fvar] Make find_axis_index() return a range, not individual value 2021-07-22 12:18:48 -07:00
Garret Rieger 1b6c1aa684 [subset] add hb-subset api to documentation generator.
Standardize subset_input parameter to be input.
2021-07-22 12:15:45 -07:00
Garret Rieger 8ce9683412 [subset] add documentation for all hb-subset.h methods. 2021-07-22 12:14:53 -07:00
Garret Rieger 9ab751ac9f [subset] Remove hb_subset(). Leaving just hb_subset_or_fail(). 2021-07-22 12:14:47 -07:00
Garret Rieger e5c887fc0f [subset] add documentation for subset input flag enums. 2021-07-22 12:14:09 -07:00
Garret Rieger 372722ceee [subset] move notdef_outline to the subset input property enum. 2021-07-22 12:14:03 -07:00
Garret Rieger a6c6cda486 [subset] Add no subset tables and passthrough unrecognized tables to the subset api.
Matches fontTools options.
2021-07-22 12:12:37 -07:00
Garret Rieger 668f2bd93e [subset] Add hb_subset_or_fail () to public subset api. 2021-07-22 12:12:36 -07:00
Garret Rieger aba2e13141 [subset] Remove hb_subset_input_get/set_overlaps_flag (). 2021-07-22 12:12:36 -07:00
Garret Rieger 7d82191f61 [subset] Remove hb_subset_input_get/set_name_legacy (). 2021-07-22 12:12:36 -07:00
Garret Rieger 942636ae13 [subset] Remove hb_subset_input_get/set_retain_gids. 2021-07-22 12:12:36 -07:00
Garret Rieger 77b4a1cd96 [subset] Remove hb_subset_input_get/set_desubroutinize. 2021-07-22 12:12:36 -07:00
Garret Rieger 8bf5d4d4f7 [subset] Remove hb_subset_input_get/set_drop_hints. 2021-07-22 12:12:36 -07:00
Garret Rieger 9fb3a25633 [subset] Use hb_set_copy in subset input. 2021-07-22 12:12:36 -07:00
Garret Rieger 38de3491a0 [subset] add implementation for get/set flag on subset input. 2021-07-22 12:12:36 -07:00
Garret Rieger 83727837ef [subset] add proposed enum property get/set method. 2021-07-22 12:12:36 -07:00
Garret Rieger b38e49dcfa [subset] add get/set user data methods to subset input. 2021-07-22 12:12:30 -07:00
Garret Rieger edb57a8d9a Make subset input const in the subsetting operation. Don't modify the subset input's sets. 2021-07-22 12:11:43 -07:00
Behdad Esfahbod 233c29b302 [font] Call fvar.find_axis_index instead of find_axis_info in set_variations() 2021-07-22 12:00:24 -07:00
Behdad Esfahbod 89018068cd [fvar] Centralize axis finding logic
Part of fixing https://github.com/harfbuzz/harfbuzz/issues/1673
2021-07-22 11:59:23 -07:00
Behdad Esfahbod 0b2280af90 [font] Call fvar table directly, instead of calling public get_axis_info
To lighten it up in next commit.
2021-07-22 11:58:14 -07:00
Behdad Esfahbod b86a45ca55 [fvar] Add TODO
Fixing https://github.com/harfbuzz/harfbuzz/issues/1673
2021-07-22 11:46:44 -07:00
Behdad Esfahbod ba6db26b65 Tolerate unsorted OT table entries for small number of entries
See comment.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3065
2021-07-22 11:38:27 -07:00
Behdad Esfahbod 03cd9c5cba Align lfind() API to match bfind() 2021-07-22 11:38:27 -07:00
Behdad Esfahbod f54f5c1b16 Fix debug printer of bool 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
Behdad Esfahbod 79e8b30609 [ot-shape] Fix application of kern table if GPOS kern is missing
Was broken sometime after we implemented kerx and tweaking it.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3043
2021-07-16 16:29:44 -06:00
Behdad Esfahbod 1060b04938
Merge pull request #3060 from googlefonts/unicode_collect
[subset] de-duplicate the logic that finds unicodes corresponding to …
2021-07-14 17:50:46 -07:00
Garret Rieger 9aa0ecef3f [subset] de-duplicate the logic that finds unicodes corresponding to requested glyphs.
Move the logic into subset planning and then re-use the results in cmap and OS2 subsetting. Removes depedency on cmap from os2.
2021-07-14 17:31:47 -07:00
Garret Rieger deee24fbef [subset] Add missing FontName op code in top dict parsing.
Fix for #3058
2021-07-14 16:01:18 -06:00
Behdad Esfahbod 9985ca6491
Merge pull request #3057 from harfbuzz/ci-coverage-macos
[ci] Add macOS GitHub workflow
2021-07-13 13:42:09 -07:00
Behdad Esfahbod 95b04f7409 [buffer] Remove unnecessary have_separate_output() 2021-07-12 17:36:38 -06:00
Behdad Esfahbod 3e266e5f64 [buffer] Update comments 2021-07-12 17:36:36 -06:00
Behdad Esfahbod 3807061d63 [ot-layout] Don't remove_output() before reverse substitution
No need anymore, because of new swap_buffers() semantics.

Just assert instead.
2021-07-12 17:36:22 -06:00
Behdad Esfahbod 10a9960f0a [buffer] Restructure swap_buffers()
Is more of a "commit" operation now. Will rename when ready.
2021-07-12 17:36:22 -06:00
Khaled Hosny d56afb750a [tests] Ignore more symbols
These seem to be exported when building with code coverage on macOS.
2021-07-13 01:12:34 +02:00
Behdad Esfahbod a7f4c985a8 [ot-layout] Always swap_buffers() even if no substitutions happened 2021-07-12 17:00:46 -06:00
Behdad Esfahbod 62b441e6ff [layout] Use Proxy::inplace instead of table index check
Equivalent.
2021-07-12 16:59:34 -06:00
Behdad Esfahbod 431f164003 [layout] Don't call clear_output() before pause-func 2021-07-12 16:57:25 -06:00
Behdad Esfahbod a623446a34 [shape] Remove stray clear_output() call in hb_shape() 2021-07-12 16:55:54 -06:00
Behdad Esfahbod 05c17787c4 [buffer] Rewind cursor in clear_output() 2021-07-12 16:55:08 -06:00
Behdad Esfahbod 1cb0ca1f2c Whitespace 2021-07-12 16:52:51 -06:00
Behdad Esfahbod 69310f14a6 [buffer] Change nil buffer have_output to false
Seems like a historical artefact that it was true.
2021-07-09 16:45:55 -07:00
Behdad Esfahbod 40884af17e [ot-layout] Narrow down random feature logic vs safe-to-break 2021-07-09 16:34:08 -07:00
Behdad Esfahbod 33b579d0ad [ot-layout] Clear random flag for subsequent flags
Ouch!
2021-07-09 16:34:08 -07:00
Behdad Esfahbod 29c9833e57 Remove Offset::serialize()
Finishing https://github.com/harfbuzz/harfbuzz/pull/2355
2021-07-09 11:58:36 -06:00
Khaled Hosny 63e15eac4f 2.8.2 2021-07-08 23:02:49 +02:00
Behdad Esfahbod 2337f0d047 Internally use hb_malloc/.../hb_free instead of malloc/.../free
Redefining those stock names as macros was conflicting with gcc 10
headers.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Behdad Esfahbod bb48bf52a4 Rename misc uses of "free"
In preparation for fixing https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Qunxin Liu 7416faceeb [subset] fuzzer fix: https://oss-fuzz.com/testcase-detail/5715464591376384 2021-07-08 09:09:30 -07: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
Behdad Esfahbod 0969614865 [ot-shape] Rewrite loop without foreach_grapheme()
We were not using the graphemes, and that's costlier than just for().
2021-06-26 08:52:53 -06:00
Qunxin Liu eee7b459ee [subset] add option --no-prune-unicode-ranges 2021-06-24 11:44:20 -07:00
Khaled Hosny c3be28ea26 [ot-shape] Numeric runs native direction is LTR
See inline comments. Slightly modified version of the code from Jonathan
Kew on the linked issue.

Fixes https://github.com/harfbuzz/harfbuzz/issues/501
2021-06-23 13:11:27 -07:00
Behdad Esfahbod cc9bb29491 [blob] Fix-up recent mistake in hb_blob_create() destroy(user_data)
https://github.com/harfbuzz/harfbuzz/pull/3026#discussion_r653437491
2021-06-20 18:47:03 -06:00
Garret Rieger bc06af977f [subset] speed up feature collection when tags are specified.
Precompute a feature index filter to avoid needing to iterate the feature tag list for each encountered feature index. For this particular fuzzer case speeds up feature collection from 50s to 2s.
2021-06-20 17:45:19 -07:00
Khaled Hosny 14f220b761 [directwrite] Support feature ranges
Code copied from hb-uniscribe.cc and adapted to use DirectWrite types.
May be there is a better way to de-duplicate the code, though I'm not
exactly sure how or if it is worth it.
2021-06-20 17:22:27 -07:00
Garret Rieger 26c80adb61 [subset] do colrv1 glyph closure before glyf composite closure. 2021-06-18 22:34:00 -07:00
Qunxin Liu d07f789ae3 [subset] support option "--notdef-outline" 2021-06-18 15:35:02 -07:00
Garret Rieger 10ad185932 [subset] add comment to copy_bytes(). 2021-06-16 17:35:39 -06:00
Garret Rieger 675ebbeb3a [subset] don't alloc zero bytes.
It will be leaked later since hb_blob_create() won't set up the blob to cleanup since it has length zero.
2021-06-16 17:35:39 -06:00
Behdad Esfahbod 93e6a9bc4e Revert "Remove unneeded buffer clear_output / remove_output calls"
This reverts commit 06175b7143.

One of the sanitizers is failing. Pushing again as PR to debug.
I have suspicions.
2021-06-15 15:38:49 -06:00
Behdad Esfahbod 06175b7143 Remove unneeded buffer clear_output / remove_output calls
Made sure clear_output is always paired with swap_buffers.
Trying to see if we can move towards RAII-like buffer iterators
instead of the buffer keeping an iterator internally.
2021-06-15 14:33:27 -06:00
Behdad Esfahbod bdfed8f113 [blob] Add failing versions of create API
Fixes https://github.com/harfbuzz/harfbuzz/issues/2567

New API:
+hb_blob_create_or_fail()
+hb_blob_create_from_file_or_fail()

Use these in util/ to distinguish empty file from not-found file.
Only err on the latter.
2021-06-15 13:56:30 -06:00
Behdad Esfahbod 2fc8d0e6f0
Merge pull request #3020 from googlefonts/serialize_serialize
[subset] Always serialize objects point to by OffsetTo to a new serializer object.
2021-06-15 12:56:17 -07:00
Garret Rieger 085aa65e09 [subset] Convert offset serialization in gsubgpos and gdef to serialize_serialize(). 2021-06-14 16:47:45 -07:00
Garret Rieger cc96c4e87e [shaping] Update shaping substituion lookup serialization to use serializer pop()/pack(). 2021-06-14 16:43:23 -07:00
Behdad Esfahbod d3dd936309 [coretext] Round position info
Test:

Before:
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=coretext
[gid781=0@-78,0+841]
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=ot
[gid781=0@-78,0+842]

After:
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=coretext
[gid781=0@-78,0+842]
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=ot
[gid781=0@-78,0+842]

I've verified in the font that 842 is correct.
2021-06-14 13:24:23 -07:00
Garret Rieger 8443cc85cb [subset] Correct OffsetTo serialization in GPOS to use serialize_serialize (). 2021-06-14 12:18:06 -07:00
Garret Rieger 5ba46ed067 [subset] Correct OffsetTo serialization in GSUB to use serialize_serialize (). 2021-06-14 12:18:06 -07:00
Garret Rieger 35458b6b66 [subset] Add serialize_serialize to OffsetTo.
Similar to serialize_subset() this will serialize the new object and then link it to the offset.
2021-06-14 12:18:06 -07:00
Behdad Esfahbod 2b0ced28b6 Cluster Regional_Indicator pairs (aka emoji flags)
Fixes https://github.com/harfbuzz/harfbuzz/issues/2265
2021-06-14 06:34:58 -07:00
Behdad Esfahbod 4e72d5e35d [src/check-static-init] Ignore objdump "file format not recognized" error
Fixes https://github.com/harfbuzz/harfbuzz/issues/3019
2021-06-13 05:46:17 -06:00
Behdad Esfahbod 5bc05ba155 Prefer GPOS over kerx, if GSUB was applied
Fixes https://github.com/harfbuzz/harfbuzz/issues/3008
2021-06-13 05:28:20 -06:00
Behdad Esfahbod 13c6ad980f [src/check-*] Pickup $(NM), $(OBJDUMP), $(LDD), $(OTOOL)
Fixes https://github.com/harfbuzz/harfbuzz/issues/3019
2021-06-12 10:13:49 -07:00
Behdad Esfahbod c61ce962cf [buffer] In hb_buffer_get_positions(), return NULL if inside message callback
As discussed in https://github.com/harfbuzz/harfbuzz/issues/2468#issuecomment-645666066

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/2468
2021-06-10 17:36:38 -06:00
Behdad Esfahbod 855a3f478e [emoji] Fix emoji table generation
Previously, the last of each range having Extended_Pictograph property
was not processed as so. Ouch!

Test:

$ echo x > null; hb-shape null -u U+1f43b,U+200d,U+2744,U+fe0f

Before:
[gid0=0+1000|gid0=2+1000]

After:
[gid0=0+1000|gid0=0+1000]

Caught by https://github.com/harfbuzz/harfbuzz/issues/3017
2021-06-09 15:10:52 -06:00
Behdad Esfahbod bd5502f09f [set] Oops. Fix compile 2021-06-09 14:03:25 -06:00