diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-11-06 07:32:02 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-11-06 07:32:02 +0000 |
commit | ce56884c340c40aaf5c90d736a404208ef486943 (patch) | |
tree | 7d9e536587ab896c22fd310607fefde2be7a06c3 /Build | |
parent | f0b25fb4bbeafb31d6b33db6763974da38e21cfc (diff) |
harfbuzz-2.1.1
git-svn-id: svn://tug.org/texlive/trunk@49090 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
79 files changed, 2493 insertions, 1006 deletions
diff --git a/Build/source/libs/README b/Build/source/libs/README index 3500c21ea8c..214da70e46a 100644 --- a/Build/source/libs/README +++ b/Build/source/libs/README @@ -25,7 +25,7 @@ graphite2 1.3.12 - checked 16aug18 http://sourceforge.net/projects/silgraphite/files/graphite2/ (requires C++11) -harfbuzz 2.1.0 - checked 31oct18 +harfbuzz 2.1.1 - checked 06nov18 http://www.freedesktop.org/software/harfbuzz/release/ icu 61.1 - checked 29mar18 diff --git a/Build/source/libs/harfbuzz/ChangeLog b/Build/source/libs/harfbuzz/ChangeLog index 6d4e367b661..8da10e3c3fe 100644 --- a/Build/source/libs/harfbuzz/ChangeLog +++ b/Build/source/libs/harfbuzz/ChangeLog @@ -1,3 +1,8 @@ +2018-11-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + Import harfbuzz-2.1.1. + * version.ac: Adjusted. + 2018-10-31 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Import harfbuzz-2.1.0. diff --git a/Build/source/libs/harfbuzz/TLpatches/ChangeLog b/Build/source/libs/harfbuzz/TLpatches/ChangeLog index 690a0f1dcc4..d482b59c979 100644 --- a/Build/source/libs/harfbuzz/TLpatches/ChangeLog +++ b/Build/source/libs/harfbuzz/TLpatches/ChangeLog @@ -1,3 +1,8 @@ +2018-11-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + Imported harfbuzz-2.1.1 source tree from: + http://www.freedesktop.org/software/harfbuzz/release/ + 2018-10-31 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Imported harfbuzz-2.1.0 source tree from: diff --git a/Build/source/libs/harfbuzz/TLpatches/TL-Changes b/Build/source/libs/harfbuzz/TLpatches/TL-Changes index 4099ec91549..26490f845bb 100644 --- a/Build/source/libs/harfbuzz/TLpatches/TL-Changes +++ b/Build/source/libs/harfbuzz/TLpatches/TL-Changes @@ -1,4 +1,4 @@ -Changes applied to the harfbuzz-2.1.0/ tree as obtained from: +Changes applied to the harfbuzz-2.1.1/ tree as obtained from: http://www.freedesktop.org/software/harfbuzz/release/ Removed: diff --git a/Build/source/libs/harfbuzz/configure b/Build/source/libs/harfbuzz/configure index 5e415177448..410beca8f48 100755 --- a/Build/source/libs/harfbuzz/configure +++ b/Build/source/libs/harfbuzz/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for harfbuzz (TeX Live) 2.1.0. +# Generated by GNU Autoconf 2.69 for harfbuzz (TeX Live) 2.1.1. # # Report bugs to <tex-k@tug.org>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='harfbuzz (TeX Live)' PACKAGE_TARNAME='harfbuzz--tex-live-' -PACKAGE_VERSION='2.1.0' -PACKAGE_STRING='harfbuzz (TeX Live) 2.1.0' +PACKAGE_VERSION='2.1.1' +PACKAGE_STRING='harfbuzz (TeX Live) 2.1.1' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1317,7 +1317,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures harfbuzz (TeX Live) 2.1.0 to adapt to many kinds of systems. +\`configure' configures harfbuzz (TeX Live) 2.1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1388,7 +1388,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of harfbuzz (TeX Live) 2.1.0:";; + short | recursive ) echo "Configuration of harfbuzz (TeX Live) 2.1.1:";; esac cat <<\_ACEOF @@ -1495,7 +1495,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -harfbuzz (TeX Live) configure 2.1.0 +harfbuzz (TeX Live) configure 2.1.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2131,7 +2131,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by harfbuzz (TeX Live) $as_me 2.1.0, which was +It was created by harfbuzz (TeX Live) $as_me 2.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4054,7 +4054,7 @@ fi # Define the identity of the package. PACKAGE='harfbuzz--tex-live-' - VERSION='2.1.0' + VERSION='2.1.1' # Some tools Automake needs. @@ -4248,8 +4248,8 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags HB_VERSION_MAJOR=2 HB_VERSION_MINOR=1 -HB_VERSION_MICRO=0 -HB_VERSION=2.1.0 +HB_VERSION_MICRO=1 +HB_VERSION=2.1.1 ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -8143,7 +8143,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by harfbuzz (TeX Live) $as_me 2.1.0, which was +This file was extended by harfbuzz (TeX Live) $as_me 2.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8209,7 +8209,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -harfbuzz (TeX Live) config.status 2.1.0 +harfbuzz (TeX Live) config.status 2.1.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog index baae3f107ed..9a263a3a514 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog +++ b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog @@ -1,3 +1,955 @@ +commit 6482fda519ca7d173e3bcb3717aa30e237f04b25 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 15:03:18 2018 -0500 + + [fuzzing] Fuzz glyph-id etc in test-ot-face + + test/api/test-ot-face.c | 57 + +++++++++++++++++++++-------------------- + test/fuzzing/hb-shape-fuzzer.cc | 19 +------------- + 2 files changed, 30 insertions(+), 46 deletions(-) + +commit 252632c477b963f305116d69fcafacd8bf7b97bf +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 14:33:41 2018 -0500 + + [uniscribe] Fix use of deprecated API + + src/hb-uniscribe.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit bb380ec18394b2c581b672ecbf98991e14897f2e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 13:45:12 2018 -0500 + + [cmap] Make null accelerator safe + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1146 + + src/hb-ot-cmap-table.hh | 50 + ++++++++++++++++++++++++------------------------- + 1 file changed, 25 insertions(+), 25 deletions(-) + +commit f6fc5574d3dae177a54b10195e0d1f368a74f768 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 13:23:54 2018 -0500 + + Add pointer magic operators to hb_atomic_ptr_t + + src/hb-atomic.hh | 3 +++ + src/hb-common.cc | 6 +++--- + src/hb-face.cc | 2 +- + src/hb-graphite2.cc | 8 ++++---- + src/hb-machinery.hh | 1 + + src/hb-ot-shape-complex-arabic.cc | 4 ++-- + src/hb-shape-plan.cc | 2 +- + 7 files changed, 15 insertions(+), 11 deletions(-) + +commit f6e7cb51b13aabb447dc97a59602d65eb42edc4b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 13:23:07 2018 -0500 + + Fix const-confusion in hb_array_t as well + + src/hb-dsalgs.hh | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit 0da22fb0ada8a54fc59739057f281a406a993212 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 13:13:39 2018 -0500 + + [null] Tweak hb_nonnull_ptr_t some more + + src/hb-null.hh | 18 ++++++------------ + 1 file changed, 6 insertions(+), 12 deletions(-) + +commit 03348ce0051cfae7172ac0d09b83ed5f82fa842a +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Nov 5 12:59:32 2018 -0500 + + Minor + + src/hb-aat-layout.cc | 12 ++++++------ + src/hb-ot-color.cc | 10 +++++----- + src/hb-ot-font.cc | 18 +++++++++--------- + src/hb-ot-layout.cc | 2 +- + src/hb-ot-math.cc | 2 +- + src/hb-ot-name.cc | 2 +- + src/hb-ot-var.cc | 6 ++---- + 7 files changed, 25 insertions(+), 27 deletions(-) + +commit b605db2f65e62ad6727a61481f78015933dbf207 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sun Nov 4 12:58:02 2018 -0500 + + [aat] Clean up ankr table include mess + + src/hb-aat-layout-ankr-table.hh | 2 ++ + src/hb-aat-layout-common.hh | 31 +++++++++--------------------- + src/hb-aat-layout-kerx-table.hh | 16 ++++++++-------- + src/hb-aat-layout.cc | 42 + +++++++++++++++++++++++++++++++++++++++-- + src/hb-ot-kern-table.hh | 1 - + src/hb-static.cc | 1 - + 6 files changed, 59 insertions(+), 34 deletions(-) + +commit bce437cf0b71e9b60bbf058eaf61593fed30ae33 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sun Nov 4 02:47:34 2018 -0500 + + [test] Call test-ot-face.c test from hb-shape-fuzzer + + Should increase coverage... + + test/api/test-ot-face.c | 28 ++++++++++++++++++---------- + test/fuzzing/hb-shape-fuzzer.cc | 6 ++++++ + 2 files changed, 24 insertions(+), 10 deletions(-) + +commit 777c22425cae97009ca4dc5b1e400670c4aa0799 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sun Nov 4 02:40:20 2018 -0500 + + [test] More funcs in test-ot-face + + test/api/test-font.c | 5 +++++ + test/api/test-ot-face.c | 21 +++++++++++++++++++-- + 2 files changed, 24 insertions(+), 2 deletions(-) + +commit 17335a8161e674e630287e18a6d304ec0c33767c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sun Nov 4 02:25:07 2018 -0500 + + Clean up buffer->swap_buffers() calls + + That function checks for buffer->successful already. No need + to check at call site. + + src/gen-vowel-constraints.py | 4 +--- + src/hb-aat-layout-common.hh | 3 +-- + src/hb-aat-layout-morx-table.hh | 3 +-- + src/hb-ot-shape-complex-indic.cc | 1 - + src/hb-ot-shape-complex-khmer.cc | 1 - + src/hb-ot-shape-complex-myanmar.cc | 1 - + src/hb-ot-shape-complex-thai.cc | 3 +-- + src/hb-ot-shape-complex-use.cc | 1 - + src/hb-ot-shape-complex-vowel-constraints.cc | 5 ++--- + src/hb-ot-shape.cc | 1 - + 10 files changed, 6 insertions(+), 17 deletions(-) + +commit 4eb52460c8c6dc48af240f2254f76fae065bfa97 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 21:45:39 2018 -0400 + + Fix >> + + src/hb-ot-post-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ae9ad1076e536aee370f9863cde8351b79f01b3b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 21:41:50 2018 -0400 + + Fix "Warning: extra ";" ignored." + + src/hb.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit d0163afb7bed83935c6a54d57a0e7366caeba0b3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 21:38:24 2018 -0400 + + Revert "Add operator char * to the naked array types as well" + + This reverts commit db889c182ee5f54127285bfaab5bc94dafe46bda. + + Was resulting in ambigious overloads... + + src/hb-dsalgs.hh | 4 +--- + src/hb-open-type.hh | 2 -- + 2 files changed, 1 insertion(+), 5 deletions(-) + +commit c8f94a1ca6928f07749285da910b63087d485537 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 21:07:39 2018 -0400 + + Minor + + src/hb-ot-name.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9779e602ed7ac214c0da2c90e104b38460422476 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 20:50:56 2018 -0400 + + [test] Add test for empty face + + test/api/Makefile.am | 1 + + test/api/test-ot-face.c | 94 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 95 insertions(+) + +commit 0b0b38ec1e6a815a30bef98193043d255b52c4a1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 16:15:30 2018 -0400 + + Fix null accelerator's + + Fixes all except for cmap. To be done separately. + + Part of https://github.com/harfbuzz/harfbuzz/issues/1146 + + src/hb-ot-color-cbdt-table.hh | 10 ++-------- + src/hb-ot-color-sbix-table.hh | 11 ++++------- + src/hb-ot-color-svg-table.hh | 11 ++++------- + src/hb-ot-glyf-table.hh | 6 +++--- + src/hb-ot-layout-gdef-table.hh | 2 +- + src/hb-ot-layout-gsubgpos.hh | 2 +- + src/hb-ot-name-table.hh | 2 +- + src/hb-ot-post-table.hh | 2 +- + 8 files changed, 17 insertions(+), 29 deletions(-) + +commit db889c182ee5f54127285bfaab5bc94dafe46bda +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 16:04:19 2018 -0400 + + Add operator char * to the naked array types as well + + src/hb-dsalgs.hh | 4 +++- + src/hb-open-type.hh | 2 ++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit d6fdae310f2a98ca624c3a77c3aa03b8b3bd393a +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 16:02:03 2018 -0400 + + Add operator char * to hb_nonnull_ptr_t + + src/hb-null.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 7430ff604aa54bedcb07cc1c2962eae85fcade76 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:59:13 2018 -0400 + + Template casts in hb_nonnull_ptr_t + + src/hb-null.hh | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit da408fce98153e0fab3d82fe28813085feed0974 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:49:37 2018 -0400 + + [blob] Allow null parent in create_sub_blob() + + Like font and unicode. + + src/hb-blob.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fb0f30f55a5d654b2f1f9b99efa9b8abc51dbf34 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:24:14 2018 -0400 + + Add hb_nonnull_ptr_t + + Towards fixing https://github.com/harfbuzz/harfbuzz/issues/1146 + + src/hb-null.hh | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +commit 8d98c51d133b058a845ed7a84bfe8a43083bbb03 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:14:57 2018 -0400 + + [kern] Third try fix access violation in Format3 + + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11245 + + src/hb-ot-kern-table.hh | 1 - + 1 file changed, 1 deletion(-) + +commit f074da8c2b6a7061c71d12213a6c494c119eb20e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:06:45 2018 -0400 + + [kern] Really fix access violation in Format3 + + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11245 + + src/hb-ot-kern-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 93ef20a83b31e6528bb1835d2b4b83b913805885 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 15:03:06 2018 -0400 + + Replace most uses of is_inert with is_immutable + + src/hb-buffer.cc | 32 ++++++++++++++++---------------- + src/hb-coretext.cc | 2 +- + src/hb-font.cc | 2 +- + src/hb-set.hh | 8 +++++--- + src/hb-shape-plan.cc | 2 +- + 5 files changed, 24 insertions(+), 22 deletions(-) + +commit 0589787ff55bff9bd5849c4443229e926cc574a5 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 14:58:54 2018 -0400 + + [kern] Fix access violation in Format3 + + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11245 + + src/hb-ot-kern-table.hh | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 5570c87f21f061cc197e02bd0526ab44c63ed6f1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 14:51:38 2018 -0400 + + Port objects to use header.writable instead of immutable + + Saves 4 or 8 bytes per object on 64bit archs. + + src/hb-blob.cc | 12 ++++-------- + src/hb-blob.hh | 2 -- + src/hb-face.cc | 16 ++++++---------- + src/hb-face.hh | 2 -- + src/hb-font.cc | 46 +++++++++++++++++++--------------------------- + src/hb-font.hh | 4 ---- + src/hb-ft.cc | 2 +- + src/hb-object.hh | 11 ++++++++--- + src/hb-unicode.cc | 11 ++++------- + src/hb-unicode.hh | 2 -- + 10 files changed, 42 insertions(+), 66 deletions(-) + +commit ee351a38ec0c62b76dd1b3f20fe56cb4d63e62be +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sat Nov 3 14:28:55 2018 -0400 + + [object] Add "writable" + + src/hb-object.hh | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit b8a78ce201608e9ac6d7f77447b2bbef6f09e9ff +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Sat Nov 3 22:28:30 2018 +0330 + + [BASE] Improvements (#1347) + + src/hb-ot-layout-base-table.hh | 610 + ++++++++++++++++++----------------------- + src/hb-ot-layout.cc | 65 ++++- + src/hb-ot-layout.h | 16 -- + test/api/Makefile.am | 1 + + test/api/fonts/base.ttf | Bin 0 -> 5596 bytes + test/api/test-baseline.c | 58 ++++ + 6 files changed, 380 insertions(+), 370 deletions(-) + +commit c560ca92512c0283e826c059431273ffecf5d993 +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Sat Nov 3 13:03:36 2018 +0330 + + [fuzz] A new testcase + + ...uzz-testcase-minimized-hb-shape-fuzzer-5735679418433536 | Bin 0 -> + 36 bytes + 1 file changed, 0 insertions(+), 0 deletions(-) + +commit 2c68f34bddbe506d0b22948562f2f59b9a5b6050 +Author: Khaled Hosny <khaledhosny@eglug.org> +Date: Fri Nov 2 23:06:00 2018 +0200 + + [os2] Capitalize table tag and struct + + Other tables follow the case of the OT tag, except this one. + + src/hb-ot-hmtx-table.hh | 6 +++--- + src/hb-ot-os2-table.hh | 12 ++++++------ + src/hb-subset.cc | 4 ++-- + 3 files changed, 11 insertions(+), 11 deletions(-) + +commit 8034d1dda091998d356e77f249d3c9f50501cc77 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 14:47:42 2018 -0400 + + [kern] Implement Format1 + + Also, implement backwards kerning for Format1 in kern and kerx. + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1350 + + src/hb-aat-layout-kerx-table.hh | 11 +++- + src/hb-ot-kern-table.hh | 127 + ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 136 insertions(+), 2 deletions(-) + +commit 46b3885c1a8ea3b85efbdd1704edcee385797c5d +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 14:43:38 2018 -0400 + + [kern] Set subtable on sanitizer + + src/hb-ot-kern-table.hh | 2 ++ + 1 file changed, 2 insertions(+) + +commit 74c7a2c6c892446dcec574986e128967bd570e47 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 14:26:04 2018 -0400 + + [kern] Respect more flags + + src/hb-ot-kern-table.hh | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +commit 9f880bad0d7291eaab10d814567c7a680e139c48 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 13:57:41 2018 -0400 + + [kern] Minor + + We like check_struct() more. + + src/hb-ot-kern-table.hh | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 04b82b181d06c229a98314c1620d3ae8a2825267 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 13:47:33 2018 -0400 + + Remove pointer cast operators from ArrayOf<> + + ArrayOf<>, unlike UnsizedArrayOf<>, has data before the array. + This was confusing. Remove. + + src/hb-open-type.hh | 3 --- + 1 file changed, 3 deletions(-) + +commit f1df441bedaf5b2c7fadf9954ea39616af87702a +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 13:26:15 2018 -0400 + + [kern] Comment + + src/hb-ot-kern-table.hh | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 095f5add0b1ca39dd09842594b80fae92f0796e4 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 13:23:54 2018 -0400 + + [kern] Push apply loop to each subtable + + src/hb-ot-kern-table.hh | 153 + ++++++++++++++++++++++++++++++++++++++---------- + src/hb-ot-layout.cc | 28 ++++++--- + src/hb-ot-layout.hh | 8 ++- + src/hb-ot-shape.cc | 2 +- + 4 files changed, 149 insertions(+), 42 deletions(-) + +commit 949dad89a81ff5b6ef92e8737962b667249a3f2b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 12:47:55 2018 -0400 + + [kern] Remove accelerator + + It wasn't doing anything. + + src/hb-ot-face.hh | 2 +- + src/hb-ot-kern-table.hh | 55 + ++++++++++++++----------------------------------- + src/hb-ot-layout.cc | 4 ++-- + 3 files changed, 18 insertions(+), 43 deletions(-) + +commit 0382b7184addf5b3723db40a57790e5e62ac1703 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 12:23:26 2018 -0400 + + Use as_array in more places + + src/hb-aat-layout-morx-table.hh | 4 ++-- + src/hb-ot-layout-gsubgpos.hh | 22 +++++++++++++--------- + 2 files changed, 15 insertions(+), 11 deletions(-) + +commit 91de9dfcf3bba7cbeef1e709679c8e24ab684c97 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 12:14:21 2018 -0400 + + Fix &array_of<> + + src/hb-dsalgs.hh | 3 +++ + src/hb-open-type.hh | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit 9b7cb137946013592c9a5a9f0a3464fb4613577b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 12:00:55 2018 -0400 + + Fixup + + src/hb-dsalgs.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6e06fe162ed79bb47f62aae03669cd72b99014a0 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 11:56:55 2018 -0400 + + [kern] Implement Format3 + + Untested. + + src/hb-ot-kern-table.hh | 51 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) + +commit c6ef5dbd5c40cc8934756456221e080012a82530 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 11:51:21 2018 -0400 + + Add cast operators to hb_array_t + + src/hb-dsalgs.hh | 21 +++++++++++++-------- + 1 file changed, 13 insertions(+), 8 deletions(-) + +commit 72462eb76584a2892f1d961c90fd289240ea9380 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 11:46:24 2018 -0400 + + Add UnsizedArrayOf::as_array() instead of hb_array() template + + src/hb-aat-layout-trak-table.hh | 2 +- + src/hb-dsalgs.hh | 2 -- + src/hb-open-file.hh | 2 +- + src/hb-open-type.hh | 11 +++-------- + src/hb-ot-color-cpal-table.hh | 6 +++--- + 5 files changed, 8 insertions(+), 15 deletions(-) + +commit 1cf075ecb674cc0c7043bffe2fef5ef187c15335 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 11:38:00 2018 -0400 + + Add get_size to UnsizedArrayOf + + src/hb-open-type.hh | 3 +++ + 1 file changed, 3 insertions(+) + +commit a4a7a623893fd4c8db3a987d81a1c80243006f1e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Nov 2 11:16:43 2018 -0400 + + [kern] Add buffer message + + src/hb-ot-kern-table.hh | 5 +++++ + 1 file changed, 5 insertions(+) + +commit de96e5c81c7f473520df93052ecea162baa5a350 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Nov 1 18:13:58 2018 -0400 + + [Crap] Avoid operator= + + src/hb-null.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f9353bd68c112dea8962dd586bf5e664f75a2a07 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Nov 1 18:05:22 2018 -0400 + + [aat] Rely on vector auto initialization + + src/hb-aat-map.hh | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +commit 5a18d97b35d05c826c242e6847764c2418831a55 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Nov 1 18:01:26 2018 -0400 + + [aat] Remove unused forward declaration + + src/hb-aat-map.hh | 2 -- + 1 file changed, 2 deletions(-) + +commit 07ec792212063851ee41eae33792d3d90d31e6a1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Nov 1 10:31:12 2018 -0400 + + Warning fix + + src/test-ot-color.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c32280b30fb3844addda31a0d97ae7cb55ef07d2 +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Thu Nov 1 15:31:14 2018 +0330 + + [ot-layout] minor + + src/hb-ot-layout.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit cad90be4ea56a85ddc084f86f36dd7129850f6d7 +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Thu Nov 1 13:39:06 2018 +0330 + + [test] minor + + test/api/test-ot-color.c | 2 -- + 1 file changed, 2 deletions(-) + +commit 52a00cd87f63c8ab32413a1a9ce792a3e2ec84e2 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 19:05:53 2018 -0700 + + [aat] Implement 'aalt' mapping + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1160 + + src/hb-aat-map.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 6e3ea269fa1fe0a3de7a8a13c6e853c91231808e +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 19:00:11 2018 -0700 + + [aat] Add 'afrc' feature mapping + + https://github.com/harfbuzz/harfbuzz/issues/1342#issuecomment-434829028 + + src/hb-aat-layout.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 40b19fd46951e2f9b402e59e1fbbf06fde7ecd61 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 18:51:45 2018 -0700 + + [aat] Fallback to old style "Letter Case" small caps + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1342 + + src/hb-aat-layout-morx-table.hh | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit f9289319481a1e9762ad366b287e781c44ba9fc6 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 18:25:05 2018 -0700 + + [test] Minor + + test/shaping/run-tests.py | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit cf203af8a33591c163b63dbdf0fd341bc4606190 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 18:21:48 2018 -0700 + + Implement space fallback in vertical direction + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1343 + + src/hb-ot-shape-fallback.cc | 36 + +++++++++++++++++++-------- + test/shaping/data/in-house/tests/spaces.tests | 17 +++++++++++++ + 2 files changed, 42 insertions(+), 11 deletions(-) + +commit e01250230b1ad85e49cc0021365d1ee43feb9855 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 18:14:00 2018 -0700 + + [hmtx/vmtx] Fix a crasher + + src/hb-ot-hmtx-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 36e90ef56e6c0643ef61e947d7361c6fa4eadf10 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 15:09:09 2018 -0700 + + [mort] Massage some more + + src/hb-aat-layout-common.hh | 28 ++++++++++++++++++++++++++++ + src/hb-aat-layout-morx-table.hh | 21 +++++---------------- + 2 files changed, 33 insertions(+), 16 deletions(-) + +commit cbaff4ef1910e2872bfff61f3d5427c076b3673d +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 15:06:12 2018 -0700 + + [mort] Some more + + src/hb-aat-layout-morx-table.hh | 34 ++++++++++++++++------------------ + 1 file changed, 16 insertions(+), 18 deletions(-) + +commit 3087046d3144afb50bcc13e4afa2d20d9f71f2c8 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 14:59:14 2018 -0700 + + [mort] Refactor offset-to-index mapping + + src/hb-aat-layout-morx-table.hh | 27 ++++++++++++++++----------- + 1 file changed, 16 insertions(+), 11 deletions(-) + +commit b9db610add702da0a257db2eb21f3a7fb56682f7 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 14:22:31 2018 -0700 + + Minor + + src/hb-font.cc | 28 ++++++++++++++-------------- + src/hb-font.h | 2 +- + 2 files changed, 15 insertions(+), 15 deletions(-) + +commit 995bf6c6f82d6b2dabcb81e1426910ee82b91b44 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 13:21:33 2018 -0700 + + [sbix] Rely on blob->as<> checking size against Type::min_size + + src/hb-ot-color-sbix-table.hh | 6 ------ + 1 file changed, 6 deletions(-) + +commit 4d4e526b5cc703111eb445b7e319a4cd1917489f +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 13:19:42 2018 -0700 + + Improve blob->as<> + + It's true that blob->as<> should only be called on null or sanitized + data. But this change is safe, so keep it. + + src/hb-blob.hh | 2 +- + src/hb-ot-glyf-table.hh | 3 ++- + 2 files changed, 3 insertions(+), 2 deletions(-) + +commit 5854d3fa251069f8158b97a831d1439c2ff8b510 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 10:42:49 2018 -0700 + + [set] Warning fix with gcc 8.1 + + https://github.com/harfbuzz/harfbuzz/pull/1334 + + src/hb-dsalgs.hh | 6 ++++-- + src/hb-set.hh | 4 ++-- + 2 files changed, 6 insertions(+), 4 deletions(-) + +commit 850a7af3a419c6c4ab92bff59991758a2951d41f +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Wed Oct 31 14:20:23 2018 +0330 + + [ot-color-test] Remove the non-working exact strike size storing + (#1339) + + src/test-ot-color.cc | 135 + +++++++++++++++++++++++---------------------------- + 1 file changed, 62 insertions(+), 73 deletions(-) + +commit 2e639c47c9d35ff7dc4dde21f744f9ee695a27f3 +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Wed Oct 31 14:20:14 2018 +0330 + + [aat] Fix older compilers by not referencing enum directly (#1340) + + src/hb-aat-layout-morx-table.hh | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit 642c9dcf1b34b51ffdbf88ccbef4762aa12a5cbe +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Wed Oct 31 14:02:37 2018 +0330 + + [aat] Minor, remove extra semicolons + + src/hb-aat-layout-morx-table.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit c962d5e714a6f88c4cb20bed219177b1bc4a2dfd +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 01:16:33 2018 -0700 + + [mort] Make ligatures work + + ./hb-shape Apple_Chancery_10_12.ttf "Th th ll te to tr fr fu fj" + [T_h=0+2308|space=2+569|t_h=3+1687|space=5+569|l_l=6+1108|space=8+569|t_e=9+1408|space=11+569|t_o=12+1531|space=14+569|t_r=15+1385|space=17+569|f_r=18+1432|space=20+569|f_u=21+1733|space=23+569|f_j=24+1098] + + Part of https://github.com/harfbuzz/harfbuzz/issues/1331 + + src/hb-aat-layout-morx-table.hh | 25 +++++++++++++++++-------- + 1 file changed, 17 insertions(+), 8 deletions(-) + +commit c07798960004439fcd8fa0f4ae33e225428d1065 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 00:36:03 2018 -0700 + + [mort] More Ligature work + + src/hb-aat-layout-morx-table.hh | 54 + ++++++++++++++++++++++++++++++----------- + 1 file changed, 40 insertions(+), 14 deletions(-) + +commit 431c6e496be56e441ee4b9b705f40a1246bdd0d6 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Oct 31 00:15:00 2018 -0700 + + [mort] Some Ligature work + + src/hb-aat-layout-morx-table.hh | 38 + +++++++++++++++++++++++++++++++------- + 1 file changed, 31 insertions(+), 7 deletions(-) + +commit 28b68cffe4e5ebf82217ebf439f428431d672af3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 23:33:30 2018 -0700 + + [mort] Implement / adjust Contextual substitution + + src/hb-aat-layout-morx-table.hh | 70 + ++++++++++++++++++++++++++++++----------- + src/hb-open-type.hh | 7 +++++ + 2 files changed, 59 insertions(+), 18 deletions(-) + +commit 11dbf0f12926b80d0c308c70a218342280045c23 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 21:49:59 2018 -0700 + + [mort] More fixes] + + src/hb-aat-layout-common.hh | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit e1552af95b6c17571f7ee58ebac92f48d93c8f98 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 21:09:05 2018 -0700 + + [maxp] Minor + + src/hb-ot-maxp-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0cf282a32e5b0fe1fec454ff293ffe04b33f1112 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 20:51:44 2018 -0700 + + [mort] Grind some more + + src/hb-aat-layout-common.hh | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +commit 90667b31bc3e61e68e27966e4781aba456c6b93b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 20:15:28 2018 -0700 + + [mort] Hook up more + + src/hb-aat-layout.cc | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit 9346b1f158dfd7d25ed0057b40aaa6980a85ea17 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 20:04:13 2018 -0700 + + [morx] Remove stale comment + + src/hb-aat-layout-morx-table.hh | 2 -- + 1 file changed, 2 deletions(-) + +commit f864ef215e1354a1e5a3c8796afafba761404e08 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:42:21 2018 -0700 + + [mort] More massaging towards mort + + src/hb-aat-layout-morx-table.hh | 53 + +++++++++++++++++++++-------------------- + 1 file changed, 27 insertions(+), 26 deletions(-) + +commit 2d9467340b1498ccc0cd47bf915b84ab12dfa025 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:33:31 2018 -0700 + + [mort] Fix version check in sanitize + + src/hb-aat-layout-morx-table.hh | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit c2527a1bc2b493473f06ea6ae79f0a87b722c4d3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:26:16 2018 -0700 + + [mort] Make it compile / hook it up + + Untested. + + src/hb-aat-layout-common.hh | 11 +++++----- + src/hb-aat-layout-morx-table.hh | 2 +- + src/hb-aat-layout.cc | 47 + ++++++++++++++++++++++++++--------------- + 3 files changed, 36 insertions(+), 24 deletions(-) + +commit 933babdc075c27fbcc1b726c3c9b2aa67338c6ad +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:22:43 2018 -0700 + + [mort] Fixup on previous commit + + src/hb-aat-layout-morx-table.hh | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +commit b053cabacd99ff69144a1459fe02ffd574c2416c +Author: Ebrahim Byagowi <ebrahim@gnu.org> +Date: Tue Oct 30 18:41:34 2018 +0330 + + [mort] Bring back mort generalizations + + Started by reverting + https://github.com/harfbuzz/harfbuzz/commit/1f1c85a5 + + Just a starting point, if we agree even mort can come back. + + src/hb-aat-layout-common.hh | 76 +++++++++++++++++++---- + src/hb-aat-layout-kerx-table.hh | 17 ++--- + src/hb-aat-layout-morx-table.hh | 133 + ++++++++++++++++++++++++---------------- + src/hb-aat-layout.cc | 16 ++++- + src/hb-ot-face.hh | 1 + + 5 files changed, 171 insertions(+), 72 deletions(-) + +commit 5cd544a621f10b307bb97aea27ea54e55aacb2e9 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:16:00 2018 -0700 + + Fix build + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1338 + + src/test-ot-color.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 69297bb21640677532b7030332f803c0768c6579 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 19:06:21 2018 -0700 + + [fuzzing] Call hb-ot-color API + + test/fuzzing/hb-shape-fuzzer.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 1019391046cf01524c4ef20c9256a47b7411610b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Oct 30 15:52:26 2018 -0700 + + 2.1.0 + + NEWS | 81 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + RELEASING.md | 3 +- + configure.ac | 2 +- + docs/harfbuzz-docs.xml | 1 + + src/hb-ot-color.cc | 22 +++++++++----- + src/hb-ot-color.h | 4 +-- + src/hb-version.h | 6 ++-- + 7 files changed, 105 insertions(+), 14 deletions(-) + commit bfd549daaa078e7edba5a65971b1d3e872664f2d Author: Behdad Esfahbod <behdad@behdad.org> Date: Tue Oct 30 14:47:27 2018 -0700 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS index cb8a28ff05a..04579d685a1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS +++ b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS @@ -1,3 +1,11 @@ +Overview of changes leading to 2.1.1 +Monday, November 5, 2018 +==================================== +- AAT improvements: + o Implement 'mort' table. + o Implement 'kern' subtables Format 1 and Format 3. + + Overview of changes leading to 2.1.0 Tuesday, October 30, 2018 ==================================== diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac index 21d48f39a28..48ee9ce9469 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], - [2.1.0], + [2.1.1], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-vowel-constraints.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-vowel-constraints.py index c4e75aa96b3..b7f6be2236f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-vowel-constraints.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-vowel-constraints.py @@ -211,9 +211,7 @@ print (' }') print (' if (processed)') print (' {') print (' if (buffer->idx < count)') -print (' buffer->next_glyph ();') -print (' if (likely (buffer->successful))') -print (' buffer->swap_buffers ();') +print (' buffer->next_glyph ();') print (' }') print ('}') diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh index 5f7656d2a49..b793245a0c5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh @@ -36,6 +36,8 @@ namespace AAT { +using namespace OT; + struct Anchor { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh index ce40abd5552..ee2136ed972 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh @@ -410,9 +410,13 @@ struct Entry<void> DEFINE_SIZE_STATIC (4); }; -template <typename Extra> +template <typename Types, typename Extra> struct StateTable { + typedef typename Types::HBUINT HBUINT; + typedef typename Types::HBUSHORT HBUSHORT; + typedef typename Types::ClassType ClassType; + enum State { STATE_START_OF_TEXT = 0, @@ -426,11 +430,13 @@ struct StateTable CLASS_END_OF_LINE = 3, }; + inline unsigned int new_state (unsigned int newState) const + { return Types::extended ? newState : (newState - stateArrayTable) / nClasses; } + inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const { if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH; - const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs); - return v ? (unsigned) *v : (unsigned) CLASS_OUT_OF_BOUNDS; + return (this+classTable).get_class (glyph_id, num_glyphs); } inline const Entry<Extra> *get_entries () const @@ -442,7 +448,7 @@ struct StateTable { if (unlikely (klass >= nClasses)) return nullptr; - const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const HBUSHORT *states = (this+stateArrayTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ; unsigned int entry = states[state * nClasses + klass]; @@ -457,7 +463,7 @@ struct StateTable if (unlikely (!(c->check_struct (this) && classTable.sanitize (c, this)))) return_trace (false); - const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const HBUSHORT *states = (this+stateArrayTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ; unsigned int num_classes = nClasses; @@ -479,8 +485,8 @@ struct StateTable if ((c->max_ops -= num_states - state) < 0) return_trace (false); { /* Sweep new states. */ - const HBUINT16 *stop = &states[num_states * num_classes]; - for (const HBUINT16 *p = &states[state * num_classes]; p < stop; p++) + const HBUSHORT *stop = &states[num_states * num_classes]; + for (const HBUSHORT *p = &states[state * num_classes]; p < stop; p++) num_entries = MAX<unsigned int> (num_entries, *p + 1); state = num_states; } @@ -492,7 +498,10 @@ struct StateTable { /* Sweep new entries. */ const Entry<Extra> *stop = &entries[num_entries]; for (const Entry<Extra> *p = &entries[entry]; p < stop; p++) - num_states = MAX<unsigned int> (num_states, p->newState + 1); + { + unsigned int newState = new_state (p->newState); + num_states = MAX<unsigned int> (num_states, newState + 1); + } entry = num_entries; } } @@ -504,23 +513,101 @@ struct StateTable } protected: - HBUINT32 nClasses; /* Number of classes, which is the number of indices + HBUINT nClasses; /* Number of classes, which is the number of indices * in a single line in the state array. */ - LOffsetTo<Lookup<HBUINT16>, false> + OffsetTo<ClassType, HBUINT, false> classTable; /* Offset to the class table. */ - LOffsetTo<UnsizedArrayOf<HBUINT16>, false> + OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT, false> stateArrayTable;/* Offset to the state array. */ - LOffsetTo<UnsizedArrayOf<Entry<Extra> >, false> + OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT, false> entryTable; /* Offset to the entry array. */ public: - DEFINE_SIZE_STATIC (16); + DEFINE_SIZE_STATIC (4 * sizeof (HBUINT)); +}; + +struct ClassTable +{ + inline unsigned int get_class (hb_codepoint_t glyph_id) const + { + return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? classArrayZ[glyph_id - firstGlyph] : 1; + } + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && classArrayZ.sanitize (c, glyphCount)); + } + protected: + GlyphID firstGlyph; /* First glyph index included in the trimmed array. */ + HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last + * glyph minus the value of firstGlyph plus 1). */ + UnsizedArrayOf<HBUINT8> + classArrayZ; /* The class codes (indexed by glyph index minus + * firstGlyph). */ + public: + DEFINE_SIZE_ARRAY (4, classArrayZ); +}; + +struct MortTypes +{ + static const bool extended = false; + typedef HBUINT16 HBUINT; + typedef HBUINT8 HBUSHORT; + struct ClassType : ClassTable + { + inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs HB_UNUSED) const + { + return ClassTable::get_class (glyph_id); + } + }; + template <typename T> + static inline unsigned int offsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return (offset - ((const char *) array - (const char *) base)) / sizeof (T); + } + template <typename T> + static inline unsigned int wordOffsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return offsetToIndex (2 * offset, base, array); + } +}; +struct MorxTypes +{ + static const bool extended = true; + typedef HBUINT32 HBUINT; + typedef HBUINT16 HBUSHORT; + struct ClassType : Lookup<HBUINT16> + { + inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + { + const HBUINT16 *v = get_value (glyph_id, num_glyphs); + return v ? *v : 1; + } + }; + template <typename T> + static inline unsigned int offsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return offset; + } + template <typename T> + static inline unsigned int wordOffsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return offset; + } }; -template <typename EntryData> +template <typename Types, typename EntryData> struct StateTableDriver { - inline StateTableDriver (const StateTable<EntryData> &machine_, + inline StateTableDriver (const StateTable<Types, EntryData> &machine_, hb_buffer_t *buffer_, hb_face_t *face_) : machine (machine_), @@ -533,13 +620,13 @@ struct StateTableDriver if (!c->in_place) buffer->clear_output (); - unsigned int state = StateTable<EntryData>::STATE_START_OF_TEXT; + unsigned int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT; bool last_was_dont_advance = false; for (buffer->idx = 0; buffer->successful;) { unsigned int klass = buffer->idx < buffer->len ? machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) : - (unsigned) StateTable<EntryData>::CLASS_END_OF_TEXT; + (unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT; const Entry<EntryData> *entry = machine.get_entryZ (state, klass); if (unlikely (!entry)) break; @@ -553,7 +640,7 @@ struct StateTableDriver /* If there's no action and we're just epsilon-transitioning to state 0, * safe to break. */ if (c->is_actionable (this, entry) || - !(entry->newState == StateTable<EntryData>::STATE_START_OF_TEXT && + !(entry->newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT && entry->flags == context_t::DontAdvance)) buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1); } @@ -567,30 +654,29 @@ struct StateTableDriver } if (unlikely (!c->transition (this, entry))) - break; + break; last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0; - state = entry->newState; + state = machine.new_state (entry->newState); if (buffer->idx == buffer->len) - break; + break; if (!last_was_dont_advance) - buffer->next_glyph (); + buffer->next_glyph (); } if (!c->in_place) { for (; buffer->successful && buffer->idx < buffer->len;) buffer->next_glyph (); - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); } } public: - const StateTable<EntryData> &machine; + const StateTable<Types, EntryData> &machine; hb_buffer_t *buffer; unsigned int num_glyphs; }; @@ -612,36 +698,23 @@ struct hb_aat_apply_context_t : hb_face_t *face; hb_buffer_t *buffer; hb_sanitize_context_t sanitizer; - const ankr &ankr_table; + const ankr *ankr_table; const char *ankr_end; /* Unused. For debug tracing only. */ unsigned int lookup_index; unsigned int debug_depth; - inline hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_, - hb_font_t *font_, - hb_buffer_t *buffer_, - hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t)), - const ankr &ankr_table_ = Null(ankr), - const char *ankr_end_ = nullptr) : - plan (plan_), font (font_), face (font->face), buffer (buffer_), - sanitizer (), - ankr_table (ankr_table_), ankr_end (ankr_end_), - lookup_index (0), debug_depth (0) - { - sanitizer.init (blob); - sanitizer.set_num_glyphs (face->get_num_glyphs ()); - sanitizer.start_processing (); - sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX); - } + HB_INTERNAL hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_, + hb_font_t *font_, + hb_buffer_t *buffer_, + hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t))); - inline void set_lookup_index (unsigned int i) { lookup_index = i; } + HB_INTERNAL ~hb_aat_apply_context_t (void); - inline ~hb_aat_apply_context_t (void) - { - sanitizer.end_processing (); - } + HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_, const char *ankr_end_); + + inline void set_lookup_index (unsigned int i) { lookup_index = i; } }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh index a88312501fb..d2242c5496e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh @@ -163,12 +163,12 @@ struct KerxSubTableFormat1 kernAction (&table->machine + table->kernAction), depth (0) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver HB_UNUSED, + inline bool is_actionable (StateTableDriver<MorxTypes, EntryData> *driver HB_UNUSED, const Entry<EntryData> *entry) { return entry->data.kernActionIndex != 0xFFFF; } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<MorxTypes, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -207,11 +207,18 @@ struct KerxSubTableFormat1 int v = *actions++; if (idx < buffer->len && buffer->info[idx].mask & kern_mask) { - /* XXX Non-forward direction... */ if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + { buffer->pos[idx].x_advance += c->font->em_scale_x (v); + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + buffer->pos[idx].x_offset += c->font->em_scale_x (v); + } else + { buffer->pos[idx].y_advance += c->font->em_scale_y (v); + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + buffer->pos[idx].y_offset += c->font->em_scale_y (v); + } } } depth = 0; @@ -239,7 +246,7 @@ struct KerxSubTableFormat1 driver_context_t dc (this, c); - StateTableDriver<EntryData> driver (machine, c->buffer, c->font->face); + StateTableDriver<MorxTypes, EntryData> driver (machine, c->buffer, c->font->face); driver.drive (&dc); return_trace (true); @@ -255,7 +262,7 @@ struct KerxSubTableFormat1 protected: KerxSubTableHeader header; - StateTable<EntryData> machine; + StateTable<MorxTypes, EntryData> machine; LOffsetTo<UnsizedArrayOf<FWORD>, false> kernAction; public: DEFINE_SIZE_STATIC (32); @@ -365,12 +372,12 @@ struct KerxSubTableFormat4 mark_set (false), mark (0) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver HB_UNUSED, + inline bool is_actionable (StateTableDriver<MorxTypes, EntryData> *driver HB_UNUSED, const Entry<EntryData> *entry) { return entry->data.ankrActionIndex != 0xFFFF; } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<MorxTypes, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -416,14 +423,14 @@ struct KerxSubTableFormat4 return false; unsigned int markAnchorPoint = *data++; unsigned int currAnchorPoint = *data++; - const Anchor markAnchor = c->ankr_table.get_anchor (c->buffer->info[mark].codepoint, - markAnchorPoint, - c->sanitizer.get_num_glyphs (), - c->ankr_end); - const Anchor currAnchor = c->ankr_table.get_anchor (c->buffer->cur ().codepoint, - currAnchorPoint, - c->sanitizer.get_num_glyphs (), - c->ankr_end); + const Anchor markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint, + markAnchorPoint, + c->sanitizer.get_num_glyphs (), + c->ankr_end); + const Anchor currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint, + currAnchorPoint, + c->sanitizer.get_num_glyphs (), + c->ankr_end); o.x_offset = c->font->em_scale_x (markAnchor.xCoordinate) - c->font->em_scale_x (currAnchor.xCoordinate); o.y_offset = c->font->em_scale_y (markAnchor.yCoordinate) - c->font->em_scale_y (currAnchor.yCoordinate); @@ -473,7 +480,7 @@ struct KerxSubTableFormat4 driver_context_t dc (this, c); - StateTableDriver<EntryData> driver (machine, c->buffer, c->font->face); + StateTableDriver<MorxTypes, EntryData> driver (machine, c->buffer, c->font->face); driver.drive (&dc); return_trace (true); @@ -489,7 +496,8 @@ struct KerxSubTableFormat4 protected: KerxSubTableHeader header; - StateTable<EntryData> machine; + StateTable<MorxTypes, EntryData> + machine; HBUINT32 flags; public: DEFINE_SIZE_STATIC (32); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh index a562091040c..2bc60182e5c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh @@ -35,17 +35,21 @@ /* * morx -- Extended Glyph Metamorphosis * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html */ #define HB_AAT_TAG_morx HB_TAG('m','o','r','x') +#define HB_AAT_TAG_mort HB_TAG('m','o','r','t') namespace AAT { using namespace OT; - +template <typename Types> struct RearrangementSubtable { + typedef typename Types::HBUINT HBUINT; + typedef void EntryData; struct driver_context_t @@ -69,12 +73,12 @@ struct RearrangementSubtable ret (false), start (0), end (0) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver HB_UNUSED, + inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, const Entry<EntryData> *entry) { return (entry->flags & Verb) && start < end; } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<Types, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -165,7 +169,7 @@ struct RearrangementSubtable driver_context_t dc (this); - StateTableDriver<EntryData> driver (machine, c->buffer, c->face); + StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face); driver.drive (&dc); return_trace (dc.ret); @@ -178,13 +182,16 @@ struct RearrangementSubtable } protected: - StateTable<EntryData> machine; + StateTable<Types, EntryData> machine; public: DEFINE_SIZE_STATIC (16); }; +template <typename Types> struct ContextualSubtable { + typedef typename Types::HBUINT HBUINT; + struct EntryData { HBUINT16 markIndex; /* Index of the substitution table for the @@ -206,13 +213,16 @@ struct ContextualSubtable Reserved = 0x3FFF, /* These bits are reserved and should be set to 0. */ }; - inline driver_context_t (const ContextualSubtable *table) : + inline driver_context_t (const ContextualSubtable *table_, + hb_aat_apply_context_t *c_) : ret (false), + c (c_), mark_set (false), mark (0), + table (table_), subs (table+table->substitutionTables) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver, + inline bool is_actionable (StateTableDriver<Types, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -222,7 +232,7 @@ struct ContextualSubtable return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF; } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<Types, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -232,30 +242,55 @@ struct ContextualSubtable if (buffer->idx == buffer->len && !mark_set) return true; - if (entry->data.markIndex != 0xFFFF) + const GlyphID *replacement; + + replacement = nullptr; + if (Types::extended) { - const Lookup<GlyphID> &lookup = subs[entry->data.markIndex]; - hb_glyph_info_t *info = buffer->info; - const GlyphID *replacement = lookup.get_value (info[mark].codepoint, driver->num_glyphs); - if (replacement) + if (entry->data.markIndex != 0xFFFF) { - buffer->unsafe_to_break (mark, MIN (buffer->idx + 1, buffer->len)); - info[mark].codepoint = *replacement; - ret = true; + const Lookup<GlyphID> &lookup = subs[entry->data.markIndex]; + replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs); } } - if (entry->data.currentIndex != 0xFFFF) + else + { + unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint; + const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; + replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; + if (!replacement->sanitize (&c->sanitizer) || !*replacement) + replacement = nullptr; + } + if (replacement) + { + buffer->unsafe_to_break (mark, MIN (buffer->idx + 1, buffer->len)); + buffer->info[mark].codepoint = *replacement; + ret = true; + } + + replacement = nullptr; + unsigned int idx = MIN (buffer->idx, buffer->len - 1); + if (Types::extended) { - unsigned int idx = MIN (buffer->idx, buffer->len - 1); - const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex]; - hb_glyph_info_t *info = buffer->info; - const GlyphID *replacement = lookup.get_value (info[idx].codepoint, driver->num_glyphs); - if (replacement) + if (entry->data.currentIndex != 0xFFFF) { - info[idx].codepoint = *replacement; - ret = true; + const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex]; + replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs); } } + else + { + unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint; + const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; + replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; + if (!replacement->sanitize (&c->sanitizer) || !*replacement) + replacement = nullptr; + } + if (replacement) + { + buffer->info[idx].codepoint = *replacement; + ret = true; + } if (entry->flags & SetMark) { @@ -269,18 +304,20 @@ struct ContextualSubtable public: bool ret; private: + hb_aat_apply_context_t *c; bool mark_set; unsigned int mark; - const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32, false> &subs; + const ContextualSubtable *table; + const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false> &subs; }; inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); - driver_context_t dc (this); + driver_context_t dc (this, c); - StateTableDriver<EntryData> driver (machine, c->buffer, c->face); + StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face); driver.drive (&dc); return_trace (dc.ret); @@ -293,6 +330,8 @@ struct ContextualSubtable unsigned int num_entries = 0; if (unlikely (!machine.sanitize (c, &num_entries))) return_trace (false); + if (!Types::extended) return_trace (true); + unsigned int num_lookups = 0; const Entry<EntryData> *entries = machine.get_entries (); @@ -310,38 +349,90 @@ struct ContextualSubtable } protected: - StateTable<EntryData> + StateTable<Types, EntryData> machine; - LOffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32, false>, false> + OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false>, HBUINT, false> substitutionTables; public: DEFINE_SIZE_STATIC (20); }; -struct LigatureSubtable + +template <bool extended> +struct LigatureEntry; + +template <> +struct LigatureEntry<true> { - struct EntryData + enum Flags + { + SetComponent = 0x8000, /* Push this glyph onto the component stack for + * eventual processing. */ + DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the + next iteration. */ + PerformAction = 0x2000, /* Use the ligActionIndex to process a ligature + * group. */ + Reserved = 0x1FFF, /* These bits are reserved and should be set to 0. */ + }; + + typedef struct { HBUINT16 ligActionIndex; /* Index to the first ligActionTable entry * for processing this group, if indicated * by the flags. */ public: DEFINE_SIZE_STATIC (2); + } EntryData; + + template <typename Flags> + static inline bool performAction (Flags flags) + { return flags & PerformAction; } + + template <typename Entry, typename Flags> + static inline unsigned int ligActionIndex (Entry &entry, Flags flags) + { return entry->data.ligActionIndex; } +}; +template <> +struct LigatureEntry<false> +{ + enum Flags + { + SetComponent = 0x8000, /* Push this glyph onto the component stack for + * eventual processing. */ + DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the + next iteration. */ + Offset = 0x3FFF, /* Byte offset from beginning of subtable to the + * ligature action list. This value must be a + * multiple of 4. */ }; + typedef void EntryData; + + template <typename Flags> + static inline bool performAction (Flags flags) + { return flags & Offset; } + + template <typename Entry, typename Flags> + static inline unsigned int ligActionIndex (Entry &entry, Flags flags) + { return flags & 0x3FFF; } +}; + + +template <typename Types> +struct LigatureSubtable +{ + typedef typename Types::HBUINT HBUINT; + + typedef LigatureEntry<Types::extended> LigatureEntryT; + typedef typename LigatureEntryT::EntryData EntryData; + struct driver_context_t { - static const bool in_place = false; - enum Flags + enum { - SetComponent = 0x8000, /* Push this glyph onto the component stack for - * eventual processing. */ - DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the - next iteration. */ - PerformAction = 0x2000, /* Use the ligActionIndex to process a ligature - * group. */ - Reserved = 0x1FFF, /* These bits are reserved and should be set to 0. */ + DontAdvance = LigatureEntryT::DontAdvance, }; + static const bool in_place = false; enum LigActionFlags { LigActionLast = 0x80000000, /* This is the last action in the list. This also @@ -354,28 +445,29 @@ struct LigatureSubtable * into the component table. */ }; - inline driver_context_t (const LigatureSubtable *table, + inline driver_context_t (const LigatureSubtable *table_, hb_aat_apply_context_t *c_) : ret (false), c (c_), + table (table_), ligAction (table+table->ligAction), component (table+table->component), ligature (table+table->ligature), match_length (0) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver HB_UNUSED, + inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, const Entry<EntryData> *entry) { - return entry->flags & PerformAction; + return LigatureEntryT::performAction (entry->flags); } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<Types, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; unsigned int flags = entry->flags; DEBUG_MSG (APPLY, nullptr, "Ligature transition at %d", buffer->idx); - if (flags & SetComponent) + if (flags & LigatureEntryT::SetComponent) { if (unlikely (match_length >= ARRAY_LENGTH (match_positions))) return false; @@ -388,11 +480,11 @@ struct LigatureSubtable DEBUG_MSG (APPLY, nullptr, "Set component at %d", buffer->out_len); } - if (flags & PerformAction) + if (LigatureEntryT::performAction (flags)) { DEBUG_MSG (APPLY, nullptr, "Perform action with %d", match_length); unsigned int end = buffer->out_len; - unsigned int action_idx = entry->data.ligActionIndex; + unsigned int action_idx = LigatureEntryT::ligActionIndex (entry, flags); unsigned int action; unsigned int ligature_idx = 0; @@ -403,6 +495,8 @@ struct LigatureSubtable return false; // TODO Work on previous instead? unsigned int cursor = match_length; + action_idx = Types::offsetToIndex (action_idx, table, ligAction.arrayZ); + const HBUINT32 *actionData = &ligAction[action_idx]; do { if (unlikely (!cursor)) @@ -416,16 +510,15 @@ struct LigatureSubtable DEBUG_MSG (APPLY, nullptr, "Moving to stack position %d", cursor - 1); buffer->move_to (match_positions[--cursor]); - const HBUINT32 &actionData = ligAction[action_idx]; - if (unlikely (!actionData.sanitize (&c->sanitizer))) return false; - action = actionData; + if (unlikely (!actionData->sanitize (&c->sanitizer))) return false; + action = *actionData; uint32_t uoffset = action & LigActionOffset; if (uoffset & 0x20000000) uoffset |= 0xC0000000; /* Sign-extend. */ int32_t offset = (int32_t) uoffset; unsigned int component_idx = buffer->cur().codepoint + offset; - + component_idx = Types::wordOffsetToIndex (component_idx, table, component.arrayZ); const HBUINT16 &componentData = component[component_idx]; if (unlikely (!componentData.sanitize (&c->sanitizer))) return false; ligature_idx += componentData; @@ -435,7 +528,7 @@ struct LigatureSubtable bool (action & LigActionLast)); if (action & (LigActionStore | LigActionLast)) { - + ligature_idx = Types::offsetToIndex (ligature_idx, table, ligature.arrayZ); const GlyphID &ligatureData = ligature[ligature_idx]; if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false; hb_codepoint_t lig = ligatureData; @@ -456,7 +549,7 @@ struct LigatureSubtable buffer->merge_out_clusters (match_positions[cursor], buffer->out_len); } - action_idx++; + actionData++; } while (!(action & LigActionLast)); buffer->move_to (end); @@ -469,6 +562,7 @@ struct LigatureSubtable bool ret; private: hb_aat_apply_context_t *c; + const LigatureSubtable *table; const UnsizedArrayOf<HBUINT32> &ligAction; const UnsizedArrayOf<HBUINT16> &component; const UnsizedArrayOf<GlyphID> &ligature; @@ -482,7 +576,7 @@ struct LigatureSubtable driver_context_t dc (this, c); - StateTableDriver<EntryData> driver (machine, c->buffer, c->face); + StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face); driver.drive (&dc); return_trace (dc.ret); @@ -497,18 +591,19 @@ struct LigatureSubtable } protected: - StateTable<EntryData> + StateTable<Types, EntryData> machine; - LOffsetTo<UnsizedArrayOf<HBUINT32>, false> + OffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT, false> ligAction; /* Offset to the ligature action table. */ - LOffsetTo<UnsizedArrayOf<HBUINT16>, false> + OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT, false> component; /* Offset to the component table. */ - LOffsetTo<UnsizedArrayOf<GlyphID>, false> + OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false> ligature; /* Offset to the actual ligature lists. */ public: DEFINE_SIZE_STATIC (28); }; +template <typename Types> struct NoncontextualSubtable { inline bool apply (hb_aat_apply_context_t *c) const @@ -545,8 +640,11 @@ struct NoncontextualSubtable DEFINE_SIZE_MIN (2); }; +template <typename Types> struct InsertionSubtable { + typedef typename Types::HBUINT HBUINT; + struct EntryData { HBUINT16 currentInsertIndex; /* Zero-based index into the insertion glyph table. @@ -622,13 +720,13 @@ struct InsertionSubtable mark (0), insertionAction (table+table->insertionAction) {} - inline bool is_actionable (StateTableDriver<EntryData> *driver HB_UNUSED, + inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, const Entry<EntryData> *entry) { return (entry->flags & (CurrentInsertCount | MarkedInsertCount)) && (entry->data.currentInsertIndex != 0xFFFF ||entry->data.markedInsertIndex != 0xFFFF); } - inline bool transition (StateTableDriver<EntryData> *driver, + inline bool transition (StateTableDriver<Types, EntryData> *driver, const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -720,7 +818,7 @@ struct InsertionSubtable driver_context_t dc (this, c); - StateTableDriver<EntryData> driver (machine, c->buffer, c->face); + StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face); driver.drive (&dc); return_trace (dc.ret); @@ -735,9 +833,9 @@ struct InsertionSubtable } protected: - StateTable<EntryData> + StateTable<Types, EntryData> machine; - LOffsetTo<UnsizedArrayOf<GlyphID>, false> + OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false> insertionAction; /* Byte offset from stateHeader to the start of * the insertion glyph table. */ public: @@ -765,30 +863,32 @@ struct Feature DEFINE_SIZE_STATIC (12); }; - +template <typename Types> struct ChainSubtable { + typedef typename Types::HBUINT HBUINT; + + template <typename T> friend struct Chain; inline unsigned int get_size (void) const { return length; } - inline unsigned int get_type (void) const { return coverage & SubtableType; } + inline unsigned int get_type (void) const { return coverage & 0xFF; } + inline unsigned int get_coverage (void) const { return coverage >> (sizeof (HBUINT) * 8 - 8); } enum Coverage { - Vertical = 0x80000000, /* If set, this subtable will only be applied - * to vertical text. If clear, this subtable - * will only be applied to horizontal text. */ - Backwards = 0x40000000, /* If set, this subtable will process glyphs - * in descending order. If clear, it will - * process the glyphs in ascending order. */ - AllDirections = 0x20000000, /* If set, this subtable will be applied to - * both horizontal and vertical text (i.e. - * the state of bit 0x80000000 is ignored). */ - Logical = 0x10000000, /* If set, this subtable will process glyphs - * in logical order (or reverse logical order, - * depending on the value of bit 0x80000000). */ - Reserved = 0x0FFFFF00, /* Reserved, set to zero. */ - SubtableType = 0x000000FF, /* Subtable type; see following table. */ + Vertical = 0x80, /* If set, this subtable will only be applied + * to vertical text. If clear, this subtable + * will only be applied to horizontal text. */ + Backwards = 0x40, /* If set, this subtable will process glyphs + * in descending order. If clear, it will + * process the glyphs in ascending order. */ + AllDirections = 0x20, /* If set, this subtable will be applied to + * both horizontal and vertical text (i.e. + * the state of bit 0x80000000 is ignored). */ + Logical = 0x10, /* If set, this subtable will process glyphs + * in logical order (or reverse logical order, + * depending on the value of bit 0x80000000). */ }; enum Type { @@ -826,40 +926,49 @@ struct ChainSubtable } protected: - HBUINT32 length; /* Total subtable length, including this header. */ - HBUINT32 coverage; /* Coverage flags and subtable type. */ + HBUINT length; /* Total subtable length, including this header. */ + HBUINT coverage; /* Coverage flags and subtable type. */ HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */ union { - RearrangementSubtable rearrangement; - ContextualSubtable contextual; - LigatureSubtable ligature; - NoncontextualSubtable noncontextual; - InsertionSubtable insertion; + RearrangementSubtable<Types> rearrangement; + ContextualSubtable<Types> contextual; + LigatureSubtable<Types> ligature; + NoncontextualSubtable<Types> noncontextual; + InsertionSubtable<Types> insertion; } u; public: - DEFINE_SIZE_MIN (12); + DEFINE_SIZE_MIN (2 * sizeof (HBUINT) + 4); }; +template <typename Types> struct Chain { + typedef typename Types::HBUINT HBUINT; + inline hb_mask_t compile_flags (const hb_aat_map_builder_t *map) const { hb_mask_t flags = defaultFlags; { - /* Compute applicable flags. TODO Should move this to planning - * stage and take user-requested features into account. */ unsigned int count = featureCount; for (unsigned i = 0; i < count; i++) { const Feature &feature = featureZ[i]; uint16_t type = feature.featureType; uint16_t setting = feature.featureSetting; + retry: const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch (type); if (info && info->setting == setting) { flags &= feature.disableFlags; flags |= feature.enableFlags; } + else if (type == 3/*kLetterCaseType*/ && setting == 3/*kSmallCapsSelector*/) + { + /* Deprecated. https://github.com/harfbuzz/harfbuzz/issues/1342 */ + type = 37/*kLowerCaseType*/; + setting = 1/*kLowerCaseSmallCapsSelector*/; + goto retry; + } } } return flags; @@ -868,7 +977,7 @@ struct Chain inline void apply (hb_aat_apply_context_t *c, hb_mask_t flags) const { - const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount)); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { @@ -877,9 +986,9 @@ struct Chain if (!(subtable->subFeatureFlags & flags)) goto skip; - if (!(subtable->coverage & ChainSubtable::AllDirections) && + if (!(subtable->get_coverage() & ChainSubtable<Types>::AllDirections) && HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) != - bool (subtable->coverage & ChainSubtable::Vertical)) + bool (subtable->get_coverage() & ChainSubtable<Types>::Vertical)) goto skip; /* Buffer contents is always in logical direction. Determine if @@ -909,9 +1018,9 @@ struct Chain (the order opposite that of the characters, which may be right-to-left or left-to-right). */ - reverse = subtable->coverage & ChainSubtable::Logical ? - bool (subtable->coverage & ChainSubtable::Backwards) : - bool (subtable->coverage & ChainSubtable::Backwards) != + reverse = subtable->get_coverage () & ChainSubtable<Types>::Logical ? + bool (subtable->get_coverage () & ChainSubtable<Types>::Backwards) : + bool (subtable->get_coverage () & ChainSubtable<Types>::Backwards) != HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction); if (!c->buffer->message (c->font, "start chain subtable %d", c->lookup_index)) @@ -932,7 +1041,7 @@ struct Chain if (unlikely (!c->buffer->successful)) return; skip: - subtable = &StructAfter<ChainSubtable> (*subtable); + subtable = &StructAfter<ChainSubtable<Types> > (*subtable); c->set_lookup_index (c->lookup_index + 1); } } @@ -950,13 +1059,13 @@ struct Chain if (!c->check_array (featureZ.arrayZ, featureCount)) return_trace (false); - const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount)); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { if (!subtable->sanitize (c)) return_trace (false); - subtable = &StructAfter<ChainSubtable> (*subtable); + subtable = &StructAfter<ChainSubtable<Types> > (*subtable); } return_trace (true); @@ -965,23 +1074,24 @@ struct Chain protected: HBUINT32 defaultFlags; /* The default specification for subtables. */ HBUINT32 length; /* Total byte count, including this header. */ - HBUINT32 featureCount; /* Number of feature subtable entries. */ - HBUINT32 subtableCount; /* The number of subtables in the chain. */ + HBUINT featureCount; /* Number of feature subtable entries. */ + HBUINT subtableCount; /* The number of subtables in the chain. */ UnsizedArrayOf<Feature> featureZ; /* Features. */ /*ChainSubtable firstSubtable;*//* Subtables. */ /*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */ public: - DEFINE_SIZE_MIN (16); + DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT)); }; /* - * The 'morx' Table + * The 'mort'/'morx' Table */ -struct morx +template <typename Types> +struct mortmorx { static const hb_tag_t tableTag = HB_AAT_TAG_morx; @@ -990,12 +1100,12 @@ struct morx inline void compile_flags (const hb_aat_map_builder_t *mapper, hb_aat_map_t *map) const { - const Chain *chain = &firstChain; + const Chain<Types> *chain = &firstChain; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { map->chain_flags.push (chain->compile_flags (mapper)); - chain = &StructAfter<Chain> (*chain); + chain = &StructAfter<Chain<Types> > (*chain); } } @@ -1011,21 +1121,20 @@ struct morx else buffer->next_glyph (); } - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); } inline void apply (hb_aat_apply_context_t *c) const { if (unlikely (!c->buffer->successful)) return; c->set_lookup_index (0); - const Chain *chain = &firstChain; + const Chain<Types> *chain = &firstChain; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { chain->apply (c, c->plan->aat_map.chain_flags[i]); if (unlikely (!c->buffer->successful)) return; - chain = &StructAfter<Chain> (*chain); + chain = &StructAfter<Chain<Types> > (*chain); } remove_deleted_glyphs (c->buffer); } @@ -1033,17 +1142,16 @@ struct morx inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (!version.sanitize (c) || version < 2 || - !chainCount.sanitize (c)) + if (!version.sanitize (c) || !version || !chainCount.sanitize (c)) return_trace (false); - const Chain *chain = &firstChain; + const Chain<Types> *chain = &firstChain; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { if (!chain->sanitize (c, version)) return_trace (false); - chain = &StructAfter<Chain> (*chain); + chain = &StructAfter<Chain<Types> > (*chain); } return_trace (true); @@ -1051,16 +1159,26 @@ struct morx protected: HBUINT16 version; /* Version number of the glyph metamorphosis table. - * 2 or 3. */ + * 1, 2, or 3. */ HBUINT16 unused; /* Set to 0. */ HBUINT32 chainCount; /* Number of metamorphosis chains contained in this * table. */ - Chain firstChain; /* Chains. */ + Chain<Types> firstChain; /* Chains. */ public: DEFINE_SIZE_MIN (8); }; +struct morx : mortmorx<MorxTypes> +{ + static const hb_tag_t tableTag = HB_AAT_TAG_morx; +}; +struct mort : mortmorx<MortTypes> +{ + static const hb_tag_t tableTag = HB_AAT_TAG_mort; +}; + + } /* namespace AAT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh index de2071ad6aa..c579c1193cd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh @@ -55,7 +55,7 @@ struct TrackTableEntry unsigned int index, unsigned int nSizes) const { - return hb_array (base+valuesZ, nSizes)[index]; + return (base+valuesZ).as_array (nSizes)[index]; } public: diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc index ec053938fdc..9e0eb92fa78 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc @@ -41,6 +41,7 @@ * when moving to this file. */ static const hb_aat_feature_mapping_t feature_mappings[] = { + {HB_TAG ('a','f','r','c'), 11/*kFractionsType*/, 1/*kVerticalFractionsSelector*/, 0/*kNoFractionsSelector*/}, {HB_TAG ('c','2','p','c'), 38/*kUpperCaseType*/, 2/*kUpperCasePetiteCapsSelector*/, 0/*kDefaultUpperCaseSelector*/}, {HB_TAG ('c','2','s','c'), 38/*kUpperCaseType*/, 1/*kUpperCaseSmallCapsSelector*/, 0/*kDefaultUpperCaseSelector*/}, {HB_TAG ('c','a','l','t'), 36/*kContextualAlternatesType*/, 0/*kContextualAlternatesOnSelector*/, 1/*kContextualAlternatesOffSelector*/}, @@ -130,9 +131,61 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag) /* - * morx/kerx/trak + * hb_aat_apply_context_t */ +AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_, + hb_font_t *font_, + hb_buffer_t *buffer_, + hb_blob_t *blob) : + plan (plan_), + font (font_), + face (font->face), + buffer (buffer_), + sanitizer (), + ankr_table (&Null(AAT::ankr)), + ankr_end (nullptr), + lookup_index (0), + debug_depth (0) +{ + sanitizer.init (blob); + sanitizer.set_num_glyphs (face->get_num_glyphs ()); + sanitizer.start_processing (); + sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX); +} + +AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t (void) +{ + sanitizer.end_processing (); +} + +void +AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_, + const char *ankr_end_) +{ + ankr_table = ankr_table_; + ankr_end = ankr_end_; +} + + +/* + * mort/morx/kerx/trak + */ + +static inline const AAT::mort& +_get_mort (hb_face_t *face, hb_blob_t **blob = nullptr) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) + { + if (blob) + *blob = hb_blob_get_empty (); + return Null(AAT::mort); + } + const AAT::mort& mort = *(hb_ot_face_data (face)->mort); + if (blob) + *blob = hb_ot_face_data (face)->mort.get_blob (); + return mort; +} static inline const AAT::morx& _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) { @@ -142,7 +195,7 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::morx); } - const AAT::morx& morx = *(hb_ot_face_data (face)->morx.get ()); + const AAT::morx& morx = *(hb_ot_face_data (face)->morx); if (blob) *blob = hb_ot_face_data (face)->morx.get_blob (); return morx; @@ -156,7 +209,7 @@ _get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::kerx); } - const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx.get ()); + const AAT::kerx& kerx = *(hb_ot_face_data (face)->kerx); if (blob) *blob = hb_ot_face_data (face)->kerx.get_blob (); return kerx; @@ -170,7 +223,7 @@ _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::ankr); } - const AAT::ankr& ankr = *(hb_ot_face_data (face)->ankr.get ()); + const AAT::ankr& ankr = *(hb_ot_face_data (face)->ankr); if (blob) *blob = hb_ot_face_data (face)->ankr.get_blob (); return ankr; @@ -179,13 +232,13 @@ static inline const AAT::trak& _get_trak (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak); - return *(hb_ot_face_data (face)->trak.get ()); + return *(hb_ot_face_data (face)->trak); } static inline const AAT::ltag& _get_ltag (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::ltag); - return *(hb_ot_face_data (face)->ltag.get ()); + return *(hb_ot_face_data (face)->ltag); } @@ -193,14 +246,27 @@ void hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper, hb_aat_map_t *map) { - _get_morx (mapper->face).compile_flags (mapper, map); + const AAT::morx& morx = _get_morx (mapper->face, nullptr); + if (morx.has_data ()) + { + morx.compile_flags (mapper, map); + return; + } + + const AAT::mort& mort = _get_mort (mapper->face, nullptr); + if (mort.has_data ()) + { + mort.compile_flags (mapper, map); + return; + } } hb_bool_t hb_aat_layout_has_substitution (hb_face_t *face) { - return _get_morx (face).has_data (); + return _get_morx (face).has_data () || + _get_mort (face).has_data (); } void @@ -209,10 +275,22 @@ hb_aat_layout_substitute (hb_ot_shape_plan_t *plan, hb_buffer_t *buffer) { hb_blob_t *blob; + const AAT::morx& morx = _get_morx (font->face, &blob); + if (morx.has_data ()) + { + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + morx.apply (&c); + return; + } - AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); - morx.apply (&c); + const AAT::mort& mort = _get_mort (font->face, &blob); + if (mort.has_data ()) + { + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + mort.apply (&c); + return; + } } @@ -233,8 +311,8 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan, hb_blob_t *ankr_blob; const AAT::ankr& ankr = _get_ankr (font->face, &ankr_blob); - AAT::hb_aat_apply_context_t c (plan, font, buffer, blob, - ankr, ankr_blob->data + ankr_blob->length); + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + c.set_ankr_table (&ankr, ankr_blob->data + ankr_blob->length); kerx.apply (&c); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc index f2736bfd119..1ce1b12b05c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc @@ -34,6 +34,14 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned int value) { + if (tag == HB_TAG ('a','a','l','t')) + { + feature_info_t *info = features.push(); + info->type = 17/*kCharacterAlternativesType*/; + info->setting = value; + return; + } + const hb_aat_feature_mapping_t *mapping = hb_aat_layout_find_feature_mapping (tag); if (!mapping) return; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh index 846cdc1a920..6fd3fa1ea86 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh @@ -30,8 +30,6 @@ #include "hb.hh" -struct hb_ot_shape_plan_t; - struct hb_aat_map_t { friend struct hb_aat_map_builder_t; @@ -58,15 +56,7 @@ struct hb_aat_map_builder_t HB_INTERNAL hb_aat_map_builder_t (hb_face_t *face_, const hb_segment_properties_t *props_ HB_UNUSED) : - face (face_) - { - features.init (); - } - - ~hb_aat_map_builder_t (void) - { - features.fini (); - } + face (face_) {} HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value=1); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh index 697de19c55d..49c2809e2fa 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh @@ -290,6 +290,9 @@ struct hb_atomic_ptr_t inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } inline bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); } + inline T * operator -> (void) const { return get (); } + template <typename C> inline operator C * (void) const { return get (); } + mutable T *v; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc index 51f22ce4dae..9271200b110 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc @@ -57,8 +57,6 @@ DEFINE_NULL_INSTANCE (hb_blob_t) = { HB_OBJECT_HEADER_STATIC, - true, /* immutable */ - nullptr, /* data */ 0, /* length */ HB_MEMORY_MODE_READONLY, /* mode */ @@ -151,7 +149,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent, { hb_blob_t *blob; - if (!length || offset >= parent->length) + if (!length || !parent || offset >= parent->length) return hb_blob_get_empty (); hb_blob_make_immutable (parent); @@ -299,12 +297,10 @@ hb_blob_get_user_data (hb_blob_t *blob, void hb_blob_make_immutable (hb_blob_t *blob) { - if (hb_object_is_inert (blob)) - return; - if (blob->immutable) + if (hb_object_is_immutable (blob)) return; - blob->immutable = true; + hb_object_make_immutable (blob); } /** @@ -320,7 +316,7 @@ hb_blob_make_immutable (hb_blob_t *blob) hb_bool_t hb_blob_is_immutable (hb_blob_t *blob) { - return blob->immutable; + return hb_object_is_immutable (blob); } @@ -454,7 +450,7 @@ hb_blob_t::try_make_writable_inplace (void) bool hb_blob_t::try_make_writable (void) { - if (this->immutable) + if (hb_object_is_immutable (this)) return false; if (this->mode == HB_MEMORY_MODE_WRITABLE) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh index 26e2dd70a0a..1f7499fbf33 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh @@ -60,7 +60,7 @@ struct hb_blob_t template <typename Type> inline const Type* as (void) const { - return unlikely (!data) ? &Null(Type) : reinterpret_cast<const Type *> (data); + return length < Type::min_size ? &Null(Type) : reinterpret_cast<const Type *> (data); } inline hb_bytes_t as_bytes (void) const { @@ -70,8 +70,6 @@ struct hb_blob_t public: hb_object_header_t header; - bool immutable; - const char *data; unsigned int length; hb_memory_mode_t mode; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc index 5a8152ed4d2..1a5547b35f3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc @@ -217,7 +217,7 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size) void hb_buffer_t::reset (void) { - if (unlikely (hb_object_is_inert (this))) + if (unlikely (hb_object_is_immutable (this))) return; hb_unicode_funcs_destroy (unicode); @@ -232,7 +232,7 @@ hb_buffer_t::reset (void) void hb_buffer_t::clear (void) { - if (unlikely (hb_object_is_inert (this))) + if (unlikely (hb_object_is_immutable (this))) return; hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; @@ -289,7 +289,7 @@ hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) void hb_buffer_t::remove_output (void) { - if (unlikely (hb_object_is_inert (this))) + if (unlikely (hb_object_is_immutable (this))) return; have_output = false; @@ -302,7 +302,7 @@ hb_buffer_t::remove_output (void) void hb_buffer_t::clear_output (void) { - if (unlikely (hb_object_is_inert (this))) + if (unlikely (hb_object_is_immutable (this))) return; have_output = true; @@ -315,7 +315,7 @@ hb_buffer_t::clear_output (void) void hb_buffer_t::clear_positions (void) { - if (unlikely (hb_object_is_inert (this))) + if (unlikely (hb_object_is_immutable (this))) return; have_output = false; @@ -873,7 +873,7 @@ void hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, hb_unicode_funcs_t *unicode_funcs) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; if (!unicode_funcs) @@ -920,7 +920,7 @@ hb_buffer_set_direction (hb_buffer_t *buffer, hb_direction_t direction) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->props.direction = direction; @@ -964,7 +964,7 @@ void hb_buffer_set_script (hb_buffer_t *buffer, hb_script_t script) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->props.script = script; @@ -1008,7 +1008,7 @@ void hb_buffer_set_language (hb_buffer_t *buffer, hb_language_t language) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->props.language = language; @@ -1046,7 +1046,7 @@ void hb_buffer_set_segment_properties (hb_buffer_t *buffer, const hb_segment_properties_t *props) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->props = *props; @@ -1082,7 +1082,7 @@ void hb_buffer_set_flags (hb_buffer_t *buffer, hb_buffer_flags_t flags) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->flags = flags; @@ -1118,7 +1118,7 @@ void hb_buffer_set_cluster_level (hb_buffer_t *buffer, hb_buffer_cluster_level_t cluster_level) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->cluster_level = cluster_level; @@ -1157,7 +1157,7 @@ void hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, hb_codepoint_t replacement) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->replacement = replacement; @@ -1197,7 +1197,7 @@ void hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, hb_codepoint_t invisible) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; buffer->invisible = invisible; @@ -1329,7 +1329,7 @@ hb_bool_t hb_buffer_set_length (hb_buffer_t *buffer, unsigned int length) { - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return length == 0; if (!buffer->ensure (length)) @@ -1535,7 +1535,7 @@ hb_buffer_add_utf (hb_buffer_t *buffer, assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); - if (unlikely (hb_object_is_inert (buffer))) + if (unlikely (hb_object_is_immutable (buffer))) return; if (text_length == -1) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc index d7c1921f3ae..37be8a34e04 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc @@ -281,7 +281,7 @@ static void free_langs (void) { retry: - hb_language_item_t *first_lang = langs.get (); + hb_language_item_t *first_lang = langs; if (unlikely (!langs.cmpexch (first_lang, nullptr))) goto retry; @@ -298,7 +298,7 @@ static hb_language_item_t * lang_find_or_insert (const char *key) { retry: - hb_language_item_t *first_lang = langs.get (); + hb_language_item_t *first_lang = langs; for (hb_language_item_t *lang = first_lang; lang; lang = lang->next) if (*lang == key) @@ -408,7 +408,7 @@ hb_language_get_default (void) { static hb_atomic_ptr_t <hb_language_t> default_language; - hb_language_t language = default_language.get (); + hb_language_t language = default_language; if (unlikely (language == HB_LANGUAGE_INVALID)) { language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc index 184db4944a9..893a8761da5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc @@ -353,7 +353,7 @@ hb_coretext_font_create (CTFontRef ct_font) hb_font_t *font = hb_font_create (face); hb_face_destroy (face); - if (unlikely (hb_object_is_inert (font))) + if (unlikely (hb_object_is_immutable (font))) return font; hb_font_set_ptem (font, coretext_font_size_to_ptem (CTFontGetSize(ct_font))); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh index e8bd95c276c..9ccd7f25538 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh @@ -539,19 +539,25 @@ struct hb_bytes_t unsigned int len; }; -template <typename T> +template <typename Type> struct hb_array_t { inline hb_array_t (void) : arrayZ (nullptr), len (0) {} - inline hb_array_t (T *array_, unsigned int len_) : arrayZ (array_), len (len_) {} + inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} - inline T& operator [] (unsigned int i) const + inline Type& operator [] (unsigned int i) const { - if (unlikely (i >= len)) return Null(T); + if (unlikely (i >= len)) return Null(Type); return arrayZ[i]; } - inline hb_array_t<T> sub_array (unsigned int start_offset, unsigned int seg_count) const + inline unsigned int get_size (void) const { return len * sizeof (Type); } + + template <typename T> inline operator T * (void) const { return arrayZ; } + + inline Type * operator & (void) const { return arrayZ; } + + inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const { unsigned int count = len; if (unlikely (start_offset > count)) @@ -559,21 +565,19 @@ struct hb_array_t else count -= start_offset; count = MIN (count, seg_count); - return hb_array_t<T> (arrayZ + start_offset, count); + return hb_array_t<Type> (arrayZ + start_offset, count); } inline hb_bytes_t as_bytes (void) const { - return hb_bytes_t (arrayZ, len * sizeof (T)); + return hb_bytes_t (arrayZ, len * sizeof (Type)); } inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } - T *arrayZ; + Type *arrayZ; unsigned int len; }; -template <typename T> static inline -hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); } struct HbOpOr @@ -610,8 +614,10 @@ struct HbOpXor template <typename elt_t, unsigned int byte_size> struct hb_vector_size_t { - elt_t& operator [] (unsigned int i) { return u.v[i]; } - const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + inline elt_t& operator [] (unsigned int i) { return u.v[i]; } + inline const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + + inline void clear (unsigned char v = 0) { memset (this, v, sizeof (*this)); } template <class Op> inline hb_vector_size_t process (const hb_vector_size_t &o) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc index 7ca4b1ba25e..a0f8047f314 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc @@ -82,8 +82,6 @@ DEFINE_NULL_INSTANCE (hb_face_t) = { HB_OBJECT_HEADER_STATIC, - true, /* immutable */ - nullptr, /* reference_table_func */ nullptr, /* user_data */ nullptr, /* destroy */ @@ -265,7 +263,7 @@ hb_face_destroy (hb_face_t *face) { if (!hb_object_destroy (face)) return; - for (hb_face_t::plan_node_t *node = face->shape_plans.get (); node; ) + for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) { hb_face_t::plan_node_t *next = node->next; hb_shape_plan_destroy (node->shape_plan); @@ -336,12 +334,10 @@ hb_face_get_user_data (const hb_face_t *face, void hb_face_make_immutable (hb_face_t *face) { - if (unlikely (hb_object_is_inert (face))) - return; - if (face->immutable) + if (hb_object_is_immutable (face)) return; - face->immutable = true; + hb_object_make_immutable (face); } /** @@ -357,7 +353,7 @@ hb_face_make_immutable (hb_face_t *face) hb_bool_t hb_face_is_immutable (const hb_face_t *face) { - return face->immutable; + return hb_object_is_immutable (face); } @@ -408,7 +404,7 @@ void hb_face_set_index (hb_face_t *face, unsigned int index) { - if (face->immutable) + if (hb_object_is_immutable (face)) return; face->index = index; @@ -443,7 +439,7 @@ void hb_face_set_upem (hb_face_t *face, unsigned int upem) { - if (face->immutable) + if (hb_object_is_immutable (face)) return; face->upem = upem; @@ -478,7 +474,7 @@ void hb_face_set_glyph_count (hb_face_t *face, unsigned int glyph_count) { - if (face->immutable) + if (hb_object_is_immutable (face)) return; face->num_glyphs = glyph_count; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh index 89673ff8424..520bdfdf81a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh @@ -43,8 +43,6 @@ struct hb_face_t { hb_object_header_t header; - hb_bool_t immutable; - hb_reference_table_func_t reference_table_func; void *user_data; hb_destroy_func_t destroy; 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 135d310ca97..b24995b12ed 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -54,23 +54,23 @@ static hb_bool_t hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, - hb_font_extents_t *metrics, + hb_font_extents_t *extents, void *user_data HB_UNUSED) { - memset (metrics, 0, sizeof (*metrics)); + memset (extents, 0, sizeof (*extents)); return false; } static hb_bool_t hb_font_get_font_h_extents_default (hb_font_t *font, void *font_data HB_UNUSED, - hb_font_extents_t *metrics, + hb_font_extents_t *extents, void *user_data HB_UNUSED) { - hb_bool_t ret = font->parent->get_font_h_extents (metrics); + hb_bool_t ret = font->parent->get_font_h_extents (extents); if (ret) { - metrics->ascender = font->parent_scale_y_distance (metrics->ascender); - metrics->descender = font->parent_scale_y_distance (metrics->descender); - metrics->line_gap = font->parent_scale_y_distance (metrics->line_gap); + extents->ascender = font->parent_scale_y_distance (extents->ascender); + extents->descender = font->parent_scale_y_distance (extents->descender); + extents->line_gap = font->parent_scale_y_distance (extents->line_gap); } return ret; } @@ -78,23 +78,23 @@ hb_font_get_font_h_extents_default (hb_font_t *font, static hb_bool_t hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, - hb_font_extents_t *metrics, + hb_font_extents_t *extents, void *user_data HB_UNUSED) { - memset (metrics, 0, sizeof (*metrics)); + memset (extents, 0, sizeof (*extents)); return false; } static hb_bool_t hb_font_get_font_v_extents_default (hb_font_t *font, void *font_data HB_UNUSED, - hb_font_extents_t *metrics, + hb_font_extents_t *extents, void *user_data HB_UNUSED) { - hb_bool_t ret = font->parent->get_font_v_extents (metrics); + hb_bool_t ret = font->parent->get_font_v_extents (extents); if (ret) { - metrics->ascender = font->parent_scale_x_distance (metrics->ascender); - metrics->descender = font->parent_scale_x_distance (metrics->descender); - metrics->line_gap = font->parent_scale_x_distance (metrics->line_gap); + extents->ascender = font->parent_scale_x_distance (extents->ascender); + extents->descender = font->parent_scale_x_distance (extents->descender); + extents->line_gap = font->parent_scale_x_distance (extents->line_gap); } return ret; } @@ -471,8 +471,6 @@ DEFINE_NULL_INSTANCE (hb_font_funcs_t) = { HB_OBJECT_HEADER_STATIC, - true, /* immutable */ - { #define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS @@ -495,8 +493,6 @@ DEFINE_NULL_INSTANCE (hb_font_funcs_t) = static const hb_font_funcs_t _hb_font_funcs_default = { HB_OBJECT_HEADER_STATIC, - true, /* immutable */ - { #define HB_FONT_FUNC_IMPLEMENT(name) nullptr, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS @@ -645,12 +641,10 @@ hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, void hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) { - if (unlikely (hb_object_is_inert (ffuncs))) - return; - if (ffuncs->immutable) + if (hb_object_is_immutable (ffuncs)) return; - ffuncs->immutable = true; + hb_object_make_immutable (ffuncs); } /** @@ -666,7 +660,7 @@ hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) hb_bool_t hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs) { - return ffuncs->immutable; + return hb_object_is_immutable (ffuncs); } @@ -678,7 +672,7 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ void *user_data, \ hb_destroy_func_t destroy) \ { \ - if (ffuncs->immutable) { \ + if (hb_object_is_immutable (ffuncs)) { \ if (destroy) \ destroy (user_data); \ return; \ @@ -1299,8 +1293,6 @@ DEFINE_NULL_INSTANCE (hb_font_t) = { HB_OBJECT_HEADER_STATIC, - true, /* immutable */ - nullptr, /* parent */ const_cast<hb_face_t *> (&_hb_Null_hb_face_t), @@ -1385,7 +1377,7 @@ hb_font_create_sub_font (hb_font_t *parent) hb_font_t *font = _hb_font_create (parent->face); - if (unlikely (hb_object_is_inert (font))) + if (unlikely (hb_object_is_immutable (font))) return font; font->parent = hb_font_reference (parent); @@ -1525,15 +1517,13 @@ hb_font_get_user_data (hb_font_t *font, void hb_font_make_immutable (hb_font_t *font) { - if (unlikely (hb_object_is_inert (font))) - return; - if (font->immutable) + if (hb_object_is_immutable (font)) return; if (font->parent) hb_font_make_immutable (font->parent); - font->immutable = true; + hb_object_make_immutable (font); } /** @@ -1549,7 +1539,7 @@ hb_font_make_immutable (hb_font_t *font) hb_bool_t hb_font_is_immutable (hb_font_t *font) { - return font->immutable; + return hb_object_is_immutable (font); } /** @@ -1565,7 +1555,7 @@ void hb_font_set_parent (hb_font_t *font, hb_font_t *parent) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; if (!parent) @@ -1607,7 +1597,7 @@ void hb_font_set_face (hb_font_t *font, hb_face_t *face) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; if (unlikely (!face)) @@ -1654,7 +1644,8 @@ hb_font_set_funcs (hb_font_t *font, void *font_data, hb_destroy_func_t destroy) { - if (font->immutable) { + if (hb_object_is_immutable (font)) + { if (destroy) destroy (font_data); return; @@ -1689,7 +1680,8 @@ hb_font_set_funcs_data (hb_font_t *font, hb_destroy_func_t destroy) { /* Destroy user_data? */ - if (font->immutable) { + if (hb_object_is_immutable (font)) + { if (destroy) destroy (font_data); return; @@ -1718,7 +1710,7 @@ hb_font_set_scale (hb_font_t *font, int x_scale, int y_scale) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; font->x_scale = x_scale; @@ -1759,7 +1751,7 @@ hb_font_set_ppem (hb_font_t *font, unsigned int x_ppem, unsigned int y_ppem) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; font->x_ppem = x_ppem; @@ -1799,7 +1791,7 @@ hb_font_get_ppem (hb_font_t *font, void hb_font_set_ptem (hb_font_t *font, float ptem) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; font->ptem = ptem; @@ -1846,7 +1838,7 @@ hb_font_set_variations (hb_font_t *font, const hb_variation_t *variations, unsigned int variations_length) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; if (!variations_length) @@ -1877,7 +1869,7 @@ hb_font_set_var_coords_design (hb_font_t *font, const float *coords, unsigned int coords_length) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr; @@ -1898,7 +1890,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font, const int *coords, /* 2.14 normalized */ unsigned int coords_length) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr; 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 74c61aba487..e2086d8184f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h @@ -110,7 +110,7 @@ typedef struct hb_glyph_extents_t /* func types */ typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data, - hb_font_extents_t *metrics, + hb_font_extents_t *extents, void *user_data); typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t; typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh index 3dce233db3a..fb29bcc2289 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh @@ -63,8 +63,6 @@ struct hb_font_funcs_t { hb_object_header_t header; - hb_bool_t immutable; - struct { #define HB_FONT_FUNC_IMPLEMENT(name) void *name; HB_FONT_FUNCS_IMPLEMENT_CALLBACKS @@ -102,8 +100,6 @@ struct hb_font_t { hb_object_header_t header; - hb_bool_t immutable; - hb_font_t *parent; hb_face_t *face; 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 5e051105229..8b80b960ba3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -135,7 +135,7 @@ _hb_ft_font_destroy (void *data) void hb_ft_font_set_load_flags (hb_font_t *font, int load_flags) { - if (font->immutable) + if (hb_object_is_immutable (font)) return; if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc index 971241f92c1..24ee3d507ed 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc @@ -71,7 +71,7 @@ struct hb_graphite2_face_data_t static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) { hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); + hb_graphite2_tablelist_t *tlist = face_data->tlist; hb_blob_t *blob = nullptr; @@ -94,7 +94,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s p->tag = tag; retry: - hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); + hb_graphite2_tablelist_t *tlist = face_data->tlist; p->next = tlist; if (unlikely (!face_data->tlist.cmpexch (tlist, p))) @@ -110,7 +110,7 @@ retry: static void hb_graphite2_release_table(const void *data, const void *table_buffer) { hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist.get(); + hb_graphite2_tablelist_t *tlist = face_data->tlist; hb_graphite2_tablelist_t *prev = nullptr; hb_graphite2_tablelist_t *curr = tlist; @@ -164,7 +164,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) void _hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data) { - hb_graphite2_tablelist_t *tlist = data->tlist.get (); + hb_graphite2_tablelist_t *tlist = data->tlist; while (tlist) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh index 465bbb14f44..f58050da06a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh @@ -795,6 +795,7 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData> inline const Returned * operator -> (void) const { return get (); } inline const Returned & operator * (void) const { return *get (); } + template <typename C> inline operator const C * (void) const { return get (); } inline Data * get_data (void) const { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh index 3d8a1ae6cce..25a24f05cb4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -87,7 +87,7 @@ template <typename Type> static inline Type& Crap (void) { static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); Type *obj = reinterpret_cast<Type *> (_hb_CrapPool); - *obj = Null(Type); + memcpy (obj, &Null(Type), sizeof (*obj)); return *obj; } #define Crap(Type) Crap<typename hb_remove_const<typename hb_remove_reference<Type>::value>::value>() @@ -103,4 +103,28 @@ struct CrapOrNull<const Type> { #define CrapOrNull(Type) CrapOrNull<Type>::get () +/* + * hb_nonnull_ptr_t + */ + +template <typename P> +struct hb_nonnull_ptr_t +{ + typedef typename hb_remove_pointer<P>::value T; + + inline hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {} + inline T * operator = (T *v_) { return v = v_; } + inline T * operator -> (void) const { return get (); } + inline T & operator * (void) const { return *get (); } + inline T ** operator & (void) const { return &v; } + /* Only auto-cast to const types. */ + template <typename C> inline operator const C * (void) const { return get (); } + inline operator const char * (void) const { return (const char *) get (); } + inline T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); } + inline T * get_raw (void) const { return v; } + + T *v; +}; + + #endif /* HB_NULL_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh index 106f5920685..74340c555a8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh @@ -194,9 +194,15 @@ struct hb_user_data_array_t struct hb_object_header_t { hb_reference_count_t ref_count; + hb_atomic_int_t writable; hb_atomic_ptr_t<hb_user_data_array_t> user_data; }; -#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)} +#define HB_OBJECT_HEADER_STATIC \ + { \ + HB_REFERENCE_COUNT_INIT, \ + HB_ATOMIC_INT_INIT (false), \ + HB_ATOMIC_PTR_INIT (nullptr) \ + } /* @@ -228,6 +234,7 @@ template <typename Type> static inline void hb_object_init (Type *obj) { obj->header.ref_count.init (); + obj->header.writable.set_relaxed (true); obj->header.user_data.init (); } template <typename Type> @@ -241,6 +248,16 @@ static inline bool hb_object_is_valid (const Type *obj) return likely (obj->header.ref_count.is_valid ()); } template <typename Type> +static inline bool hb_object_is_immutable (const Type *obj) +{ + return !obj->header.writable.get_relaxed (); +} +template <typename Type> +static inline void hb_object_make_immutable (const Type *obj) +{ + obj->header.writable.set_relaxed (false); +} +template <typename Type> static inline Type *hb_object_reference (Type *obj) { hb_object_trace (obj, HB_FUNC); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh index 80dc5e614b1..2ef6d775f3f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh @@ -330,7 +330,7 @@ struct ResourceTypeRecord inline const ResourceRecord& get_resource_record (unsigned int i, const void *type_base) const { - return hb_array (type_base+resourcesZ, get_resource_count ())[i]; + return (type_base+resourcesZ).as_array (get_resource_count ())[i]; } inline bool sanitize (hb_sanitize_context_t *c, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh index e9f99b10487..0f6efdc6905 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh @@ -340,6 +340,15 @@ struct UnsizedArrayOf inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } inline Type& operator [] (unsigned int i) { return arrayZ[i]; } + template <typename T> inline operator T * (void) { return arrayZ; } + template <typename T> inline operator const T * (void) const { return arrayZ; } + + inline unsigned int get_size (unsigned int len) const + { return len * Type::static_size; } + + inline hb_array_t<Type> as_array (unsigned int len) { return hb_array_t<Type> (arrayZ, len); } + inline hb_array_t<const Type> as_array (unsigned int len) const { return hb_array_t<const Type> (arrayZ, len); } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); @@ -387,14 +396,6 @@ struct UnsizedArrayOf public: DEFINE_SIZE_ARRAY (0, arrayZ); }; -} /* namespace OT */ -template <typename T> static inline -hb_array_t<T> hb_array (OT::UnsizedArrayOf<T> &array, unsigned int len) -{ return hb_array (array.arrayZ, len); } -template <typename T> static inline -hb_array_t<const T> hb_array (const OT::UnsizedArrayOf<T> &array, unsigned int len) -{ return hb_array (array.arrayZ, len); } -namespace OT { /* Unsized array of offset's */ template <typename Type, typename OffsetType, bool has_null=true> @@ -450,6 +451,7 @@ struct ArrayOf if (unlikely (i >= len)) return Crap(Type); return arrayZ[i]; } + inline unsigned int get_size (void) const { return len.static_size + len * Type::static_size; } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh index a1c5a9747b1..bcb50790e40 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh @@ -1016,40 +1016,35 @@ struct cmap { this->blob = hb_sanitize_context_t().reference_table<cmap> (face); const cmap *table = this->blob->as<cmap> (); - const CmapSubtableFormat14 *subtable_uvs = nullptr; bool symbol; - subtable = table->find_best_subtable (&symbol); + subtableZ = table->find_best_subtable (&symbol); /* UVS subtable. */ - if (!subtable_uvs) + subtable_uvsZ = &Null(CmapSubtableFormat14); { const CmapSubtable *st = table->find_subtable (0, 5); if (st && st->u.format == 14) - subtable_uvs = &st->u.format14; + subtable_uvsZ = &st->u.format14; } - /* Meh. */ - if (!subtable_uvs) subtable_uvs = &Null(CmapSubtableFormat14); - this->subtable_uvs = subtable_uvs; - - this->get_glyph_data = subtable; + this->get_glyph_data = subtableZ; if (unlikely (symbol)) { - this->get_glyph_func = get_glyph_from_symbol<CmapSubtable>; + this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable>; } else { - switch (subtable->u.format) { + switch (subtableZ->u.format) { /* Accelerate format 4 and format 12. */ default: - this->get_glyph_func = get_glyph_from<CmapSubtable>; + this->get_glyph_funcZ = get_glyph_from<CmapSubtable>; break; case 12: - this->get_glyph_func = get_glyph_from<CmapSubtableFormat12>; + this->get_glyph_funcZ = get_glyph_from<CmapSubtableFormat12>; break; case 4: { - this->format4_accel.init (&subtable->u.format4); + this->format4_accel.init (&subtableZ->u.format4); this->get_glyph_data = &this->format4_accel; - this->get_glyph_func = this->format4_accel.get_glyph_func; + this->get_glyph_funcZ = this->format4_accel.get_glyph_func; } break; } @@ -1064,16 +1059,18 @@ struct cmap inline bool get_nominal_glyph (hb_codepoint_t unicode, hb_codepoint_t *glyph) const { - return this->get_glyph_func (this->get_glyph_data, unicode, glyph); + if (unlikely (!this->get_glyph_funcZ)) return false; + return this->get_glyph_funcZ (this->get_glyph_data, unicode, glyph); } inline bool get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, hb_codepoint_t *glyph) const { - switch (this->subtable_uvs->get_glyph_variant (unicode, - variation_selector, - glyph)) + if (unlikely (!this->subtable_uvsZ)) return false; + switch (this->subtable_uvsZ->get_glyph_variant (unicode, + variation_selector, + glyph)) { case GLYPH_VARIANT_NOT_FOUND: return false; case GLYPH_VARIANT_FOUND: return true; @@ -1085,16 +1082,19 @@ struct cmap inline void collect_unicodes (hb_set_t *out) const { - subtable->collect_unicodes (out); + if (unlikely (!this->subtableZ)) return; + subtableZ->collect_unicodes (out); } inline void collect_variation_selectors (hb_set_t *out) const { - subtable_uvs->collect_variation_selectors (out); + if (unlikely (!this->subtable_uvsZ)) return; + subtable_uvsZ->collect_variation_selectors (out); } inline void collect_variation_unicodes (hb_codepoint_t variation_selector, hb_set_t *out) const { - subtable_uvs->collect_variation_unicodes (variation_selector, out); + if (unlikely (!this->subtable_uvsZ)) return; + subtable_uvsZ->collect_variation_unicodes (variation_selector, out); } protected: @@ -1134,10 +1134,10 @@ struct cmap } private: - const CmapSubtable *subtable; - const CmapSubtableFormat14 *subtable_uvs; + const CmapSubtable *subtableZ; + const CmapSubtableFormat14 *subtable_uvsZ; - hb_cmap_get_glyph_func_t get_glyph_func; + hb_cmap_get_glyph_func_t get_glyph_funcZ; const void *get_glyph_data; CmapSubtableFormat4::accelerator_t format4_accel; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh index 614cc80ce2b..580dc37690f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh @@ -409,9 +409,6 @@ struct CBDT inline bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const { - if (!cblc) - return false; - const void *base; const BitmapSizeTable &strike = this->cblc->choose_strike (font); const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base); @@ -467,9 +464,6 @@ struct CBDT inline hb_blob_t* reference_png (hb_font_t *font, hb_codepoint_t glyph) const { - if (!cblc) - return hb_blob_get_empty (); - const void *base; const BitmapSizeTable &strike = this->cblc->choose_strike (font); const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base); @@ -525,8 +519,8 @@ struct CBDT private: hb_blob_t *cblc_blob; hb_blob_t *cbdt_blob; - const CBLC *cblc; - const CBDT *cbdt; + hb_nonnull_ptr_t<const CBLC> cblc; + hb_nonnull_ptr_t<const CBDT> cbdt; unsigned int cbdt_len; unsigned int upem; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh index df4d9b4e7f1..332f0dd7452 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh @@ -55,7 +55,7 @@ struct CPALV1Tail { if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT; return (hb_ot_color_palette_flags_t) (uint32_t) - hb_array (base+paletteFlagsZ, palette_count)[palette_index]; + (base+paletteFlagsZ).as_array (palette_count)[palette_index]; } inline hb_ot_name_id_t @@ -64,7 +64,7 @@ struct CPALV1Tail unsigned int palette_count) const { if (!paletteLabelsZ) return HB_OT_NAME_ID_INVALID; - return hb_array (base+paletteLabelsZ, palette_count)[palette_index]; + return (base+paletteLabelsZ).as_array (palette_count)[palette_index]; } inline hb_ot_name_id_t @@ -73,7 +73,7 @@ struct CPALV1Tail unsigned int color_count) const { if (!colorLabelsZ) return HB_OT_NAME_ID_INVALID; - return hb_array (base+colorLabelsZ, color_count)[color_index]; + return (base+colorLabelsZ).as_array (color_count)[color_index]; } public: diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh index 4feb4e19374..7a01d14ae78 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh @@ -152,9 +152,6 @@ struct sbix inline bool has_data () const { - /* XXX Fix somehow and remove next line. - * https://github.com/harfbuzz/harfbuzz/issues/1146 */ - if (!num_glyphs) return false; return table->has_data (); } @@ -234,8 +231,8 @@ struct sbix hb_codepoint_t glyph, hb_glyph_extents_t *extents) const { - /* Following code is safe to call even without data (XXX currently - * isn't. See has_data()), but faster to short-circuit. */ + /* Following code is safe to call even without data. + * But faster to short-circuit. */ if (!has_data ()) return false; @@ -243,12 +240,6 @@ struct sbix unsigned int strike_ppem = 0; hb_blob_t *blob = reference_png (font, glyph, &x_offset, &y_offset, &strike_ppem); - if (unlikely (blob->length < sizeof (PNGHeader))) - { - hb_blob_destroy (blob); - return false; - } - const PNGHeader &png = *blob->as<PNGHeader>(); extents->x_bearing = x_offset; @@ -268,12 +259,12 @@ struct sbix hb_blob_destroy (blob); - return true; + return strike_ppem; } private: hb_blob_t *sbix_blob; - const sbix *table; + hb_nonnull_ptr_t<const sbix> table; unsigned int num_glyphs; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh index bb4c4f757c8..069c547889a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh @@ -75,12 +75,13 @@ struct SVG { static const hb_tag_t tableTag = HB_OT_TAG_SVG; + inline bool has_data (void) const { return svgDocEntries; } + struct accelerator_t { inline void init (hb_face_t *face) { svg_blob = hb_sanitize_context_t().reference_table<SVG> (face); - svg_len = hb_blob_get_length (svg_blob); table = svg_blob->as<SVG> (); } @@ -91,18 +92,14 @@ struct SVG inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const { - if (unlikely (!svg_len)) - return hb_blob_get_empty (); return table->get_glyph_entry (glyph_id).reference_blob (svg_blob, table->svgDocEntries); } - inline bool has_data () const { return svg_len; } + inline bool has_data () const { return table->has_data (); } private: hb_blob_t *svg_blob; - const SVG *table; - - unsigned int svg_len; + hb_nonnull_ptr_t<const SVG> table; }; inline const SVGDocumentIndexEntry &get_glyph_entry (hb_codepoint_t glyph_id) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc index b87ed56fa4a..853f65dcf65 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc @@ -54,35 +54,35 @@ static inline const OT::COLR& _get_colr (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR); - return *(hb_ot_face_data (face)->COLR.get ()); + return *(hb_ot_face_data (face)->COLR); } static inline const OT::CBDT_accelerator_t& _get_cbdt (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CBDT_accelerator_t); - return *(hb_ot_face_data (face)->CBDT.get ()); + return *(hb_ot_face_data (face)->CBDT); } static inline const OT::CPAL& _get_cpal (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL); - return *(hb_ot_face_data (face)->CPAL.get ()); + return *(hb_ot_face_data (face)->CPAL); } static inline const OT::sbix_accelerator_t& _get_sbix (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix_accelerator_t); - return *(hb_ot_face_data (face)->sbix.get ()); + return *(hb_ot_face_data (face)->sbix); } static inline const OT::SVG_accelerator_t& _get_svg (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG_accelerator_t); - return *(hb_ot_face_data (face)->SVG.get ()); + return *(hb_ot_face_data (face)->SVG); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh index f3b7945bbd2..caa1d97ef1b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh @@ -52,6 +52,7 @@ HB_OT_TABLE(OT, BASE) \ /* AAT shaping. */ \ HB_OT_TABLE(AAT, morx) \ + HB_OT_TABLE(AAT, mort) \ HB_OT_TABLE(AAT, kerx) \ HB_OT_TABLE(AAT, ankr) \ HB_OT_TABLE(AAT, trak) \ @@ -66,7 +67,7 @@ HB_OT_ACCELERATOR(OT, hmtx) \ HB_OT_ACCELERATOR(OT, vmtx) \ HB_OT_ACCELERATOR(OT, post) \ - HB_OT_ACCELERATOR(OT, kern) \ + HB_OT_TABLE(OT, kern) \ HB_OT_ACCELERATOR(OT, glyf) \ HB_OT_TABLE(OT, VORG) \ HB_OT_ACCELERATOR(OT, name) \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc index 33a4388cebe..41bea140523 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc @@ -62,7 +62,7 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - return ot_face->cmap.get ()->get_nominal_glyph (unicode, glyph); + return ot_face->cmap->get_nominal_glyph (unicode, glyph); } static unsigned int @@ -76,7 +76,7 @@ hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::cmap_accelerator_t &cmap = *ot_face->cmap.get (); + const OT::cmap_accelerator_t &cmap = *ot_face->cmap; unsigned int done; for (done = 0; done < count && cmap.get_nominal_glyph (*first_unicode, first_glyph); @@ -97,7 +97,7 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - return ot_face->cmap.get ()->get_variation_glyph (unicode, variation_selector, glyph); + return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph); } static void @@ -110,7 +110,7 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get (); + const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx; for (unsigned int i = 0; i < count; i++) { @@ -130,7 +130,7 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; for (unsigned int i = 0; i < count; i++) { @@ -152,7 +152,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font, *x = font->get_glyph_h_advance (glyph) / 2; - const OT::VORG &VORG = *ot_face->VORG.get (); + const OT::VORG &VORG = *ot_face->VORG; if (VORG.has_data ()) { *y = font->em_scale_y (VORG.get_y_origin (glyph)); @@ -162,7 +162,7 @@ hb_ot_get_glyph_v_origin (hb_font_t *font, hb_glyph_extents_t extents = {0}; if (ot_face->glyf->get_extents (glyph, &extents)) { - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; hb_position_t tsb = vmtx.get_side_bearing (glyph); *y = font->em_scale_y (extents.y_bearing + tsb); return true; @@ -225,7 +225,7 @@ hb_ot_get_font_h_extents (hb_font_t *font, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get (); + const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx; metrics->ascender = font->em_scale_y (hmtx.ascender); metrics->descender = font->em_scale_y (hmtx.descender); metrics->line_gap = font->em_scale_y (hmtx.line_gap); @@ -240,7 +240,7 @@ hb_ot_get_font_v_extents (hb_font_t *font, void *user_data HB_UNUSED) { const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; - const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx; metrics->ascender = font->em_scale_x (vmtx.ascender); metrics->descender = font->em_scale_x (vmtx.descender); metrics->line_gap = font->em_scale_x (vmtx.line_gap); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh index 9437a83d870..d2a39f2300a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh @@ -55,6 +55,7 @@ struct loca protected: UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */ + public: DEFINE_SIZE_ARRAY (0, dataZ); }; @@ -275,7 +276,7 @@ struct glyf if (!get_offsets (glyph, &start_offset, &end_offset)) return false; /* glyph not found */ - return CompositeGlyphHeader::get_iterator ((const char*) this->glyf_table + start_offset, + return CompositeGlyphHeader::get_iterator ((const char *) this->glyf_table + start_offset, end_offset - start_offset, composite); } @@ -475,8 +476,8 @@ struct glyf private: bool short_offset; unsigned int num_glyphs; - const loca *loca_table; - const glyf *glyf_table; + hb_nonnull_ptr_t<const loca> loca_table; + hb_nonnull_ptr_t<const glyf> glyf_table; hb_blob_t *loca_blob; hb_blob_t *glyf_blob; unsigned int glyf_len; @@ -484,7 +485,7 @@ struct glyf protected: UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */ - + public: DEFINE_SIZE_ARRAY (0, dataZ); }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh index 60735858468..f898a0336a2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh @@ -194,8 +194,8 @@ struct hmtxvmtx bool got_font_extents = false; if (T::os2Tag) { - hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<os2> (face); - const os2 *os2_table = os2_blob->as<os2> (); + hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<OS2> (face); + const OS2 *os2_table = os2_blob->as<OS2> (); #define USE_TYPO_METRICS (1u<<7) if (0 != (os2_table->fsSelection & USE_TYPO_METRICS)) { @@ -255,7 +255,7 @@ struct hmtxvmtx if (glyph < num_advances) return table->longMetricZ[glyph].sb; - if (unlikely (glyph > num_metrics)) + if (unlikely (glyph >= num_metrics)) return 0; const FWORD *bearings = (const FWORD *) &table->longMetricZ[num_advances]; @@ -336,7 +336,7 @@ struct hmtxvmtx struct hmtx : hmtxvmtx<hmtx, hhea> { static const hb_tag_t tableTag = HB_OT_TAG_hmtx; static const hb_tag_t variationsTag = HB_OT_TAG_HVAR; - static const hb_tag_t os2Tag = HB_OT_TAG_os2; + static const hb_tag_t os2Tag = HB_OT_TAG_OS2; }; struct vmtx : hmtxvmtx<vmtx, vhea> { static const hb_tag_t tableTag = HB_OT_TAG_vmtx; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh index 63551d313cd..5bc9e436c74 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh @@ -30,6 +30,7 @@ #include "hb-open-type.hh" #include "hb-ot-shape.hh" #include "hb-ot-layout-gsubgpos.hh" +#include "hb-aat-layout-common.hh" template <typename Driver> @@ -165,6 +166,19 @@ struct KernSubTableFormat0 return pairs[i].get_kerning (); } + inline bool apply (AAT::hb_aat_apply_context_t *c) const + { + TRACE_APPLY (this); + + if (!c->plan->requested_kerning) + return false; + + hb_kern_machine_t<KernSubTableFormat0> machine (*this); + machine.kern (c->font, c->buffer, c->plan->kern_mask); + + return_trace (true); + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -177,6 +191,130 @@ struct KernSubTableFormat0 DEFINE_SIZE_ARRAY (8, pairs); }; +struct KernSubTableFormat1 +{ + typedef void EntryData; + + struct driver_context_t + { + static const bool in_place = true; + enum Flags + { + Push = 0x8000, /* If set, push this glyph on the kerning stack. */ + DontAdvance = 0x4000, /* If set, don't advance to the next glyph + * before going to the new state. */ + Offset = 0x3FFF, /* Byte offset from beginning of subtable to the + * value table for the glyphs on the kerning stack. */ + }; + + inline driver_context_t (const KernSubTableFormat1 *table_, + AAT::hb_aat_apply_context_t *c_) : + c (c_), + table (table_), + /* Apparently the offset kernAction is from the beginning of the state-machine, + * similar to offsets in morx table, NOT from beginning of this table, like + * other subtables in kerx. Discovered via testing. */ + kernAction (&table->machine + table->kernAction), + depth (0) {} + + inline bool is_actionable (AAT::StateTableDriver<AAT::MortTypes, EntryData> *driver HB_UNUSED, + const AAT::Entry<EntryData> *entry) + { + return entry->flags & Offset; + } + inline bool transition (AAT::StateTableDriver<AAT::MortTypes, EntryData> *driver, + const AAT::Entry<EntryData> *entry) + { + hb_buffer_t *buffer = driver->buffer; + unsigned int flags = entry->flags; + + if (flags & Push) + { + if (likely (depth < ARRAY_LENGTH (stack))) + stack[depth++] = buffer->idx; + else + depth = 0; /* Probably not what CoreText does, but better? */ + } + + if (entry->flags & Offset) + { + unsigned int kernIndex = AAT::MortTypes::offsetToIndex (entry->flags & Offset, &table->machine, kernAction.arrayZ); + const FWORD *actions = &kernAction[kernIndex]; + if (!c->sanitizer.check_array (actions, depth)) + { + depth = 0; + return false; + } + + hb_mask_t kern_mask = c->plan->kern_mask; + for (unsigned int i = 0; i < depth; i++) + { + /* Apparently, when spec says "Each pops one glyph from the kerning stack + * and applies the kerning value to it.", it doesn't mean it in that order. + * The deepest item in the stack corresponds to the first item in the action + * list. Discovered by testing. */ + unsigned int idx = stack[i]; + int v = *actions++; + if (idx < buffer->len && buffer->info[idx].mask & kern_mask) + { + if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + { + buffer->pos[idx].x_advance += c->font->em_scale_x (v); + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + buffer->pos[idx].x_offset += c->font->em_scale_x (v); + } + else + { + buffer->pos[idx].y_advance += c->font->em_scale_y (v); + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + buffer->pos[idx].y_offset += c->font->em_scale_y (v); + } + } + } + depth = 0; + } + + return true; + } + + private: + AAT::hb_aat_apply_context_t *c; + const KernSubTableFormat1 *table; + const UnsizedArrayOf<FWORD> &kernAction; + unsigned int stack[8]; + unsigned int depth; + }; + + inline bool apply (AAT::hb_aat_apply_context_t *c) const + { + TRACE_APPLY (this); + + if (!c->plan->requested_kerning) + return false; + + driver_context_t dc (this, c); + + AAT::StateTableDriver<AAT::MortTypes, EntryData> driver (machine, c->buffer, c->font->face); + driver.drive (&dc); + + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + /* The rest of array sanitizations are done at run-time. */ + return_trace (likely (c->check_struct (this) && + machine.sanitize (c))); + } + + protected: + AAT::StateTable<AAT::MortTypes, EntryData> machine; + OffsetTo<UnsizedArrayOf<FWORD>, HBUINT16, false> kernAction; + public: + DEFINE_SIZE_STATIC (10); +}; + struct KernClassTable { inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; } @@ -184,7 +322,8 @@ struct KernClassTable inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (firstGlyph.sanitize (c) && classes.sanitize (c)); + return_trace (c->check_struct (this) && + classes.sanitize (c)); } protected: @@ -196,29 +335,58 @@ struct KernClassTable struct KernSubTableFormat2 { - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const + inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, + AAT::hb_aat_apply_context_t *c) const { /* This subtable is disabled. It's not cleaer to me *exactly* where the offests are * based from. I *think* they should be based from beginning of kern subtable wrapper, * *NOT* "this". Since we know of no fonts that use this subtable, we are disabling - * it. Someday fix it and re-enable. Better yet, find fonts that use it... Meh, - * Windows doesn't implement it. Maybe just remove... */ + * it. Someday fix it and re-enable. */ return 0; unsigned int l = (this+leftClassTable).get_class (left); unsigned int r = (this+rightClassTable).get_class (right); unsigned int offset = l + r; const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset); +#if 0 if (unlikely ((const char *) v < (const char *) &array || (const char *) v > (const char *) end - 2)) +#endif return 0; return *v; } + inline bool apply (AAT::hb_aat_apply_context_t *c) const + { + TRACE_APPLY (this); + + if (!c->plan->requested_kerning) + return false; + + accelerator_t accel (*this, c); + hb_kern_machine_t<accelerator_t> machine (accel); + machine.kern (c->font, c->buffer, c->plan->kern_mask); + + return_trace (true); + } + + struct accelerator_t + { + const KernSubTableFormat2 &table; + AAT::hb_aat_apply_context_t *c; + + inline accelerator_t (const KernSubTableFormat2 &table_, + AAT::hb_aat_apply_context_t *c_) : + table (table_), c (c_) {} + + inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const + { return table.get_kerning (left, right, c); } + }; + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (true); /* Disabled. See above. */ - return_trace (rowWidth.sanitize (c) && + return_trace (c->check_struct (this) && leftClassTable.sanitize (c, this) && rightClassTable.sanitize (c, this) && array.sanitize (c, this)); @@ -239,23 +407,101 @@ struct KernSubTableFormat2 DEFINE_SIZE_MIN (8); }; +struct KernSubTableFormat3 +{ + inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const + { + hb_array_t<const FWORD> kernValue = kernValueZ.as_array (kernValueCount); + hb_array_t<const HBUINT8> leftClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (kernValue).as_array (glyphCount); + hb_array_t<const HBUINT8> rightClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (leftClass).as_array (glyphCount); + hb_array_t<const HBUINT8> kernIndex = StructAfter<const UnsizedArrayOf<HBUINT8> > (rightClass).as_array (leftClassCount * rightClassCount); + + unsigned int leftC = leftClass[left]; + unsigned int rightC = rightClass[right]; + if (unlikely (leftC >= leftClassCount || rightC >= rightClassCount)) + return 0; + unsigned int i = leftC * rightClassCount + rightC; + return kernValue[kernIndex[i]]; + } + + inline bool apply (AAT::hb_aat_apply_context_t *c) const + { + TRACE_APPLY (this); + + if (!c->plan->requested_kerning) + return false; + + hb_kern_machine_t<KernSubTableFormat3> machine (*this); + machine.kern (c->font, c->buffer, c->plan->kern_mask); + + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + c->check_range (kernValueZ, + kernValueCount * sizeof (FWORD) + + glyphCount * 2 + + leftClassCount * rightClassCount)); + } + + protected: + HBUINT16 glyphCount; /* The number of glyphs in this font. */ + HBUINT8 kernValueCount; /* The number of kerning values. */ + HBUINT8 leftClassCount; /* The number of left-hand classes. */ + HBUINT8 rightClassCount;/* The number of right-hand classes. */ + HBUINT8 flags; /* Set to zero (reserved for future use). */ + UnsizedArrayOf<FWORD> + kernValueZ; /* The kerning values. + * Length kernValueCount. */ +#if 0 + UnsizedArrayOf<HBUINT8> + leftClass; /* The left-hand classes. + * Length glyphCount. */ + UnsizedArrayOf<HBUINT8> + RightClass; /* The right-hand classes. + * Length glyphCount. */ + UnsizedArrayOf<HBUINT8> + kernIndex; /* The indices into the kernValue array. + * Length leftClassCount * rightClassCount */ +#endif + public: + DEFINE_SIZE_ARRAY (6, kernValueZ); +}; + struct KernSubTable { - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end, unsigned int format) const + inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int format) const { switch (format) { + /* This method hooks up to hb_font_t's get_h_kerning. Only support Format0. */ case 0: return u.format0.get_kerning (left, right); - case 2: return u.format2.get_kerning (left, right, end); default:return 0; } } + inline void apply (AAT::hb_aat_apply_context_t *c, unsigned int format) const + { + /* TODO Switch to dispatch(). */ + switch (format) { + case 0: u.format0.apply (c); return; + case 1: u.format1.apply (c); return; + case 2: u.format2.apply (c); return; + case 3: u.format3.apply (c); return; + default: return; + } + } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int format) const { TRACE_SANITIZE (this); switch (format) { case 0: return_trace (u.format0.sanitize (c)); + case 1: return_trace (u.format1.sanitize (c)); case 2: return_trace (u.format2.sanitize (c)); + case 3: return_trace (u.format3.sanitize (c)); default:return_trace (true); } } @@ -263,7 +509,9 @@ struct KernSubTable protected: union { KernSubTableFormat0 format0; + KernSubTableFormat1 format1; KernSubTableFormat2 format2; + KernSubTableFormat3 format3; } u; public: DEFINE_SIZE_MIN (0); @@ -276,17 +524,23 @@ struct KernSubTableWrapper /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ inline const T* thiz (void) const { return static_cast<const T *> (this); } + inline bool is_supported (void) const + { return !(thiz()->coverage & T::CheckFlags); } + inline bool is_horizontal (void) const - { return (thiz()->coverage & T::CheckFlags) == T::CheckHorizontal; } + { return (thiz()->coverage & T::Direction) == T::CheckHorizontal; } inline bool is_override (void) const { return bool (thiz()->coverage & T::Override); } - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const - { return thiz()->subtable.get_kerning (left, right, end, thiz()->format); } + inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const + { return thiz()->subtable.get_kerning (left, right, thiz()->format); } - inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const - { return is_horizontal () ? get_kerning (left, right, end) : 0; } + inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const + { return is_supported () && is_horizontal () ? get_kerning (left, right) : 0; } + + inline void apply (AAT::hb_aat_apply_context_t *c) const + { thiz()->subtable.apply (c, thiz()->format); } inline unsigned int get_size (void) const { return thiz()->length; } @@ -313,14 +567,53 @@ struct KernTable unsigned int count = thiz()->nTables; for (unsigned int i = 0; i < count; i++) { - if (st->is_override ()) + if (st->is_supported () && st->is_override ()) v = 0; - v += st->get_h_kerning (left, right, st->length + (const char *) st); + v += st->get_h_kerning (left, right); st = &StructAfter<typename T::SubTableWrapper> (*st); } return v; } + inline void apply (AAT::hb_aat_apply_context_t *c) const + { + c->set_lookup_index (0); + const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ); + unsigned int count = thiz()->nTables; + /* If there's an override subtable, skip subtables before that. */ + unsigned int last_override = 0; + for (unsigned int i = 0; i < count; i++) + { + if (st->is_supported () && st->is_override ()) + last_override = i; + st = &StructAfter<typename T::SubTableWrapper> (*st); + } + st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ); + for (unsigned int i = 0; i < count; i++) + { + if (!st->is_supported ()) + goto skip; + + if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->is_horizontal ()) + goto skip; + + if (i < last_override) + goto skip; + + if (!c->buffer->message (c->font, "start kern subtable %d", c->lookup_index)) + goto skip; + + c->sanitizer.set_object (*st); + + st->apply (c); + + (void) c->buffer->message (c->font, "end kern subtable %d", c->lookup_index); + + skip: + st = &StructAfter<typename T::SubTableWrapper> (*st); + } + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -361,7 +654,7 @@ struct KernOT : KernTable<KernOT> Variation = 0x00u, /* Not supported. */ - CheckFlags = 0x07u, + CheckFlags = 0x06u, CheckHorizontal = 0x01u }; @@ -402,7 +695,7 @@ struct KernAAT : KernTable<KernAAT> Override = 0x00u, /* Not supported. */ - CheckFlags = 0xE0u, + CheckFlags = 0x60u, CheckHorizontal = 0x00u }; @@ -441,6 +734,16 @@ struct kern } } + inline void apply (AAT::hb_aat_apply_context_t *c) const + { + /* TODO Switch to dispatch(). */ + switch (u.major) { + case 0: u.ot.apply (c); return; + case 1: u.aat.apply (c); return; + default: return; + } + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -452,45 +755,6 @@ struct kern } } - struct accelerator_t - { - inline void init (hb_face_t *face) - { - blob = hb_sanitize_context_t().reference_table<kern> (face); - table = blob->as<kern> (); - } - inline void fini (void) - { - hb_blob_destroy (blob); - } - - inline bool has_data (void) const - { return table->has_data (); } - - inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const - { return table->get_h_kerning (left, right); } - - inline int get_kerning (hb_codepoint_t first, hb_codepoint_t second) const - { return get_h_kerning (first, second); } - - inline void apply (hb_font_t *font, - hb_buffer_t *buffer, - hb_mask_t kern_mask) const - { - /* We only apply horizontal kerning in this table. */ - if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) - return; - - hb_kern_machine_t<accelerator_t> machine (*this); - - machine.kern (font, buffer, kern_mask); - } - - private: - hb_blob_t *blob; - const kern *table; - }; - protected: union { HBUINT32 version32; @@ -502,8 +766,6 @@ struct kern DEFINE_SIZE_UNION (4, version32); }; -struct kern_accelerator_t : kern::accelerator_t {}; - } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh index 449e74550e9..582e60155b7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh @@ -1,6 +1,7 @@ /* * Copyright © 2016 Elie Roux <elie.roux@telecom-bretagne.eu> * Copyright © 2018 Google, Inc. + * Copyright © 2018 Ebrahim Byagowi * * This is part of HarfBuzz, a text shaping library. * @@ -31,6 +32,9 @@ #include "hb-open-type.hh" #include "hb-ot-layout-common.hh" +/* To be removed */ +typedef hb_tag_t hb_ot_layout_baseline_t; + namespace OT { /* @@ -38,19 +42,14 @@ namespace OT { * https://docs.microsoft.com/en-us/typography/opentype/spec/base */ - -/* XXX Review this. */ -#define NOT_INDEXED ((unsigned int) -1) - - struct BaseCoordFormat1 { - inline int get_coord (void) const { return coordinate; } + inline hb_position_t get_coord () const { return coordinate; } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); + return_trace (likely (c->check_struct (this))); } protected: @@ -62,7 +61,7 @@ struct BaseCoordFormat1 struct BaseCoordFormat2 { - inline int get_coord (void) const + inline hb_position_t get_coord () const { /* TODO */ return coordinate; @@ -86,37 +85,45 @@ struct BaseCoordFormat2 struct BaseCoordFormat3 { - inline int get_coord (void) const + inline hb_position_t get_coord (hb_font_t *font, + const VariationStore &var_store, + hb_direction_t direction) const { - /* TODO */ - return coordinate; + const Device &device = this+deviceTable; + return coordinate + (HB_DIRECTION_IS_VERTICAL (direction) ? + device.get_y_delta (font, var_store) : + device.get_x_delta (font, var_store)); } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && deviceTable.sanitize (c, this)); + return_trace (likely (c->check_struct (this) && + deviceTable.sanitize (c, this))); } protected: - HBUINT16 format; /* Format identifier--format = 3 */ - FWORD coordinate; /* X or Y value, in design units */ - OffsetTo<Device> deviceTable; /* Offset to Device table for X or - * Y value, from beginning of - * BaseCoord table (may be NULL). */ + HBUINT16 format; /* Format identifier--format = 3 */ + FWORD coordinate; /* X or Y value, in design units */ + OffsetTo<Device> + deviceTable; /* Offset to Device table for X or + * Y value, from beginning of + * BaseCoord table (may be NULL). */ public: DEFINE_SIZE_STATIC (6); }; struct BaseCoord { - inline int get_coord (void) const + inline hb_position_t get_coord (hb_font_t *font, + const VariationStore &var_store, + hb_direction_t direction) const { - /* XXX wire up direction and font. */ switch (u.format) { case 1: return u.format1.get_coord (); case 2: return u.format2.get_coord (); - case 3: return u.format3.get_coord (); + case 3: return u.format3.get_coord (font, var_store, direction); default:return 0; } } @@ -124,7 +131,7 @@ struct BaseCoord inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (!u.format.sanitize (c)) return_trace (false); + if (unlikely (!u.format.sanitize (c))) return_trace (false); switch (u.format) { case 1: return_trace (u.format1.sanitize (c)); case 2: return_trace (u.format2.sanitize (c)); @@ -146,28 +153,40 @@ struct BaseCoord struct FeatMinMaxRecord { - inline int get_min_value (void) const { return (this+minCoord).get_coord(); } - inline int get_max_value (void) const { return (this+maxCoord).get_coord(); } + static int cmp (const void *key_, const void *entry_) + { + hb_tag_t key = * (hb_tag_t *) key_; + const FeatMinMaxRecord &entry = * (const FeatMinMaxRecord *) entry_; + return key < (unsigned int) entry.tag ? -1 : + key > (unsigned int) entry.tag ? 1 : + 0; + } - inline const Tag& get_tag () const { return tag; } + inline void get_min_max (const BaseCoord **min, const BaseCoord **max) const + { + if (likely (min)) *min = &(this+minCoord); + if (likely (max)) *max = &(this+maxCoord); + } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - minCoord.sanitize (c, base) && - maxCoord.sanitize (c, base)); + return_trace (likely (c->check_struct (this) && + minCoord.sanitize (c, this) && + maxCoord.sanitize (c, this))); } protected: - Tag tag; /* 4-byte feature identification tag--must - * match feature tag in FeatureList */ - OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines - * the minimum extent value, from beginning - * of MinMax table (may be NULL) */ - OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines - * the maximum extent value, from beginning - * of MinMax table (may be NULL) */ + Tag tag; /* 4-byte feature identification tag--must + * match feature tag in FeatureList */ + OffsetTo<BaseCoord> + minCoord; /* Offset to BaseCoord table that defines + * the minimum extent value, from beginning + * of MinMax table (may be NULL) */ + OffsetTo<BaseCoord> + maxCoord; /* Offset to BaseCoord table that defines + * the maximum extent value, from beginning + * of MinMax table (may be NULL) */ public: DEFINE_SIZE_STATIC (8); @@ -175,257 +194,202 @@ struct FeatMinMaxRecord struct MinMax { - inline unsigned int get_feature_tag_index (Tag featureTableTag) const - { - /* TODO bsearch */ - unsigned int count = featMinMaxRecords.len; - for (unsigned int i = 0; i < count; i++) + inline void get_min_max (hb_tag_t feature_tag, + const BaseCoord **min, + const BaseCoord **max) const + { + const FeatMinMaxRecord *minMaxCoord = (const FeatMinMaxRecord *) + hb_bsearch (&feature_tag, featMinMaxRecords.arrayZ, + featMinMaxRecords.len, + FeatMinMaxRecord::static_size, + FeatMinMaxRecord::cmp); + if (minMaxCoord) + minMaxCoord->get_min_max (min, max); + else { - Tag tag = featMinMaxRecords[i].get_tag (); - int cmp = tag.cmp(featureTableTag); - if (cmp == 0) return i; - if (cmp > 0) return NOT_INDEXED; + if (likely (min)) *min = &(this+minCoord); + if (likely (max)) *max = &(this+maxCoord); } - return NOT_INDEXED; - } - - inline int get_min_value (unsigned int featureTableTagIndex) const - { - if (featureTableTagIndex == NOT_INDEXED) - return (this+minCoord).get_coord(); - return featMinMaxRecords[featureTableTagIndex].get_min_value(); - } - - inline int get_max_value (unsigned int featureTableTagIndex) const - { - if (featureTableTagIndex == NOT_INDEXED) - return (this+maxCoord).get_coord(); - return featMinMaxRecords[featureTableTagIndex].get_max_value(); } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - minCoord.sanitize (c, this) && - maxCoord.sanitize (c, this) && - featMinMaxRecords.sanitize (c, this)); + return_trace (likely (c->check_struct (this) && + minCoord.sanitize (c, this) && + maxCoord.sanitize (c, this) && + featMinMaxRecords.sanitize (c, this))); } protected: - OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines - * minimum extent value, from the beginning - * of MinMax table (may be NULL) */ - OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines - * maximum extent value, from the beginning - * of MinMax table (may be NULL) */ + OffsetTo<BaseCoord> + minCoord; /* Offset to BaseCoord table that defines + * minimum extent value, from the beginning + * of MinMax table (may be NULL) */ + OffsetTo<BaseCoord> + maxCoord; /* Offset to BaseCoord table that defines + * maximum extent value, from the beginning + * of MinMax table (may be NULL) */ ArrayOf<FeatMinMaxRecord> - featMinMaxRecords; /* Array of FeatMinMaxRecords, in alphabetical - * order by featureTableTag */ + featMinMaxRecords; + /* Array of FeatMinMaxRecords, in alphabetical + * order by featureTableTag */ public: DEFINE_SIZE_ARRAY (6, featMinMaxRecords); }; -/* TODO... */ -struct BaseLangSysRecord -{ - inline const Tag& get_tag(void) const - { return baseLangSysTag; } - - inline unsigned int get_feature_tag_index (Tag featureTableTag) const - { return (this+minMax).get_feature_tag_index( featureTableTag); } - - inline int get_min_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_min_value( featureTableTagIndex); } - - inline int get_max_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_max_value (featureTableTagIndex); } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - minMax.sanitize (c, base)); - } - - protected: - Tag baseLangSysTag; - OffsetTo<MinMax> minMax; - public: - DEFINE_SIZE_STATIC (6); - -}; - struct BaseValues { - inline unsigned int get_default_base_tag_index (void) const - { return defaultIndex; } - - inline int get_base_coord (unsigned int baselineTagIndex) const + inline const BaseCoord &get_base_coord (int baseline_tag_index) const { - return (this+baseCoords[baselineTagIndex]).get_coord (); + if (baseline_tag_index == -1) baseline_tag_index = defaultIndex; + return this+baseCoords[baseline_tag_index]; } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - baseCoords.sanitize (c, this)); + return_trace (likely (c->check_struct (this) && + baseCoords.sanitize (c, this))); } protected: - Index defaultIndex; - OffsetArrayOf<BaseCoord> baseCoords; + Index defaultIndex; /* Index number of default baseline for this + * script — equals index position of baseline tag + * in baselineTags array of the BaseTagList */ + OffsetArrayOf<BaseCoord> + baseCoords; /* Number of BaseCoord tables defined — should equal + * baseTagCount in the BaseTagList + * + * Array of offsets to BaseCoord tables, from beginning of + * BaseValues table — order matches baselineTags array in + * the BaseTagList */ public: DEFINE_SIZE_ARRAY (4, baseCoords); }; -struct BaseScript { - - inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const +struct BaseLangSysRecord +{ + static int cmp (const void *key_, const void *entry_) { - /* XXX bsearch */ - Tag tag; - int cmp; - unsigned int count = baseLangSysRecords.len; - for (unsigned int i = 0; i < count; i++) - { - tag = baseLangSysRecords[i].get_tag (); - // taking advantage of alphabetical order - cmp = tag.cmp(baseLangSysTag); - if (cmp == 0) return i; - if (cmp > 0) return NOT_INDEXED; - } - return NOT_INDEXED; + hb_tag_t key = * (hb_tag_t *) key_; + const BaseLangSysRecord &entry = * (const BaseLangSysRecord *) entry_; + return key < (unsigned int) entry.baseLangSysTag ? -1 : + key > (unsigned int) entry.baseLangSysTag ? 1 : + 0; } - inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const - { - if (baseLangSysIndex == NOT_INDEXED) - { - if (unlikely(defaultMinMax)) return NOT_INDEXED; - return (this+defaultMinMax).get_feature_tag_index (featureTableTag); - } - return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index (featureTableTag); - } + inline const MinMax &get_min_max () const + { return this+minMax; } - inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { - if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value (featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && + minMax.sanitize (c, this))); } - inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + protected: + Tag baseLangSysTag; /* 4-byte language system identification tag */ + OffsetTo<MinMax> + minMax; /* Offset to MinMax table, from beginning + * of BaseScript table */ + public: + DEFINE_SIZE_STATIC (6); +}; + +struct BaseScript +{ + inline const MinMax &get_min_max (hb_tag_t language_tag) const { - if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value (featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); + const BaseLangSysRecord* record = (const BaseLangSysRecord *) + hb_bsearch (&language_tag, baseLangSysRecords.arrayZ, + baseLangSysRecords.len, + BaseLangSysRecord::static_size, + BaseLangSysRecord::cmp); + return record ? record->get_min_max () : this+defaultMinMax; } - inline unsigned int get_default_base_tag_index (void) const - { return (this+baseValues).get_default_base_tag_index (); } + inline const BaseCoord &get_base_coord (int baseline_tag_index) const + { return (this+baseValues).get_base_coord (baseline_tag_index); } - inline int get_base_coord (unsigned int baselineTagIndex) const - { return (this+baseValues).get_base_coord (baselineTagIndex); } + inline bool is_empty () const + { return !baseValues; } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - baseValues.sanitize (c, this) && - defaultMinMax.sanitize (c, this) && - baseLangSysRecords.sanitize (c, this)); + return_trace (likely (c->check_struct (this) && + baseValues.sanitize (c, this) && + defaultMinMax.sanitize (c, this) && + baseLangSysRecords.sanitize (c, this))); } protected: - OffsetTo<BaseValues> baseValues; - OffsetTo<MinMax> defaultMinMax; - ArrayOf<BaseLangSysRecord> baseLangSysRecords; + OffsetTo<BaseValues> + baseValues; /* Offset to BaseValues table, from beginning + * of BaseScript table (may be NULL) */ + OffsetTo<MinMax> + defaultMinMax; /* Offset to MinMax table, from beginning of + * BaseScript table (may be NULL) */ + ArrayOf<BaseLangSysRecord> + baseLangSysRecords; + /* Number of BaseLangSysRecords + * defined — may be zero (0) */ public: - DEFINE_SIZE_ARRAY (6, baseLangSysRecords); + DEFINE_SIZE_ARRAY (6, baseLangSysRecords); }; +struct BaseScriptList; +struct BaseScriptRecord +{ + static int cmp (const void *key_, const void *entry_) + { + hb_tag_t key = * (hb_tag_t *) key_; + const BaseScriptRecord &entry = * (const BaseScriptRecord *) entry_; + return key < (unsigned int) entry.baseScriptTag ? -1 : + key > (unsigned int) entry.baseScriptTag ? 1 : + 0; + } -struct BaseScriptRecord { - - inline const Tag& get_tag (void) const - { return baseScriptTag; } - - inline unsigned int get_default_base_tag_index(void) const - { return (this+baseScript).get_default_base_tag_index (); } - - inline int get_base_coord(unsigned int baselineTagIndex) const - { return (this+baseScript).get_base_coord (baselineTagIndex); } - - inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const - { return (this+baseScript).get_lang_tag_index (baseLangSysTag); } - - inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const - { return (this+baseScript).get_feature_tag_index (baseLangSysIndex, featureTableTag); } - - inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { return (this+baseScript).get_max_value (baseLangSysIndex, featureTableTagIndex); } - - inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { return (this+baseScript).get_min_value (baseLangSysIndex, featureTableTagIndex); } + inline const BaseScript &get_base_script (const BaseScriptList *list) const + { return list+baseScript; } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - baseScript.sanitize (c, base)); + return_trace (likely (c->check_struct (this) && + baseScript.sanitize (c, base))); } protected: - Tag baseScriptTag; - OffsetTo<BaseScript> baseScript; + Tag baseScriptTag; /* 4-byte script identification tag */ + OffsetTo<BaseScript> + baseScript; /* Offset to BaseScript table, from beginning + * of BaseScriptList */ public: - DEFINE_SIZE_STATIC (6); + DEFINE_SIZE_STATIC (6); }; -struct BaseScriptList { - - inline unsigned int get_base_script_index (Tag baseScriptTag) const - { - /* XXX bsearch? */ - unsigned int count = baseScriptRecords.len; - for (unsigned int i = 0; i < count; i++) - if (baseScriptRecords[i].get_tag() == baseScriptTag) - return i; - return NOT_INDEXED; - } - - inline unsigned int get_default_base_tag_index (unsigned int baseScriptIndex) const - { - return baseScriptRecords[baseScriptIndex].get_default_base_tag_index(); - } - - inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const - { - return baseScriptRecords[baseScriptIndex].get_base_coord(baselineTagIndex); - } - - inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const +struct BaseScriptList +{ + inline const BaseScriptRecord *find_record (hb_tag_t script) const { - return baseScriptRecords[baseScriptIndex].get_lang_tag_index(baseLangSysTag); + return (const BaseScriptRecord *) hb_bsearch (&script, baseScriptRecords.arrayZ, + baseScriptRecords.len, + BaseScriptRecord::static_size, + BaseScriptRecord::cmp); } - inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const + /* TODO: Or client should handle fallback? */ + inline const BaseScript &get_base_script (hb_tag_t script) const { - return baseScriptRecords[baseScriptIndex].get_feature_tag_index(baseLangSysIndex, featureTableTag); - } + const BaseScriptRecord *record = find_record (script); + if (!record) record = find_record ((hb_script_t) HB_TAG ('D','F','L','T')); - inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return baseScriptRecords[baseScriptIndex].get_max_value(baseLangSysIndex, featureTableTagIndex); - } - - inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return baseScriptRecords[baseScriptIndex].get_min_value(baseLangSysIndex, featureTableTagIndex); + return record ? record->get_base_script (this) : Null (BaseScript); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -436,86 +400,61 @@ struct BaseScriptList { } protected: - ArrayOf<BaseScriptRecord> baseScriptRecords; + ArrayOf<BaseScriptRecord> + baseScriptRecords; public: DEFINE_SIZE_ARRAY (2, baseScriptRecords); }; -struct BaseTagList -{ - inline unsigned int get_tag_index (Tag baselineTag) const - { - /* TODO bsearch? */ - unsigned int count = baselineTags.len; - for (unsigned int i = 0; i < count; i++) - if (baselineTags[i] == baselineTag) - return i; - return NOT_INDEXED; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - protected: - SortedArrayOf<Tag> baselineTags; - - public: - DEFINE_SIZE_ARRAY (2, baselineTags); -}; - struct Axis { - - inline unsigned int get_base_tag_index (Tag baselineTag) const + inline bool get_baseline (hb_ot_layout_baseline_t baseline, + hb_tag_t script_tag, + hb_tag_t language_tag, + const BaseCoord **coord) const { - return (this+baseTagList).get_tag_index(baselineTag); - } + const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); + if (base_script.is_empty ()) return false; - inline unsigned int get_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const - { - return (this+baseScriptList).get_default_base_tag_index(baseScriptIndex); - } + if (likely (coord)) *coord = &base_script.get_base_coord ((this+baseTagList).bsearch (baseline)); - inline int get_base_coord (unsigned int baseScriptIndex, unsigned int baselineTagIndex) const - { - return (this+baseScriptList).get_base_coord(baseScriptIndex, baselineTagIndex); + return true; } - inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const + inline bool get_min_max (hb_tag_t script_tag, + hb_tag_t language_tag, + hb_tag_t feature_tag, + const BaseCoord **min_coord, + const BaseCoord **max_coord) const { - return (this+baseScriptList).get_lang_tag_index(baseScriptIndex, baseLangSysTag); - } + const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); + if (base_script.is_empty ()) return false; - inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const - { - return (this+baseScriptList).get_feature_tag_index(baseScriptIndex, baseLangSysIndex, featureTableTag); - } + base_script.get_min_max (language_tag).get_min_max (feature_tag, min_coord, max_coord); - inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+baseScriptList).get_max_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex); - } - - inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+baseScriptList).get_min_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return true; } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - baseTagList.sanitize (c, this) && - baseScriptList.sanitize (c, this)); + return_trace (likely (c->check_struct (this) && + (this+baseTagList).sanitize (c) && + (this+baseScriptList).sanitize (c))); } protected: - OffsetTo<BaseTagList> baseTagList; - OffsetTo<BaseScriptList> baseScriptList; + OffsetTo<SortedArrayOf<Tag> > + baseTagList; /* Offset to BaseTagList table, from beginning + * of Axis table (may be NULL) + * Array of 4-byte baseline identification tags — must + * be in alphabetical order */ + OffsetTo<BaseScriptList> + baseScriptList; /* Offset to BaseScriptList table, from beginning + * of Axis table + * Array of BaseScriptRecords, in alphabetical order + * by baseScriptTag */ public: DEFINE_SIZE_STATIC (4); @@ -525,99 +464,70 @@ struct BASE { static const hb_tag_t tableTag = HB_OT_TAG_BASE; - inline bool has_v_axis(void) { return vAxis != 0; } - - inline bool has_h_axis(void) { return hAxis != 0; } + inline const Axis &get_axis (hb_direction_t direction) const + { return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; } - inline unsigned int get_h_base_tag_index (Tag baselineTag) const - { - return (this+hAxis).get_base_tag_index(baselineTag); - } + inline const VariationStore &get_var_store () const + { return version.to_int () < 0x00010001u ? Null (VariationStore) : this+varStore; } - inline unsigned int get_h_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const + inline bool get_baseline (hb_font_t *font, + hb_ot_layout_baseline_t baseline, + hb_direction_t direction, + hb_tag_t script_tag, + hb_tag_t language_tag, + hb_position_t *base) const { - return (this+hAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); - } + const BaseCoord *base_coord; + if (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord)) + return false; - inline int get_h_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const - { - return (this+hAxis).get_base_coord(baseScriptIndex, baselineTagIndex); + if (likely (base && base_coord)) *base = base_coord->get_coord (font, + get_var_store (), + direction); + return true; } - inline unsigned int get_v_base_tag_index(Tag baselineTag) const + /* TODO: Expose this separately sometime? */ + inline bool get_min_max (hb_font_t *font, + hb_direction_t direction, + hb_tag_t script_tag, + hb_tag_t language_tag, + hb_tag_t feature_tag, + hb_position_t *min, + hb_position_t *max) { - return (this+vAxis).get_base_tag_index(baselineTag); - } + const BaseCoord *min_coord, *max_coord; + if (!get_axis (direction).get_min_max (script_tag, language_tag, feature_tag, + &min_coord, &max_coord)) + return false; - inline unsigned int get_v_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const - { - return (this+vAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); - } - - inline int get_v_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const - { - return (this+vAxis).get_base_coord(baseScriptIndex, baselineTagIndex); - } - - inline unsigned int get_h_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const - { - return (this+hAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); - } - - inline unsigned int get_h_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const - { - return (this+hAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); - } - - inline int get_h_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+hAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); - } - - inline int get_h_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+hAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); - } - - inline unsigned int get_v_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const - { - return (this+vAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); - } - - inline unsigned int get_v_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const - { - return (this+vAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); - } - - inline int get_v_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+vAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); - } - - inline int get_v_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { - return (this+vAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + const VariationStore &var_store = get_var_store (); + if (likely (min && min_coord)) *min = min_coord->get_coord (font, var_store, direction); + if (likely (max && max_coord)) *max = max_coord->get_coord (font, var_store, direction); + return true; } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - likely (version.major == 1) && - hAxis.sanitize (c, this) && - vAxis.sanitize (c, this) && - (version.to_int () < 0x00010001u || varStore.sanitize (c, this))); + return_trace (likely (c->check_struct (this) && + likely (version.major == 1) && + hAxis.sanitize (c, this) && + vAxis.sanitize (c, this) && + (version.to_int () < 0x00010001u || varStore.sanitize (c, this)))); } protected: - FixedVersion<> version; - OffsetTo<Axis> hAxis; - OffsetTo<Axis> vAxis; + FixedVersion<>version; /* Version of the BASE table */ + OffsetTo<Axis>hAxis; /* Offset to horizontal Axis table, from beginning + * of BASE table (may be NULL) */ + OffsetTo<Axis>vAxis; /* Offset to vertical Axis table, from beginning + * of BASE table (may be NULL) */ LOffsetTo<VariationStore> - varStore; /* Offset to the table of Item Variation - * Store--from beginning of BASE - * header (may be NULL). Introduced - * in version 0x00010001. */ + varStore; /* Offset to the table of Item Variation + * Store--from beginning of BASE + * header (may be NULL). Introduced + * in version 0x00010001. */ public: DEFINE_SIZE_MIN (8); }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh index 757090861b0..5847953d3d1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh @@ -418,7 +418,7 @@ struct GDEF } hb_blob_t *blob; - const GDEF *table; + hb_nonnull_ptr_t<const GDEF> table; }; inline unsigned int get_size (void) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh index c4af42048e8..0d9eeae585a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh @@ -1308,7 +1308,8 @@ struct Rule inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); - const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > + (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); context_closure_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, @@ -1318,7 +1319,8 @@ struct Rule inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); - const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > + (inputZ.as_array (inputCount ? inputCount - 1 : 0)); context_collect_glyphs_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, @@ -1328,14 +1330,16 @@ struct Rule inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); - const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > + (inputZ.as_array (inputCount ? inputCount - 1 : 0)); return_trace (context_would_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); } inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); - const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > + (inputZ.as_array (inputCount ? inputCount - 1 : 0)); return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); } @@ -1686,7 +1690,7 @@ struct ContextFormat3 if (!(this+coverageZ[0]).intersects (c->glyphs)) return; - const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); struct ContextClosureLookupContext lookup_context = { {intersects_coverage}, this @@ -1702,7 +1706,7 @@ struct ContextFormat3 TRACE_COLLECT_GLYPHS (this); (this+coverageZ[0]).add_coverage (c->input); - const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); struct ContextCollectGlyphsLookupContext lookup_context = { {collect_coverage}, this @@ -1718,7 +1722,7 @@ struct ContextFormat3 { TRACE_WOULD_APPLY (this); - const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); struct ContextApplyLookupContext lookup_context = { {match_coverage}, this @@ -1735,7 +1739,7 @@ struct ContextFormat3 unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint); if (likely (index == NOT_COVERED)) return_trace (false); - const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); struct ContextApplyLookupContext lookup_context = { {match_coverage}, this @@ -1759,7 +1763,7 @@ struct ContextFormat3 if (!c->check_array (coverageZ.arrayZ, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) if (!coverageZ[i].sanitize (c, this)) return_trace (false); - const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * count); + const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); return_trace (c->check_array (lookupRecord, lookupCount)); } @@ -2770,7 +2774,7 @@ struct GSUBGPOS } hb_blob_t *blob; - const T *table; + hb_nonnull_ptr_t<const T> table; unsigned int lookup_count; hb_ot_layout_lookup_accelerator_t *accels; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc index e135e4a9ebe..fcdc79ee9bb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc @@ -37,10 +37,8 @@ #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-table.hh" - -// Just so we compile them; unused otherwise: -#include "hb-ot-layout-base-table.hh" -#include "hb-ot-layout-jstf-table.hh" +#include "hb-ot-layout-base-table.hh" // Just so we compile it; unused otherwise +#include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise #include "hb-ot-kern-table.hh" #include "hb-ot-name-table.hh" @@ -55,10 +53,19 @@ **/ -static const OT::kern::accelerator_t& _get_kern (hb_face_t *face) +static inline const OT::kern& +_get_kern (hb_face_t *face, hb_blob_t **blob = nullptr) { - if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::kern::accelerator_t); - return *hb_ot_face_data (face)->kern; + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) + { + if (blob) + *blob = hb_blob_get_empty (); + return Null(OT::kern); + } + const OT::kern& kern = *(hb_ot_face_data (face)->kern); + if (blob) + *blob = hb_ot_face_data (face)->kern.get_blob (); + return kern; } const OT::GDEF& _get_gdef (hb_face_t *face) { @@ -106,11 +113,16 @@ hb_ot_layout_has_kerning (hb_face_t *face) } void -hb_ot_layout_kern (hb_font_t *font, - hb_buffer_t *buffer, - hb_mask_t kern_mask) +hb_ot_layout_kern (hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer) { - _get_kern (font->face).apply (font, buffer, kern_mask); + hb_blob_t *blob; + const AAT::kern& kern = _get_kern (font->face, &blob); + + AAT::hb_aat_apply_context_t c (plan, font, buffer, blob); + + kern.apply (&c); } @@ -1411,3 +1423,62 @@ hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c, { apply_string<GSUBProxy> (c, lookup, accel); } + +#if 0 +static const OT::BASE& _get_base (hb_face_t *face) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE); + return *hb_ot_face_data (face)->BASE; +} + +hb_bool_t +hb_ot_layout_get_baseline (hb_font_t *font, + hb_ot_layout_baseline_t baseline, + hb_direction_t direction, + hb_tag_t script_tag, + hb_tag_t language_tag, + hb_position_t *coord /* OUT. May be NULL. */) +{ + const OT::BASE &base = _get_base (font->face); + bool result = base.get_baseline (font, baseline, direction, script_tag, + language_tag, coord); + + /* TODO: Simulate https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags#ideographic-em-box */ + if (!result && coord) *coord = 0; + + if (coord) *coord = font->em_scale_dir (*coord, direction); + + return result; +} + +/* To be moved to public header */ +/* + * BASE + */ + +/** + * hb_ot_layout_baseline_t: + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags + * + * Since: DONTREPLACEME + */ +typedef enum { + HB_OT_LAYOUT_BASELINE_HANG = HB_TAG('h','a','n','g'), + HB_OT_LAYOUT_BASELINE_ICFB = HB_TAG('i','c','f','b'), + HB_OT_LAYOUT_BASELINE_ICFT = HB_TAG('i','c','f','t'), + HB_OT_LAYOUT_BASELINE_IDEO = HB_TAG('i','d','e','o'), + HB_OT_LAYOUT_BASELINE_IDTB = HB_TAG('i','d','t','b'), + HB_OT_LAYOUT_BASELINE_MATH = HB_TAG('m','a','t','h'), + HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n') +} hb_ot_layout_baseline_t; + +HB_EXTERN hb_bool_t +hb_ot_layout_get_baseline (hb_font_t *font, + hb_ot_layout_baseline_t baseline, + hb_direction_t direction, + hb_tag_t script_tag, + hb_tag_t language_tag, + hb_position_t *coord /* OUT. May be NULL. */); + +#endif diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.h index 7a016c39082..e473954125e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.h @@ -391,22 +391,6 @@ hb_ot_layout_feature_get_characters (hb_face_t *face, unsigned int *char_count /* IN/OUT. May be NULL */, hb_codepoint_t *characters /* OUT. May be NULL */); -/* - * BASE - */ -#if 0 - -#define HB_OT_TAG_BASE_HANG HB_TAG('h','a','n','g') -#define HB_OT_TAG_BASE_ICFB HB_TAG('i','c','f','b') -#define HB_OT_TAG_BASE_ICFT HB_TAG('i','c','f','t') -#define HB_OT_TAG_BASE_IDEO HB_TAG('i','d','e','o') -#define HB_OT_TAG_BASE_IDTB HB_TAG('i','d','t','b') -#define HB_OT_TAG_BASE_MATH HB_TAG('m','a','t','h') -#define HB_OT_TAG_BASE_ROMN HB_TAG('r','o','m','n') - -#endif - - HB_END_DECLS #endif /* HB_OT_LAYOUT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh index 64b3d7480d6..b29f87c5a36 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh @@ -34,6 +34,7 @@ #include "hb-font.hh" #include "hb-buffer.hh" #include "hb-open-type.hh" +#include "hb-ot-shape.hh" #include "hb-set-digest.hh" @@ -48,6 +49,7 @@ HB_INTERNAL const OT::GDEF& _get_gdef (hb_face_t *face); HB_INTERNAL const OT::GSUB& _get_gsub_relaxed (hb_face_t *face); HB_INTERNAL const OT::GPOS& _get_gpos_relaxed (hb_face_t *face); +struct hb_ot_shape_plan_t; /* * kern @@ -57,9 +59,9 @@ HB_INTERNAL hb_bool_t hb_ot_layout_has_kerning (hb_face_t *face); HB_INTERNAL void -hb_ot_layout_kern (hb_font_t *font, - hb_buffer_t *buffer, - hb_mask_t kern_mask); +hb_ot_layout_kern (hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer); /* Private API corresponding to hb-ot-layout.h: */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math.cc index 92c29480db1..3fb720b20f7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math.cc @@ -45,7 +45,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_face_data_t * data = hb_ot_face_data (face); - return *(data->MATH.get ()); + return *(data->MATH); } /* diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh index 648f232d960..198dd2518c3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh @@ -92,7 +92,7 @@ struct maxp if (version.major == 1) { const maxpV1Tail &v1 = StructAfter<maxpV1Tail> (*this); - return v1.sanitize (c); + return_trace (v1.sanitize (c)); } return_trace (likely (version.major == 0 && version.minor == 0x5000u)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh index 9f67b5745b3..f1e785f19f7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh @@ -257,7 +257,7 @@ struct name const void *pool; unsigned int pool_len; public: - const name *table; + hb_nonnull_ptr_t<const name> table; hb_vector_t<hb_ot_name_entry_t> names; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc index e0c97108757..f2d1f0c2f71 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc @@ -46,13 +46,13 @@ static inline const OT::name_accelerator_t& _get_name (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::name_accelerator_t); - return *(hb_ot_face_data (face)->name.get ()); + return *(hb_ot_face_data (face)->name); } /** * hb_ot_name_list_names: * @face: font face. - * @num_entries: (out): number of returned entries. + * @num_entries: (out) (allow-none): number of returned entries. * * Enumerates all available name IDs and language combinations. Returned * array is owned by the @face and should not be modified. It can be @@ -66,7 +66,7 @@ hb_ot_name_list_names (hb_face_t *face, unsigned int *num_entries /* OUT */) { const OT::name_accelerator_t &name = _get_name (face); - *num_entries = name.names.len; + if (num_entries) *num_entries = name.names.len; return name.names.arrayZ(); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh index 71d2bf59d66..b2495128e81 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh @@ -36,11 +36,11 @@ namespace OT { * OS/2 and Windows Metrics * https://docs.microsoft.com/en-us/typography/opentype/spec/os2 */ -#define HB_OT_TAG_os2 HB_TAG('O','S','/','2') +#define HB_OT_TAG_OS2 HB_TAG('O','S','/','2') -struct os2 +struct OS2 { - static const hb_tag_t tableTag = HB_OT_TAG_os2; + static const hb_tag_t tableTag = HB_OT_TAG_OS2; inline bool sanitize (hb_sanitize_context_t *c) const { @@ -50,12 +50,12 @@ struct os2 inline bool subset (hb_subset_plan_t *plan) const { - hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<os2> (plan->source); + hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<OS2> (plan->source); hb_blob_t *os2_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1); // TODO(grieger): move to hb_blob_copy_writable_or_fail hb_blob_destroy (os2_blob); - os2 *os2_prime = (os2 *) hb_blob_get_data_writable (os2_prime_blob, nullptr); + OS2 *os2_prime = (OS2 *) hb_blob_get_data_writable (os2_prime_blob, nullptr); if (unlikely (!os2_prime)) { hb_blob_destroy (os2_prime_blob); return false; @@ -67,7 +67,7 @@ struct os2 os2_prime->usLastCharIndex.set (max_cp); _update_unicode_ranges (plan->unicodes, os2_prime->ulUnicodeRange); - bool result = plan->add_table (HB_OT_TAG_os2, os2_prime_blob); + bool result = plan->add_table (HB_OT_TAG_OS2, os2_prime_blob); hb_blob_destroy (os2_prime_blob); return result; 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 bd049f9ab97..b15a459b17e 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 @@ -254,7 +254,7 @@ struct post private: hb_blob_t *blob; uint32_t version; - const ArrayOf<HBUINT16> *glyphNameIndex; + hb_nonnull_ptr_t<const ArrayOf<HBUINT16> > glyphNameIndex; hb_vector_t<uint32_t, 1> index_to_offset; const uint8_t *pool; hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic.cc index 8e56dde3d7f..50a52136b7f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic.cc @@ -279,7 +279,7 @@ data_destroy_arabic (void *data) { arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) data; - arabic_fallback_plan_destroy (arabic_plan->fallback_plan.get ()); + arabic_fallback_plan_destroy (arabic_plan->fallback_plan); free (data); } @@ -389,7 +389,7 @@ arabic_fallback_shape (const hb_ot_shape_plan_t *plan, return; retry: - arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan.get (); + arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan; if (unlikely (!fallback_plan)) { /* This sucks. We need a font to build the fallback plan... */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc index 4f98f748024..8933c1822a8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc @@ -1018,7 +1018,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc index 1142da3ec3b..497891ea045 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc @@ -414,7 +414,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc index dcada261ce5..ca7b5a9b2d1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc @@ -343,7 +343,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-thai.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-thai.cc index b687fe61e3d..650c9800ac2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-thai.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-thai.cc @@ -357,8 +357,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan, buffer->merge_out_clusters (start - 1, end); } } - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->swap_buffers (); /* If font has Thai GSUB, we are done. */ if (plan->props.script == HB_SCRIPT_THAI && !plan->map.found_script[0]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc index 3ab77fc5860..af25b07f8cb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc @@ -552,7 +552,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, else buffer->next_glyph (); } - buffer->swap_buffers (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-vowel-constraints.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-vowel-constraints.cc index 20af8711eed..0e532581d94 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-vowel-constraints.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-vowel-constraints.cc @@ -429,9 +429,8 @@ _hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan HB_UNUSED, if (processed) { if (buffer->idx < count) - buffer->next_glyph (); - if (likely (buffer->successful)) - buffer->swap_buffers (); + buffer->next_glyph (); + buffer->swap_buffers (); } } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc index 94bc4afb165..766efe20d5b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc @@ -476,11 +476,9 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, hb_font_t *font, hb_buffer_t *buffer) { - if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) - return; - hb_glyph_info_t *info = buffer->info; hb_glyph_position_t *pos = buffer->pos; + bool horizontal = HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction); unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) if (_hb_glyph_info_is_unicode_space (&info[i]) && !_hb_glyph_info_ligated (&info[i])) @@ -501,27 +499,40 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, case t::SPACE_EM_5: case t::SPACE_EM_6: case t::SPACE_EM_16: - pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type; + if (horizontal) + pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type; + else + pos[i].y_advance = (font->y_scale + ((int) space_type)/2) / (int) space_type; break; case t::SPACE_4_EM_18: - pos[i].x_advance = (int64_t) font->x_scale * 4 / 18; + if (horizontal) + pos[i].x_advance = (int64_t) font->x_scale * 4 / 18; + else + pos[i].y_advance = (int64_t) font->y_scale * 4 / 18; break; case t::SPACE_FIGURE: for (char u = '0'; u <= '9'; u++) if (font->get_nominal_glyph (u, &glyph)) { - pos[i].x_advance = font->get_glyph_h_advance (glyph); + if (horizontal) + pos[i].x_advance = font->get_glyph_h_advance (glyph); + else + pos[i].y_advance = font->get_glyph_v_advance (glyph); break; } break; case t::SPACE_PUNCTUATION: - if (font->get_nominal_glyph ('.', &glyph)) - pos[i].x_advance = font->get_glyph_h_advance (glyph); - else if (font->get_nominal_glyph (',', &glyph)) - pos[i].x_advance = font->get_glyph_h_advance (glyph); + if (font->get_nominal_glyph ('.', &glyph) || + font->get_nominal_glyph (',', &glyph)) + { + if (horizontal) + pos[i].x_advance = font->get_glyph_h_advance (glyph); + else + pos[i].y_advance = font->get_glyph_v_advance (glyph); + } break; case t::SPACE_NARROW: @@ -530,7 +541,10 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, * However, in my testing, many fonts have their regular space being about that * size. To me, a percentage of the space width makes more sense. Half is as * good as any. */ - pos[i].x_advance /= 2; + if (horizontal) + pos[i].x_advance /= 2; + else + pos[i].y_advance /= 2; break; } } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc index c55d8dcb8b7..8c5e38e06dd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc @@ -425,7 +425,6 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) buffer->output_info (info); while (buffer->idx < buffer->len && buffer->successful) buffer->next_glyph (); - buffer->swap_buffers (); } @@ -918,7 +917,7 @@ hb_ot_position (const hb_ot_shape_context_t *c) /* Visual fallback goes here. */ if (c->plan->apply_kern) - hb_ot_layout_kern (c->font, c->buffer, c->plan->kern_mask); + hb_ot_layout_kern (c->plan, c->font, c->buffer); else if (c->plan->fallback_kerning) _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.cc index 64087be8117..4363f85ee7f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.cc @@ -51,15 +51,13 @@ static inline const OT::fvar& _get_fvar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar); - hb_ot_face_data_t *layout = hb_ot_face_data (face); - return *(layout->fvar.get ()); + return *(hb_ot_face_data (face)->fvar); } static inline const OT::avar& _get_avar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar); - hb_ot_face_data_t *layout = hb_ot_face_data (face); - return *(layout->avar.get ()); + return *(hb_ot_face_data (face)->avar); } /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh index 2dfcc242ae9..21a22525f88 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh @@ -53,8 +53,8 @@ struct hb_set_t struct page_t { - inline void init0 (void) { memset (reinterpret_cast<char*>(&v), 0, sizeof (v)); } - inline void init1 (void) { memset (reinterpret_cast<char*>(&v), 0xff, sizeof (v)); } + inline void init0 (void) { v.clear (); } + inline void init1 (void) { v.clear (0xFF); } inline unsigned int len (void) const { return ARRAY_LENGTH_CONST (v); } @@ -225,15 +225,17 @@ struct hb_set_t return true; } - inline void clear (void) { - if (unlikely (hb_object_is_inert (this))) + inline void clear (void) + { + if (unlikely (hb_object_is_immutable (this))) return; successful = true; population = 0; page_map.resize (0); pages.resize (0); } - inline bool is_empty (void) const { + inline bool is_empty (void) const + { unsigned int count = pages.len; for (unsigned int i = 0; i < count; i++) if (!pages[i].is_empty ()) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc index 4648cc7570e..f2f21019690 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc @@ -343,7 +343,7 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan, if (unlikely (!buffer->len)) return true; - assert (!hb_object_is_inert (buffer)); + assert (!hb_object_is_immutable (buffer)); assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE); if (unlikely (hb_object_is_inert (shape_plan))) @@ -532,7 +532,7 @@ hb_shape_plan_create_cached2 (hb_face_t *face, retry: - hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans.get (); + hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans; /* Don't look for plan in the cache if there were variation coordinates XXX Fix me. */ if (!hb_coords_present (coords, num_coords)) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc index e5507960d2a..3669e08b70d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc @@ -28,7 +28,6 @@ #include "hb-open-type.hh" #include "hb-ot-layout-common.hh" -#include "hb-aat-layout-ankr-table.hh" /* I don't even want to know why... */ #include "hb-aat-layout-common.hh" #include "hb-face.hh" 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 ed61c628fdb..a1c52c57a72 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc @@ -171,8 +171,8 @@ _subset_table (hb_subset_plan_t *plan, case HB_OT_TAG_cmap: result = _subset<const OT::cmap> (plan); break; - case HB_OT_TAG_os2: - result = _subset<const OT::os2> (plan); + case HB_OT_TAG_OS2: + result = _subset<const OT::OS2> (plan); break; case HB_OT_TAG_post: result = _subset<const OT::post> (plan); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc index 8cf7898a164..5accf3643cd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc @@ -187,7 +187,6 @@ DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) = HB_OBJECT_HEADER_STATIC, nullptr, /* parent */ - true, /* immutable */ { #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil, HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS @@ -303,12 +302,10 @@ hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs, void hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) { - if (unlikely (hb_object_is_inert (ufuncs))) - return; - if (ufuncs->immutable) + if (hb_object_is_immutable (ufuncs)) return; - ufuncs->immutable = true; + hb_object_make_immutable (ufuncs); } /** @@ -324,7 +321,7 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) hb_bool_t hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs) { - return ufuncs->immutable; + return hb_object_is_immutable (ufuncs); } /** @@ -352,7 +349,7 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \ void *user_data, \ hb_destroy_func_t destroy) \ { \ - if (ufuncs->immutable) \ + if (hb_object_is_immutable (ufuncs)) \ return; \ \ if (ufuncs->destroy.name) \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh index 0b66ce8a13b..d3fd5ea4bae 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh @@ -66,8 +66,6 @@ struct hb_unicode_funcs_t hb_unicode_funcs_t *parent; - bool immutable; - #define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \ inline return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); } HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc index 26b99ed157b..e77825b343f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc @@ -853,7 +853,13 @@ retry: #undef MAX_ITEMS - OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language)); + hb_tag_t lang_tag; + unsigned int lang_count = 1; + hb_ot_tags_from_script_and_language (buffer->props.script, + buffer->props.language, + nullptr, nullptr, + &lang_count, &lang_tag); + OPENTYPE_TAG language_tag = hb_uint32_swap (lang_count ? lang_tag : HB_TAG_NONE); hb_vector_t<TEXTRANGE_PROPERTIES*> range_properties; hb_vector_t<int> range_char_counts; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh index fa6a7404d9f..e3faf17c94f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh @@ -365,10 +365,10 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); #else /* __cpluspplus >= 201103L */ #define HB_NO_COPY_ASSIGN(TypeName) -#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) -#define HB_NO_CREATE_COPY_ASSIGN(TypeName) -#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE(TypeName, T) -#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) +#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) static_assert (true, "") +#define HB_NO_CREATE_COPY_ASSIGN(TypeName) static_assert (true, "") +#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE(TypeName, T) static_assert (true, "") +#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) static_assert (true, "") #endif /* __cpluspplus >= 201103L */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-ot-color.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-ot-color.cc index 2cb9b03b248..4b10e017743 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-ot-color.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-ot-color.cc @@ -40,74 +40,6 @@ #include <stdio.h> static void -png_dump (hb_face_t *face, unsigned int face_index) -{ - unsigned glyph_count = hb_face_get_glyph_count (face); - hb_font_t *font = hb_font_create (face); - - /* ugly hack, scans the font for strikes, not needed for regular clients */ - #define STRIKES_MAX 20 - unsigned int strikes_count = 0; - unsigned int strikes[STRIKES_MAX] = {0}; - { - /* find a sample glyph */ - unsigned int sample_glyph_id; - /* we don't care much about different strikes for different glyphs */ - for (sample_glyph_id = 0; sample_glyph_id < glyph_count; sample_glyph_id++) - { - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); - unsigned int blob_length = hb_blob_get_length (blob); - hb_blob_destroy (blob); - if (blob_length != 0) - break; - } - /* find strikes it has */ - unsigned int upem = hb_face_get_upem (face); - unsigned int blob_length = 0; - for (unsigned int ppem = 1; ppem <= upem && strikes_count < STRIKES_MAX; ppem++) - { - hb_font_set_ppem (font, ppem, ppem); - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); - unsigned int new_blob_length = hb_blob_get_length (blob); - if (blob_length != new_blob_length) - { - strikes_count++; - blob_length = new_blob_length; - } - if (strikes_count != 0) - strikes[strikes_count - 1] = ppem; - hb_blob_destroy (blob); - } - /* can't report the biggest strike correctly, and, we can't do anything about it */ - } - #undef STRIKES_MAX - - for (unsigned int strike = 0; strike < strikes_count; strike++) - for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++) - { - unsigned int ppem = strikes[strike]; - hb_font_set_ppem (font, ppem, ppem); - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, glyph_id); - - if (hb_blob_get_length (blob) == 0) continue; - - unsigned int length; - const char *data = hb_blob_get_data (blob, &length); - - char output_path[255]; - sprintf (output_path, "out/png-%d-%d-%d.png", glyph_id, strike, face_index); - - FILE *f = fopen (output_path, "wb"); - fwrite (data, 1, length, f); - fclose (f); - - hb_blob_destroy (blob); - } - - hb_font_destroy (font); -} - -static void svg_dump (hb_face_t *face, unsigned int face_index) { unsigned glyph_count = hb_face_get_glyph_count (face); @@ -136,6 +68,63 @@ svg_dump (hb_face_t *face, unsigned int face_index) } } +/* _png API is so easy to use unlike the below code, don't get confused */ +static void +png_dump (hb_face_t *face, unsigned int face_index) +{ + unsigned glyph_count = hb_face_get_glyph_count (face); + hb_font_t *font = hb_font_create (face); + + /* scans the font for strikes */ + unsigned int sample_glyph_id; + /* we don't care about different strikes for different glyphs at this point */ + for (sample_glyph_id = 0; sample_glyph_id < glyph_count; sample_glyph_id++) + { + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); + unsigned int blob_length = hb_blob_get_length (blob); + hb_blob_destroy (blob); + if (blob_length != 0) + break; + } + + unsigned int upem = hb_face_get_upem (face); + unsigned int blob_length = 0; + unsigned int strike = 0; + for (unsigned int ppem = 1; ppem < upem; ppem++) + { + hb_font_set_ppem (font, ppem, ppem); + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); + unsigned int new_blob_length = hb_blob_get_length (blob); + hb_blob_destroy (blob); + if (new_blob_length != blob_length) + { + for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++) + { + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, glyph_id); + + if (hb_blob_get_length (blob) == 0) continue; + + unsigned int length; + const char *data = hb_blob_get_data (blob, &length); + + char output_path[255]; + sprintf (output_path, "out/png-%d-%d-%d.png", glyph_id, strike, face_index); + + FILE *f = fopen (output_path, "wb"); + fwrite (data, 1, length, f); + fclose (f); + + hb_blob_destroy (blob); + } + + strike++; + blob_length = new_blob_length; + } + } + + hb_font_destroy (font); +} + static void layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int face_index) { @@ -144,7 +133,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int unsigned glyph_count = hb_face_get_glyph_count (face); for (hb_codepoint_t gid = 0; gid < glyph_count; ++gid) { - unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, nullptr, nullptr); + unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, NULL, NULL); if (!num_layers) continue; @@ -181,7 +170,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int for (unsigned int palette = 0; palette < palette_count; palette++) { char output_path[255]; - unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, nullptr, nullptr); + unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, NULL, NULL); if (!num_colors) continue; @@ -282,14 +271,14 @@ main (int argc, char **argv) FILE *font_name_file = fopen ("out/.dumped_font_name", "r"); - if (font_name_file != nullptr) + if (font_name_file != NULL) { fprintf (stderr, "Purge or move ./out folder in order to run a new dump\n"); exit (1); } font_name_file = fopen ("out/.dumped_font_name", "w"); - if (font_name_file == nullptr) + if (font_name_file == NULL) { fprintf (stderr, "./out is not accessible as a folder, create it please\n"); exit (1); diff --git a/Build/source/libs/harfbuzz/version.ac b/Build/source/libs/harfbuzz/version.ac index 3857ba51644..13d6eaea0dc 100644 --- a/Build/source/libs/harfbuzz/version.ac +++ b/Build/source/libs/harfbuzz/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current harfbuzz version -m4_define([harfbuzz_version], [2.1.0]) +m4_define([harfbuzz_version], [2.1.1]) |