diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-08-07 22:18:29 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-08-07 22:18:29 +0000 |
commit | 107a97e83d0d11cef7cf494660fc8bf730b3e13f (patch) | |
tree | fd1a16b582fc976e5a8869990a8cfcca1bb63375 /Build | |
parent | 2dd8fea11f36f8ba29c512d4e0a6d16b8e82cfdb (diff) |
harfbuzz 1.8.6
git-svn-id: svn://tug.org/texlive/trunk@48370 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
63 files changed, 2158 insertions, 1200 deletions
diff --git a/Build/source/libs/README b/Build/source/libs/README index b9f29d74df7..6948db9c0ca 100644 --- a/Build/source/libs/README +++ b/Build/source/libs/README @@ -24,7 +24,7 @@ gmp 6.1.2 - checked 16dec16 graphite2 1.3.11 - checked 05mar18 http://sourceforge.net/projects/silgraphite/files/graphite2/ -harfbuzz 1.8.5 - checked 03aug18 +harfbuzz 1.8.6 - checked 07aug18 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 3a1fa6076c8..3ef5e4b57eb 100644 --- a/Build/source/libs/harfbuzz/ChangeLog +++ b/Build/source/libs/harfbuzz/ChangeLog @@ -1,3 +1,8 @@ +2018-08-07 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + Import harfbuzz-1.8.6. + * version.ac, Makefile.am: Adjusted. + 2018-08-03 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Import harfbuzz-1.8.5. diff --git a/Build/source/libs/harfbuzz/Makefile.am b/Build/source/libs/harfbuzz/Makefile.am index 4091c07ffb0..b850fa1f1b3 100644 --- a/Build/source/libs/harfbuzz/Makefile.am +++ b/Build/source/libs/harfbuzz/Makefile.am @@ -49,6 +49,7 @@ libharfbuzz_a_SOURCES = \ @HARFBUZZ_TREE@/src/hb-map.cc \ @HARFBUZZ_TREE@/src/hb-machinery-private.hh \ @HARFBUZZ_TREE@/src/hb-mutex-private.hh \ + @HARFBUZZ_TREE@/src/hb-null.hh \ @HARFBUZZ_TREE@/src/hb-object-private.hh \ @HARFBUZZ_TREE@/src/hb-open-file-private.hh \ @HARFBUZZ_TREE@/src/hb-open-type-private.hh \ @@ -82,6 +83,7 @@ libharfbuzz_a_SOURCES = \ @HARFBUZZ_TREE@/src/hb-string-array.hh \ @HARFBUZZ_TREE@/src/hb-unicode-private.hh \ @HARFBUZZ_TREE@/src/hb-unicode.cc \ + @HARFBUZZ_TREE@/src/hb-vector-private.hh \ @HARFBUZZ_TREE@/src/hb-utf-private.hh \ @HARFBUZZ_TREE@/src/hb-warning.cc \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-json.hh \ diff --git a/Build/source/libs/harfbuzz/Makefile.in b/Build/source/libs/harfbuzz/Makefile.in index 680f294c00b..1263f1a8e49 100644 --- a/Build/source/libs/harfbuzz/Makefile.in +++ b/Build/source/libs/harfbuzz/Makefile.in @@ -714,6 +714,7 @@ libharfbuzz_a_SOURCES = @HARFBUZZ_TREE@/src/hb-atomic-private.hh \ @HARFBUZZ_TREE@/src/hb-map.cc \ @HARFBUZZ_TREE@/src/hb-machinery-private.hh \ @HARFBUZZ_TREE@/src/hb-mutex-private.hh \ + @HARFBUZZ_TREE@/src/hb-null.hh \ @HARFBUZZ_TREE@/src/hb-object-private.hh \ @HARFBUZZ_TREE@/src/hb-open-file-private.hh \ @HARFBUZZ_TREE@/src/hb-open-type-private.hh \ @@ -746,6 +747,7 @@ libharfbuzz_a_SOURCES = @HARFBUZZ_TREE@/src/hb-atomic-private.hh \ @HARFBUZZ_TREE@/src/hb-string-array.hh \ @HARFBUZZ_TREE@/src/hb-unicode-private.hh \ @HARFBUZZ_TREE@/src/hb-unicode.cc \ + @HARFBUZZ_TREE@/src/hb-vector-private.hh \ @HARFBUZZ_TREE@/src/hb-utf-private.hh \ @HARFBUZZ_TREE@/src/hb-warning.cc \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-json.hh \ diff --git a/Build/source/libs/harfbuzz/TLpatches/ChangeLog b/Build/source/libs/harfbuzz/TLpatches/ChangeLog index 10de7723d25..3c9fe1b4162 100644 --- a/Build/source/libs/harfbuzz/TLpatches/ChangeLog +++ b/Build/source/libs/harfbuzz/TLpatches/ChangeLog @@ -1,3 +1,8 @@ +2018-08-07 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + Imported harfbuzz-1.8.6 source tree from: + http://www.freedesktop.org/software/harfbuzz/release/ + 2018-08-03 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Imported harfbuzz-1.8.5 source tree from: diff --git a/Build/source/libs/harfbuzz/TLpatches/TL-Changes b/Build/source/libs/harfbuzz/TLpatches/TL-Changes index 3a0b7c86b9a..571498ea442 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-1.8.5/ tree as obtained from: +Changes applied to the harfbuzz-1.8.6/ 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 4ad07773dd0..867118c7d15 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) 1.8.5. +# Generated by GNU Autoconf 2.69 for harfbuzz (TeX Live) 1.8.6. # # 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='1.8.5' -PACKAGE_STRING='harfbuzz (TeX Live) 1.8.5' +PACKAGE_VERSION='1.8.6' +PACKAGE_STRING='harfbuzz (TeX Live) 1.8.6' 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) 1.8.5 to adapt to many kinds of systems. +\`configure' configures harfbuzz (TeX Live) 1.8.6 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) 1.8.5:";; + short | recursive ) echo "Configuration of harfbuzz (TeX Live) 1.8.6:";; 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 1.8.5 +harfbuzz (TeX Live) configure 1.8.6 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 1.8.5, which was +It was created by harfbuzz (TeX Live) $as_me 1.8.6, 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='1.8.5' + VERSION='1.8.6' # Some tools Automake needs. @@ -4248,8 +4248,8 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags HB_VERSION_MAJOR=1 HB_VERSION_MINOR=8 -HB_VERSION_MICRO=5 -HB_VERSION=1.8.5 +HB_VERSION_MICRO=6 +HB_VERSION=1.8.6 ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -8140,7 +8140,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 1.8.5, which was +This file was extended by harfbuzz (TeX Live) $as_me 1.8.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8206,7 +8206,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 1.8.5 +harfbuzz (TeX Live) config.status 1.8.6 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 97ac4f04e14..4b0b64c8cc6 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog +++ b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog @@ -1,3 +1,573 @@ +commit b0ff79acd804e47a2a3db73746cf9c6dc986950a +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Aug 7 09:52:06 2018 -0700 + + Add +hb_font_get_glyph_advances_for_direction + + New API: + +hb_font_get_glyph_advances_for_direction + + docs/harfbuzz-sections.txt | 1 + + src/hb-font-private.hh | 12 ++++++++++++ + src/hb-font.cc | 20 ++++++++++++++++++++ + src/hb-font.h | 8 ++++++++ + 4 files changed, 41 insertions(+) + +commit 28e2f467e1c7dd5e82d105efa8c4580dbfc93960 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Aug 7 09:47:00 2018 -0700 + + Actually add hb_font_get_glyph_[hv]_advances + + New API: + +hb_font_get_glyph_h_advances + +hb_font_get_glyph_v_advances + + src/hb-font.cc | 37 +++++++++++++++++++++++++++++++++++++ + src/hb-font.h | 15 +++++++++++++++ + 2 files changed, 52 insertions(+) + +commit 996775191a3fdeeeaee80e3123ef2240e6390b3d +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Aug 7 09:44:01 2018 -0700 + + Minor + + src/hb-font-private.hh | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +commit 3d7c555a19ca0725c386aa6da648ecf2ae50fc19 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Aug 7 09:37:52 2018 -0700 + + Remove get_advances_nil and alias it to get_advances_default + + src/hb-font.cc | 36 ++---------------------------------- + 1 file changed, 2 insertions(+), 34 deletions(-) + +commit 66920a6bace7c54c8166c4ed938b6ffc5fabcf2b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 15:32:13 2018 -0700 + + [iter] Make operator bool explicit + + We would need to write: + + for (Iter<T> it (...); bool (t); t++) + + instead of: + + for (Iter<T> it (...); t; t++) + + But I think it's an improvement in code readability in the long term. + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1127 + + src/hb-iter-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 79e21984b13bdb879f3007ba9a97fde47df340d3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 09:45:17 2018 -0700 + + Add batch advance width callback function + + New API: + +hb_font_funcs_set_glyph_h_advances_func + +hb_font_funcs_set_glyph_v_advances_func + +hb_font_get_glyph_h_advances + +hb_font_get_glyph_h_advances_func_t + +hb_font_get_glyph_v_advances + +hb_font_get_glyph_v_advances_func_t + + docs/harfbuzz-sections.txt | 6 + + src/hb-font-private.hh | 41 +++++-- + src/hb-font.cc | 299 + +++++++++++++++++++++++++++------------------ + src/hb-font.h | 53 ++++++-- + src/hb-ot-shape.cc | 3 +- + 5 files changed, 255 insertions(+), 147 deletions(-) + +commit 9533364cc3a8cccbae793de1873a727de73f64d5 +Author: Koji Ishii <kojii@chromium.org> +Date: Wed Aug 1 13:01:08 2018 +0900 + + batchwidth + + src/hb-font-private.hh | 13 +++++++++++++ + src/hb-font.cc | 37 +++++++++++++++++++++++++++++++++++++ + src/hb-font.h | 15 +++++++++++++++ + src/hb-ot-shape.cc | 4 ++-- + 4 files changed, 67 insertions(+), 2 deletions(-) + +commit b912fbea17c50e229977345012227810ed7641e9 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 06:30:12 2018 -0700 + + Remove most uses of direct comparison to Null objects + + src/hb-ot-glyf-table.hh | 6 +++--- + src/hb-ot-head-table.hh | 4 ++-- + src/hb-ot-layout-gdef-table.hh | 1 + + src/hb-ot-layout-gsubgpos-private.hh | 1 + + src/hb-ot-layout.cc | 6 +++--- + src/hb-ot-math-table.hh | 2 ++ + src/hb-ot-math.cc | 2 +- + src/hb-ot-shape-complex-arabic-fallback.hh | 3 ++- + src/hb-ot-var-fvar-table.hh | 2 ++ + src/hb-ot-var.cc | 2 +- + src/hb-subset.cc | 2 +- + src/main.cc | 2 +- + 12 files changed, 20 insertions(+), 13 deletions(-) + +commit 3506672ce9d8685ce4e113716b0d06adbc7981b7 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 06:17:48 2018 -0700 + + Port _nil objects to Null() machinery + + Finally, unified! + + src/hb-blob-private.hh | 1 + + src/hb-blob.cc | 29 ++++++------- + src/hb-buffer-private.hh | 4 +- + src/hb-buffer.cc | 44 ++++++++++---------- + src/hb-face-private.hh | 6 +-- + src/hb-face.cc | 5 ++- + src/hb-font-private.hh | 10 +++-- + src/hb-font.cc | 66 + ++++++++++++++++-------------- + src/hb-null.hh | 11 ++++- + src/hb-ot-shape-complex-arabic-fallback.hh | 11 +++-- + src/hb-shape-plan-private.hh | 1 + + src/hb-shape-plan.cc | 50 +++++++++++----------- + src/hb-unicode-private.hh | 7 ++-- + src/hb-unicode.cc | 5 ++- + 14 files changed, 137 insertions(+), 113 deletions(-) + +commit 1abd427acfb7229b8607646bdde59f29306b86e1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 05:53:35 2018 -0700 + + [BASE] Rename horzi/vert to h/v + + src/hb-ot-layout-base-table.hh | 68 + +++++++++++++++++++++--------------------- + 1 file changed, 34 insertions(+), 34 deletions(-) + +commit da48aca1be89efbb8b3ca4471f542aa54aff17c4 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 05:52:12 2018 -0700 + + [BASE] Misc fixes + + The code was badly broken. In better shape now, but still, needs + a full review before ever working. + + src/hb-ot-layout-base-table.hh | 163 + +++++++++++++++++------------------------ + 1 file changed, 68 insertions(+), 95 deletions(-) + +commit f9cfa5cb0e70203279e74fb6adb0cd4570238ff8 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 05:29:15 2018 -0700 + + Change null-pool specialization to min_size again + + src/hb-null.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 25147ff8086ab65995fe046cfdf8007604de6962 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 05:01:52 2018 -0700 + + Move Null system to hb-null.hh + + src/Makefile.sources | 1 + + src/hb-null.hh | 97 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-private.hh | 65 +---------------------------------- + 3 files changed, 99 insertions(+), 64 deletions(-) + +commit f800368df33e7ec15c3e77bdb9f4b464899322d3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 04:58:34 2018 -0700 + + Remove unused macros + + src/hb-object-private.hh | 1 - + src/hb-vector-private.hh | 1 - + 2 files changed, 2 deletions(-) + +commit 19e0091299f06856002c702792b448b06da637a8 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 04:54:31 2018 -0700 + + Minor + + src/hb-private.hh | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 37be774af921812018f723521b90f2ab54f661c5 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 04:51:38 2018 -0700 + + Minor + + src/hb-private.hh | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit e1acff806b469e58f568bf5ad6ba578207821e87 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 04:42:46 2018 -0700 + + Move hb_vector_t to hb-vector-private.hh + + src/Makefile.sources | 1 + + src/hb-dsalgs.hh | 297 + ----------------------------------------------- + src/hb-object-private.hh | 109 ++++++++++++++++- + src/hb-vector-private.hh | 239 ++++++++++++++++++++++++++++++++++++++ + 4 files changed, 346 insertions(+), 300 deletions(-) + +commit be336dadc07460a53de51be32dd5d1f218b398b6 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Mon Aug 6 04:32:51 2018 -0700 + + Move some more code around + + src/hb-dsalgs.hh | 43 +++++++++++++++++++++++++++++++++++++++++++ + src/hb-private.hh | 51 + +-------------------------------------------------- + 2 files changed, 44 insertions(+), 50 deletions(-) + +commit 92806ee055c8efb68fcbe9e1750ce2532a1f8ab3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Sun Aug 5 21:41:52 2018 -0700 + + Move null data definitions to hb-static.cc + + Also remove " " null data for Tag. Just use zeroes. + + src/hb-open-type-private.hh | 3 +-- + src/hb-ot-layout-common-private.hh | 5 ++--- + src/hb-private.hh | 12 +++++++----- + src/hb-static.cc | 10 +++++++++- + 4 files changed, 19 insertions(+), 11 deletions(-) + +commit 1b4d5a2402302e90867c178b6b2ad07541091a74 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 19:55:09 2018 -0700 + + Minor + + src/hb-ot-layout-private.hh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7df7963b46223f47e89a5a38c597c874aaa93141 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 19:54:33 2018 -0700 + + Make lazy loader deal with OOM + + src/hb-machinery-private.hh | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 30ff8ac865a266c8dca11eeac155c2cd3d1aa159 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 17:32:00 2018 -0700 + + Rename + + src/hb-machinery-private.hh | 6 +++--- + src/hb-ot-font.cc | 8 ++++---- + 2 files changed, 7 insertions(+), 7 deletions(-) + +commit 85ba4a190f30da5147d3b2ddac4d58dda31181f1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 17:06:42 2018 -0700 + + [ot] Comment + + src/hb-ot-layout-private.hh | 2 ++ + 1 file changed, 2 insertions(+) + +commit 07afc1a213bde91fdfc44dd613f2e82ac1617c9f +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 17:03:32 2018 -0700 + + [ot] Add misc tables to tables_t + + Most unused. + + src/hb-ot-layout-private.hh | 36 ++++++++++++++++++++++-------------- + 1 file changed, 22 insertions(+), 14 deletions(-) + +commit 74b4df2cdef68b74536d9c29426b242199a63a6f +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 16:57:40 2018 -0700 + + [ot] Move GDEF into tables_t + + src/hb-machinery-private.hh | 6 ++++++ + src/hb-ot-layout-gsub-table.hh | 2 +- + src/hb-ot-layout-gsubgpos-private.hh | 2 +- + src/hb-ot-layout-private.hh | 7 +------ + src/hb-ot-layout.cc | 15 +++++---------- + 5 files changed, 14 insertions(+), 18 deletions(-) + +commit 0271c7ab3b76dbf8a4e3e92eaf67d9d61b7a63dc +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 16:45:57 2018 -0700 + + [ot] Move GSUB/GPOS into tables_t + + src/hb-machinery-private.hh | 6 ++---- + src/hb-ot-layout-gpos-table.hh | 4 ++-- + src/hb-ot-layout-gsub-table.hh | 4 ++-- + src/hb-ot-layout-private.hh | 7 ++---- + src/hb-ot-layout.cc | 49 + +++++++++++++++++++----------------------- + 5 files changed, 30 insertions(+), 40 deletions(-) + +commit f73d2775cf649d148ace7c2593da9666d60fc1be +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 16:34:25 2018 -0700 + + [ot] More shuffling + + Misc. table loading now properly automated. + + src/hb-ot-layout-private.hh | 67 + +++++++++++++++++++++++++++++---------------- + src/hb-ot-layout.cc | 25 +++++++++++------ + src/hb-ot-math.cc | 2 +- + 3 files changed, 61 insertions(+), 33 deletions(-) + +commit 52fbd23d868a989d51b7df5be40be582890d13e5 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Fri Aug 3 16:22:16 2018 -0700 + + [ot] Minor + + src/hb-aat-layout.cc | 4 ++-- + src/hb-face-private.hh | 7 ++----- + src/hb-machinery-private.hh | 1 + + src/hb-ot-layout-private.hh | 15 +++++++++------ + src/hb-ot-layout.cc | 20 ++++++++++---------- + src/hb-ot-math.cc | 2 +- + src/hb-ot-var.cc | 4 ++-- + 7 files changed, 27 insertions(+), 26 deletions(-) + +commit 6a0a298aabe777e2c1ed443f100fe6142c83e3b3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 23:13:19 2018 -0700 + + [ot] Move code around + + src/hb-ot-layout.cc | 211 + ++++++++++++++++++++++++++-------------------------- + 1 file changed, 106 insertions(+), 105 deletions(-) + +commit 5e718a751efdda89511c9f30238b500125193499 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 23:04:42 2018 -0700 + + [ot] Use switch for checking for blacklisted GDEF tables + + Faster / more compact code. + + src/hb-ot-layout.cc | 107 + +++++++++++++++++++++++++++++----------------------- + 1 file changed, 59 insertions(+), 48 deletions(-) + +commit b5cdf5280d5b00df5356cc5c3236844ca0576bd0 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 22:56:42 2018 -0700 + + [ot] In GDEF blacklisting logic, remove the glyph index check + for Times + + Just blacklist based on table sizes like we do for other fonts. + + src/hb-ot-layout.cc | 12 ------------ + 1 file changed, 12 deletions(-) + +commit c988b119994ef78d400bc7d3139785312da0be75 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 20:04:37 2018 -0700 + + Move code around + + src/hb-ot-font.cc | 41 ++++++++++++++++++++++++++--------------- + 1 file changed, 26 insertions(+), 15 deletions(-) + +commit 574b37e933f98e35c2bdae04458a95522bbfbb82 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 02:22:38 2018 -0700 + + Minor + + src/hb-ot-font.cc | 2 +- + src/hb-ot-layout-private.hh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit d4d1bf8177b127caa57b146c932f553dca1ad933 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 02:04:02 2018 -0700 + + Fix for recent rename + + src/hb-graphite2.cc | 2 +- + src/hb-uniscribe.cc | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 91126aa11a5fa2bff72137df4768ad13fc9b7803 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 02:03:13 2018 -0700 + + [uniscribe] Update for recent changes + + src/hb-uniscribe.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 66952ec47b5f09d88b83fb6a71b1cdb26c53668d +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 01:44:20 2018 -0700 + + Remove unused table reference + + src/hb-ot-layout-private.hh | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +commit 443de26fa56dd1ef149d3ce4206f4495eceec2eb +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 01:41:19 2018 -0700 + + Minor + + src/hb-face.cc | 1 - + src/hb-ot-layout-private.hh | 12 ++++++------ + 2 files changed, 6 insertions(+), 7 deletions(-) + +commit ee35af738b5c802ca62eb1c39b77f0bd992329df +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 01:37:57 2018 -0700 + + Make lazy-loader safe for nil objectification + + src/hb-machinery-private.hh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 6404c49d0735d92779089ddef5c1d34aad1542d7 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 01:36:08 2018 -0700 + + Minor + + src/hb-machinery-private.hh | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit ff7826e90bce46985651015059872d1d8559b6ce +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 01:27:40 2018 -0700 + + Reduce storage by sharing face amongst lazy_loaders + + src/hb-machinery-private.hh | 113 + ++++++++++++++++++++++++-------------------- + src/hb-ot-font.cc | 19 ++++---- + src/hb-ot-layout-private.hh | 11 +++-- + src/hb-ot-layout.cc | 9 ++-- + 4 files changed, 85 insertions(+), 67 deletions(-) + +commit bdd3c11a19d87999eeaff2c82f21c6938d1d9342 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Aug 2 00:38:46 2018 -0700 + + Internal templatization of lazy-loaders + + src/hb-machinery-private.hh | 74 + ++++++++++++++++++++------------------------- + 1 file changed, 32 insertions(+), 42 deletions(-) + +commit ed7b2e58fc9afb547656cf28eb4a253d989de43c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 23:59:09 2018 -0700 + + Remove OT namespace from hb-machinery-private.hh + + src/dump-emoji.cc | 4 ++-- + src/hb-aat-layout.cc | 2 +- + src/hb-face.cc | 4 ++-- + src/hb-machinery-private.hh | 14 +++++--------- + src/hb-ot-font.cc | 8 ++++---- + src/hb-ot-layout-private.hh | 10 +++++----- + src/hb-ot-layout.cc | 8 ++++---- + src/hb-ot-shape-complex-arabic-fallback.hh | 18 +++++++++--------- + src/hb-static.cc | 4 ++-- + src/hb-subset-glyf.cc | 2 +- + src/hb-subset.cc | 8 ++++---- + src/hb-uniscribe.cc | 2 +- + 12 files changed, 40 insertions(+), 44 deletions(-) + +commit cb1491f92e24649433988ff81a89347dccf07c8b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 22:50:45 2018 -0700 + + Minor + + src/hb-blob-private.hh | 5 ----- + src/hb-machinery-private.hh | 10 ++++++---- + 2 files changed, 6 insertions(+), 9 deletions(-) + +commit 16ccfafbbd48c7a9737ce1d12e75406a050b71a9 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 22:50:06 2018 -0700 + + [face] Sprinkle const in the API + + src/hb-face.cc | 17 +++++++++-------- + src/hb-face.h | 16 ++++++++-------- + 2 files changed, 17 insertions(+), 16 deletions(-) + +commit 3d22aefedebb5277c5d79011e48e7be1a26a53c1 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 18:03:32 2018 -0700 + + Rename + + src/hb-coretext.cc | 46 + +++++++++++++++++++++++----------------------- + src/hb-directwrite.cc | 28 ++++++++++++++-------------- + src/hb-fallback-shape.cc | 24 ++++++++++++------------ + src/hb-graphite2.cc | 26 +++++++++++++------------- + src/hb-ot-shape.cc | 20 ++++++++++---------- + src/hb-shaper-private.hh | 2 +- + src/hb-uniscribe.cc | 34 +++++++++++++++++----------------- + 7 files changed, 90 insertions(+), 90 deletions(-) + +commit 1a624c6e06763a8a61bc686d2d44272d4ef50d4a +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 17:53:30 2018 -0700 + + Add comment re (our only) race condition + + src/hb-shaper-private.hh | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 44d1fb37efa20852cc466c0f0bba95dbd24ce288 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Aug 1 14:51:51 2018 -0700 + + 1.8.5 + + NEWS | 8 ++++++++ + configure.ac | 2 +- + src/hb-ot-layout.cc | 2 +- + src/hb-version.h | 4 ++-- + 4 files changed, 12 insertions(+), 4 deletions(-) + commit 13f4c137c686aed5c2888b5c47d9f16892be0d5e Author: Behdad Esfahbod <behdad@behdad.org> Date: Wed Aug 1 14:13:59 2018 -0700 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS index 13aa66295b8..e97a501d5ed 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS +++ b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS @@ -1,3 +1,18 @@ +Overview of changes leading to 1.8.6 +Tuesday, August 7, 2018 +==================================== +- Internal code shuffling. +- New API to speed up getting advance widths for implementations + that have heavy overhead in get_h_advance callback: ++hb_font_funcs_set_glyph_h_advances_func ++hb_font_funcs_set_glyph_v_advances_func ++hb_font_get_glyph_advances_for_direction ++hb_font_get_glyph_h_advances ++hb_font_get_glyph_h_advances_func_t ++hb_font_get_glyph_v_advances ++hb_font_get_glyph_v_advances_func_t + + Overview of changes leading to 1.8.5 Wednesday, August 1, 2018 ==================================== diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac index c439f54d034..c03d79dc57a 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], - [1.8.5], + [1.8.6], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources index 80b8e261c41..b981b0e264f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources @@ -19,6 +19,7 @@ HB_BASE_sources = \ hb-map.cc \ hb-machinery-private.hh \ hb-mutex-private.hh \ + hb-null.hh \ hb-object-private.hh \ hb-open-file-private.hh \ hb-open-type-private.hh \ @@ -52,6 +53,7 @@ HB_BASE_sources = \ hb-string-array.hh \ hb-unicode-private.hh \ hb-unicode.cc \ + hb-vector-private.hh \ hb-utf-private.hh \ hb-warning.cc \ $(NULL) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-emoji.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-emoji.cc index 400b890ad33..65214692ff5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-emoji.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-emoji.cc @@ -233,10 +233,10 @@ int main (int argc, char **argv) svg.dump (svg_callback); svg.fini (); - hb_blob_t* colr_blob = OT::hb_sanitize_context_t().reference_table<OT::COLR> (face); + hb_blob_t* colr_blob = hb_sanitize_context_t ().reference_table<OT::COLR> (face); const OT::COLR *colr = colr_blob->as<OT::COLR> (); - hb_blob_t* cpal_blob = OT::hb_sanitize_context_t().reference_table<OT::CPAL> (face); + hb_blob_t* cpal_blob = hb_sanitize_context_t ().reference_table<OT::CPAL> (face); const OT::CPAL *cpal = cpal_blob->as<OT::CPAL> (); cairo_font_face_t *cairo_face; 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 405aafccb81..36d4037ad9b 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 @@ -52,16 +52,16 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) return Null(AAT::morx); } hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::morx& morx = *(layout->morx.get ()); + const AAT::morx& morx = *(layout->table.morx.get ()); if (blob) - *blob = layout->morx.get_blob (); + *blob = layout->table.morx.get_blob (); return morx; } // static inline void // _hb_aat_layout_create (hb_face_t *face) // { -// hb_blob_t *morx_blob = OT::hb_sanitize_context_t().reference_table<AAT::morx> (face); +// hb_blob_t *morx_blob = hb_sanitize_context_t ().reference_table<AAT::morx> (face); // morx_blob->as<AAT::morx> (); // if (0) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh index 56a7b668bfc..49ad68ecec7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh @@ -57,11 +57,6 @@ struct hb_blob_t HB_INTERNAL bool try_make_writable_inplace (void); HB_INTERNAL bool try_make_writable_inplace_unix (void); - inline void lock (void) - { - hb_blob_make_immutable (this); - } - template <typename Type> inline const Type* as (void) const { @@ -81,6 +76,7 @@ struct hb_blob_t void *user_data; hb_destroy_func_t destroy; }; +DECLARE_NULL_INSTANCE (hb_blob_t); #endif /* HB_BLOB_PRIVATE_HH */ 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 5bab1abbe9a..25c3e05aad1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc @@ -45,6 +45,20 @@ #include <stdlib.h> +DEFINE_NULL_INSTANCE (hb_blob_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + nullptr, /* data */ + 0, /* length */ + HB_MEMORY_MODE_READONLY, /* mode */ + + nullptr, /* user_data */ + nullptr /* destroy */ +}; + /** * hb_blob_create: (skip) * @data: Pointer to blob data. @@ -182,20 +196,7 @@ hb_blob_copy_writable_or_fail (hb_blob_t *blob) hb_blob_t * hb_blob_get_empty (void) { - static const hb_blob_t _hb_blob_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - nullptr, /* data */ - 0, /* length */ - HB_MEMORY_MODE_READONLY, /* mode */ - - nullptr, /* user_data */ - nullptr /* destroy */ - }; - - return const_cast<hb_blob_t *> (&_hb_blob_nil); + return const_cast<hb_blob_t *> (&Null(hb_blob_t)); } /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh index f45814070cd..a6c4b696330 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh @@ -83,7 +83,8 @@ HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t); * hb_buffer_t */ -struct hb_buffer_t { +struct hb_buffer_t +{ hb_object_header_t header; ASSERT_POD (); @@ -352,6 +353,7 @@ struct hb_buffer_t { info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; } }; +DECLARE_NULL_INSTANCE (hb_buffer_t); /* Loop over clusters. Duplicated in foreach_syllable(). */ 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 d04e1e80f7c..e79b45ae4aa 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc @@ -701,6 +701,28 @@ hb_buffer_t::guess_segment_properties (void) /* Public API */ +DEFINE_NULL_INSTANCE (hb_buffer_t) = +{ + HB_OBJECT_HEADER_STATIC, + + const_cast<hb_unicode_funcs_t *> (&_hb_Null_hb_unicode_funcs_t), + HB_BUFFER_FLAG_DEFAULT, + HB_BUFFER_CLUSTER_LEVEL_DEFAULT, + HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, + HB_BUFFER_SCRATCH_FLAG_DEFAULT, + HB_BUFFER_MAX_LEN_DEFAULT, + HB_BUFFER_MAX_OPS_DEFAULT, + + HB_BUFFER_CONTENT_TYPE_INVALID, + HB_SEGMENT_PROPERTIES_DEFAULT, + false, /* successful */ + true, /* have_output */ + true /* have_positions */ + + /* Zero is good enough for everything else. */ +}; + + /** * hb_buffer_create: (Xconstructor) * @@ -743,27 +765,7 @@ hb_buffer_create (void) hb_buffer_t * hb_buffer_get_empty (void) { - static const hb_buffer_t _hb_buffer_nil = { - HB_OBJECT_HEADER_STATIC, - - const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), - HB_BUFFER_FLAG_DEFAULT, - HB_BUFFER_CLUSTER_LEVEL_DEFAULT, - HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, - HB_BUFFER_SCRATCH_FLAG_DEFAULT, - HB_BUFFER_MAX_LEN_DEFAULT, - HB_BUFFER_MAX_OPS_DEFAULT, - - HB_BUFFER_CONTENT_TYPE_INVALID, - HB_SEGMENT_PROPERTIES_DEFAULT, - false, /* successful */ - true, /* have_output */ - true /* have_positions */ - - /* Zero is good enough for everything else. */ - }; - - return const_cast<hb_buffer_t *> (&_hb_buffer_nil); + return const_cast<hb_buffer_t *> (&Null(hb_buffer_t)); } /** 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 3bdc3f784cd..13ab988651f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc @@ -269,7 +269,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) return ct_font; } -hb_coretext_shaper_face_data_t * +hb_coretext_face_data_t * _hb_coretext_shaper_face_data_create (hb_face_t *face) { CGFontRef cg_font = create_cg_font (face); @@ -280,11 +280,11 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face) return nullptr; } - return (hb_coretext_shaper_face_data_t *) cg_font; + return (hb_coretext_face_data_t *) cg_font; } void -_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) +_hb_coretext_shaper_face_data_destroy (hb_coretext_face_data_t *data) { CFRelease ((CGFontRef) data); } @@ -306,7 +306,7 @@ hb_coretext_face_get_cg_font (hb_face_t *face) } -hb_coretext_shaper_font_data_t * +hb_coretext_font_data_t * _hb_coretext_shaper_font_data_create (hb_font_t *font) { hb_face_t *face = font->face; @@ -321,11 +321,11 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font) return nullptr; } - return (hb_coretext_shaper_font_data_t *) ct_font; + return (hb_coretext_font_data_t *) ct_font; } void -_hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) +_hb_coretext_shaper_font_data_destroy (hb_coretext_font_data_t *data) { CFRelease ((CTFontRef) data); } @@ -348,7 +348,7 @@ hb_coretext_font_create (CTFontRef ct_font) hb_font_set_ptem (font, coretext_font_size_to_ptem (CTFontGetSize(ct_font))); /* Let there be dragons here... */ - HB_SHAPER_DATA_GET (font) = (hb_coretext_shaper_font_data_t *) CFRetain (ct_font); + HB_SHAPER_DATA_GET (font) = (hb_coretext_font_data_t *) CFRetain (ct_font); return font; } @@ -366,20 +366,20 @@ hb_coretext_font_get_ct_font (hb_font_t *font) * shaper shape_plan data */ -struct hb_coretext_shaper_shape_plan_data_t {}; +struct hb_coretext_shape_plan_data_t {}; -hb_coretext_shaper_shape_plan_data_t * +hb_coretext_shape_plan_data_t * _hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_coretext_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shape_plan_data_t *data HB_UNUSED) { } @@ -1329,9 +1329,9 @@ HB_SHAPER_DATA_ENSURE_DEFINE(coretext_aat, font) * shaper face data */ -struct hb_coretext_aat_shaper_face_data_t {}; +struct hb_coretext_aat_face_data_t {}; -hb_coretext_aat_shaper_face_data_t * +hb_coretext_aat_face_data_t * _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) { static const hb_tag_t tags[] = {HB_CORETEXT_TAG_MORX, HB_CORETEXT_TAG_MORT, HB_CORETEXT_TAG_KERX}; @@ -1342,7 +1342,7 @@ _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) if (hb_blob_get_length (blob)) { hb_blob_destroy (blob); - return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; + return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } hb_blob_destroy (blob); } @@ -1351,7 +1351,7 @@ _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) } void -_hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_shaper_face_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_face_data_t *data HB_UNUSED) { } @@ -1360,16 +1360,16 @@ _hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_shaper_face_data_t *d * shaper font data */ -struct hb_coretext_aat_shaper_font_data_t {}; +struct hb_coretext_aat_font_data_t {}; -hb_coretext_aat_shaper_font_data_t * +hb_coretext_aat_font_data_t * _hb_coretext_aat_shaper_font_data_create (hb_font_t *font) { - return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; + return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } void -_hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_shaper_font_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_font_data_t *data HB_UNUSED) { } @@ -1378,20 +1378,20 @@ _hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_shaper_font_data_t *d * shaper shape_plan data */ -struct hb_coretext_aat_shaper_shape_plan_data_t {}; +struct hb_coretext_aat_shape_plan_data_t {}; -hb_coretext_aat_shaper_shape_plan_data_t * +hb_coretext_aat_shape_plan_data_t * _hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_coretext_aat_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shape_plan_data_t *data HB_UNUSED) { } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc index 7c688494f07..baad81884dc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc @@ -133,7 +133,7 @@ public: * shaper face data */ -struct hb_directwrite_shaper_face_data_t +struct hb_directwrite_face_data_t { IDWriteFactory *dwriteFactory; IDWriteFontFile *fontFile; @@ -143,10 +143,10 @@ struct hb_directwrite_shaper_face_data_t hb_blob_t *faceBlob; }; -hb_directwrite_shaper_face_data_t * +hb_directwrite_face_data_t * _hb_directwrite_shaper_face_data_create (hb_face_t *face) { - hb_directwrite_shaper_face_data_t *data = new hb_directwrite_shaper_face_data_t; + hb_directwrite_face_data_t *data = new hb_directwrite_face_data_t; if (unlikely (!data)) return nullptr; @@ -206,7 +206,7 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face) } void -_hb_directwrite_shaper_face_data_destroy (hb_directwrite_shaper_face_data_t *data) +_hb_directwrite_shaper_face_data_destroy (hb_directwrite_face_data_t *data) { if (data->fontFace) data->fontFace->Release (); @@ -233,16 +233,16 @@ _hb_directwrite_shaper_face_data_destroy (hb_directwrite_shaper_face_data_t *dat * shaper font data */ -struct hb_directwrite_shaper_font_data_t +struct hb_directwrite_font_data_t { }; -hb_directwrite_shaper_font_data_t * +hb_directwrite_font_data_t * _hb_directwrite_shaper_font_data_create (hb_font_t *font) { if (unlikely (!hb_directwrite_shaper_face_data_ensure (font->face))) return nullptr; - hb_directwrite_shaper_font_data_t *data = new hb_directwrite_shaper_font_data_t; + hb_directwrite_font_data_t *data = new hb_directwrite_font_data_t; if (unlikely (!data)) return nullptr; @@ -250,7 +250,7 @@ _hb_directwrite_shaper_font_data_create (hb_font_t *font) } void -_hb_directwrite_shaper_font_data_destroy (hb_directwrite_shaper_font_data_t *data) +_hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data) { delete data; } @@ -260,20 +260,20 @@ _hb_directwrite_shaper_font_data_destroy (hb_directwrite_shaper_font_data_t *dat * shaper shape_plan data */ -struct hb_directwrite_shaper_shape_plan_data_t {}; +struct hb_directwrite_shape_plan_data_t {}; -hb_directwrite_shaper_shape_plan_data_t * +hb_directwrite_shape_plan_data_t * _hb_directwrite_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_directwrite_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_directwrite_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shape_plan_data_t *data HB_UNUSED) { } @@ -555,8 +555,8 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, float lineWidth) { hb_face_t *face = font->face; - hb_directwrite_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - hb_directwrite_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_directwrite_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_directwrite_font_data_t *font_data = HB_SHAPER_DATA_GET (font); IDWriteFactory *dwriteFactory = face_data->dwriteFactory; IDWriteFontFace *fontFace = face_data->fontFace; 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 fc7d1f0a904..8cbe6584b29 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh @@ -232,6 +232,18 @@ hb_ctz (T v) * Tiny stuff. */ +/* ASCII tag/character handling */ +static inline bool ISALPHA (unsigned char c) +{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } +static inline bool ISALNUM (unsigned char c) +{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } +static inline bool ISSPACE (unsigned char c) +{ return c == ' ' || c =='\f'|| c =='\n'|| c =='\r'|| c =='\t'|| c =='\v'; } +static inline unsigned char TOUPPER (unsigned char c) +{ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; } +static inline unsigned char TOLOWER (unsigned char c) +{ return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; } + #undef MIN template <typename Type> static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } @@ -262,6 +274,37 @@ hb_ceil_to_4 (unsigned int v) return ((v - 1) | 3) + 1; } +template <typename T> class hb_assert_unsigned_t; +template <> class hb_assert_unsigned_t<unsigned char> {}; +template <> class hb_assert_unsigned_t<unsigned short> {}; +template <> class hb_assert_unsigned_t<unsigned int> {}; +template <> class hb_assert_unsigned_t<unsigned long> {}; + +template <typename T> static inline bool +hb_in_range (T u, T lo, T hi) +{ + /* The sizeof() is here to force template instantiation. + * I'm sure there are better ways to do this but can't think of + * one right now. Declaring a variable won't work as HB_UNUSED + * is unusable on some platforms and unused types are less likely + * to generate a warning than unused variables. */ + static_assert ((sizeof (hb_assert_unsigned_t<T>) >= 0), ""); + + /* The casts below are important as if T is smaller than int, + * the subtract results will become a signed int! */ + return (T)(u - lo) <= (T)(hi - lo); +} +template <typename T> static inline bool +hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) +{ + return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); +} +template <typename T> static inline bool +hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) +{ + return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3); +} + /* * Sort and search. @@ -445,303 +488,6 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o } -#define HB_VECTOR_INIT {0, 0, false, nullptr} -template <typename Type, unsigned int StaticSize=8> -struct hb_vector_t -{ - unsigned int len; - unsigned int allocated; /* == 0 means allocation failed. */ - Type *arrayZ; - Type static_array[StaticSize]; - - void init (void) - { - len = 0; - allocated = ARRAY_LENGTH (static_array); - arrayZ = static_array; - } - - inline Type& operator [] (unsigned int i) - { - if (unlikely (i >= len)) - return Crap (Type); - return arrayZ[i]; - } - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len)) - return Null(Type); - return arrayZ[i]; - } - - inline Type *push (void) - { - if (unlikely (!resize (len + 1))) - return &Crap(Type); - return &arrayZ[len - 1]; - } - inline Type *push (const Type& v) - { - Type *p = push (); - *p = v; - return p; - } - - /* Allocate for size but don't adjust len. */ - inline bool alloc (unsigned int size) - { - if (unlikely (!allocated)) - return false; - - if (likely (size <= allocated)) - return true; - - /* Reallocate */ - - unsigned int new_allocated = allocated; - while (size >= new_allocated) - new_allocated += (new_allocated >> 1) + 8; - - Type *new_array = nullptr; - - if (arrayZ == static_array) - { - new_array = (Type *) calloc (new_allocated, sizeof (Type)); - if (new_array) - memcpy (new_array, arrayZ, len * sizeof (Type)); - } - else - { - bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); - if (likely (!overflows)) - new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); - } - - if (unlikely (!new_array)) - { - allocated = 0; - return false; - } - - arrayZ = new_array; - allocated = new_allocated; - - return true; - } - - inline bool resize (int size_) - { - unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; - if (!alloc (size)) - return false; - - if (size > len) - memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ)); - - len = size; - return true; - } - - inline void pop (void) - { - if (!len) return; - len--; - } - - inline void remove (unsigned int i) - { - if (unlikely (i >= len)) - return; - memmove (static_cast<void *> (&arrayZ[i]), - static_cast<void *> (&arrayZ[i + 1]), - (len - i - 1) * sizeof (Type)); - len--; - } - - inline void shrink (int size_) - { - unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; - if (size < len) - len = size; - } - - template <typename T> - inline Type *find (T v) { - for (unsigned int i = 0; i < len; i++) - if (arrayZ[i] == v) - return &arrayZ[i]; - return nullptr; - } - template <typename T> - inline const Type *find (T v) const { - for (unsigned int i = 0; i < len; i++) - if (arrayZ[i] == v) - return &arrayZ[i]; - return nullptr; - } - - inline void qsort (int (*cmp)(const void*, const void*)) - { - ::qsort (arrayZ, len, sizeof (Type), cmp); - } - - inline void qsort (void) - { - ::qsort (arrayZ, len, sizeof (Type), Type::cmp); - } - - inline void qsort (unsigned int start, unsigned int end) - { - ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp); - } - - template <typename T> - inline Type *lsearch (const T &x) - { - for (unsigned int i = 0; i < len; i++) - if (0 == this->arrayZ[i].cmp (&x)) - return &arrayZ[i]; - return nullptr; - } - - template <typename T> - inline Type *bsearch (const T &x) - { - unsigned int i; - return bfind (x, &i) ? &arrayZ[i] : nullptr; - } - template <typename T> - inline const Type *bsearch (const T &x) const - { - unsigned int i; - return bfind (x, &i) ? &arrayZ[i] : nullptr; - } - template <typename T> - inline bool bfind (const T &x, unsigned int *i) const - { - int min = 0, max = (int) this->len - 1; - while (min <= max) - { - int mid = (min + max) / 2; - int c = this->arrayZ[mid].cmp (&x); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - { - *i = mid; - return true; - } - } - if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0)) - max++; - *i = max; - return false; - } - - inline void fini (void) - { - if (arrayZ != static_array) - free (arrayZ); - arrayZ = nullptr; - allocated = len = 0; - } -}; - - -#define HB_LOCKABLE_SET_INIT {HB_VECTOR_INIT} -template <typename item_t, typename lock_t> -struct hb_lockable_set_t -{ - hb_vector_t <item_t, 1> items; - - inline void init (void) { items.init (); } - - template <typename T> - inline item_t *replace_or_insert (T v, lock_t &l, bool replace) - { - l.lock (); - item_t *item = items.find (v); - if (item) { - if (replace) { - item_t old = *item; - *item = v; - l.unlock (); - old.fini (); - } - else { - item = nullptr; - l.unlock (); - } - } else { - item = items.push (v); - l.unlock (); - } - return item; - } - - template <typename T> - inline void remove (T v, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (item) { - item_t old = *item; - *item = items[items.len - 1]; - items.pop (); - l.unlock (); - old.fini (); - } else { - l.unlock (); - } - } - - template <typename T> - inline bool find (T v, item_t *i, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (item) - *i = *item; - l.unlock (); - return !!item; - } - - template <typename T> - inline item_t *find_or_insert (T v, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (!item) { - item = items.push (v); - } - l.unlock (); - return item; - } - - inline void fini (lock_t &l) - { - if (!items.len) { - /* No need for locking. */ - items.fini (); - return; - } - l.lock (); - while (items.len) { - item_t old = items[items.len - 1]; - items.pop (); - l.unlock (); - old.fini (); - l.lock (); - } - items.fini (); - l.unlock (); - } - -}; - - template <typename Type> struct hb_auto_t : Type { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh index fe3b8b240c8..a4b2cd36d6a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh @@ -39,7 +39,8 @@ * hb_face_t */ -struct hb_face_t { +struct hb_face_t +{ hb_object_header_t header; ASSERT_POD (); @@ -55,16 +56,13 @@ struct hb_face_t { struct hb_shaper_data_t shaper_data; /* Various shaper data. */ - /* Various non-shaping data. */ - /* ... */ - /* Cache */ - struct plan_node_t { + struct plan_node_t + { hb_shape_plan_t *shape_plan; plan_node_t *next; } *shape_plans; - inline hb_blob_t *reference_table (hb_tag_t tag) const { hb_blob_t *blob; @@ -97,8 +95,7 @@ struct hb_face_t { HB_INTERNAL void load_upem (void) const; HB_INTERNAL void load_num_glyphs (void) const; }; - -extern HB_INTERNAL const hb_face_t _hb_face_nil; +DECLARE_NULL_INSTANCE (hb_face_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face); 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 fab2aa3a9f8..e1492756cfc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc @@ -33,7 +33,6 @@ #include "hb-open-file-private.hh" - /** * hb_face_count: Get number of faces on the blob * @blob: @@ -51,7 +50,8 @@ hb_face_count (hb_blob_t *blob) return 0; /* TODO We shouldn't be sanitizing blob. Port to run sanitizer and return if not sane. */ - hb_blob_t *sanitized = OT::hb_sanitize_context_t().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob)); + /* Make API signature const after. */ + hb_blob_t *sanitized = hb_sanitize_context_t ().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob)); const OT::OpenTypeFontFile& ot = *sanitized->as<OT::OpenTypeFontFile> (); unsigned int ret = ot.get_face_count (); hb_blob_destroy (sanitized); @@ -63,7 +63,8 @@ hb_face_count (hb_blob_t *blob) * hb_face_t */ -const hb_face_t _hb_face_nil = { +DEFINE_NULL_INSTANCE (hb_face_t) = +{ HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -189,7 +190,7 @@ hb_face_create (hb_blob_t *blob, if (unlikely (!blob)) blob = hb_blob_get_empty (); - hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::hb_sanitize_context_t().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob)), index); + hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (hb_sanitize_context_t ().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob)), index); if (unlikely (!closure)) return hb_face_get_empty (); @@ -215,7 +216,7 @@ hb_face_create (hb_blob_t *blob, hb_face_t * hb_face_get_empty (void) { - return const_cast<hb_face_t *> (&_hb_face_nil); + return const_cast<hb_face_t *> (&Null(hb_face_t)); } @@ -302,7 +303,7 @@ hb_face_set_user_data (hb_face_t *face, * Since: 0.9.2 **/ void * -hb_face_get_user_data (hb_face_t *face, +hb_face_get_user_data (const hb_face_t *face, hb_user_data_key_t *key) { return hb_object_get_user_data (face, key); @@ -336,7 +337,7 @@ hb_face_make_immutable (hb_face_t *face) * Since: 0.9.2 **/ hb_bool_t -hb_face_is_immutable (hb_face_t *face) +hb_face_is_immutable (const hb_face_t *face) { return face->immutable; } @@ -354,8 +355,8 @@ hb_face_is_immutable (hb_face_t *face) * Since: 0.9.2 **/ hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag) +hb_face_reference_table (const hb_face_t *face, + hb_tag_t tag) { return face->reference_table (tag); } @@ -406,7 +407,7 @@ hb_face_set_index (hb_face_t *face, * Since: 0.9.2 **/ unsigned int -hb_face_get_index (hb_face_t *face) +hb_face_get_index (const hb_face_t *face) { return face->index; } @@ -441,7 +442,7 @@ hb_face_set_upem (hb_face_t *face, * Since: 0.9.2 **/ unsigned int -hb_face_get_upem (hb_face_t *face) +hb_face_get_upem (const hb_face_t *face) { return face->get_upem (); } @@ -476,7 +477,7 @@ hb_face_set_glyph_count (hb_face_t *face, * Since: 0.9.7 **/ unsigned int -hb_face_get_glyph_count (hb_face_t *face) +hb_face_get_glyph_count (const hb_face_t *face) { return face->get_num_glyphs (); } @@ -492,7 +493,7 @@ hb_face_get_glyph_count (hb_face_t *face) * Since: 1.6.0 **/ unsigned int -hb_face_get_table_tags (hb_face_t *face, +hb_face_get_table_tags (const hb_face_t *face, unsigned int start_offset, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h index 983ee56b1c1..208092efc28 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h @@ -76,19 +76,19 @@ hb_face_set_user_data (hb_face_t *face, hb_bool_t replace); HB_EXTERN void * -hb_face_get_user_data (hb_face_t *face, +hb_face_get_user_data (const hb_face_t *face, hb_user_data_key_t *key); HB_EXTERN void hb_face_make_immutable (hb_face_t *face); HB_EXTERN hb_bool_t -hb_face_is_immutable (hb_face_t *face); +hb_face_is_immutable (const hb_face_t *face); HB_EXTERN hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag); +hb_face_reference_table (const hb_face_t *face, + hb_tag_t tag); HB_EXTERN hb_blob_t * hb_face_reference_blob (hb_face_t *face); @@ -98,24 +98,24 @@ hb_face_set_index (hb_face_t *face, unsigned int index); HB_EXTERN unsigned int -hb_face_get_index (hb_face_t *face); +hb_face_get_index (const hb_face_t *face); HB_EXTERN void hb_face_set_upem (hb_face_t *face, unsigned int upem); HB_EXTERN unsigned int -hb_face_get_upem (hb_face_t *face); +hb_face_get_upem (const hb_face_t *face); HB_EXTERN void hb_face_set_glyph_count (hb_face_t *face, unsigned int glyph_count); HB_EXTERN unsigned int -hb_face_get_glyph_count (hb_face_t *face); +hb_face_get_glyph_count (const hb_face_t *face); HB_EXTERN unsigned int -hb_face_get_table_tags (hb_face_t *face, +hb_face_get_table_tags (const hb_face_t *face, unsigned int start_offset, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc index 3f09c3f5306..eff20f70c77 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc @@ -36,16 +36,16 @@ HB_SHAPER_DATA_ENSURE_DEFINE(fallback, font) * shaper face data */ -struct hb_fallback_shaper_face_data_t {}; +struct hb_fallback_face_data_t {}; -hb_fallback_shaper_face_data_t * +hb_fallback_face_data_t * _hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED) { - return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED) +_hb_fallback_shaper_face_data_destroy (hb_fallback_face_data_t *data HB_UNUSED) { } @@ -54,16 +54,16 @@ _hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_U * shaper font data */ -struct hb_fallback_shaper_font_data_t {}; +struct hb_fallback_font_data_t {}; -hb_fallback_shaper_font_data_t * +hb_fallback_font_data_t * _hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED) +_hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED) { } @@ -72,20 +72,20 @@ _hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_U * shaper shape_plan data */ -struct hb_fallback_shaper_shape_plan_data_t {}; +struct hb_fallback_shape_plan_data_t {}; -hb_fallback_shaper_shape_plan_data_t * +hb_fallback_shape_plan_data_t * _hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shape_plan_data_t *data HB_UNUSED) { } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh index 9f657db6062..d3a41380258 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh @@ -35,7 +35,6 @@ #include "hb-shaper-private.hh" - /* * hb_font_funcs_t */ @@ -47,6 +46,8 @@ HB_FONT_FUNC_IMPLEMENT (variation_glyph) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ + HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_advances) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ @@ -57,7 +58,8 @@ HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ /* ^--- Add new callbacks here */ -struct hb_font_funcs_t { +struct hb_font_funcs_t +{ hb_object_header_t header; ASSERT_POD (); @@ -89,14 +91,15 @@ struct hb_font_funcs_t { ]) (void); } get; }; - +DECLARE_NULL_INSTANCE (hb_font_funcs_t); /* * hb_font_t */ -struct hb_font_t { +struct hb_font_t +{ hb_object_header_t header; ASSERT_POD (); @@ -233,6 +236,32 @@ struct hb_font_t { klass->user_data.glyph_v_advance); } + inline void get_glyph_h_advances (unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) + { + return klass->get.f.glyph_h_advances (this, user_data, + count, + first_glyph, glyph_stride, + first_advance, advance_stride, + klass->user_data.glyph_h_advances); + } + + inline void get_glyph_v_advances (unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) + { + return klass->get.f.glyph_v_advances (this, user_data, + count, + first_glyph, glyph_stride, + first_advance, advance_stride, + klass->user_data.glyph_v_advances); + } + inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) { @@ -341,13 +370,23 @@ struct hb_font_t { hb_direction_t direction, hb_position_t *x, hb_position_t *y) { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + *x = *y = 0; + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) *x = get_glyph_h_advance (glyph); - *y = 0; - } else { - *x = 0; + else *y = get_glyph_v_advance (glyph); - } + } + inline void get_glyph_advances_for_direction (hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); + else + get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); } inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, @@ -553,6 +592,7 @@ struct hb_font_t { return (float) v * scale / face->get_upem (); } }; +DECLARE_NULL_INSTANCE (hb_font_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); 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 4d62b9e9c79..80768d6d517 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -29,6 +29,7 @@ #include "hb-private.hh" #include "hb-font-private.hh" +#include "hb-machinery-private.hh" /* @@ -45,10 +46,10 @@ hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_font_h_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_font_extents_t *metrics, - void *user_data HB_UNUSED) +hb_font_get_font_h_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_font_extents_t *metrics, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_font_h_extents (metrics); if (ret) { @@ -69,10 +70,10 @@ hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_font_v_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_font_extents_t *metrics, - void *user_data HB_UNUSED) +hb_font_get_font_v_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_font_extents_t *metrics, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_font_v_extents (metrics); if (ret) { @@ -94,11 +95,11 @@ hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_nominal_glyph_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_nominal_glyph_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_nominal_glyph (unicode, glyph); } @@ -115,12 +116,12 @@ hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_variation_glyph_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_variation_glyph_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_variation_glyph (unicode, variation_selector, glyph); } @@ -129,16 +130,16 @@ hb_font_get_variation_glyph_parent (hb_font_t *font, static hb_position_t hb_font_get_glyph_h_advance_nil (hb_font_t *font, void *font_data HB_UNUSED, - hb_codepoint_t glyph, + hb_codepoint_t glyph HB_UNUSED, void *user_data HB_UNUSED) { return font->x_scale; } static hb_position_t -hb_font_get_glyph_h_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_advance_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) { return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph)); } @@ -146,21 +147,85 @@ hb_font_get_glyph_h_advance_parent (hb_font_t *font, static hb_position_t hb_font_get_glyph_v_advance_nil (hb_font_t *font, void *font_data HB_UNUSED, - hb_codepoint_t glyph, + hb_codepoint_t glyph HB_UNUSED, void *user_data HB_UNUSED) { /* TODO use font_extents.ascender+descender */ return font->y_scale; } static hb_position_t -hb_font_get_glyph_v_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_advance_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) { return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph)); } +#define hb_font_get_glyph_h_advances_nil hb_font_get_glyph_h_advances_default +static void +hb_font_get_glyph_h_advances_default (hb_font_t* font, + void* font_data HB_UNUSED, + unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride, + void *user_data HB_UNUSED) +{ + if (font->has_glyph_h_advance_func ()) + { + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->get_glyph_h_advance (*first_glyph); + first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); + first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); + } + return; + } + + font->parent->get_glyph_h_advances (count, + first_glyph, glyph_stride, + first_advance, advance_stride); + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->parent_scale_x_distance (*first_advance); + first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); + } +} + +#define hb_font_get_glyph_v_advances_nil hb_font_get_glyph_v_advances_default +static void +hb_font_get_glyph_v_advances_default (hb_font_t* font, + void* font_data HB_UNUSED, + unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride, + void *user_data HB_UNUSED) +{ + if (font->has_glyph_v_advance_func ()) + { + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->get_glyph_v_advance (*first_glyph); + first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); + first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); + } + return; + } + + font->parent->get_glyph_v_advances (count, + first_glyph, glyph_stride, + first_advance, advance_stride); + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->parent_scale_y_distance (*first_advance); + first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); + } +} + static hb_bool_t hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, @@ -173,12 +238,12 @@ hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, return true; } static hb_bool_t -hb_font_get_glyph_h_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_origin_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); if (ret) @@ -198,12 +263,12 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_glyph_v_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_origin_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); if (ret) @@ -221,11 +286,11 @@ hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, return 0; } static hb_position_t -hb_font_get_glyph_h_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t left_glyph, - hb_codepoint_t right_glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_kerning_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph, + void *user_data HB_UNUSED) { return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph)); } @@ -240,11 +305,11 @@ hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, return 0; } static hb_position_t -hb_font_get_glyph_v_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t top_glyph, - hb_codepoint_t bottom_glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_kerning_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t top_glyph, + hb_codepoint_t bottom_glyph, + void *user_data HB_UNUSED) { return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph)); } @@ -260,11 +325,11 @@ hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_glyph_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) +hb_font_get_glyph_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); if (ret) { @@ -287,13 +352,13 @@ hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_glyph_contour_point_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - unsigned int point_index, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_contour_point_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + unsigned int point_index, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y); if (ret) @@ -312,11 +377,11 @@ hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_glyph_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data HB_UNUSED) +hb_font_get_glyph_name_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) { return font->parent->get_glyph_name (glyph, name, size); } @@ -332,16 +397,17 @@ hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED, return false; } static hb_bool_t -hb_font_get_glyph_from_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_from_name_default (hb_font_t *font, + void *font_data HB_UNUSED, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_glyph_from_name (name, len, glyph); } -static const hb_font_funcs_t _hb_font_funcs_nil = { +DEFINE_NULL_INSTANCE (hb_font_funcs_t) = +{ HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -364,7 +430,8 @@ static const hb_font_funcs_t _hb_font_funcs_nil = { } } }; -static const hb_font_funcs_t _hb_font_funcs_parent = { + +static const hb_font_funcs_t _hb_font_funcs_default = { HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -381,7 +448,7 @@ static const hb_font_funcs_t _hb_font_funcs_parent = { }, { { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent, +#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_default, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT } @@ -406,7 +473,7 @@ hb_font_funcs_create (void) if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) return hb_font_funcs_get_empty (); - ffuncs->get = _hb_font_funcs_parent.get; + ffuncs->get = _hb_font_funcs_default.get; return ffuncs; } @@ -423,7 +490,7 @@ hb_font_funcs_create (void) hb_font_funcs_t * hb_font_funcs_get_empty (void) { - return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_parent); + return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_default); } /** @@ -562,9 +629,9 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ ffuncs->user_data.name = user_data; \ ffuncs->destroy.name = destroy; \ } else { \ - ffuncs->get.f.name = hb_font_get_##name##_parent; \ - ffuncs->user_data.name = nullptr; \ - ffuncs->destroy.name = nullptr; \ + ffuncs->get.f.name = hb_font_get_##name##_default; \ + ffuncs->user_data.name = nullptr; \ + ffuncs->destroy.name = nullptr; \ } \ } @@ -574,9 +641,8 @@ HB_FONT_FUNCS_IMPLEMENT_CALLBACKS bool hb_font_t::has_func (unsigned int i) { - if (parent && parent != hb_font_get_empty () && parent->has_func (i)) - return true; - return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i]; + return (this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]) || + (parent && parent != &_hb_Null_hb_font_t && parent->has_func (i)); } /* Public getters */ @@ -718,6 +784,43 @@ hb_font_get_glyph_v_advance (hb_font_t *font, } /** + * hb_font_get_glyph_h_advances: + * @font: a font. + * + * + * + * Since: 1.8.6 + **/ +void +hb_font_get_glyph_h_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); +} +/** + * hb_font_get_glyph_v_advances: + * @font: a font. + * + * + * + * Since: 1.8.6 + **/ +void +hb_font_get_glyph_v_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); +} + +/** * hb_font_get_glyph_h_origin: * @font: a font. * @glyph: @@ -921,6 +1024,26 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font, { return font->get_glyph_advance_for_direction (glyph, direction, x, y); } +/** + * hb_font_get_glyph_advances_for_direction: + * @font: a font. + * @direction: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_get_glyph_advances_for_direction (hb_font_t* font, + hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_advances_for_direction (direction, count, first_glyph, glyph_stride, first_advance, advance_stride); +} /** * hb_font_get_glyph_origin_for_direction: @@ -1100,6 +1223,37 @@ hb_font_glyph_from_string (hb_font_t *font, * hb_font_t */ +DEFINE_NULL_INSTANCE (hb_font_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + nullptr, /* parent */ + const_cast<hb_face_t *> (&_hb_Null_hb_face_t), + + 1000, /* x_scale */ + 1000, /* y_scale */ + + 0, /* x_ppem */ + 0, /* y_ppem */ + 0, /* ptem */ + + 0, /* num_coords */ + nullptr, /* coords */ + + const_cast<hb_font_funcs_t *> (&_hb_Null_hb_font_funcs_t), /* klass */ + nullptr, /* user_data */ + nullptr, /* destroy */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } +}; + + /** * hb_font_create: (Xconstructor) * @face: a face. @@ -1187,36 +1341,7 @@ hb_font_create_sub_font (hb_font_t *parent) hb_font_t * hb_font_get_empty (void) { - static const hb_font_t _hb_font_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - nullptr, /* parent */ - const_cast<hb_face_t *> (&_hb_face_nil), - - 1000, /* x_scale */ - 1000, /* y_scale */ - - 0, /* x_ppem */ - 0, /* y_ppem */ - 0, /* ptem */ - - 0, /* num_coords */ - nullptr, /* coords */ - - const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */ - nullptr, /* user_data */ - nullptr, /* destroy */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - } - }; - - return const_cast<hb_font_t *> (&_hb_font_nil); + return const_cast<hb_font_t *> (&Null(hb_font_t)); } /** 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 c95b61d2da8..6cd486979b0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h @@ -132,6 +132,16 @@ typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; +typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride, + void *user_data); +typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t; +typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t; + typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y, @@ -265,6 +275,38 @@ hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, void *user_data, hb_destroy_func_t destroy); /** + * hb_font_funcs_set_glyph_h_advances_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_h_advances_func_t func, + void *user_data, hb_destroy_func_t destroy); + +/** + * hb_font_funcs_set_glyph_v_advances_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_v_advances_func_t func, + void *user_data, hb_destroy_func_t destroy); + +/** * hb_font_funcs_set_glyph_h_origin_func: * @ffuncs: font functions. * @func: (closure user_data) (destroy destroy) (scope notified): @@ -417,6 +459,21 @@ HB_EXTERN hb_position_t hb_font_get_glyph_v_advance (hb_font_t *font, hb_codepoint_t glyph); +HB_EXTERN void +hb_font_get_glyph_h_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); +HB_EXTERN void +hb_font_get_glyph_v_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); + HB_EXTERN hb_bool_t hb_font_get_glyph_h_origin (hb_font_t *font, hb_codepoint_t glyph, @@ -472,6 +529,14 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font, hb_direction_t direction, hb_position_t *x, hb_position_t *y); HB_EXTERN void +hb_font_get_glyph_advances_for_direction (hb_font_t* font, + hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); +HB_EXTERN void hb_font_get_glyph_origin_for_direction (hb_font_t *font, hb_codepoint_t glyph, hb_direction_t direction, 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 c20f6bef2d8..2ba905d6df1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc @@ -48,7 +48,7 @@ typedef struct hb_graphite2_tablelist_t { unsigned int tag; } hb_graphite2_tablelist_t; -struct hb_graphite2_shaper_face_data_t { +struct hb_graphite2_face_data_t { hb_face_t *face; gr_face *grface; hb_graphite2_tablelist_t *tlist; @@ -56,7 +56,7 @@ struct hb_graphite2_shaper_face_data_t { static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) { - hb_graphite2_shaper_face_data_t *face_data = (hb_graphite2_shaper_face_data_t *) data; + hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; hb_graphite2_tablelist_t *tlist = face_data->tlist; hb_blob_t *blob = nullptr; @@ -93,7 +93,7 @@ retry: return d; } -hb_graphite2_shaper_face_data_t * +hb_graphite2_face_data_t * _hb_graphite2_shaper_face_data_create (hb_face_t *face) { hb_blob_t *silf_blob = face->reference_table (HB_GRAPHITE2_TAG_SILF); @@ -106,7 +106,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) } hb_blob_destroy (silf_blob); - hb_graphite2_shaper_face_data_t *data = (hb_graphite2_shaper_face_data_t *) calloc (1, sizeof (hb_graphite2_shaper_face_data_t)); + hb_graphite2_face_data_t *data = (hb_graphite2_face_data_t *) calloc (1, sizeof (hb_graphite2_face_data_t)); if (unlikely (!data)) return nullptr; @@ -122,7 +122,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face) } void -_hb_graphite2_shaper_face_data_destroy (hb_graphite2_shaper_face_data_t *data) +_hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data) { hb_graphite2_tablelist_t *tlist = data->tlist; @@ -154,16 +154,16 @@ hb_graphite2_face_get_gr_face (hb_face_t *face) * shaper font data */ -struct hb_graphite2_shaper_font_data_t {}; +struct hb_graphite2_font_data_t {}; -hb_graphite2_shaper_font_data_t * +hb_graphite2_font_data_t * _hb_graphite2_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_graphite2_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_graphite2_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data HB_UNUSED) +_hb_graphite2_shaper_font_data_destroy (hb_graphite2_font_data_t *data HB_UNUSED) { } @@ -181,20 +181,20 @@ hb_graphite2_font_get_gr_font (hb_font_t *font) * shaper shape_plan data */ -struct hb_graphite2_shaper_shape_plan_data_t {}; +struct hb_graphite2_shape_plan_data_t {}; -hb_graphite2_shaper_shape_plan_data_t * +hb_graphite2_shape_plan_data_t * _hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_graphite2_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_graphite2_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shape_plan_data_t *data HB_UNUSED) { } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh index 410a50f94dc..039a7734837 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh @@ -72,7 +72,7 @@ struct Iter<T *> array (array_), length (length_) {} /* Emptiness. */ - inline operator bool (void) const { return bool (length); } + explicit inline operator bool (void) const { return bool (length); } /* Current item. */ inline T &operator * (void) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh index ff56b1dc9bb..119625c45a2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh @@ -30,10 +30,9 @@ #define HB_MACHINERY_PRIVATE_HH #include "hb-private.hh" -#include "hb-iter-private.hh" - +#include "hb-blob-private.hh" -namespace OT { +#include "hb-iter-private.hh" /* @@ -188,7 +187,7 @@ struct hb_sanitize_context_t : inline void start_processing (void) { - this->start = hb_blob_get_data (this->blob, nullptr); + this->start = this->blob->data; this->end = this->start + this->blob->length; assert (this->start <= this->end); /* Must not overflow. */ this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR, @@ -336,7 +335,7 @@ struct hb_sanitize_context_t : DEBUG_MSG_FUNC (SANITIZE, start, sane ? "PASSED" : "FAILED"); if (sane) { - blob->lock (); + hb_blob_make_immutable (blob); return blob; } else @@ -350,8 +349,8 @@ struct hb_sanitize_context_t : inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) { if (!num_glyphs_set) - set_num_glyphs (face->get_num_glyphs ()); - return sanitize_blob<Type> (face->reference_table (tableTag)); + set_num_glyphs (hb_face_get_glyph_count (face)); + return sanitize_blob<Type> (hb_face_reference_table (face, tableTag)); } mutable unsigned int debug_depth; @@ -588,109 +587,126 @@ struct BEInt<Type, 4> /* - * Lazy struct and blob loaders. + * Lazy loaders. */ -/* Logic is shared between hb_lazy_loader_t and hb_table_lazy_loader_t */ -template <typename T> +template <unsigned int WheresFace, + typename Subclass, + typename Returned, + typename Stored = Returned> struct hb_lazy_loader_t { - inline void init (hb_face_t *face_) + static_assert (WheresFace > 0, ""); + + /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ + inline const Subclass* thiz (void) const { return static_cast<const Subclass *> (this); } + inline Subclass* thiz (void) { return static_cast<Subclass *> (this); } + + inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ + inline void init (void) { - face = face_; instance = nullptr; } - inline void fini (void) { - if (instance && instance != &Null(T)) - { - instance->fini(); - free (instance); - } + if (instance) + thiz ()->destroy (instance); } - inline const T* get (void) const + inline const Returned * operator -> (void) const { return thiz ()->get (); } + inline const Returned & operator * (void) const { return *thiz ()->get (); } + + inline Stored * get_stored (void) const { retry: - T *p = (T *) hb_atomic_ptr_get (&instance); + Stored *p = (Stored *) hb_atomic_ptr_get (&this->instance); if (unlikely (!p)) { - p = (T *) calloc (1, sizeof (T)); + hb_face_t *face = *(((hb_face_t **) this) - WheresFace); + if (likely (!p)) + p = thiz ()->create (face); if (unlikely (!p)) - p = const_cast<T *> (&Null(T)); - else - p->init (face); - if (unlikely (!hb_atomic_ptr_cmpexch (const_cast<T **>(&instance), nullptr, p))) + p = thiz ()->create (nullptr); /* Produce nil object. */ + assert (p); + if (unlikely (!hb_atomic_ptr_cmpexch (const_cast<Stored **>(&this->instance), nullptr, p))) { - if (p != &Null(T)) - p->fini (); + thiz ()->destroy (p); goto retry; } } return p; } - inline const T* operator-> (void) const + inline void set_stored (Stored *instance_) { - return get (); + assert (instance == nullptr); + instance = instance_; } - private: - hb_face_t *face; - mutable T *instance; -}; - -/* Logic is shared between hb_lazy_loader_t and hb_table_lazy_loader_t */ -template <typename T> -struct hb_table_lazy_loader_t -{ - inline void init (hb_face_t *face_) + inline const Returned * get (void) const { - face = face_; - blob = nullptr; + return thiz ()->convert (get_stored ()); } - inline void fini (void) + static inline const Returned* convert (const Stored *p) { - hb_blob_destroy (blob); + return p; } - inline hb_blob_t* get_blob (void) const + private: + /* Must only have one pointer. */ + mutable Stored *instance; +}; + +/* Specializations. */ + +template <unsigned int WheresFace, typename T> +struct hb_object_lazy_loader_t : hb_lazy_loader_t<WheresFace, hb_object_lazy_loader_t<WheresFace, T>, T> +{ + static inline T *create (hb_face_t *face) { - retry: - hb_blob_t *b = (hb_blob_t *) hb_atomic_ptr_get (&blob); - if (unlikely (!b)) + if (unlikely (!face)) + return const_cast<T *> (&Null(T)); + T *p = (T *) calloc (1, sizeof (T)); + if (unlikely (!p)) + p = const_cast<T *> (&Null(T)); + else + p->init (face); + return p; + } + static inline void destroy (T *p) + { + if (p != &Null(T)) { - b = OT::hb_sanitize_context_t().reference_table<T> (face); - if (!hb_atomic_ptr_cmpexch (&blob, nullptr, b)) - { - hb_blob_destroy (b); - goto retry; - } - blob = b; + p->fini(); + free (p); } - return b; } +}; - inline const T* get (void) const +template <unsigned int WheresFace, typename T> +struct hb_table_lazy_loader_t : hb_lazy_loader_t<WheresFace, hb_table_lazy_loader_t<WheresFace, T>, T, hb_blob_t> +{ + static inline hb_blob_t *create (hb_face_t *face) { - hb_blob_t *b = get_blob (); - return b->as<T> (); + if (unlikely (!face)) + return hb_blob_get_empty (); + return hb_sanitize_context_t ().reference_table<T> (face); } - - inline const T* operator-> (void) const + static inline void destroy (hb_blob_t *p) { - return get(); + hb_blob_destroy (p); + } + static inline const T* convert (const hb_blob_t *blob) + { + return blob->as<T> (); } - private: - hb_face_t *face; - mutable hb_blob_t *blob; + inline hb_blob_t* get_blob (void) const + { + return this->get_stored (); + } }; -} /* namespace OT */ - - #endif /* HB_MACHINERY_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh new file mode 100644 index 00000000000..91efee6443d --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -0,0 +1,106 @@ +/* + * Copyright © 2018 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_NULL_HH +#define HB_NULL_HH + +#include "hb-private.hh" + + +/* + * Static pools + */ + +/* Global nul-content Null pool. Enlarge as necessary. */ + +#define HB_NULL_POOL_SIZE 264 + +extern HB_INTERNAL +hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; + +/* Generic nul-content Null objects. */ +template <typename Type> +static inline Type const & Null (void) { + static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); + return *reinterpret_cast<Type const *> (_hb_NullPool); +} +#define Null(Type) Null<Type>() + +/* Specializaitons for arbitrary-content Null objects expressed in bytes. */ +#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \ +} /* Close namespace. */ \ +extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size]; \ +template <> \ +/*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \ + return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \ +} \ +namespace Namespace { \ +static_assert (true, "Just so we take semicolon after.") +#define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \ +const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size] + +/* Specializaitons for arbitrary-content Null objects expressed as struct initializer. */ +#define DECLARE_NULL_INSTANCE(Type) \ +extern HB_INTERNAL const Type _hb_Null_##Type; \ +template <> \ +/*static*/ inline const Type& Null<Type> (void) { \ + return _hb_Null_##Type; \ +} \ +static_assert (true, "Just so we take semicolon after.") +#define DEFINE_NULL_INSTANCE(Type) \ +const Type _hb_Null_##Type + +/* Global writable pool. Enlarge as necessary. */ + +/* To be fully correct, CrapPool must be thread_local. However, we do not rely on CrapPool + * for correct operation. It only exist to catch and divert program logic bugs instead of + * causing bad memory access. So, races there are not actually introducing incorrectness + * in the code. Has ~12kb binary size overhead to have it, also clang build fails with it. */ +extern HB_INTERNAL +/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; + +/* CRAP pool: Common Region for Access Protection. */ +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); + return *obj; +} +#define Crap(Type) Crap<Type>() + +template <typename Type> +struct CrapOrNull { + static inline Type & get (void) { return Crap(Type); } +}; +template <typename Type> +struct CrapOrNull<const Type> { + static inline Type const & get (void) { return Null(Type); } +}; +#define CrapOrNull(Type) CrapOrNull<Type>::get () + + +#endif /* HB_NULL_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh index 36d27a8913e..47255488274 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh @@ -35,9 +35,107 @@ #include "hb-private.hh" #include "hb-atomic-private.hh" #include "hb-mutex-private.hh" +#include "hb-vector-private.hh" -/* reference_count */ +/* + * Lockable set + */ + +template <typename item_t, typename lock_t> +struct hb_lockable_set_t +{ + hb_vector_t <item_t, 1> items; + + inline void init (void) { items.init (); } + + template <typename T> + inline item_t *replace_or_insert (T v, lock_t &l, bool replace) + { + l.lock (); + item_t *item = items.find (v); + if (item) { + if (replace) { + item_t old = *item; + *item = v; + l.unlock (); + old.fini (); + } + else { + item = nullptr; + l.unlock (); + } + } else { + item = items.push (v); + l.unlock (); + } + return item; + } + + template <typename T> + inline void remove (T v, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (item) { + item_t old = *item; + *item = items[items.len - 1]; + items.pop (); + l.unlock (); + old.fini (); + } else { + l.unlock (); + } + } + + template <typename T> + inline bool find (T v, item_t *i, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (item) + *i = *item; + l.unlock (); + return !!item; + } + + template <typename T> + inline item_t *find_or_insert (T v, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (!item) { + item = items.push (v); + } + l.unlock (); + return item; + } + + inline void fini (lock_t &l) + { + if (!items.len) { + /* No need for locking. */ + items.fini (); + return; + } + l.lock (); + while (items.len) { + item_t old = items[items.len - 1]; + items.pop (); + l.unlock (); + old.fini (); + l.lock (); + } + items.fini (); + l.unlock (); + } + +}; + + +/* + * Reference-count. + */ #define HB_REFERENCE_COUNT_INERT_VALUE 0 #define HB_REFERENCE_COUNT_POISON_VALUE -0x0000DEAD @@ -89,7 +187,9 @@ struct hb_user_data_array_t }; -/* object_header */ +/* + * Object header + */ struct hb_object_header_t { @@ -103,7 +203,9 @@ struct hb_object_header_t }; -/* object */ +/* + * Object + */ template <typename Type> static inline void hb_object_trace (const Type *obj, const char *function) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh index bae2eed81a6..5580565f118 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh @@ -140,7 +140,6 @@ struct Tag : HBUINT32 public: DEFINE_SIZE_STATIC (4); }; -DEFINE_NULL_DATA (OT, Tag, " "); /* Glyph index number, same as uint16 (length = 16 bits) */ typedef HBUINT16 GlyphID; @@ -152,7 +151,7 @@ typedef HBUINT16 NameID; struct Index : HBUINT16 { static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; }; -DEFINE_NULL_DATA (OT, Index, "\xff\xff"); +DECLARE_NULL_NAMESPACE_BYTES (OT, Index); /* Offset, Null offset = 0 */ template <typename Type> 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 8310230328b..025f943762c 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 @@ -41,13 +41,39 @@ struct hb_ot_font_t { + inline void init (hb_face_t *face) + { + cmap.init (face); + h_metrics.init (face); + v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */ + + this->face = face; + glyf.init (); + cbdt.init (); + post.init (); + kern.init (); + } + inline void fini (void) + { + cmap.fini (); + h_metrics.fini (); + v_metrics.fini (); + + glyf.fini (); + cbdt.fini (); + post.fini (); + kern.fini (); + } + OT::cmap::accelerator_t cmap; OT::hmtx::accelerator_t h_metrics; OT::vmtx::accelerator_t v_metrics; - OT::hb_lazy_loader_t<OT::glyf::accelerator_t> glyf; - OT::hb_lazy_loader_t<OT::CBDT::accelerator_t> cbdt; - OT::hb_lazy_loader_t<OT::post::accelerator_t> post; - OT::hb_lazy_loader_t<OT::kern::accelerator_t> kern; + + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ + hb_object_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; + hb_object_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; + hb_object_lazy_loader_t<3, OT::post::accelerator_t> post; + hb_object_lazy_loader_t<4, OT::kern::accelerator_t> kern; }; @@ -59,13 +85,7 @@ _hb_ot_font_create (hb_face_t *face) if (unlikely (!ot_font)) return nullptr; - ot_font->cmap.init (face); - ot_font->h_metrics.init (face); - ot_font->v_metrics.init (face, ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ - ot_font->glyf.init (face); - ot_font->cbdt.init (face); - ot_font->post.init (face); - ot_font->kern.init (face); + ot_font->init (face); return ot_font; } @@ -75,13 +95,7 @@ _hb_ot_font_destroy (void *data) { hb_ot_font_t *ot_font = (hb_ot_font_t *) data; - ot_font->cmap.fini (); - ot_font->h_metrics.fini (); - ot_font->v_metrics.fini (); - ot_font->glyf.fini (); - ot_font->cbdt.fini (); - ot_font->post.fini (); - ot_font->kern.fini (); + ot_font->fini (); free (ot_font); } 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 ce6ee1e22f7..bcf89e46247 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 @@ -238,9 +238,9 @@ struct glyf hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (face); const head *head_table = head_blob->as<head> (); - if (head_table == &Null(head) || (unsigned int) head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0) + if (head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0) { - /* head table is not present, or in an unknown format. Leave num_glyphs=0, that takes care of disabling us. */ + /* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */ hb_blob_destroy (head_blob); return; } @@ -270,7 +270,7 @@ struct glyf inline bool get_composite (hb_codepoint_t glyph, CompositeGlyphHeader::Iterator *composite /* OUT */) const { - if (this->glyf_table == &Null(glyf) || !num_glyphs) + if (unlikely (!num_glyphs)) return false; unsigned int start_offset, end_offset; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh index 965e30a088f..fded120be28 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh @@ -141,8 +141,8 @@ struct head * -1: Only strongly right to left; * -2: Like -1 but also contains neutrals. */ public: - HBINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ - HBINT16 glyphDataFormat; /* 0 for current format. */ + HBUINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ + HBUINT16 glyphDataFormat; /* 0 for current format. */ DEFINE_SIZE_STATIC (54); }; 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 33dce89099b..96da07fb5cd 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 @@ -33,13 +33,16 @@ namespace OT { -#define NOT_INDEXED ((unsigned int) -1) - /* * BASE -- Baseline * 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; } @@ -52,7 +55,7 @@ struct BaseCoordFormat1 protected: HBUINT16 format; /* Format identifier--format = 1 */ - HBINT16 coordinate; /* X or Y value, in design units */ + FWORD coordinate; /* X or Y value, in design units */ public: DEFINE_SIZE_STATIC (4); }; @@ -73,7 +76,7 @@ struct BaseCoordFormat2 protected: HBUINT16 format; /* Format identifier--format = 2 */ - HBINT16 coordinate; /* X or Y value, in design units */ + FWORD coordinate; /* X or Y value, in design units */ GlyphID referenceGlyph; /* Glyph ID of control glyph */ HBUINT16 coordPoint; /* Index of contour point on the * reference glyph */ @@ -97,7 +100,7 @@ struct BaseCoordFormat3 protected: HBUINT16 format; /* Format identifier--format = 3 */ - HBINT16 coordinate; /* X or Y value, in design units */ + 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). */ @@ -109,6 +112,7 @@ struct BaseCoord { inline int get_coord (void) const { + /* XXX wire up direction and font. */ switch (u.format) { case 1: return u.format1.get_coord (); case 2: return u.format2.get_coord (); @@ -142,14 +146,10 @@ 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(); } + inline int get_min_value (void) const { return (this+minCoord).get_coord(); } + inline int get_max_value (void) const { return (this+maxCoord).get_coord(); } - inline const Tag &get_tag () const - { return tag; } + inline const Tag& get_tag () const { return tag; } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -181,7 +181,7 @@ struct MinMax unsigned int count = featMinMaxRecords.len; for (unsigned int i = 0; i < count; i++) { - Tag tag = featMinMaxRecords[i].get_tag(); + Tag tag = featMinMaxRecords[i].get_tag (); int cmp = tag.cmp(featureTableTag); if (cmp == 0) return i; if (cmp > 0) return NOT_INDEXED; @@ -233,13 +233,13 @@ struct BaseLangSysRecord { return baseLangSysTag; } inline unsigned int get_feature_tag_index (Tag featureTableTag) const - { return (this+minMax).get_feature_tag_index(featureTableTag); } + { return (this+minMax).get_feature_tag_index( featureTableTag); } inline int get_min_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_min_value(featureTableTagIndex); } + { return (this+minMax).get_min_value( featureTableTagIndex); } inline int get_max_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_max_value(featureTableTagIndex); } + { return (this+minMax).get_max_value (featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -263,34 +263,34 @@ struct BaseValues inline int get_base_coord (unsigned int baselineTagIndex) const { - return (this+baseCoords[baselineTagIndex]).get_coord(); + return (this+baseCoords[baselineTagIndex]).get_coord (); } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - defaultIndex <= baseCoordCount && - baseCoords.sanitize (c, this)); + baseCoords.sanitize (c, this)); } protected: Index defaultIndex; - HBUINT16 baseCoordCount; OffsetArrayOf<BaseCoord> baseCoords; public: - DEFINE_SIZE_ARRAY (6, baseCoords); - + DEFINE_SIZE_ARRAY (4, baseCoords); }; struct BaseScript { inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const { + /* XXX bsearch */ Tag tag; int cmp; - for (unsigned int i = 0; i < baseLangSysCount; i++) { - tag = baseLangSysRecords[i].get_tag(); + 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; @@ -301,51 +301,50 @@ struct BaseScript { inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (baseLangSysIndex == NOT_INDEXED) { + if (baseLangSysIndex == NOT_INDEXED) + { if (unlikely(defaultMinMax)) return NOT_INDEXED; - return (this+defaultMinMax).get_feature_tag_index(featureTableTag); + return (this+defaultMinMax).get_feature_tag_index (featureTableTag); } - if (unlikely(baseLangSysIndex >= baseLangSysCount)) return NOT_INDEXED; - return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index(featureTableTag); + return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index (featureTableTag); } inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value(featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); + return (this+defaultMinMax).get_min_value (featureTableTagIndex); + return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); } inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value(featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); + return (this+defaultMinMax).get_min_value (featureTableTagIndex); + return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); } inline unsigned int get_default_base_tag_index (void) const - { return (this+baseValues).get_default_base_tag_index(); } + { return (this+baseValues).get_default_base_tag_index (); } inline int get_base_coord (unsigned int baselineTagIndex) const - { return (this+baseValues).get_base_coord(baselineTagIndex); } + { return (this+baseValues).get_base_coord (baselineTagIndex); } 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)); + baseValues.sanitize (c, this) && + defaultMinMax.sanitize (c, this) && + baseLangSysRecords.sanitize (c, this)); } protected: - OffsetTo<BaseValues> baseValues; - OffsetTo<MinMax> defaultMinMax; - HBUINT16 baseLangSysCount; - ArrayOf<BaseLangSysRecord> baseLangSysRecords; + OffsetTo<BaseValues> baseValues; + OffsetTo<MinMax> defaultMinMax; + ArrayOf<BaseLangSysRecord> baseLangSysRecords; public: - DEFINE_SIZE_ARRAY (8, baseLangSysRecords); + DEFINE_SIZE_ARRAY (6, baseLangSysRecords); }; @@ -355,29 +354,28 @@ struct BaseScriptRecord { { return baseScriptTag; } inline unsigned int get_default_base_tag_index(void) const - { return (this+baseScript).get_default_base_tag_index(); } + { return (this+baseScript).get_default_base_tag_index (); } inline int get_base_coord(unsigned int baselineTagIndex) const - { return (this+baseScript).get_base_coord(baselineTagIndex); } + { 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); } + { 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); } + { 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); } + { 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); } + { return (this+baseScript).get_min_value (baseLangSysIndex, featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseScript != Null(OffsetTo<BaseScript>) && - baseScript.sanitize (c, base)); + baseScript.sanitize (c, base)); } protected: @@ -392,7 +390,9 @@ struct BaseScriptList { inline unsigned int get_base_script_index (Tag baseScriptTag) const { - for (unsigned int i = 0; i < baseScriptCount; i++) + /* 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; @@ -400,7 +400,6 @@ struct BaseScriptList { inline unsigned int get_default_base_tag_index (unsigned int baseScriptIndex) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_default_base_tag_index(); } @@ -411,13 +410,11 @@ struct BaseScriptList { inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_lang_tag_index(baseLangSysTag); } inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_feature_tag_index(baseLangSysIndex, featureTableTag); } @@ -435,24 +432,23 @@ struct BaseScriptList { { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseScriptRecords.sanitize (c, this)); + baseScriptRecords.sanitize (c, this)); } protected: - HBUINT16 baseScriptCount; - ArrayOf<BaseScriptRecord> baseScriptRecords; + ArrayOf<BaseScriptRecord> baseScriptRecords; public: - DEFINE_SIZE_ARRAY (4, baseScriptRecords); - + DEFINE_SIZE_ARRAY (2, baseScriptRecords); }; struct BaseTagList { - - inline unsigned int get_tag_index(Tag baselineTag) const + inline unsigned int get_tag_index (Tag baselineTag) const { - for (unsigned int i = 0; i < baseTagCount; i++) + /* TODO bsearch? */ + unsigned int count = baselineTags.len; + for (unsigned int i = 0; i < count; i++) if (baselineTags[i] == baselineTag) return i; return NOT_INDEXED; @@ -465,42 +461,37 @@ struct BaseTagList } protected: - HBUINT16 baseTagCount; SortedArrayOf<Tag> baselineTags; public: - DEFINE_SIZE_ARRAY (4, baselineTags); + DEFINE_SIZE_ARRAY (2, baselineTags); }; struct Axis { - inline unsigned int get_base_tag_index(Tag baselineTag) const + inline unsigned int get_base_tag_index (Tag baselineTag) const { - if (unlikely(baseTagList == Null(OffsetTo<BaseTagList>))) return NOT_INDEXED; return (this+baseTagList).get_tag_index(baselineTag); } inline unsigned int get_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; return (this+baseScriptList).get_default_base_tag_index(baseScriptIndex); } - inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_base_coord (unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { return (this+baseScriptList).get_base_coord(baseScriptIndex, baselineTagIndex); } inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; return (this+baseScriptList).get_lang_tag_index(baseScriptIndex, baseLangSysTag); } inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; return (this+baseScriptList).get_feature_tag_index(baseScriptIndex, baseLangSysIndex, featureTableTag); } @@ -518,13 +509,13 @@ struct Axis { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseTagList.sanitize (c, this) && - baseScriptList.sanitize (c, this)); + baseTagList.sanitize (c, this) && + baseScriptList.sanitize (c, this)); } protected: - OffsetTo<BaseTagList> baseTagList; - OffsetTo<BaseScriptList> baseScriptList; + OffsetTo<BaseTagList> baseTagList; + OffsetTo<BaseScriptList> baseScriptList; public: DEFINE_SIZE_STATIC (4); @@ -534,96 +525,78 @@ struct BASE { static const hb_tag_t tableTag = HB_OT_TAG_BASE; - inline bool has_vert_axis(void) - { return vertAxis != Null(OffsetTo<Axis>); } + inline bool has_v_axis(void) { return vAxis != 0; } - inline bool has_horiz_axis(void) - { return horizAxis != Null(OffsetTo<Axis>); } + inline bool has_h_axis(void) { return hAxis != 0; } - // horizontal axis base coords: - - inline unsigned int get_horiz_base_tag_index(Tag baselineTag) const + inline unsigned int get_h_base_tag_index (Tag baselineTag) const { - if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+horizAxis).get_base_tag_index(baselineTag); + return (this+hAxis).get_base_tag_index(baselineTag); } - inline unsigned int get_horiz_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const + inline unsigned int get_h_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+horizAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); + return (this+hAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); } - inline int get_horiz_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_h_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { - return (this+horizAxis).get_base_coord(baseScriptIndex, baselineTagIndex); + return (this+hAxis).get_base_coord(baseScriptIndex, baselineTagIndex); } - // vertical axis base coords: - - inline unsigned int get_vert_base_tag_index(Tag baselineTag) const + inline unsigned int get_v_base_tag_index(Tag baselineTag) const { - if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+vertAxis).get_base_tag_index(baselineTag); + return (this+vAxis).get_base_tag_index(baselineTag); } - inline unsigned int get_vert_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const + inline unsigned int get_v_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+vertAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); + return (this+vAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); } - inline int get_vert_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_v_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { - return (this+vertAxis).get_base_coord(baseScriptIndex, baselineTagIndex); + return (this+vAxis).get_base_coord(baseScriptIndex, baselineTagIndex); } - // horizontal axis min/max coords: - - inline unsigned int get_horiz_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const + inline unsigned int get_h_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+horizAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); + return (this+hAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); } - inline unsigned int get_horiz_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const + inline unsigned int get_h_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+horizAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); + return (this+hAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); } - inline int get_horiz_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_h_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+horizAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+hAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - inline int get_horiz_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_h_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+horizAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+hAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - // vertical axis min/max coords: - - inline unsigned int get_vert_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const + inline unsigned int get_v_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+vertAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); + return (this+vAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); } - inline unsigned int get_vert_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const + inline unsigned int get_v_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; - return (this+vertAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); + return (this+vAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); } - inline int get_vert_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_v_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+vertAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+vAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - inline int get_vert_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_v_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+vertAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+vAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -631,15 +604,15 @@ struct BASE TRACE_SANITIZE (this); return_trace (c->check_struct (this) && likely (version.major == 1) && - horizAxis.sanitize (c, this) && - vertAxis.sanitize (c, this) && + hAxis.sanitize (c, this) && + vAxis.sanitize (c, this) && (version.to_int () < 0x00010001u || varStore.sanitize (c, this))); } protected: FixedVersion<> version; - OffsetTo<Axis> horizAxis; - OffsetTo<Axis> vertAxis; + OffsetTo<Axis> hAxis; + OffsetTo<Axis> vAxis; LOffsetTo<VariationStore> varStore; /* Offset to the table of Item Variation * Store--from beginning of BASE diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh index 2da6e315ca7..89d5eae494f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh @@ -173,7 +173,7 @@ struct RangeRecord public: DEFINE_SIZE_STATIC (6); }; -DEFINE_NULL_DATA (OT, RangeRecord, "\000\001"); +DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord); struct IndexArray : ArrayOf<Index> @@ -240,8 +240,7 @@ struct LangSys public: DEFINE_SIZE_ARRAY (6, featureIndex); }; -DEFINE_NULL_DATA (OT, LangSys, "\0\0\xFF\xFF"); - +DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys); struct Script { 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 60a8d3adff5..d2b41a8ef50 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 @@ -349,6 +349,7 @@ struct GDEF ComponentGlyph = 4 }; + inline bool has_data (void) const { return version.to_int () != 0; } inline bool has_glyph_classes (void) const { return glyphClassDef != 0; } inline unsigned int get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh index b52c0144f14..fe34a328b27 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh @@ -1628,14 +1628,14 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) template <typename context_t> /*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh index eef8dc5462a..1d5a02a021d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh @@ -1335,7 +1335,7 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) { _hb_buffer_assert_gsubgpos_vars (buffer); - const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef; + const GDEF &gdef = *hb_ot_layout_from_face (font->face)->table.GDEF; unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) { @@ -1359,14 +1359,14 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) template <typename context_t> /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos-private.hh index 747811e6a6b..40a2fc4ccd3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos-private.hh @@ -480,7 +480,7 @@ struct hb_ot_apply_context_t : iter_input (), iter_context (), font (font_), face (font->face), buffer (buffer_), recurse_func (nullptr), - gdef (*hb_ot_layout_from_face (face)->gdef), + gdef (*hb_ot_layout_from_face (face)->table.GDEF), var_store (gdef.get_var_store ()), direction (buffer_->props.direction), lookup_mask (1), @@ -2320,6 +2320,7 @@ struct Extension struct GSUBGPOS { + inline bool has_data (void) const { return version.to_int () != 0; } inline unsigned int get_script_count (void) const { return (this+scriptList).len; } inline const Tag& get_script_tag (unsigned int i) const diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-private.hh index 6fe673e9118..2a74135c8d2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-private.hh @@ -121,25 +121,6 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font, * hb_ot_layout_t */ -namespace OT { - struct BASE; - struct COLR; - struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; - struct MATH; - struct fvar; - struct avar; -} - -namespace AAT { - struct ankr; - struct kerx; - struct morx; - struct trak; -} - struct hb_ot_layout_lookup_accelerator_t { template <typename TLookup> @@ -161,28 +142,73 @@ struct hb_ot_layout_lookup_accelerator_t hb_set_digest_t digest; }; +/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*. + * This is as good as any place. */ +#define HB_OT_LAYOUT_TABLES \ + /* OpenType shaping. */ \ + HB_OT_LAYOUT_TABLE(OT, GDEF) \ + HB_OT_LAYOUT_TABLE(OT, GSUB) \ + HB_OT_LAYOUT_TABLE(OT, GPOS) \ + HB_OT_LAYOUT_TABLE(OT, JSTF) \ + HB_OT_LAYOUT_TABLE(OT, BASE) \ + /* AAT shaping. */ \ + HB_OT_LAYOUT_TABLE(AAT, morx) \ + HB_OT_LAYOUT_TABLE(AAT, kerx) \ + HB_OT_LAYOUT_TABLE(AAT, ankr) \ + HB_OT_LAYOUT_TABLE(AAT, trak) \ + /* OpenType variations. */ \ + HB_OT_LAYOUT_TABLE(OT, fvar) \ + HB_OT_LAYOUT_TABLE(OT, avar) \ + HB_OT_LAYOUT_TABLE(OT, MVAR) \ + /* OpenType color. */ \ + HB_OT_LAYOUT_TABLE(OT, COLR) \ + HB_OT_LAYOUT_TABLE(OT, CPAL) \ + HB_OT_LAYOUT_TABLE(OT, CBDT) \ + HB_OT_LAYOUT_TABLE(OT, CBLC) \ + HB_OT_LAYOUT_TABLE(OT, sbix) \ + HB_OT_LAYOUT_TABLE(OT, svg) \ + /* OpenType math. */ \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + /* OpenType fundamentals. */ \ + HB_OT_LAYOUT_TABLE(OT, post) \ + /* */ + +/* Declare tables. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + struct hb_ot_layout_t { - hb_blob_t *gdef_blob; - hb_blob_t *gsub_blob; - hb_blob_t *gpos_blob; - - const struct OT::GDEF *gdef; - const struct OT::GSUB *gsub; - const struct OT::GPOS *gpos; - - /* TODO Move the following out of this struct. */ - OT::hb_table_lazy_loader_t<struct OT::BASE> base; - OT::hb_table_lazy_loader_t<struct OT::MATH> math; - OT::hb_table_lazy_loader_t<struct OT::fvar> fvar; - OT::hb_table_lazy_loader_t<struct OT::avar> avar; - OT::hb_table_lazy_loader_t<struct AAT::morx> morx; - unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; hb_ot_layout_lookup_accelerator_t *gsub_accels; hb_ot_layout_lookup_accelerator_t *gpos_accels; + + /* Various non-shaping tables. */ + struct tables_t + { + HB_INTERNAL void init0 (hb_face_t *face); + HB_INTERNAL void fini (void); + +#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \ + HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) + enum order_t + { + ORDER_ZERO, +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + }; + + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + hb_table_lazy_loader_t<HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), struct Namespace::Type> Type; + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + } table; }; 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 c790c3ceb3d..09ff0e6c0d7 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 @@ -31,6 +31,7 @@ #include "hb-open-type-private.hh" #include "hb-ot-layout-private.hh" #include "hb-ot-map-private.hh" +#include "hb-map-private.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" @@ -44,9 +45,124 @@ #include "hb-ot-color-sbix-table.hh" #include "hb-ot-color-svg-table.hh" #include "hb-ot-name-table.hh" -#include "hb-map-private.hh" +static bool +_hb_ot_blacklist_gdef (unsigned int gdef_len, + unsigned int gsub_len, + unsigned int gpos_len) +{ + /* The ugly business of blacklisting individual fonts' tables happen here! + * See this thread for why we finally had to bend in and do this: + * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html + * + * In certain versions of Times New Roman Italic and Bold Italic, + * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) + * in GDEF. Many versions of Tahoma have bad GDEF tables that + * incorrectly classify some spacing marks such as certain IPA + * symbols as glyph class 3. So do older versions of Microsoft + * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. + * + * Nuke the GDEF tables of to avoid unwanted width-zeroing. + * + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 + */ +#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z)) + switch ENCODE(gdef_len, gsub_len, gpos_len) + { + /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ + case ENCODE (442, 2874, 42038): + /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ + case ENCODE (430, 2874, 40662): + /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ + case ENCODE (442, 2874, 39116): + /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ + case ENCODE (430, 2874, 39374): + /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ + case ENCODE (490, 3046, 41638): + /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ + case ENCODE (478, 3046, 41902): + /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ + case ENCODE (898, 12554, 46470): + /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ + case ENCODE (910, 12566, 47732): + /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ + case ENCODE (928, 23298, 59332): + /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ + case ENCODE (940, 23310, 60732): + /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (964, 23836, 60072): + /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (976, 23832, 61456): + /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ + case ENCODE (994, 24474, 60336): + /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ + case ENCODE (1006, 24470, 61740): + /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1006, 24576, 61346): + /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1018, 24572, 62828): + /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ + case ENCODE (1006, 24576, 61352): + /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ + case ENCODE (1018, 24572, 62834): + /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ + case ENCODE (832, 7324, 47162): + /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ + case ENCODE (844, 7302, 45474): + /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ + case ENCODE (180, 13054, 7254): + /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ + case ENCODE (192, 12638, 7254): + /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ + case ENCODE (192, 12690, 7254): + /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ + /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ + case ENCODE (188, 248, 3852): + /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ + /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ + case ENCODE (188, 264, 3426): + /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ + case ENCODE (1058, 47032, 11818): + /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ + case ENCODE (1046, 47030, 12600): + /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ + case ENCODE (1058, 71796, 16770): + /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ + case ENCODE (1046, 71790, 17862): + /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ + case ENCODE (1046, 71788, 17112): + /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ + case ENCODE (1058, 71794, 17514): + /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ + case ENCODE (1330, 109904, 57938): + /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ + case ENCODE (1330, 109904, 58972): + /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf + * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ + case ENCODE (1004, 59092, 14836): + return true; +#undef ENCODE + } + return false; +} + +void hb_ot_layout_t::tables_t::init0 (hb_face_t *face) +{ + this->face = face; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} +void hb_ot_layout_t::tables_t::fini (void) +{ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} + hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { @@ -54,144 +170,33 @@ _hb_ot_layout_create (hb_face_t *face) if (unlikely (!layout)) return nullptr; - layout->gdef_blob = OT::hb_sanitize_context_t().reference_table<OT::GDEF> (face); - layout->gdef = layout->gdef_blob->as<OT::GDEF> (); + layout->table.init0 (face); - layout->gsub_blob = OT::hb_sanitize_context_t().reference_table<OT::GSUB> (face); - layout->gsub = layout->gsub_blob->as<OT::GSUB> (); + const OT::GSUB &gsub = *layout->table.GSUB; + const OT::GPOS &gpos = *layout->table.GPOS; - layout->gpos_blob = OT::hb_sanitize_context_t().reference_table<OT::GPOS> (face); - layout->gpos = layout->gpos_blob->as<OT::GPOS> (); + if (unlikely (_hb_ot_blacklist_gdef (layout->table.GDEF.get_blob ()->length, + layout->table.GSUB.get_blob ()->length, + layout->table.GPOS.get_blob ()->length))) + layout->table.GDEF.set_stored (hb_blob_get_empty ()); - layout->math.init (face); - layout->fvar.init (face); - layout->avar.init (face); - layout->morx.init (face); + unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); + unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); - { - /* - * The ugly business of blacklisting individual fonts' tables happen here! - * See this thread for why we finally had to bend in and do this: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - */ - unsigned int gdef_len = layout->gdef_blob->length; - unsigned int gsub_len = layout->gsub_blob->length; - unsigned int gpos_len = layout->gpos_blob->length; - if (0 - /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ - || (442 == gdef_len && 42038 == gpos_len && 2874 == gsub_len) - /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ - || (430 == gdef_len && 40662 == gpos_len && 2874 == gsub_len) - /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ - || (442 == gdef_len && 39116 == gpos_len && 2874 == gsub_len) - /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ - || (430 == gdef_len && 39374 == gpos_len && 2874 == gsub_len) - /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ - || (490 == gdef_len && 41638 == gpos_len && 3046 == gsub_len) - /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ - || (478 == gdef_len && 41902 == gpos_len && 3046 == gsub_len) - ) - { - /* In certain versions of Times New Roman Italic and Bold Italic, - * ASCII double quotation mark U+0022, mapped to glyph 5, has wrong - * glyph class 3 (mark) in GDEF. Nuke the GDEF to avoid zero-width - * double-quote. See: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - */ - if (3 == layout->gdef->get_glyph_class (5)) - layout->gdef = &Null(OT::GDEF); - } - else if (0 - /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ - || (898 == gdef_len && 46470 == gpos_len && 12554 == gsub_len) - /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ - || (910 == gdef_len && 47732 == gpos_len && 12566 == gsub_len) - /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ - || (928 == gdef_len && 59332 == gpos_len && 23298 == gsub_len) - /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ - || (940 == gdef_len && 60732 == gpos_len && 23310 == gsub_len) - /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (964 == gdef_len && 60072 == gpos_len && 23836 == gsub_len) - /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (976 == gdef_len && 61456 == gpos_len && 23832 == gsub_len) - /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ - || (994 == gdef_len && 60336 == gpos_len && 24474 == gsub_len) - /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ - || (1006 == gdef_len && 61740 == gpos_len && 24470 == gsub_len) - /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1006 == gdef_len && 61346 == gpos_len && 24576 == gsub_len) - /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1018 == gdef_len && 62828 == gpos_len && 24572 == gsub_len) - /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ - || (1006 == gdef_len && 61352 == gpos_len && 24576 == gsub_len) - /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ - || (1018 == gdef_len && 62834 == gpos_len && 24572 == gsub_len) - /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ - || (832 == gdef_len && 47162 == gpos_len && 7324 == gsub_len) - /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ - || (844 == gdef_len && 45474 == gpos_len && 7302 == gsub_len) - /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ - || (180 == gdef_len && 7254 == gpos_len && 13054 == gsub_len) - /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ - || (192 == gdef_len && 7254 == gpos_len && 12638 == gsub_len) - /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ - || (192 == gdef_len && 7254 == gpos_len && 12690 == gsub_len) - /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ - /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ - || (188 == gdef_len && 3852 == gpos_len && 248 == gsub_len) - /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ - /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ - || (188 == gdef_len && 3426 == gpos_len && 264 == gsub_len) - /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ - || (1058 == gdef_len && 11818 == gpos_len && 47032 == gsub_len) - /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ - || (1046 == gdef_len && 12600 == gpos_len && 47030 == gsub_len) - /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ - || (1058 == gdef_len && 16770 == gpos_len && 71796 == gsub_len) - /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ - || (1046 == gdef_len && 17862 == gpos_len && 71790 == gsub_len) - /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ - || (1046 == gdef_len && 17112 == gpos_len && 71788 == gsub_len) - /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ - || (1058 == gdef_len && 17514 == gpos_len && 71794 == gsub_len) - /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ - || (1330 == gdef_len && 57938 == gpos_len && 109904 == gsub_len) - /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ - || (1330 == gdef_len && 58972 == gpos_len && 109904 == gsub_len) - /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf - * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ - || (1004 == gdef_len && 14836 == gpos_len && 59092 == gsub_len) - ) - { - /* Many versions of Tahoma have bad GDEF tables that incorrectly classify some spacing marks - * such as certain IPA symbols as glyph class 3. So do older versions of Microsoft Himalaya, - * and the version of Cantarell shipped by Ubuntu 16.04. - * Nuke the GDEF tables of these fonts to avoid unwanted width-zeroing. - * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 - */ - layout->gdef = &Null(OT::GDEF); - } - } - - layout->gsub_lookup_count = layout->gsub->get_lookup_count (); - layout->gpos_lookup_count = layout->gpos->get_lookup_count (); + layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); - layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); - layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); - - if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) || - (layout->gpos_lookup_count && !layout->gpos_accels))) + if (unlikely ((gsub_lookup_count && !layout->gsub_accels) || + (gpos_lookup_count && !layout->gpos_accels))) { _hb_ot_layout_destroy (layout); return nullptr; } - for (unsigned int i = 0; i < layout->gsub_lookup_count; i++) - layout->gsub_accels[i].init (layout->gsub->get_lookup (i)); - for (unsigned int i = 0; i < layout->gpos_lookup_count; i++) - layout->gpos_accels[i].init (layout->gpos->get_lookup (i)); + for (unsigned int i = 0; i < gsub_lookup_count; i++) + layout->gsub_accels[i].init (gsub.get_lookup (i)); + for (unsigned int i = 0; i < gpos_lookup_count; i++) + layout->gpos_accels[i].init (gpos.get_lookup (i)); return layout; } @@ -209,14 +214,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) free (layout->gsub_accels); free (layout->gpos_accels); - hb_blob_destroy (layout->gdef_blob); - hb_blob_destroy (layout->gsub_blob); - hb_blob_destroy (layout->gpos_blob); - - layout->math.fini (); - layout->fvar.fini (); - layout->avar.fini (); - layout->morx.fini (); + layout->table.fini (); free (layout); } @@ -233,19 +231,19 @@ static inline const OT::GDEF& _get_gdef (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF); - return *hb_ot_layout_from_face (face)->gdef; + return *hb_ot_layout_from_face (face)->table.GDEF; } static inline const OT::GSUB& _get_gsub (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB); - return *hb_ot_layout_from_face (face)->gsub; + return *hb_ot_layout_from_face (face)->table.GSUB; } static inline const OT::GPOS& _get_gpos (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS); - return *hb_ot_layout_from_face (face)->gpos; + return *hb_ot_layout_from_face (face)->table.GPOS; } /* @@ -853,13 +851,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, { case HB_OT_TAG_GSUB: { - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); l.collect_glyphs (&c); return; } case HB_OT_TAG_GPOS: { - const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index); + const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index); l.collect_glyphs (&c); return; } @@ -906,7 +904,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, hb_bool_t hb_ot_layout_has_substitution (hb_face_t *face) { - return &_get_gsub (face) != &Null(OT::GSUB); + return _get_gsub (face).has_data (); } /** @@ -935,7 +933,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false; OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context); - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]); } @@ -1008,7 +1006,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face, hb_bool_t hb_ot_layout_has_positioning (hb_face_t *face) { - return &_get_gpos (face) != &Null(OT::GPOS); + return _get_gpos (face).has_data (); } void @@ -1093,7 +1091,7 @@ struct GSUBProxy typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gsub), + table (*hb_ot_layout_from_face (face)->table.GSUB), accels (hb_ot_layout_from_face (face)->gsub_accels) {} const OT::GSUB &table; @@ -1107,7 +1105,7 @@ struct GPOSProxy typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gpos), + table (*hb_ot_layout_from_face (face)->table.GPOS), accels (hb_ot_layout_from_face (face)->gpos_accels) {} const OT::GPOS &table; @@ -1116,7 +1114,7 @@ struct GPOSProxy struct hb_get_subtables_context_t : - OT::hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY> + hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY> { template <typename Type> static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c) @@ -1343,5 +1341,5 @@ hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c, // hb_bool_t // hb_ot_base_has_data (hb_face_t *face) // { -// return &_get_base (face) != &Null(OT::BASE); +// return _get_base (face).has_data (); // } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh index 5fef2d28f25..2dd714580d5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh @@ -686,6 +686,8 @@ struct MATH { static const hb_tag_t tableTag = HB_OT_TAG_MATH; + inline bool has_data (void) const { return version.to_int () != 0; } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); 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 1667a7da819..66ce207a799 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 @@ -34,7 +34,7 @@ _get_math (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->math.get ()); + return *(layout->table.MATH.get ()); } /* @@ -55,7 +55,7 @@ _get_math (hb_face_t *face) hb_bool_t hb_ot_math_has_data (hb_face_t *face) { - return &_get_math (face) != &Null(OT::MATH); + return _get_math (face).has_data (); } /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh index 5a257f042d0..a55511aa069 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh @@ -79,12 +79,12 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS * May not be good-enough for presidential candidate interviews, but good-enough for us... */ hb_stable_sort (&glyphs[0], num_glyphs, (int(*)(const OT::GlyphID*, const OT::GlyphID *)) OT::GlyphID::cmp, &substitutes[0]); - OT::Supplier<OT::GlyphID> glyphs_supplier (glyphs, num_glyphs); - OT::Supplier<OT::GlyphID> substitutes_supplier (substitutes, num_glyphs); + Supplier<OT::GlyphID> glyphs_supplier (glyphs, num_glyphs); + Supplier<OT::GlyphID> substitutes_supplier (substitutes, num_glyphs); /* Each glyph takes four bytes max, and there's some overhead. */ char buf[(SHAPING_TABLE_LAST - SHAPING_TABLE_FIRST + 1) * 4 + 128]; - OT::hb_serialize_context_t c (buf, sizeof (buf)); + hb_serialize_context_t c (buf, sizeof (buf)); OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); bool ret = lookup->serialize_single (&c, OT::LookupFlag::IgnoreMarks, @@ -155,15 +155,15 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN if (!num_ligatures) return nullptr; - OT::Supplier<OT::GlyphID> first_glyphs_supplier (first_glyphs, num_first_glyphs); - OT::Supplier<unsigned int > ligature_per_first_glyph_count_supplier (ligature_per_first_glyph_count_list, num_first_glyphs); - OT::Supplier<OT::GlyphID> ligatures_supplier (ligature_list, num_ligatures); - OT::Supplier<unsigned int > component_count_supplier (component_count_list, num_ligatures); - OT::Supplier<OT::GlyphID> component_supplier (component_list, num_ligatures); + Supplier<OT::GlyphID> first_glyphs_supplier (first_glyphs, num_first_glyphs); + Supplier<unsigned int > ligature_per_first_glyph_count_supplier (ligature_per_first_glyph_count_list, num_first_glyphs); + Supplier<OT::GlyphID> ligatures_supplier (ligature_list, num_ligatures); + Supplier<unsigned int > component_count_supplier (component_count_list, num_ligatures); + Supplier<OT::GlyphID> component_supplier (component_list, num_ligatures); /* 16 bytes per ligature ought to be enough... */ char buf[ARRAY_LENGTH_CONST (ligature_list) * 16 + 128]; - OT::hb_serialize_context_t c (buf, sizeof (buf)); + hb_serialize_context_t c (buf, sizeof (buf)); OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); bool ret = lookup->serialize_ligature (&c, OT::LookupFlag::IgnoreMarks, @@ -205,8 +205,6 @@ struct arabic_fallback_plan_t hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS]; }; -static const arabic_fallback_plan_t arabic_fallback_plan_nil = {}; - #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_WIN1256) #define HB_WITH_WIN1256 #endif @@ -215,7 +213,8 @@ static const arabic_fallback_plan_t arabic_fallback_plan_nil = {}; #include "hb-ot-shape-complex-arabic-win1256.hh" #endif -struct ManifestLookup { +struct ManifestLookup +{ OT::Tag tag; OT::OffsetTo<OT::SubstLookup> lookupOffset; }; @@ -299,7 +298,7 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan, { arabic_fallback_plan_t *fallback_plan = (arabic_fallback_plan_t *) calloc (1, sizeof (arabic_fallback_plan_t)); if (unlikely (!fallback_plan)) - return const_cast<arabic_fallback_plan_t *> (&arabic_fallback_plan_nil); + return const_cast<arabic_fallback_plan_t *> (&Null(arabic_fallback_plan_t)); fallback_plan->num_lookups = 0; fallback_plan->free_lookups = false; @@ -314,14 +313,15 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan, if (arabic_fallback_plan_init_win1256 (fallback_plan, plan, font)) return fallback_plan; + assert (fallback_plan->num_lookups == 0); free (fallback_plan); - return const_cast<arabic_fallback_plan_t *> (&arabic_fallback_plan_nil); + return const_cast<arabic_fallback_plan_t *> (&Null(arabic_fallback_plan_t)); } static void arabic_fallback_plan_destroy (arabic_fallback_plan_t *fallback_plan) { - if (!fallback_plan || fallback_plan == &arabic_fallback_plan_nil) + if (!fallback_plan || fallback_plan->num_lookups == 0) return; for (unsigned int i = 0; i < fallback_plan->num_lookups; i++) 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 e40a0e94a3d..71632b563c4 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 @@ -27,8 +27,8 @@ */ #define HB_SHAPER ot -#define hb_ot_shaper_face_data_t hb_ot_layout_t -#define hb_ot_shaper_shape_plan_data_t hb_ot_shape_plan_t +#define hb_ot_face_data_t hb_ot_layout_t +#define hb_ot_shape_plan_data_t hb_ot_shape_plan_t #include "hb-shaper-impl-private.hh" #include "hb-ot-shape-private.hh" @@ -132,14 +132,14 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, HB_SHAPER_DATA_ENSURE_DEFINE(ot, face) -hb_ot_shaper_face_data_t * +hb_ot_face_data_t * _hb_ot_shaper_face_data_create (hb_face_t *face) { return _hb_ot_layout_create (face); } void -_hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data) +_hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data) { _hb_ot_layout_destroy (data); } @@ -151,16 +151,16 @@ _hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data) HB_SHAPER_DATA_ENSURE_DEFINE(ot, font) -struct hb_ot_shaper_font_data_t {}; +struct hb_ot_font_data_t {}; -hb_ot_shaper_font_data_t * +hb_ot_font_data_t * _hb_ot_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_ot_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_ot_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_ot_shaper_font_data_destroy (hb_ot_shaper_font_data_t *data) +_hb_ot_shaper_font_data_destroy (hb_ot_font_data_t *data) { } @@ -169,7 +169,7 @@ _hb_ot_shaper_font_data_destroy (hb_ot_shaper_font_data_t *data) * shaper shape_plan data */ -hb_ot_shaper_shape_plan_data_t * +hb_ot_shape_plan_data_t * _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, const hb_feature_t *user_features, unsigned int num_user_features, @@ -204,7 +204,7 @@ _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, } void -_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shaper_shape_plan_data_t *plan) +_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shape_plan_data_t *plan) { if (plan->shaper->data_destroy) plan->shaper->data_destroy (const_cast<void *> (plan->data)); @@ -680,8 +680,8 @@ hb_ot_position_default (hb_ot_shape_context_t *c) if (HB_DIRECTION_IS_HORIZONTAL (direction)) { - for (unsigned int i = 0; i < count; i++) - pos[i].x_advance = c->font->get_glyph_h_advance (info[i].codepoint); + c->font->get_glyph_h_advances (count, &info[0].codepoint, sizeof(info[0]), + &pos[0].x_advance, sizeof(pos[0])); /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ if (c->font->has_glyph_h_origin_func ()) for (unsigned int i = 0; i < count; i++) @@ -691,9 +691,10 @@ hb_ot_position_default (hb_ot_shape_context_t *c) } else { + c->font->get_glyph_v_advances (count, &info[0].codepoint, sizeof(info[0]), + &pos[0].y_advance, sizeof(pos[0])); for (unsigned int i = 0; i < count; i++) { - pos[i].y_advance = c->font->get_glyph_v_advance (info[i].codepoint); c->font->subtract_glyph_v_origin (info[i].codepoint, &pos[i].x_offset, &pos[i].y_offset); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh index 82d299685c3..101476ed322 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh @@ -87,6 +87,8 @@ struct fvar { static const hb_tag_t tableTag = HB_OT_TAG_fvar; + inline bool has_data (void) const { return version.to_int () != 0; } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); 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 f0612a61100..6081ddfc389 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 @@ -41,14 +41,14 @@ _get_fvar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->fvar.get ()); + return *(layout->table.fvar.get ()); } 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_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->avar.get ()); + return *(layout->table.avar.get ()); } /** @@ -65,7 +65,7 @@ _get_avar (hb_face_t *face) hb_bool_t hb_ot_var_has_data (hb_face_t *face) { - return &_get_fvar (face) != &Null(OT::fvar); + return _get_fvar (face).has_data (); } /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh index 32e1edffe31..1bc996edba8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh @@ -86,7 +86,7 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); /* * Compiler attributes - * */ + */ #if __cplusplus < 201103L @@ -98,7 +98,6 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); #define constexpr const #endif -// Static assertions #ifndef static_assert #define static_assert(e, msg) \ HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1] @@ -124,7 +123,7 @@ struct _hb_alignof }; #ifndef alignof #define alignof(x) (_hb_alignof<x>::value) -#endif // alignof +#endif #endif // __cplusplus < 201103L @@ -286,13 +285,12 @@ static int errno = 0; /* Use something better? */ #define HB_STMT_START do #define HB_STMT_END while (0) +/* Static-assert as expression. */ template <unsigned int cond> class hb_assert_constant_t; template <> class hb_assert_constant_t<1> {}; - #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * (unsigned int) sizeof (hb_assert_constant_t<_cond>)) /* Lets assert int types. Saves trouble down the road. */ - static_assert ((sizeof (int8_t) == 1), ""); static_assert ((sizeof (uint8_t) == 1), ""); static_assert ((sizeof (int16_t) == 2), ""); @@ -301,7 +299,6 @@ static_assert ((sizeof (int32_t) == 4), ""); static_assert ((sizeof (uint32_t) == 4), ""); static_assert ((sizeof (int64_t) == 8), ""); static_assert ((sizeof (uint64_t) == 8), ""); - static_assert ((sizeof (hb_codepoint_t) == 4), ""); static_assert ((sizeof (hb_position_t) == 4), ""); static_assert ((sizeof (hb_mask_t) == 4), ""); @@ -371,82 +368,6 @@ typedef uint64_t hb_vector_size_impl_t; #endif -/* - * Static pools - */ - -/* Global nul-content Null pool. Enlarge as necessary. */ - -#define HB_NULL_POOL_SIZE 264 - -extern HB_INTERNAL -hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; - -/* Generic nul-content Null objects. */ -template <typename Type> -static inline Type const & Null (void) { - static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); - return *reinterpret_cast<Type const *> (_hb_NullPool); -} -#define Null(Type) Null<Type>() - -/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ -#define DEFINE_NULL_DATA(Namespace, Type, data) \ -} /* Close namespace. */ \ -static const char _Null##Type[sizeof (Namespace::Type) + 1] = data; /* +1 is for nul-termination in data */ \ -template <> \ -/*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \ - return *reinterpret_cast<const Namespace::Type *> (_Null##Type); \ -} \ -namespace Namespace { \ -/* The following line really exists such that we end in a place needing semicolon */ \ -static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.") - - -/* Global writable pool. Enlarge as necessary. */ - -/* To be fully correct, CrapPool must be thread_local. However, we do not rely on CrapPool - * for correct operation. It only exist to catch and divert program logic bugs instead of - * causing bad memory access. So, races there are not actually introducing incorrectness - * in the code. Has ~12kb binary size overhead to have it, also clang build fails with it. */ -extern HB_INTERNAL -/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; - -/* CRAP pool: Common Region for Access Protection. */ -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); - return *obj; -} -#define Crap(Type) Crap<Type>() - -template <typename Type> -struct CrapOrNull { - static inline Type & get (void) { return Crap(Type); } -}; -template <typename Type> -struct CrapOrNull<const Type> { - static inline Type const & get (void) { return Null(Type); } -}; -#define CrapOrNull(Type) CrapOrNull<Type>::get () - - -/* ASCII tag/character handling */ - -static inline bool ISALPHA (unsigned char c) -{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } -static inline bool ISALNUM (unsigned char c) -{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } -static inline bool ISSPACE (unsigned char c) -{ return c == ' ' || c =='\f'|| c =='\n'|| c =='\r'|| c =='\t'|| c =='\v'; } -static inline unsigned char TOUPPER (unsigned char c) -{ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; } -static inline unsigned char TOLOWER (unsigned char c) -{ return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; } - - /* HB_NDEBUG disables some sanity checks that are very safe to disable and * should be disabled in production systems. If NDEBUG is defined, enable * HB_NDEBUG; but if it's desirable that normal assert()s (which are very @@ -457,41 +378,7 @@ static inline unsigned char TOLOWER (unsigned char c) #endif -/* Misc */ - -template <typename T> class hb_assert_unsigned_t; -template <> class hb_assert_unsigned_t<unsigned char> {}; -template <> class hb_assert_unsigned_t<unsigned short> {}; -template <> class hb_assert_unsigned_t<unsigned int> {}; -template <> class hb_assert_unsigned_t<unsigned long> {}; - -template <typename T> static inline bool -hb_in_range (T u, T lo, T hi) -{ - /* The sizeof() is here to force template instantiation. - * I'm sure there are better ways to do this but can't think of - * one right now. Declaring a variable won't work as HB_UNUSED - * is unusable on some platforms and unused types are less likely - * to generate a warning than unused variables. */ - static_assert ((sizeof (hb_assert_unsigned_t<T>) >= 0), ""); - - /* The casts below are important as if T is smaller than int, - * the subtract results will become a signed int! */ - return (T)(u - lo) <= (T)(hi - lo); -} - -template <typename T> static inline bool -hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) -{ - return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); -} - -template <typename T> static inline bool -hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) -{ - return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3); -} - +/* Flags */ /* Enable bitwise ops on enums marked as flags_t */ /* To my surprise, looks like the function resolver is happy to silently cast @@ -515,7 +402,6 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \ } - /* Useful for set-operations on small enums. * For example, for testing "x ∈ {x1, x2, x3}" use: * (FLAG_UNSAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3))) @@ -575,6 +461,7 @@ _hb_memalign(void **memptr, size_t alignment, size_t size) #include "hb-debug.hh" #include "hb-dsalgs.hh" #include "hb-mutex-private.hh" +#include "hb-null.hh" #include "hb-object-private.hh" #endif /* HB_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan-private.hh index c2c4987e527..7d020ff16be 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan-private.hh @@ -51,6 +51,7 @@ struct hb_shape_plan_t struct hb_shaper_data_t shaper_data; }; +DECLARE_NULL_INSTANCE (hb_shape_plan_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \ , const hb_feature_t *user_features \ 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 37ff1a6e6c4..cc1834c4758 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 @@ -88,6 +88,31 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan, * hb_shape_plan_t */ +DEFINE_NULL_INSTANCE (hb_shape_plan_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* default_shaper_list */ + nullptr, /* face */ + HB_SEGMENT_PROPERTIES_DEFAULT, /* props */ + + nullptr, /* shaper_func */ + nullptr, /* shaper_name */ + + nullptr, /* user_features */ + 0, /* num_user_featurs */ + + nullptr, /* coords */ + 0, /* num_coords */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } +}; + + /** * hb_shape_plan_create: (Xconstructor) * @face: @@ -188,30 +213,7 @@ hb_shape_plan_create2 (hb_face_t *face, hb_shape_plan_t * hb_shape_plan_get_empty (void) { - static const hb_shape_plan_t _hb_shape_plan_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* default_shaper_list */ - nullptr, /* face */ - HB_SEGMENT_PROPERTIES_DEFAULT, /* props */ - - nullptr, /* shaper_func */ - nullptr, /* shaper_name */ - - nullptr, /* user_features */ - 0, /* num_user_featurs */ - - nullptr, /* coords */ - 0, /* num_coords */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - } - }; - - return const_cast<hb_shape_plan_t *> (&_hb_shape_plan_nil); + return const_cast<hb_shape_plan_t *> (&Null(hb_shape_plan_t)); } /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-private.hh index 4bd36b5ba05..457cd957bfb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-private.hh @@ -54,7 +54,7 @@ _hb_shapers_get (void); /* Means: tried but failed to create. */ #define HB_SHAPER_DATA_INVALID ((void *) -1) -#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_shaper_##object##_data_t +#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_##object##_data_t #define HB_SHAPER_DATA_TYPE(shaper, object) struct HB_SHAPER_DATA_TYPE_NAME(shaper, object) #define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper) #define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE(shaper, object, object) @@ -89,7 +89,13 @@ HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) (hb_##object##_t *object) \ /* Note that evaluating condition above can be dangerous if another thread \ * got here first and destructed data. That's, as always, bad use pattern. \ * If you modify the font (change font size), other threads must not be \ - * using it at the same time. */ \ + * using it at the same time. However, since this check is delayed to \ + * when one actually tries to shape something, this is a XXX race condition \ + * (and the only know we have that I know of) right now. Ie. you modify the \ + * font size in one thread, then (supposedly safely) try to use it from two \ + * or more threads and BOOM! I'm not sure how to fix this. We want RCU. \ + * Maybe when it doesn't matter when we finally implement AAT shaping, as + * this (condition) is currently only used by hb-coretext. */ \ /* Drop and recreate. */ \ /* If someone dropped it in the mean time, throw it away and don't touch it. \ * Otherwise, destruct it. */ \ 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 e6920e7e01c..ddecbba1154 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc @@ -25,8 +25,11 @@ */ #include "hb-private.hh" -#include "hb-face-private.hh" + #include "hb-open-type-private.hh" +#include "hb-ot-layout-common-private.hh" + +#include "hb-face-private.hh" #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" @@ -35,10 +38,15 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; +DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; +DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; +DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00}; + + void hb_face_t::load_num_glyphs (void) const { - OT::hb_sanitize_context_t c = OT::hb_sanitize_context_t(); + hb_sanitize_context_t c = hb_sanitize_context_t (); c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */ hb_blob_t *maxp_blob = c.reference_table<OT::maxp> (this); const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> (); @@ -49,7 +57,7 @@ hb_face_t::load_num_glyphs (void) const void hb_face_t::load_upem (void) const { - hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table<OT::head> (this); + hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<OT::head> (this); const OT::head *head_table = head_blob->as<OT::head> (); upem = head_table->get_upem (); hb_blob_destroy (head_blob); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc index 2b97a010a19..36af3beae72 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc @@ -292,7 +292,7 @@ hb_subset_glyf_and_loca (hb_subset_plan_t *plan, hb_blob_t **glyf_prime, /* OUT */ hb_blob_t **loca_prime /* OUT */) { - hb_blob_t *glyf_blob = OT::hb_sanitize_context_t().reference_table<OT::glyf> (plan->source); + hb_blob_t *glyf_blob = hb_sanitize_context_t ().reference_table<OT::glyf> (plan->source); const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr); OT::glyf::accelerator_t glyf; 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 308c7eb21c9..411c6b861c7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc @@ -78,12 +78,12 @@ template<typename TableType> static bool _subset (hb_subset_plan_t *plan) { - hb_blob_t *source_blob = OT::hb_sanitize_context_t().reference_table<TableType> (plan->source); + hb_blob_t *source_blob = hb_sanitize_context_t ().reference_table<TableType> (plan->source); const TableType *table = source_blob->as<TableType> (); hb_tag_t tag = TableType::tableTag; hb_bool_t result = false; - if (table != &Null(TableType)) + if (source_blob->data) { result = table->subset(plan); } else { @@ -157,14 +157,14 @@ _hb_subset_face_data_reference_blob (hb_subset_face_data_t *data) if (unlikely (!buf)) return nullptr; - OT::hb_serialize_context_t c (buf, face_length); + hb_serialize_context_t c (buf, face_length); OT::OpenTypeFontFile *f = c.start_serialize<OT::OpenTypeFontFile> (); bool is_cff = data->tables.lsearch (HB_TAG ('C','F','F',' ')) || data->tables.lsearch (HB_TAG ('C','F','F','2')); hb_tag_t sfnt_tag = is_cff ? OT::OpenTypeFontFile::CFFTag : OT::OpenTypeFontFile::TrueTypeTag; - OT::Supplier<hb_tag_t> tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); - OT::Supplier<hb_blob_t *> blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); + Supplier<hb_tag_t> tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); + Supplier<hb_blob_t *> blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); bool ret = f->serialize_single (&c, sfnt_tag, tags_supplier, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode-private.hh index b2c203d260e..fb16ba437ed 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode-private.hh @@ -60,7 +60,8 @@ extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256]; HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \ /* ^--- Add new simple callbacks here */ -struct hb_unicode_funcs_t { +struct hb_unicode_funcs_t +{ hb_object_header_t header; ASSERT_POD (); @@ -263,9 +264,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE #undef HB_UNICODE_FUNC_IMPLEMENT } destroy; }; - - -extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil; +DECLARE_NULL_INSTANCE (hb_unicode_funcs_t); /* Modified combining marks */ 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 2d16c2e3a79..8cb41723398 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc @@ -185,7 +185,8 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent) } -const hb_unicode_funcs_t _hb_unicode_funcs_nil = { +DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) = +{ HB_OBJECT_HEADER_STATIC, nullptr, /* parent */ @@ -209,7 +210,7 @@ const hb_unicode_funcs_t _hb_unicode_funcs_nil = { hb_unicode_funcs_t * hb_unicode_funcs_get_empty (void) { - return const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil); + return const_cast<hb_unicode_funcs_t *> (&Null(hb_unicode_funcs_t)); } /** 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 0199e65f864..94e6bb551bc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc @@ -309,7 +309,7 @@ HB_SHAPER_DATA_ENSURE_DEFINE(uniscribe, font) * shaper face data */ -struct hb_uniscribe_shaper_face_data_t { +struct hb_uniscribe_face_data_t { HANDLE fh; hb_uniscribe_shaper_funcs_t *funcs; wchar_t face_name[LF_FACESIZE]; @@ -358,7 +358,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name) * full, PS. All of them point to the same name data with our unique name. */ - blob = OT::hb_sanitize_context_t().sanitize_blob<OT::OpenTypeFontFile> (blob); + blob = hb_sanitize_context_t ().sanitize_blob<OT::OpenTypeFontFile> (blob); unsigned int length, new_length, name_str_len; const char *orig_sfnt_data = hb_blob_get_data (blob, &length); @@ -383,7 +383,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name) memcpy(new_sfnt_data, orig_sfnt_data, length); - OT::name &name = OT::StructAtOffset<OT::name> (new_sfnt_data, name_table_offset); + OT::name &name = StructAtOffset<OT::name> (new_sfnt_data, name_table_offset); name.format.set (0); name.count.set (ARRAY_LENGTH (name_IDs)); name.stringOffset.set (name.get_size ()); @@ -399,7 +399,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name) } /* Copy string data from new_name, converting wchar_t to UTF16BE. */ - unsigned char *p = &OT::StructAfter<unsigned char> (name); + unsigned char *p = &StructAfter<unsigned char> (name); for (unsigned int i = 0; i < name_str_len; i++) { *p++ = new_name[i] >> 8; @@ -439,10 +439,10 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name) HB_MEMORY_MODE_WRITABLE, nullptr, free); } -hb_uniscribe_shaper_face_data_t * +hb_uniscribe_face_data_t * _hb_uniscribe_shaper_face_data_create (hb_face_t *face) { - hb_uniscribe_shaper_face_data_t *data = (hb_uniscribe_shaper_face_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_face_data_t)); + hb_uniscribe_face_data_t *data = (hb_uniscribe_face_data_t *) calloc (1, sizeof (hb_uniscribe_face_data_t)); if (unlikely (!data)) return nullptr; @@ -479,7 +479,7 @@ _hb_uniscribe_shaper_face_data_create (hb_face_t *face) } void -_hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_shaper_face_data_t *data) +_hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_face_data_t *data) { RemoveFontMemResourceEx (data->fh); free (data); @@ -490,7 +490,7 @@ _hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_shaper_face_data_t *data) * shaper font data */ -struct hb_uniscribe_shaper_font_data_t { +struct hb_uniscribe_font_data_t { HDC hdc; LOGFONTW log_font; HFONT hfont; @@ -508,19 +508,19 @@ populate_log_font (LOGFONTW *lf, lf->lfCharSet = DEFAULT_CHARSET; hb_face_t *face = font->face; - hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face); memcpy (lf->lfFaceName, face_data->face_name, sizeof (lf->lfFaceName)); return true; } -hb_uniscribe_shaper_font_data_t * +hb_uniscribe_font_data_t * _hb_uniscribe_shaper_font_data_create (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_face_data_ensure (font->face))) return nullptr; - hb_uniscribe_shaper_font_data_t *data = (hb_uniscribe_shaper_font_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_font_data_t)); + hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) calloc (1, sizeof (hb_uniscribe_font_data_t)); if (unlikely (!data)) return nullptr; @@ -559,7 +559,7 @@ _hb_uniscribe_shaper_font_data_create (hb_font_t *font) } void -_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_shaper_font_data_t *data) +_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_font_data_t *data) { if (data->hdc) ReleaseDC (nullptr, data->hdc); @@ -574,7 +574,7 @@ LOGFONTW * hb_uniscribe_font_get_logfontw (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr; - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); return &font_data->log_font; } @@ -582,7 +582,7 @@ HFONT hb_uniscribe_font_get_hfont (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr; - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); return font_data->hfont; } @@ -591,20 +591,20 @@ hb_uniscribe_font_get_hfont (hb_font_t *font) * shaper shape_plan data */ -struct hb_uniscribe_shaper_shape_plan_data_t {}; +struct hb_uniscribe_shape_plan_data_t {}; -hb_uniscribe_shaper_shape_plan_data_t * +hb_uniscribe_shape_plan_data_t * _hb_uniscribe_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_uniscribe_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_uniscribe_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shape_plan_data_t *data HB_UNUSED) { } @@ -622,8 +622,8 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan, unsigned int num_features) { hb_face_t *face = font->face; - hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); hb_uniscribe_shaper_funcs_t *funcs = face_data->funcs; /* diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector-private.hh new file mode 100644 index 00000000000..1ef20d43863 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector-private.hh @@ -0,0 +1,238 @@ +/* + * Copyright © 2017,2018 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_VECTOR_PRIVATE_HH +#define HB_VECTOR_PRIVATE_HH + +#include "hb-private.hh" + + +template <typename Type, unsigned int StaticSize=8> +struct hb_vector_t +{ + unsigned int len; + unsigned int allocated; /* == 0 means allocation failed. */ + Type *arrayZ; + Type static_array[StaticSize]; + + void init (void) + { + len = 0; + allocated = ARRAY_LENGTH (static_array); + arrayZ = static_array; + } + + inline Type& operator [] (unsigned int i) + { + if (unlikely (i >= len)) + return Crap (Type); + return arrayZ[i]; + } + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) + return Null(Type); + return arrayZ[i]; + } + + inline Type *push (void) + { + if (unlikely (!resize (len + 1))) + return &Crap(Type); + return &arrayZ[len - 1]; + } + inline Type *push (const Type& v) + { + Type *p = push (); + *p = v; + return p; + } + + /* Allocate for size but don't adjust len. */ + inline bool alloc (unsigned int size) + { + if (unlikely (!allocated)) + return false; + + if (likely (size <= allocated)) + return true; + + /* Reallocate */ + + unsigned int new_allocated = allocated; + while (size >= new_allocated) + new_allocated += (new_allocated >> 1) + 8; + + Type *new_array = nullptr; + + if (arrayZ == static_array) + { + new_array = (Type *) calloc (new_allocated, sizeof (Type)); + if (new_array) + memcpy (new_array, arrayZ, len * sizeof (Type)); + } + else + { + bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); + if (likely (!overflows)) + new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); + } + + if (unlikely (!new_array)) + { + allocated = 0; + return false; + } + + arrayZ = new_array; + allocated = new_allocated; + + return true; + } + + inline bool resize (int size_) + { + unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; + if (!alloc (size)) + return false; + + if (size > len) + memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ)); + + len = size; + return true; + } + + inline void pop (void) + { + if (!len) return; + len--; + } + + inline void remove (unsigned int i) + { + if (unlikely (i >= len)) + return; + memmove (static_cast<void *> (&arrayZ[i]), + static_cast<void *> (&arrayZ[i + 1]), + (len - i - 1) * sizeof (Type)); + len--; + } + + inline void shrink (int size_) + { + unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; + if (size < len) + len = size; + } + + template <typename T> + inline Type *find (T v) { + for (unsigned int i = 0; i < len; i++) + if (arrayZ[i] == v) + return &arrayZ[i]; + return nullptr; + } + template <typename T> + inline const Type *find (T v) const { + for (unsigned int i = 0; i < len; i++) + if (arrayZ[i] == v) + return &arrayZ[i]; + return nullptr; + } + + inline void qsort (int (*cmp)(const void*, const void*)) + { + ::qsort (arrayZ, len, sizeof (Type), cmp); + } + + inline void qsort (void) + { + ::qsort (arrayZ, len, sizeof (Type), Type::cmp); + } + + inline void qsort (unsigned int start, unsigned int end) + { + ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp); + } + + template <typename T> + inline Type *lsearch (const T &x) + { + for (unsigned int i = 0; i < len; i++) + if (0 == this->arrayZ[i].cmp (&x)) + return &arrayZ[i]; + return nullptr; + } + + template <typename T> + inline Type *bsearch (const T &x) + { + unsigned int i; + return bfind (x, &i) ? &arrayZ[i] : nullptr; + } + template <typename T> + inline const Type *bsearch (const T &x) const + { + unsigned int i; + return bfind (x, &i) ? &arrayZ[i] : nullptr; + } + template <typename T> + inline bool bfind (const T &x, unsigned int *i) const + { + int min = 0, max = (int) this->len - 1; + while (min <= max) + { + int mid = (min + max) / 2; + int c = this->arrayZ[mid].cmp (&x); + if (c < 0) + max = mid - 1; + else if (c > 0) + min = mid + 1; + else + { + *i = mid; + return true; + } + } + if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0)) + max++; + *i = max; + return false; + } + + inline void fini (void) + { + if (arrayZ != static_array) + free (arrayZ); + arrayZ = nullptr; + allocated = len = 0; + } +}; + + +#endif /* HB_VECTOR_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc index c6e05fc3780..98a1320bfb0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc @@ -53,7 +53,7 @@ main (int argc, char **argv) hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile> (blob); const OpenTypeFontFile* sanitized = font_blob->as<OpenTypeFontFile> (); - if (sanitized == &Null(OpenTypeFontFile)) + if (!font_blob->data) { printf ("Sanitization of the file wasn't successful. Exit"); return 1; diff --git a/Build/source/libs/harfbuzz/version.ac b/Build/source/libs/harfbuzz/version.ac index 8e2a1b62840..98390259f5d 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], [1.8.5]) +m4_define([harfbuzz_version], [1.8.6]) |