diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src')
37 files changed, 1562 insertions, 372 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog index 759594e33bb..1111f51303f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog +++ b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog @@ -1,3 +1,536 @@ +commit 60841e26187576bff477c1a09ee2ffe544844abc +Author: Khaled Hosny <khaled@aliftype.com> +Date: Fri Mar 3 01:01:49 2023 +0200 + + 7.1.0 + + NEWS | 10 ++++++++++ + configure.ac | 2 +- + docs/harfbuzz-docs.xml | 1 + + meson.build | 2 +- + src/hb-font.cc | 2 +- + src/hb-version.h | 6 +++--- + 6 files changed, 17 insertions(+), 6 deletions(-) + +commit e471ef77f93eeafff2701a31e6c042054ea4f7e1 +Author: Qunxin Liu <qxliu@google.com> +Date: Thu Mar 2 12:40:16 2023 -0800 + + [instancer] fix a runtime error + + runtime error: -1 is outside the range of representable values of type 'unsigned int' + + src/hb-ot-var-cvar-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 43dbdd9db6abda31d41d06f4c33a826e1b791bd2 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 13:42:52 2023 -0700 + + [justify] Document algorithm + + src/hb-shape.cc | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +commit c98bb4cf9c2d73a78773ea9547865fbeaa1ecaff +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 13:18:06 2023 -0700 + + [justify] Fix up after recent changes + + Oops. + + src/hb-shape.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit fb067390e422d79b092d9cfe8abb84f0ef8cae05 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 11:40:45 2023 -0700 + + [docs] Fix a warning + + docs/harfbuzz-sections.txt | 1 + + 1 file changed, 1 insertion(+) + +commit fe83736e2608eb4697ce1194a69a55234561b620 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 11:35:42 2023 -0700 + + [sanitize] Protect against an underflow + + src/hb-sanitize.hh | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit 08784baf101aea472c133dcd67604b475ace3772 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 10:48:30 2023 -0700 + + [GSUB/GPOS] Fix sanitization in Format1 + + Fixes https://oss-fuzz.com/testcase-detail/5120727025319936 + + src/OT/Layout/GPOS/SinglePosFormat1.hh | 14 ++++++++------ + src/OT/Layout/GSUB/SingleSubstFormat1.hh | 14 ++++++++------ + 2 files changed, 16 insertions(+), 12 deletions(-) + +commit 789717387042ae7855cb61af2ef4b91ee32866a4 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 10:38:12 2023 -0700 + + [justify] Fix compiler warnings + + src/hb-shape.cc | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +commit be64cae16489406147848e4613d11de8303e1513 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Mar 2 09:50:38 2023 -0700 + + [map] Another try at fixing old Mac builds + + Maybe fixes https://github.com/harfbuzz/harfbuzz/issues/4138 + + src/hb-map.cc | 4 ++-- + src/hb-map.hh | 12 ------------ + src/test-map.cc | 4 ++-- + 3 files changed, 4 insertions(+), 16 deletions(-) + +commit 67e01c1292821e7b6fc2ab13acddb84ab41b2187 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 20:07:38 2023 -0700 + + [map] Try to work around old Mac compiler bug + + Maybe fixes https://github.com/harfbuzz/harfbuzz/issues/4138 + + src/hb-map.hh | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit e359f46a202899e0ee6dab1fec3c4cc325b9509c +Author: Khaled Hosny <khaled@aliftype.com> +Date: Thu Mar 2 03:06:53 2023 +0200 + + Fix build + + src/hb-shape.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit e8f94f9e1249fd1374fa282685ae93aba3b8fcdd +Merge: c67c0086e 6de9d2b89 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 16:34:01 2023 -0700 + + Merge pull request #4144 from harfbuzz/justify + + Justify + +commit 6de9d2b89fb10ce69ebf501b3e77bd95da5b1792 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 14:32:06 2023 -0700 + + [justify] Rename hb-view --width to hb-view --justify-to + + util/shape-options.hh | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +commit 25c66d633d58dcdd1e59095abf673a9ef08a612c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 14:16:08 2023 -0700 + + [justify] Wrap in HB_EXPERIMENTAL_API + + src/gen-def.py | 3 ++- + src/hb-shape.cc | 8 +++++++- + util/shape-options.hh | 4 ++++ + 3 files changed, 13 insertions(+), 2 deletions(-) + +commit 96d4ed093123293114d65800e8629deb1fff2218 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 14:08:16 2023 -0700 + + [justify] Document API + + docs/harfbuzz-sections.txt | 1 + + src/hb-shape.cc | 78 ++++++++++++++++++++++++++++++---------------- + src/hb-shape.h | 6 ++-- + 3 files changed, 56 insertions(+), 29 deletions(-) + +commit d29d7b7a3dd2cfca151ce667a3290359d028911c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 13:10:11 2023 -0700 + + [algs] Adjust solve_itp + + src/hb-algs.hh | 11 +++++++---- + src/hb-shape.cc | 4 ---- + 2 files changed, 7 insertions(+), 8 deletions(-) + +commit aa10deaf4283822f8c368ecbdebd01330dd76fe5 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 11:08:32 2023 -0700 + + [justify] Print default buffer width in hb-shape --width=-1 + + util/shape-options.hh | 25 ++++++++++++++++++++++--- + 1 file changed, 22 insertions(+), 3 deletions(-) + +commit 93252c6fc3585f6c226514e9c476af82b7c55d86 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 10:59:04 2023 -0700 + + [justify] Debug output + + src/hb-debug.hh | 4 ++++ + src/hb-shape.cc | 11 ++++++++--- + 2 files changed, 12 insertions(+), 3 deletions(-) + +commit b937edfb148d28421f97db7c3c81e2253019e469 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 10:44:57 2023 -0700 + + [justify] Add min/max target_width + + Speeds up solving when some slack available. + + src/hb-algs.hh | 8 +++++--- + src/hb-shape.cc | 32 ++++++++++++++++++-------------- + src/hb-shape.h | 3 ++- + util/shape-options.hh | 6 ++++-- + 4 files changed, 29 insertions(+), 20 deletions(-) + +commit 6e483c4061b526c6c22db198194d4f8b2cfb3a86 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 12:25:32 2023 -0700 + + [shape] Add hb_shape_justify() and hb-view --width + + src/hb-algs.hh | 2 +- + src/hb-shape.cc | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-shape.h | 11 ++++ + util/shape-options.hh | 30 +++++++-- + 4 files changed, 210 insertions(+), 6 deletions(-) + +commit ee4822f9696d2a40351a26d73257667a77af78ca +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 09:39:32 2023 -0700 + + [algs] Add solve_itp method + + Port from kurbo. + + src/hb-algs.hh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 53 insertions(+) + +commit c67c0086ef66e05228f9cc1f4c169f690e130511 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Mar 1 13:32:44 2023 -0700 + + [GPOS] Fix indexing in MarkLigPos + + This was broken in 8708b9e081. + + Fixes https://github.com/harfbuzz/harfbuzz/issues/4142 + + src/OT/Layout/GPOS/MarkLigPosFormat1.hh | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit 01d34763f06f0c513406dc14db6d496a08ecf4fa +Author: Matthias Clasen <mclasen@redhat.com> +Date: Tue Feb 28 20:16:39 2023 -0500 + + Typo fix + + src/hb-font.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2d33a6b4dfdcd751eba242637c863d810a4a803c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 15:31:45 2023 -0700 + + [subset-fuzzer] Protect against overflow + + Fixes + https://github.com/harfbuzz/harfbuzz/issues/4137#issuecomment-1448994447 + + test/fuzzing/hb-subset-fuzzer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5226d697338756e661c951af28c19b9a69b4ff93 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 14:49:44 2023 -0700 + + [font] Make set_variation() respect currently-set variations + + Fixes https://github.com/harfbuzz/harfbuzz/issues/4143 + + src/hb-font.cc | 27 ++++++++++++++++++--------- + 1 file changed, 18 insertions(+), 9 deletions(-) + +commit 91627daee2970b26666d8d9d47161387511667d1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 14:31:25 2023 -0700 + + [outline] Rename internal function + + src/hb-outline.cc | 4 ++-- + src/hb-outline.hh | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 5c462865920681246422a1d23d38cc62a94f1870 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 12:16:46 2023 -0700 + + Revert "." + + This reverts commit 59434578cd453d9dcdcaf5d010d5f5686c17717e. + + src/hb-shape.cc | 84 --------------------------------------------------------- + src/hb-shape.h | 9 ------- + 2 files changed, 93 deletions(-) + +commit 59434578cd453d9dcdcaf5d010d5f5686c17717e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 12:13:55 2023 -0700 + + . + + src/hb-shape.cc | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-shape.h | 9 +++++++ + 2 files changed, 93 insertions(+) + +commit bbb9d6d436b7fb5aba771c63378aa4daa231b8c5 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 28 12:07:48 2023 -0700 + + [font] Add hb_font_set_variation() + + docs/harfbuzz-sections.txt | 1 + + src/hb-font.cc | 64 ++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-font.h | 5 ++++ + 3 files changed, 70 insertions(+) + +commit a975ec4842468e574484bdc310095fad780978fc +Author: Qunxin Liu <qxliu@google.com> +Date: Tue Feb 14 13:26:59 2023 -0800 + + [instancer] apply cvar deltas + + src/hb-ot-face-table-list.hh | 1 + + src/hb-ot-var-cvar-table.hh | 27 +++++++++++++-------- + src/hb-subset-input.cc | 1 - + src/hb-subset.cc | 11 +++++++++ + test/subset/data/Makefile.am | 1 + + test/subset/data/Makefile.sources | 1 + + ...r-new.default.retain-all-codepoint.wght=300.ttf | Bin 0 -> 131712 bytes + ...r-new.default.retain-all-codepoint.wght=700.ttf | Bin 0 -> 131588 bytes + test/subset/data/tests/apply_cvar_delta.tests | 12 +++++++++ + test/subset/meson.build | 1 + + 10 files changed, 44 insertions(+), 11 deletions(-) + +commit 8b0c7b9554cc75d499bc0aa9c25f45e53a1f2ce9 +Author: Qunxin Liu <qxliu@google.com> +Date: Fri Feb 10 09:49:09 2023 -0800 + + [instance] Add struct definition for cvar table + + Also add functions to add cvt tables with cvar deltas applied + + src/Makefile.sources | 1 + + src/hb-ot-var-common.hh | 19 ++++++ + src/hb-ot-var-cvar-table.hh | 151 ++++++++++++++++++++++++++++++++++++++++++++ + src/meson.build | 1 + + 4 files changed, 172 insertions(+) + +commit 22cc73f3e9b941be47330a574599cddd79811168 +Author: Qunxin Liu <qxliu@google.com> +Date: Mon Feb 6 12:36:05 2023 -0800 + + Move common structs for TupleVariation from gvar to var-common.hh + + Also added a table_base in the iterator and related function to handle + different start address for dataoffset in cvar and gvar + + src/hb-ot-var-common.hh | 308 +++++++++++++++++++++++++++++++++++++++++++ + src/hb-ot-var-gvar-table.hh | 309 +------------------------------------------- + 2 files changed, 312 insertions(+), 305 deletions(-) + +commit c0fac016dc017596e2d979e19e1eb8f88df38ea3 +Author: Garret Rieger <grieger@google.com> +Date: Wed Feb 22 20:54:20 2023 +0000 + + [subset] update the subset fuzzer to be able to reach instancing code. + + test/fuzzing/fonts/AdobeVFPrototype.ABC.otf | Bin 0 -> 4724 bytes + test/fuzzing/fonts/Roboto-Variable.ABC.ttf | Bin 0 -> 13480 bytes + test/fuzzing/hb-subset-fuzzer.cc | 49 +++++++++++++++++++++++----- + 3 files changed, 41 insertions(+), 8 deletions(-) + +commit 62fc27f372779d363cb6ba46cfaca6433a42504b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Feb 27 11:20:47 2023 -0700 + + [ft] Enlarge glyph-cache value-size again + + 8bits just doesn't do it. It has caused cache-hammering and high + CPU usage when the font is hinted. + + Fixes https://github.com/harfbuzz/harfbuzz/issues/4139 + + src/hb-ft.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 921eca3e79df93af8ee16a47994150d1f4845bfc +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Feb 24 17:06:43 2023 -0700 + + [autotools] Fix hb-info chafa build + + util/Makefile.am | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit 209f63b7850f836e5e3628523f6f740e25008409 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Feb 24 16:03:23 2023 -0700 + + [TINY] Fix config issue + + src/hb-config.hh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 605aed0544e51fa2534a3324262f3935d4dcfe99 +Author: Qunxin Liu <qxliu@google.com> +Date: Fri Feb 24 10:17:32 2023 -0800 + + [instancer] bug fix in post table applying mvar deltas + + src/hb-ot-post-table.hh | 8 ++++---- + test/subset/data/Makefile.am | 1 + + test/subset/data/Makefile.sources | 1 + + ...l-codepoint.wght=400,CASL=0,CRSV=0,MONO=0,slnt=0.ttf | Bin 0 -> 1884 bytes + test/subset/data/fonts/Recursive-ABC.ttf | Bin 0 -> 20332 bytes + test/subset/data/tests/post_apply_mvar_delta.tests | 11 +++++++++++ + test/subset/meson.build | 1 + + 7 files changed, 18 insertions(+), 4 deletions(-) + +commit 918193ebf908d35c88bb71d02dfc14bc41ffc31d +Author: Garret Rieger <grieger@google.com> +Date: Wed Feb 22 23:11:29 2023 +0000 + + [subset] fix a class of fuzzer timeouts caused by large shared coverage tables. + + More acurately estimates the op count for CoverageFormat2 tables as the population size instead of the size in bytes. + + src/OT/Layout/GPOS/SinglePosFormat1.hh | 8 +++++++- + src/OT/Layout/GSUB/SingleSubstFormat1.hh | 8 +++++++- + src/hb-sanitize.hh | 8 ++++++++ + ...testcase-minimized-hb-subset-fuzzer-5192684970311680 | Bin 0 -> 67697 bytes + 4 files changed, 22 insertions(+), 2 deletions(-) + +commit ddd0f7f40b5cae71271fcfa7b6143066d8e465df +Author: Garret Rieger <grieger@google.com> +Date: Wed Feb 22 20:23:34 2023 +0000 + + [subset] Add a test for CFF2 instancing. + + Adds option to disable the fonttools comparison check in the test. This is needed since CFF2 instancing is not yet supported in fonttools. + + test/subset/data/Makefile.am | 1 + + test/subset/data/Makefile.sources | 1 + + ...efault.retain-all-codepoint.wght=650,CNTR=50.otf | Bin 0 -> 41760 bytes + test/subset/data/tests/instantiate_cff2.tests | 14 ++++++++++++++ + test/subset/generate-expected-outputs.py | 20 +++++++++++--------- + test/subset/meson.build | 1 + + test/subset/subset_test_suite.py | 13 ++++++++----- + 7 files changed, 36 insertions(+), 14 deletions(-) + +commit 33cc3121d457b415f3fac2374af7df5cd4fd704e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 22 12:03:30 2023 -0700 + + Comment + + src/hb-shaper-list.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5bc6ab006da7dbab993867c3d7d24cefaa81b51c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 22 08:08:11 2023 -0700 + + Use __has_builtin for builtin checks instead of compiler versions + + https://github.com/harfbuzz/harfbuzz/issues/4066#issuecomment-1439510188 + + src/hb-algs.hh | 30 ++++++++++++++++++++++-------- + src/hb.hh | 10 +++++++++- + 2 files changed, 31 insertions(+), 9 deletions(-) + +commit 6b286cfabf23c93ecec6d65f83d8c1291cd46cf6 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 21 16:15:45 2023 -0700 + + [cubic-glyf] Remove stale comment + + src/OT/glyf/path-builder.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 22b93156281dae8772b15e68b2553a2a9a5c8367 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 21 15:50:55 2023 -0700 + + [cubic-glyf] Handle wrap-around cubic off-curves + + src/OT/glyf/path-builder.hh | 30 ++++++++++++++++++++---------- + 1 file changed, 20 insertions(+), 10 deletions(-) + +commit 050f5a58fe182f8f2bf85c95fc2ddc13bc784699 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 21 15:25:59 2023 -0700 + + [cubic-glyf] Handle contour-initial cubic offcurves + + src/OT/glyf/path-builder.hh | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit 9c27fe625f592fdb97dc94c4006f928877e7cb61 +Author: Khaled Hosny <khaled@aliftype.com> +Date: Tue Feb 21 23:25:14 2023 +0200 + + Revert "[doc] Fix a couple of gtk-doc warnings" + + This reverts commit ed42b2fcb556a1d47a620f77cc98069123d1670c. + + docs/harfbuzz-sections.txt | 1 - + src/hb-gobject-structs.cc | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +commit ed42b2fcb556a1d47a620f77cc98069123d1670c +Author: Khaled Hosny <khaled@aliftype.com> +Date: Tue Feb 21 23:08:15 2023 +0200 + + [doc] Fix a couple of gtk-doc warnings + + docs/harfbuzz-sections.txt | 1 + + src/hb-gobject-structs.cc | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 0575229477006a51f85eee10c9490db92972d60a +Author: Khaled Hosny <khaled@aliftype.com> +Date: Tue Feb 21 18:07:53 2023 +0200 + + [blob] Typo in documentation + + src/hb-blob.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 424f5f2c0d10596abc79d98bc165cd9e86680597 +Author: Khaled Hosny <khaled@aliftype.com> +Date: Mon Feb 20 16:05:53 2023 +0200 + + [ci] Don’t build docs while building Windows binaries + + .circleci/config.yml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + commit 1d1f93a612ed071b703abab7deb0951f46a12433 Author: Khaled Hosny <khaled@aliftype.com> Date: Mon Feb 20 15:54:12 2023 +0200 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS index 9a5914525c5..5ed287822d0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS +++ b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS @@ -1,3 +1,13 @@ +Overview of changes leading to 7.1.0 +Friday, March 3, 2023 +==================================== +- New experimental hb_shape_justify() API that uses font variations to expand + or shrink the text to a given advance. (Behdad Esfahbod) +- Various build and bug fixes. (Behdad Esfahbod, Garret Rieger, Qunxin Liu) + +- New API: ++hb_font_set_variation() + Overview of changes leading to 7.0.1 Monday, February 20, 2023 ==================================== diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac index 099259a2752..c863ab83b0b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac +++ b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [7.0.1], + [7.1.0], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/meson.build b/Build/source/libs/harfbuzz/harfbuzz-src/meson.build index 1515257c9c9..6bf8d05da94 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/meson.build +++ b/Build/source/libs/harfbuzz/harfbuzz-src/meson.build @@ -1,6 +1,6 @@ project('harfbuzz', 'c', 'cpp', meson_version: '>= 0.55.0', - version: '7.0.1', + version: '7.1.0', default_options: [ 'cpp_eh=none', # Just to support msvc, we are passing -fno-exceptions also anyway 'cpp_rtti=false', # Just to support msvc, we are passing -fno-rtti also anyway diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources index 9a96ad69ffc..fd7c3b55ef2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources @@ -225,6 +225,7 @@ HB_BASE_sources = \ hb-ot-tag.cc \ hb-ot-var-avar-table.hh \ hb-ot-var-common.hh \ + hb-ot-var-cvar-table.hh \ hb-ot-var-fvar-table.hh \ hb-ot-var-gvar-table.hh \ hb-ot-var-hvar-table.hh \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/MarkLigPosFormat1.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/MarkLigPosFormat1.hh index 7e7b438aa7d..92e83a0e994 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/MarkLigPosFormat1.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/MarkLigPosFormat1.hh @@ -126,15 +126,15 @@ struct MarkLigPosFormat1_2 return_trace (false); } - j = (unsigned) c->last_base; + unsigned idx = (unsigned) c->last_base; /* Checking that matched glyph is actually a ligature by GDEF is too strong; disabled */ - //if (!_hb_glyph_info_is_ligature (&buffer->info[j])) { return_trace (false); } + //if (!_hb_glyph_info_is_ligature (&buffer->info[idx])) { return_trace (false); } - unsigned int lig_index = (this+ligatureCoverage).get_coverage (buffer->info[j].codepoint); + unsigned int lig_index = (this+ligatureCoverage).get_coverage (buffer->info[idx].codepoint); if (lig_index == NOT_COVERED) { - buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1); + buffer->unsafe_to_concat_from_outbuffer (idx, buffer->idx + 1); return_trace (false); } @@ -145,7 +145,7 @@ struct MarkLigPosFormat1_2 unsigned int comp_count = lig_attach.rows; if (unlikely (!comp_count)) { - buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1); + buffer->unsafe_to_concat_from_outbuffer (idx, buffer->idx + 1); return_trace (false); } @@ -154,7 +154,7 @@ struct MarkLigPosFormat1_2 * can directly use the component index. If not, we attach the mark * glyph to the last component of the ligature. */ unsigned int comp_index; - unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[j]); + unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[idx]); unsigned int mark_id = _hb_glyph_info_get_lig_id (&buffer->cur()); unsigned int mark_comp = _hb_glyph_info_get_lig_comp (&buffer->cur()); if (lig_id && lig_id == mark_id && mark_comp > 0) @@ -162,7 +162,7 @@ struct MarkLigPosFormat1_2 else comp_index = comp_count - 1; - return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j)); + return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, idx)); } bool subset (hb_subset_context_t *c) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/SinglePosFormat1.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/SinglePosFormat1.hh index f7a170f34e0..623e4e66b20 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/SinglePosFormat1.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GPOS/SinglePosFormat1.hh @@ -28,7 +28,15 @@ struct SinglePosFormat1 TRACE_SANITIZE (this); return_trace (c->check_struct (this) && coverage.sanitize (c, this) && + /* The coverage table may use a range to represent a set + * of glyphs, which means a small number of bytes can + * generate a large glyph set. Manually modify the + * sanitizer max ops to take this into account. + * + * Note: This check *must* be right after coverage sanitize. */ + c->check_ops ((this + coverage).get_population () >> 1) && valueFormat.sanitize_value (c, this, values)); + } bool intersects (const hb_set_t *glyphs) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GSUB/SingleSubstFormat1.hh index 78725352c28..5b54fdb0788 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -25,7 +25,15 @@ struct SingleSubstFormat1_3 bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c)); + return_trace (c->check_struct (this) && + coverage.sanitize (c, this) && + /* The coverage table may use a range to represent a set + * of glyphs, which means a small number of bytes can + * generate a large glyph set. Manually modify the + * sanitizer max ops to take this into account. + * + * Note: This check *must* be right after coverage sanitize. */ + c->check_ops ((this + coverage).get_population () >> 1)); } hb_codepoint_t get_mask () const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/glyf/path-builder.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/glyf/path-builder.hh index e35a4dafde0..8916241f76e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/glyf/path-builder.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/OT/glyf/path-builder.hh @@ -26,13 +26,13 @@ struct path_builder_t optional_point_t lerp (optional_point_t p, float t) { return optional_point_t (x + t * (p.x - x), y + t * (p.y - y)); } - } first_oncurve, first_offcurve, last_offcurve, last_offcurve2; + } first_oncurve, first_offcurve, first_offcurve2, last_offcurve, last_offcurve2; path_builder_t (hb_font_t *font_, hb_draw_session_t &draw_session_) { font = font_; draw_session = &draw_session_; - first_oncurve = first_offcurve = last_offcurve = last_offcurve2 = optional_point_t (); + first_oncurve = first_offcurve = first_offcurve2 = last_offcurve = last_offcurve2 = optional_point_t (); } /* based on https://github.com/RazrFalcon/ttf-parser/blob/4f32821/src/glyf.rs#L287 @@ -40,7 +40,7 @@ struct path_builder_t * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM01/Chap1.html * https://stackoverflow.com/a/20772557 * - * Cubic support added (incomplete). */ + * Cubic support added. */ void consume_point (const contour_point_t &point) { bool is_on_curve = point.flag & glyf_impl::SimpleGlyph::FLAG_ON_CURVE; @@ -59,7 +59,12 @@ struct path_builder_t } else { - if (first_offcurve) + if (is_cubic && !first_offcurve2) + { + first_offcurve2 = first_offcurve; + first_offcurve = p; + } + else if (first_offcurve) { optional_point_t mid = first_offcurve.lerp (p, .5f); first_oncurve = mid; @@ -126,16 +131,30 @@ struct path_builder_t { if (first_offcurve && last_offcurve) { - optional_point_t mid = last_offcurve.lerp (first_offcurve, .5f); - draw_session->quadratic_to (last_offcurve.x, last_offcurve.y, - mid.x, mid.y); + optional_point_t mid = last_offcurve.lerp (first_offcurve2 ? + first_offcurve2 : + first_offcurve, .5f); + if (last_offcurve2) + draw_session->cubic_to (last_offcurve2.x, last_offcurve2.y, + last_offcurve.x, last_offcurve.y, + mid.x, mid.y); + else + draw_session->quadratic_to (last_offcurve.x, last_offcurve.y, + mid.x, mid.y); last_offcurve = optional_point_t (); - /* now check the rest */ } + /* now check the rest */ if (first_offcurve && first_oncurve) - draw_session->quadratic_to (first_offcurve.x, first_offcurve.y, - first_oncurve.x, first_oncurve.y); + { + if (first_offcurve2) + draw_session->cubic_to (first_offcurve2.x, first_offcurve2.y, + first_offcurve.x, first_offcurve.y, + first_oncurve.x, first_oncurve.y); + else + draw_session->quadratic_to (first_offcurve.x, first_offcurve.y, + first_oncurve.x, first_oncurve.y); + } else if (last_offcurve && first_oncurve) { if (last_offcurve2) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-def.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-def.py index 9b4efd4f3ec..6011817bc54 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-def.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-def.py @@ -19,7 +19,8 @@ symbols = sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re if '--experimental-api' not in sys.argv: # Move these to harfbuzz-sections.txt when got stable experimental_symbols = \ -"""hb_subset_repack_or_fail +"""hb_shape_justify +hb_subset_repack_or_fail hb_subset_input_override_name_table """.splitlines () symbols = [x for x in symbols if x not in experimental_symbols] diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-algs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-algs.hh index e98645e3e3b..13587eac017 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-algs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-algs.hh @@ -110,9 +110,10 @@ struct BEInt<Type, 2> constexpr operator Type () const { #if defined(__OPTIMIZE__) && !defined(HB_NO_PACKED) && \ - ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) && \ defined(__BYTE_ORDER) && \ - (__BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __BIG_ENDIAN) + (__BYTE_ORDER == __BIG_ENDIAN || \ + (__BYTE_ORDER == __LITTLE_ENDIAN && \ + hb_has_builtin(__builtin_bswap16))) /* Spoon-feed the compiler a big-endian integer with alignment 1. * https://github.com/harfbuzz/harfbuzz/pull/1398 */ #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -155,9 +156,10 @@ struct BEInt<Type, 4> struct __attribute__((packed)) packed_uint32_t { uint32_t v; }; constexpr operator Type () const { #if defined(__OPTIMIZE__) && !defined(HB_NO_PACKED) && \ - ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) && \ defined(__BYTE_ORDER) && \ - (__BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __BIG_ENDIAN) + (__BYTE_ORDER == __BIG_ENDIAN || \ + (__BYTE_ORDER == __LITTLE_ENDIAN && \ + hb_has_builtin(__builtin_bswap32))) /* Spoon-feed the compiler a big-endian integer with alignment 1. * https://github.com/harfbuzz/harfbuzz/pull/1398 */ #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -598,13 +600,17 @@ template <typename T> static inline unsigned int hb_popcount (T v) { -#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) +#if hb_has_builtin(__builtin_popcount) if (sizeof (T) <= sizeof (unsigned int)) return __builtin_popcount (v); +#endif +#if hb_has_builtin(__builtin_popcountl) if (sizeof (T) <= sizeof (unsigned long)) return __builtin_popcountl (v); +#endif +#if hb_has_builtin(__builtin_popcountll) if (sizeof (T) <= sizeof (unsigned long long)) return __builtin_popcountll (v); #endif @@ -641,13 +647,17 @@ hb_bit_storage (T v) { if (unlikely (!v)) return 0; -#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) +#if hb_has_builtin(__builtin_clz) if (sizeof (T) <= sizeof (unsigned int)) return sizeof (unsigned int) * 8 - __builtin_clz (v); +#endif +#if hb_has_builtin(__builtin_clzl) if (sizeof (T) <= sizeof (unsigned long)) return sizeof (unsigned long) * 8 - __builtin_clzl (v); +#endif +#if hb_has_builtin(__builtin_clzll) if (sizeof (T) <= sizeof (unsigned long long)) return sizeof (unsigned long long) * 8 - __builtin_clzll (v); #endif @@ -715,13 +725,17 @@ hb_ctz (T v) { if (unlikely (!v)) return 8 * sizeof (T); -#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) +#if hb_has_builtin(__builtin_ctz) if (sizeof (T) <= sizeof (unsigned int)) return __builtin_ctz (v); +#endif +#if hb_has_builtin(__builtin_ctzl) if (sizeof (T) <= sizeof (unsigned long)) return __builtin_ctzl (v); +#endif +#if hb_has_builtin(__builtin_ctzll) if (sizeof (T) <= sizeof (unsigned long long)) return __builtin_ctzll (v); #endif @@ -875,7 +889,7 @@ hb_in_ranges (T u, T lo1, T hi1, Ts... ds) static inline bool hb_unsigned_mul_overflows (unsigned int count, unsigned int size, unsigned *result = nullptr) { -#if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && (__clang_major__ >= 8)) +#if hb_has_builtin(__builtin_mul_overflow) unsigned stack_result; if (!result) result = &stack_result; @@ -1330,4 +1344,62 @@ struct HB_FUNCOBJ (hb_dec); +/* Adapted from kurbo implementation with extra parameters added, + * and finding for a particular range instead of 0. + * + * For documentation and implementation see: + * + * [ITP method]: https://en.wikipedia.org/wiki/ITP_Method + * [An Enhancement of the Bisection Method Average Performance Preserving Minmax Optimality]: https://dl.acm.org/doi/10.1145/3423597 + * https://docs.rs/kurbo/0.8.1/kurbo/common/fn.solve_itp.html + * https://github.com/linebender/kurbo/blob/fd839c25ea0c98576c7ce5789305822675a89938/src/common.rs#L162-L248 + */ +template <typename func_t> +double solve_itp (func_t f, + double a, double b, + double epsilon, + double min_y, double max_y, + double &ya, double &yb, double &y) +{ + unsigned n1_2 = (unsigned) (hb_max (ceil (log2 ((b - a) / epsilon)) - 1.0, 0.0)); + const unsigned n0 = 1; // Hardwired + const double k1 = 0.2 / (b - a); // Hardwired. + unsigned nmax = n0 + n1_2; + double scaled_epsilon = epsilon * double (1llu << nmax); + double _2_epsilon = 2.0 * epsilon; + while (b - a > _2_epsilon) + { + double x1_2 = 0.5 * (a + b); + double r = scaled_epsilon - 0.5 * (b - a); + double xf = (yb * a - ya * b) / (yb - ya); + double sigma = x1_2 - xf; + double b_a = b - a; + // This has k2 = 2 hardwired for efficiency. + double b_a_k2 = b_a * b_a; + double delta = k1 * b_a_k2; + int sigma_sign = sigma >= 0 ? +1 : -1; + double xt = delta <= fabs (x1_2 - xf) ? xf + delta * sigma_sign : x1_2; + double xitp = fabs (xt - x1_2) <= r ? xt : x1_2 - r * sigma_sign; + double yitp = f (xitp); + if (yitp > max_y) + { + b = xitp; + yb = yitp; + } + else if (yitp < min_y) + { + a = xitp; + ya = yitp; + } + else + { + y = yitp; + return xitp; + } + scaled_epsilon *= 0.5; + } + return 0.5 * (a + b); +} + + #endif /* HB_ALGS_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.h index 4eb42314da3..db50067e164 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.h @@ -63,7 +63,7 @@ HB_BEGIN_DECLS * HarfBuzz and doing that just once (no reuse!), * * - If the font is mmap()ed, it's okay to use - * @HB_MEMORY_READONLY_MAY_MAKE_WRITABLE, however, using that mode + * @HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE, however, using that mode * correctly is very tricky. Use @HB_MEMORY_MODE_READONLY instead. **/ typedef enum { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text-glyphs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text-glyphs.hh index ea81273b31c..5fe75659b49 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text-glyphs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text-glyphs.hh @@ -32,7 +32,7 @@ #include "hb.hh" -#line 36 "hb-buffer-deserialize-text-glyphs.hh" +#line 33 "hb-buffer-deserialize-text-glyphs.hh" static const unsigned char _deserialize_text_glyphs_trans_keys[] = { 0u, 0u, 48u, 57u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 43u, 124u, 9u, 124u, 9u, 124u, @@ -349,12 +349,12 @@ _hb_buffer_deserialize_text_glyphs (hb_buffer_t *buffer, hb_glyph_info_t info = {0}; hb_glyph_position_t pos = {0}; -#line 353 "hb-buffer-deserialize-text-glyphs.hh" +#line 346 "hb-buffer-deserialize-text-glyphs.hh" { cs = deserialize_text_glyphs_start; } -#line 358 "hb-buffer-deserialize-text-glyphs.hh" +#line 349 "hb-buffer-deserialize-text-glyphs.hh" { int _slen; int _trans; @@ -550,7 +550,7 @@ _resume: *end_ptr = p; } break; -#line 554 "hb-buffer-deserialize-text-glyphs.hh" +#line 516 "hb-buffer-deserialize-text-glyphs.hh" } _again: @@ -667,7 +667,7 @@ _again: *end_ptr = p; } break; -#line 671 "hb-buffer-deserialize-text-glyphs.hh" +#line 616 "hb-buffer-deserialize-text-glyphs.hh" } } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-config.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-config.hh index 047518b87d4..52adaad4384 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-config.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-config.hh @@ -136,6 +136,10 @@ #define HB_NO_SUBSET_CFF #endif +#ifdef HB_NO_DRAW +#define HB_NO_OUTLINE +#endif + #ifdef HB_NO_GETENV #define HB_NO_UNISCRIBE_BUG_COMPATIBLE #endif diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh index efab374646b..0ac4515fa85 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh @@ -373,6 +373,10 @@ struct hb_no_trace_t { #define HB_DEBUG_FT (HB_DEBUG+0) #endif +#ifndef HB_DEBUG_JUSTIFY +#define HB_DEBUG_JUSTIFY (HB_DEBUG+0) +#endif + #ifndef HB_DEBUG_OBJECT #define HB_DEBUG_OBJECT (HB_DEBUG+0) #endif diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc index 3868863105f..1b345a9447c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -2650,6 +2650,79 @@ hb_font_set_variations (hb_font_t *font, } /** + * hb_font_set_variation: + * @font: #hb_font_t to work upon + * @tag: The #hb_tag_t tag of the variation-axis name + * @value: The value of the variation axis + * + * Change the value of one variation axis on the font. + * + * Note: This function is expensive to be called repeatedly. + * If you want to set multiple variation axes at the same time, + * use hb_font_set_variations() instead. + * + * Since: 7.1.0 + */ +void +hb_font_set_variation (hb_font_t *font, + hb_tag_t tag, + float value) +{ + if (hb_object_is_immutable (font)) + return; + + font->serial_coords = ++font->serial; + + // TODO Share some of this code with set_variations() + + const OT::fvar &fvar = *font->face->table.fvar; + auto axes = fvar.get_axes (); + const unsigned coords_length = axes.length; + + int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr; + float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr; + + if (unlikely (coords_length && !(normalized && design_coords))) + { + hb_free (normalized); + hb_free (design_coords); + return; + } + + /* Initialize design coords. */ + if (font->design_coords) + { + assert (coords_length == font->num_coords); + for (unsigned int i = 0; i < coords_length; i++) + design_coords[i] = font->design_coords[i]; + } + else + { + for (unsigned int i = 0; i < coords_length; i++) + design_coords[i] = axes[i].get_default (); + if (font->instance_index != HB_FONT_NO_VAR_NAMED_INSTANCE) + { + unsigned count = coords_length; + /* This may fail if index is out-of-range; + * That's why we initialize design_coords from fvar above + * unconditionally. */ + hb_ot_var_named_instance_get_design_coords (font->face, font->instance_index, + &count, design_coords); + } + } + + for (unsigned axis_index = 0; axis_index < coords_length; axis_index++) + if (axes[axis_index].axisTag == tag) + design_coords[axis_index] = value; + + font->face->table.avar->map_coords (normalized, coords_length); + + hb_ot_var_normalize_coords (font->face, coords_length, design_coords, normalized); + _hb_font_adopt_var_coords (font, normalized, design_coords, coords_length); + +} + +/** * hb_font_set_var_coords_design: * @font: #hb_font_t to work upon * @coords: (array length=coords_length): Array of variation coordinates to apply diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h index 69457da5770..f3b589bd0d8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h @@ -1151,6 +1151,11 @@ hb_font_set_variations (hb_font_t *font, unsigned int variations_length); HB_EXTERN void +hb_font_set_variation (hb_font_t *font, + hb_tag_t tag, + float value); + +HB_EXTERN void hb_font_set_var_coords_design (hb_font_t *font, const float *coords, unsigned int coords_length); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc index 4bc10e06202..1105862fbc9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -85,7 +85,7 @@ */ -using hb_ft_advance_cache_t = hb_cache_t<16, 8, 8, false>; +using hb_ft_advance_cache_t = hb_cache_t<16, 24, 8, false>; struct hb_ft_font_t { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc index 0014570e8e5..5d67cd9a12d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc @@ -399,7 +399,7 @@ void hb_map_keys (const hb_map_t *map, hb_set_t *keys) { - map->keys (*keys); + hb_copy (map->keys() , *keys); } /** @@ -415,5 +415,5 @@ void hb_map_values (const hb_map_t *map, hb_set_t *values) { - map->values (*values); + hb_copy (map->values() , *values); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh index 615d1825edd..552b4066518 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh @@ -317,16 +317,6 @@ struct hb_hashmap_t hb_copy (other, *this); } - void keys (hb_set_t &keys_) const - { - hb_copy (keys() , keys_); - } - - void values (hb_set_t &values_) const - { - hb_copy (values() , values_); - } - /* * Iterator */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face-table-list.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face-table-list.hh index c9da36c1bb5..b552dfdd9da 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face-table-list.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face-table-list.hh @@ -93,6 +93,7 @@ HB_OT_ACCELERATOR (OT, cff2) #ifndef HB_NO_VAR HB_OT_CORE_TABLE (OT, fvar) HB_OT_CORE_TABLE (OT, avar) +HB_OT_CORE_TABLE (OT, cvar) HB_OT_ACCELERATOR (OT, gvar) HB_OT_CORE_TABLE (OT, MVAR) #endif diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh index e0eb7709487..042fa611adf 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh @@ -99,6 +99,10 @@ struct post post *post_prime = c->serializer->start_embed<post> (); if (unlikely (!post_prime)) return_trace (false); + bool glyph_names = c->plan->flags & HB_SUBSET_FLAGS_GLYPH_NAMES; + if (!serialize (c->serializer, glyph_names)) + return_trace (false); + #ifndef HB_NO_VAR if (c->plan->normalized_coords) { @@ -110,10 +114,6 @@ struct post } #endif - bool glyph_names = c->plan->flags & HB_SUBSET_FLAGS_GLYPH_NAMES; - if (!serialize (c->serializer, glyph_names)) - return_trace (false); - if (c->plan->user_axes_location.has (HB_TAG ('s','l','n','t')) && !c->plan->pinned_at_default) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shaper-myanmar-machine.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shaper-myanmar-machine.hh index f7b456b11f6..809f6eefb02 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shaper-myanmar-machine.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shaper-myanmar-machine.hh @@ -50,7 +50,7 @@ enum myanmar_syllable_type_t { }; -#line 54 "hb-ot-shaper-myanmar-machine.hh" +#line 51 "hb-ot-shaper-myanmar-machine.hh" #define myanmar_syllable_machine_ex_A 9u #define myanmar_syllable_machine_ex_As 32u #define myanmar_syllable_machine_ex_C 1u @@ -77,7 +77,7 @@ enum myanmar_syllable_type_t { #define myanmar_syllable_machine_ex_ZWNJ 5u -#line 81 "hb-ot-shaper-myanmar-machine.hh" +#line 76 "hb-ot-shaper-myanmar-machine.hh" static const unsigned char _myanmar_syllable_machine_trans_keys[] = { 1u, 41u, 3u, 41u, 5u, 39u, 5u, 8u, 3u, 41u, 3u, 39u, 3u, 39u, 5u, 39u, 5u, 39u, 3u, 39u, 3u, 39u, 3u, 41u, 5u, 39u, 1u, 15u, 3u, 39u, 3u, 39u, @@ -443,7 +443,7 @@ find_syllables_myanmar (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 447 "hb-ot-shaper-myanmar-machine.hh" +#line 436 "hb-ot-shaper-myanmar-machine.hh" { cs = myanmar_syllable_machine_start; ts = 0; @@ -459,7 +459,7 @@ find_syllables_myanmar (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 463 "hb-ot-shaper-myanmar-machine.hh" +#line 448 "hb-ot-shaper-myanmar-machine.hh" { int _slen; int _trans; @@ -473,7 +473,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 477 "hb-ot-shaper-myanmar-machine.hh" +#line 460 "hb-ot-shaper-myanmar-machine.hh" } _keys = _myanmar_syllable_machine_trans_keys + (cs<<1); @@ -519,7 +519,7 @@ _eof_trans: #line 113 "hb-ot-shaper-myanmar-machine.rl" {te = p;p--;{ found_syllable (myanmar_non_myanmar_cluster); }} break; -#line 523 "hb-ot-shaper-myanmar-machine.hh" +#line 498 "hb-ot-shaper-myanmar-machine.hh" } _again: @@ -528,7 +528,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 532 "hb-ot-shaper-myanmar-machine.hh" +#line 505 "hb-ot-shaper-myanmar-machine.hh" } if ( ++p != pe ) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-common.hh index 4997c2e2e89..cdc6a274ce1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-common.hh @@ -237,6 +237,333 @@ struct VarStoreInstancer hb_array_t<int> coords; }; +/* https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#tuplevariationheader */ +struct TupleVariationHeader +{ + unsigned get_size (unsigned axis_count) const + { return min_size + get_all_tuples (axis_count).get_size (); } + + unsigned get_data_size () const { return varDataSize; } + + const TupleVariationHeader &get_next (unsigned axis_count) const + { return StructAtOffset<TupleVariationHeader> (this, get_size (axis_count)); } + + float calculate_scalar (hb_array_t<int> coords, unsigned int coord_count, + const hb_array_t<const F2DOT14> shared_tuples) const + { + hb_array_t<const F2DOT14> peak_tuple; + + if (has_peak ()) + peak_tuple = get_peak_tuple (coord_count); + else + { + unsigned int index = get_index (); + if (unlikely (index * coord_count >= shared_tuples.length)) + return 0.f; + peak_tuple = shared_tuples.sub_array (coord_count * index, coord_count); + } + + hb_array_t<const F2DOT14> start_tuple; + hb_array_t<const F2DOT14> end_tuple; + if (has_intermediate ()) + { + start_tuple = get_start_tuple (coord_count); + end_tuple = get_end_tuple (coord_count); + } + + float scalar = 1.f; + for (unsigned int i = 0; i < coord_count; i++) + { + int v = coords[i]; + int peak = peak_tuple[i].to_int (); + if (!peak || v == peak) continue; + + if (has_intermediate ()) + { + int start = start_tuple[i].to_int (); + int end = end_tuple[i].to_int (); + if (unlikely (start > peak || peak > end || + (start < 0 && end > 0 && peak))) continue; + if (v < start || v > end) return 0.f; + if (v < peak) + { if (peak != start) scalar *= (float) (v - start) / (peak - start); } + else + { if (peak != end) scalar *= (float) (end - v) / (end - peak); } + } + else if (!v || v < hb_min (0, peak) || v > hb_max (0, peak)) return 0.f; + else + scalar *= (float) v / peak; + } + return scalar; + } + + bool has_peak () const { return tupleIndex & TuppleIndex::EmbeddedPeakTuple; } + bool has_intermediate () const { return tupleIndex & TuppleIndex::IntermediateRegion; } + bool has_private_points () const { return tupleIndex & TuppleIndex::PrivatePointNumbers; } + unsigned get_index () const { return tupleIndex & TuppleIndex::TupleIndexMask; } + + protected: + struct TuppleIndex : HBUINT16 + { + enum Flags { + EmbeddedPeakTuple = 0x8000u, + IntermediateRegion = 0x4000u, + PrivatePointNumbers = 0x2000u, + TupleIndexMask = 0x0FFFu + }; + + DEFINE_SIZE_STATIC (2); + }; + + hb_array_t<const F2DOT14> get_all_tuples (unsigned axis_count) const + { return StructAfter<UnsizedArrayOf<F2DOT14>> (tupleIndex).as_array ((has_peak () + has_intermediate () * 2) * axis_count); } + hb_array_t<const F2DOT14> get_peak_tuple (unsigned axis_count) const + { return get_all_tuples (axis_count).sub_array (0, axis_count); } + hb_array_t<const F2DOT14> get_start_tuple (unsigned axis_count) const + { return get_all_tuples (axis_count).sub_array (has_peak () * axis_count, axis_count); } + hb_array_t<const F2DOT14> get_end_tuple (unsigned axis_count) const + { return get_all_tuples (axis_count).sub_array (has_peak () * axis_count + axis_count, axis_count); } + + HBUINT16 varDataSize; /* The size in bytes of the serialized + * data for this tuple variation table. */ + TuppleIndex tupleIndex; /* A packed field. The high 4 bits are flags (see below). + The low 12 bits are an index into a shared tuple + records array. */ + /* UnsizedArrayOf<F2DOT14> peakTuple - optional */ + /* Peak tuple record for this tuple variation table — optional, + * determined by flags in the tupleIndex value. + * + * Note that this must always be included in the 'cvar' table. */ + /* UnsizedArrayOf<F2DOT14> intermediateStartTuple - optional */ + /* Intermediate start tuple record for this tuple variation table — optional, + determined by flags in the tupleIndex value. */ + /* UnsizedArrayOf<F2DOT14> intermediateEndTuple - optional */ + /* Intermediate end tuple record for this tuple variation table — optional, + * determined by flags in the tupleIndex value. */ + public: + DEFINE_SIZE_MIN (4); +}; + +struct TupleVariationData +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + // here check on min_size only, TupleVariationHeader and var data will be + // checked while accessing through iterator. + return_trace (c->check_struct (this)); + } + + unsigned get_size (unsigned axis_count) const + { + unsigned total_size = min_size; + unsigned count = tupleVarCount; + const TupleVariationHeader& tuple_var_header = get_tuple_var_header(); + for (unsigned i = 0; i < count; i++) + total_size += tuple_var_header.get_size (axis_count) + tuple_var_header.get_data_size (); + + return total_size; + } + + const TupleVariationHeader &get_tuple_var_header (void) const + { return StructAfter<TupleVariationHeader> (data); } + + struct tuple_iterator_t + { + void init (hb_bytes_t var_data_bytes_, unsigned int axis_count_, const void *table_base_) + { + var_data_bytes = var_data_bytes_; + var_data = var_data_bytes_.as<TupleVariationData> (); + index = 0; + axis_count = axis_count_; + current_tuple = &var_data->get_tuple_var_header (); + data_offset = 0; + table_base = table_base_; + } + + bool get_shared_indices (hb_vector_t<unsigned int> &shared_indices /* OUT */) + { + if (var_data->has_shared_point_numbers ()) + { + const HBUINT8 *base = &(table_base+var_data->data); + const HBUINT8 *p = base; + if (!unpack_points (p, shared_indices, (const HBUINT8 *) (var_data_bytes.arrayZ + var_data_bytes.length))) return false; + data_offset = p - base; + } + return true; + } + + bool is_valid () const + { + return (index < var_data->tupleVarCount.get_count ()) && + var_data_bytes.check_range (current_tuple, TupleVariationHeader::min_size) && + var_data_bytes.check_range (current_tuple, hb_max (current_tuple->get_data_size (), + current_tuple->get_size (axis_count))); + } + + bool move_to_next () + { + data_offset += current_tuple->get_data_size (); + current_tuple = ¤t_tuple->get_next (axis_count); + index++; + return is_valid (); + } + + const HBUINT8 *get_serialized_data () const + { return &(table_base+var_data->data) + data_offset; } + + private: + const TupleVariationData *var_data; + unsigned int index; + unsigned int axis_count; + unsigned int data_offset; + const void *table_base; + + public: + hb_bytes_t var_data_bytes; + const TupleVariationHeader *current_tuple; + }; + + static bool get_tuple_iterator (hb_bytes_t var_data_bytes, unsigned axis_count, + const void *table_base, + hb_vector_t<unsigned int> &shared_indices /* OUT */, + tuple_iterator_t *iterator /* OUT */) + { + iterator->init (var_data_bytes, axis_count, table_base); + if (!iterator->get_shared_indices (shared_indices)) + return false; + return iterator->is_valid (); + } + + bool has_shared_point_numbers () const { return tupleVarCount.has_shared_point_numbers (); } + + static bool unpack_points (const HBUINT8 *&p /* IN/OUT */, + hb_vector_t<unsigned int> &points /* OUT */, + const HBUINT8 *end) + { + enum packed_point_flag_t + { + POINTS_ARE_WORDS = 0x80, + POINT_RUN_COUNT_MASK = 0x7F + }; + + if (unlikely (p + 1 > end)) return false; + + unsigned count = *p++; + if (count & POINTS_ARE_WORDS) + { + if (unlikely (p + 1 > end)) return false; + count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++; + } + if (unlikely (!points.resize (count, false))) return false; + + unsigned n = 0; + unsigned i = 0; + while (i < count) + { + if (unlikely (p + 1 > end)) return false; + unsigned control = *p++; + unsigned run_count = (control & POINT_RUN_COUNT_MASK) + 1; + if (unlikely (i + run_count > count)) return false; + unsigned j; + if (control & POINTS_ARE_WORDS) + { + if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; + for (j = 0; j < run_count; j++, i++) + { + n += *(const HBUINT16 *)p; + points.arrayZ[i] = n; + p += HBUINT16::static_size; + } + } + else + { + if (unlikely (p + run_count > end)) return false; + for (j = 0; j < run_count; j++, i++) + { + n += *p++; + points.arrayZ[i] = n; + } + } + } + return true; + } + + static bool unpack_deltas (const HBUINT8 *&p /* IN/OUT */, + hb_vector_t<int> &deltas /* IN/OUT */, + const HBUINT8 *end) + { + enum packed_delta_flag_t + { + DELTAS_ARE_ZERO = 0x80, + DELTAS_ARE_WORDS = 0x40, + DELTA_RUN_COUNT_MASK = 0x3F + }; + + unsigned i = 0; + unsigned count = deltas.length; + while (i < count) + { + if (unlikely (p + 1 > end)) return false; + unsigned control = *p++; + unsigned run_count = (control & DELTA_RUN_COUNT_MASK) + 1; + if (unlikely (i + run_count > count)) return false; + unsigned j; + if (control & DELTAS_ARE_ZERO) + { + for (j = 0; j < run_count; j++, i++) + deltas.arrayZ[i] = 0; + } + else if (control & DELTAS_ARE_WORDS) + { + if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; + for (j = 0; j < run_count; j++, i++) + { + deltas.arrayZ[i] = * (const HBINT16 *) p; + p += HBUINT16::static_size; + } + } + else + { + if (unlikely (p + run_count > end)) return false; + for (j = 0; j < run_count; j++, i++) + { + deltas.arrayZ[i] = * (const HBINT8 *) p++; + } + } + } + return true; + } + + bool has_data () const { return tupleVarCount; } + + protected: + struct TupleVarCount : HBUINT16 + { + bool has_shared_point_numbers () const { return ((*this) & SharedPointNumbers); } + unsigned int get_count () const { return (*this) & CountMask; } + + protected: + enum Flags + { + SharedPointNumbers= 0x8000u, + CountMask = 0x0FFFu + }; + public: + DEFINE_SIZE_STATIC (2); + }; + + TupleVarCount tupleVarCount; /* A packed field. The high 4 bits are flags, and the + * low 12 bits are the number of tuple variation tables + * for this glyph. The number of tuple variation tables + * can be any number between 1 and 4095. */ + Offset16To<HBUINT8> + data; /* Offset from the start of the base table + * to the serialized data. */ + /* TupleVariationHeader tupleVariationHeaders[] *//* Array of tuple variation headers. */ + public: + DEFINE_SIZE_MIN (4); +}; } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-cvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-cvar-table.hh new file mode 100644 index 00000000000..bdb2b6b23bd --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-cvar-table.hh @@ -0,0 +1,158 @@ +/* + * Copyright © 2023 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + */ + +#ifndef HB_OT_VAR_CVAR_TABLE_HH +#define HB_OT_VAR_CVAR_TABLE_HH + +#include "hb-ot-var-common.hh" + + +namespace OT { +/* + * cvar -- control value table (CVT) Variations + * https://docs.microsoft.com/en-us/typography/opentype/spec/cvar + */ +#define HB_OT_TAG_cvar HB_TAG('c','v','a','r') + +struct cvar +{ + static constexpr hb_tag_t tableTag = HB_OT_TAG_cvar; + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + version.sanitize (c) && likely (version.major == 1) && + tupleVariationData.sanitize (c)); + } + + const TupleVariationData* get_tuple_var_data (void) const + { return &tupleVariationData; } + + static bool calculate_cvt_deltas (unsigned axis_count, + hb_array_t<int> coords, + unsigned num_cvt_item, + const TupleVariationData *tuple_var_data, + const void *base, + hb_vector_t<float>& cvt_deltas /* OUT */) + { + if (!coords) return true; + hb_vector_t<unsigned> shared_indices; + TupleVariationData::tuple_iterator_t iterator; + unsigned var_data_length = tuple_var_data->get_size (axis_count); + hb_bytes_t var_data_bytes = hb_bytes_t (reinterpret_cast<const char*> (tuple_var_data), var_data_length); + if (!TupleVariationData::get_tuple_iterator (var_data_bytes, axis_count, base, + shared_indices, &iterator)) + return true; /* isn't applied at all */ + + hb_array_t<const F2DOT14> shared_tuples = hb_array<F2DOT14> (); + hb_vector_t<unsigned> private_indices; + hb_vector_t<int> unpacked_deltas; + + do + { + float scalar = iterator.current_tuple->calculate_scalar (coords, axis_count, shared_tuples); + if (scalar == 0.f) continue; + const HBUINT8 *p = iterator.get_serialized_data (); + unsigned int length = iterator.current_tuple->get_data_size (); + if (unlikely (!iterator.var_data_bytes.check_range (p, length))) + return false; + + const HBUINT8 *end = p + length; + + bool has_private_points = iterator.current_tuple->has_private_points (); + if (has_private_points && + !TupleVariationData::unpack_points (p, private_indices, end)) + return false; + const hb_vector_t<unsigned int> &indices = has_private_points ? private_indices : shared_indices; + + bool apply_to_all = (indices.length == 0); + unsigned num_deltas = apply_to_all ? num_cvt_item : indices.length; + if (unlikely (!unpacked_deltas.resize (num_deltas, false))) return false; + if (unlikely (!TupleVariationData::unpack_deltas (p, unpacked_deltas, end))) return false; + + for (unsigned int i = 0; i < num_deltas; i++) + { + unsigned int idx = apply_to_all ? i : indices[i]; + if (unlikely (idx >= num_cvt_item)) continue; + if (scalar != 1.0f) cvt_deltas[idx] += unpacked_deltas[i] * scalar ; + else cvt_deltas[idx] += unpacked_deltas[i]; + } + } while (iterator.move_to_next ()); + + return true; + } + + static bool add_cvt_and_apply_deltas (hb_subset_plan_t *plan, + const TupleVariationData *tuple_var_data, + const void *base) + { + const hb_tag_t cvt = HB_TAG('c','v','t',' '); + hb_blob_t *cvt_blob = hb_face_reference_table (plan->source, cvt); + hb_blob_t *cvt_prime_blob = hb_blob_copy_writable_or_fail (cvt_blob); + hb_blob_destroy (cvt_blob); + + if (unlikely (!cvt_prime_blob)) + return false; + + unsigned cvt_blob_length = hb_blob_get_length (cvt_prime_blob); + unsigned num_cvt_item = cvt_blob_length / FWORD::static_size; + + hb_vector_t<float> cvt_deltas; + if (unlikely (!cvt_deltas.resize (num_cvt_item))) + { + hb_blob_destroy (cvt_prime_blob); + return false; + } + hb_memset (cvt_deltas.arrayZ, 0, cvt_deltas.get_size ()); + + if (!calculate_cvt_deltas (plan->normalized_coords.length, plan->normalized_coords.as_array (), + num_cvt_item, tuple_var_data, base, cvt_deltas)) + { + hb_blob_destroy (cvt_prime_blob); + return false; + } + + FWORD *cvt_prime = (FWORD *) hb_blob_get_data_writable (cvt_prime_blob, nullptr); + for (unsigned i = 0; i < num_cvt_item; i++) + cvt_prime[i] += (int) roundf (cvt_deltas[i]); + + bool success = plan->add_table (cvt, cvt_prime_blob); + hb_blob_destroy (cvt_prime_blob); + return success; + } + + protected: + FixedVersion<>version; /* Version of the CVT variation table + * initially set to 0x00010000u */ + TupleVariationData tupleVariationData; /* TupleVariationDate for cvar table */ + public: + DEFINE_SIZE_MIN (8); +}; + +} /* namespace OT */ + + +#endif /* HB_OT_VAR_CVAR_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-gvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-gvar-table.hh index 1eae6a35324..d707a463338 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-gvar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-gvar-table.hh @@ -29,6 +29,7 @@ #define HB_OT_VAR_GVAR_TABLE_HH #include "hb-open-type.hh" +#include "hb-ot-var-common.hh" /* * gvar -- Glyph Variation Table @@ -90,311 +91,8 @@ struct contour_point_vector_t : hb_vector_t<contour_point_t> } }; -/* https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#tuplevariationheader */ -struct TupleVariationHeader -{ - unsigned get_size (unsigned axis_count) const - { return min_size + get_all_tuples (axis_count).get_size (); } - - unsigned get_data_size () const { return varDataSize; } - - const TupleVariationHeader &get_next (unsigned axis_count) const - { return StructAtOffset<TupleVariationHeader> (this, get_size (axis_count)); } - - float calculate_scalar (hb_array_t<int> coords, unsigned int coord_count, - const hb_array_t<const F2DOT14> shared_tuples) const - { - hb_array_t<const F2DOT14> peak_tuple; - - if (has_peak ()) - peak_tuple = get_peak_tuple (coord_count); - else - { - unsigned int index = get_index (); - if (unlikely (index * coord_count >= shared_tuples.length)) - return 0.f; - peak_tuple = shared_tuples.sub_array (coord_count * index, coord_count); - } - - hb_array_t<const F2DOT14> start_tuple; - hb_array_t<const F2DOT14> end_tuple; - if (has_intermediate ()) - { - start_tuple = get_start_tuple (coord_count); - end_tuple = get_end_tuple (coord_count); - } - - float scalar = 1.f; - for (unsigned int i = 0; i < coord_count; i++) - { - int v = coords[i]; - int peak = peak_tuple[i].to_int (); - if (!peak || v == peak) continue; - - if (has_intermediate ()) - { - int start = start_tuple[i].to_int (); - int end = end_tuple[i].to_int (); - if (unlikely (start > peak || peak > end || - (start < 0 && end > 0 && peak))) continue; - if (v < start || v > end) return 0.f; - if (v < peak) - { if (peak != start) scalar *= (float) (v - start) / (peak - start); } - else - { if (peak != end) scalar *= (float) (end - v) / (end - peak); } - } - else if (!v || v < hb_min (0, peak) || v > hb_max (0, peak)) return 0.f; - else - scalar *= (float) v / peak; - } - return scalar; - } - - bool has_peak () const { return tupleIndex & TuppleIndex::EmbeddedPeakTuple; } - bool has_intermediate () const { return tupleIndex & TuppleIndex::IntermediateRegion; } - bool has_private_points () const { return tupleIndex & TuppleIndex::PrivatePointNumbers; } - unsigned get_index () const { return tupleIndex & TuppleIndex::TupleIndexMask; } - - protected: - struct TuppleIndex : HBUINT16 - { - enum Flags { - EmbeddedPeakTuple = 0x8000u, - IntermediateRegion = 0x4000u, - PrivatePointNumbers = 0x2000u, - TupleIndexMask = 0x0FFFu - }; - - DEFINE_SIZE_STATIC (2); - }; - - hb_array_t<const F2DOT14> get_all_tuples (unsigned axis_count) const - { return StructAfter<UnsizedArrayOf<F2DOT14>> (tupleIndex).as_array ((has_peak () + has_intermediate () * 2) * axis_count); } - hb_array_t<const F2DOT14> get_peak_tuple (unsigned axis_count) const - { return get_all_tuples (axis_count).sub_array (0, axis_count); } - hb_array_t<const F2DOT14> get_start_tuple (unsigned axis_count) const - { return get_all_tuples (axis_count).sub_array (has_peak () * axis_count, axis_count); } - hb_array_t<const F2DOT14> get_end_tuple (unsigned axis_count) const - { return get_all_tuples (axis_count).sub_array (has_peak () * axis_count + axis_count, axis_count); } - - HBUINT16 varDataSize; /* The size in bytes of the serialized - * data for this tuple variation table. */ - TuppleIndex tupleIndex; /* A packed field. The high 4 bits are flags (see below). - The low 12 bits are an index into a shared tuple - records array. */ - /* UnsizedArrayOf<F2DOT14> peakTuple - optional */ - /* Peak tuple record for this tuple variation table — optional, - * determined by flags in the tupleIndex value. - * - * Note that this must always be included in the 'cvar' table. */ - /* UnsizedArrayOf<F2DOT14> intermediateStartTuple - optional */ - /* Intermediate start tuple record for this tuple variation table — optional, - determined by flags in the tupleIndex value. */ - /* UnsizedArrayOf<F2DOT14> intermediateEndTuple - optional */ - /* Intermediate end tuple record for this tuple variation table — optional, - * determined by flags in the tupleIndex value. */ - public: - DEFINE_SIZE_MIN (4); -}; - -struct GlyphVariationData -{ - const TupleVariationHeader &get_tuple_var_header (void) const - { return StructAfter<TupleVariationHeader> (data); } - - struct tuple_iterator_t - { - void init (hb_bytes_t var_data_bytes_, unsigned int axis_count_) - { - var_data_bytes = var_data_bytes_; - var_data = var_data_bytes_.as<GlyphVariationData> (); - index = 0; - axis_count = axis_count_; - current_tuple = &var_data->get_tuple_var_header (); - data_offset = 0; - } - - bool get_shared_indices (hb_vector_t<unsigned int> &shared_indices /* OUT */) - { - if (var_data->has_shared_point_numbers ()) - { - const HBUINT8 *base = &(var_data+var_data->data); - const HBUINT8 *p = base; - if (!unpack_points (p, shared_indices, (const HBUINT8 *) (var_data_bytes.arrayZ + var_data_bytes.length))) return false; - data_offset = p - base; - } - return true; - } - - bool is_valid () const - { - return (index < var_data->tupleVarCount.get_count ()) && - var_data_bytes.check_range (current_tuple, TupleVariationHeader::min_size) && - var_data_bytes.check_range (current_tuple, hb_max (current_tuple->get_data_size (), - current_tuple->get_size (axis_count))); - } - - bool move_to_next () - { - data_offset += current_tuple->get_data_size (); - current_tuple = ¤t_tuple->get_next (axis_count); - index++; - return is_valid (); - } - - const HBUINT8 *get_serialized_data () const - { return &(var_data+var_data->data) + data_offset; } - - private: - const GlyphVariationData *var_data; - unsigned int index; - unsigned int axis_count; - unsigned int data_offset; - - public: - hb_bytes_t var_data_bytes; - const TupleVariationHeader *current_tuple; - }; - - static bool get_tuple_iterator (hb_bytes_t var_data_bytes, unsigned axis_count, - hb_vector_t<unsigned int> &shared_indices /* OUT */, - tuple_iterator_t *iterator /* OUT */) - { - iterator->init (var_data_bytes, axis_count); - if (!iterator->get_shared_indices (shared_indices)) - return false; - return iterator->is_valid (); - } - - bool has_shared_point_numbers () const { return tupleVarCount.has_shared_point_numbers (); } - - static bool unpack_points (const HBUINT8 *&p /* IN/OUT */, - hb_vector_t<unsigned int> &points /* OUT */, - const HBUINT8 *end) - { - enum packed_point_flag_t - { - POINTS_ARE_WORDS = 0x80, - POINT_RUN_COUNT_MASK = 0x7F - }; - - if (unlikely (p + 1 > end)) return false; - - unsigned count = *p++; - if (count & POINTS_ARE_WORDS) - { - if (unlikely (p + 1 > end)) return false; - count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++; - } - if (unlikely (!points.resize (count, false))) return false; - - unsigned n = 0; - unsigned i = 0; - while (i < count) - { - if (unlikely (p + 1 > end)) return false; - unsigned control = *p++; - unsigned run_count = (control & POINT_RUN_COUNT_MASK) + 1; - if (unlikely (i + run_count > count)) return false; - unsigned j; - if (control & POINTS_ARE_WORDS) - { - if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; - for (j = 0; j < run_count; j++, i++) - { - n += *(const HBUINT16 *)p; - points.arrayZ[i] = n; - p += HBUINT16::static_size; - } - } - else - { - if (unlikely (p + run_count > end)) return false; - for (j = 0; j < run_count; j++, i++) - { - n += *p++; - points.arrayZ[i] = n; - } - } - } - return true; - } - - static bool unpack_deltas (const HBUINT8 *&p /* IN/OUT */, - hb_vector_t<int> &deltas /* IN/OUT */, - const HBUINT8 *end) - { - enum packed_delta_flag_t - { - DELTAS_ARE_ZERO = 0x80, - DELTAS_ARE_WORDS = 0x40, - DELTA_RUN_COUNT_MASK = 0x3F - }; - - unsigned i = 0; - unsigned count = deltas.length; - while (i < count) - { - if (unlikely (p + 1 > end)) return false; - unsigned control = *p++; - unsigned run_count = (control & DELTA_RUN_COUNT_MASK) + 1; - if (unlikely (i + run_count > count)) return false; - unsigned j; - if (control & DELTAS_ARE_ZERO) - { - for (j = 0; j < run_count; j++, i++) - deltas.arrayZ[i] = 0; - } - else if (control & DELTAS_ARE_WORDS) - { - if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; - for (j = 0; j < run_count; j++, i++) - { - deltas.arrayZ[i] = * (const HBINT16 *) p; - p += HBUINT16::static_size; - } - } - else - { - if (unlikely (p + run_count > end)) return false; - for (j = 0; j < run_count; j++, i++) - { - deltas.arrayZ[i] = * (const HBINT8 *) p++; - } - } - } - return true; - } - - bool has_data () const { return tupleVarCount; } - - protected: - struct TupleVarCount : HBUINT16 - { - bool has_shared_point_numbers () const { return ((*this) & SharedPointNumbers); } - unsigned int get_count () const { return (*this) & CountMask; } - - protected: - enum Flags - { - SharedPointNumbers= 0x8000u, - CountMask = 0x0FFFu - }; - public: - DEFINE_SIZE_STATIC (2); - }; - - TupleVarCount tupleVarCount; /* A packed field. The high 4 bits are flags, and the - * low 12 bits are the number of tuple variation tables - * for this glyph. The number of tuple variation tables - * can be any number between 1 and 4095. */ - Offset16To<HBUINT8> - data; /* Offset from the start of the GlyphVariationData table - * to the serialized data. */ - /* TupleVariationHeader tupleVariationHeaders[] *//* Array of tuple variation headers. */ - public: - DEFINE_SIZE_MIN (4); -}; +struct GlyphVariationData : TupleVariationData +{}; struct gvar { @@ -561,6 +259,7 @@ struct gvar hb_vector_t<unsigned int> shared_indices; GlyphVariationData::tuple_iterator_t iterator; if (!GlyphVariationData::get_tuple_iterator (var_data_bytes, table->axisCount, + var_data_bytes.arrayZ, shared_indices, &iterator)) return true; /* so isn't applied at all */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.cc index 184e48cfb7a..0657e0e1d3d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.cc @@ -85,7 +85,7 @@ void hb_outline_t::replay (hb_draw_funcs_t *pen, void *pen_data) const } } -float hb_outline_t::area () const +float hb_outline_t::control_area () const { float a = 0; unsigned first = 0; @@ -118,7 +118,7 @@ void hb_outline_t::embolden (float x_strength, float y_strength, x_strength /= 2.f; y_strength /= 2.f; - bool orientation_negative = area () < 0; + bool orientation_negative = control_area () < 0; signed first = 0; for (unsigned c = 0; c < contours.length; c++) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.hh index c463993cfbb..c43c06596bb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-outline.hh @@ -68,7 +68,7 @@ struct hb_outline_t void reset () { points.shrink (0, false); contours.resize (0); } HB_INTERNAL void replay (hb_draw_funcs_t *pen, void *pen_data) const; - HB_INTERNAL float area () const; + HB_INTERNAL float control_area () const; HB_INTERNAL void embolden (float x_strength, float y_strength, float x_shift, float y_shift); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-sanitize.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-sanitize.hh index eb907c6b2af..5259891b7e0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-sanitize.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-sanitize.hh @@ -228,6 +228,18 @@ struct hb_sanitize_context_t : unsigned get_edit_count () { return edit_count; } + + bool check_ops(unsigned count) + { + /* Avoid underflow */ + if (unlikely (this->max_ops < 0 || count >= (unsigned) this->max_ops)) + { + this->max_ops = -1; + return false; + } + return (this->max_ops -= (int) count) > 0; + } + bool check_range (const void *base, unsigned int len) const { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc index 7b5bf2c5ef7..89d354fc012 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc @@ -196,4 +196,238 @@ hb_shape (hb_font_t *font, } +#ifdef HB_EXPERIMENTAL_API + +static float +buffer_advance (hb_buffer_t *buffer) +{ + float a = 0; + auto *pos = buffer->pos; + unsigned count = buffer->len; + if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + for (unsigned i = 0; i < count; i++) + a += pos[i].x_advance; + else + for (unsigned i = 0; i < count; i++) + a += pos[i].y_advance; + return a; +} + +static void +reset_buffer (hb_buffer_t *buffer, + hb_array_t<const hb_glyph_info_t> text) +{ + assert (buffer->ensure (text.length)); + buffer->have_positions = false; + buffer->len = text.length; + memcpy (buffer->info, text.arrayZ, text.length * sizeof (buffer->info[0])); + hb_buffer_set_content_type (buffer, HB_BUFFER_CONTENT_TYPE_UNICODE); +} + +/** + * hb_shape_justify: + * @font: a mutable #hb_font_t to use for shaping + * @buffer: an #hb_buffer_t to shape + * @features: (array length=num_features) (nullable): an array of user + * specified #hb_feature_t or `NULL` + * @num_features: the length of @features array + * @shaper_list: (array zero-terminated=1) (nullable): a `NULL`-terminated + * array of shapers to use or `NULL` + * @min_target_advance: Minimum advance width/height to aim for. + * @max_target_advance: Maximum advance width/height to aim for. + * @advance: (inout): Input/output advance width/height of the buffer. + * @var_tag: (out): Variation-axis tag used for justification. + * @var_value: (out): Variation-axis value used to reach target justification. + * + * See hb_shape_full() for basic details. If @shaper_list is not `NULL`, the specified + * shapers will be used in the given order, otherwise the default shapers list + * will be used. + * + * In addition, justify the shaping results such that the shaping results reach + * the target advance width/height, depending on the buffer direction. + * + * If the advance of the buffer shaped with hb_shape_full() is already known, + * put that in *advance. Otherwise set *advance to zero. + * + * This API is currently experimental and will probably change in the future. + * + * Return value: false if all shapers failed, true otherwise + * + * XSince: EXPERIMENTAL + **/ +hb_bool_t +hb_shape_justify (hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features, + const char * const *shaper_list, + float min_target_advance, + float max_target_advance, + float *advance, /* IN/OUT */ + hb_tag_t *var_tag, /* OUT */ + float *var_value /* OUT */) +{ + // TODO Negative font scales? + + /* If default advance already matches target, nothing to do. Shape and return. */ + if (min_target_advance <= *advance && *advance <= max_target_advance) + return hb_shape_full (font, buffer, + features, num_features, + shaper_list); + + hb_face_t *face = font->face; + + /* Choose variation tag to use for justification. */ + + hb_tag_t tag = HB_TAG_NONE; + hb_ot_var_axis_info_t axis_info; + + hb_tag_t tags[] = + { + HB_TAG ('j','s','t','f'), + HB_TAG ('w','d','t','h'), + }; + for (unsigned i = 0; i < ARRAY_LENGTH (tags); i++) + if (hb_ot_var_find_axis_info (face, tags[i], &axis_info)) + { + tag = *var_tag = tags[i]; + break; + } + + /* If no suitable variation axis found, can't justify. Just shape and return. */ + if (!tag) + { + if (hb_shape_full (font, buffer, + features, num_features, + shaper_list)) + { + *advance = buffer_advance (buffer); + return true; + } + else + return false; + } + + /* Copy buffer text as we need it so we can shape multiple times. */ + unsigned text_len = buffer->len; + auto *text_info = (hb_glyph_info_t *) hb_malloc (text_len * sizeof (buffer->info[0])); + if (unlikely (text_len && !text_info)) + return false; + hb_memcpy (text_info, buffer->info, text_len * sizeof (buffer->info[0])); + auto text = hb_array<const hb_glyph_info_t> (text_info, text_len); + + /* If default advance was not provided to us, calculate it. */ + if (!*advance) + { + hb_font_set_variation (font, tag, axis_info.default_value); + if (!hb_shape_full (font, buffer, + features, num_features, + shaper_list)) + return false; + *advance = buffer_advance (buffer); + } + + /* If default advance already matches target, nothing to do. Shape and return. + * Do this again, in case advance was just calculated. + */ + if (min_target_advance <= *advance && *advance <= max_target_advance) + return true; + + /* Prepare for running the solver. */ + double a, b, ya, yb; + if (*advance < min_target_advance) + { + /* Need to expand. */ + ya = (double) *advance; + a = (double) axis_info.default_value; + b = (double) axis_info.max_value; + + /* Shape buffer for maximum expansion to use as other + * starting point for the solver. */ + hb_font_set_variation (font, tag, (float) b); + reset_buffer (buffer, text); + if (!hb_shape_full (font, buffer, + features, num_features, + shaper_list)) + return false; + yb = (double) buffer_advance (buffer); + /* If the maximum expansion is less than max target, + * there's nothing to solve for. Just return it. */ + if (yb <= (double) max_target_advance) + { + *advance = (float) yb; + return true; + } + } + else + { + /* Need to shrink. */ + yb = (double) *advance; + a = (double) axis_info.min_value; + b = (double) axis_info.default_value; + + /* Shape buffer for maximum shrinkate to use as other + * starting point for the solver. */ + hb_font_set_variation (font, tag, (float) a); + reset_buffer (buffer, text); + if (!hb_shape_full (font, buffer, + features, num_features, + shaper_list)) + return false; + ya = (double) buffer_advance (buffer); + /* If the maximum shrinkate is more than min target, + * there's nothing to solve for. Just return it. */ + if (ya >= (double) min_target_advance) + { + *advance = (float) ya; + return true; + } + } + + /* Run the solver to find a var axis value that hits + * the desired width. */ + + double epsilon = (b - a) / (1<<14); + bool failed = false; + + auto f = [&] (double x) + { + hb_font_set_variation (font, tag, (float) x); + reset_buffer (buffer, text); + if (unlikely (!hb_shape_full (font, buffer, + features, num_features, + shaper_list))) + { + failed = true; + return (double) min_target_advance; + } + + double w = (double) buffer_advance (buffer); + DEBUG_MSG (JUSTIFY, nullptr, "Trying '%c%c%c%c' axis parameter %f. Advance %g. Target: min %g max %g", + HB_UNTAG (tag), x, w, + (double) min_target_advance, (double) max_target_advance); + return w; + }; + + double y = 0; + double itp = solve_itp (f, + a, b, + epsilon, + (double) min_target_advance, (double) max_target_advance, + ya, yb, y); + + hb_free (text_info); + + if (failed) + return false; + + *var_value = (float) itp; + *advance = (float) y; + + return true; +} + +#endif + + #endif diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.h index 922f8c011ec..d4d4fdfd267 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.h @@ -53,6 +53,18 @@ hb_shape_full (hb_font_t *font, unsigned int num_features, const char * const *shaper_list); +HB_EXTERN hb_bool_t +hb_shape_justify (hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features, + const char * const *shaper_list, + float min_target_advance, + float max_target_advance, + float *advance, /* IN/OUT */ + hb_tag_t *var_tag, /* OUT */ + float *var_value /* OUT */); + HB_EXTERN const char ** hb_shape_list_shapers (void); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh index 0d63933a766..4158b7094c9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh @@ -39,7 +39,7 @@ HB_SHAPER_IMPLEMENT (graphite2) #endif #ifndef HB_NO_OT_SHAPE -HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */ +HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main shaper. */ #endif #ifdef HAVE_UNISCRIBE diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc index ca59de79a2b..5f001ac2511 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc @@ -71,7 +71,6 @@ hb_subset_input_t::hb_subset_input_t () hb_tag_t default_no_subset_tables[] = { HB_TAG ('a', 'v', 'a', 'r'), HB_TAG ('g', 'a', 's', 'p'), - HB_TAG ('c', 'v', 't', ' '), HB_TAG ('f', 'p', 'g', 'm'), HB_TAG ('p', 'r', 'e', 'p'), HB_TAG ('V', 'D', 'M', 'X'), diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc index 82df3386f5d..e0b1ed64425 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc @@ -50,6 +50,7 @@ #include "hb-ot-name-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-table.hh" +#include "hb-ot-var-cvar-table.hh" #include "hb-ot-var-fvar-table.hh" #include "hb-ot-var-gvar-table.hh" #include "hb-ot-var-hvar-table.hh" @@ -478,6 +479,16 @@ _subset_table (hb_subset_plan_t *plan, if (plan->all_axes_pinned) return _subset<const OT::STAT> (plan, buf); else return _passthrough (plan, tag); + case HB_TAG ('c', 'v', 't', ' '): +#ifndef HB_NO_VAR + if (_is_table_present (plan->source, HB_OT_TAG_cvar) && + plan->normalized_coords && !plan->pinned_at_default) + { + auto &cvar = *plan->source->table.cvar; + return OT::cvar::add_cvt_and_apply_deltas (plan, cvar.get_tuple_var_data (), &cvar); + } +#endif + return _passthrough (plan, tag); default: if (plan->flags & HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED) return _passthrough (plan, tag); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh index 857571b42fd..d09849e5653 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh @@ -246,7 +246,15 @@ extern "C" void hb_free_impl(void *ptr); * Compiler attributes */ -#if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__) +// gcc 10 has __has_builtin but not earlier versions. Sanction any gcc >= 5 +// clang defines it so no need. +#ifdef __has_builtin +#define hb_has_builtin __has_builtin +#else +#define hb_has_builtin(x) ((defined(__GNUC__) && __GNUC__ >= 5)) +#endif + +#if defined(__OPTIMIZE__) && hb_has_builtin(__builtin_expect) #define likely(expr) (__builtin_expect (!!(expr), 1)) #define unlikely(expr) (__builtin_expect (!!(expr), 0)) #else diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/meson.build b/Build/source/libs/harfbuzz/harfbuzz-src/src/meson.build index 435201c28c4..93991abd9f7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/meson.build +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/meson.build @@ -226,6 +226,7 @@ hb_base_sources = files( 'hb-ot-tag.cc', 'hb-ot-var-avar-table.hh', 'hb-ot-var-common.hh', + 'hb-ot-var-cvar-table.hh', 'hb-ot-var-fvar-table.hh', 'hb-ot-var-gvar-table.hh', 'hb-ot-var-hvar-table.hh', diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-map.cc index a0a59cbcd1b..61cc8bfb32f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-map.cc @@ -344,8 +344,8 @@ main (int argc, char **argv) hb_set_t keys; hb_set_t values; - m.keys (keys); - m.values (values); + hb_copy (m.keys (), keys); + hb_copy (m.values (), values); assert (keys.is_equal (hb_set_t ({1, 2, 3, 4, 5, 6}))); assert (values.is_equal (hb_set_t ({1, 1, 2, 3, 5, 8}))); |