From 683672628fe7bb6a6c5e71735942eb1b5fcae0a6 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 11 Sep 2018 04:13:36 +0000 Subject: harfbuzz 1.9.0 git-svn-id: svn://tug.org/texlive/trunk@48641 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/libs/README | 2 +- Build/source/libs/harfbuzz/ChangeLog | 5 + Build/source/libs/harfbuzz/Makefile.am | 79 +- Build/source/libs/harfbuzz/Makefile.in | 89 +- Build/source/libs/harfbuzz/TLpatches/ChangeLog | 5 + Build/source/libs/harfbuzz/TLpatches/TL-Changes | 2 +- Build/source/libs/harfbuzz/configure | 26 +- Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog | 1217 +++++++++ Build/source/libs/harfbuzz/harfbuzz-src/NEWS | 19 + .../source/libs/harfbuzz/harfbuzz-src/configure.ac | 2 +- .../harfbuzz/harfbuzz-src/src/Makefile.sources | 81 +- .../harfbuzz/harfbuzz-src/src/check-includes.sh | 8 +- .../harfbuzz/harfbuzz-src/src/dump-indic-data.cc | 2 +- .../harfbuzz/harfbuzz-src/src/dump-khmer-data.cc | 2 +- .../harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc | 2 +- .../harfbuzz/harfbuzz-src/src/dump-use-data.cc | 2 +- .../harfbuzz/harfbuzz-src/src/gen-indic-table.py | 2 +- .../harfbuzz/harfbuzz-src/src/gen-use-table.py | 2 +- .../harfbuzz-src/src/hb-aat-layout-ankr-table.hh | 2 +- .../harfbuzz-src/src/hb-aat-layout-bsln-table.hh | 2 +- .../src/hb-aat-layout-common-private.hh | 644 ----- .../harfbuzz-src/src/hb-aat-layout-common.hh | 644 +++++ .../harfbuzz-src/src/hb-aat-layout-feat-table.hh | 2 +- .../harfbuzz-src/src/hb-aat-layout-kerx-table.hh | 4 +- .../harfbuzz-src/src/hb-aat-layout-morx-table.hh | 6 +- .../harfbuzz-src/src/hb-aat-layout-private.hh | 43 - .../harfbuzz-src/src/hb-aat-layout-trak-table.hh | 6 +- .../harfbuzz/harfbuzz-src/src/hb-aat-layout.cc | 25 +- .../harfbuzz/harfbuzz-src/src/hb-aat-layout.hh | 43 + .../harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-atomic-private.hh | 281 -- .../libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh | 282 ++ .../harfbuzz/harfbuzz-src/src/hb-blob-private.hh | 82 - .../libs/harfbuzz/harfbuzz-src/src/hb-blob.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-blob.hh | 86 + .../harfbuzz-src/src/hb-buffer-deserialize-json.hh | 2 +- .../harfbuzz-src/src/hb-buffer-deserialize-json.rl | 2 +- .../harfbuzz-src/src/hb-buffer-deserialize-text.hh | 2 +- .../harfbuzz-src/src/hb-buffer-deserialize-text.rl | 2 +- .../harfbuzz/harfbuzz-src/src/hb-buffer-private.hh | 389 --- .../harfbuzz-src/src/hb-buffer-serialize.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh | 389 +++ .../libs/harfbuzz/harfbuzz-src/src/hb-common.cc | 7 +- .../libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-debug.hh | 4 +- .../harfbuzz/harfbuzz-src/src/hb-directwrite.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh | 14 +- .../harfbuzz/harfbuzz-src/src/hb-face-private.hh | 108 - .../libs/harfbuzz/harfbuzz-src/src/hb-face.cc | 215 +- .../libs/harfbuzz/harfbuzz-src/src/hb-face.h | 33 + .../libs/harfbuzz/harfbuzz-src/src/hb-face.hh | 108 + .../harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc | 2 +- .../harfbuzz/harfbuzz-src/src/hb-font-private.hh | 604 ----- .../libs/harfbuzz/harfbuzz-src/src/hb-font.cc | 6 +- .../libs/harfbuzz/harfbuzz-src/src/hb-font.hh | 604 +++++ .../source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc | 11 +- .../libs/harfbuzz/harfbuzz-src/src/hb-glib.cc | 9 +- .../harfbuzz-src/src/hb-gobject-enums.cc.tmpl | 2 +- .../harfbuzz-src/src/hb-gobject-structs.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-icu.cc | 9 +- .../harfbuzz/harfbuzz-src/src/hb-iter-private.hh | 149 -- .../libs/harfbuzz/harfbuzz-src/src/hb-iter.hh | 149 ++ .../harfbuzz-src/src/hb-machinery-private.hh | 792 ------ .../libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh | 907 +++++++ .../harfbuzz/harfbuzz-src/src/hb-map-private.hh | 254 -- .../libs/harfbuzz/harfbuzz-src/src/hb-map.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-map.hh | 254 ++ .../harfbuzz/harfbuzz-src/src/hb-mutex-private.hh | 141 - .../libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh | 141 + .../libs/harfbuzz/harfbuzz-src/src/hb-null.hh | 45 +- .../harfbuzz/harfbuzz-src/src/hb-object-private.hh | 325 --- .../libs/harfbuzz/harfbuzz-src/src/hb-object.hh | 325 +++ .../harfbuzz-src/src/hb-open-file-private.hh | 568 ----- .../libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh | 567 +++++ .../harfbuzz-src/src/hb-open-type-private.hh | 649 ----- .../libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh | 673 +++++ .../harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh | 284 ++- .../harfbuzz-src/src/hb-ot-color-cbdt-table.hh | 4 +- .../harfbuzz-src/src/hb-ot-color-colr-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-color-cpal-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-color-sbix-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-color-svg-table.hh | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc | 12 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc | 76 + .../libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh | 116 + .../libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc | 133 +- .../harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh | 6 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh | 20 +- .../harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh | 6 +- .../harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh | 4 +- .../harfbuzz-src/src/hb-ot-layout-base-table.hh | 4 +- .../src/hb-ot-layout-common-private.hh | 1806 ------------- .../harfbuzz-src/src/hb-ot-layout-common.hh | 1971 ++++++++++++++ .../harfbuzz-src/src/hb-ot-layout-gdef-table.hh | 51 +- .../harfbuzz-src/src/hb-ot-layout-gpos-table.hh | 203 +- .../harfbuzz-src/src/hb-ot-layout-gsub-table.hh | 417 ++- .../src/hb-ot-layout-gsubgpos-private.hh | 2406 ------------------ .../harfbuzz-src/src/hb-ot-layout-gsubgpos.hh | 2685 ++++++++++++++++++++ .../harfbuzz-src/src/hb-ot-layout-jstf-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-layout-private.hh | 704 ----- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc | 198 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh | 625 +++++ .../harfbuzz/harfbuzz-src/src/hb-ot-map-private.hh | 253 -- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh | 253 ++ .../harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-math.cc | 8 +- .../harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh | 3 +- .../harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh | 3 +- .../harfbuzz-src/src/hb-ot-os2-unicode-ranges.hh | 2 +- .../harfbuzz-src/src/hb-ot-post-macroman.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh | 5 +- .../src/hb-ot-shape-complex-arabic-fallback.hh | 5 +- .../src/hb-ot-shape-complex-arabic-private.hh | 50 - .../src/hb-ot-shape-complex-arabic-win1256.hh | 2 +- .../harfbuzz-src/src/hb-ot-shape-complex-arabic.cc | 6 +- .../harfbuzz-src/src/hb-ot-shape-complex-arabic.hh | 50 + .../src/hb-ot-shape-complex-default.cc | 2 +- .../harfbuzz-src/src/hb-ot-shape-complex-hangul.cc | 2 +- .../harfbuzz-src/src/hb-ot-shape-complex-hebrew.cc | 2 +- .../src/hb-ot-shape-complex-indic-machine.hh | 2 +- .../src/hb-ot-shape-complex-indic-machine.rl | 2 +- .../src/hb-ot-shape-complex-indic-private.hh | 403 --- .../src/hb-ot-shape-complex-indic-table.cc | 2 +- .../harfbuzz-src/src/hb-ot-shape-complex-indic.cc | 4 +- .../harfbuzz-src/src/hb-ot-shape-complex-indic.hh | 403 +++ .../src/hb-ot-shape-complex-khmer-machine.hh | 2 +- .../src/hb-ot-shape-complex-khmer-machine.rl | 2 +- .../src/hb-ot-shape-complex-khmer-private.hh | 124 - .../harfbuzz-src/src/hb-ot-shape-complex-khmer.cc | 4 +- .../harfbuzz-src/src/hb-ot-shape-complex-khmer.hh | 124 + .../src/hb-ot-shape-complex-myanmar-machine.hh | 2 +- .../src/hb-ot-shape-complex-myanmar-machine.rl | 2 +- .../src/hb-ot-shape-complex-myanmar-private.hh | 171 -- .../src/hb-ot-shape-complex-myanmar.cc | 2 +- .../src/hb-ot-shape-complex-myanmar.hh | 171 ++ .../src/hb-ot-shape-complex-private.hh | 393 --- .../harfbuzz-src/src/hb-ot-shape-complex-thai.cc | 2 +- .../src/hb-ot-shape-complex-tibetan.cc | 2 +- .../src/hb-ot-shape-complex-use-machine.hh | 2 +- .../src/hb-ot-shape-complex-use-machine.rl | 2 +- .../src/hb-ot-shape-complex-use-private.hh | 97 - .../src/hb-ot-shape-complex-use-table.cc | 2 +- .../harfbuzz-src/src/hb-ot-shape-complex-use.cc | 4 +- .../harfbuzz-src/src/hb-ot-shape-complex-use.hh | 97 + .../harfbuzz-src/src/hb-ot-shape-complex.hh | 393 +++ .../src/hb-ot-shape-fallback-private.hh | 53 - .../harfbuzz-src/src/hb-ot-shape-fallback.cc | 4 +- .../harfbuzz-src/src/hb-ot-shape-fallback.hh | 53 + .../src/hb-ot-shape-normalize-private.hh | 69 - .../harfbuzz-src/src/hb-ot-shape-normalize.cc | 6 +- .../harfbuzz-src/src/hb-ot-shape-normalize.hh | 69 + .../harfbuzz-src/src/hb-ot-shape-private.hh | 112 - .../libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc | 26 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh | 112 + .../libs/harfbuzz/harfbuzz-src/src/hb-ot-tag.cc | 2 +- .../harfbuzz-src/src/hb-ot-var-avar-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-var-fvar-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-var-hvar-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-var-mvar-table.hh | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-var.cc | 12 +- .../libs/harfbuzz/harfbuzz-src/src/hb-private.hh | 480 ---- .../harfbuzz-src/src/hb-set-digest-private.hh | 179 -- .../harfbuzz/harfbuzz-src/src/hb-set-digest.hh | 179 ++ .../harfbuzz/harfbuzz-src/src/hb-set-private.hh | 700 ----- .../libs/harfbuzz/harfbuzz-src/src/hb-set.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-set.hh | 700 +++++ .../harfbuzz-src/src/hb-shape-plan-private.hh | 67 - .../harfbuzz/harfbuzz-src/src/hb-shape-plan.cc | 10 +- .../harfbuzz/harfbuzz-src/src/hb-shape-plan.hh | 67 + .../libs/harfbuzz/harfbuzz-src/src/hb-shape.cc | 16 +- .../harfbuzz-src/src/hb-shaper-impl-private.hh | 43 - .../harfbuzz/harfbuzz-src/src/hb-shaper-impl.hh | 43 + .../harfbuzz/harfbuzz-src/src/hb-shaper-private.hh | 134 - .../libs/harfbuzz/harfbuzz-src/src/hb-shaper.cc | 9 +- .../libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh | 134 + .../libs/harfbuzz/harfbuzz-src/src/hb-static.cc | 8 +- .../harfbuzz/harfbuzz-src/src/hb-string-array.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc | 3 +- .../harfbuzz/harfbuzz-src/src/hb-subset-glyf.hh | 4 +- .../harfbuzz/harfbuzz-src/src/hb-subset-input.cc | 48 +- .../harfbuzz/harfbuzz-src/src/hb-subset-input.hh | 57 + .../harfbuzz/harfbuzz-src/src/hb-subset-plan.cc | 33 +- .../harfbuzz/harfbuzz-src/src/hb-subset-plan.hh | 22 +- .../harfbuzz/harfbuzz-src/src/hb-subset-private.hh | 63 - .../libs/harfbuzz/harfbuzz-src/src/hb-subset.cc | 259 +- .../libs/harfbuzz/harfbuzz-src/src/hb-subset.h | 33 +- .../libs/harfbuzz/harfbuzz-src/src/hb-subset.hh | 60 + .../libs/harfbuzz/harfbuzz-src/src/hb-ucdn.cc | 6 +- .../harfbuzz-src/src/hb-unicode-private.hh | 369 --- .../libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc | 6 +- .../libs/harfbuzz/harfbuzz-src/src/hb-unicode.h | 8 + .../libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh | 369 +++ .../libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc | 6 +- .../harfbuzz/harfbuzz-src/src/hb-utf-private.hh | 282 -- .../libs/harfbuzz/harfbuzz-src/src/hb-utf.hh | 282 ++ .../harfbuzz/harfbuzz-src/src/hb-vector-private.hh | 238 -- .../libs/harfbuzz/harfbuzz-src/src/hb-vector.hh | 240 ++ .../libs/harfbuzz/harfbuzz-src/src/hb-warning.cc | 6 +- Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh | 480 ++++ .../source/libs/harfbuzz/harfbuzz-src/src/main.cc | 4 +- .../harfbuzz-src/src/test-buffer-serialize.cc | 2 +- .../harfbuzz/harfbuzz-src/src/test-size-params.cc | 2 +- .../harfbuzz-src/src/test-unicode-ranges.cc | 2 +- .../harfbuzz-src/src/test-would-substitute.cc | 2 +- .../source/libs/harfbuzz/harfbuzz-src/src/test.cc | 2 +- Build/source/libs/harfbuzz/version.ac | 2 +- 212 files changed, 17824 insertions(+), 15368 deletions(-) delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-impl-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-impl.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh diff --git a/Build/source/libs/README b/Build/source/libs/README index 8abfd4a15dd..334a0df72b8 100644 --- a/Build/source/libs/README +++ b/Build/source/libs/README @@ -25,7 +25,7 @@ graphite2 1.3.12 - checked 16aug18 http://sourceforge.net/projects/silgraphite/files/graphite2/ (requires C++11) -harfbuzz 1.8.8 - checked 15aug18 +harfbuzz 1.9.0 - checked 11sep18 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 f6663a60671..48421da880d 100644 --- a/Build/source/libs/harfbuzz/ChangeLog +++ b/Build/source/libs/harfbuzz/ChangeLog @@ -1,3 +1,8 @@ +2018-09-11 Akira Kakuto + + Import harfbuzz-1.9.0. + * version.ac, Makefile.am: Adjusted. + 2018-08-15 Akira Kakuto Import harfbuzz-1.8.8. diff --git a/Build/source/libs/harfbuzz/Makefile.am b/Build/source/libs/harfbuzz/Makefile.am index b850fa1f1b3..2242e91b854 100644 --- a/Build/source/libs/harfbuzz/Makefile.am +++ b/Build/source/libs/harfbuzz/Makefile.am @@ -31,30 +31,32 @@ AM_CPPFLAGS = -DHB_NO_MT -DHB_NO_UNICODE_FUNCS -DHAVE_FALLBACK=1 \ -I$(top_srcdir)/$(HARFBUZZ_SRC) libharfbuzz_dependencies = libharfbuzz_a_SOURCES = \ - @HARFBUZZ_TREE@/src/hb-atomic-private.hh \ - @HARFBUZZ_TREE@/src/hb-blob-private.hh \ + @HARFBUZZ_TREE@/src/hb-atomic.hh \ + @HARFBUZZ_TREE@/src/hb-blob.hh \ @HARFBUZZ_TREE@/src/hb-blob.cc \ - @HARFBUZZ_TREE@/src/hb-buffer-private.hh \ + @HARFBUZZ_TREE@/src/hb-buffer.hh \ @HARFBUZZ_TREE@/src/hb-buffer-serialize.cc \ @HARFBUZZ_TREE@/src/hb-buffer.cc \ @HARFBUZZ_TREE@/src/hb-common.cc \ @HARFBUZZ_TREE@/src/hb-debug.hh \ @HARFBUZZ_TREE@/src/hb-dsalgs.hh \ - @HARFBUZZ_TREE@/src/hb-face-private.hh \ + @HARFBUZZ_TREE@/src/hb-face.hh \ @HARFBUZZ_TREE@/src/hb-face.cc \ - @HARFBUZZ_TREE@/src/hb-font-private.hh \ + @HARFBUZZ_TREE@/src/hb-font.hh \ @HARFBUZZ_TREE@/src/hb-font.cc \ - @HARFBUZZ_TREE@/src/hb-iter-private.hh \ - @HARFBUZZ_TREE@/src/hb-map-private.hh \ + @HARFBUZZ_TREE@/src/hb-iter.hh \ + @HARFBUZZ_TREE@/src/hb-map.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-machinery.hh \ + @HARFBUZZ_TREE@/src/hb-mutex.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 \ + @HARFBUZZ_TREE@/src/hb-object.hh \ + @HARFBUZZ_TREE@/src/hb-open-file.hh \ + @HARFBUZZ_TREE@/src/hb-open-type.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-cbdt-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-cmap-table.hh \ + @HARFBUZZ_TREE@/src/hb-ot-face.cc \ + @HARFBUZZ_TREE@/src/hb-ot-face.hh \ @HARFBUZZ_TREE@/src/hb-ot-glyf-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-hdmx-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-head-table.hh \ @@ -68,87 +70,88 @@ libharfbuzz_a_SOURCES = \ @HARFBUZZ_TREE@/src/hb-ot-post-macroman.hh \ @HARFBUZZ_TREE@/src/hb-ot-post-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-tag.cc \ - @HARFBUZZ_TREE@/src/hb-private.hh \ - @HARFBUZZ_TREE@/src/hb-set-digest-private.hh \ - @HARFBUZZ_TREE@/src/hb-set-private.hh \ + @HARFBUZZ_TREE@/src/hb-set-digest.hh \ + @HARFBUZZ_TREE@/src/hb-set.hh \ @HARFBUZZ_TREE@/src/hb-set.cc \ @HARFBUZZ_TREE@/src/hb-shape.cc \ - @HARFBUZZ_TREE@/src/hb-shape-plan-private.hh \ + @HARFBUZZ_TREE@/src/hb-shape-plan.hh \ @HARFBUZZ_TREE@/src/hb-shape-plan.cc \ @HARFBUZZ_TREE@/src/hb-shaper-list.hh \ - @HARFBUZZ_TREE@/src/hb-shaper-impl-private.hh \ - @HARFBUZZ_TREE@/src/hb-shaper-private.hh \ + @HARFBUZZ_TREE@/src/hb-shaper-impl.hh \ + @HARFBUZZ_TREE@/src/hb-shaper.hh \ @HARFBUZZ_TREE@/src/hb-shaper.cc \ @HARFBUZZ_TREE@/src/hb-static.cc \ @HARFBUZZ_TREE@/src/hb-string-array.hh \ - @HARFBUZZ_TREE@/src/hb-unicode-private.hh \ + @HARFBUZZ_TREE@/src/hb-subset-input.hh \ + @HARFBUZZ_TREE@/src/hb-subset.hh \ + @HARFBUZZ_TREE@/src/hb-unicode.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-vector.hh \ + @HARFBUZZ_TREE@/src/hb-utf.hh \ @HARFBUZZ_TREE@/src/hb-warning.cc \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-json.hh \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-text.hh \ - @HARFBUZZ_TREE@/src/hb-fallback-shape.cc - + @HARFBUZZ_TREE@/src/hb-fallback-shape.cc \ + @HARFBUZZ_TREE@/src/hb.hh ## native OpenType Layout backend libharfbuzz_a_SOURCES += \ @HARFBUZZ_TREE@/src/hb-aat-layout.cc \ - @HARFBUZZ_TREE@/src/aat-layout-common-private.hh \ + @HARFBUZZ_TREE@/src/hb-aat-layout-common.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-ankr-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-bsln-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-feat-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-kerx-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-morx-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-trak-table.hh \ - @HARFBUZZ_TREE@/src/hb-aat-layout-private.hh \ + @HARFBUZZ_TREE@/src/hb-aat-layout.hh \ @HARFBUZZ_TREE@/src/hb-aat-ltag-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-font.cc \ @HARFBUZZ_TREE@/src/hb-ot-layout.cc \ @HARFBUZZ_TREE@/src/hb-ot-layout-base-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-common-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout-common.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gdef-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gpos-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-gsubgpos-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout-gsubgpos.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gsub-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-jstf-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout.hh \ @HARFBUZZ_TREE@/src/hb-ot-color.cc \ @HARFBUZZ_TREE@/src/hb-ot-color-colr-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-cpal-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-sbix-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-svg-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-map.cc \ - @HARFBUZZ_TREE@/src/hb-ot-map-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-map.hh \ @HARFBUZZ_TREE@/src/hb-ot-math.cc \ @HARFBUZZ_TREE@/src/hb-ot-math-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-fallback.hh \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-win1256.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-default.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-hangul.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-hebrew.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic-table.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-thai.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-tibetan.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use-table.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-private.hh \ - @HARFBUZZ_TREE@/src/hb-ot-shape-normalize-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-normalize.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-normalize.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-fallback-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-fallback.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-fallback.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape.hh \ @HARFBUZZ_TREE@/src/hb-ot-var.cc \ @HARFBUZZ_TREE@/src/hb-ot-var-avar-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-var-fvar-table.hh \ diff --git a/Build/source/libs/harfbuzz/Makefile.in b/Build/source/libs/harfbuzz/Makefile.in index 1263f1a8e49..287c4eddabf 100644 --- a/Build/source/libs/harfbuzz/Makefile.in +++ b/Build/source/libs/harfbuzz/Makefile.in @@ -127,6 +127,7 @@ am_libharfbuzz_a_OBJECTS = @HARFBUZZ_TREE@/src/hb-blob.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-face.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-font.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-map.$(OBJEXT) \ + @HARFBUZZ_TREE@/src/hb-ot-face.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-ot-tag.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-set.$(OBJEXT) \ @HARFBUZZ_TREE@/src/hb-shape.$(OBJEXT) \ @@ -197,6 +198,7 @@ am__depfiles_remade = ./$(DEPDIR)/hbtest-dummy.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-icu.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-map.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-color.Po \ + @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-face.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-font.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-layout.Po \ @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-map.Po \ @@ -696,30 +698,27 @@ AM_CPPFLAGS = -DHB_NO_MT -DHB_NO_UNICODE_FUNCS -DHAVE_FALLBACK=1 \ -I$(top_srcdir)/$(HARFBUZZ_SRC) $(ICU_INCLUDES) \ $(GRAPHITE2_INCLUDES) libharfbuzz_dependencies = $(ICU_DEPEND) $(GRAPHITE2_DEPEND) -libharfbuzz_a_SOURCES = @HARFBUZZ_TREE@/src/hb-atomic-private.hh \ - @HARFBUZZ_TREE@/src/hb-blob-private.hh \ - @HARFBUZZ_TREE@/src/hb-blob.cc \ - @HARFBUZZ_TREE@/src/hb-buffer-private.hh \ +libharfbuzz_a_SOURCES = @HARFBUZZ_TREE@/src/hb-atomic.hh \ + @HARFBUZZ_TREE@/src/hb-blob.hh @HARFBUZZ_TREE@/src/hb-blob.cc \ + @HARFBUZZ_TREE@/src/hb-buffer.hh \ @HARFBUZZ_TREE@/src/hb-buffer-serialize.cc \ @HARFBUZZ_TREE@/src/hb-buffer.cc \ @HARFBUZZ_TREE@/src/hb-common.cc \ @HARFBUZZ_TREE@/src/hb-debug.hh \ @HARFBUZZ_TREE@/src/hb-dsalgs.hh \ - @HARFBUZZ_TREE@/src/hb-face-private.hh \ - @HARFBUZZ_TREE@/src/hb-face.cc \ - @HARFBUZZ_TREE@/src/hb-font-private.hh \ - @HARFBUZZ_TREE@/src/hb-font.cc \ - @HARFBUZZ_TREE@/src/hb-iter-private.hh \ - @HARFBUZZ_TREE@/src/hb-map-private.hh \ + @HARFBUZZ_TREE@/src/hb-face.hh @HARFBUZZ_TREE@/src/hb-face.cc \ + @HARFBUZZ_TREE@/src/hb-font.hh @HARFBUZZ_TREE@/src/hb-font.cc \ + @HARFBUZZ_TREE@/src/hb-iter.hh @HARFBUZZ_TREE@/src/hb-map.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 \ + @HARFBUZZ_TREE@/src/hb-machinery.hh \ + @HARFBUZZ_TREE@/src/hb-mutex.hh @HARFBUZZ_TREE@/src/hb-null.hh \ + @HARFBUZZ_TREE@/src/hb-object.hh \ + @HARFBUZZ_TREE@/src/hb-open-file.hh \ + @HARFBUZZ_TREE@/src/hb-open-type.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-cbdt-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-cmap-table.hh \ + @HARFBUZZ_TREE@/src/hb-ot-face.cc \ + @HARFBUZZ_TREE@/src/hb-ot-face.hh \ @HARFBUZZ_TREE@/src/hb-ot-glyf-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-hdmx-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-head-table.hh \ @@ -733,82 +732,82 @@ libharfbuzz_a_SOURCES = @HARFBUZZ_TREE@/src/hb-atomic-private.hh \ @HARFBUZZ_TREE@/src/hb-ot-post-macroman.hh \ @HARFBUZZ_TREE@/src/hb-ot-post-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-tag.cc \ - @HARFBUZZ_TREE@/src/hb-private.hh \ - @HARFBUZZ_TREE@/src/hb-set-digest-private.hh \ - @HARFBUZZ_TREE@/src/hb-set-private.hh \ - @HARFBUZZ_TREE@/src/hb-set.cc @HARFBUZZ_TREE@/src/hb-shape.cc \ - @HARFBUZZ_TREE@/src/hb-shape-plan-private.hh \ + @HARFBUZZ_TREE@/src/hb-set-digest.hh \ + @HARFBUZZ_TREE@/src/hb-set.hh @HARFBUZZ_TREE@/src/hb-set.cc \ + @HARFBUZZ_TREE@/src/hb-shape.cc \ + @HARFBUZZ_TREE@/src/hb-shape-plan.hh \ @HARFBUZZ_TREE@/src/hb-shape-plan.cc \ @HARFBUZZ_TREE@/src/hb-shaper-list.hh \ - @HARFBUZZ_TREE@/src/hb-shaper-impl-private.hh \ - @HARFBUZZ_TREE@/src/hb-shaper-private.hh \ + @HARFBUZZ_TREE@/src/hb-shaper-impl.hh \ + @HARFBUZZ_TREE@/src/hb-shaper.hh \ @HARFBUZZ_TREE@/src/hb-shaper.cc \ @HARFBUZZ_TREE@/src/hb-static.cc \ @HARFBUZZ_TREE@/src/hb-string-array.hh \ - @HARFBUZZ_TREE@/src/hb-unicode-private.hh \ + @HARFBUZZ_TREE@/src/hb-subset-input.hh \ + @HARFBUZZ_TREE@/src/hb-subset.hh \ + @HARFBUZZ_TREE@/src/hb-unicode.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-vector.hh @HARFBUZZ_TREE@/src/hb-utf.hh \ @HARFBUZZ_TREE@/src/hb-warning.cc \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-json.hh \ @HARFBUZZ_TREE@/src/hb-buffer-deserialize-text.hh \ @HARFBUZZ_TREE@/src/hb-fallback-shape.cc \ - @HARFBUZZ_TREE@/src/hb-aat-layout.cc \ - @HARFBUZZ_TREE@/src/aat-layout-common-private.hh \ + @HARFBUZZ_TREE@/src/hb.hh @HARFBUZZ_TREE@/src/hb-aat-layout.cc \ + @HARFBUZZ_TREE@/src/hb-aat-layout-common.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-ankr-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-bsln-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-feat-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-kerx-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-morx-table.hh \ @HARFBUZZ_TREE@/src/hb-aat-layout-trak-table.hh \ - @HARFBUZZ_TREE@/src/hb-aat-layout-private.hh \ + @HARFBUZZ_TREE@/src/hb-aat-layout.hh \ @HARFBUZZ_TREE@/src/hb-aat-ltag-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-font.cc \ @HARFBUZZ_TREE@/src/hb-ot-layout.cc \ @HARFBUZZ_TREE@/src/hb-ot-layout-base-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-common-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout-common.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gdef-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gpos-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-gsubgpos-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout-gsubgpos.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-gsub-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-layout-jstf-table.hh \ - @HARFBUZZ_TREE@/src/hb-ot-layout-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-layout.hh \ @HARFBUZZ_TREE@/src/hb-ot-color.cc \ @HARFBUZZ_TREE@/src/hb-ot-color-colr-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-cpal-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-sbix-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-color-svg-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-map.cc \ - @HARFBUZZ_TREE@/src/hb-ot-map-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-map.hh \ @HARFBUZZ_TREE@/src/hb-ot-math.cc \ @HARFBUZZ_TREE@/src/hb-ot-math-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-fallback.hh \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-arabic-win1256.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-default.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-hangul.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-hebrew.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-indic-table.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-khmer.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-myanmar.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-thai.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-tibetan.cc \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use-table.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-complex-private.hh \ - @HARFBUZZ_TREE@/src/hb-ot-shape-normalize-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-complex-use.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-normalize.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-normalize.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-fallback-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape-fallback.hh \ @HARFBUZZ_TREE@/src/hb-ot-shape-fallback.cc \ - @HARFBUZZ_TREE@/src/hb-ot-shape-private.hh \ + @HARFBUZZ_TREE@/src/hb-ot-shape.hh \ @HARFBUZZ_TREE@/src/hb-ot-var.cc \ @HARFBUZZ_TREE@/src/hb-ot-var-avar-table.hh \ @HARFBUZZ_TREE@/src/hb-ot-var-fvar-table.hh \ @@ -926,6 +925,9 @@ clean-noinstLIBRARIES: @HARFBUZZ_TREE@/src/hb-map.$(OBJEXT): \ @HARFBUZZ_TREE@/src/$(am__dirstamp) \ @HARFBUZZ_TREE@/src/$(DEPDIR)/$(am__dirstamp) +@HARFBUZZ_TREE@/src/hb-ot-face.$(OBJEXT): \ + @HARFBUZZ_TREE@/src/$(am__dirstamp) \ + @HARFBUZZ_TREE@/src/$(DEPDIR)/$(am__dirstamp) @HARFBUZZ_TREE@/src/hb-ot-tag.$(OBJEXT): \ @HARFBUZZ_TREE@/src/$(am__dirstamp) \ @HARFBUZZ_TREE@/src/$(DEPDIR)/$(am__dirstamp) @@ -1056,6 +1058,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-icu.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-map.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-color.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-face.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-font.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-layout.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@@HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-map.Po@am__quote@ # am--include-marker @@ -1689,6 +1692,7 @@ distclean: distclean-recursive -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-icu.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-map.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-color.Po + -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-face.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-font.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-layout.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-map.Po @@ -1778,6 +1782,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-icu.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-map.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-color.Po + -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-face.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-font.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-layout.Po -rm -f @HARFBUZZ_TREE@/src/$(DEPDIR)/hb-ot-map.Po diff --git a/Build/source/libs/harfbuzz/TLpatches/ChangeLog b/Build/source/libs/harfbuzz/TLpatches/ChangeLog index 34acd8fe52d..488f19d7882 100644 --- a/Build/source/libs/harfbuzz/TLpatches/ChangeLog +++ b/Build/source/libs/harfbuzz/TLpatches/ChangeLog @@ -1,3 +1,8 @@ +2018-09-11 Akira Kakuto + + Imported harfbuzz-1.9.0 source tree from: + http://www.freedesktop.org/software/harfbuzz/release/ + 2018-08-15 Akira Kakuto Imported harfbuzz-1.8.8 source tree from: diff --git a/Build/source/libs/harfbuzz/TLpatches/TL-Changes b/Build/source/libs/harfbuzz/TLpatches/TL-Changes index ed5f79ba8f6..dae72960cfe 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.8/ tree as obtained from: +Changes applied to the harfbuzz-1.9.0/ 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 ce1b6cf0d6e..04479097c61 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.8. +# Generated by GNU Autoconf 2.69 for harfbuzz (TeX Live) 1.9.0. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='harfbuzz (TeX Live)' PACKAGE_TARNAME='harfbuzz--tex-live-' -PACKAGE_VERSION='1.8.8' -PACKAGE_STRING='harfbuzz (TeX Live) 1.8.8' +PACKAGE_VERSION='1.9.0' +PACKAGE_STRING='harfbuzz (TeX Live) 1.9.0' 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.8 to adapt to many kinds of systems. +\`configure' configures harfbuzz (TeX Live) 1.9.0 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.8:";; + short | recursive ) echo "Configuration of harfbuzz (TeX Live) 1.9.0:";; 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.8 +harfbuzz (TeX Live) configure 1.9.0 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.8, which was +It was created by harfbuzz (TeX Live) $as_me 1.9.0, 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.8' + VERSION='1.9.0' # Some tools Automake needs. @@ -4247,9 +4247,9 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags HB_VERSION_MAJOR=1 -HB_VERSION_MINOR=8 -HB_VERSION_MICRO=8 -HB_VERSION=1.8.8 +HB_VERSION_MINOR=9 +HB_VERSION_MICRO=0 +HB_VERSION=1.9.0 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.8, which was +This file was extended by harfbuzz (TeX Live) $as_me 1.9.0, 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.8 +harfbuzz (TeX Live) config.status 1.9.0 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 a9bca1bb51d..e0f47e8af90 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog +++ b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog @@ -1,3 +1,1220 @@ +commit 616fd34a69bb69bc35c7e4ea939e71c3ea2e92cb +Author: Behdad Esfahbod +Date: Mon Sep 10 11:19:49 2018 +0200 + + [subset] Disable GSUB/GPOS subsetting for now + + So I can get a release out. I haven't debugged those yet, and they + are producing bad tables. + + src/hb-subset.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d42f0e5809964136911cbbd845bc423a8dfd5e31 +Author: Behdad Esfahbod +Date: Mon Sep 10 11:05:33 2018 +0200 + + [atomic] Fix pointer type passed to InterlockedExchangeAdd() + + John Emmas reported on mailing list that build with MSVC is failing. + Not sure why bots don't catch it, but this should fix. + + src/hb-atomic.hh | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit fda994e1d45c4d34601af7272f37ea257f92a3d8 +Author: Behdad Esfahbod +Date: Fri Sep 7 15:02:57 2018 -0400 + + Use enum instead of "static const" in class scope + + Technically, static const needs an out-of-class definition. Eg: + + CXXLD libharfbuzz-subset.la + Undefined symbols for architecture x86_64: + "OT::FeatureVariationRecord::min_size", referenced from: + bool OT::GSUBGPOS::subset(hb_subset_context_t*) + constin libharfbuzz_subset_la-hb-subset.o + bool OT::GSUBGPOS::subset(hb_subset_context_t*) + constin libharfbuzz_subset_la-hb-subset.o + "OT::Record::min_size", referenced from: + OT::Script::subset(hb_subset_context_t*) constin + libharfbuzz_subset_la-hb-subset.o + "OT::IntType::min_size", referenced from: + OT::Script::subset(hb_subset_context_t*) constin + libharfbuzz_subset_la-hb-subset.o + OT::RecordListOf::subset(hb_subset_context_t*) + const in libharfbuzz_subset_la-hb-subset.o + ld: symbol(s) not found for architecture x86_64 + collect2: ld returned 1 exit status + make[4]: *** [libharfbuzz-subset.la] Error 1 + make[3]: *** [all-recursive] Error 1 + make[2]: *** [all] Error 2 + make[1]: *** [all-recursive] Error 1 + make: *** [all] Error 2 + Exited with code 2 + + src/hb-buffer.hh | 2 +- + src/hb-machinery.hh | 8 ++++---- + src/hb-open-file.hh | 2 +- + src/hb-open-type.hh | 2 +- + src/hb-ot-layout-common.hh | 2 +- + src/hb-ot-layout.cc | 4 ++-- + src/hb-set-digest.hh | 4 ++-- + src/hb-set.hh | 12 ++++++------ + 8 files changed, 18 insertions(+), 18 deletions(-) + +commit ebe67137ab3559c2c6aaf53442ca223cb34df5af +Author: Behdad Esfahbod +Date: Fri Sep 7 10:46:13 2018 -0400 + + Try fixing bots + + src/hb-ot-layout-common.hh | 32 ++++++++++++++++++-------------- + 1 file changed, 18 insertions(+), 14 deletions(-) + +commit 5f17dbc3025093308d2191a4abd2eec24db35c0e +Author: Behdad Esfahbod +Date: Fri Sep 7 10:24:22 2018 -0400 + + [subset] Fix div-by-zero + + src/hb-subset.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 21bf147054f6b5bd1c430c0e02a8c4058ed229a1 +Author: Garret Rieger +Date: Wed Sep 5 18:04:52 2018 -0700 + + [subset] Fix hdmx subsetted size calculation. + + src/hb-ot-hdmx-table.hh | 14 ++++++++++---- + test/api/fonts/Roboto-Regular.multihdmx.a.ttf | Bin 0 -> 2052 bytes + test/api/fonts/Roboto-Regular.multihdmx.abc.ttf | Bin 0 -> 2468 bytes + test/api/test-subset-hdmx.c | 20 + ++++++++++++++++++++ + 4 files changed, 30 insertions(+), 4 deletions(-) + +commit 1e6599f59680c81356b2e9ddddb61252490337a0 +Author: Behdad Esfahbod +Date: Wed Sep 5 19:29:42 2018 -0700 + + Fix older compilers re '>>' at nested template declarations + + src/hb-ot-layout-gsub-table.hh | 8 ++++---- + src/hb-subset.cc | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit a1e5e07c735091e82d66ac56a4e27341f589369d +Author: Behdad Esfahbod +Date: Wed Sep 5 16:24:28 2018 -0700 + + [subset] Hook up GSUB/GPOS, but still disabled + + They are still in the drop list. + + src/hb-ot-hdmx-table.hh | 3 +- + src/hb-subset.cc | 75 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 77 insertions(+), 1 deletion(-) + +commit 0d160d5ff5158fd4190201becd652c8f28ef4430 +Author: Behdad Esfahbod +Date: Mon Sep 3 20:50:11 2018 -0700 + + [subset] Implement subsetting of SingleSubst + + src/hb-machinery.hh | 2 ++ + src/hb-null.hh | 43 +++++++++++++++++++----------- + src/hb-ot-layout-gsub-table.hh | 59 + +++++++++++++++++++++++++++++++++++------- + src/hb-vector.hh | 2 ++ + 4 files changed, 81 insertions(+), 25 deletions(-) + +commit 3f00d0b0df14d69859b15568ff28a810d08f59ea +Author: Behdad Esfahbod +Date: Mon Sep 3 18:54:32 2018 -0700 + + [subset] Keep glyph set in plan + + Should remove the vector version at some point... + + src/hb-subset-plan.cc | 19 ++++++++++--------- + src/hb-subset-plan.hh | 3 +-- + 2 files changed, 11 insertions(+), 11 deletions(-) + +commit dc50493a8da05d6561242136d63cae836486c150 +Author: Behdad Esfahbod +Date: Mon Sep 3 18:23:23 2018 -0700 + + [subset] Towards subsetting SingleSubstFormat1 + + Why does subset plan not have a hb_set_t of glyphs? + + src/hb-machinery.hh | 10 +++++++++- + src/hb-ot-layout-gsub-table.hh | 12 +++++++++++- + 2 files changed, 20 insertions(+), 2 deletions(-) + +commit 339d3603b916cebf24ff86d9842b766261e1b262 +Author: Behdad Esfahbod +Date: Mon Sep 3 17:33:34 2018 -0700 + + [subset] Wire up subset() call down to subtables + + src/hb-ot-layout-common.hh | 36 +++++++++++++++++++++++ + src/hb-ot-layout-gpos-table.hh | 67 + +++++++++++++++++++++++++++++++++++++++--- + src/hb-ot-layout-gsub-table.hh | 54 ++++++++++++++++++++++++++++------ + src/hb-ot-layout-gsubgpos.hh | 42 ++++++++++++++++++++++++++ + 4 files changed, 186 insertions(+), 13 deletions(-) + +commit 7b2ef551da0d53cd94106035b1f065a759cf3cd5 +Author: Behdad Esfahbod +Date: Mon Sep 3 17:16:09 2018 -0700 + + Templatize Lookup::sanitize() + + src/hb-ot-layout-common.hh | 40 + ++++++++++++++++++++++++++++------------ + src/hb-ot-layout-gpos-table.hh | 7 ++----- + src/hb-ot-layout-gsub-table.hh | 25 +++---------------------- + 3 files changed, 33 insertions(+), 39 deletions(-) + +commit 9c3747c5e50423e0a7202f249728d5c5b2b09073 +Author: Behdad Esfahbod +Date: Mon Sep 3 16:53:03 2018 -0700 + + [subset] More + + src/hb-ot-layout-gpos-table.hh | 10 +++++---- + src/hb-ot-layout-gsub-table.hh | 48 + +++++++++++++++++++++--------------------- + src/hb-ot-layout-gsubgpos.hh | 22 +++++++++++++------ + 3 files changed, 45 insertions(+), 35 deletions(-) + +commit 6d618522d63a94230ad708fc49c1c73927da0137 +Author: Behdad Esfahbod +Date: Mon Sep 3 16:41:28 2018 -0700 + + Templatize GSUBGPOS::sanitize() + + src/hb-ot-layout-gpos-table.hh | 6 +----- + src/hb-ot-layout-gsub-table.hh | 14 +++++--------- + src/hb-ot-layout-gsubgpos.hh | 4 +++- + 3 files changed, 9 insertions(+), 15 deletions(-) + +commit 49c44b58f6c2536ea5f403c54a40cab41b905150 +Author: Behdad Esfahbod +Date: Mon Sep 3 16:37:17 2018 -0700 + + [subset] Fix serialize_subset() calls + + Ouch. + + src/hb-open-type.hh | 2 +- + src/hb-ot-layout-common.hh | 6 +++--- + src/hb-ot-layout-gsub-table.hh | 13 ++++++------- + src/hb-ot-layout-gsubgpos.hh | 6 +++--- + 4 files changed, 13 insertions(+), 14 deletions(-) + +commit 7c9cfa2b4002c18585a26134ab987ceb7ebc97a2 +Author: Behdad Esfahbod +Date: Sun Sep 2 19:47:50 2018 -0700 + + Add intersects() method to GSUB/GPOS lookups + + src/hb-ot-layout-common.hh | 77 +++++++++-- + src/hb-ot-layout-gpos-table.hh | 103 ++++++++++---- + src/hb-ot-layout-gsub-table.hh | 205 +++++++++++++++++++-------- + src/hb-ot-layout-gsubgpos.hh | 306 + ++++++++++++++++++++++++++++++++--------- + 4 files changed, 528 insertions(+), 163 deletions(-) + +commit 61ce62e55455bb0d6c9db3b076676ab18e51d449 +Author: Behdad Esfahbod +Date: Sun Sep 2 17:00:27 2018 -0700 + + [subset] Minor + + Remove Lookup::subset(). + + src/hb-ot-layout-common.hh | 11 ----------- + src/hb-ot-layout-gsubgpos.hh | 2 +- + 2 files changed, 1 insertion(+), 12 deletions(-) + +commit bfa72a9a72a15d977f503f12eef376a355679d76 +Author: Behdad Esfahbod +Date: Sat Sep 1 18:34:50 2018 -0700 + + [subset] Towards GSUB/GPOS subsetting + + Add subset() call for GSUBGPOS struct and its dependencies. + Not hooked up anywhere. + + src/hb-machinery.hh | 10 ++++-- + src/hb-open-type.hh | 25 ++++++++++++- + src/hb-ot-layout-common.hh | 80 + +++++++++++++++++++++++++++++++++++------- + src/hb-ot-layout-gdef-table.hh | 33 ++++++++++------- + src/hb-ot-layout-gsub-table.hh | 11 ++++-- + src/hb-ot-layout-gsubgpos.hh | 19 ++++++++++ + 6 files changed, 145 insertions(+), 33 deletions(-) + +commit 6803ed8674028a656957910381150ab28d75a5f8 +Author: Behdad Esfahbod +Date: Fri Aug 31 17:11:08 2018 -0700 + + [serialize] Add reset() + + src/hb-machinery.hh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit e58b190292f85c9676fe14cf63d2831d4d6e6bab +Author: Behdad Esfahbod +Date: Fri Aug 31 16:46:35 2018 -0700 + + [subset] De-templatize hb_subset_context_t + + We're going to (finally) use virtual methods for + hb_serialize_context_t + customization, so don't need to carry a Serializer template variable + around... Simplifies code. + + src/hb-machinery.hh | 2 +- + src/hb-ot-layout-gsub-table.hh | 5 ++--- + src/hb-subset.hh | 7 +++---- + 3 files changed, 6 insertions(+), 8 deletions(-) + +commit 22acd424ca77c16d28405021f06c5562497920ab +Author: Behdad Esfahbod +Date: Fri Aug 31 16:38:04 2018 -0700 + + [serialize] Add a couple small methods + + src/hb-machinery.hh | 25 +++++++++++++++++-------- + src/hb-open-file.hh | 3 +-- + src/hb-ot-layout-gsub-table.hh | 1 + + 3 files changed, 19 insertions(+), 10 deletions(-) + +commit d1f29908c281b1685eea00b71bae934d9f1f20eb +Author: Behdad Esfahbod +Date: Fri Aug 31 16:31:00 2018 -0700 + + [subset] Add hb_subset_context_t<> + + src/hb-open-type.hh | 1 + + src/hb-ot-cmap-table.hh | 1 - + src/hb-ot-hdmx-table.hh | 1 - + src/hb-ot-hmtx-table.hh | 1 - + src/hb-ot-layout-gsub-table.hh | 9 +++++++++ + src/hb-ot-maxp-table.hh | 1 - + src/hb-ot-os2-table.hh | 1 - + src/hb-ot-post-table.hh | 1 - + src/hb-subset.hh | 21 +++++++++++++++++++++ + 9 files changed, 31 insertions(+), 6 deletions(-) + +commit aba0a945c5f8724cc7bd1a9b7f7b5df1c64b03f4 +Author: Behdad Esfahbod +Date: Fri Aug 31 13:25:19 2018 -0700 + + [subset] Add hb-subset-input.hh and make hb-subset.hh toplevel include + + src/Makefile.sources | 1 + + src/hb-ot-cmap-table.hh | 2 +- + src/hb-ot-glyf-table.hh | 2 -- + src/hb-ot-hdmx-table.hh | 2 +- + src/hb-ot-hmtx-table.hh | 2 +- + src/hb-ot-maxp-table.hh | 2 +- + src/hb-ot-os2-table.hh | 2 +- + src/hb-ot-post-table.hh | 2 +- + src/hb-subset-glyf.cc | 1 - + src/hb-subset-glyf.hh | 2 +- + src/hb-subset-input.hh | 57 + +++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-subset-plan.cc | 3 +-- + src/hb-subset-plan.hh | 2 +- + src/hb-subset.cc | 3 +-- + src/hb-subset.hh | 23 +++----------------- + 15 files changed, 71 insertions(+), 35 deletions(-) + +commit 18d01eac7f2870e2804ceed2c70a604a5dc6a320 +Author: Behdad Esfahbod +Date: Fri Aug 31 13:00:57 2018 -0700 + + Minor + + src/hb-ot-shape-complex-arabic-fallback.hh | 1 - + 1 file changed, 1 deletion(-) + +commit a23b892fe6cc4859a30edc7ffc003ab7624aa5f0 +Author: Behdad Esfahbod +Date: Wed Aug 29 18:28:39 2018 -0700 + + Shuffle + + src/hb-machinery.hh | 62 + +++++++++++++++++++++++++++-------------------------- + 1 file changed, 32 insertions(+), 30 deletions(-) + +commit 93fe0faaee45b8fb646f7aa33620105c62193885 +Author: Behdad Esfahbod +Date: Wed Aug 29 18:24:03 2018 -0700 + + [subset] Clean up hb_subset_input_t API + + src/hb-subset-input.cc | 44 + +++++++++++++++++++--------------------- + src/hb-subset-plan.cc | 4 ++-- + src/hb-subset-plan.hh | 10 ++++----- + src/hb-subset.cc | 2 +- + src/hb-subset.h | 14 +++++++++---- + src/hb-subset.hh | 4 ++-- + test/api/test-subset-glyf.c | 10 ++++----- + test/fuzzing/hb-subset-fuzzer.cc | 10 ++++----- + util/hb-subset.cc | 3 +-- + 9 files changed, 52 insertions(+), 49 deletions(-) + +commit d237ce71810045ee400c52740cd8ab6e1113aada +Author: Behdad Esfahbod +Date: Wed Aug 29 18:13:07 2018 -0700 + + [subset] Bail if subsetting a table failed + + src/hb-subset.cc | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +commit f39166f0c0c09fac7874fda6b0b0825f20768e3e +Author: Behdad Esfahbod +Date: Wed Aug 29 18:09:55 2018 -0700 + + [subset] Remove unused hb_subset_profile_t + + We might reintroduce it later, but for now remove, as it was unused. + Some things that should have been in this object (drop_hints, etc) + are already in hb_subset_input_t. So, for now, keep everything there. + + src/hb-subset-plan.cc | 3 +-- + src/hb-subset-plan.hh | 1 - + src/hb-subset.cc | 39 + +++------------------------------------ + src/hb-subset.h | 16 +--------------- + test/api/hb-subset-test.h | 4 +--- + test/api/test-subset-hdmx.c | 8 ++------ + test/api/test-subset-hmtx.c | 4 +--- + test/api/test-subset.c | 12 +++--------- + test/fuzzing/hb-subset-fuzzer.cc | 5 +---- + util/hb-subset.cc | 4 +--- + 10 files changed, 14 insertions(+), 82 deletions(-) + +commit 2ccc322cf88a01248aa5df88a5073db3dfb40eea +Author: Behdad Esfahbod +Date: Wed Aug 29 16:38:04 2018 -0700 + + [ot-font] Clean up cmap with gid=0 + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1145 + + src/hb-ot-cmap-table.hh | 25 +++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +commit 0c7b633f528bae4a0cf5ca816f75a0d84206b3fb +Author: Ross Burton +Date: Wed Aug 29 22:37:39 2018 +0100 + + Delete pkg.m4 + + pkg.m4 is provided by pkg-config, which is a requirement to build, + and this copy is ancient. Delete it to avoid it being used instead + of the host copy. + + m4/pkg.m4 | 157 + -------------------------------------------------------------- + 1 file changed, 157 deletions(-) + +commit fee0f41c6c1e50621d10b07802ca36a9b295b53d +Author: Behdad Esfahbod +Date: Tue Aug 28 18:27:41 2018 -0700 + + Don't declare extern symbols as inline + + clang -O3 was completely removing _get_gdef(), causing link + failure when needed from another compilation unit. Surprisingly, + "extern inline" didn't fix it. + + src/hb-ot-layout.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 967741e4c468ebf0a40f91934ed1923506099806 +Author: Behdad Esfahbod +Date: Tue Aug 28 18:18:02 2018 -0700 + + Add explicit to hb_auto_t 1param constructors + + src/hb-dsalgs.hh | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit c0a3f38f78362a183b30afd109dcebfca563d144 +Author: Behdad Esfahbod +Date: Tue Aug 28 17:22:38 2018 -0700 + + Fix distcheck + + src/Makefile.sources | 3 +++ + 1 file changed, 3 insertions(+) + +commit 2dde6c803a9e50c5bff74095187b0cb2e12eebdd +Author: Behdad Esfahbod +Date: Tue Aug 28 11:02:00 2018 -0700 + + Explicitly pass reference in hb_auto_t constructor + + Fixes clang bots as well as fuzzer issue. + + src/hb-dsalgs.hh | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit a26806801005c28115ae9e48bdcf3bbbc1bcd767 +Author: Behdad Esfahbod +Date: Sun Aug 26 15:18:46 2018 -0700 + + [ot-face] Remove tables_t. The face_data_t is what tables_t was + + src/hb-aat-layout.cc | 4 ++-- + src/hb-face.cc | 6 +++--- + src/hb-ot-face.cc | 8 ++++---- + src/hb-ot-face.hh | 28 ++++++++++++---------------- + src/hb-ot-font.cc | 25 +++++++++++-------------- + src/hb-ot-layout.cc | 36 ++++++++++++++++++------------------ + src/hb-ot-math.cc | 4 ++-- + src/hb-ot-var.cc | 4 ++-- + 8 files changed, 54 insertions(+), 61 deletions(-) + +commit 3a0b3a29cc246d0b1e5989c9e8c1e6d544046dcc +Author: Behdad Esfahbod +Date: Sun Aug 26 15:11:24 2018 -0700 + + Free up hb-ot-face.hh from includes + + There might be a better way to do this, but I couldn't find... + + src/hb-face.cc | 1 + + src/hb-ot-cmap-table.hh | 1 + + src/hb-ot-color-cbdt-table.hh | 2 ++ + src/hb-ot-face.cc | 10 ++++++++++ + src/hb-ot-face.hh | 15 ++------------- + src/hb-ot-font.cc | 7 +++++++ + src/hb-ot-glyf-table.hh | 2 ++ + src/hb-ot-hmtx-table.hh | 3 +++ + src/hb-ot-kern-table.hh | 2 ++ + src/hb-ot-layout-gdef-table.hh | 1 + + src/hb-ot-layout-gpos-table.hh | 2 ++ + src/hb-ot-layout-gsub-table.hh | 1 + + src/hb-ot-post-table.hh | 2 ++ + 13 files changed, 36 insertions(+), 13 deletions(-) + +commit a84309afc8817cd386e555af21dfcdc03388b329 +Author: Behdad Esfahbod +Date: Sun Aug 26 09:33:01 2018 -0700 + + [face] Use saved cmap in collect_unicodes() APIs + + src/hb-face.cc | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +commit c624e18a24311c66737dde4ce515aa1eca892b94 +Author: Behdad Esfahbod +Date: Sun Aug 26 09:19:20 2018 -0700 + + [OT] Move code around + + src/hb-ot-layout-gsub-table.hh | 18 ------------------ + src/hb-ot-layout.cc | 23 +++++++++++++++++++++-- + 2 files changed, 21 insertions(+), 20 deletions(-) + +commit 399909468204b76769857508e74f802d648ca0a5 +Author: Behdad Esfahbod +Date: Sun Aug 26 09:12:25 2018 -0700 + + [OT] Use relaxed ops for recursing into GSUB/GPOS lookups again + + src/hb-ot-layout-gpos-table.hh | 4 ++-- + src/hb-ot-layout-gsub-table.hh | 4 ++-- + src/hb-ot-layout.cc | 12 ++++++++++-- + src/hb-ot-layout.hh | 4 ++-- + 4 files changed, 16 insertions(+), 8 deletions(-) + +commit d8c57e85d9981b4c7a11fae4f31100359574cf13 +Author: Behdad Esfahbod +Date: Sun Aug 26 09:03:31 2018 -0700 + + [GDEF] Move code around + + src/hb-ot-layout-gdef-table.hh | 118 +----------------------------------- + src/hb-ot-layout.cc | 134 + ++++++++++++++++++++++++++++++++++++++--- + src/hb-ot-layout.hh | 14 +---- + 3 files changed, 128 insertions(+), 138 deletions(-) + +commit 453e0c60b1c87d2cd2527d6d2de673f65458a9fd +Author: Behdad Esfahbod +Date: Sun Aug 26 01:30:52 2018 -0700 + + Add template keyword + + I swear I have no idea why this is needed, but it is... + + src/hb-ot-layout-gsubgpos.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c44b0caf0d0cddb7228dcec0b9d25bb62f641abc +Author: Behdad Esfahbod +Date: Sun Aug 26 01:29:30 2018 -0700 + + Fixup + + src/hb-ot-layout-gpos-table.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4096fbe487d90de04020e32e8487295ecd4d8836 +Author: Behdad Esfahbod +Date: Sun Aug 26 01:25:54 2018 -0700 + + [ot-face] Port GDEF to unified table accelerator model as well + + src/hb-ot-face.cc | 108 ---------------------------------- + src/hb-ot-face.hh | 2 +- + src/hb-ot-layout-gdef-table.hh | 129 + +++++++++++++++++++++++++++++++++++++++++ + src/hb-ot-layout.cc | 14 ++++- + src/hb-ot-layout.hh | 5 +- + 5 files changed, 147 insertions(+), 111 deletions(-) + +commit b929100f8782816c2621715f6c007ecefc419d83 +Author: Behdad Esfahbod +Date: Sun Aug 26 01:15:47 2018 -0700 + + [ot-face] Unify GSUB/GPOS accelerators in the table accelerator + framework + + src/hb-aat-layout.cc | 4 +--- + src/hb-ot-face.cc | 40 + ++-------------------------------------- + src/hb-ot-face.hh | 25 +++++++++++-------------- + src/hb-ot-layout-gpos-table.hh | 2 +- + src/hb-ot-layout-gsub-table.hh | 6 +++--- + src/hb-ot-layout-gsubgpos.hh | 24 +++++++++++++----------- + src/hb-ot-layout.cc | 33 +++++++++++++++++---------------- + src/hb-ot-layout.hh | 17 +++++++++++++++++ + src/hb-ot-shape.cc | 1 + + 9 files changed, 66 insertions(+), 86 deletions(-) + +commit 963413fc5454d92621ae83a8d9c9324e404b8166 +Author: Behdad Esfahbod +Date: Sun Aug 26 00:47:55 2018 -0700 + + WIP + + src/hb-ot-cmap-table.hh | 1 - + src/hb-ot-face.hh | 22 ---------------------- + src/hb-ot-layout-gpos-table.hh | 2 ++ + src/hb-ot-layout-gsub-table.hh | 2 ++ + src/hb-ot-layout-gsubgpos.hh | 31 ++++++++++++++++++++++++++++++- + src/hb-ot-layout.hh | 18 +++++++++++++++++- + 6 files changed, 51 insertions(+), 25 deletions(-) + +commit e6cb9380651c753485f721bd3df523d03be41d91 +Author: Behdad Esfahbod +Date: Sun Aug 26 00:21:29 2018 -0700 + + [ot-face] Unify accelerators and tables + + src/hb-machinery.hh | 4 ++-- + src/hb-ot-cmap-table.hh | 3 ++- + src/hb-ot-face.cc | 6 +++-- + src/hb-ot-face.hh | 58 + +++++++++++++------------------------------------ + src/hb-ot-font.cc | 6 ++--- + 5 files changed, 26 insertions(+), 51 deletions(-) + +commit 7f8b6fe67d64b41786edbf8650efb1c0deba573f +Author: Behdad Esfahbod +Date: Sun Aug 26 00:07:12 2018 -0700 + + Minor + + src/hb-ot-face.hh | 1 - + 1 file changed, 1 deletion(-) + +commit 59bca0d2cb6010bc237afb2255ccda3b8dd0585d +Author: Behdad Esfahbod +Date: Sun Aug 26 00:06:12 2018 -0700 + + [ot-font] Rename + + src/hb-ot-face.hh | 12 ++++++------ + src/hb-ot-font.cc | 24 ++++++++++++------------ + 2 files changed, 18 insertions(+), 18 deletions(-) + +commit 1c48a7ef06b82ef9ca013066d1fb3c6fda82aa0c +Author: Behdad Esfahbod +Date: Sat Aug 25 23:54:06 2018 -0700 + + [ot-font] Cache tables on face, not font + + src/hb-ot-cmap-table.hh | 1 + + src/hb-ot-face.cc | 2 ++ + src/hb-ot-face.hh | 55 +++++++++++++++++++++++++++----- + src/hb-ot-font.cc | 75 + ++++---------------------------------------- + src/hb-ot-layout-gsubgpos.hh | 1 + + src/hb-ot-layout.hh | 1 - + 6 files changed, 58 insertions(+), 77 deletions(-) + +commit 71f8893eff56bff651e3df6288becc68ecea6cd1 +Author: Behdad Esfahbod +Date: Sat Aug 25 23:27:45 2018 -0700 + + [ot-font] Use init0 + + src/hb-ot-font.cc | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +commit f36ae6f8a82485bbf727f24dfd7da8f32002cad6 +Author: Behdad Esfahbod +Date: Sat Aug 25 23:19:34 2018 -0700 + + [ot-font] Make everything (cmap/metrics) lazy + + src/hb-machinery.hh | 5 +++++ + src/hb-ot-font.cc | 51 + ++++++++++++++++++++++++++------------------------- + 2 files changed, 31 insertions(+), 25 deletions(-) + +commit 62fc54725a3863473829f3a3748c9336e4dc0787 +Author: Behdad Esfahbod +Date: Sat Aug 25 23:15:52 2018 -0700 + + [ot-font] Fallback vertical advance to UPEM + + Used to be ascent+descent. Whatever. This is more convenient for + upcoming changes. + + src/hb-ot-font.cc | 2 +- + test/shaping/data/in-house/tests/vertical.tests | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit d950022c8ae3f85546272b38b187d6ed9f5ff16f +Author: Behdad Esfahbod +Date: Sat Aug 25 23:06:37 2018 -0700 + + Add hb-ot-face.cc/hh + + src/Makefile.sources | 2 + + src/hb-ot-face.cc | 206 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-ot-face.hh | 144 +++++++++++++++++++++++++++++++++++ + src/hb-ot-layout.cc | 172 ------------------------------------------ + src/hb-ot-layout.hh | 108 +-------------------------- + src/hb-ot-math.cc | 2 +- + src/hb-ot-var.cc | 2 +- + 7 files changed, 355 insertions(+), 281 deletions(-) + +commit dae39c58fb63c2211e2842121bbe6d5b8b18651b +Author: Behdad Esfahbod +Date: Sat Aug 25 22:44:39 2018 -0700 + + [face] Introduce character-map API + + New API: + +hb_face_collect_unicodes + +hb_face_collect_variation_selectors + +hb_face_collect_variation_unicodes + + docs/harfbuzz-sections.txt | 3 ++ + src/hb-face.cc | 61 + ++++++++++++++++++++++++- + src/hb-face.h | 19 ++++++++ + src/hb-subset.cc | 53 + --------------------- + src/hb-subset.h | 15 ------ + test/api/test-subset-codepoints.c | 6 +-- + test/fuzzing/hb-subset-get-codepoints-fuzzer.cc | 2 +- + 7 files changed, 86 insertions(+), 73 deletions(-) + +commit 66384db97c439a64d729f9206657d0b37ec0cb32 +Author: Behdad Esfahbod +Date: Sat Aug 25 22:39:17 2018 -0700 + + Minor + + src/hb-subset.hh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit c77ae40852aabb1698da9e8d488f75bae2f4e734 +Author: Behdad Esfahbod +Date: Sat Aug 25 22:36:36 2018 -0700 + + Rename hb-*private.hh to hb-*.hh + + Sorry for the noise, downstream custom builders. Please adjust. + + src/Makefile.sources | 75 + +++++++++++----------- + src/check-includes.sh | 8 +-- + src/dump-indic-data.cc | 2 +- + src/dump-khmer-data.cc | 2 +- + src/dump-myanmar-data.cc | 2 +- + src/dump-use-data.cc | 2 +- + src/gen-indic-table.py | 2 +- + src/gen-use-table.py | 2 +- + src/hb-aat-layout-ankr-table.hh | 2 +- + src/hb-aat-layout-bsln-table.hh | 2 +- + ...t-common-private.hh => hb-aat-layout-common.hh} | 8 +-- + src/hb-aat-layout-feat-table.hh | 2 +- + src/hb-aat-layout-kerx-table.hh | 4 +- + src/hb-aat-layout-morx-table.hh | 6 +- + src/hb-aat-layout-trak-table.hh | 6 +- + src/hb-aat-layout.cc | 8 +-- + src/{hb-aat-layout-private.hh => hb-aat-layout.hh} | 14 ++-- + src/hb-aat-ltag-table.hh | 2 +- + src/{hb-atomic-private.hh => hb-atomic.hh} | 8 +-- + src/hb-blob.cc | 4 +- + src/{hb-blob-private.hh => hb-blob.hh} | 8 +-- + src/hb-buffer-deserialize-json.hh | 2 +- + src/hb-buffer-deserialize-json.rl | 2 +- + src/hb-buffer-deserialize-text.hh | 2 +- + src/hb-buffer-deserialize-text.rl | 2 +- + src/hb-buffer-serialize.cc | 2 +- + src/hb-buffer.cc | 4 +- + src/{hb-buffer-private.hh => hb-buffer.hh} | 10 +-- + src/hb-common.cc | 4 +- + src/hb-coretext.cc | 4 +- + src/hb-debug.hh | 4 +- + src/hb-directwrite.cc | 4 +- + src/hb-dsalgs.hh | 2 +- + src/hb-face.cc | 8 +-- + src/{hb-face-private.hh => hb-face.hh} | 12 ++-- + src/hb-fallback-shape.cc | 2 +- + src/hb-font.cc | 6 +- + src/{hb-font-private.hh => hb-font.hh} | 12 ++-- + src/hb-ft.cc | 6 +- + src/hb-glib.cc | 6 +- + src/hb-gobject-enums.cc.tmpl | 2 +- + src/hb-gobject-structs.cc | 2 +- + src/hb-graphite2.cc | 2 +- + src/hb-icu.cc | 6 +- + src/{hb-iter-private.hh => hb-iter.hh} | 8 +-- + src/{hb-machinery-private.hh => hb-machinery.hh} | 12 ++-- + src/hb-map.cc | 2 +- + src/{hb-map-private.hh => hb-map.hh} | 8 +-- + src/{hb-mutex-private.hh => hb-mutex.hh} | 8 +-- + src/hb-null.hh | 2 +- + src/{hb-object-private.hh => hb-object.hh} | 14 ++-- + src/{hb-open-file-private.hh => hb-open-file.hh} | 8 +-- + src/{hb-open-type-private.hh => hb-open-type.hh} | 14 ++-- + src/hb-ot-cmap-table.hh | 4 +- + src/hb-ot-color-cbdt-table.hh | 2 +- + src/hb-ot-color-colr-table.hh | 2 +- + src/hb-ot-color-cpal-table.hh | 2 +- + src/hb-ot-color-sbix-table.hh | 2 +- + src/hb-ot-color-svg-table.hh | 2 +- + src/hb-ot-color.cc | 6 +- + src/hb-ot-font.cc | 6 +- + src/hb-ot-glyf-table.hh | 4 +- + src/hb-ot-hdmx-table.hh | 2 +- + src/hb-ot-head-table.hh | 2 +- + src/hb-ot-hhea-table.hh | 2 +- + src/hb-ot-hmtx-table.hh | 2 +- + src/hb-ot-kern-table.hh | 2 +- + src/hb-ot-layout-base-table.hh | 4 +- + ...ut-common-private.hh => hb-ot-layout-common.hh} | 14 ++-- + src/hb-ot-layout-gdef-table.hh | 4 +- + src/hb-ot-layout-gpos-table.hh | 2 +- + src/hb-ot-layout-gsub-table.hh | 2 +- + ...subgpos-private.hh => hb-ot-layout-gsubgpos.hh} | 14 ++-- + src/hb-ot-layout-jstf-table.hh | 2 +- + src/hb-ot-layout.cc | 8 +-- + src/{hb-ot-layout-private.hh => hb-ot-layout.hh} | 16 ++--- + src/hb-ot-map.cc | 4 +- + src/{hb-ot-map-private.hh => hb-ot-map.hh} | 8 +-- + src/hb-ot-math-table.hh | 4 +- + src/hb-ot-math.cc | 4 +- + src/hb-ot-maxp-table.hh | 2 +- + src/hb-ot-name-table.hh | 2 +- + src/hb-ot-os2-table.hh | 2 +- + src/hb-ot-os2-unicode-ranges.hh | 2 +- + src/hb-ot-post-macroman.hh | 2 +- + src/hb-ot-post-table.hh | 2 +- + src/hb-ot-shape-complex-arabic-fallback.hh | 4 +- + src/hb-ot-shape-complex-arabic-win1256.hh | 2 +- + src/hb-ot-shape-complex-arabic.cc | 6 +- + ...ic-private.hh => hb-ot-shape-complex-arabic.hh} | 10 +-- + src/hb-ot-shape-complex-default.cc | 2 +- + src/hb-ot-shape-complex-hangul.cc | 2 +- + src/hb-ot-shape-complex-hebrew.cc | 2 +- + src/hb-ot-shape-complex-indic-machine.hh | 2 +- + src/hb-ot-shape-complex-indic-machine.rl | 2 +- + src/hb-ot-shape-complex-indic-table.cc | 2 +- + src/hb-ot-shape-complex-indic.cc | 4 +- + ...dic-private.hh => hb-ot-shape-complex-indic.hh} | 12 ++-- + src/hb-ot-shape-complex-khmer-machine.hh | 2 +- + src/hb-ot-shape-complex-khmer-machine.rl | 2 +- + src/hb-ot-shape-complex-khmer.cc | 4 +- + ...mer-private.hh => hb-ot-shape-complex-khmer.hh} | 10 +-- + src/hb-ot-shape-complex-myanmar-machine.hh | 2 +- + src/hb-ot-shape-complex-myanmar-machine.rl | 2 +- + src/hb-ot-shape-complex-myanmar.cc | 2 +- + ...r-private.hh => hb-ot-shape-complex-myanmar.hh} | 10 +-- + src/hb-ot-shape-complex-thai.cc | 2 +- + src/hb-ot-shape-complex-tibetan.cc | 2 +- + src/hb-ot-shape-complex-use-machine.hh | 2 +- + src/hb-ot-shape-complex-use-machine.rl | 2 +- + src/hb-ot-shape-complex-use-table.cc | 2 +- + src/hb-ot-shape-complex-use.cc | 4 +- + ...x-use-private.hh => hb-ot-shape-complex-use.hh} | 10 +-- + ...e-complex-private.hh => hb-ot-shape-complex.hh} | 12 ++-- + src/hb-ot-shape-fallback.cc | 4 +- + ...fallback-private.hh => hb-ot-shape-fallback.hh} | 10 +-- + src/hb-ot-shape-normalize.cc | 6 +- + ...rmalize-private.hh => hb-ot-shape-normalize.hh} | 8 +-- + src/hb-ot-shape.cc | 20 +++--- + src/{hb-ot-shape-private.hh => hb-ot-shape.hh} | 12 ++-- + src/hb-ot-tag.cc | 2 +- + src/hb-ot-var-avar-table.hh | 2 +- + src/hb-ot-var-fvar-table.hh | 2 +- + src/hb-ot-var-hvar-table.hh | 2 +- + src/hb-ot-var-mvar-table.hh | 2 +- + src/hb-ot-var.cc | 4 +- + src/{hb-set-digest-private.hh => hb-set-digest.hh} | 8 +-- + src/hb-set.cc | 2 +- + src/{hb-set-private.hh => hb-set.hh} | 8 +-- + src/hb-shape-plan.cc | 10 +-- + src/{hb-shape-plan-private.hh => hb-shape-plan.hh} | 10 +-- + src/hb-shape.cc | 12 ++-- + ...hb-shaper-impl-private.hh => hb-shaper-impl.hh} | 16 ++--- + src/hb-shaper.cc | 6 +- + src/{hb-shaper-private.hh => hb-shaper.hh} | 8 +-- + src/hb-static.cc | 8 +-- + src/hb-string-array.hh | 2 +- + src/hb-subset-glyf.cc | 2 +- + src/hb-subset-glyf.hh | 2 +- + src/hb-subset-input.cc | 4 +- + src/hb-subset-plan.cc | 6 +- + src/hb-subset-plan.hh | 6 +- + src/hb-subset.cc | 8 +-- + src/{hb-subset-private.hh => hb-subset.hh} | 10 +-- + src/hb-ucdn.cc | 6 +- + src/hb-unicode.cc | 6 +- + src/{hb-unicode-private.hh => hb-unicode.hh} | 8 +-- + src/hb-uniscribe.cc | 6 +- + src/{hb-utf-private.hh => hb-utf.hh} | 8 +-- + src/{hb-vector-private.hh => hb-vector.hh} | 8 +-- + src/hb-warning.cc | 6 +- + src/{hb-private.hh => hb.hh} | 12 ++-- + src/main.cc | 4 +- + src/test-buffer-serialize.cc | 2 +- + src/test-size-params.cc | 2 +- + src/test-unicode-ranges.cc | 2 +- + src/test-would-substitute.cc | 2 +- + src/test.cc | 2 +- + test/api/test-common.c | 1 - + util/Makefile.am | 4 +- + util/ansi-print.hh | 3 +- + util/hb-subset.cc | 2 +- + util/helper-cairo-ansi.hh | 2 +- + util/helper-cairo.hh | 2 +- + util/main-font-text.hh | 2 +- + util/options.hh | 2 +- + util/shape-consumer.hh | 2 +- + util/view-cairo.hh | 2 +- + 168 files changed, 452 insertions(+), 455 deletions(-) + +commit 82b12bcadd50c9e86bbe82623a1cbc0b4afdd237 +Author: Behdad Esfahbod +Date: Sat Aug 25 22:07:17 2018 -0700 + + [unicode] Add HB_UNICODE_MAX + + New API: + HB_UNICODE_MAX + + docs/harfbuzz-sections.txt | 1 + + src/hb-ot-cmap-table.hh | 8 ++------ + src/hb-unicode.h | 3 +++ + 3 files changed, 6 insertions(+), 6 deletions(-) + +commit b09a0336ca856a2b1040e7fabd5819b64749e308 +Author: Behdad Esfahbod +Date: Sat Aug 25 22:04:39 2018 -0700 + + [cmap] More hb_auto_t<>(...) + + src/hb-subset.cc | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +commit 28634db07e6ecbdb7e59ed8f989212272a97de86 +Author: Behdad Esfahbod +Date: Sat Aug 25 21:23:43 2018 -0700 + + [cmap] Fix skipping gid0 in Format4 collect_unicodes() + + src/hb-ot-cmap-table.hh | 20 ++++++++++++++++++-- + 1 file changed, 18 insertions(+), 2 deletions(-) + +commit acce1fa3ea9707d0883cd66397fd187d3268905c +Author: Behdad Esfahbod +Date: Sat Aug 25 21:15:39 2018 -0700 + + Use new hb_auto_t<> constructor with Coverage::Iter + + src/hb-ot-layout-common-private.hh | 65 + ++++++++++++++++++++++++-------------- + src/hb-ot-layout-gsub-table.hh | 30 ++++++------------ + 2 files changed, 52 insertions(+), 43 deletions(-) + +commit ddea4d19cf6d64270e14418f02e7ff1f1b9458db +Author: Behdad Esfahbod +Date: Sat Aug 25 21:08:15 2018 -0700 + + Add 1-param passthrough constructor to hb_auto_t<> + + And use. + + src/hb-dsalgs.hh | 1 + + src/hb-ot-cmap-table.hh | 7 +++---- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit c8cfb702e96bf4e89495fcc56f965c88bfa77dca +Author: Behdad Esfahbod +Date: Sat Aug 25 16:14:32 2018 -0700 + + [cmap] Minor + + src/hb-ot-cmap-table.hh | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 1dcf5fb038e7c2d3d03a50c4cd9869a922f9adf7 +Author: Behdad Esfahbod +Date: Sat Aug 25 16:11:26 2018 -0700 + + [cmap Add hb_subset_collect_variation_unicodes() + + To be moved to hb-face.h later. + + src/hb-ot-cmap-table.hh | 59 + +++++++++++++++++++++++++++++++++++++++++-------- + src/hb-subset.cc | 25 ++++++++++++++++++++- + src/hb-subset.h | 10 +++++++-- + 3 files changed, 82 insertions(+), 12 deletions(-) + +commit 4806b3800d77603c203e8bb2e88baeb2b3a14f05 +Author: Behdad Esfahbod +Date: Sat Aug 25 15:56:07 2018 -0700 + + [cmap] Add hb_subset_collect_variation_selectors() + + To be moved to hb-face later. + + src/hb-ot-cmap-table.hh | 20 ++++++++++++++++---- + src/hb-subset.cc | 30 ++++++++++++++++++++++++++---- + src/hb-subset.h | 8 +++++++- + 3 files changed, 49 insertions(+), 9 deletions(-) + +commit 3336de24790ac1a12852ac2a3e2fff4d6bb19bc7 +Author: Behdad Esfahbod +Date: Sat Aug 25 15:41:25 2018 -0700 + + [cmap] Remove unused code + + src/hb-ot-cmap-table.hh | 10 ---------- + 1 file changed, 10 deletions(-) + +commit 1becabe06c0c58aaf69a9ba641508e77a60f3451 +Author: Behdad Esfahbod +Date: Sat Aug 25 15:37:56 2018 -0700 + + [cmap] Use bsearch to find subtables + + src/hb-ot-cmap-table.hh | 5 +---- + test/shaping/data/in-house/tests/fuzzed.tests | 2 +- + 2 files changed, 2 insertions(+), 5 deletions(-) + +commit 02fe03e09a3258e07d2d6749990f6d31dd2a8525 +Author: Behdad Esfahbod +Date: Sat Aug 25 15:33:05 2018 -0700 + + [cmap] Factor out find_best_subtable + + src/hb-ot-cmap-table.hh | 52 + +++++++++++++++++++++++++++++-------------------- + 1 file changed, 31 insertions(+), 21 deletions(-) + +commit b41c43b4e112bfa38fef35694842f242c28a7da2 +Author: Behdad Esfahbod +Date: Sat Aug 25 15:25:03 2018 -0700 + + Minor + + src/hb-ot-cmap-table.hh | 48 + ++++++++++++++++++++++++++---------------------- + 1 file changed, 26 insertions(+), 22 deletions(-) + +commit 7d382fa276f44b7b163e98d434cc79f958bf87fb +Author: Behdad Esfahbod +Date: Sat Aug 25 09:35:45 2018 -0700 + + [cmap] Implement collect_unicodes() for Format0/6/10 + + src/hb-ot-cmap-table.hh | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +commit bd0e542525d41d9ebe51cbcab8151d65eb984b2e +Author: Behdad Esfahbod +Date: Sat Aug 25 09:33:30 2018 -0700 + + [cmap] Simplify collect_unicodes() + + Don't use accelerator (almost). Hooks up Format13 as well. + + src/hb-ot-cmap-table.hh | 52 + +++++++++++++++++++++++++++---------------------- + 1 file changed, 29 insertions(+), 23 deletions(-) + +commit d60c465627d76fcfbeb37d6b8f9382f3b84ace6e +Author: Behdad Esfahbod +Date: Sat Aug 25 08:47:06 2018 -0700 + + Rename get_all_codepoints() to collect_unicodes() + + src/hb-ot-cmap-table.hh | 26 + ++++++++++++------------- + src/hb-subset.cc | 6 +++--- + src/hb-subset.h | 4 ++-- + test/api/test-subset-codepoints.c | 18 ++++++++--------- + test/fuzzing/hb-subset-get-codepoints-fuzzer.cc | 2 +- + 5 files changed, 28 insertions(+), 28 deletions(-) + +commit 531051b8b904cf4eb6a50bacebc11c2d85e40140 +Author: Behdad Esfahbod +Date: Sat Aug 25 08:44:18 2018 -0700 + + [ot-font] Return char-not-found if mapped to gid 0 + + OpenType cmap table can use gid=0 to mean "not covered" to produce + more optimized cmap subtables. Return false from get_nominal_glyph() + for those. hb-ft already does this. + + src/hb-ot-cmap-table.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit aadb2a9188f143126392c0b0f139326dcf7f9c8d +Author: Behdad Esfahbod +Date: Sat Aug 25 08:18:53 2018 -0700 + + Add face-builder + + New API: + +hb_face_builder_create + +hb_face_builder_add_table + + docs/harfbuzz-sections.txt | 5 +- + src/hb-face.cc | 149 + +++++++++++++++++++++++++++++++++++++++++++++ + src/hb-face.h | 14 +++++ + src/hb-subset-plan.cc | 2 +- + src/hb-subset-plan.hh | 2 +- + src/hb-subset-private.hh | 7 --- + src/hb-subset.cc | 129 --------------------------------------- + 7 files changed, 169 insertions(+), 139 deletions(-) + +commit 6cac9dc9ccb76945e9dfacafc169afad4a6e1e88 +Author: Behdad Esfahbod +Date: Fri Aug 24 10:29:45 2018 -0700 + + [blob] Add as_bytes() + + src/hb-blob-private.hh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 29a9a0883877c598413de78cd0c61f07bc393b2c +Author: Behdad Esfahbod +Date: Fri Aug 24 10:24:45 2018 -0700 + + [sanitize] Document how sanitize machinery works + + src/hb-machinery-private.hh | 62 + +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 62 insertions(+) + +commit 142ac5a6be6088771e0ee4b135ba753c80036a9a +Author: Behdad Esfahbod +Date: Fri Aug 24 10:07:49 2018 -0700 + + [serialize] Add copy_bytes() and copy_blob() + + src/hb-dsalgs.hh | 3 +++ + src/hb-machinery-private.hh | 21 ++++++++++++++++++++- + 2 files changed, 23 insertions(+), 1 deletion(-) + +commit 1c6b3693245d38103cab224d75262d45dc88c71c +Author: Behdad Esfahbod +Date: Wed Aug 15 20:12:25 2018 -0700 + + [ot] Rename hb_ot_layout_t to hb_ot_face_data_t + + src/hb-aat-layout.cc | 17 +----- + src/hb-ot-color.cc | 6 +-- + src/hb-ot-layout-gpos-table.hh | 6 +-- + src/hb-ot-layout-gsub-table.hh | 8 ++- + src/hb-ot-layout-gsubgpos-private.hh | 2 +- + src/hb-ot-layout-private.hh | 12 ++--- + src/hb-ot-layout.cc | 100 + +++++++++++++++++------------------ + src/hb-ot-math.cc | 2 +- + src/hb-ot-shape.cc | 5 +- + src/hb-ot-var.cc | 4 +- + 10 files changed, 71 insertions(+), 91 deletions(-) + +commit 22defe0965adddaa09eebc13df7fa6c64e2abba3 +Author: Emil A Eklund +Date: Tue Aug 14 14:47:20 2018 -0700 + + Add guard around free_static_C_locale + + Add HB_USE_ATEXIT guard around free_static_C_locale missed by previous + commit. + + src/hb-common.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7112c6413ca7a1773847fe258145cc5162420953 +Author: Emil A Eklund +Date: Tue Aug 14 13:50:24 2018 -0700 + + Guard free_static function definitions with macro + + Add HB_USE_ATEXIT macros around free_static function definitions to + avoid unused function compiler warnings/errors. + + src/hb-ft.cc | 5 ++++- + src/hb-glib.cc | 3 ++- + src/hb-icu.cc | 3 ++- + src/hb-ot-font.cc | 3 ++- + src/hb-shape.cc | 4 +++- + src/hb-shaper.cc | 3 ++- + 6 files changed, 15 insertions(+), 6 deletions(-) + +commit 63be5dcdde61275822d931b2924425478bc1dac1 +Author: Behdad Esfahbod +Date: Tue Aug 14 10:59:34 2018 -0700 + + 1.8.8 + + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + src/hb-version.h | 4 ++-- + 3 files changed, 21 insertions(+), 3 deletions(-) + commit c9a22fa124310c98c73b8d7b495ed354542a75de Author: Behdad Esfahbod Date: Mon Aug 13 17:02:21 2018 -0700 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS index 3ae857ef329..c9af0f36853 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS +++ b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS @@ -1,3 +1,22 @@ +Overview of changes leading to 1.9.0 +Monday, September 10, 2018 +==================================== +- Added 'cmap' API to hb_face_t. +- Face-builder API. +- hb-ot-font re-creation should be much leaner now, as the + font tables it uses are cached on hb_face_t now. +- Internal source header file name changes: + hb-*-private.hh is renamed to hb-*.hh. + +New API: ++HB_UNICODE_MAX ++hb_face_collect_unicodes() ++hb_face_collect_variation_selectors() ++hb_face_collect_variation_unicodes() ++hb_face_builder_create() ++hb_face_builder_add_table() + + Overview of changes leading to 1.8.8 Tuesday, August 14, 2018 ==================================== diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac index 55cc12b3f40..1c698087132 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.8], + [1.9.0], [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 b981b0e264f..654255e20c7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources @@ -1,28 +1,28 @@ # Base and default-included sources and headers HB_BASE_sources = \ - hb-atomic-private.hh \ - hb-blob-private.hh \ + hb-atomic.hh \ + hb-blob.hh \ hb-blob.cc \ - hb-buffer-private.hh \ + hb-buffer.hh \ hb-buffer-serialize.cc \ hb-buffer.cc \ hb-common.cc \ hb-debug.hh \ hb-dsalgs.hh \ - hb-face-private.hh \ + hb-face.hh \ hb-face.cc \ - hb-font-private.hh \ + hb-font.hh \ hb-font.cc \ - hb-iter-private.hh \ - hb-map-private.hh \ + hb-iter.hh \ + hb-map.hh \ hb-map.cc \ - hb-machinery-private.hh \ - hb-mutex-private.hh \ + hb-machinery.hh \ + hb-mutex.hh \ hb-null.hh \ - hb-object-private.hh \ - hb-open-file-private.hh \ - hb-open-type-private.hh \ + hb-object.hh \ + hb-open-file.hh \ + hb-open-type.hh \ hb-ot-color-cbdt-table.hh \ hb-ot-cmap-table.hh \ hb-ot-glyf-table.hh \ @@ -38,23 +38,23 @@ HB_BASE_sources = \ hb-ot-post-macroman.hh \ hb-ot-post-table.hh \ hb-ot-tag.cc \ - hb-private.hh \ - hb-set-digest-private.hh \ - hb-set-private.hh \ + hb.hh \ + hb-set-digest.hh \ + hb-set.hh \ hb-set.cc \ hb-shape.cc \ - hb-shape-plan-private.hh \ + hb-shape-plan.hh \ hb-shape-plan.cc \ hb-shaper-list.hh \ - hb-shaper-impl-private.hh \ - hb-shaper-private.hh \ + hb-shaper-impl.hh \ + hb-shaper.hh \ hb-shaper.cc \ hb-static.cc \ hb-string-array.hh \ - hb-unicode-private.hh \ + hb-unicode.hh \ hb-unicode.cc \ - hb-vector-private.hh \ - hb-utf-private.hh \ + hb-vector.hh \ + hb-utf.hh \ hb-warning.cc \ $(NULL) @@ -89,61 +89,63 @@ HB_FALLBACK_sources = \ HB_OT_sources = \ hb-aat-layout.cc \ - hb-aat-layout-common-private.hh \ + hb-aat-layout-common.hh \ hb-aat-layout-ankr-table.hh \ hb-aat-layout-bsln-table.hh \ hb-aat-layout-feat-table.hh \ hb-aat-layout-kerx-table.hh \ hb-aat-layout-morx-table.hh \ hb-aat-layout-trak-table.hh \ - hb-aat-layout-private.hh \ + hb-aat-layout.hh \ hb-aat-ltag-table.hh \ + hb-ot-face.hh \ + hb-ot-face.cc \ hb-ot-font.cc \ hb-ot-layout.cc \ hb-ot-layout-base-table.hh \ - hb-ot-layout-common-private.hh \ + hb-ot-layout-common.hh \ hb-ot-layout-gdef-table.hh \ hb-ot-layout-gpos-table.hh \ - hb-ot-layout-gsubgpos-private.hh \ + hb-ot-layout-gsubgpos.hh \ hb-ot-layout-gsub-table.hh \ hb-ot-layout-jstf-table.hh \ - hb-ot-layout-private.hh \ + hb-ot-layout.hh \ hb-ot-color.cc \ hb-ot-color-colr-table.hh \ hb-ot-color-cpal-table.hh \ hb-ot-color-sbix-table.hh \ hb-ot-color-svg-table.hh \ hb-ot-map.cc \ - hb-ot-map-private.hh \ + hb-ot-map.hh \ hb-ot-math.cc \ hb-ot-math-table.hh \ hb-ot-shape.cc \ hb-ot-shape-complex-arabic.cc \ hb-ot-shape-complex-arabic-fallback.hh \ - hb-ot-shape-complex-arabic-private.hh \ + hb-ot-shape-complex-arabic.hh \ hb-ot-shape-complex-arabic-table.hh \ hb-ot-shape-complex-arabic-win1256.hh \ hb-ot-shape-complex-default.cc \ hb-ot-shape-complex-hangul.cc \ hb-ot-shape-complex-hebrew.cc \ hb-ot-shape-complex-indic.cc \ - hb-ot-shape-complex-indic-private.hh \ + hb-ot-shape-complex-indic.hh \ hb-ot-shape-complex-indic-table.cc \ - hb-ot-shape-complex-khmer-private.hh \ + hb-ot-shape-complex-khmer.hh \ hb-ot-shape-complex-khmer.cc \ - hb-ot-shape-complex-myanmar-private.hh \ + hb-ot-shape-complex-myanmar.hh \ hb-ot-shape-complex-myanmar.cc \ hb-ot-shape-complex-thai.cc \ hb-ot-shape-complex-tibetan.cc \ hb-ot-shape-complex-use.cc \ - hb-ot-shape-complex-use-private.hh \ + hb-ot-shape-complex-use.hh \ hb-ot-shape-complex-use-table.cc \ - hb-ot-shape-complex-private.hh \ - hb-ot-shape-normalize-private.hh \ + hb-ot-shape-complex.hh \ + hb-ot-shape-normalize.hh \ hb-ot-shape-normalize.cc \ - hb-ot-shape-fallback-private.hh \ + hb-ot-shape-fallback.hh \ hb-ot-shape-fallback.cc \ - hb-ot-shape-private.hh \ + hb-ot-shape.hh \ hb-ot-var.cc \ hb-ot-var-avar-table.hh \ hb-ot-var-fvar-table.hh \ @@ -207,16 +209,17 @@ HB_ICU_headers = hb-icu.h HB_SUBSET_sources = \ hb-static.cc \ hb-subset.cc \ + hb-subset.hh \ hb-subset-glyf.cc \ + hb-subset-glyf.hh \ hb-subset-input.cc \ + hb-subset-input.hh \ hb-subset-plan.cc \ + hb-subset-plan.hh \ $(NULL) HB_SUBSET_headers = \ hb-subset.h \ - hb-subset-glyf.hh \ - hb-subset-plan.hh \ - hb-subset-private.hh \ $(NULL) HB_GOBJECT_DIST_sources = hb-gobject-structs.cc diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh index fd565da53fb..f938f706cfd 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh @@ -23,14 +23,14 @@ grep -v 'hb[.]h:' | grep . >&2 && stat=1 -echo 'Checking that source files #include "hb-*private.hh" first (or none)' +echo 'Checking that source files #include a private header first (or none)' for x in $HBSOURCES; do test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" - grep '#.*\' "$x" /dev/null | grep -v 'include _' | head -n 1 + grep '#.*\' "$x" /dev/null | head -n 1 done | -grep -v '"hb-.*private[.]hh"' | -grep -v 'hb-private[.]hh:' | +grep -v '"hb-.*[.]hh"' | +grep -v 'hb[.]hh' | grep . >&2 && stat=1 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc index d57413884be..a506889810b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-ot-shape-complex-indic-private.hh" +#include "hb-ot-shape-complex-indic.hh" int main (void) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc index 7dd09b2b5ca..12871fa850f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-ot-shape-complex-khmer-private.hh" +#include "hb-ot-shape-complex-khmer.hh" int main (void) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc index 2df9cd987f3..9f8b12ed229 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-ot-shape-complex-myanmar-private.hh" +#include "hb-ot-shape-complex-myanmar.hh" int main (void) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc index 0e64688f1e0..4a8b25842e1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-ot-shape-complex-use-private.hh" +#include "hb-ot-shape-complex-use.hh" int main (void) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py index 6252664caae..e65b9814adf 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py @@ -102,7 +102,7 @@ for h in headers: print (" * %s" % (l.strip())) print (" */") print () -print ('#include "hb-ot-shape-complex-indic-private.hh"') +print ('#include "hb-ot-shape-complex-indic.hh"') print () # Shorten values diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py index c742ebacae4..a8724619a03 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py @@ -394,7 +394,7 @@ for h in headers: print (" * %s" % (l.strip())) print (" */") print () -print ('#include "hb-ot-shape-complex-use-private.hh"') +print ('#include "hb-ot-shape-complex-use.hh"') print () total = 0 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh index 3b7912b9df6..a197cec8112 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh @@ -25,7 +25,7 @@ #ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH #define HB_AAT_LAYOUT_ANKR_TABLE_HH -#include "hb-aat-layout-common-private.hh" +#include "hb-aat-layout-common.hh" /* * ankr -- Anchor Point diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh index df2bf5b43f0..b86408626f2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh @@ -25,7 +25,7 @@ #ifndef HB_AAT_LAYOUT_BSLN_TABLE_HH #define HB_AAT_LAYOUT_BSLN_TABLE_HH -#include "hb-aat-layout-common-private.hh" +#include "hb-aat-layout-common.hh" /* * bsln -- Baseline diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common-private.hh deleted file mode 100644 index d7f35052d77..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common-private.hh +++ /dev/null @@ -1,644 +0,0 @@ -/* - * Copyright © 2017 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_AAT_LAYOUT_COMMON_PRIVATE_HH -#define HB_AAT_LAYOUT_COMMON_PRIVATE_HH - -#include "hb-aat-layout-private.hh" - - -namespace AAT { - -using namespace OT; - - -/* - * Binary Searching Tables - */ - -struct BinSearchHeader -{ - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - HBUINT16 unitSize; /* Size of a lookup unit for this search in bytes. */ - HBUINT16 nUnits; /* Number of units of the preceding size to be searched. */ - HBUINT16 searchRange; /* The value of unitSize times the largest power of 2 - * that is less than or equal to the value of nUnits. */ - HBUINT16 entrySelector; /* The log base 2 of the largest power of 2 less than - * or equal to the value of nUnits. */ - HBUINT16 rangeShift; /* The value of unitSize times the difference of the - * value of nUnits minus the largest power of 2 less - * than or equal to the value of nUnits. */ - public: - DEFINE_SIZE_STATIC (10); -}; - -template -struct BinSearchArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= header.nUnits)) return Null(Type); - return StructAtOffset (bytesZ, i * header.unitSize); - } - inline Type& operator [] (unsigned int i) - { - return StructAtOffset (bytesZ, i * header.unitSize); - } - inline unsigned int get_size (void) const - { return header.static_size + header.nUnits * header.unitSize; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && StructAtOffset (bytesZ, 0).sanitize (c)); - - return_trace (true); - } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - unsigned int count = header.nUnits; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!(*this)[i].sanitize (c, base))) - return_trace (false); - return_trace (true); - } - - template - inline const Type *bsearch (const T &key) const - { - unsigned int size = header.unitSize; - int min = 0, max = (int) header.nUnits - 1; - while (min <= max) - { - int mid = (min + max) / 2; - const Type *p = (const Type *) (((const char *) bytesZ) + (mid * size)); - int c = p->cmp (key); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - return p; - } - return nullptr; - } - - private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (header.sanitize (c) && - Type::static_size >= header.unitSize && - c->check_array (bytesZ, header.unitSize, header.nUnits)); - } - - protected: - BinSearchHeader header; - HBUINT8 bytesZ[VAR]; - public: - DEFINE_SIZE_ARRAY (10, bytesZ); -}; - - -/* - * Lookup Table - */ - -template struct Lookup; - -template -struct LookupFormat0 -{ - friend struct Lookup; - - private: - inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const - { - if (unlikely (glyph_id >= num_glyphs)) return nullptr; - return &arrayZ[glyph_id]; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (arrayZ.sanitize (c, c->get_num_glyphs ())); - } - - protected: - HBUINT16 format; /* Format identifier--format = 0 */ - UnsizedArrayOf - arrayZ; /* Array of lookup values, indexed by glyph index. */ - public: - DEFINE_SIZE_ARRAY (2, arrayZ); -}; - - -template -struct LookupSegmentSingle -{ - inline int cmp (hb_codepoint_t g) const { - return g < first ? -1 : g <= last ? 0 : +1 ; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && value.sanitize (c)); - } - - GlyphID last; /* Last GlyphID in this segment */ - GlyphID first; /* First GlyphID in this segment */ - T value; /* The lookup value (only one) */ - public: - DEFINE_SIZE_STATIC (4 + T::static_size); -}; - -template -struct LookupFormat2 -{ - friend struct Lookup; - - private: - inline const T* get_value (hb_codepoint_t glyph_id) const - { - const LookupSegmentSingle *v = segments.bsearch (glyph_id); - return v ? &v->value : nullptr; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (segments.sanitize (c)); - } - - protected: - HBUINT16 format; /* Format identifier--format = 2 */ - BinSearchArrayOf > - segments; /* The actual segments. These must already be sorted, - * according to the first word in each one (the last - * glyph in each segment). */ - public: - DEFINE_SIZE_ARRAY (8, segments); -}; - -template -struct LookupSegmentArray -{ - inline const T* get_value (hb_codepoint_t glyph_id, const void *base) const - { - return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr; - } - - inline int cmp (hb_codepoint_t g) const { - return g < first ? -1 : g <= last ? 0 : +1 ; - } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - first <= last && - valuesZ.sanitize (c, base, last - first + 1)); - } - - GlyphID last; /* Last GlyphID in this segment */ - GlyphID first; /* First GlyphID in this segment */ - OffsetTo > - valuesZ; /* A 16-bit offset from the start of - * the table to the data. */ - public: - DEFINE_SIZE_STATIC (6); -}; - -template -struct LookupFormat4 -{ - friend struct Lookup; - - private: - inline const T* get_value (hb_codepoint_t glyph_id) const - { - const LookupSegmentArray *v = segments.bsearch (glyph_id); - return v ? v->get_value (glyph_id, this) : nullptr; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (segments.sanitize (c, this)); - } - - protected: - HBUINT16 format; /* Format identifier--format = 2 */ - BinSearchArrayOf > - segments; /* The actual segments. These must already be sorted, - * according to the first word in each one (the last - * glyph in each segment). */ - public: - DEFINE_SIZE_ARRAY (8, segments); -}; - -template -struct LookupSingle -{ - inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && value.sanitize (c)); - } - - GlyphID glyph; /* Last GlyphID */ - T value; /* The lookup value (only one) */ - public: - DEFINE_SIZE_STATIC (4 + T::static_size); -}; - -template -struct LookupFormat6 -{ - friend struct Lookup; - - private: - inline const T* get_value (hb_codepoint_t glyph_id) const - { - const LookupSingle *v = entries.bsearch (glyph_id); - return v ? &v->value : nullptr; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (entries.sanitize (c)); - } - - protected: - HBUINT16 format; /* Format identifier--format = 6 */ - BinSearchArrayOf > - entries; /* The actual entries, sorted by glyph index. */ - public: - DEFINE_SIZE_ARRAY (8, entries); -}; - -template -struct LookupFormat8 -{ - friend struct Lookup; - - private: - inline const T* get_value (hb_codepoint_t glyph_id) const - { - return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? &valueArrayZ[glyph_id - firstGlyph] : nullptr; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount)); - } - - protected: - HBUINT16 format; /* Format identifier--format = 6 */ - GlyphID firstGlyph; /* First glyph index included in the trimmed array. */ - HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last - * glyph minus the value of firstGlyph plus 1). */ - UnsizedArrayOf - valueArrayZ; /* The lookup values (indexed by the glyph index - * minus the value of firstGlyph). */ - public: - DEFINE_SIZE_ARRAY (6, valueArrayZ); -}; - -template -struct Lookup -{ - inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const - { - switch (u.format) { - case 0: return u.format0.get_value (glyph_id, num_glyphs); - case 2: return u.format2.get_value (glyph_id); - case 4: return u.format4.get_value (glyph_id); - case 6: return u.format6.get_value (glyph_id); - case 8: return u.format8.get_value (glyph_id); - default:return nullptr; - } - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (!u.format.sanitize (c)) return_trace (false); - switch (u.format) { - case 0: return_trace (u.format0.sanitize (c)); - case 2: return_trace (u.format2.sanitize (c)); - case 4: return_trace (u.format4.sanitize (c)); - case 6: return_trace (u.format6.sanitize (c)); - case 8: return_trace (u.format8.sanitize (c)); - default:return_trace (true); - } - } - - protected: - union { - HBUINT16 format; /* Format identifier */ - LookupFormat0 format0; - LookupFormat2 format2; - LookupFormat4 format4; - LookupFormat6 format6; - LookupFormat8 format8; - } u; - public: - DEFINE_SIZE_UNION (2, format); -}; - - -/* - * Extended State Table - */ - -template -struct Entry -{ - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - /* Note, we don't recurse-sanitize data because we don't access it. - * That said, in our DEFINE_SIZE_STATIC we access T::static_size, - * which ensures that data has a simple sanitize(). To be determined - * if I need to remove that as well. */ - return_trace (c->check_struct (this)); - } - - public: - HBUINT16 newState; /* Byte offset from beginning of state table - * to the new state. Really?!?! Or just state - * number? The latter in morx for sure. */ - HBUINT16 flags; /* Table specific. */ - T data; /* Optional offsets to per-glyph tables. */ - public: - DEFINE_SIZE_STATIC (4 + T::static_size); -}; - -template <> -struct Entry -{ - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - public: - HBUINT16 newState; /* Byte offset from beginning of state table to the new state. */ - HBUINT16 flags; /* Table specific. */ - public: - DEFINE_SIZE_STATIC (4); -}; - -template -struct StateTable -{ - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const - { - const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs); - return v ? *v : 1; - } - - inline const Entry *get_entries () const - { - return (this+entryTable).arrayZ; - } - - inline const Entry *get_entryZ (unsigned int state, unsigned int klass) const - { - if (unlikely (klass >= nClasses)) return nullptr; - - const HBUINT16 *states = (this+stateArrayTable).arrayZ; - const Entry *entries = (this+entryTable).arrayZ; - - unsigned int entry = states[state * nClasses + klass]; - - return &entries[entry]; - } - - inline bool sanitize (hb_sanitize_context_t *c, - unsigned int *num_entries_out = nullptr) const - { - TRACE_SANITIZE (this); - if (unlikely (!(c->check_struct (this) && - classTable.sanitize (c, this)))) return_trace (false); - - const HBUINT16 *states = (this+stateArrayTable).arrayZ; - const Entry *entries = (this+entryTable).arrayZ; - - unsigned int num_states = 1; - unsigned int num_entries = 0; - - unsigned int state = 0; - unsigned int entry = 0; - while (state < num_states) - { - if (unlikely (!c->check_array (states, - states[0].static_size * nClasses, - num_states))) - return_trace (false); - { /* Sweep new states. */ - const HBUINT16 *stop = &states[num_states * nClasses]; - for (const HBUINT16 *p = &states[state * nClasses]; p < stop; p++) - num_entries = MAX (num_entries, *p + 1); - state = num_states; - } - - if (unlikely (!c->check_array (entries, - entries[0].static_size, - num_entries))) - return_trace (false); - { /* Sweep new entries. */ - const Entry *stop = &entries[num_entries]; - for (const Entry *p = &entries[entry]; p < stop; p++) - num_states = MAX (num_states, p->newState + 1); - entry = num_entries; - } - } - - if (num_entries_out) - *num_entries_out = num_entries; - - return_trace (true); - } - - protected: - HBUINT32 nClasses; /* Number of classes, which is the number of indices - * in a single line in the state array. */ - LOffsetTo > - classTable; /* Offset to the class table. */ - LOffsetTo > - stateArrayTable;/* Offset to the state array. */ - LOffsetTo > > - entryTable; /* Offset to the entry array. */ - - public: - DEFINE_SIZE_STATIC (16); -}; - -template -struct StateTableDriver -{ - inline StateTableDriver (const StateTable &machine_, - hb_buffer_t *buffer_, - hb_face_t *face_) : - machine (machine_), - buffer (buffer_), - num_glyphs (face_->get_num_glyphs ()) {} - - template - inline void drive (context_t *c) - { - hb_glyph_info_t *info = buffer->info; - - if (!c->in_place) - buffer->clear_output (); - - unsigned int state = 0; - bool last_was_dont_advance = false; - for (buffer->idx = 0;;) - { - unsigned int klass = buffer->idx < buffer->len ? - machine.get_class (info[buffer->idx].codepoint, num_glyphs) : - 0 /* End of text */; - const Entry *entry = machine.get_entryZ (state, klass); - if (unlikely (!entry)) - break; - - /* Unsafe-to-break before this if not in state 0, as things might - * go differently if we start from state 0 here. */ - if (state && buffer->idx) - { - /* If there's no action and we're just epsilon-transitioning to state 0, - * safe to break. */ - if (c->is_actionable (this, entry) || - !(entry->newState == 0 && entry->flags == context_t::DontAdvance)) - buffer->unsafe_to_break (buffer->idx - 1, buffer->idx + 1); - } - - /* Unsafe-to-break if end-of-text would kick in here. */ - if (buffer->idx + 2 <= buffer->len) - { - const Entry *end_entry = machine.get_entryZ (state, 0); - if (c->is_actionable (this, end_entry)) - buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); - } - - if (unlikely (!c->transition (this, entry))) - break; - - last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0; - - state = entry->newState; - - if (buffer->idx == buffer->len) - break; - - if (!last_was_dont_advance) - buffer->next_glyph (); - } - - if (!c->in_place) - { - for (; buffer->idx < buffer->len;) - buffer->next_glyph (); - buffer->swap_buffers (); - } - } - - public: - const StateTable &machine; - hb_buffer_t *buffer; - unsigned int num_glyphs; -}; - - - -struct hb_aat_apply_context_t : - hb_dispatch_context_t -{ - inline const char *get_name (void) { return "APPLY"; } - template - inline return_t dispatch (const T &obj) { return obj.apply (this); } - static return_t default_return_value (void) { return false; } - bool stop_sublookup_iteration (return_t r) const { return r; } - - hb_font_t *font; - hb_face_t *face; - hb_buffer_t *buffer; - hb_sanitize_context_t sanitizer; - - /* Unused. For debug tracing only. */ - unsigned int lookup_index; - unsigned int debug_depth; - - inline hb_aat_apply_context_t (hb_font_t *font_, - hb_buffer_t *buffer_, - hb_blob_t *table) : - font (font_), face (font->face), buffer (buffer_), - sanitizer (), lookup_index (0), debug_depth (0) - { - sanitizer.init (table); - sanitizer.set_num_glyphs (face->get_num_glyphs ()); - sanitizer.start_processing (); - } - - inline void set_lookup_index (unsigned int i) { lookup_index = i; } - - inline ~hb_aat_apply_context_t (void) - { - sanitizer.end_processing (); - } -}; - - -} /* namespace AAT */ - - -#endif /* HB_AAT_LAYOUT_COMMON_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh new file mode 100644 index 00000000000..25f4fe14a75 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh @@ -0,0 +1,644 @@ +/* + * Copyright © 2017 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_AAT_LAYOUT_COMMON_HH +#define HB_AAT_LAYOUT_COMMON_HH + +#include "hb-aat-layout.hh" + + +namespace AAT { + +using namespace OT; + + +/* + * Binary Searching Tables + */ + +struct BinSearchHeader +{ + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + HBUINT16 unitSize; /* Size of a lookup unit for this search in bytes. */ + HBUINT16 nUnits; /* Number of units of the preceding size to be searched. */ + HBUINT16 searchRange; /* The value of unitSize times the largest power of 2 + * that is less than or equal to the value of nUnits. */ + HBUINT16 entrySelector; /* The log base 2 of the largest power of 2 less than + * or equal to the value of nUnits. */ + HBUINT16 rangeShift; /* The value of unitSize times the difference of the + * value of nUnits minus the largest power of 2 less + * than or equal to the value of nUnits. */ + public: + DEFINE_SIZE_STATIC (10); +}; + +template +struct BinSearchArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= header.nUnits)) return Null(Type); + return StructAtOffset (bytesZ, i * header.unitSize); + } + inline Type& operator [] (unsigned int i) + { + return StructAtOffset (bytesZ, i * header.unitSize); + } + inline unsigned int get_size (void) const + { return header.static_size + header.nUnits * header.unitSize; } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && StructAtOffset (bytesZ, 0).sanitize (c)); + + return_trace (true); + } + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + unsigned int count = header.nUnits; + for (unsigned int i = 0; i < count; i++) + if (unlikely (!(*this)[i].sanitize (c, base))) + return_trace (false); + return_trace (true); + } + + template + inline const Type *bsearch (const T &key) const + { + unsigned int size = header.unitSize; + int min = 0, max = (int) header.nUnits - 1; + while (min <= max) + { + int mid = (min + max) / 2; + const Type *p = (const Type *) (((const char *) bytesZ) + (mid * size)); + int c = p->cmp (key); + if (c < 0) + max = mid - 1; + else if (c > 0) + min = mid + 1; + else + return p; + } + return nullptr; + } + + private: + inline bool sanitize_shallow (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (header.sanitize (c) && + Type::static_size >= header.unitSize && + c->check_array (bytesZ, header.unitSize, header.nUnits)); + } + + protected: + BinSearchHeader header; + HBUINT8 bytesZ[VAR]; + public: + DEFINE_SIZE_ARRAY (10, bytesZ); +}; + + +/* + * Lookup Table + */ + +template struct Lookup; + +template +struct LookupFormat0 +{ + friend struct Lookup; + + private: + inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + { + if (unlikely (glyph_id >= num_glyphs)) return nullptr; + return &arrayZ[glyph_id]; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (arrayZ.sanitize (c, c->get_num_glyphs ())); + } + + protected: + HBUINT16 format; /* Format identifier--format = 0 */ + UnsizedArrayOf + arrayZ; /* Array of lookup values, indexed by glyph index. */ + public: + DEFINE_SIZE_ARRAY (2, arrayZ); +}; + + +template +struct LookupSegmentSingle +{ + inline int cmp (hb_codepoint_t g) const { + return g < first ? -1 : g <= last ? 0 : +1 ; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && value.sanitize (c)); + } + + GlyphID last; /* Last GlyphID in this segment */ + GlyphID first; /* First GlyphID in this segment */ + T value; /* The lookup value (only one) */ + public: + DEFINE_SIZE_STATIC (4 + T::static_size); +}; + +template +struct LookupFormat2 +{ + friend struct Lookup; + + private: + inline const T* get_value (hb_codepoint_t glyph_id) const + { + const LookupSegmentSingle *v = segments.bsearch (glyph_id); + return v ? &v->value : nullptr; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (segments.sanitize (c)); + } + + protected: + HBUINT16 format; /* Format identifier--format = 2 */ + BinSearchArrayOf > + segments; /* The actual segments. These must already be sorted, + * according to the first word in each one (the last + * glyph in each segment). */ + public: + DEFINE_SIZE_ARRAY (8, segments); +}; + +template +struct LookupSegmentArray +{ + inline const T* get_value (hb_codepoint_t glyph_id, const void *base) const + { + return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr; + } + + inline int cmp (hb_codepoint_t g) const { + return g < first ? -1 : g <= last ? 0 : +1 ; + } + + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + first <= last && + valuesZ.sanitize (c, base, last - first + 1)); + } + + GlyphID last; /* Last GlyphID in this segment */ + GlyphID first; /* First GlyphID in this segment */ + OffsetTo > + valuesZ; /* A 16-bit offset from the start of + * the table to the data. */ + public: + DEFINE_SIZE_STATIC (6); +}; + +template +struct LookupFormat4 +{ + friend struct Lookup; + + private: + inline const T* get_value (hb_codepoint_t glyph_id) const + { + const LookupSegmentArray *v = segments.bsearch (glyph_id); + return v ? v->get_value (glyph_id, this) : nullptr; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (segments.sanitize (c, this)); + } + + protected: + HBUINT16 format; /* Format identifier--format = 2 */ + BinSearchArrayOf > + segments; /* The actual segments. These must already be sorted, + * according to the first word in each one (the last + * glyph in each segment). */ + public: + DEFINE_SIZE_ARRAY (8, segments); +}; + +template +struct LookupSingle +{ + inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && value.sanitize (c)); + } + + GlyphID glyph; /* Last GlyphID */ + T value; /* The lookup value (only one) */ + public: + DEFINE_SIZE_STATIC (4 + T::static_size); +}; + +template +struct LookupFormat6 +{ + friend struct Lookup; + + private: + inline const T* get_value (hb_codepoint_t glyph_id) const + { + const LookupSingle *v = entries.bsearch (glyph_id); + return v ? &v->value : nullptr; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (entries.sanitize (c)); + } + + protected: + HBUINT16 format; /* Format identifier--format = 6 */ + BinSearchArrayOf > + entries; /* The actual entries, sorted by glyph index. */ + public: + DEFINE_SIZE_ARRAY (8, entries); +}; + +template +struct LookupFormat8 +{ + friend struct Lookup; + + private: + inline const T* get_value (hb_codepoint_t glyph_id) const + { + return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? &valueArrayZ[glyph_id - firstGlyph] : nullptr; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount)); + } + + protected: + HBUINT16 format; /* Format identifier--format = 6 */ + GlyphID firstGlyph; /* First glyph index included in the trimmed array. */ + HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last + * glyph minus the value of firstGlyph plus 1). */ + UnsizedArrayOf + valueArrayZ; /* The lookup values (indexed by the glyph index + * minus the value of firstGlyph). */ + public: + DEFINE_SIZE_ARRAY (6, valueArrayZ); +}; + +template +struct Lookup +{ + inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + { + switch (u.format) { + case 0: return u.format0.get_value (glyph_id, num_glyphs); + case 2: return u.format2.get_value (glyph_id); + case 4: return u.format4.get_value (glyph_id); + case 6: return u.format6.get_value (glyph_id); + case 8: return u.format8.get_value (glyph_id); + default:return nullptr; + } + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (!u.format.sanitize (c)) return_trace (false); + switch (u.format) { + case 0: return_trace (u.format0.sanitize (c)); + case 2: return_trace (u.format2.sanitize (c)); + case 4: return_trace (u.format4.sanitize (c)); + case 6: return_trace (u.format6.sanitize (c)); + case 8: return_trace (u.format8.sanitize (c)); + default:return_trace (true); + } + } + + protected: + union { + HBUINT16 format; /* Format identifier */ + LookupFormat0 format0; + LookupFormat2 format2; + LookupFormat4 format4; + LookupFormat6 format6; + LookupFormat8 format8; + } u; + public: + DEFINE_SIZE_UNION (2, format); +}; + + +/* + * Extended State Table + */ + +template +struct Entry +{ + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + /* Note, we don't recurse-sanitize data because we don't access it. + * That said, in our DEFINE_SIZE_STATIC we access T::static_size, + * which ensures that data has a simple sanitize(). To be determined + * if I need to remove that as well. */ + return_trace (c->check_struct (this)); + } + + public: + HBUINT16 newState; /* Byte offset from beginning of state table + * to the new state. Really?!?! Or just state + * number? The latter in morx for sure. */ + HBUINT16 flags; /* Table specific. */ + T data; /* Optional offsets to per-glyph tables. */ + public: + DEFINE_SIZE_STATIC (4 + T::static_size); +}; + +template <> +struct Entry +{ + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + public: + HBUINT16 newState; /* Byte offset from beginning of state table to the new state. */ + HBUINT16 flags; /* Table specific. */ + public: + DEFINE_SIZE_STATIC (4); +}; + +template +struct StateTable +{ + inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + { + const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs); + return v ? *v : 1; + } + + inline const Entry *get_entries () const + { + return (this+entryTable).arrayZ; + } + + inline const Entry *get_entryZ (unsigned int state, unsigned int klass) const + { + if (unlikely (klass >= nClasses)) return nullptr; + + const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const Entry *entries = (this+entryTable).arrayZ; + + unsigned int entry = states[state * nClasses + klass]; + + return &entries[entry]; + } + + inline bool sanitize (hb_sanitize_context_t *c, + unsigned int *num_entries_out = nullptr) const + { + TRACE_SANITIZE (this); + if (unlikely (!(c->check_struct (this) && + classTable.sanitize (c, this)))) return_trace (false); + + const HBUINT16 *states = (this+stateArrayTable).arrayZ; + const Entry *entries = (this+entryTable).arrayZ; + + unsigned int num_states = 1; + unsigned int num_entries = 0; + + unsigned int state = 0; + unsigned int entry = 0; + while (state < num_states) + { + if (unlikely (!c->check_array (states, + states[0].static_size * nClasses, + num_states))) + return_trace (false); + { /* Sweep new states. */ + const HBUINT16 *stop = &states[num_states * nClasses]; + for (const HBUINT16 *p = &states[state * nClasses]; p < stop; p++) + num_entries = MAX (num_entries, *p + 1); + state = num_states; + } + + if (unlikely (!c->check_array (entries, + entries[0].static_size, + num_entries))) + return_trace (false); + { /* Sweep new entries. */ + const Entry *stop = &entries[num_entries]; + for (const Entry *p = &entries[entry]; p < stop; p++) + num_states = MAX (num_states, p->newState + 1); + entry = num_entries; + } + } + + if (num_entries_out) + *num_entries_out = num_entries; + + return_trace (true); + } + + protected: + HBUINT32 nClasses; /* Number of classes, which is the number of indices + * in a single line in the state array. */ + LOffsetTo > + classTable; /* Offset to the class table. */ + LOffsetTo > + stateArrayTable;/* Offset to the state array. */ + LOffsetTo > > + entryTable; /* Offset to the entry array. */ + + public: + DEFINE_SIZE_STATIC (16); +}; + +template +struct StateTableDriver +{ + inline StateTableDriver (const StateTable &machine_, + hb_buffer_t *buffer_, + hb_face_t *face_) : + machine (machine_), + buffer (buffer_), + num_glyphs (face_->get_num_glyphs ()) {} + + template + inline void drive (context_t *c) + { + hb_glyph_info_t *info = buffer->info; + + if (!c->in_place) + buffer->clear_output (); + + unsigned int state = 0; + bool last_was_dont_advance = false; + for (buffer->idx = 0;;) + { + unsigned int klass = buffer->idx < buffer->len ? + machine.get_class (info[buffer->idx].codepoint, num_glyphs) : + 0 /* End of text */; + const Entry *entry = machine.get_entryZ (state, klass); + if (unlikely (!entry)) + break; + + /* Unsafe-to-break before this if not in state 0, as things might + * go differently if we start from state 0 here. */ + if (state && buffer->idx) + { + /* If there's no action and we're just epsilon-transitioning to state 0, + * safe to break. */ + if (c->is_actionable (this, entry) || + !(entry->newState == 0 && entry->flags == context_t::DontAdvance)) + buffer->unsafe_to_break (buffer->idx - 1, buffer->idx + 1); + } + + /* Unsafe-to-break if end-of-text would kick in here. */ + if (buffer->idx + 2 <= buffer->len) + { + const Entry *end_entry = machine.get_entryZ (state, 0); + if (c->is_actionable (this, end_entry)) + buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); + } + + if (unlikely (!c->transition (this, entry))) + break; + + last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0; + + state = entry->newState; + + if (buffer->idx == buffer->len) + break; + + if (!last_was_dont_advance) + buffer->next_glyph (); + } + + if (!c->in_place) + { + for (; buffer->idx < buffer->len;) + buffer->next_glyph (); + buffer->swap_buffers (); + } + } + + public: + const StateTable &machine; + hb_buffer_t *buffer; + unsigned int num_glyphs; +}; + + + +struct hb_aat_apply_context_t : + hb_dispatch_context_t +{ + inline const char *get_name (void) { return "APPLY"; } + template + inline return_t dispatch (const T &obj) { return obj.apply (this); } + static return_t default_return_value (void) { return false; } + bool stop_sublookup_iteration (return_t r) const { return r; } + + hb_font_t *font; + hb_face_t *face; + hb_buffer_t *buffer; + hb_sanitize_context_t sanitizer; + + /* Unused. For debug tracing only. */ + unsigned int lookup_index; + unsigned int debug_depth; + + inline hb_aat_apply_context_t (hb_font_t *font_, + hb_buffer_t *buffer_, + hb_blob_t *table) : + font (font_), face (font->face), buffer (buffer_), + sanitizer (), lookup_index (0), debug_depth (0) + { + sanitizer.init (table); + sanitizer.set_num_glyphs (face->get_num_glyphs ()); + sanitizer.start_processing (); + } + + inline void set_lookup_index (unsigned int i) { lookup_index = i; } + + inline ~hb_aat_apply_context_t (void) + { + sanitizer.end_processing (); + } +}; + + +} /* namespace AAT */ + + +#endif /* HB_AAT_LAYOUT_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh index 3e070d79592..b7007631662 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh @@ -25,7 +25,7 @@ #ifndef HB_AAT_LAYOUT_FEAT_TABLE_HH #define HB_AAT_LAYOUT_FEAT_TABLE_HH -#include "hb-aat-layout-common-private.hh" +#include "hb-aat-layout-common.hh" /* * feat -- Feature Name diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh index cc03d627862..615a8f8d4c3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh @@ -28,8 +28,8 @@ #ifndef HB_AAT_LAYOUT_KERX_TABLE_HH #define HB_AAT_LAYOUT_KERX_TABLE_HH -#include "hb-open-type-private.hh" -#include "hb-aat-layout-common-private.hh" +#include "hb-open-type.hh" +#include "hb-aat-layout-common.hh" #include "hb-aat-layout-ankr-table.hh" /* diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh index f25842457db..ef452e22b29 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh @@ -27,9 +27,9 @@ #ifndef HB_AAT_LAYOUT_MORX_TABLE_HH #define HB_AAT_LAYOUT_MORX_TABLE_HH -#include "hb-open-type-private.hh" -#include "hb-aat-layout-common-private.hh" -#include "hb-ot-layout-common-private.hh" +#include "hb-open-type.hh" +#include "hb-aat-layout-common.hh" +#include "hb-ot-layout-common.hh" /* * morx -- Extended Glyph Metamorphosis diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-private.hh deleted file mode 100644 index ce75c8e7192..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-private.hh +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2017 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_AAT_LAYOUT_PRIVATE_HH -#define HB_AAT_LAYOUT_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-font-private.hh" -#include "hb-buffer-private.hh" -#include "hb-open-type-private.hh" - - -HB_INTERNAL void -hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer); - -HB_INTERNAL void -hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer); - -#endif /* HB_AAT_LAYOUT_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh index f5dc558c3fe..c4bec2cab64 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh @@ -28,9 +28,9 @@ #ifndef HB_AAT_LAYOUT_TRAK_TABLE_HH #define HB_AAT_LAYOUT_TRAK_TABLE_HH -#include "hb-aat-layout-common-private.hh" -#include "hb-ot-layout-private.hh" -#include "hb-open-type-private.hh" +#include "hb-aat-layout-common.hh" +#include "hb-ot-layout.hh" +#include "hb-open-type.hh" /* * trak -- Tracking 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 36d4037ad9b..a5e36a40a38 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 @@ -24,12 +24,10 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" -#include "hb-ot-layout-private.hh" -#include "hb-ot-layout-gsubgpos-private.hh" - -#include "hb-aat-layout-private.hh" +#include "hb-ot-face.hh" +#include "hb-aat-layout.hh" #include "hb-aat-layout-ankr-table.hh" #include "hb-aat-layout-bsln-table.hh" // Just so we compile it; unused otherwise. #include "hb-aat-layout-feat-table.hh" // Just so we compile it; unused otherwise. @@ -51,25 +49,12 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr) *blob = hb_blob_get_empty (); return Null(AAT::morx); } - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::morx& morx = *(layout->table.morx.get ()); + const AAT::morx& morx = *(hb_ot_face_data (face)->morx.get ()); if (blob) - *blob = layout->table.morx.get_blob (); + *blob = hb_ot_face_data (face)->morx.get_blob (); return morx; } -// static inline void -// _hb_aat_layout_create (hb_face_t *face) -// { -// hb_blob_t *morx_blob = hb_sanitize_context_t ().reference_table (face); -// morx_blob->as (); - -// if (0) -// { -// morx_blob->as > ()->get_value (1, face->get_num_glyphs ()); -// } -// } - void hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh new file mode 100644 index 00000000000..ac9c535395a --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh @@ -0,0 +1,43 @@ +/* + * Copyright © 2017 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_AAT_LAYOUT_HH +#define HB_AAT_LAYOUT_HH + +#include "hb.hh" + +#include "hb-font.hh" +#include "hb-buffer.hh" +#include "hb-open-type.hh" + + +HB_INTERNAL void +hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer); + +HB_INTERNAL void +hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer); + +#endif /* HB_AAT_LAYOUT_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh index 15c4e89cbe5..e308ab28c37 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh @@ -25,7 +25,7 @@ #ifndef HB_AAT_LTAG_TABLE_HH #define HB_AAT_LTAG_TABLE_HH -#include "hb-aat-layout-common-private.hh" +#include "hb-aat-layout-common.hh" /* * ltag -- Language Tag diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic-private.hh deleted file mode 100644 index 297c646986c..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic-private.hh +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 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. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_ATOMIC_PRIVATE_HH -#define HB_ATOMIC_PRIVATE_HH - -#include "hb-private.hh" - - -/* - * Atomic integers and pointers. - */ - - -/* We need external help for these */ - -#if defined(hb_atomic_int_impl_add) \ - && defined(hb_atomic_ptr_impl_get) \ - && defined(hb_atomic_ptr_impl_cmpexch) - -/* Defined externally, i.e. in config.h. */ - - -#elif !defined(HB_NO_MT) && defined(__ATOMIC_CONSUME) - -/* C++11-style GCC primitives. */ - -#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL) -#define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED) -#define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED) - -#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED) -#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED) -#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_CONSUME) -static inline bool -_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) -{ - const void *O = O_; // Need lvalue - return __atomic_compare_exchange_n ((void **) P, (void **) &O, (void *) N, true, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); -} -#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) - -#elif !defined(HB_NO_MT) && __cplusplus >= 201103L - -/* C++11 atomics. */ - -#include - -#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast *> (AI)->fetch_add ((V), std::memory_order_acq_rel)) -#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast *> (AI)->store ((V), std::memory_order_relaxed)) -#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast *> (AI)->load (std::memory_order_relaxed)) - -#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast *> (P)->store ((V), std::memory_order_relaxed)) -#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast *> (P)->load (std::memory_order_relaxed)) -#define hb_atomic_ptr_impl_get(P) (reinterpret_cast *> (P)->load (std::memory_order_consume)) -static inline bool -_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) -{ - const void *O = O_; // Need lvalue - return reinterpret_cast *> (P)->compare_exchange_weak (O, N, std::memory_order_acq_rel, std::memory_order_relaxed); -} -#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) - - -#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) - -#include - -static inline void _hb_memory_barrier (void) -{ -#if !defined(MemoryBarrier) - /* MinGW has a convoluted history of supporting MemoryBarrier. */ - long dummy = 0; - InterlockedExchange (&dummy, 1); -#else - MemoryBarrier (); -#endif -} -#define _hb_memory_barrier() _hb_memory_barrier () - -#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((unsigned *) (AI), (V)) - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) - - -#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) - -#define _hb_memory_barrier() __sync_synchronize () - -#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add ((AI), (V)) - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) - - -#elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS) - -#include -#include - -#define _hb_memory_r_barrier() __machine_r_barrier () -#define _hb_memory_w_barrier() __machine_w_barrier () -#define _hb_memory_barrier() __machine_rw_barrier () - -static inline int _hb_fetch_and_add (int *AI, int V) -{ - _hb_memory_w_barrier (); - int result = atomic_add_int_nv ((uint_t *) AI, V); - _hb_memory_r_barrier (); - return result; -} -static inline bool _hb_compare_and_swap_ptr (const void **P, const void *O, const void *N) -{ - _hb_memory_w_barrier (); - int result = atomic_cas_ptr ((void **) P, (void *) O, (void *) N) == (void *) O; - _hb_memory_r_barrier (); - return result; -} - -#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swap_ptr ((const void **) (P), (O), (N)) - - -#elif !defined(HB_NO_MT) && defined(__APPLE__) - -#include -#ifdef __MAC_OS_X_MIN_REQUIRED -#include -#elif defined(__IPHONE_OS_MIN_REQUIRED) -#include -#endif - -#define _hb_memory_barrier() OSMemoryBarrier () - -#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), (AI)) - (V)) - -#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) -#else -#if __ppc64__ || __x86_64__ || __aarch64__ -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (void *) (O), (int64_t) (void *) (N), (int64_t*) (P)) -#else -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (void *) (O), (int32_t) (void *) (N), (int32_t*) (P)) -#endif -#endif - - -#elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__) - -#include - -#define _hb_memory_barrier() __lwsync () - -static inline int _hb_fetch_and_add (int *AI, int V) -{ - _hb_memory_barrier (); - int result = __fetch_and_add (AI, V); - _hb_memory_barrier (); - return result; -} -static inline bool _hb_compare_and_swaplp (long *P, long O, long N) -{ - _hb_memory_barrier (); - bool result = __compare_and_swaplp (P, &O, N); - _hb_memory_barrier (); - return result; -} - -#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N)) -static_assert ((sizeof (long) == sizeof (void *)), ""); - - -#elif !defined(HB_NO_MT) - -#define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */ - -#define _hb_memory_barrier() - -#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) - - -#else /* HB_NO_MT */ - -#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) - -#define _hb_memory_barrier() - -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) - - -#endif - - -#ifndef _hb_memory_r_barrier -#define _hb_memory_r_barrier() _hb_memory_barrier () -#endif -#ifndef _hb_memory_w_barrier -#define _hb_memory_w_barrier() _hb_memory_barrier () -#endif -#ifndef hb_atomic_int_impl_set_relaxed -#define hb_atomic_int_impl_set_relaxed(AI, V) (*(AI) = (V)) -#endif -#ifndef hb_atomic_int_impl_get_relaxed -#define hb_atomic_int_impl_get_relaxed(AI) (*(AI)) -#endif - -#ifndef hb_atomic_ptr_impl_set_relaxed -#define hb_atomic_ptr_impl_set_relaxed(P, V) (*(P) = (V)) -#endif -#ifndef hb_atomic_ptr_impl_get_relaxed -#define hb_atomic_ptr_impl_get_relaxed(P) (*(P)) -#endif -#ifndef hb_atomic_ptr_impl_get -inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barrier (); return v; } -#endif - - -#define HB_ATOMIC_INT_INIT(V) {V} -struct hb_atomic_int_t -{ - inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); } - inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); } - inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); } - inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); } - - mutable int v; -}; - - -template struct hb_remove_ptr_t { typedef T value; }; -template struct hb_remove_ptr_t { typedef T value; }; - -#define HB_ATOMIC_PTR_INIT(V) {V} -template -struct hb_atomic_ptr_t -{ - typedef typename hb_remove_ptr_t

::value T; - - inline void init (T* v_ = nullptr) { set_relaxed (v_); } - inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); } - inline T *get_relaxed (void) const { return hb_atomic_ptr_impl_get_relaxed (&v); } - inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } - inline bool cmpexch (const T *old, T *new_) const{ return hb_atomic_ptr_impl_cmpexch (&v, old, new_); } - - mutable T *v; -}; - - -#endif /* HB_ATOMIC_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh new file mode 100644 index 00000000000..6e3672c18bc --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh @@ -0,0 +1,282 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 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. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_ATOMIC_HH +#define HB_ATOMIC_HH + +#include "hb.hh" + + +/* + * Atomic integers and pointers. + */ + + +/* We need external help for these */ + +#if defined(hb_atomic_int_impl_add) \ + && defined(hb_atomic_ptr_impl_get) \ + && defined(hb_atomic_ptr_impl_cmpexch) + +/* Defined externally, i.e. in config.h. */ + + +#elif !defined(HB_NO_MT) && defined(__ATOMIC_CONSUME) + +/* C++11-style GCC primitives. */ + +#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL) +#define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED) +#define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED) + +#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED) +#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED) +#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_CONSUME) +static inline bool +_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) +{ + const void *O = O_; // Need lvalue + return __atomic_compare_exchange_n ((void **) P, (void **) &O, (void *) N, true, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); +} +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) + +#elif !defined(HB_NO_MT) && __cplusplus >= 201103L + +/* C++11 atomics. */ + +#include + +#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast *> (AI)->fetch_add ((V), std::memory_order_acq_rel)) +#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast *> (AI)->store ((V), std::memory_order_relaxed)) +#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast *> (AI)->load (std::memory_order_relaxed)) + +#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast *> (P)->store ((V), std::memory_order_relaxed)) +#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast *> (P)->load (std::memory_order_relaxed)) +#define hb_atomic_ptr_impl_get(P) (reinterpret_cast *> (P)->load (std::memory_order_consume)) +static inline bool +_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) +{ + const void *O = O_; // Need lvalue + return reinterpret_cast *> (P)->compare_exchange_weak (O, N, std::memory_order_acq_rel, std::memory_order_relaxed); +} +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) + + +#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) + +#include + +static inline void _hb_memory_barrier (void) +{ +#if !defined(MemoryBarrier) + /* MinGW has a convoluted history of supporting MemoryBarrier. */ + LONG dummy = 0; + InterlockedExchange (&dummy, 1); +#else + MemoryBarrier (); +#endif +} +#define _hb_memory_barrier() _hb_memory_barrier () + +#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((LONG *) (AI), (V)) +static_assert ((sizeof (LONG) == sizeof (int)), ""); + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) + + +#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) + +#define _hb_memory_barrier() __sync_synchronize () + +#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add ((AI), (V)) + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) + + +#elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS) + +#include +#include + +#define _hb_memory_r_barrier() __machine_r_barrier () +#define _hb_memory_w_barrier() __machine_w_barrier () +#define _hb_memory_barrier() __machine_rw_barrier () + +static inline int _hb_fetch_and_add (int *AI, int V) +{ + _hb_memory_w_barrier (); + int result = atomic_add_int_nv ((uint_t *) AI, V); + _hb_memory_r_barrier (); + return result; +} +static inline bool _hb_compare_and_swap_ptr (const void **P, const void *O, const void *N) +{ + _hb_memory_w_barrier (); + int result = atomic_cas_ptr ((void **) P, (void *) O, (void *) N) == (void *) O; + _hb_memory_r_barrier (); + return result; +} + +#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swap_ptr ((const void **) (P), (O), (N)) + + +#elif !defined(HB_NO_MT) && defined(__APPLE__) + +#include +#ifdef __MAC_OS_X_MIN_REQUIRED +#include +#elif defined(__IPHONE_OS_MIN_REQUIRED) +#include +#endif + +#define _hb_memory_barrier() OSMemoryBarrier () + +#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), (AI)) - (V)) + +#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) +#else +#if __ppc64__ || __x86_64__ || __aarch64__ +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (void *) (O), (int64_t) (void *) (N), (int64_t*) (P)) +#else +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (void *) (O), (int32_t) (void *) (N), (int32_t*) (P)) +#endif +#endif + + +#elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__) + +#include + +#define _hb_memory_barrier() __lwsync () + +static inline int _hb_fetch_and_add (int *AI, int V) +{ + _hb_memory_barrier (); + int result = __fetch_and_add (AI, V); + _hb_memory_barrier (); + return result; +} +static inline bool _hb_compare_and_swaplp (long *P, long O, long N) +{ + _hb_memory_barrier (); + bool result = __compare_and_swaplp (P, &O, N); + _hb_memory_barrier (); + return result; +} + +#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N)) +static_assert ((sizeof (long) == sizeof (void *)), ""); + + +#elif !defined(HB_NO_MT) + +#define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */ + +#define _hb_memory_barrier() + +#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) + + +#else /* HB_NO_MT */ + +#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) + +#define _hb_memory_barrier() + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) + + +#endif + + +#ifndef _hb_memory_r_barrier +#define _hb_memory_r_barrier() _hb_memory_barrier () +#endif +#ifndef _hb_memory_w_barrier +#define _hb_memory_w_barrier() _hb_memory_barrier () +#endif +#ifndef hb_atomic_int_impl_set_relaxed +#define hb_atomic_int_impl_set_relaxed(AI, V) (*(AI) = (V)) +#endif +#ifndef hb_atomic_int_impl_get_relaxed +#define hb_atomic_int_impl_get_relaxed(AI) (*(AI)) +#endif + +#ifndef hb_atomic_ptr_impl_set_relaxed +#define hb_atomic_ptr_impl_set_relaxed(P, V) (*(P) = (V)) +#endif +#ifndef hb_atomic_ptr_impl_get_relaxed +#define hb_atomic_ptr_impl_get_relaxed(P) (*(P)) +#endif +#ifndef hb_atomic_ptr_impl_get +inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barrier (); return v; } +#endif + + +#define HB_ATOMIC_INT_INIT(V) {V} +struct hb_atomic_int_t +{ + inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); } + inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); } + inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); } + inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); } + + mutable int v; +}; + + +template struct hb_remove_ptr_t { typedef T value; }; +template struct hb_remove_ptr_t { typedef T value; }; + +#define HB_ATOMIC_PTR_INIT(V) {V} +template +struct hb_atomic_ptr_t +{ + typedef typename hb_remove_ptr_t

::value T; + + inline void init (T* v_ = nullptr) { set_relaxed (v_); } + inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); } + inline T *get_relaxed (void) const { return hb_atomic_ptr_impl_get_relaxed (&v); } + inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } + inline bool cmpexch (const T *old, T *new_) const{ return hb_atomic_ptr_impl_cmpexch (&v, old, new_); } + + mutable T *v; +}; + + +#endif /* HB_ATOMIC_HH */ 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 deleted file mode 100644 index 49ad68ecec7..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob-private.hh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * 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. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_BLOB_PRIVATE_HH -#define HB_BLOB_PRIVATE_HH - -#include "hb-private.hh" - - -/* - * hb_blob_t - */ - -struct hb_blob_t -{ - inline void fini_shallow (void) - { - destroy_user_data (); - } - - inline void destroy_user_data (void) - { - if (destroy) - { - destroy (user_data); - user_data = nullptr; - destroy = nullptr; - } - } - - HB_INTERNAL bool try_make_writable (void); - HB_INTERNAL bool try_make_writable_inplace (void); - HB_INTERNAL bool try_make_writable_inplace_unix (void); - - template - inline const Type* as (void) const - { - return unlikely (!data) ? &Null(Type) : reinterpret_cast (data); - } - - public: - hb_object_header_t header; - ASSERT_POD (); - - bool immutable; - - const char *data; - unsigned int length; - hb_memory_mode_t mode; - - 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 25c3e05aad1..a335df308a5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc @@ -30,8 +30,8 @@ #define _POSIX_C_SOURCE 200809L #endif -#include "hb-private.hh" -#include "hb-blob-private.hh" +#include "hb.hh" +#include "hb-blob.hh" #ifdef HAVE_SYS_MMAN_H #ifdef HAVE_UNISTD_H diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh new file mode 100644 index 00000000000..bee8c9794ad --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh @@ -0,0 +1,86 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * 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. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_BLOB_HH +#define HB_BLOB_HH + +#include "hb.hh" + + +/* + * hb_blob_t + */ + +struct hb_blob_t +{ + inline void fini_shallow (void) + { + destroy_user_data (); + } + + inline void destroy_user_data (void) + { + if (destroy) + { + destroy (user_data); + user_data = nullptr; + destroy = nullptr; + } + } + + HB_INTERNAL bool try_make_writable (void); + HB_INTERNAL bool try_make_writable_inplace (void); + HB_INTERNAL bool try_make_writable_inplace_unix (void); + + template + inline const Type* as (void) const + { + return unlikely (!data) ? &Null(Type) : reinterpret_cast (data); + } + inline hb_bytes_t as_bytes (void) const + { + return hb_bytes_t (data, length); + } + + public: + hb_object_header_t header; + ASSERT_POD (); + + bool immutable; + + const char *data; + unsigned int length; + hb_memory_mode_t mode; + + void *user_data; + hb_destroy_func_t destroy; +}; +DECLARE_NULL_INSTANCE (hb_blob_t); + + +#endif /* HB_BLOB_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.hh index 380f3c5fca3..1f9e2e91db8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.hh @@ -29,7 +29,7 @@ #ifndef HB_BUFFER_DESERIALIZE_JSON_HH #define HB_BUFFER_DESERIALIZE_JSON_HH -#include "hb-private.hh" +#include "hb.hh" #line 36 "hb-buffer-deserialize-json.hh" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.rl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.rl index ec9bc7c9ae9..f3abb027b20 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.rl +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-json.rl @@ -27,7 +27,7 @@ #ifndef HB_BUFFER_DESERIALIZE_JSON_HH #define HB_BUFFER_DESERIALIZE_JSON_HH -#include "hb-private.hh" +#include "hb.hh" %%{ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.hh index 5bca369f8d2..67f0a1252f8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.hh @@ -29,7 +29,7 @@ #ifndef HB_BUFFER_DESERIALIZE_TEXT_HH #define HB_BUFFER_DESERIALIZE_TEXT_HH -#include "hb-private.hh" +#include "hb.hh" #line 36 "hb-buffer-deserialize-text.hh" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.rl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.rl index 1d90979a902..6268a6c5039 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.rl +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-deserialize-text.rl @@ -27,7 +27,7 @@ #ifndef HB_BUFFER_DESERIALIZE_TEXT_HH #define HB_BUFFER_DESERIALIZE_TEXT_HH -#include "hb-private.hh" +#include "hb.hh" %%{ 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 deleted file mode 100644 index a6c4b696330..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright © 1998-2004 David Turner and Werner Lemberg - * Copyright © 2004,2007,2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 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): Owen Taylor, Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_BUFFER_PRIVATE_HH -#define HB_BUFFER_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-unicode-private.hh" - - -#ifndef HB_BUFFER_MAX_LEN_FACTOR -#define HB_BUFFER_MAX_LEN_FACTOR 32 -#endif -#ifndef HB_BUFFER_MAX_LEN_MIN -#define HB_BUFFER_MAX_LEN_MIN 8192 -#endif -#ifndef HB_BUFFER_MAX_LEN_DEFAULT -#define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */ -#endif - -#ifndef HB_BUFFER_MAX_OPS_FACTOR -#define HB_BUFFER_MAX_OPS_FACTOR 64 -#endif -#ifndef HB_BUFFER_MAX_OPS_MIN -#define HB_BUFFER_MAX_OPS_MIN 1024 -#endif -#ifndef HB_BUFFER_MAX_OPS_DEFAULT -#define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */ -#endif - -static_assert ((sizeof (hb_glyph_info_t) == 20), ""); -static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)), ""); - -HB_MARK_AS_FLAG_T (hb_buffer_flags_t); -HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t); -HB_MARK_AS_FLAG_T (hb_buffer_diff_flags_t); - -enum hb_buffer_scratch_flags_t { - HB_BUFFER_SCRATCH_FLAG_DEFAULT = 0x00000000u, - HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u, - HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u, - HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, - HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, - HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u, - HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u, - - /* Reserved for complex shapers' internal use. */ - HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX2 = 0x04000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX3 = 0x08000000u, -}; -HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t); - - -/* - * hb_buffer_t - */ - -struct hb_buffer_t -{ - hb_object_header_t header; - ASSERT_POD (); - - /* Information about how the text in the buffer should be treated */ - hb_unicode_funcs_t *unicode; /* Unicode functions */ - hb_buffer_flags_t flags; /* BOT / EOT / etc. */ - hb_buffer_cluster_level_t cluster_level; - hb_codepoint_t replacement; /* U+FFFD or something else. */ - hb_buffer_scratch_flags_t scratch_flags; /* Have space-fallback, etc. */ - unsigned int max_len; /* Maximum allowed len. */ - int max_ops; /* Maximum allowed operations. */ - - /* Buffer contents */ - hb_buffer_content_type_t content_type; - hb_segment_properties_t props; /* Script, language, direction */ - - bool successful; /* Allocations successful */ - bool have_output; /* Whether we have an output buffer going on */ - bool have_positions; /* Whether we have positions */ - - unsigned int idx; /* Cursor into ->info and ->pos arrays */ - unsigned int len; /* Length of ->info and ->pos arrays */ - unsigned int out_len; /* Length of ->out array if have_output */ - - unsigned int allocated; /* Length of allocated arrays */ - hb_glyph_info_t *info; - hb_glyph_info_t *out_info; - hb_glyph_position_t *pos; - - unsigned int serial; - - /* Text before / after the main buffer contents. - * Always in Unicode, and ordered outward. - * Index 0 is for "pre-context", 1 for "post-context". */ - static const unsigned int CONTEXT_LENGTH = 5; - hb_codepoint_t context[2][CONTEXT_LENGTH]; - unsigned int context_len[2]; - - /* Debugging API */ - hb_buffer_message_func_t message_func; - void *message_data; - hb_destroy_func_t message_destroy; - - /* Internal debugging. */ - /* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ -#ifndef HB_NDEBUG - uint8_t allocated_var_bits; -#endif - - - /* Methods */ - - inline void allocate_var (unsigned int start, unsigned int count) - { -#ifndef HB_NDEBUG - unsigned int end = start + count; - assert (end <= 8); - unsigned int bits = (1u< (cluster, infos[i].cluster); - return cluster; - } - inline void - _unsafe_to_break_set_mask (hb_glyph_info_t *infos, - unsigned int start, unsigned int end, - unsigned int cluster) - { - for (unsigned int i = start; i < end; i++) - if (cluster != infos[i].cluster) - { - scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK; - infos[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; - } - } - - inline void - unsafe_to_break_all (void) - { - unsafe_to_break_impl (0, len); - } - inline void - safe_to_break_all (void) - { - for (unsigned int i = 0; i < len; i++) - info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; - } -}; -DECLARE_NULL_INSTANCE (hb_buffer_t); - - -/* Loop over clusters. Duplicated in foreach_syllable(). */ -#define foreach_cluster(buffer, start, end) \ - for (unsigned int \ - _count = buffer->len, \ - start = 0, end = _count ? _next_cluster (buffer, 0) : 0; \ - start < _count; \ - start = end, end = _next_cluster (buffer, start)) - -static inline unsigned int -_next_cluster (hb_buffer_t *buffer, unsigned int start) -{ - hb_glyph_info_t *info = buffer->info; - unsigned int count = buffer->len; - - unsigned int cluster = info[start].cluster; - while (++start < count && cluster == info[start].cluster) - ; - - return start; -} - - -#define HB_BUFFER_XALLOCATE_VAR(b, func, var) \ - b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ - sizeof (b->info[0].var)) -#define HB_BUFFER_ALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var ()) -#define HB_BUFFER_DEALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var ()) -#define HB_BUFFER_ASSERT_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, assert_var, var ()) - - -#endif /* HB_BUFFER_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc index 11471941de8..1b6d14731fd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-buffer-private.hh" +#include "hb-buffer.hh" static const char *serialize_formats[] = { 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 eb7b01caafa..536ab5d5376 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc @@ -27,8 +27,8 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-buffer-private.hh" -#include "hb-utf-private.hh" +#include "hb-buffer.hh" +#include "hb-utf.hh" /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh new file mode 100644 index 00000000000..bcaf066c70b --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh @@ -0,0 +1,389 @@ +/* + * Copyright © 1998-2004 David Turner and Werner Lemberg + * Copyright © 2004,2007,2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 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): Owen Taylor, Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_BUFFER_HH +#define HB_BUFFER_HH + +#include "hb.hh" +#include "hb-unicode.hh" + + +#ifndef HB_BUFFER_MAX_LEN_FACTOR +#define HB_BUFFER_MAX_LEN_FACTOR 32 +#endif +#ifndef HB_BUFFER_MAX_LEN_MIN +#define HB_BUFFER_MAX_LEN_MIN 8192 +#endif +#ifndef HB_BUFFER_MAX_LEN_DEFAULT +#define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */ +#endif + +#ifndef HB_BUFFER_MAX_OPS_FACTOR +#define HB_BUFFER_MAX_OPS_FACTOR 64 +#endif +#ifndef HB_BUFFER_MAX_OPS_MIN +#define HB_BUFFER_MAX_OPS_MIN 1024 +#endif +#ifndef HB_BUFFER_MAX_OPS_DEFAULT +#define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */ +#endif + +static_assert ((sizeof (hb_glyph_info_t) == 20), ""); +static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)), ""); + +HB_MARK_AS_FLAG_T (hb_buffer_flags_t); +HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t); +HB_MARK_AS_FLAG_T (hb_buffer_diff_flags_t); + +enum hb_buffer_scratch_flags_t { + HB_BUFFER_SCRATCH_FLAG_DEFAULT = 0x00000000u, + HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u, + HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u, + HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, + HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, + HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u, + HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u, + + /* Reserved for complex shapers' internal use. */ + HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, + HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u, + HB_BUFFER_SCRATCH_FLAG_COMPLEX2 = 0x04000000u, + HB_BUFFER_SCRATCH_FLAG_COMPLEX3 = 0x08000000u, +}; +HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t); + + +/* + * hb_buffer_t + */ + +struct hb_buffer_t +{ + hb_object_header_t header; + ASSERT_POD (); + + /* Information about how the text in the buffer should be treated */ + hb_unicode_funcs_t *unicode; /* Unicode functions */ + hb_buffer_flags_t flags; /* BOT / EOT / etc. */ + hb_buffer_cluster_level_t cluster_level; + hb_codepoint_t replacement; /* U+FFFD or something else. */ + hb_buffer_scratch_flags_t scratch_flags; /* Have space-fallback, etc. */ + unsigned int max_len; /* Maximum allowed len. */ + int max_ops; /* Maximum allowed operations. */ + + /* Buffer contents */ + hb_buffer_content_type_t content_type; + hb_segment_properties_t props; /* Script, language, direction */ + + bool successful; /* Allocations successful */ + bool have_output; /* Whether we have an output buffer going on */ + bool have_positions; /* Whether we have positions */ + + unsigned int idx; /* Cursor into ->info and ->pos arrays */ + unsigned int len; /* Length of ->info and ->pos arrays */ + unsigned int out_len; /* Length of ->out array if have_output */ + + unsigned int allocated; /* Length of allocated arrays */ + hb_glyph_info_t *info; + hb_glyph_info_t *out_info; + hb_glyph_position_t *pos; + + unsigned int serial; + + /* Text before / after the main buffer contents. + * Always in Unicode, and ordered outward. + * Index 0 is for "pre-context", 1 for "post-context". */ + enum { CONTEXT_LENGTH = 5 }; + hb_codepoint_t context[2][CONTEXT_LENGTH]; + unsigned int context_len[2]; + + /* Debugging API */ + hb_buffer_message_func_t message_func; + void *message_data; + hb_destroy_func_t message_destroy; + + /* Internal debugging. */ + /* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ +#ifndef HB_NDEBUG + uint8_t allocated_var_bits; +#endif + + + /* Methods */ + + inline void allocate_var (unsigned int start, unsigned int count) + { +#ifndef HB_NDEBUG + unsigned int end = start + count; + assert (end <= 8); + unsigned int bits = (1u< (cluster, infos[i].cluster); + return cluster; + } + inline void + _unsafe_to_break_set_mask (hb_glyph_info_t *infos, + unsigned int start, unsigned int end, + unsigned int cluster) + { + for (unsigned int i = start; i < end; i++) + if (cluster != infos[i].cluster) + { + scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK; + infos[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; + } + } + + inline void + unsafe_to_break_all (void) + { + unsafe_to_break_impl (0, len); + } + inline void + safe_to_break_all (void) + { + for (unsigned int i = 0; i < len; i++) + info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; + } +}; +DECLARE_NULL_INSTANCE (hb_buffer_t); + + +/* Loop over clusters. Duplicated in foreach_syllable(). */ +#define foreach_cluster(buffer, start, end) \ + for (unsigned int \ + _count = buffer->len, \ + start = 0, end = _count ? _next_cluster (buffer, 0) : 0; \ + start < _count; \ + start = end, end = _next_cluster (buffer, start)) + +static inline unsigned int +_next_cluster (hb_buffer_t *buffer, unsigned int start) +{ + hb_glyph_info_t *info = buffer->info; + unsigned int count = buffer->len; + + unsigned int cluster = info[start].cluster; + while (++start < count && cluster == info[start].cluster) + ; + + return start; +} + + +#define HB_BUFFER_XALLOCATE_VAR(b, func, var) \ + b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ + sizeof (b->info[0].var)) +#define HB_BUFFER_ALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var ()) +#define HB_BUFFER_DEALLOCATE_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var ()) +#define HB_BUFFER_ASSERT_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, assert_var, var ()) + + +#endif /* HB_BUFFER_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc index 22dd52f49d8..ed3fed2a35c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc @@ -26,9 +26,9 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" -#include "hb-machinery-private.hh" +#include "hb-machinery.hh" #include #ifdef HAVE_XLOCALE_H @@ -731,8 +731,9 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv) #ifdef USE_XLOCALE - +#ifdef HB_USE_ATEXIT static void free_static_C_locale (void); +#endif static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t::value, hb_C_locale_lazy_loader_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 1b916a53d34..a7ba85f8350 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc @@ -28,8 +28,8 @@ #define HB_SHAPER coretext -#include "hb-private.hh" -#include "hb-shaper-impl-private.hh" +#include "hb.hh" +#include "hb-shaper-impl.hh" #include "hb-coretext.h" #include diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh index 9056ffca2b1..49663d215dc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh @@ -27,8 +27,8 @@ #ifndef HB_DEBUG_HH #define HB_DEBUG_HH -#include "hb-private.hh" -#include "hb-atomic-private.hh" +#include "hb.hh" +#include "hb-atomic.hh" #include "hb-dsalgs.hh" 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 baad81884dc..35197c23865 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc @@ -22,9 +22,9 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -#include "hb-private.hh" +#include "hb.hh" #define HB_SHAPER directwrite -#include "hb-shaper-impl-private.hh" +#include "hb-shaper-impl.hh" #include 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 8cbe6584b29..7e06ff17010 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh @@ -27,7 +27,7 @@ #ifndef HB_DSALGS_HH #define HB_DSALGS_HH -#include "hb-private.hh" +#include "hb.hh" /* Void! For when we need a expression-type of void. */ @@ -492,6 +492,15 @@ template struct hb_auto_t : Type { hb_auto_t (void) { Type::init (); } + /* Explicitly allow the following only for pointer and references, + * to avoid any accidental copies. + * + * Apparently if we template for all types, then gcc seems to + * capture a reference argument in the type, but clang doesn't, + * causing unwanted copies and bugs that come with it. Ideally + * we should use C++11-style rvalue reference &&t1. */ + template explicit hb_auto_t (T1 *t1) { Type::init (t1); } + template explicit hb_auto_t (T1 &t1) { Type::init (t1); } ~hb_auto_t (void) { Type::fini (); } private: /* Hide */ void init (void) {} @@ -502,6 +511,9 @@ struct hb_bytes_t { inline hb_bytes_t (void) : bytes (nullptr), len (0) {} inline hb_bytes_t (const char *bytes_, unsigned int len_) : bytes (bytes_), len (len_) {} + inline hb_bytes_t (const void *bytes_, unsigned int len_) : bytes ((const char *) bytes_), len (len_) {} + + inline void free (void) { ::free ((void *) bytes); bytes = nullptr; len = 0; } inline int cmp (const hb_bytes_t &a) const { 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 deleted file mode 100644 index 086ce6e96d1..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face-private.hh +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2011 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_FACE_PRIVATE_HH -#define HB_FACE_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-shaper-private.hh" -#include "hb-shape-plan-private.hh" - - -/* - * hb_face_t - */ - -struct hb_face_t -{ - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - hb_reference_table_func_t reference_table_func; - void *user_data; - hb_destroy_func_t destroy; - - unsigned int index; /* Face index in a collection, zero-based. */ - mutable unsigned int upem; /* Units-per-EM. */ - mutable unsigned int num_glyphs; /* Number of glyphs. */ - - struct hb_shaper_data_t shaper_data; /* Various shaper data. */ - - /* Cache */ - struct plan_node_t - { - hb_shape_plan_t *shape_plan; - plan_node_t *next; - }; - hb_atomic_ptr_t shape_plans; - - inline hb_blob_t *reference_table (hb_tag_t tag) const - { - hb_blob_t *blob; - - if (unlikely (!reference_table_func)) - return hb_blob_get_empty (); - - blob = reference_table_func (/*XXX*/const_cast (this), tag, user_data); - if (unlikely (!blob)) - return hb_blob_get_empty (); - - return blob; - } - - inline HB_PURE_FUNC unsigned int get_upem (void) const - { - if (unlikely (!upem)) - load_upem (); - return upem; - } - - inline unsigned int get_num_glyphs (void) const - { - if (unlikely (num_glyphs == (unsigned int) -1)) - load_num_glyphs (); - return num_glyphs; - } - - private: - HB_INTERNAL void load_upem (void) const; - HB_INTERNAL void load_num_glyphs (void) const; -}; -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); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT -#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS - - -#endif /* HB_FACE_PRIVATE_HH */ 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 49f29d3fa87..92c34152335 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc @@ -26,11 +26,13 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" -#include "hb-face-private.hh" -#include "hb-blob-private.hh" -#include "hb-open-file-private.hh" +#include "hb-face.hh" +#include "hb-blob.hh" +#include "hb-open-file.hh" +#include "hb-ot-face.hh" +#include "hb-ot-cmap-table.hh" /** @@ -512,3 +514,208 @@ hb_face_get_table_tags (const hb_face_t *face, return ot_face.get_table_tags (start_offset, table_count, table_tags); } + + +/* + * Character set. + */ + + +/** + * hb_face_collect_unicodes: + * @face: font face. + * @out: set to add Unicode characters covered by @face to. + * + * Since: 1.9.0 + */ +void +hb_face_collect_unicodes (hb_face_t *face, + hb_set_t *out) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return; + hb_ot_face_data (face)->cmap->collect_unicodes (out); +} + +/** + * hb_face_collect_variation_selectors: + * @face: font face. + * @out: set to add Variation Selector characters covered by @face to. + * + * + * + * Since: 1.9.0 + */ +void +hb_face_collect_variation_selectors (hb_face_t *face, + hb_set_t *out) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return; + hb_ot_face_data (face)->cmap->collect_variation_selectors (out); +} + +/** + * hb_face_collect_variation_unicodes: + * @face: font face. + * @out: set to add Unicode characters for @variation_selector covered by @face to. + * + * + * + * Since: 1.9.0 + */ +void +hb_face_collect_variation_unicodes (hb_face_t *face, + hb_codepoint_t variation_selector, + hb_set_t *out) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return; + hb_ot_face_data (face)->cmap->collect_variation_unicodes (variation_selector, out); +} + + + +/* + * face-builder: A face that has add_table(). + */ + +struct hb_face_builder_data_t +{ + struct table_entry_t + { + inline int cmp (const hb_tag_t *t) const + { + if (*t < tag) return -1; + if (*t > tag) return -1; + return 0; + } + + hb_tag_t tag; + hb_blob_t *blob; + }; + + hb_vector_t tables; +}; + +static hb_face_builder_data_t * +_hb_face_builder_data_create (void) +{ + hb_face_builder_data_t *data = (hb_face_builder_data_t *) calloc (1, sizeof (hb_face_builder_data_t)); + if (unlikely (!data)) + return nullptr; + + data->tables.init (); + + return data; +} + +static void +_hb_face_builder_data_destroy (void *user_data) +{ + hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data; + + for (unsigned int i = 0; i < data->tables.len; i++) + hb_blob_destroy (data->tables[i].blob); + + data->tables.fini (); + + free (data); +} + +static hb_blob_t * +_hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) +{ + + unsigned int table_count = data->tables.len; + unsigned int face_length = table_count * 16 + 12; + + for (unsigned int i = 0; i < table_count; i++) + face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob)); + + char *buf = (char *) malloc (face_length); + if (unlikely (!buf)) + return nullptr; + + hb_serialize_context_t c (buf, face_length); + OT::OpenTypeFontFile *f = c.start_serialize (); + + 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; + + Supplier tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); + Supplier blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); + bool ret = f->serialize_single (&c, + sfnt_tag, + tags_supplier, + blobs_supplier, + table_count); + + c.end_serialize (); + + if (unlikely (!ret)) + { + free (buf); + return nullptr; + } + + return hb_blob_create (buf, face_length, HB_MEMORY_MODE_WRITABLE, buf, free); +} + +static hb_blob_t * +_hb_face_builder_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data) +{ + hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data; + + if (!tag) + return _hb_face_builder_data_reference_blob (data); + + hb_face_builder_data_t::table_entry_t *entry = data->tables.lsearch (tag); + if (entry) + return hb_blob_reference (entry->blob); + + return nullptr; +} + + +/** + * hb_face_builder_create: + * + * Creates a #hb_face_t that can be used with hb_face_builder_add_table(). + * After tables are added to the face, it can be compiled to a binary + * font file by calling hb_face_reference_blob(). + * + * Return value: (transfer full) New face. + * + * Since: 1.9.0 + **/ +hb_face_t * +hb_face_builder_create (void) +{ + hb_face_builder_data_t *data = _hb_face_builder_data_create (); + if (unlikely (!data)) return hb_face_get_empty (); + + return hb_face_create_for_tables (_hb_face_builder_reference_table, + data, + _hb_face_builder_data_destroy); +} + +/** + * hb_face_builder_add_table: + * + * Add table for @tag with data provided by @blob to the face. @face must + * be created using hb_face_builder_create(). + * + * Since: 1.9.0 + **/ +hb_bool_t +hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob) +{ + if (unlikely (face->destroy != (hb_destroy_func_t) _hb_face_builder_data_destroy)) + return false; + + hb_face_builder_data_t *data = (hb_face_builder_data_t *) face->user_data; + hb_face_builder_data_t::table_entry_t *entry = data->tables.push (); + + entry->tag = tag; + entry->blob = hb_blob_reference (blob); + + return true; +} 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 208092efc28..e8ff090d55f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.h @@ -33,6 +33,7 @@ #include "hb-common.h" #include "hb-blob.h" +#include "hb-set.h" HB_BEGIN_DECLS @@ -120,6 +121,38 @@ hb_face_get_table_tags (const hb_face_t *face, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */); + +/* + * Character set. + */ + +HB_EXTERN void +hb_face_collect_unicodes (hb_face_t *face, + hb_set_t *out); + +HB_EXTERN void +hb_face_collect_variation_selectors (hb_face_t *face, + hb_set_t *out); + +HB_EXTERN void +hb_face_collect_variation_unicodes (hb_face_t *face, + hb_codepoint_t variation_selector, + hb_set_t *out); + + +/* + * Builder face. + */ + +HB_EXTERN hb_face_t * +hb_face_builder_create (void); + +HB_EXTERN hb_bool_t +hb_face_builder_add_table (hb_face_t *face, + hb_tag_t tag, + hb_blob_t *blob); + + HB_END_DECLS #endif /* HB_FACE_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh new file mode 100644 index 00000000000..f90453dbd1f --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh @@ -0,0 +1,108 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 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_FACE_HH +#define HB_FACE_HH + +#include "hb.hh" + +#include "hb-shaper.hh" +#include "hb-shape-plan.hh" + + +/* + * hb_face_t + */ + +struct hb_face_t +{ + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + hb_reference_table_func_t reference_table_func; + void *user_data; + hb_destroy_func_t destroy; + + unsigned int index; /* Face index in a collection, zero-based. */ + mutable unsigned int upem; /* Units-per-EM. */ + mutable unsigned int num_glyphs; /* Number of glyphs. */ + + struct hb_shaper_data_t shaper_data; /* Various shaper data. */ + + /* Cache */ + struct plan_node_t + { + hb_shape_plan_t *shape_plan; + plan_node_t *next; + }; + hb_atomic_ptr_t shape_plans; + + inline hb_blob_t *reference_table (hb_tag_t tag) const + { + hb_blob_t *blob; + + if (unlikely (!reference_table_func)) + return hb_blob_get_empty (); + + blob = reference_table_func (/*XXX*/const_cast (this), tag, user_data); + if (unlikely (!blob)) + return hb_blob_get_empty (); + + return blob; + } + + inline HB_PURE_FUNC unsigned int get_upem (void) const + { + if (unlikely (!upem)) + load_upem (); + return upem; + } + + inline unsigned int get_num_glyphs (void) const + { + if (unlikely (num_glyphs == (unsigned int) -1)) + load_num_glyphs (); + return num_glyphs; + } + + private: + HB_INTERNAL void load_upem (void) const; + HB_INTERNAL void load_num_glyphs (void) const; +}; +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); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT +#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS + + +#endif /* HB_FACE_HH */ 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 eff20f70c77..dc8536c8281 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 @@ -25,7 +25,7 @@ */ #define HB_SHAPER fallback -#include "hb-shaper-impl-private.hh" +#include "hb-shaper-impl.hh" HB_SHAPER_DATA_ENSURE_DEFINE(fallback, face) 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 deleted file mode 100644 index d3a41380258..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2011 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_FONT_PRIVATE_HH -#define HB_FONT_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-face-private.hh" -#include "hb-shaper-private.hh" - - -/* - * hb_font_funcs_t - */ - -#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ - HB_FONT_FUNC_IMPLEMENT (font_h_extents) \ - HB_FONT_FUNC_IMPLEMENT (font_v_extents) \ - HB_FONT_FUNC_IMPLEMENT (nominal_glyph) \ - 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) \ - HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ - HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ - HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ - HB_FONT_FUNC_IMPLEMENT (glyph_name) \ - HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ - /* ^--- Add new callbacks here */ - -struct hb_font_funcs_t -{ - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - struct { -#define HB_FONT_FUNC_IMPLEMENT(name) void *name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } user_data; - - struct { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } destroy; - - /* Don't access these directly. Call font->get_*() instead. */ - union get_t { - struct get_funcs_t { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } f; - void (*array[0 -#define HB_FONT_FUNC_IMPLEMENT(name) +1 - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - ]) (void); - } get; -}; -DECLARE_NULL_INSTANCE (hb_font_funcs_t); - - -/* - * hb_font_t - */ - -struct hb_font_t -{ - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - hb_font_t *parent; - hb_face_t *face; - - int x_scale; - int y_scale; - - unsigned int x_ppem; - unsigned int y_ppem; - - float ptem; - - /* Font variation coordinates. */ - unsigned int num_coords; - int *coords; - - hb_font_funcs_t *klass; - void *user_data; - hb_destroy_func_t destroy; - - struct hb_shaper_data_t shaper_data; - - - /* Convert from font-space to user-space */ - inline int dir_scale (hb_direction_t direction) - { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; } - inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); } - inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); } - inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); } - inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); } - inline float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); } - inline float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); } - inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction) - { return em_scale (v, dir_scale (direction)); } - - /* Convert from parent-font user-space to our user-space */ - inline hb_position_t parent_scale_x_distance (hb_position_t v) { - if (unlikely (parent && parent->x_scale != x_scale)) - return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale); - return v; - } - inline hb_position_t parent_scale_y_distance (hb_position_t v) { - if (unlikely (parent && parent->y_scale != y_scale)) - return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale); - return v; - } - inline hb_position_t parent_scale_x_position (hb_position_t v) { - return parent_scale_x_distance (v); - } - inline hb_position_t parent_scale_y_position (hb_position_t v) { - return parent_scale_y_distance (v); - } - - inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { - *x = parent_scale_x_distance (*x); - *y = parent_scale_y_distance (*y); - } - inline void parent_scale_position (hb_position_t *x, hb_position_t *y) { - *x = parent_scale_x_position (*x); - *y = parent_scale_y_position (*y); - } - - - /* Public getters */ - - HB_INTERNAL bool has_func (unsigned int i); - - /* has_* ... */ -#define HB_FONT_FUNC_IMPLEMENT(name) \ - bool \ - has_##name##_func (void) \ - { \ - hb_font_funcs_t *funcs = this->klass; \ - unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \ - return has_func (i); \ - } - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - - inline hb_bool_t get_font_h_extents (hb_font_extents_t *extents) - { - memset (extents, 0, sizeof (*extents)); - return klass->get.f.font_h_extents (this, user_data, - extents, - klass->user_data.font_h_extents); - } - inline hb_bool_t get_font_v_extents (hb_font_extents_t *extents) - { - memset (extents, 0, sizeof (*extents)); - return klass->get.f.font_v_extents (this, user_data, - extents, - klass->user_data.font_v_extents); - } - - inline bool has_glyph (hb_codepoint_t unicode) - { - hb_codepoint_t glyph; - return get_nominal_glyph (unicode, &glyph); - } - - inline hb_bool_t get_nominal_glyph (hb_codepoint_t unicode, - hb_codepoint_t *glyph) - { - *glyph = 0; - return klass->get.f.nominal_glyph (this, user_data, - unicode, glyph, - klass->user_data.nominal_glyph); - } - - inline hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) - { - *glyph = 0; - return klass->get.f.variation_glyph (this, user_data, - unicode, variation_selector, glyph, - klass->user_data.variation_glyph); - } - - inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) - { - return klass->get.f.glyph_h_advance (this, user_data, - glyph, - klass->user_data.glyph_h_advance); - } - - inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) - { - return klass->get.f.glyph_v_advance (this, user_data, - glyph, - 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) - { - *x = *y = 0; - return klass->get.f.glyph_h_origin (this, user_data, - glyph, x, y, - klass->user_data.glyph_h_origin); - } - - inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - return klass->get.f.glyph_v_origin (this, user_data, - glyph, x, y, - klass->user_data.glyph_v_origin); - } - - inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) - { - return klass->get.f.glyph_h_kerning (this, user_data, - left_glyph, right_glyph, - klass->user_data.glyph_h_kerning); - } - - inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph) - { - return klass->get.f.glyph_v_kerning (this, user_data, - top_glyph, bottom_glyph, - klass->user_data.glyph_v_kerning); - } - - inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph, - hb_glyph_extents_t *extents) - { - memset (extents, 0, sizeof (*extents)); - return klass->get.f.glyph_extents (this, user_data, - glyph, - extents, - klass->user_data.glyph_extents); - } - - inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - return klass->get.f.glyph_contour_point (this, user_data, - glyph, point_index, - x, y, - klass->user_data.glyph_contour_point); - } - - inline hb_bool_t get_glyph_name (hb_codepoint_t glyph, - char *name, unsigned int size) - { - if (size) *name = '\0'; - return klass->get.f.glyph_name (this, user_data, - glyph, - name, size, - klass->user_data.glyph_name); - } - - inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) - { - *glyph = 0; - if (len == -1) len = strlen (name); - return klass->get.f.glyph_from_name (this, user_data, - name, len, - glyph, - klass->user_data.glyph_from_name); - } - - - /* A bit higher-level, and with fallback */ - - inline void get_h_extents_with_fallback (hb_font_extents_t *extents) - { - if (!get_font_h_extents (extents)) - { - extents->ascender = y_scale * .8; - extents->descender = extents->ascender - y_scale; - extents->line_gap = 0; - } - } - inline void get_v_extents_with_fallback (hb_font_extents_t *extents) - { - if (!get_font_v_extents (extents)) - { - extents->ascender = x_scale / 2; - extents->descender = extents->ascender - x_scale; - extents->line_gap = 0; - } - } - - inline void get_extents_for_direction (hb_direction_t direction, - hb_font_extents_t *extents) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - get_h_extents_with_fallback (extents); - else - get_v_extents_with_fallback (extents); - } - - inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - *x = get_glyph_h_advance (glyph); - 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, - hb_position_t *x, hb_position_t *y) - { - *x = get_glyph_h_advance (glyph) / 2; - - /* TODO cache this somehow?! */ - hb_font_extents_t extents; - get_h_extents_with_fallback (&extents); - *y = extents.ascender; - } - - inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - if (!get_glyph_h_origin (glyph, x, y) && - get_glyph_v_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x -= dx; *y -= dy; - } - } - inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - if (!get_glyph_v_origin (glyph, x, y) && - get_glyph_h_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x += dx; *y += dy; - } - } - - inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - get_glyph_h_origin_with_fallback (glyph, x, y); - else - get_glyph_v_origin_with_fallback (glyph, x, y); - } - - inline void add_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - inline void add_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - inline void add_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - - inline void subtract_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - inline void subtract_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - - inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { - *x = get_glyph_h_kerning (first_glyph, second_glyph); - *y = 0; - } else { - *x = 0; - *y = get_glyph_v_kerning (first_glyph, second_glyph); - } - } - - inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, - hb_direction_t direction, - hb_glyph_extents_t *extents) - { - hb_bool_t ret = get_glyph_extents (glyph, extents); - - if (ret) - subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing); - - return ret; - } - - inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y); - - if (ret) - subtract_glyph_origin_for_direction (glyph, direction, x, y); - - return ret; - } - - /* Generates gidDDD if glyph has no name. */ - inline void - glyph_to_string (hb_codepoint_t glyph, - char *s, unsigned int size) - { - if (get_glyph_name (glyph, s, size)) return; - - if (size && snprintf (s, size, "gid%u", glyph) < 0) - *s = '\0'; - } - - /* Parses gidDDD and uniUUUU strings automatically. */ - inline hb_bool_t - glyph_from_string (const char *s, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) - { - if (get_glyph_from_name (s, len, glyph)) return true; - - if (len == -1) len = strlen (s); - - /* Straight glyph index. */ - if (hb_codepoint_parse (s, len, 10, glyph)) - return true; - - if (len > 3) - { - /* gidDDD syntax for glyph indices. */ - if (0 == strncmp (s, "gid", 3) && - hb_codepoint_parse (s + 3, len - 3, 10, glyph)) - return true; - - /* uniUUUU and other Unicode character indices. */ - hb_codepoint_t unichar; - if (0 == strncmp (s, "uni", 3) && - hb_codepoint_parse (s + 3, len - 3, 16, &unichar) && - get_nominal_glyph (unichar, glyph)) - return true; - } - - return false; - } - - inline hb_position_t em_scale (int16_t v, int scale) - { - int upem = face->get_upem (); - int64_t scaled = v * (int64_t) scale; - scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */ - return (hb_position_t) (scaled / upem); - } - inline hb_position_t em_scalef (float v, int scale) - { - return (hb_position_t) round (v * scale / face->get_upem ()); - } - inline float em_fscale (int16_t v, int scale) - { - 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); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT -#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS - - -#endif /* HB_FONT_PRIVATE_HH */ 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 857b8f57734..bc831dd53f2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -26,10 +26,10 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" -#include "hb-font-private.hh" -#include "hb-machinery-private.hh" +#include "hb-font.hh" +#include "hb-machinery.hh" /* diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh new file mode 100644 index 00000000000..4c8d0aeec03 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh @@ -0,0 +1,604 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 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_FONT_HH +#define HB_FONT_HH + +#include "hb.hh" + +#include "hb-face.hh" +#include "hb-shaper.hh" + + +/* + * hb_font_funcs_t + */ + +#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ + HB_FONT_FUNC_IMPLEMENT (font_h_extents) \ + HB_FONT_FUNC_IMPLEMENT (font_v_extents) \ + HB_FONT_FUNC_IMPLEMENT (nominal_glyph) \ + 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) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ + HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ + HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ + HB_FONT_FUNC_IMPLEMENT (glyph_name) \ + HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ + /* ^--- Add new callbacks here */ + +struct hb_font_funcs_t +{ + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + struct { +#define HB_FONT_FUNC_IMPLEMENT(name) void *name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } user_data; + + struct { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } destroy; + + /* Don't access these directly. Call font->get_*() instead. */ + union get_t { + struct get_funcs_t { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } f; + void (*array[0 +#define HB_FONT_FUNC_IMPLEMENT(name) +1 + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + ]) (void); + } get; +}; +DECLARE_NULL_INSTANCE (hb_font_funcs_t); + + +/* + * hb_font_t + */ + +struct hb_font_t +{ + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + hb_font_t *parent; + hb_face_t *face; + + int x_scale; + int y_scale; + + unsigned int x_ppem; + unsigned int y_ppem; + + float ptem; + + /* Font variation coordinates. */ + unsigned int num_coords; + int *coords; + + hb_font_funcs_t *klass; + void *user_data; + hb_destroy_func_t destroy; + + struct hb_shaper_data_t shaper_data; + + + /* Convert from font-space to user-space */ + inline int dir_scale (hb_direction_t direction) + { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; } + inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); } + inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); } + inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); } + inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); } + inline float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); } + inline float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); } + inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction) + { return em_scale (v, dir_scale (direction)); } + + /* Convert from parent-font user-space to our user-space */ + inline hb_position_t parent_scale_x_distance (hb_position_t v) { + if (unlikely (parent && parent->x_scale != x_scale)) + return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale); + return v; + } + inline hb_position_t parent_scale_y_distance (hb_position_t v) { + if (unlikely (parent && parent->y_scale != y_scale)) + return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale); + return v; + } + inline hb_position_t parent_scale_x_position (hb_position_t v) { + return parent_scale_x_distance (v); + } + inline hb_position_t parent_scale_y_position (hb_position_t v) { + return parent_scale_y_distance (v); + } + + inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { + *x = parent_scale_x_distance (*x); + *y = parent_scale_y_distance (*y); + } + inline void parent_scale_position (hb_position_t *x, hb_position_t *y) { + *x = parent_scale_x_position (*x); + *y = parent_scale_y_position (*y); + } + + + /* Public getters */ + + HB_INTERNAL bool has_func (unsigned int i); + + /* has_* ... */ +#define HB_FONT_FUNC_IMPLEMENT(name) \ + bool \ + has_##name##_func (void) \ + { \ + hb_font_funcs_t *funcs = this->klass; \ + unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \ + return has_func (i); \ + } + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + + inline hb_bool_t get_font_h_extents (hb_font_extents_t *extents) + { + memset (extents, 0, sizeof (*extents)); + return klass->get.f.font_h_extents (this, user_data, + extents, + klass->user_data.font_h_extents); + } + inline hb_bool_t get_font_v_extents (hb_font_extents_t *extents) + { + memset (extents, 0, sizeof (*extents)); + return klass->get.f.font_v_extents (this, user_data, + extents, + klass->user_data.font_v_extents); + } + + inline bool has_glyph (hb_codepoint_t unicode) + { + hb_codepoint_t glyph; + return get_nominal_glyph (unicode, &glyph); + } + + inline hb_bool_t get_nominal_glyph (hb_codepoint_t unicode, + hb_codepoint_t *glyph) + { + *glyph = 0; + return klass->get.f.nominal_glyph (this, user_data, + unicode, glyph, + klass->user_data.nominal_glyph); + } + + inline hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) + { + *glyph = 0; + return klass->get.f.variation_glyph (this, user_data, + unicode, variation_selector, glyph, + klass->user_data.variation_glyph); + } + + inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) + { + return klass->get.f.glyph_h_advance (this, user_data, + glyph, + klass->user_data.glyph_h_advance); + } + + inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) + { + return klass->get.f.glyph_v_advance (this, user_data, + glyph, + 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) + { + *x = *y = 0; + return klass->get.f.glyph_h_origin (this, user_data, + glyph, x, y, + klass->user_data.glyph_h_origin); + } + + inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + return klass->get.f.glyph_v_origin (this, user_data, + glyph, x, y, + klass->user_data.glyph_v_origin); + } + + inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) + { + return klass->get.f.glyph_h_kerning (this, user_data, + left_glyph, right_glyph, + klass->user_data.glyph_h_kerning); + } + + inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph) + { + return klass->get.f.glyph_v_kerning (this, user_data, + top_glyph, bottom_glyph, + klass->user_data.glyph_v_kerning); + } + + inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph, + hb_glyph_extents_t *extents) + { + memset (extents, 0, sizeof (*extents)); + return klass->get.f.glyph_extents (this, user_data, + glyph, + extents, + klass->user_data.glyph_extents); + } + + inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + return klass->get.f.glyph_contour_point (this, user_data, + glyph, point_index, + x, y, + klass->user_data.glyph_contour_point); + } + + inline hb_bool_t get_glyph_name (hb_codepoint_t glyph, + char *name, unsigned int size) + { + if (size) *name = '\0'; + return klass->get.f.glyph_name (this, user_data, + glyph, + name, size, + klass->user_data.glyph_name); + } + + inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) + { + *glyph = 0; + if (len == -1) len = strlen (name); + return klass->get.f.glyph_from_name (this, user_data, + name, len, + glyph, + klass->user_data.glyph_from_name); + } + + + /* A bit higher-level, and with fallback */ + + inline void get_h_extents_with_fallback (hb_font_extents_t *extents) + { + if (!get_font_h_extents (extents)) + { + extents->ascender = y_scale * .8; + extents->descender = extents->ascender - y_scale; + extents->line_gap = 0; + } + } + inline void get_v_extents_with_fallback (hb_font_extents_t *extents) + { + if (!get_font_v_extents (extents)) + { + extents->ascender = x_scale / 2; + extents->descender = extents->ascender - x_scale; + extents->line_gap = 0; + } + } + + inline void get_extents_for_direction (hb_direction_t direction, + hb_font_extents_t *extents) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + get_h_extents_with_fallback (extents); + else + get_v_extents_with_fallback (extents); + } + + inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + *x = get_glyph_h_advance (glyph); + 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, + hb_position_t *x, hb_position_t *y) + { + *x = get_glyph_h_advance (glyph) / 2; + + /* TODO cache this somehow?! */ + hb_font_extents_t extents; + get_h_extents_with_fallback (&extents); + *y = extents.ascender; + } + + inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + if (!get_glyph_h_origin (glyph, x, y) && + get_glyph_v_origin (glyph, x, y)) + { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x -= dx; *y -= dy; + } + } + inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + if (!get_glyph_v_origin (glyph, x, y) && + get_glyph_h_origin (glyph, x, y)) + { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x += dx; *y += dy; + } + } + + inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + get_glyph_h_origin_with_fallback (glyph, x, y); + else + get_glyph_v_origin_with_fallback (glyph, x, y); + } + + inline void add_glyph_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); + + *x += origin_x; + *y += origin_y; + } + inline void add_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); + + *x += origin_x; + *y += origin_y; + } + inline void add_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); + + *x += origin_x; + *y += origin_y; + } + + inline void subtract_glyph_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); + + *x -= origin_x; + *y -= origin_y; + } + inline void subtract_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); + + *x -= origin_x; + *y -= origin_y; + } + inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); + + *x -= origin_x; + *y -= origin_y; + } + + inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + *x = get_glyph_h_kerning (first_glyph, second_glyph); + *y = 0; + } else { + *x = 0; + *y = get_glyph_v_kerning (first_glyph, second_glyph); + } + } + + inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, + hb_direction_t direction, + hb_glyph_extents_t *extents) + { + hb_bool_t ret = get_glyph_extents (glyph, extents); + + if (ret) + subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing); + + return ret; + } + + inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y); + + if (ret) + subtract_glyph_origin_for_direction (glyph, direction, x, y); + + return ret; + } + + /* Generates gidDDD if glyph has no name. */ + inline void + glyph_to_string (hb_codepoint_t glyph, + char *s, unsigned int size) + { + if (get_glyph_name (glyph, s, size)) return; + + if (size && snprintf (s, size, "gid%u", glyph) < 0) + *s = '\0'; + } + + /* Parses gidDDD and uniUUUU strings automatically. */ + inline hb_bool_t + glyph_from_string (const char *s, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) + { + if (get_glyph_from_name (s, len, glyph)) return true; + + if (len == -1) len = strlen (s); + + /* Straight glyph index. */ + if (hb_codepoint_parse (s, len, 10, glyph)) + return true; + + if (len > 3) + { + /* gidDDD syntax for glyph indices. */ + if (0 == strncmp (s, "gid", 3) && + hb_codepoint_parse (s + 3, len - 3, 10, glyph)) + return true; + + /* uniUUUU and other Unicode character indices. */ + hb_codepoint_t unichar; + if (0 == strncmp (s, "uni", 3) && + hb_codepoint_parse (s + 3, len - 3, 16, &unichar) && + get_nominal_glyph (unichar, glyph)) + return true; + } + + return false; + } + + inline hb_position_t em_scale (int16_t v, int scale) + { + int upem = face->get_upem (); + int64_t scaled = v * (int64_t) scale; + scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */ + return (hb_position_t) (scaled / upem); + } + inline hb_position_t em_scalef (float v, int scale) + { + return (hb_position_t) round (v * scale / face->get_upem ()); + } + inline float em_fscale (int16_t v, int scale) + { + 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); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT +#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS + + +#endif /* HB_FONT_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc index 01341b604a1..5d6abb29d16 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -27,12 +27,12 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" #include "hb-ft.h" -#include "hb-font-private.hh" -#include "hb-machinery-private.hh" +#include "hb-font.hh" +#include "hb-machinery.hh" #include FT_ADVANCES_H #include FT_MULTIPLE_MASTERS_H @@ -417,7 +417,9 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED, return true; } +#ifdef HB_USE_ATEXIT static void free_static_ft_funcs (void); +#endif static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t { @@ -682,8 +684,9 @@ hb_ft_font_create_referenced (FT_Face ft_face) return hb_ft_font_create (ft_face, _hb_ft_face_destroy); } - +#ifdef HB_USE_ATEXIT static void free_static_ft_library (void); +#endif static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t::value, hb_ft_library_lazy_loader_t> diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc index 809b22f6b46..18f3a81db64 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc @@ -26,12 +26,12 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" #include "hb-glib.h" -#include "hb-unicode-private.hh" -#include "hb-machinery-private.hh" +#include "hb-unicode.hh" +#include "hb-machinery.hh" #if !GLIB_CHECK_VERSION(2,29,14) @@ -366,8 +366,9 @@ hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, } - +#ifdef HB_USE_ATEXIT static void free_static_glib_funcs (void); +#endif static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl index ca458a3846c..e056df47891 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl @@ -25,7 +25,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" /* g++ didn't like older gtype.h gcc-only code path. */ #include diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc index 0c8e55733eb..1b87585832e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" /* g++ didn't like older gtype.h gcc-only code path. */ #include 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 1f42a36f35a..817278f309b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-graphite2.cc @@ -27,7 +27,7 @@ */ #define HB_SHAPER graphite2 -#include "hb-shaper-impl-private.hh" +#include "hb-shaper-impl.hh" #include "hb-graphite2.h" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc index 2e3ad367544..564f71fe2dc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc @@ -27,12 +27,12 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" #include "hb-icu.h" -#include "hb-unicode-private.hh" -#include "hb-machinery-private.hh" +#include "hb-unicode.hh" +#include "hb-machinery.hh" #include #include @@ -343,8 +343,9 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, return utf32_len; } - +#ifdef HB_USE_ATEXIT static void free_static_icu_funcs (void); +#endif static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t { 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 deleted file mode 100644 index 314133ade70..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter-private.hh +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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_ITER_PRIVATE_HH -#define HB_ITER_PRIVATE_HH - -#include "hb-private.hh" - - -/* Unified iterator object. - * - * The goal of this template is to make the same iterator interface - * available to all types, and make it very easy and compact to use. - * Iterator objects are small, light-weight, objects that can be - * copied by value. If the collection / object being iterated on - * is writable, then the iterator points to lvalues, otherwise it - * returns rvalues. - * - * The way to declare, initialize, and use iterators, eg.: - * - * Iter s (src); - * Iter t (dst); - * for (; s && t; s++, t++) - * *s = *t; - */ - -template -struct Iter; - -#if 0 -template -struct Iter -{ - explicit inline Iter (const T &c); -}; -#endif - -template -struct Iter -{ - /* Type of items. */ - typedef T Value; - - /* Constructors. */ - inline Iter (T *array_, int length_) : - array (array_), length (MAX (length_, 0)) {} - template - explicit inline Iter (T (&array_)[length_]) : - array (array_), length (length_) {} - - /* Emptiness. */ - explicit_operator inline operator bool (void) const { return bool (length); } - - /* Current item. */ - inline T &operator * (void) - { - if (unlikely (!length)) return CrapOrNull(T); - return *array; - } - inline T &operator -> (void) - { - return (operator *); - } - - /* Next. */ - inline Iter & operator ++ (void) - { - if (unlikely (!length)) return *this; - array++; - length--; - return *this; - } - /* Might return void, or a copy of pre-increment iterator. */ - inline void operator ++ (int) - { - if (unlikely (!length)) return; - array++; - length--; - } - - /* Some iterators might implement len(). */ - inline unsigned int len (void) const { return length; } - - /* Some iterators might implement fast-forward. - * Only implement it if it's constant-time. */ - inline void operator += (unsigned int n) - { - n = MIN (n, length); - array += n; - length -= n; - } - - /* Some iterators might implement random-access. - * Only implement it if it's constant-time. */ - inline Iter & operator [] (unsigned int i) - { - if (unlikely (i >= length)) return CrapOrNull(T); - return array[i]; - } - - private: - T *array; - unsigned int length; -}; - -/* XXX Remove - * Just to test these compile. */ -static inline void -m (void) -{ - const int src[10] = {}; - int dst[20]; - - Iter s (src); - Iter s2 (src, 5); - Iter t (dst); - - s2 = s; - - for (; s && t; ++s, ++t) - { - *t = *s; - } -} - -#endif /* HB_ITER_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh new file mode 100644 index 00000000000..6fd6aed79a7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh @@ -0,0 +1,149 @@ +/* + * 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_ITER_HH +#define HB_ITER_HH + +#include "hb.hh" + + +/* Unified iterator object. + * + * The goal of this template is to make the same iterator interface + * available to all types, and make it very easy and compact to use. + * Iterator objects are small, light-weight, objects that can be + * copied by value. If the collection / object being iterated on + * is writable, then the iterator points to lvalues, otherwise it + * returns rvalues. + * + * The way to declare, initialize, and use iterators, eg.: + * + * Iter s (src); + * Iter t (dst); + * for (; s && t; s++, t++) + * *s = *t; + */ + +template +struct Iter; + +#if 0 +template +struct Iter +{ + explicit inline Iter (const T &c); +}; +#endif + +template +struct Iter +{ + /* Type of items. */ + typedef T Value; + + /* Constructors. */ + inline Iter (T *array_, int length_) : + array (array_), length (MAX (length_, 0)) {} + template + explicit inline Iter (T (&array_)[length_]) : + array (array_), length (length_) {} + + /* Emptiness. */ + explicit_operator inline operator bool (void) const { return bool (length); } + + /* Current item. */ + inline T &operator * (void) + { + if (unlikely (!length)) return CrapOrNull(T); + return *array; + } + inline T &operator -> (void) + { + return (operator *); + } + + /* Next. */ + inline Iter & operator ++ (void) + { + if (unlikely (!length)) return *this; + array++; + length--; + return *this; + } + /* Might return void, or a copy of pre-increment iterator. */ + inline void operator ++ (int) + { + if (unlikely (!length)) return; + array++; + length--; + } + + /* Some iterators might implement len(). */ + inline unsigned int len (void) const { return length; } + + /* Some iterators might implement fast-forward. + * Only implement it if it's constant-time. */ + inline void operator += (unsigned int n) + { + n = MIN (n, length); + array += n; + length -= n; + } + + /* Some iterators might implement random-access. + * Only implement it if it's constant-time. */ + inline Iter & operator [] (unsigned int i) + { + if (unlikely (i >= length)) return CrapOrNull(T); + return array[i]; + } + + private: + T *array; + unsigned int length; +}; + +/* XXX Remove + * Just to test these compile. */ +static inline void +m (void) +{ + const int src[10] = {}; + int dst[20]; + + Iter s (src); + Iter s2 (src, 5); + Iter t (dst); + + s2 = s; + + for (; s && t; ++s, ++t) + { + *t = *s; + } +} + +#endif /* HB_ITER_HH */ 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 deleted file mode 100644 index 99ef485a307..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery-private.hh +++ /dev/null @@ -1,792 +0,0 @@ -/* - * Copyright © 2007,2008,2009,2010 Red Hat, Inc. - * Copyright © 2012,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_MACHINERY_PRIVATE_HH -#define HB_MACHINERY_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-blob-private.hh" - -#include "hb-iter-private.hh" - - -/* - * Casts - */ - -/* Cast to struct T, reference to reference */ -template -static inline const Type& CastR(const TObject &X) -{ return reinterpret_cast (X); } -template -static inline Type& CastR(TObject &X) -{ return reinterpret_cast (X); } - -/* Cast to struct T, pointer to pointer */ -template -static inline const Type* CastP(const TObject *X) -{ return reinterpret_cast (X); } -template -static inline Type* CastP(TObject *X) -{ return reinterpret_cast (X); } - -/* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory - * location pointed to by P plus Ofs bytes. */ -template -static inline const Type& StructAtOffset(const void *P, unsigned int offset) -{ return * reinterpret_cast ((const char *) P + offset); } -template -static inline Type& StructAtOffset(void *P, unsigned int offset) -{ return * reinterpret_cast ((char *) P + offset); } - -/* StructAfter(X) returns the struct T& that is placed after X. - * Works with X of variable size also. X must implement get_size() */ -template -static inline const Type& StructAfter(const TObject &X) -{ return StructAtOffset(&X, X.get_size()); } -template -static inline Type& StructAfter(TObject &X) -{ return StructAtOffset(&X, X.get_size()); } - - -/* - * Size checking - */ - -/* Check _assertion in a method environment */ -#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \ - inline void _instance_assertion_on_line_##_line (void) const \ - { \ - static_assert ((_assertion), ""); \ - ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \ - } -# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) -# define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion) - -/* Check that _code compiles in a method environment */ -#define _DEFINE_COMPILES_ASSERTION1(_line, _code) \ - inline void _compiles_assertion_on_line_##_line (void) const \ - { _code; } -# define _DEFINE_COMPILES_ASSERTION0(_line, _code) _DEFINE_COMPILES_ASSERTION1 (_line, _code) -# define DEFINE_COMPILES_ASSERTION(_code) _DEFINE_COMPILES_ASSERTION0 (__LINE__, _code) - - -#define DEFINE_SIZE_STATIC(size) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \ - static const unsigned int static_size = (size); \ - static const unsigned int min_size = (size); \ - inline unsigned int get_size (void) const { return (size); } - -#define DEFINE_SIZE_UNION(size, _member) \ - DEFINE_INSTANCE_ASSERTION (0*sizeof(this->u._member.static_size) + sizeof(this->u._member) == (size)); \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_MIN(size) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)); \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_ARRAY(size, array) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (array[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_ARRAY2(size, array1, array2) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (this->array1[0]) + sizeof (this->array2[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array1[0].static_size; (void) array2[0].static_size) \ - static const unsigned int min_size = (size) - - -/* - * Dispatch - */ - -template -struct hb_dispatch_context_t -{ - static const unsigned int max_debug_depth = MaxDebugDepth; - typedef Return return_t; - template - inline bool may_dispatch (const T *obj, const F *format) { return true; } - static return_t no_dispatch_return_value (void) { return Context::default_return_value (); } -}; - - -/* - * Sanitize - */ - -/* This limits sanitizing time on really broken fonts. */ -#ifndef HB_SANITIZE_MAX_EDITS -#define HB_SANITIZE_MAX_EDITS 32 -#endif -#ifndef HB_SANITIZE_MAX_OPS_FACTOR -#define HB_SANITIZE_MAX_OPS_FACTOR 8 -#endif -#ifndef HB_SANITIZE_MAX_OPS_MIN -#define HB_SANITIZE_MAX_OPS_MIN 16384 -#endif - -struct hb_sanitize_context_t : - hb_dispatch_context_t -{ - inline hb_sanitize_context_t (void) : - debug_depth (0), - start (nullptr), end (nullptr), - writable (false), edit_count (0), max_ops (0), - blob (nullptr), - num_glyphs (65536), - num_glyphs_set (false) {} - - inline const char *get_name (void) { return "SANITIZE"; } - template - inline bool may_dispatch (const T *obj, const F *format) - { return format->sanitize (this); } - template - inline return_t dispatch (const T &obj) { return obj.sanitize (this); } - static return_t default_return_value (void) { return true; } - static return_t no_dispatch_return_value (void) { return false; } - bool stop_sublookup_iteration (const return_t r) const { return !r; } - - inline void init (hb_blob_t *b) - { - this->blob = hb_blob_reference (b); - this->writable = false; - } - - inline void set_num_glyphs (unsigned int num_glyphs_) - { - num_glyphs = num_glyphs_; - num_glyphs_set = true; - } - inline unsigned int get_num_glyphs (void) { return num_glyphs; } - - inline void start_processing (void) - { - 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, - (unsigned) HB_SANITIZE_MAX_OPS_MIN); - this->edit_count = 0; - this->debug_depth = 0; - - DEBUG_MSG_LEVEL (SANITIZE, start, 0, +1, - "start [%p..%p] (%lu bytes)", - this->start, this->end, - (unsigned long) (this->end - this->start)); - } - - inline void end_processing (void) - { - DEBUG_MSG_LEVEL (SANITIZE, this->start, 0, -1, - "end [%p..%p] %u edit requests", - this->start, this->end, this->edit_count); - - hb_blob_destroy (this->blob); - this->blob = nullptr; - this->start = this->end = nullptr; - } - - inline bool check_range (const void *base, unsigned int len) const - { - const char *p = (const char *) base; - bool ok = this->max_ops-- > 0 && - this->start <= p && - p <= this->end && - (unsigned int) (this->end - p) >= len; - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "check_range [%p..%p] (%d bytes) in [%p..%p] -> %s", - p, p + len, len, - this->start, this->end, - ok ? "OK" : "OUT-OF-RANGE"); - - return likely (ok); - } - - inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const - { - const char *p = (const char *) base; - bool overflows = hb_unsigned_mul_overflows (len, record_size); - unsigned int array_size = record_size * len; - bool ok = !overflows && this->check_range (base, array_size); - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "check_array [%p..%p] (%d*%d=%d bytes) in [%p..%p] -> %s", - p, p + (record_size * len), record_size, len, (unsigned int) array_size, - this->start, this->end, - overflows ? "OVERFLOWS" : ok ? "OK" : "OUT-OF-RANGE"); - - return likely (ok); - } - - template - inline bool check_struct (const Type *obj) const - { - return likely (this->check_range (obj, obj->min_size)); - } - - inline bool may_edit (const void *base, unsigned int len) - { - if (this->edit_count >= HB_SANITIZE_MAX_EDITS) - return false; - - const char *p = (const char *) base; - this->edit_count++; - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s", - this->edit_count, - p, p + len, len, - this->start, this->end, - this->writable ? "GRANTED" : "DENIED"); - - return this->writable; - } - - template - inline bool try_set (const Type *obj, const ValueType &v) { - if (this->may_edit (obj, obj->static_size)) { - const_cast (obj)->set (v); - return true; - } - return false; - } - - template - inline hb_blob_t *sanitize_blob (hb_blob_t *blob) - { - bool sane; - - init (blob); - - retry: - DEBUG_MSG_FUNC (SANITIZE, start, "start"); - - start_processing (); - - if (unlikely (!start)) - { - end_processing (); - return blob; - } - - Type *t = CastP (const_cast (start)); - - sane = t->sanitize (this); - if (sane) - { - if (edit_count) - { - DEBUG_MSG_FUNC (SANITIZE, start, "passed first round with %d edits; going for second round", edit_count); - - /* sanitize again to ensure no toe-stepping */ - edit_count = 0; - sane = t->sanitize (this); - if (edit_count) { - DEBUG_MSG_FUNC (SANITIZE, start, "requested %d edits in second round; FAILLING", edit_count); - sane = false; - } - } - } - else - { - if (edit_count && !writable) { - start = hb_blob_get_data_writable (blob, nullptr); - end = start + blob->length; - - if (start) - { - writable = true; - /* ok, we made it writable by relocating. try again */ - DEBUG_MSG_FUNC (SANITIZE, start, "retry"); - goto retry; - } - } - } - - end_processing (); - - DEBUG_MSG_FUNC (SANITIZE, start, sane ? "PASSED" : "FAILED"); - if (sane) - { - hb_blob_make_immutable (blob); - return blob; - } - else - { - hb_blob_destroy (blob); - return hb_blob_get_empty (); - } - } - - template - inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) - { - if (!num_glyphs_set) - set_num_glyphs (hb_face_get_glyph_count (face)); - return sanitize_blob (hb_face_reference_table (face, tableTag)); - } - - mutable unsigned int debug_depth; - const char *start, *end; - private: - bool writable; - unsigned int edit_count; - mutable int max_ops; - hb_blob_t *blob; - unsigned int num_glyphs; - bool num_glyphs_set; -}; - - -/* - * Serialize - */ - -struct hb_serialize_context_t -{ - inline hb_serialize_context_t (void *start_, unsigned int size) - { - this->start = (char *) start_; - this->end = this->start + size; - - this->ran_out_of_room = false; - this->head = this->start; - this->debug_depth = 0; - } - - template - inline Type *start_serialize (void) - { - DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, +1, - "start [%p..%p] (%lu bytes)", - this->start, this->end, - (unsigned long) (this->end - this->start)); - - return start_embed (); - } - - inline void end_serialize (void) - { - DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1, - "end [%p..%p] serialized %d bytes; %s", - this->start, this->end, - (int) (this->head - this->start), - this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room"); - } - - template - inline Type *copy (void) - { - assert (!this->ran_out_of_room); - unsigned int len = this->head - this->start; - void *p = malloc (len); - if (p) - memcpy (p, this->start, len); - return reinterpret_cast (p); - } - - template - inline Type *allocate_size (unsigned int size) - { - if (unlikely (this->ran_out_of_room || this->end - this->head < ptrdiff_t (size))) { - this->ran_out_of_room = true; - return nullptr; - } - memset (this->head, 0, size); - char *ret = this->head; - this->head += size; - return reinterpret_cast (ret); - } - - template - inline Type *allocate_min (void) - { - return this->allocate_size (Type::min_size); - } - - template - inline Type *start_embed (void) - { - Type *ret = reinterpret_cast (this->head); - return ret; - } - - template - inline Type *embed (const Type &obj) - { - unsigned int size = obj.get_size (); - Type *ret = this->allocate_size (size); - if (unlikely (!ret)) return nullptr; - memcpy (ret, obj, size); - return ret; - } - - template - inline Type *extend_min (Type &obj) - { - unsigned int size = obj.min_size; - assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; - return reinterpret_cast (&obj); - } - - template - inline Type *extend (Type &obj) - { - unsigned int size = obj.get_size (); - assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; - return reinterpret_cast (&obj); - } - - unsigned int debug_depth; - char *start, *end, *head; - bool ran_out_of_room; -}; - - -/* - * Supplier - */ - -template -struct Supplier -{ - inline Supplier (const Type *array, unsigned int len_, unsigned int stride_=sizeof(Type)) - { - head = array; - len = len_; - stride = stride_; - } - inline const Type operator [] (unsigned int i) const - { - if (unlikely (i >= len)) return Type (); - return * (const Type *) (const void *) ((const char *) head + stride * i); - } - - inline Supplier & operator += (unsigned int count) - { - if (unlikely (count > len)) - count = len; - len -= count; - head = (const Type *) (const void *) ((const char *) head + stride * count); - return *this; - } - - private: - inline Supplier (const Supplier &); /* Disallow copy */ - inline Supplier& operator= (const Supplier &); /* Disallow copy */ - - unsigned int len; - unsigned int stride; - const Type *head; -}; - - -/* - * Big-endian integers. - */ - -template struct BEInt; - -template -struct BEInt -{ - public: - inline void set (Type V) - { - v = V; - } - inline operator Type (void) const - { - return v; - } - private: uint8_t v; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 8) & 0xFF; - v[1] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 8) - + (v[1] ); - } - private: uint8_t v[2]; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 16) & 0xFF; - v[1] = (V >> 8) & 0xFF; - v[2] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 16) - + (v[1] << 8) - + (v[2] ); - } - private: uint8_t v[3]; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 24) & 0xFF; - v[1] = (V >> 16) & 0xFF; - v[2] = (V >> 8) & 0xFF; - v[3] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 24) - + (v[1] << 16) - + (v[2] << 8) - + (v[3] ); - } - private: uint8_t v[4]; -}; - - -/* - * Lazy loaders. - */ - -template -struct hb_data_wrapper_t -{ - static_assert (WheresData > 0, ""); - - inline Data * get_data (void) const - { - return *(((Data **) (void *) this) - WheresData); - } - - template - inline Stored * call_create (void) const - { - Data *data = this->get_data (); - return likely (data) ? Subclass::create (data) : nullptr; - } -}; -template <> -struct hb_data_wrapper_t -{ - template - inline Stored * call_create (void) const - { - return Funcs::create (); - } -}; - -template struct hb_non_void_t { typedef T1 value; }; -template struct hb_non_void_t { typedef T2 value; }; - -template -struct hb_lazy_loader_t : hb_data_wrapper_t -{ - typedef typename hb_non_void_t - >::value Funcs; - - inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ - inline void init (void) { instance.set_relaxed (nullptr); } - inline void fini (void) - { - do_destroy (instance.get ()); - } - inline void free_instance (void) - { - retry: - Stored *p = instance.get (); - if (unlikely (p && !this->instance.cmpexch (p, nullptr))) - goto retry; - do_destroy (p); - } - - inline Stored * do_create (void) const - { - Stored *p = this->template call_create (); - if (unlikely (!p)) - p = const_cast (Funcs::get_null ()); - return p; - } - static inline void do_destroy (Stored *p) - { - if (p && p != Funcs::get_null ()) - Funcs::destroy (p); - } - - inline const Returned * operator -> (void) const { return get (); } - inline const Returned & operator * (void) const { return *get (); } - - inline Data * get_data (void) const - { - return *(((Data **) this) - WheresData); - } - - inline Stored * get_stored (void) const - { - retry: - Stored *p = this->instance.get (); - if (unlikely (!p)) - { - p = do_create (); - if (unlikely (!this->instance.cmpexch (nullptr, p))) - { - do_destroy (p); - goto retry; - } - } - return p; - } - - inline void set_stored (Stored *instance_) - { - /* This *must* be called when there are no other threads accessing. - * However, to make TSan, etc, happy, we using cmpexch. */ - retry: - Stored *p = this->instance.get (); - if (unlikely (!this->instance.cmpexch (p, instance_))) - goto retry; - do_destroy (p); - } - - inline const Returned * get (void) const { return Funcs::convert (get_stored ()); } - inline Returned * get_unconst (void) const { return const_cast (Funcs::convert (get_stored ())); } - - /* To be possibly overloaded by subclasses. */ - static inline Returned* convert (Stored *p) { return p; } - - /* By default null/init/fini the object. */ - static inline const Stored* get_null (void) { return &Null(Stored); } - static inline Stored *create (Data *data) - { - Stored *p = (Stored *) calloc (1, sizeof (Stored)); - if (likely (p)) - p->init (data); - return p; - } - static inline Stored *create (void) - { - Stored *p = (Stored *) calloc (1, sizeof (Stored)); - if (likely (p)) - p->init (); - return p; - } - static inline void destroy (Stored *p) - { - p->fini (); - free (p); - } - - private: - /* Must only have one pointer. */ - hb_atomic_ptr_t instance; -}; - -/* Specializations. */ - -template -struct hb_face_lazy_loader_t : hb_lazy_loader_t, - hb_face_t, WheresFace> {}; - -template -struct hb_table_lazy_loader_t : hb_lazy_loader_t, - hb_face_t, WheresFace, - hb_blob_t> -{ - static inline hb_blob_t *create (hb_face_t *face) - { - return hb_sanitize_context_t ().reference_table (face); - } - static inline void destroy (hb_blob_t *p) - { - hb_blob_destroy (p); - } - static inline const hb_blob_t *get_null (void) - { - return hb_blob_get_empty (); - } - static inline const T* convert (const hb_blob_t *blob) - { - return blob->as (); - } - - inline hb_blob_t* get_blob (void) const - { - return this->get_stored (); - } -}; - -template -struct hb_font_funcs_lazy_loader_t : hb_lazy_loader_t -{ - static inline void destroy (hb_font_funcs_t *p) - { - hb_font_funcs_destroy (p); - } - static inline const hb_font_funcs_t *get_null (void) - { - return hb_font_funcs_get_empty (); - } -}; -template -struct hb_unicode_funcs_lazy_loader_t : hb_lazy_loader_t -{ - static inline void destroy (hb_unicode_funcs_t *p) - { - hb_unicode_funcs_destroy (p); - } - static inline const hb_unicode_funcs_t *get_null (void) - { - return hb_unicode_funcs_get_empty (); - } -}; - - -#endif /* HB_MACHINERY_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh new file mode 100644 index 00000000000..62f49072113 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh @@ -0,0 +1,907 @@ +/* + * Copyright © 2007,2008,2009,2010 Red Hat, Inc. + * Copyright © 2012,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_MACHINERY_HH +#define HB_MACHINERY_HH + +#include "hb.hh" +#include "hb-blob.hh" + +#include "hb-iter.hh" +#include "hb-vector.hh" + + +/* + * Casts + */ + +/* Cast to struct T, reference to reference */ +template +static inline const Type& CastR(const TObject &X) +{ return reinterpret_cast (X); } +template +static inline Type& CastR(TObject &X) +{ return reinterpret_cast (X); } + +/* Cast to struct T, pointer to pointer */ +template +static inline const Type* CastP(const TObject *X) +{ return reinterpret_cast (X); } +template +static inline Type* CastP(TObject *X) +{ return reinterpret_cast (X); } + +/* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory + * location pointed to by P plus Ofs bytes. */ +template +static inline const Type& StructAtOffset(const void *P, unsigned int offset) +{ return * reinterpret_cast ((const char *) P + offset); } +template +static inline Type& StructAtOffset(void *P, unsigned int offset) +{ return * reinterpret_cast ((char *) P + offset); } + +/* StructAfter(X) returns the struct T& that is placed after X. + * Works with X of variable size also. X must implement get_size() */ +template +static inline const Type& StructAfter(const TObject &X) +{ return StructAtOffset(&X, X.get_size()); } +template +static inline Type& StructAfter(TObject &X) +{ return StructAtOffset(&X, X.get_size()); } + + +/* + * Size checking + */ + +/* Check _assertion in a method environment */ +#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \ + inline void _instance_assertion_on_line_##_line (void) const \ + { \ + static_assert ((_assertion), ""); \ + ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \ + } +# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) +# define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion) + +/* Check that _code compiles in a method environment */ +#define _DEFINE_COMPILES_ASSERTION1(_line, _code) \ + inline void _compiles_assertion_on_line_##_line (void) const \ + { _code; } +# define _DEFINE_COMPILES_ASSERTION0(_line, _code) _DEFINE_COMPILES_ASSERTION1 (_line, _code) +# define DEFINE_COMPILES_ASSERTION(_code) _DEFINE_COMPILES_ASSERTION0 (__LINE__, _code) + + +#define DEFINE_SIZE_STATIC(size) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \ + enum { static_size = (size) }; \ + enum { min_size = (size) }; \ + inline unsigned int get_size (void) const { return (size); } + +#define DEFINE_SIZE_UNION(size, _member) \ + DEFINE_INSTANCE_ASSERTION (0*sizeof(this->u._member.static_size) + sizeof(this->u._member) == (size)); \ + static const unsigned int min_size = (size) + +#define DEFINE_SIZE_MIN(size) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)); \ + static const unsigned int min_size = (size) + +#define DEFINE_SIZE_ARRAY(size, array) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof (array[0])); \ + DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ + enum { min_size = (size) }; \ + +#define DEFINE_SIZE_ARRAY_SIZED(size, array) \ + DEFINE_SIZE_ARRAY(size, array); \ + inline unsigned int get_size (void) const { return (size - array[0].min_size + array.get_size ()); } + +#define DEFINE_SIZE_ARRAY2(size, array1, array2) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (this->array1[0]) + sizeof (this->array2[0])); \ + DEFINE_COMPILES_ASSERTION ((void) array1[0].static_size; (void) array2[0].static_size) \ + static const unsigned int min_size = (size) + + +/* + * Dispatch + */ + +template +struct hb_dispatch_context_t +{ + enum { max_debug_depth = MaxDebugDepth }; + typedef Return return_t; + template + inline bool may_dispatch (const T *obj, const F *format) { return true; } + static return_t no_dispatch_return_value (void) { return Context::default_return_value (); } +}; + + +/* + * Sanitize + * + * + * === Introduction === + * + * The sanitize machinery is at the core of our zero-cost font loading. We + * mmap() font file into memory and create a blob out of it. Font subtables + * are returned as a readonly sub-blob of the main font blob. These table + * blobs are then sanitized before use, to ensure invalid memory access does + * not happen. The toplevel sanitize API use is like, eg. to load the 'head' + * table: + * + * hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table (face); + * + * The blob then can be converted to a head table struct with: + * + * const head *head_table = head_blob->as (); + * + * What the reference_table does is, to call hb_face_reference_table() to load + * the table blob, sanitize it and return either the sanitized blob, or empty + * blob if sanitization failed. The blob->as() function returns the null + * object of its template type argument if the blob is empty. Otherwise, it + * just casts the blob contents to the desired type. + * + * Sanitizing a blob of data with a type T works as follows (with minor + * simplification): + * + * - Cast blob content to T*, call sanitize() method of it, + * - If sanitize succeeded, return blob. + * - Otherwise, if blob is not writable, try making it writable, + * or copy if cannot be made writable in-place, + * - Call sanitize() again. Return blob if sanitize succeeded. + * - Return empty blob otherwise. + * + * + * === The sanitize() contract === + * + * The sanitize() method of each object type shall return true if it's safe to + * call other methods of the object, and false otherwise. + * + * Note that what sanitize() checks for might align with what the specification + * describes as valid table data, but does not have to be. In particular, we + * do NOT want to be pedantic and concern ourselves with validity checks that + * are irrelevant to our use of the table. On the contrary, we want to be + * lenient with error handling and accept invalid data to the extent that it + * does not impose extra burden on us. + * + * Based on the sanitize contract, one can see that what we check for depends + * on how we use the data in other table methods. Ie. if other table methods + * assume that offsets do NOT point out of the table data block, then that's + * something sanitize() must check for (GSUB/GPOS/GDEF/etc work this way). On + * the other hand, if other methods do such checks themselves, then sanitize() + * does not have to bother with them (glyf/local work this way). The choice + * depends on the table structure and sanitize() performance. For example, to + * check glyf/loca offsets in sanitize() would cost O(num-glyphs). We try hard + * to avoid such costs during font loading. By postponing such checks to the + * actual glyph loading, we reduce the sanitize cost to O(1) and total runtime + * cost to O(used-glyphs). As such, this is preferred. + * + * The same argument can be made re GSUB/GPOS/GDEF, but there, the table + * structure is so complicated that by checking all offsets at sanitize() time, + * we make the code much simpler in other methods, as offsets and referenced + * objectes do not need to be validated at each use site. + */ + +/* This limits sanitizing time on really broken fonts. */ +#ifndef HB_SANITIZE_MAX_EDITS +#define HB_SANITIZE_MAX_EDITS 32 +#endif +#ifndef HB_SANITIZE_MAX_OPS_FACTOR +#define HB_SANITIZE_MAX_OPS_FACTOR 8 +#endif +#ifndef HB_SANITIZE_MAX_OPS_MIN +#define HB_SANITIZE_MAX_OPS_MIN 16384 +#endif + +struct hb_sanitize_context_t : + hb_dispatch_context_t +{ + inline hb_sanitize_context_t (void) : + debug_depth (0), + start (nullptr), end (nullptr), + writable (false), edit_count (0), max_ops (0), + blob (nullptr), + num_glyphs (65536), + num_glyphs_set (false) {} + + inline const char *get_name (void) { return "SANITIZE"; } + template + inline bool may_dispatch (const T *obj, const F *format) + { return format->sanitize (this); } + template + inline return_t dispatch (const T &obj) { return obj.sanitize (this); } + static return_t default_return_value (void) { return true; } + static return_t no_dispatch_return_value (void) { return false; } + bool stop_sublookup_iteration (const return_t r) const { return !r; } + + inline void init (hb_blob_t *b) + { + this->blob = hb_blob_reference (b); + this->writable = false; + } + + inline void set_num_glyphs (unsigned int num_glyphs_) + { + num_glyphs = num_glyphs_; + num_glyphs_set = true; + } + inline unsigned int get_num_glyphs (void) { return num_glyphs; } + + inline void start_processing (void) + { + 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, + (unsigned) HB_SANITIZE_MAX_OPS_MIN); + this->edit_count = 0; + this->debug_depth = 0; + + DEBUG_MSG_LEVEL (SANITIZE, start, 0, +1, + "start [%p..%p] (%lu bytes)", + this->start, this->end, + (unsigned long) (this->end - this->start)); + } + + inline void end_processing (void) + { + DEBUG_MSG_LEVEL (SANITIZE, this->start, 0, -1, + "end [%p..%p] %u edit requests", + this->start, this->end, this->edit_count); + + hb_blob_destroy (this->blob); + this->blob = nullptr; + this->start = this->end = nullptr; + } + + inline bool check_range (const void *base, unsigned int len) const + { + const char *p = (const char *) base; + bool ok = this->max_ops-- > 0 && + this->start <= p && + p <= this->end && + (unsigned int) (this->end - p) >= len; + + DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, + "check_range [%p..%p] (%d bytes) in [%p..%p] -> %s", + p, p + len, len, + this->start, this->end, + ok ? "OK" : "OUT-OF-RANGE"); + + return likely (ok); + } + + inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const + { + const char *p = (const char *) base; + bool overflows = hb_unsigned_mul_overflows (len, record_size); + unsigned int array_size = record_size * len; + bool ok = !overflows && this->check_range (base, array_size); + + DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, + "check_array [%p..%p] (%d*%d=%d bytes) in [%p..%p] -> %s", + p, p + (record_size * len), record_size, len, (unsigned int) array_size, + this->start, this->end, + overflows ? "OVERFLOWS" : ok ? "OK" : "OUT-OF-RANGE"); + + return likely (ok); + } + + template + inline bool check_struct (const Type *obj) const + { + return likely (this->check_range (obj, obj->min_size)); + } + + inline bool may_edit (const void *base, unsigned int len) + { + if (this->edit_count >= HB_SANITIZE_MAX_EDITS) + return false; + + const char *p = (const char *) base; + this->edit_count++; + + DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, + "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s", + this->edit_count, + p, p + len, len, + this->start, this->end, + this->writable ? "GRANTED" : "DENIED"); + + return this->writable; + } + + template + inline bool try_set (const Type *obj, const ValueType &v) { + if (this->may_edit (obj, obj->static_size)) { + const_cast (obj)->set (v); + return true; + } + return false; + } + + template + inline hb_blob_t *sanitize_blob (hb_blob_t *blob) + { + bool sane; + + init (blob); + + retry: + DEBUG_MSG_FUNC (SANITIZE, start, "start"); + + start_processing (); + + if (unlikely (!start)) + { + end_processing (); + return blob; + } + + Type *t = CastP (const_cast (start)); + + sane = t->sanitize (this); + if (sane) + { + if (edit_count) + { + DEBUG_MSG_FUNC (SANITIZE, start, "passed first round with %d edits; going for second round", edit_count); + + /* sanitize again to ensure no toe-stepping */ + edit_count = 0; + sane = t->sanitize (this); + if (edit_count) { + DEBUG_MSG_FUNC (SANITIZE, start, "requested %d edits in second round; FAILLING", edit_count); + sane = false; + } + } + } + else + { + if (edit_count && !writable) { + start = hb_blob_get_data_writable (blob, nullptr); + end = start + blob->length; + + if (start) + { + writable = true; + /* ok, we made it writable by relocating. try again */ + DEBUG_MSG_FUNC (SANITIZE, start, "retry"); + goto retry; + } + } + } + + end_processing (); + + DEBUG_MSG_FUNC (SANITIZE, start, sane ? "PASSED" : "FAILED"); + if (sane) + { + hb_blob_make_immutable (blob); + return blob; + } + else + { + hb_blob_destroy (blob); + return hb_blob_get_empty (); + } + } + + template + inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) + { + if (!num_glyphs_set) + set_num_glyphs (hb_face_get_glyph_count (face)); + return sanitize_blob (hb_face_reference_table (face, tableTag)); + } + + mutable unsigned int debug_depth; + const char *start, *end; + private: + bool writable; + unsigned int edit_count; + mutable int max_ops; + hb_blob_t *blob; + unsigned int num_glyphs; + bool num_glyphs_set; +}; + + +/* + * Serialize + */ + +struct hb_serialize_context_t +{ + inline hb_serialize_context_t (void *start_, unsigned int size) + { + this->start = (char *) start_; + this->end = this->start + size; + reset (); + } + + inline void reset (void) + { + this->ran_out_of_room = false; + this->head = this->start; + this->debug_depth = 0; + } + + inline bool err (bool e) { return this->ran_out_of_room = this->ran_out_of_room || e; } + + /* To be called around main operation. */ + template + inline Type *start_serialize (void) + { + DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, +1, + "start [%p..%p] (%lu bytes)", + this->start, this->end, + (unsigned long) (this->end - this->start)); + + return start_embed (); + } + inline void end_serialize (void) + { + DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1, + "end [%p..%p] serialized %d bytes; %s", + this->start, this->end, + (int) (this->head - this->start), + this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room"); + } + + inline unsigned int length (void) const { return this->head - this->start; } + + inline void align (unsigned int alignment) + { + unsigned int l = length () % alignment; + if (l) + allocate_size (alignment - l); + } + + template + inline Type *start_embed (void) const + { + Type *ret = reinterpret_cast (this->head); + return ret; + } + + template + inline Type *allocate_size (unsigned int size) + { + if (unlikely (this->ran_out_of_room || this->end - this->head < ptrdiff_t (size))) { + this->ran_out_of_room = true; + return nullptr; + } + memset (this->head, 0, size); + char *ret = this->head; + this->head += size; + return reinterpret_cast (ret); + } + + template + inline Type *allocate_min (void) + { + return this->allocate_size (Type::min_size); + } + + template + inline Type *embed (const Type &obj) + { + unsigned int size = obj.get_size (); + Type *ret = this->allocate_size (size); + if (unlikely (!ret)) return nullptr; + memcpy (ret, &obj, size); + return ret; + } + + template + inline Type *extend_min (Type &obj) + { + unsigned int size = obj.min_size; + assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; + return reinterpret_cast (&obj); + } + + template + inline Type *extend (Type &obj) + { + unsigned int size = obj.get_size (); + assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return nullptr; + return reinterpret_cast (&obj); + } + + /* Output routines. */ + template + inline Type *copy (void) const + { + assert (!this->ran_out_of_room); + unsigned int len = this->head - this->start; + void *p = malloc (len); + if (p) + memcpy (p, this->start, len); + return reinterpret_cast (p); + } + inline hb_bytes_t copy_bytes (void) const + { + assert (!this->ran_out_of_room); + unsigned int len = this->head - this->start; + void *p = malloc (len); + if (p) + memcpy (p, this->start, len); + else + return hb_bytes_t (); + return hb_bytes_t (p, len); + } + inline hb_blob_t *copy_blob (void) const + { + assert (!this->ran_out_of_room); + return hb_blob_create (this->start, + this->head - this->start, + HB_MEMORY_MODE_DUPLICATE, + nullptr, nullptr); + } + + public: + unsigned int debug_depth; + char *start, *end, *head; + bool ran_out_of_room; +}; + + +/* + * Supplier + */ + +template +struct Supplier +{ + inline Supplier (const Type *array, unsigned int len_, unsigned int stride_=sizeof (Type)) + { + head = array; + len = len_; + stride = stride_; + } + inline Supplier (const hb_vector_t *v) + { + head = v->arrayZ; + len = v->len; + stride = sizeof (Type); + } + + inline const Type operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Type (); + return * (const Type *) (const void *) ((const char *) head + stride * i); + } + + inline Supplier & operator += (unsigned int count) + { + if (unlikely (count > len)) + count = len; + len -= count; + head = (const Type *) (const void *) ((const char *) head + stride * count); + return *this; + } + + private: + inline Supplier (const Supplier &); /* Disallow copy */ + inline Supplier& operator= (const Supplier &); /* Disallow copy */ + + unsigned int len; + unsigned int stride; + const Type *head; +}; + + +/* + * Big-endian integers. + */ + +template struct BEInt; + +template +struct BEInt +{ + public: + inline void set (Type V) + { + v = V; + } + inline operator Type (void) const + { + return v; + } + private: uint8_t v; +}; +template +struct BEInt +{ + public: + inline void set (Type V) + { + v[0] = (V >> 8) & 0xFF; + v[1] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 8) + + (v[1] ); + } + private: uint8_t v[2]; +}; +template +struct BEInt +{ + public: + inline void set (Type V) + { + v[0] = (V >> 16) & 0xFF; + v[1] = (V >> 8) & 0xFF; + v[2] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 16) + + (v[1] << 8) + + (v[2] ); + } + private: uint8_t v[3]; +}; +template +struct BEInt +{ + public: + inline void set (Type V) + { + v[0] = (V >> 24) & 0xFF; + v[1] = (V >> 16) & 0xFF; + v[2] = (V >> 8) & 0xFF; + v[3] = (V ) & 0xFF; + } + inline operator Type (void) const + { + return (v[0] << 24) + + (v[1] << 16) + + (v[2] << 8) + + (v[3] ); + } + private: uint8_t v[4]; +}; + + +/* + * Lazy loaders. + */ + +template +struct hb_data_wrapper_t +{ + static_assert (WheresData > 0, ""); + + inline Data * get_data (void) const + { + return *(((Data **) (void *) this) - WheresData); + } + + template + inline Stored * call_create (void) const + { + Data *data = this->get_data (); + return likely (data) ? Subclass::create (data) : nullptr; + } +}; +template <> +struct hb_data_wrapper_t +{ + template + inline Stored * call_create (void) const + { + return Funcs::create (); + } +}; + +template struct hb_non_void_t { typedef T1 value; }; +template struct hb_non_void_t { typedef T2 value; }; + +template +struct hb_lazy_loader_t : hb_data_wrapper_t +{ + typedef typename hb_non_void_t + >::value Funcs; + + inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ + inline void init (void) { instance.set_relaxed (nullptr); } + inline void fini (void) + { + do_destroy (instance.get ()); + } + inline void free_instance (void) + { + retry: + Stored *p = instance.get (); + if (unlikely (p && !this->instance.cmpexch (p, nullptr))) + goto retry; + do_destroy (p); + } + + inline Stored * do_create (void) const + { + Stored *p = this->template call_create (); + if (unlikely (!p)) + p = const_cast (Funcs::get_null ()); + return p; + } + static inline void do_destroy (Stored *p) + { + if (p && p != Funcs::get_null ()) + Funcs::destroy (p); + } + + inline const Returned * operator -> (void) const { return get (); } + inline const Returned & operator * (void) const { return *get (); } + + inline Data * get_data (void) const + { + return *(((Data **) this) - WheresData); + } + + inline Stored * get_stored (void) const + { + retry: + Stored *p = this->instance.get (); + if (unlikely (!p)) + { + p = do_create (); + if (unlikely (!this->instance.cmpexch (nullptr, p))) + { + do_destroy (p); + goto retry; + } + } + return p; + } + inline Stored * get_stored_relaxed (void) const + { + return this->instance.get_relaxed (); + } + + inline void set_stored (Stored *instance_) + { + /* This *must* be called when there are no other threads accessing. + * However, to make TSan, etc, happy, we using cmpexch. */ + retry: + Stored *p = this->instance.get (); + if (unlikely (!this->instance.cmpexch (p, instance_))) + goto retry; + do_destroy (p); + } + + inline const Returned * get (void) const { return Funcs::convert (get_stored ()); } + inline const Returned * get_relaxed (void) const { return Funcs::convert (get_stored_relaxed ()); } + inline Returned * get_unconst (void) const { return const_cast (Funcs::convert (get_stored ())); } + + /* To be possibly overloaded by subclasses. */ + static inline Returned* convert (Stored *p) { return p; } + + /* By default null/init/fini the object. */ + static inline const Stored* get_null (void) { return &Null(Stored); } + static inline Stored *create (Data *data) + { + Stored *p = (Stored *) calloc (1, sizeof (Stored)); + if (likely (p)) + p->init (data); + return p; + } + static inline Stored *create (void) + { + Stored *p = (Stored *) calloc (1, sizeof (Stored)); + if (likely (p)) + p->init (); + return p; + } + static inline void destroy (Stored *p) + { + p->fini (); + free (p); + } + + private: + /* Must only have one pointer. */ + hb_atomic_ptr_t instance; +}; + +/* Specializations. */ + +template +struct hb_face_lazy_loader_t : hb_lazy_loader_t, + hb_face_t, WheresFace> {}; + +template +struct hb_table_lazy_loader_t : hb_lazy_loader_t, + hb_face_t, WheresFace, + hb_blob_t> +{ + static inline hb_blob_t *create (hb_face_t *face) + { + return hb_sanitize_context_t ().reference_table (face); + } + static inline void destroy (hb_blob_t *p) + { + hb_blob_destroy (p); + } + static inline const hb_blob_t *get_null (void) + { + return hb_blob_get_empty (); + } + static inline const T* convert (const hb_blob_t *blob) + { + return blob->as (); + } + + inline hb_blob_t* get_blob (void) const + { + return this->get_stored (); + } +}; + +template +struct hb_font_funcs_lazy_loader_t : hb_lazy_loader_t +{ + static inline void destroy (hb_font_funcs_t *p) + { + hb_font_funcs_destroy (p); + } + static inline const hb_font_funcs_t *get_null (void) + { + return hb_font_funcs_get_empty (); + } +}; +template +struct hb_unicode_funcs_lazy_loader_t : hb_lazy_loader_t +{ + static inline void destroy (hb_unicode_funcs_t *p) + { + hb_unicode_funcs_destroy (p); + } + static inline const hb_unicode_funcs_t *get_null (void) + { + return hb_unicode_funcs_get_empty (); + } +}; + + +#endif /* HB_MACHINERY_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map-private.hh deleted file mode 100644 index 00f089e8151..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map-private.hh +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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_MAP_PRIVATE_HH -#define HB_MAP_PRIVATE_HH - -#include "hb-private.hh" - - -template -inline uint32_t Hash (const T &v) -{ - /* Knuth's multiplicative method: */ - return (uint32_t) v * 2654435761u; -} - - -/* - * hb_map_t - */ - -struct hb_map_t -{ - struct item_t - { - hb_codepoint_t key; - hb_codepoint_t value; - - inline bool is_unused (void) const { return key == INVALID; } - inline bool is_tombstone (void) const { return key != INVALID && value == INVALID; } - }; - - hb_object_header_t header; - bool successful; /* Allocations successful */ - unsigned int population; /* Not including tombstones. */ - unsigned int occupancy; /* Including tombstones. */ - unsigned int mask; - unsigned int prime; - item_t *items; - - inline void init_shallow (void) - { - successful = true; - population = occupancy = 0; - mask = 0; - prime = 0; - items = nullptr; - } - inline void init (void) - { - hb_object_init (this); - init_shallow (); - } - inline void fini_shallow (void) - { - free (items); - } - inline void fini (void) - { - hb_object_fini (this); - fini_shallow (); - } - - inline bool resize (void) - { - if (unlikely (!successful)) return false; - - unsigned int power = hb_bit_storage (population * 2 + 8); - unsigned int new_size = 1u << power; - item_t *new_items = (item_t *) malloc ((size_t) new_size * sizeof (item_t)); - if (unlikely (!new_items)) - { - successful = false; - return false; - } - memset (new_items, 0xFF, (size_t) new_size * sizeof (item_t)); - - unsigned int old_size = mask + 1; - item_t *old_items = items; - - /* Switch to new, empty, array. */ - population = occupancy = 0; - mask = new_size - 1; - prime = prime_for (power); - items = new_items; - - /* Insert back old items. */ - if (old_items) - for (unsigned int i = 0; i < old_size; i++) - if (old_items[i].key != INVALID && old_items[i].value != INVALID) - set (old_items[i].key, old_items[i].value); - - free (old_items); - - return true; - } - - inline void set (hb_codepoint_t key, hb_codepoint_t value) - { - if (unlikely (!successful)) return; - if (unlikely (key == INVALID)) return; - if ((occupancy + occupancy / 2) >= mask && !resize ()) return; - unsigned int i = bucket_for (key); - - if (value == INVALID && items[i].key != key) - return; /* Trying to delete non-existent key. */ - - if (!items[i].is_unused ()) - { - occupancy--; - if (items[i].is_tombstone ()) - population--; - } - - items[i].key = key; - items[i].value = value; - - occupancy++; - if (!items[i].is_tombstone ()) - population++; - - } - inline hb_codepoint_t get (hb_codepoint_t key) const - { - if (unlikely (!items)) return INVALID; - unsigned int i = bucket_for (key); - return items[i].key == key ? items[i].value : INVALID; - } - - inline void del (hb_codepoint_t key) - { - set (key, INVALID); - } - inline bool has (hb_codepoint_t key) const - { - return get (key) != INVALID; - } - - inline hb_codepoint_t operator [] (unsigned int key) const - { return get (key); } - - static const hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID; - - inline void clear (void) - { - memset (items, 0xFF, ((size_t) mask + 1) * sizeof (item_t)); - population = occupancy = 0; - } - - inline bool is_empty (void) const - { - return population != 0; - } - - inline unsigned int get_population () const - { - return population; - } - - protected: - - inline unsigned int bucket_for (hb_codepoint_t key) const - { - unsigned int i = Hash (key) % prime; - unsigned int step = 0; - unsigned int tombstone = INVALID; - while (!items[i].is_unused ()) - { - if (items[i].key == key) - return i; - if (tombstone == INVALID && items[i].is_tombstone ()) - tombstone = i; - i = (i + ++step) & mask; - } - return tombstone == INVALID ? i : tombstone; - } - - static inline unsigned int prime_for (unsigned int shift) - { - /* Following comment and table copied from glib. */ - /* Each table size has an associated prime modulo (the first prime - * lower than the table size) used to find the initial bucket. Probing - * then works modulo 2^n. The prime modulo is necessary to get a - * good distribution with poor hash functions. - */ - /* Not declaring static to make all kinds of compilers happy... */ - /*static*/ const unsigned int prime_mod [32] = - { - 1, /* For 1 << 0 */ - 2, - 3, - 7, - 13, - 31, - 61, - 127, - 251, - 509, - 1021, - 2039, - 4093, - 8191, - 16381, - 32749, - 65521, /* For 1 << 16 */ - 131071, - 262139, - 524287, - 1048573, - 2097143, - 4194301, - 8388593, - 16777213, - 33554393, - 67108859, - 134217689, - 268435399, - 536870909, - 1073741789, - 2147483647 /* For 1 << 31 */ - }; - - if (unlikely (shift >= ARRAY_LENGTH (prime_mod))) - return prime_mod[ARRAY_LENGTH (prime_mod) - 1]; - - return prime_mod[shift]; - } -}; - - -#endif /* HB_MAP_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc index 138a85612fc..225f37bc678 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-map-private.hh" +#include "hb-map.hh" /* Public API */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh new file mode 100644 index 00000000000..21898a7a677 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh @@ -0,0 +1,254 @@ +/* + * 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_MAP_HH +#define HB_MAP_HH + +#include "hb.hh" + + +template +inline uint32_t Hash (const T &v) +{ + /* Knuth's multiplicative method: */ + return (uint32_t) v * 2654435761u; +} + + +/* + * hb_map_t + */ + +struct hb_map_t +{ + struct item_t + { + hb_codepoint_t key; + hb_codepoint_t value; + + inline bool is_unused (void) const { return key == INVALID; } + inline bool is_tombstone (void) const { return key != INVALID && value == INVALID; } + }; + + hb_object_header_t header; + bool successful; /* Allocations successful */ + unsigned int population; /* Not including tombstones. */ + unsigned int occupancy; /* Including tombstones. */ + unsigned int mask; + unsigned int prime; + item_t *items; + + inline void init_shallow (void) + { + successful = true; + population = occupancy = 0; + mask = 0; + prime = 0; + items = nullptr; + } + inline void init (void) + { + hb_object_init (this); + init_shallow (); + } + inline void fini_shallow (void) + { + free (items); + } + inline void fini (void) + { + hb_object_fini (this); + fini_shallow (); + } + + inline bool resize (void) + { + if (unlikely (!successful)) return false; + + unsigned int power = hb_bit_storage (population * 2 + 8); + unsigned int new_size = 1u << power; + item_t *new_items = (item_t *) malloc ((size_t) new_size * sizeof (item_t)); + if (unlikely (!new_items)) + { + successful = false; + return false; + } + memset (new_items, 0xFF, (size_t) new_size * sizeof (item_t)); + + unsigned int old_size = mask + 1; + item_t *old_items = items; + + /* Switch to new, empty, array. */ + population = occupancy = 0; + mask = new_size - 1; + prime = prime_for (power); + items = new_items; + + /* Insert back old items. */ + if (old_items) + for (unsigned int i = 0; i < old_size; i++) + if (old_items[i].key != INVALID && old_items[i].value != INVALID) + set (old_items[i].key, old_items[i].value); + + free (old_items); + + return true; + } + + inline void set (hb_codepoint_t key, hb_codepoint_t value) + { + if (unlikely (!successful)) return; + if (unlikely (key == INVALID)) return; + if ((occupancy + occupancy / 2) >= mask && !resize ()) return; + unsigned int i = bucket_for (key); + + if (value == INVALID && items[i].key != key) + return; /* Trying to delete non-existent key. */ + + if (!items[i].is_unused ()) + { + occupancy--; + if (items[i].is_tombstone ()) + population--; + } + + items[i].key = key; + items[i].value = value; + + occupancy++; + if (!items[i].is_tombstone ()) + population++; + + } + inline hb_codepoint_t get (hb_codepoint_t key) const + { + if (unlikely (!items)) return INVALID; + unsigned int i = bucket_for (key); + return items[i].key == key ? items[i].value : INVALID; + } + + inline void del (hb_codepoint_t key) + { + set (key, INVALID); + } + inline bool has (hb_codepoint_t key) const + { + return get (key) != INVALID; + } + + inline hb_codepoint_t operator [] (unsigned int key) const + { return get (key); } + + static const hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID; + + inline void clear (void) + { + memset (items, 0xFF, ((size_t) mask + 1) * sizeof (item_t)); + population = occupancy = 0; + } + + inline bool is_empty (void) const + { + return population != 0; + } + + inline unsigned int get_population () const + { + return population; + } + + protected: + + inline unsigned int bucket_for (hb_codepoint_t key) const + { + unsigned int i = Hash (key) % prime; + unsigned int step = 0; + unsigned int tombstone = INVALID; + while (!items[i].is_unused ()) + { + if (items[i].key == key) + return i; + if (tombstone == INVALID && items[i].is_tombstone ()) + tombstone = i; + i = (i + ++step) & mask; + } + return tombstone == INVALID ? i : tombstone; + } + + static inline unsigned int prime_for (unsigned int shift) + { + /* Following comment and table copied from glib. */ + /* Each table size has an associated prime modulo (the first prime + * lower than the table size) used to find the initial bucket. Probing + * then works modulo 2^n. The prime modulo is necessary to get a + * good distribution with poor hash functions. + */ + /* Not declaring static to make all kinds of compilers happy... */ + /*static*/ const unsigned int prime_mod [32] = + { + 1, /* For 1 << 0 */ + 2, + 3, + 7, + 13, + 31, + 61, + 127, + 251, + 509, + 1021, + 2039, + 4093, + 8191, + 16381, + 32749, + 65521, /* For 1 << 16 */ + 131071, + 262139, + 524287, + 1048573, + 2097143, + 4194301, + 8388593, + 16777213, + 33554393, + 67108859, + 134217689, + 268435399, + 536870909, + 1073741789, + 2147483647 /* For 1 << 31 */ + }; + + if (unlikely (shift >= ARRAY_LENGTH (prime_mod))) + return prime_mod[ARRAY_LENGTH (prime_mod) - 1]; + + return prime_mod[shift]; + } +}; + + +#endif /* HB_MAP_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex-private.hh deleted file mode 100644 index 14bde3103e1..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex-private.hh +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 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. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_MUTEX_PRIVATE_HH -#define HB_MUTEX_PRIVATE_HH - -#include "hb-private.hh" - - -/* mutex */ - -/* We need external help for these */ - -#if defined(HB_MUTEX_IMPL_INIT) \ - && defined(hb_mutex_impl_init) \ - && defined(hb_mutex_impl_lock) \ - && defined(hb_mutex_impl_unlock) \ - && defined(hb_mutex_impl_finish) - -/* Defined externally, i.e. in config.h; must have typedef'ed hb_mutex_impl_t as well. */ - - -#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) - -#include -typedef CRITICAL_SECTION hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT {0} -#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) -#define hb_mutex_impl_init(M) InitializeCriticalSectionEx (M, 0, 0) -#else -#define hb_mutex_impl_init(M) InitializeCriticalSection (M) -#endif -#define hb_mutex_impl_lock(M) EnterCriticalSection (M) -#define hb_mutex_impl_unlock(M) LeaveCriticalSection (M) -#define hb_mutex_impl_finish(M) DeleteCriticalSection (M) - - -#elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__)) - -#include -typedef pthread_mutex_t hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT PTHREAD_MUTEX_INITIALIZER -#define hb_mutex_impl_init(M) pthread_mutex_init (M, nullptr) -#define hb_mutex_impl_lock(M) pthread_mutex_lock (M) -#define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) -#define hb_mutex_impl_finish(M) pthread_mutex_destroy (M) - - -#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) - -#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) -# include -# define HB_SCHED_YIELD() sched_yield () -#else -# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END -#endif - -/* This actually is not a totally awful implementation. */ -typedef volatile int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) *(M) = 0 -#define hb_mutex_impl_lock(M) HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END -#define hb_mutex_impl_unlock(M) __sync_lock_release (M) -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#elif !defined(HB_NO_MT) - -#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) -# include -# define HB_SCHED_YIELD() sched_yield () -#else -# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END -#endif - -#define HB_MUTEX_INT_NIL 1 /* Warn that fallback implementation is in use. */ -typedef volatile int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) *(M) = 0 -#define hb_mutex_impl_lock(M) HB_STMT_START { while (*(M)) HB_SCHED_YIELD (); (*(M))++; } HB_STMT_END -#define hb_mutex_impl_unlock(M) (*(M))--; -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#else /* HB_NO_MT */ - -typedef int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_lock(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_unlock(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#endif - - -#define HB_MUTEX_INIT {HB_MUTEX_IMPL_INIT} - -struct hb_mutex_t -{ - /* TODO Add tracing. */ - - hb_mutex_impl_t m; - - inline void init (void) { hb_mutex_impl_init (&m); } - inline void lock (void) { hb_mutex_impl_lock (&m); } - inline void unlock (void) { hb_mutex_impl_unlock (&m); } - inline void fini (void) { hb_mutex_impl_finish (&m); } -}; - - -#endif /* HB_MUTEX_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh new file mode 100644 index 00000000000..d8cdf4b64ac --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh @@ -0,0 +1,141 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 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. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_MUTEX_HH +#define HB_MUTEX_HH + +#include "hb.hh" + + +/* mutex */ + +/* We need external help for these */ + +#if defined(HB_MUTEX_IMPL_INIT) \ + && defined(hb_mutex_impl_init) \ + && defined(hb_mutex_impl_lock) \ + && defined(hb_mutex_impl_unlock) \ + && defined(hb_mutex_impl_finish) + +/* Defined externally, i.e. in config.h; must have typedef'ed hb_mutex_impl_t as well. */ + + +#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) + +#include +typedef CRITICAL_SECTION hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT {0} +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#define hb_mutex_impl_init(M) InitializeCriticalSectionEx (M, 0, 0) +#else +#define hb_mutex_impl_init(M) InitializeCriticalSection (M) +#endif +#define hb_mutex_impl_lock(M) EnterCriticalSection (M) +#define hb_mutex_impl_unlock(M) LeaveCriticalSection (M) +#define hb_mutex_impl_finish(M) DeleteCriticalSection (M) + + +#elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__)) + +#include +typedef pthread_mutex_t hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT PTHREAD_MUTEX_INITIALIZER +#define hb_mutex_impl_init(M) pthread_mutex_init (M, nullptr) +#define hb_mutex_impl_lock(M) pthread_mutex_lock (M) +#define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) +#define hb_mutex_impl_finish(M) pthread_mutex_destroy (M) + + +#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) +# include +# define HB_SCHED_YIELD() sched_yield () +#else +# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END +#endif + +/* This actually is not a totally awful implementation. */ +typedef volatile int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) *(M) = 0 +#define hb_mutex_impl_lock(M) HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END +#define hb_mutex_impl_unlock(M) __sync_lock_release (M) +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + + +#elif !defined(HB_NO_MT) + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) +# include +# define HB_SCHED_YIELD() sched_yield () +#else +# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END +#endif + +#define HB_MUTEX_INT_NIL 1 /* Warn that fallback implementation is in use. */ +typedef volatile int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) *(M) = 0 +#define hb_mutex_impl_lock(M) HB_STMT_START { while (*(M)) HB_SCHED_YIELD (); (*(M))++; } HB_STMT_END +#define hb_mutex_impl_unlock(M) (*(M))--; +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + + +#else /* HB_NO_MT */ + +typedef int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_lock(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_unlock(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + + +#endif + + +#define HB_MUTEX_INIT {HB_MUTEX_IMPL_INIT} + +struct hb_mutex_t +{ + /* TODO Add tracing. */ + + hb_mutex_impl_t m; + + inline void init (void) { hb_mutex_impl_init (&m); } + inline void lock (void) { hb_mutex_impl_lock (&m); } + inline void unlock (void) { hb_mutex_impl_unlock (&m); } + inline void fini (void) { hb_mutex_impl_finish (&m); } +}; + + +#endif /* HB_MUTEX_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 index 91efee6443d..7128f0a94f3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -27,7 +27,7 @@ #ifndef HB_NULL_HH #define HB_NULL_HH -#include "hb-private.hh" +#include "hb.hh" /* @@ -51,27 +51,40 @@ static inline Type const & Null (void) { /* 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 (void) { \ - return *reinterpret_cast (_hb_Null_##Namespace##_##Type); \ -} \ -namespace Namespace { \ -static_assert (true, "Just so we take semicolon after.") + } /* Close namespace. */ \ + extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size]; \ + template <> \ + /*static*/ inline const Namespace::Type& Null (void) { \ + return *reinterpret_cast (_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] + 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 (void) { \ - return _hb_Null_##Type; \ -} \ + extern HB_INTERNAL const Type _hb_Null_##Type; \ + template <> \ + /*static*/ inline const Type& Null (void) { \ + return _hb_Null_##Type; \ + } \ static_assert (true, "Just so we take semicolon after.") #define DEFINE_NULL_INSTANCE(Type) \ -const Type _hb_Null_##Type + const Type _hb_Null_##Type + +/* Specializaiton to disallow Null objects. */ +#define DECLARE_NULL_DISALLOW(Type) \ + template <> inline const Type& Null (void) +#define DECLARE_NULL_NAMSPACE_DISALLOW(Namespace, Type) \ + } /* Close namespace. */ \ + template <> \ + /*static*/ inline const Namespace::Type& Null (void) { \ + extern void *_hb_undefined; \ + return *reinterpret_cast (_hb_undefined); \ + } \ + namespace Namespace { \ + static_assert (true, "Just so we take semicolon after.") /* Global writable pool. Enlarge as necessary. */ 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 deleted file mode 100644 index 4955a68dc3c..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object-private.hh +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 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. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OBJECT_PRIVATE_HH -#define HB_OBJECT_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-atomic-private.hh" -#include "hb-mutex-private.hh" -#include "hb-vector-private.hh" - - -/* - * Lockable set - */ - -template -struct hb_lockable_set_t -{ - hb_vector_t items; - - inline void init (void) { items.init (); } - - template - 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 - 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 - 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 - 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 -#define HB_REFERENCE_COUNT_INIT {HB_ATOMIC_INT_INIT (HB_REFERENCE_COUNT_INERT_VALUE)} - -struct hb_reference_count_t -{ - mutable hb_atomic_int_t ref_count; - - inline void init (int v = 1) { ref_count.set_relaxed (v); } - inline int get_relaxed (void) const { return ref_count.get_relaxed (); } - inline int inc (void) const { return ref_count.inc (); } - inline int dec (void) const { return ref_count.dec (); } - inline void fini (void) { ref_count.set_relaxed (HB_REFERENCE_COUNT_POISON_VALUE); } - - inline bool is_inert (void) const { return ref_count.get_relaxed () == HB_REFERENCE_COUNT_INERT_VALUE; } - inline bool is_valid (void) const { return ref_count.get_relaxed () > 0; } -}; - - -/* user_data */ - -struct hb_user_data_array_t -{ - struct hb_user_data_item_t { - hb_user_data_key_t *key; - void *data; - hb_destroy_func_t destroy; - - inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } - inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; } - - void fini (void) { if (destroy) destroy (data); } - }; - - hb_mutex_t lock; - hb_lockable_set_t items; - - inline void init (void) { lock.init (); items.init (); } - - HB_INTERNAL bool set (hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - HB_INTERNAL void *get (hb_user_data_key_t *key); - - inline void fini (void) { items.fini (lock); lock.fini (); } -}; - - -/* - * Object header - */ - -struct hb_object_header_t -{ - hb_reference_count_t ref_count; - hb_atomic_ptr_t user_data; - -#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)} - - private: - ASSERT_POD (); -}; - - -/* - * Object - */ - -template -static inline void hb_object_trace (const Type *obj, const char *function) -{ - DEBUG_MSG (OBJECT, (void *) obj, - "%s refcount=%d", - function, - obj ? obj->header.ref_count.get_relaxed () : 0); -} - -template -static inline Type *hb_object_create (void) -{ - Type *obj = (Type *) calloc (1, sizeof (Type)); - - if (unlikely (!obj)) - return obj; - - hb_object_init (obj); - hb_object_trace (obj, HB_FUNC); - return obj; -} -template -static inline void hb_object_init (Type *obj) -{ - obj->header.ref_count.init (); - obj->header.user_data.init (); -} -template -static inline bool hb_object_is_inert (const Type *obj) -{ - return unlikely (obj->header.ref_count.is_inert ()); -} -template -static inline bool hb_object_is_valid (const Type *obj) -{ - return likely (obj->header.ref_count.is_valid ()); -} -template -static inline Type *hb_object_reference (Type *obj) -{ - hb_object_trace (obj, HB_FUNC); - if (unlikely (!obj || hb_object_is_inert (obj))) - return obj; - assert (hb_object_is_valid (obj)); - obj->header.ref_count.inc (); - return obj; -} -template -static inline bool hb_object_destroy (Type *obj) -{ - hb_object_trace (obj, HB_FUNC); - if (unlikely (!obj || hb_object_is_inert (obj))) - return false; - assert (hb_object_is_valid (obj)); - if (obj->header.ref_count.dec () != 1) - return false; - - hb_object_fini (obj); - return true; -} -template -static inline void hb_object_fini (Type *obj) -{ - obj->header.ref_count.fini (); /* Do this before user_data */ - hb_user_data_array_t *user_data = obj->header.user_data.get (); - if (user_data) - { - user_data->fini (); - free (user_data); - } -} -template -static inline bool hb_object_set_user_data (Type *obj, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - if (unlikely (!obj || hb_object_is_inert (obj))) - return false; - assert (hb_object_is_valid (obj)); - -retry: - hb_user_data_array_t *user_data = obj->header.user_data.get (); - if (unlikely (!user_data)) - { - user_data = (hb_user_data_array_t *) calloc (sizeof (hb_user_data_array_t), 1); - if (unlikely (!user_data)) - return false; - user_data->init (); - if (unlikely (!obj->header.user_data.cmpexch (nullptr, user_data))) - { - user_data->fini (); - free (user_data); - goto retry; - } - } - - return user_data->set (key, data, destroy, replace); -} - -template -static inline void *hb_object_get_user_data (Type *obj, - hb_user_data_key_t *key) -{ - if (unlikely (!obj || hb_object_is_inert (obj))) - return nullptr; - assert (hb_object_is_valid (obj)); - hb_user_data_array_t *user_data = obj->header.user_data.get (); - if (!user_data) - return nullptr; - return user_data->get (key); -} - - -#endif /* HB_OBJECT_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh new file mode 100644 index 00000000000..ca85af691d9 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh @@ -0,0 +1,325 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 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. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OBJECT_HH +#define HB_OBJECT_HH + +#include "hb.hh" +#include "hb-atomic.hh" +#include "hb-mutex.hh" +#include "hb-vector.hh" + + +/* + * Lockable set + */ + +template +struct hb_lockable_set_t +{ + hb_vector_t items; + + inline void init (void) { items.init (); } + + template + 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 + 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 + 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 + 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 +#define HB_REFERENCE_COUNT_INIT {HB_ATOMIC_INT_INIT (HB_REFERENCE_COUNT_INERT_VALUE)} + +struct hb_reference_count_t +{ + mutable hb_atomic_int_t ref_count; + + inline void init (int v = 1) { ref_count.set_relaxed (v); } + inline int get_relaxed (void) const { return ref_count.get_relaxed (); } + inline int inc (void) const { return ref_count.inc (); } + inline int dec (void) const { return ref_count.dec (); } + inline void fini (void) { ref_count.set_relaxed (HB_REFERENCE_COUNT_POISON_VALUE); } + + inline bool is_inert (void) const { return ref_count.get_relaxed () == HB_REFERENCE_COUNT_INERT_VALUE; } + inline bool is_valid (void) const { return ref_count.get_relaxed () > 0; } +}; + + +/* user_data */ + +struct hb_user_data_array_t +{ + struct hb_user_data_item_t { + hb_user_data_key_t *key; + void *data; + hb_destroy_func_t destroy; + + inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } + inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; } + + void fini (void) { if (destroy) destroy (data); } + }; + + hb_mutex_t lock; + hb_lockable_set_t items; + + inline void init (void) { lock.init (); items.init (); } + + HB_INTERNAL bool set (hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + HB_INTERNAL void *get (hb_user_data_key_t *key); + + inline void fini (void) { items.fini (lock); lock.fini (); } +}; + + +/* + * Object header + */ + +struct hb_object_header_t +{ + hb_reference_count_t ref_count; + hb_atomic_ptr_t user_data; + +#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)} + + private: + ASSERT_POD (); +}; + + +/* + * Object + */ + +template +static inline void hb_object_trace (const Type *obj, const char *function) +{ + DEBUG_MSG (OBJECT, (void *) obj, + "%s refcount=%d", + function, + obj ? obj->header.ref_count.get_relaxed () : 0); +} + +template +static inline Type *hb_object_create (void) +{ + Type *obj = (Type *) calloc (1, sizeof (Type)); + + if (unlikely (!obj)) + return obj; + + hb_object_init (obj); + hb_object_trace (obj, HB_FUNC); + return obj; +} +template +static inline void hb_object_init (Type *obj) +{ + obj->header.ref_count.init (); + obj->header.user_data.init (); +} +template +static inline bool hb_object_is_inert (const Type *obj) +{ + return unlikely (obj->header.ref_count.is_inert ()); +} +template +static inline bool hb_object_is_valid (const Type *obj) +{ + return likely (obj->header.ref_count.is_valid ()); +} +template +static inline Type *hb_object_reference (Type *obj) +{ + hb_object_trace (obj, HB_FUNC); + if (unlikely (!obj || hb_object_is_inert (obj))) + return obj; + assert (hb_object_is_valid (obj)); + obj->header.ref_count.inc (); + return obj; +} +template +static inline bool hb_object_destroy (Type *obj) +{ + hb_object_trace (obj, HB_FUNC); + if (unlikely (!obj || hb_object_is_inert (obj))) + return false; + assert (hb_object_is_valid (obj)); + if (obj->header.ref_count.dec () != 1) + return false; + + hb_object_fini (obj); + return true; +} +template +static inline void hb_object_fini (Type *obj) +{ + obj->header.ref_count.fini (); /* Do this before user_data */ + hb_user_data_array_t *user_data = obj->header.user_data.get (); + if (user_data) + { + user_data->fini (); + free (user_data); + } +} +template +static inline bool hb_object_set_user_data (Type *obj, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + if (unlikely (!obj || hb_object_is_inert (obj))) + return false; + assert (hb_object_is_valid (obj)); + +retry: + hb_user_data_array_t *user_data = obj->header.user_data.get (); + if (unlikely (!user_data)) + { + user_data = (hb_user_data_array_t *) calloc (sizeof (hb_user_data_array_t), 1); + if (unlikely (!user_data)) + return false; + user_data->init (); + if (unlikely (!obj->header.user_data.cmpexch (nullptr, user_data))) + { + user_data->fini (); + free (user_data); + goto retry; + } + } + + return user_data->set (key, data, destroy, replace); +} + +template +static inline void *hb_object_get_user_data (Type *obj, + hb_user_data_key_t *key) +{ + if (unlikely (!obj || hb_object_is_inert (obj))) + return nullptr; + assert (hb_object_is_valid (obj)); + hb_user_data_array_t *user_data = obj->header.user_data.get (); + if (!user_data) + return nullptr; + return user_data->get (key); +} + + +#endif /* HB_OBJECT_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file-private.hh deleted file mode 100644 index d47bff66e78..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file-private.hh +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright © 2007,2008,2009 Red Hat, Inc. - * Copyright © 2012 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_OPEN_FILE_PRIVATE_HH -#define HB_OPEN_FILE_PRIVATE_HH - -#include "hb-open-type-private.hh" -#include "hb-ot-head-table.hh" - - -namespace OT { - - -/* - * - * The OpenType Font File - * - */ - - -/* - * Organization of an OpenType Font - */ - -struct OpenTypeFontFile; -struct OffsetTable; -struct TTCHeader; - - -typedef struct TableRecord -{ - int cmp (Tag t) const - { return -t.cmp (tag); } - - static int cmp (const void *pa, const void *pb) - { - const TableRecord *a = (const TableRecord *) pa; - const TableRecord *b = (const TableRecord *) pb; - return b->cmp (a->tag); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - Tag tag; /* 4-byte identifier. */ - CheckSum checkSum; /* CheckSum for this table. */ - Offset32 offset; /* Offset from beginning of TrueType font - * file. */ - HBUINT32 length; /* Length of this table. */ - public: - DEFINE_SIZE_STATIC (16); -} OpenTypeTable; - -typedef struct OffsetTable -{ - friend struct OpenTypeFontFile; - - inline unsigned int get_table_count (void) const - { return tables.len; } - inline const TableRecord& get_table (unsigned int i) const - { - return tables[i]; - } - inline unsigned int get_table_tags (unsigned int start_offset, - unsigned int *table_count, /* IN/OUT */ - hb_tag_t *table_tags /* OUT */) const - { - if (table_count) - { - if (start_offset >= tables.len) - *table_count = 0; - else - *table_count = MIN (*table_count, tables.len - start_offset); - - const TableRecord *sub_tables = tables.arrayZ + start_offset; - unsigned int count = *table_count; - for (unsigned int i = 0; i < count; i++) - table_tags[i] = sub_tables[i].tag; - } - return tables.len; - } - inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const - { - Tag t; - t.set (tag); - /* Linear-search for small tables to work around fonts with unsorted - * table list. */ - int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t); - if (table_index) - *table_index = i == -1 ? Index::NOT_FOUND_INDEX : (unsigned int) i; - return i != -1; - } - inline const TableRecord& get_table_by_tag (hb_tag_t tag) const - { - unsigned int table_index; - find_table_index (tag, &table_index); - return get_table (table_index); - } - - public: - - inline bool serialize (hb_serialize_context_t *c, - hb_tag_t sfnt_tag, - Supplier &tags, - Supplier &blobs, - unsigned int table_count) - { - TRACE_SERIALIZE (this); - /* Alloc 12 for the OTHeader. */ - if (unlikely (!c->extend_min (*this))) return_trace (false); - /* Write sfntVersion (bytes 0..3). */ - sfnt_version.set (sfnt_tag); - /* Take space for numTables, searchRange, entrySelector, RangeShift - * and the TableRecords themselves. */ - if (unlikely (!tables.serialize (c, table_count))) return_trace (false); - - const char *dir_end = (const char *) c->head; - HBUINT32 *checksum_adjustment = nullptr; - - /* Write OffsetTables, alloc for and write actual table blobs. */ - for (unsigned int i = 0; i < table_count; i++) - { - TableRecord &rec = tables.arrayZ[i]; - hb_blob_t *blob = blobs[i]; - rec.tag.set (tags[i]); - rec.length.set (hb_blob_get_length (blob)); - rec.offset.serialize (c, this); - - /* Allocate room for the table and copy it. */ - char *start = (char *) c->allocate_size (rec.length); - if (unlikely (!start)) {return false;} - - memcpy (start, hb_blob_get_data (blob, nullptr), rec.length); - - /* 4-byte allignment. */ - if (rec.length % 4) - c->allocate_size (4 - rec.length % 4); - const char *end = (const char *) c->head; - - if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size) - { - head *h = (head *) start; - checksum_adjustment = &h->checkSumAdjustment; - checksum_adjustment->set (0); - } - - rec.checkSum.set_for_data (start, end - start); - } - tags += table_count; - blobs += table_count; - - tables.qsort (); - - if (checksum_adjustment) - { - CheckSum checksum; - - /* The following line is a slower version of the following block. */ - //checksum.set_for_data (this, (const char *) c->head - (const char *) this); - checksum.set_for_data (this, dir_end - (const char *) this); - for (unsigned int i = 0; i < table_count; i++) - { - TableRecord &rec = tables.arrayZ[i]; - checksum.set (checksum + rec.checkSum); - } - - checksum_adjustment->set (0xB1B0AFBAu - checksum); - } - - return_trace (true); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && tables.sanitize (c)); - } - - protected: - Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ - BinSearchArrayOf - tables; - public: - DEFINE_SIZE_ARRAY (12, tables); -} OpenTypeFontFace; - - -/* - * TrueType Collections - */ - -struct TTCHeaderVersion1 -{ - friend struct TTCHeader; - - inline unsigned int get_face_count (void) const { return table.len; } - inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (table.sanitize (c, this)); - } - - protected: - Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion<>version; /* Version of the TTC Header (1.0), - * 0x00010000u */ - LArrayOf > - table; /* Array of offsets to the OffsetTable for each font - * from the beginning of the file */ - public: - DEFINE_SIZE_ARRAY (12, table); -}; - -struct TTCHeader -{ - friend struct OpenTypeFontFile; - - private: - - inline unsigned int get_face_count (void) const - { - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return u.version1.get_face_count (); - default:return 0; - } - } - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return u.version1.get_face (i); - default:return Null(OpenTypeFontFace); - } - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!u.header.version.sanitize (c))) return_trace (false); - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return_trace (u.version1.sanitize (c)); - default:return_trace (true); - } - } - - protected: - union { - struct { - Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion<>version; /* Version of the TTC Header (1.0 or 2.0), - * 0x00010000u or 0x00020000u */ - } header; - TTCHeaderVersion1 version1; - } u; -}; - -/* - * Mac Resource Fork - */ - -struct ResourceRefItem -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - // actual data sanitization is done on ResourceForkHeader sanitizer - return_trace (likely (c->check_struct (this))); - } - - HBINT16 id; /* Resource ID, is really should be signed? */ - HBINT16 nameOffset; /* Offset from beginning of resource name list - * to resource name, minus means there is no */ - HBUINT8 attr; /* Resource attributes */ - HBUINT24 dataOffset; /* Offset from beginning of resource data to - * data for this resource */ - HBUINT32 reserved; /* Reserved for handle to resource */ - public: - DEFINE_SIZE_STATIC (12); -}; - -struct ResourceTypeItem -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - // RefList sanitization is done on ResourceMap sanitizer - return_trace (likely (c->check_struct (this))); - } - - inline unsigned int get_resource_count () const - { - return numRes + 1; - } - - inline bool is_sfnt () const - { - return type == HB_TAG ('s','f','n','t'); - } - - inline const ResourceRefItem& get_ref_item (const void *base, - unsigned int i) const - { - return (base+refList)[i]; - } - - protected: - Tag type; /* Resource type */ - HBUINT16 numRes; /* Number of resource this type in map minus 1 */ - OffsetTo > - refList; /* Offset from beginning of resource type list - * to reference list for this type */ - public: - DEFINE_SIZE_STATIC (8); -}; - -struct ResourceMap -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) - return_trace (false); - for (unsigned int i = 0; i < get_types_count (); ++i) - { - const ResourceTypeItem& type = get_type (i); - if (unlikely (!type.sanitize (c))) - return_trace (false); - for (unsigned int j = 0; j < type.get_resource_count (); ++j) - if (unlikely (!get_ref_item (type, j).sanitize (c))) - return_trace (false); - } - return_trace (true); - } - - inline const ResourceTypeItem& get_type (unsigned int i) const - { - // Why offset from the second byte of the object? I'm not sure - return ((&reserved[2])+typeList)[i]; - } - - inline unsigned int get_types_count () const - { - return nTypes + 1; - } - - inline const ResourceRefItem &get_ref_item (const ResourceTypeItem &type, - unsigned int i) const - { - return type.get_ref_item (&(this+typeList), i); - } - - inline const PString& get_name (const ResourceRefItem &item, - unsigned int i) const - { - if (item.nameOffset == -1) - return Null (PString); - - return StructAtOffset (this, nameList + item.nameOffset); - } - - protected: - HBUINT8 reserved[16]; /* Reserved for copy of resource header */ - LOffsetTo - reserved1; /* Reserved for handle to next resource map */ - HBUINT16 reserved2; /* Reserved for file reference number */ - HBUINT16 attr; /* Resource fork attribute */ - OffsetTo > - typeList; /* Offset from beginning of map to - * resource type list */ - HBUINT16 nameList; /* Offset from beginning of map to - * resource name list */ - HBUINT16 nTypes; /* Number of types in the map minus 1 */ - public: - DEFINE_SIZE_STATIC (30); -}; - -struct ResourceForkHeader -{ - inline unsigned int get_face_count () const - { - const ResourceMap &resource_map = this+map; - for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) - { - const ResourceTypeItem& type = resource_map.get_type (i); - if (type.is_sfnt ()) - return type.get_resource_count (); - } - return 0; - } - - inline const LArrayOf& get_data (const ResourceTypeItem& type, - unsigned int idx) const - { - const ResourceMap &resource_map = this+map; - unsigned int offset = dataOffset; - offset += resource_map.get_ref_item (type, idx).dataOffset; - return StructAtOffset > (this, offset); - } - - inline const OpenTypeFontFace& get_face (unsigned int idx) const - { - const ResourceMap &resource_map = this+map; - for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) - { - const ResourceTypeItem& type = resource_map.get_type (i); - if (type.is_sfnt () && idx < type.get_resource_count ()) - return (OpenTypeFontFace&) get_data (type, idx).arrayZ; - } - return Null (OpenTypeFontFace); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) - return_trace (false); - - const ResourceMap &resource_map = this+map; - if (unlikely (!resource_map.sanitize (c))) - return_trace (false); - - for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) - { - const ResourceTypeItem& type = resource_map.get_type (i); - for (unsigned int j = 0; j < type.get_resource_count (); ++j) - { - const LArrayOf& data = get_data (type, j); - if (unlikely (!(data.sanitize (c) && - ((OpenTypeFontFace&) data.arrayZ).sanitize (c)))) - return_trace (false); - } - } - - return_trace (true); - } - - protected: - HBUINT32 dataOffset; /* Offset from beginning of resource fork - * to resource data */ - LOffsetTo - map; /* Offset from beginning of resource fork - * to resource map */ - HBUINT32 dataLen; /* Length of resource data */ - HBUINT32 mapLen; /* Length of resource map */ - public: - DEFINE_SIZE_STATIC (16); -}; - -/* - * OpenType Font File - */ - -struct OpenTypeFontFile -{ - enum { - CFFTag = HB_TAG ('O','T','T','O'), /* OpenType with Postscript outlines */ - TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ), /* OpenType with TrueType outlines */ - TTCTag = HB_TAG ('t','t','c','f'), /* TrueType Collection */ - DFontTag = HB_TAG ( 0 , 0 , 1 , 0 ), /* DFont Mac Resource Fork */ - TrueTag = HB_TAG ('t','r','u','e'), /* Obsolete Apple TrueType */ - Typ1Tag = HB_TAG ('t','y','p','1') /* Obsolete Apple Type1 font in SFNT container */ - }; - - inline hb_tag_t get_tag (void) const { return u.tag; } - - inline unsigned int get_face_count (void) const - { - switch (u.tag) { - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return 1; - case TTCTag: return u.ttcHeader.get_face_count (); -// case DFontTag: return u.rfHeader.get_face_count (); - default: return 0; - } - } - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - switch (u.tag) { - /* Note: for non-collection SFNT data we ignore index. This is because - * Apple dfont container is a container of SFNT's. So each SFNT is a - * non-TTC, but the index is more than zero. */ - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return u.fontFace; - case TTCTag: return u.ttcHeader.get_face (i); -// case DFontTag: return u.rfHeader.get_face (i); - default: return Null(OpenTypeFontFace); - } - } - - inline bool serialize_single (hb_serialize_context_t *c, - hb_tag_t sfnt_tag, - Supplier &tags, - Supplier &blobs, - unsigned int table_count) - { - TRACE_SERIALIZE (this); - assert (sfnt_tag != TTCTag); - if (unlikely (!c->extend_min (*this))) return_trace (false); - return_trace (u.fontFace.serialize (c, sfnt_tag, tags, blobs, table_count)); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!u.tag.sanitize (c))) return_trace (false); - switch (u.tag) { - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return_trace (u.fontFace.sanitize (c)); - case TTCTag: return_trace (u.ttcHeader.sanitize (c)); -// case DFontTag: return_trace (u.rfHeader.sanitize (c)); - default: return_trace (true); - } - } - - protected: - union { - Tag tag; /* 4-byte identifier. */ - OpenTypeFontFace fontFace; - TTCHeader ttcHeader; - ResourceForkHeader rfHeader; - } u; - public: - DEFINE_SIZE_UNION (4, tag); -}; - - -} /* namespace OT */ - - -#endif /* HB_OPEN_FILE_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh new file mode 100644 index 00000000000..d3b748602ba --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh @@ -0,0 +1,567 @@ +/* + * Copyright © 2007,2008,2009 Red Hat, Inc. + * Copyright © 2012 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_OPEN_FILE_HH +#define HB_OPEN_FILE_HH + +#include "hb-open-type.hh" +#include "hb-ot-head-table.hh" + + +namespace OT { + + +/* + * + * The OpenType Font File + * + */ + + +/* + * Organization of an OpenType Font + */ + +struct OpenTypeFontFile; +struct OffsetTable; +struct TTCHeader; + + +typedef struct TableRecord +{ + int cmp (Tag t) const + { return -t.cmp (tag); } + + static int cmp (const void *pa, const void *pb) + { + const TableRecord *a = (const TableRecord *) pa; + const TableRecord *b = (const TableRecord *) pb; + return b->cmp (a->tag); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + Tag tag; /* 4-byte identifier. */ + CheckSum checkSum; /* CheckSum for this table. */ + Offset32 offset; /* Offset from beginning of TrueType font + * file. */ + HBUINT32 length; /* Length of this table. */ + public: + DEFINE_SIZE_STATIC (16); +} OpenTypeTable; + +typedef struct OffsetTable +{ + friend struct OpenTypeFontFile; + + inline unsigned int get_table_count (void) const + { return tables.len; } + inline const TableRecord& get_table (unsigned int i) const + { + return tables[i]; + } + inline unsigned int get_table_tags (unsigned int start_offset, + unsigned int *table_count, /* IN/OUT */ + hb_tag_t *table_tags /* OUT */) const + { + if (table_count) + { + if (start_offset >= tables.len) + *table_count = 0; + else + *table_count = MIN (*table_count, tables.len - start_offset); + + const TableRecord *sub_tables = tables.arrayZ + start_offset; + unsigned int count = *table_count; + for (unsigned int i = 0; i < count; i++) + table_tags[i] = sub_tables[i].tag; + } + return tables.len; + } + inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const + { + Tag t; + t.set (tag); + /* Linear-search for small tables to work around fonts with unsorted + * table list. */ + int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t); + if (table_index) + *table_index = i == -1 ? (unsigned) Index::NOT_FOUND_INDEX : (unsigned) i; + return i != -1; + } + inline const TableRecord& get_table_by_tag (hb_tag_t tag) const + { + unsigned int table_index; + find_table_index (tag, &table_index); + return get_table (table_index); + } + + public: + + inline bool serialize (hb_serialize_context_t *c, + hb_tag_t sfnt_tag, + Supplier &tags, + Supplier &blobs, + unsigned int table_count) + { + TRACE_SERIALIZE (this); + /* Alloc 12 for the OTHeader. */ + if (unlikely (!c->extend_min (*this))) return_trace (false); + /* Write sfntVersion (bytes 0..3). */ + sfnt_version.set (sfnt_tag); + /* Take space for numTables, searchRange, entrySelector, RangeShift + * and the TableRecords themselves. */ + if (unlikely (!tables.serialize (c, table_count))) return_trace (false); + + const char *dir_end = (const char *) c->head; + HBUINT32 *checksum_adjustment = nullptr; + + /* Write OffsetTables, alloc for and write actual table blobs. */ + for (unsigned int i = 0; i < table_count; i++) + { + TableRecord &rec = tables.arrayZ[i]; + hb_blob_t *blob = blobs[i]; + rec.tag.set (tags[i]); + rec.length.set (hb_blob_get_length (blob)); + rec.offset.serialize (c, this); + + /* Allocate room for the table and copy it. */ + char *start = (char *) c->allocate_size (rec.length); + if (unlikely (!start)) {return false;} + + memcpy (start, hb_blob_get_data (blob, nullptr), rec.length); + + /* 4-byte allignment. */ + c->align (4); + const char *end = (const char *) c->head; + + if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size) + { + head *h = (head *) start; + checksum_adjustment = &h->checkSumAdjustment; + checksum_adjustment->set (0); + } + + rec.checkSum.set_for_data (start, end - start); + } + tags += table_count; + blobs += table_count; + + tables.qsort (); + + if (checksum_adjustment) + { + CheckSum checksum; + + /* The following line is a slower version of the following block. */ + //checksum.set_for_data (this, (const char *) c->head - (const char *) this); + checksum.set_for_data (this, dir_end - (const char *) this); + for (unsigned int i = 0; i < table_count; i++) + { + TableRecord &rec = tables.arrayZ[i]; + checksum.set (checksum + rec.checkSum); + } + + checksum_adjustment->set (0xB1B0AFBAu - checksum); + } + + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && tables.sanitize (c)); + } + + protected: + Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ + BinSearchArrayOf + tables; + public: + DEFINE_SIZE_ARRAY (12, tables); +} OpenTypeFontFace; + + +/* + * TrueType Collections + */ + +struct TTCHeaderVersion1 +{ + friend struct TTCHeader; + + inline unsigned int get_face_count (void) const { return table.len; } + inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (table.sanitize (c, this)); + } + + protected: + Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ + FixedVersion<>version; /* Version of the TTC Header (1.0), + * 0x00010000u */ + LArrayOf > + table; /* Array of offsets to the OffsetTable for each font + * from the beginning of the file */ + public: + DEFINE_SIZE_ARRAY (12, table); +}; + +struct TTCHeader +{ + friend struct OpenTypeFontFile; + + private: + + inline unsigned int get_face_count (void) const + { + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return u.version1.get_face_count (); + default:return 0; + } + } + inline const OpenTypeFontFace& get_face (unsigned int i) const + { + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return u.version1.get_face (i); + default:return Null(OpenTypeFontFace); + } + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!u.header.version.sanitize (c))) return_trace (false); + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return_trace (u.version1.sanitize (c)); + default:return_trace (true); + } + } + + protected: + union { + struct { + Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ + FixedVersion<>version; /* Version of the TTC Header (1.0 or 2.0), + * 0x00010000u or 0x00020000u */ + } header; + TTCHeaderVersion1 version1; + } u; +}; + +/* + * Mac Resource Fork + */ + +struct ResourceRefItem +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + // actual data sanitization is done on ResourceForkHeader sanitizer + return_trace (likely (c->check_struct (this))); + } + + HBINT16 id; /* Resource ID, is really should be signed? */ + HBINT16 nameOffset; /* Offset from beginning of resource name list + * to resource name, minus means there is no */ + HBUINT8 attr; /* Resource attributes */ + HBUINT24 dataOffset; /* Offset from beginning of resource data to + * data for this resource */ + HBUINT32 reserved; /* Reserved for handle to resource */ + public: + DEFINE_SIZE_STATIC (12); +}; + +struct ResourceTypeItem +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + // RefList sanitization is done on ResourceMap sanitizer + return_trace (likely (c->check_struct (this))); + } + + inline unsigned int get_resource_count () const + { + return numRes + 1; + } + + inline bool is_sfnt () const + { + return type == HB_TAG ('s','f','n','t'); + } + + inline const ResourceRefItem& get_ref_item (const void *base, + unsigned int i) const + { + return (base+refList)[i]; + } + + protected: + Tag type; /* Resource type */ + HBUINT16 numRes; /* Number of resource this type in map minus 1 */ + OffsetTo > + refList; /* Offset from beginning of resource type list + * to reference list for this type */ + public: + DEFINE_SIZE_STATIC (8); +}; + +struct ResourceMap +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) + return_trace (false); + for (unsigned int i = 0; i < get_types_count (); ++i) + { + const ResourceTypeItem& type = get_type (i); + if (unlikely (!type.sanitize (c))) + return_trace (false); + for (unsigned int j = 0; j < type.get_resource_count (); ++j) + if (unlikely (!get_ref_item (type, j).sanitize (c))) + return_trace (false); + } + return_trace (true); + } + + inline const ResourceTypeItem& get_type (unsigned int i) const + { + // Why offset from the second byte of the object? I'm not sure + return ((&reserved[2])+typeList)[i]; + } + + inline unsigned int get_types_count () const + { + return nTypes + 1; + } + + inline const ResourceRefItem &get_ref_item (const ResourceTypeItem &type, + unsigned int i) const + { + return type.get_ref_item (&(this+typeList), i); + } + + inline const PString& get_name (const ResourceRefItem &item, + unsigned int i) const + { + if (item.nameOffset == -1) + return Null (PString); + + return StructAtOffset (this, nameList + item.nameOffset); + } + + protected: + HBUINT8 reserved[16]; /* Reserved for copy of resource header */ + LOffsetTo + reserved1; /* Reserved for handle to next resource map */ + HBUINT16 reserved2; /* Reserved for file reference number */ + HBUINT16 attr; /* Resource fork attribute */ + OffsetTo > + typeList; /* Offset from beginning of map to + * resource type list */ + HBUINT16 nameList; /* Offset from beginning of map to + * resource name list */ + HBUINT16 nTypes; /* Number of types in the map minus 1 */ + public: + DEFINE_SIZE_STATIC (30); +}; + +struct ResourceForkHeader +{ + inline unsigned int get_face_count () const + { + const ResourceMap &resource_map = this+map; + for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) + { + const ResourceTypeItem& type = resource_map.get_type (i); + if (type.is_sfnt ()) + return type.get_resource_count (); + } + return 0; + } + + inline const LArrayOf& get_data (const ResourceTypeItem& type, + unsigned int idx) const + { + const ResourceMap &resource_map = this+map; + unsigned int offset = dataOffset; + offset += resource_map.get_ref_item (type, idx).dataOffset; + return StructAtOffset > (this, offset); + } + + inline const OpenTypeFontFace& get_face (unsigned int idx) const + { + const ResourceMap &resource_map = this+map; + for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) + { + const ResourceTypeItem& type = resource_map.get_type (i); + if (type.is_sfnt () && idx < type.get_resource_count ()) + return (OpenTypeFontFace&) get_data (type, idx).arrayZ; + } + return Null (OpenTypeFontFace); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) + return_trace (false); + + const ResourceMap &resource_map = this+map; + if (unlikely (!resource_map.sanitize (c))) + return_trace (false); + + for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) + { + const ResourceTypeItem& type = resource_map.get_type (i); + for (unsigned int j = 0; j < type.get_resource_count (); ++j) + { + const LArrayOf& data = get_data (type, j); + if (unlikely (!(data.sanitize (c) && + ((OpenTypeFontFace&) data.arrayZ).sanitize (c)))) + return_trace (false); + } + } + + return_trace (true); + } + + protected: + HBUINT32 dataOffset; /* Offset from beginning of resource fork + * to resource data */ + LOffsetTo + map; /* Offset from beginning of resource fork + * to resource map */ + HBUINT32 dataLen; /* Length of resource data */ + HBUINT32 mapLen; /* Length of resource map */ + public: + DEFINE_SIZE_STATIC (16); +}; + +/* + * OpenType Font File + */ + +struct OpenTypeFontFile +{ + enum { + CFFTag = HB_TAG ('O','T','T','O'), /* OpenType with Postscript outlines */ + TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ), /* OpenType with TrueType outlines */ + TTCTag = HB_TAG ('t','t','c','f'), /* TrueType Collection */ + DFontTag = HB_TAG ( 0 , 0 , 1 , 0 ), /* DFont Mac Resource Fork */ + TrueTag = HB_TAG ('t','r','u','e'), /* Obsolete Apple TrueType */ + Typ1Tag = HB_TAG ('t','y','p','1') /* Obsolete Apple Type1 font in SFNT container */ + }; + + inline hb_tag_t get_tag (void) const { return u.tag; } + + inline unsigned int get_face_count (void) const + { + switch (u.tag) { + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return 1; + case TTCTag: return u.ttcHeader.get_face_count (); +// case DFontTag: return u.rfHeader.get_face_count (); + default: return 0; + } + } + inline const OpenTypeFontFace& get_face (unsigned int i) const + { + switch (u.tag) { + /* Note: for non-collection SFNT data we ignore index. This is because + * Apple dfont container is a container of SFNT's. So each SFNT is a + * non-TTC, but the index is more than zero. */ + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return u.fontFace; + case TTCTag: return u.ttcHeader.get_face (i); +// case DFontTag: return u.rfHeader.get_face (i); + default: return Null(OpenTypeFontFace); + } + } + + inline bool serialize_single (hb_serialize_context_t *c, + hb_tag_t sfnt_tag, + Supplier &tags, + Supplier &blobs, + unsigned int table_count) + { + TRACE_SERIALIZE (this); + assert (sfnt_tag != TTCTag); + if (unlikely (!c->extend_min (*this))) return_trace (false); + return_trace (u.fontFace.serialize (c, sfnt_tag, tags, blobs, table_count)); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!u.tag.sanitize (c))) return_trace (false); + switch (u.tag) { + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return_trace (u.fontFace.sanitize (c)); + case TTCTag: return_trace (u.ttcHeader.sanitize (c)); +// case DFontTag: return_trace (u.rfHeader.sanitize (c)); + default: return_trace (true); + } + } + + protected: + union { + Tag tag; /* 4-byte identifier. */ + OpenTypeFontFace fontFace; + TTCHeader ttcHeader; + ResourceForkHeader rfHeader; + } u; + public: + DEFINE_SIZE_UNION (4, tag); +}; + + +} /* namespace OT */ + + +#endif /* HB_OPEN_FILE_HH */ 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 deleted file mode 100644 index 5580565f118..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type-private.hh +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Copyright © 2007,2008,2009,2010 Red Hat, Inc. - * Copyright © 2012 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_OPEN_TYPE_PRIVATE_HH -#define HB_OPEN_TYPE_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-blob-private.hh" -#include "hb-face-private.hh" -#include "hb-machinery-private.hh" - - -namespace OT { - - -/* - * - * The OpenType Font File: Data Types - */ - - -/* "The following data types are used in the OpenType font file. - * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */ - -/* - * Int types - */ - -/* Integer types in big-endian order and no alignment requirement */ -template -struct IntType -{ - inline void set (Type i) { v.set (i); } - inline operator Type(void) const { return v; } - inline bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } - inline bool operator != (const IntType &o) const { return !(*this == o); } - static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } - template - inline int cmp (Type2 a) const - { - Type b = v; - if (sizeof (Type) < sizeof (int) && sizeof (Type2) < sizeof (int)) - return (int) a - (int) b; - else - return a < b ? -1 : a == b ? 0 : +1; - } - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this))); - } - protected: - BEInt v; - public: - DEFINE_SIZE_STATIC (Size); -}; - -typedef IntType HBUINT8; /* 8-bit unsigned integer. */ -typedef IntType HBINT8; /* 8-bit signed integer. */ -typedef IntType HBUINT16; /* 16-bit unsigned integer. */ -typedef IntType HBINT16; /* 16-bit signed integer. */ -typedef IntType HBUINT32; /* 32-bit unsigned integer. */ -typedef IntType HBINT32; /* 32-bit signed integer. */ -typedef IntType HBUINT24; /* 24-bit unsigned integer. */ - -/* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */ -typedef HBINT16 FWORD; - -/* 16-bit unsigned integer (HBUINT16) that describes a quantity in FUnits. */ -typedef HBUINT16 UFWORD; - -/* 16-bit signed fixed number with the low 14 bits of fraction (2.14). */ -struct F2DOT14 : HBINT16 -{ - // 16384 means 1<<14 - inline float to_float (void) const { return ((int32_t) v) / 16384.f; } - inline void set_float (float f) { v.set (round (f * 16384.f)); } - public: - DEFINE_SIZE_STATIC (2); -}; - -/* 32-bit signed fixed-point number (16.16). */ -struct Fixed : HBINT32 -{ - // 65536 means 1<<16 - inline float to_float (void) const { return ((int32_t) v) / 65536.f; } - inline void set_float (float f) { v.set (round (f * 65536.f)); } - public: - DEFINE_SIZE_STATIC (4); -}; - -/* Date represented in number of seconds since 12:00 midnight, January 1, - * 1904. The value is represented as a signed 64-bit integer. */ -struct LONGDATETIME -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this))); - } - protected: - HBINT32 major; - HBUINT32 minor; - public: - DEFINE_SIZE_STATIC (8); -}; - -/* Array of four uint8s (length = 32 bits) used to identify a script, language - * system, feature, or baseline */ -struct Tag : HBUINT32 -{ - /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ - inline operator const char* (void) const { return reinterpret_cast (&this->v); } - inline operator char* (void) { return reinterpret_cast (&this->v); } - public: - DEFINE_SIZE_STATIC (4); -}; - -/* Glyph index number, same as uint16 (length = 16 bits) */ -typedef HBUINT16 GlyphID; - -/* Name-table index, same as uint16 (length = 16 bits) */ -typedef HBUINT16 NameID; - -/* Script/language-system/feature index */ -struct Index : HBUINT16 { - static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; -}; -DECLARE_NULL_NAMESPACE_BYTES (OT, Index); - -/* Offset, Null offset = 0 */ -template -struct Offset : Type -{ - inline bool is_null (void) const { return 0 == *this; } - - inline void *serialize (hb_serialize_context_t *c, const void *base) - { - void *t = c->start_embed (); - this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ - return t; - } - - public: - DEFINE_SIZE_STATIC (sizeof(Type)); -}; - -typedef Offset Offset16; -typedef Offset Offset32; - - -/* CheckSum */ -struct CheckSum : HBUINT32 -{ - /* This is reference implementation from the spec. */ - static inline uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length) - { - uint32_t Sum = 0L; - assert (0 == (Length & 3)); - const HBUINT32 *EndPtr = Table + Length / HBUINT32::static_size; - - while (Table < EndPtr) - Sum += *Table++; - return Sum; - } - - /* Note: data should be 4byte aligned and have 4byte padding at the end. */ - inline void set_for_data (const void *data, unsigned int length) - { set (CalcTableChecksum ((const HBUINT32 *) data, length)); } - - public: - DEFINE_SIZE_STATIC (4); -}; - - -/* - * Version Numbers - */ - -template -struct FixedVersion -{ - inline uint32_t to_int (void) const { return (major << (sizeof(FixedType) * 8)) + minor; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - FixedType major; - FixedType minor; - public: - DEFINE_SIZE_STATIC (2 * sizeof(FixedType)); -}; - - -/* - * Template subclasses of Offset that do the dereferencing. - * Use: (base+offset) - */ - -template -struct OffsetTo : Offset -{ - inline const Type& operator () (const void *base) const - { - unsigned int offset = *this; - if (unlikely (!offset)) return Null(Type); - return StructAtOffset (base, offset); - } - inline Type& operator () (void *base) const - { - unsigned int offset = *this; - if (unlikely (!offset)) return Crap(Type); - return StructAtOffset (base, offset); - } - - inline Type& serialize (hb_serialize_context_t *c, const void *base) - { - return * (Type *) Offset::serialize (c, base); - } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) return_trace (false); - unsigned int offset = *this; - if (unlikely (!offset)) return_trace (true); - if (unlikely (!c->check_range (base, offset))) return_trace (false); - const Type &obj = StructAtOffset (base, offset); - return_trace (likely (obj.sanitize (c)) || neuter (c)); - } - template - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) return_trace (false); - unsigned int offset = *this; - if (unlikely (!offset)) return_trace (true); - if (unlikely (!c->check_range (base, offset))) return_trace (false); - const Type &obj = StructAtOffset (base, offset); - return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); - } - - /* Set the offset to Null */ - inline bool neuter (hb_sanitize_context_t *c) const { - return c->try_set (this, 0); - } - DEFINE_SIZE_STATIC (sizeof(OffsetType)); -}; -template struct LOffsetTo : OffsetTo {}; -template -static inline const Type& operator + (const Base &base, const OffsetTo &offset) { return offset (base); } -template -static inline Type& operator + (Base &base, OffsetTo &offset) { return offset (base); } - - -/* - * Array Types - */ - -/* TODO Use it in ArrayOf, HeadlessArrayOf, and other places around the code base?? */ -template -struct UnsizedArrayOf -{ - inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } - inline Type& operator [] (unsigned int i) { return arrayZ[i]; } - - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && arrayZ[0].sanitize (c)); - - return_trace (true); - } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base))) - return_trace (false); - return_trace (true); - } - template - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); - return_trace (true); - } - - inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - return_trace (c->check_array (arrayZ, arrayZ[0].static_size, count)); - } - - public: - Type arrayZ[VAR]; - public: - DEFINE_SIZE_ARRAY (0, arrayZ); -}; - -/* Unsized array of offset's */ -template -struct UnsizedOffsetArrayOf : UnsizedArrayOf > {}; - -/* Unsized array of offsets relative to the beginning of the array itself. */ -template -struct UnsizedOffsetListOf : UnsizedOffsetArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - return this+this->arrayZ[i]; - } - - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - return_trace ((UnsizedOffsetArrayOf::sanitize (c, count, this))); - } - template - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const - { - TRACE_SANITIZE (this); - return_trace ((UnsizedOffsetArrayOf::sanitize (c, count, this, user_data))); - } -}; - -/* An array with a number of elements. */ -template -struct ArrayOf -{ - const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const - { - unsigned int count = len; - if (unlikely (start_offset > count)) - count = 0; - else - count -= start_offset; - count = MIN (count, *pcount); - *pcount = count; - return arrayZ + start_offset; - } - - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len)) return Null(Type); - return arrayZ[i]; - } - inline Type& operator [] (unsigned int i) - { - if (unlikely (i >= len)) return Crap(Type); - return arrayZ[i]; - } - inline unsigned int get_size (void) const - { return len.static_size + len * Type::static_size; } - - inline bool serialize (hb_serialize_context_t *c, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - len.set (items_len); /* TODO(serialize) Overflow? */ - if (unlikely (!c->extend (*this))) return_trace (false); - return_trace (true); - } - - inline bool serialize (hb_serialize_context_t *c, - Supplier &items, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!serialize (c, items_len))) return_trace (false); - for (unsigned int i = 0; i < items_len; i++) - arrayZ[i] = items[i]; - items += items_len; - return_trace (true); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && arrayZ[0].sanitize (c)); - - return_trace (true); - } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base))) - return_trace (false); - return_trace (true); - } - template - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); - return_trace (true); - } - - template - inline int lsearch (const SearchType &x) const - { - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!this->arrayZ[i].cmp (x)) - return i; - return -1; - } - - inline void qsort (void) - { - ::qsort (arrayZ, len, sizeof (Type), Type::cmp); - } - - private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (len.sanitize (c) && c->check_array (arrayZ, Type::static_size, len)); - } - - public: - LenType len; - Type arrayZ[VAR]; - public: - DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); -}; -template struct LArrayOf : ArrayOf {}; -typedef ArrayOf PString; - -/* Array of Offset's */ -template -struct OffsetArrayOf : ArrayOf > {}; - -/* Array of offsets relative to the beginning of the array itself. */ -template -struct OffsetListOf : OffsetArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= this->len)) return Null(Type); - return this+this->arrayZ[i]; - } - inline const Type& operator [] (unsigned int i) - { - if (unlikely (i >= this->len)) return Crap(Type); - return this+this->arrayZ[i]; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (OffsetArrayOf::sanitize (c, this)); - } - template - inline bool sanitize (hb_sanitize_context_t *c, T user_data) const - { - TRACE_SANITIZE (this); - return_trace (OffsetArrayOf::sanitize (c, this, user_data)); - } -}; - -/* An array starting at second element. */ -template -struct HeadlessArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len || !i)) return Null(Type); - return arrayZ[i-1]; - } - inline Type& operator [] (unsigned int i) - { - if (unlikely (i >= len || !i)) return Crap(Type); - return arrayZ[i-1]; - } - inline unsigned int get_size (void) const - { return len.static_size + (len ? len - 1 : 0) * Type::static_size; } - - inline bool serialize (hb_serialize_context_t *c, - Supplier &items, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - len.set (items_len); /* TODO(serialize) Overflow? */ - if (unlikely (!items_len)) return_trace (true); - if (unlikely (!c->extend (*this))) return_trace (false); - for (unsigned int i = 0; i < items_len - 1; i++) - arrayZ[i] = items[i]; - items += items_len - 1; - return_trace (true); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && arrayZ[0].sanitize (c)); - - return_trace (true); - } - - private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (len.sanitize (c) && - (!len || c->check_array (arrayZ, Type::static_size, len - 1))); - } - - public: - LenType len; - Type arrayZ[VAR]; - public: - DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); -}; - -/* An array with sorted elements. Supports binary searching. */ -template -struct SortedArrayOf : ArrayOf -{ - template - inline int bsearch (const SearchType &x) const - { - /* Hand-coded bsearch here since this is in the hot inner loop. */ - const Type *arr = this->arrayZ; - int min = 0, max = (int) this->len - 1; - while (min <= max) - { - int mid = (min + max) / 2; - int c = arr[mid].cmp (x); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - return mid; - } - return -1; - } -}; - -/* Binary-search arrays */ -struct BinSearchHeader -{ - inline operator uint32_t (void) const { return len; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - inline void set (unsigned int v) - { - len.set (v); - assert (len == v); - entrySelector.set (MAX (1u, hb_bit_storage (v)) - 1); - searchRange.set (16 * (1u << entrySelector)); - rangeShift.set (v * 16 > searchRange - ? 16 * v - searchRange - : 0); - } - - protected: - HBUINT16 len; - HBUINT16 searchRange; - HBUINT16 entrySelector; - HBUINT16 rangeShift; - - public: - DEFINE_SIZE_STATIC (8); -}; - -template -struct BinSearchArrayOf : SortedArrayOf {}; - - -} /* namespace OT */ - - -#endif /* HB_OPEN_TYPE_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh new file mode 100644 index 00000000000..ef18163fa56 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh @@ -0,0 +1,673 @@ +/* + * Copyright © 2007,2008,2009,2010 Red Hat, Inc. + * Copyright © 2012 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_OPEN_TYPE_HH +#define HB_OPEN_TYPE_HH + +#include "hb.hh" +#include "hb-blob.hh" +#include "hb-face.hh" +#include "hb-machinery.hh" +#include "hb-subset.hh" + + +namespace OT { + + +/* + * + * The OpenType Font File: Data Types + */ + + +/* "The following data types are used in the OpenType font file. + * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */ + +/* + * Int types + */ + +/* Integer types in big-endian order and no alignment requirement */ +template +struct IntType +{ + inline void set (Type i) { v.set (i); } + inline operator Type(void) const { return v; } + inline bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } + inline bool operator != (const IntType &o) const { return !(*this == o); } + static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } + template + inline int cmp (Type2 a) const + { + Type b = v; + if (sizeof (Type) < sizeof (int) && sizeof (Type2) < sizeof (int)) + return (int) a - (int) b; + else + return a < b ? -1 : a == b ? 0 : +1; + } + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this))); + } + protected: + BEInt v; + public: + DEFINE_SIZE_STATIC (Size); +}; + +typedef IntType HBUINT8; /* 8-bit unsigned integer. */ +typedef IntType HBINT8; /* 8-bit signed integer. */ +typedef IntType HBUINT16; /* 16-bit unsigned integer. */ +typedef IntType HBINT16; /* 16-bit signed integer. */ +typedef IntType HBUINT32; /* 32-bit unsigned integer. */ +typedef IntType HBINT32; /* 32-bit signed integer. */ +typedef IntType HBUINT24; /* 24-bit unsigned integer. */ + +/* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */ +typedef HBINT16 FWORD; + +/* 16-bit unsigned integer (HBUINT16) that describes a quantity in FUnits. */ +typedef HBUINT16 UFWORD; + +/* 16-bit signed fixed number with the low 14 bits of fraction (2.14). */ +struct F2DOT14 : HBINT16 +{ + // 16384 means 1<<14 + inline float to_float (void) const { return ((int32_t) v) / 16384.f; } + inline void set_float (float f) { v.set (round (f * 16384.f)); } + public: + DEFINE_SIZE_STATIC (2); +}; + +/* 32-bit signed fixed-point number (16.16). */ +struct Fixed : HBINT32 +{ + // 65536 means 1<<16 + inline float to_float (void) const { return ((int32_t) v) / 65536.f; } + inline void set_float (float f) { v.set (round (f * 65536.f)); } + public: + DEFINE_SIZE_STATIC (4); +}; + +/* Date represented in number of seconds since 12:00 midnight, January 1, + * 1904. The value is represented as a signed 64-bit integer. */ +struct LONGDATETIME +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this))); + } + protected: + HBINT32 major; + HBUINT32 minor; + public: + DEFINE_SIZE_STATIC (8); +}; + +/* Array of four uint8s (length = 32 bits) used to identify a script, language + * system, feature, or baseline */ +struct Tag : HBUINT32 +{ + /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ + inline operator const char* (void) const { return reinterpret_cast (&this->v); } + inline operator char* (void) { return reinterpret_cast (&this->v); } + public: + DEFINE_SIZE_STATIC (4); +}; + +/* Glyph index number, same as uint16 (length = 16 bits) */ +typedef HBUINT16 GlyphID; + +/* Name-table index, same as uint16 (length = 16 bits) */ +typedef HBUINT16 NameID; + +/* Script/language-system/feature index */ +struct Index : HBUINT16 { + enum { NOT_FOUND_INDEX = 0xFFFFu }; +}; +DECLARE_NULL_NAMESPACE_BYTES (OT, Index); + +/* Offset, Null offset = 0 */ +template +struct Offset : Type +{ + inline bool is_null (void) const { return 0 == *this; } + + inline void *serialize (hb_serialize_context_t *c, const void *base) + { + void *t = c->start_embed (); + this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ + return t; + } + + public: + DEFINE_SIZE_STATIC (sizeof(Type)); +}; + +typedef Offset Offset16; +typedef Offset Offset32; + + +/* CheckSum */ +struct CheckSum : HBUINT32 +{ + /* This is reference implementation from the spec. */ + static inline uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length) + { + uint32_t Sum = 0L; + assert (0 == (Length & 3)); + const HBUINT32 *EndPtr = Table + Length / HBUINT32::static_size; + + while (Table < EndPtr) + Sum += *Table++; + return Sum; + } + + /* Note: data should be 4byte aligned and have 4byte padding at the end. */ + inline void set_for_data (const void *data, unsigned int length) + { set (CalcTableChecksum ((const HBUINT32 *) data, length)); } + + public: + DEFINE_SIZE_STATIC (4); +}; + + +/* + * Version Numbers + */ + +template +struct FixedVersion +{ + inline uint32_t to_int (void) const { return (major << (sizeof(FixedType) * 8)) + minor; } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + FixedType major; + FixedType minor; + public: + DEFINE_SIZE_STATIC (2 * sizeof(FixedType)); +}; + + +/* + * Template subclasses of Offset that do the dereferencing. + * Use: (base+offset) + */ + +template +struct OffsetTo : Offset +{ + inline const Type& operator () (const void *base) const + { + unsigned int offset = *this; + if (unlikely (!offset)) return Null(Type); + return StructAtOffset (base, offset); + } + inline Type& operator () (void *base) const + { + unsigned int offset = *this; + if (unlikely (!offset)) return Crap(Type); + return StructAtOffset (base, offset); + } + + inline Type& serialize (hb_serialize_context_t *c, const void *base) + { + return * (Type *) Offset::serialize (c, base); + } + + template + inline void serialize_subset (hb_subset_context_t *c, const T &src, const void *base) + { + if (&src == &Null(T)) + { + this->set (0); + return; + } + serialize (c->serializer, base); + if (!src.subset (c)) + this->set (0); + } + + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) return_trace (false); + unsigned int offset = *this; + if (unlikely (!offset)) return_trace (true); + if (unlikely (!c->check_range (base, offset))) return_trace (false); + const Type &obj = StructAtOffset (base, offset); + return_trace (likely (obj.sanitize (c)) || neuter (c)); + } + template + inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) return_trace (false); + unsigned int offset = *this; + if (unlikely (!offset)) return_trace (true); + if (unlikely (!c->check_range (base, offset))) return_trace (false); + const Type &obj = StructAtOffset (base, offset); + return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); + } + + /* Set the offset to Null */ + inline bool neuter (hb_sanitize_context_t *c) const { + return c->try_set (this, 0); + } + DEFINE_SIZE_STATIC (sizeof(OffsetType)); +}; +template struct LOffsetTo : OffsetTo {}; +template +static inline const Type& operator + (const Base &base, const OffsetTo &offset) { return offset (base); } +template +static inline Type& operator + (Base &base, OffsetTo &offset) { return offset (base); } + + +/* + * Array Types + */ + +/* TODO Use it in ArrayOf, HeadlessArrayOf, and other places around the code base?? */ +template +struct UnsizedArrayOf +{ + inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } + inline Type& operator [] (unsigned int i) { return arrayZ[i]; } + + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && arrayZ[0].sanitize (c)); + + return_trace (true); + } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base))) + return_trace (false); + return_trace (true); + } + template + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) + return_trace (false); + return_trace (true); + } + + inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_array (arrayZ, arrayZ[0].static_size, count)); + } + + public: + Type arrayZ[VAR]; + public: + DEFINE_SIZE_ARRAY (0, arrayZ); +}; + +/* Unsized array of offset's */ +template +struct UnsizedOffsetArrayOf : UnsizedArrayOf > {}; + +/* Unsized array of offsets relative to the beginning of the array itself. */ +template +struct UnsizedOffsetListOf : UnsizedOffsetArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + return this+this->arrayZ[i]; + } + + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + return_trace ((UnsizedOffsetArrayOf::sanitize (c, count, this))); + } + template + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const + { + TRACE_SANITIZE (this); + return_trace ((UnsizedOffsetArrayOf::sanitize (c, count, this, user_data))); + } +}; + +/* An array with a number of elements. */ +template +struct ArrayOf +{ + const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const + { + unsigned int count = len; + if (unlikely (start_offset > count)) + count = 0; + else + count -= start_offset; + count = MIN (count, *pcount); + *pcount = count; + return arrayZ + start_offset; + } + + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Null(Type); + return arrayZ[i]; + } + inline Type& operator [] (unsigned int i) + { + if (unlikely (i >= len)) return Crap(Type); + return arrayZ[i]; + } + inline unsigned int get_size (void) const + { return len.static_size + len * Type::static_size; } + + inline bool serialize (hb_serialize_context_t *c, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + len.set (items_len); /* TODO(serialize) Overflow? */ + if (unlikely (!c->extend (*this))) return_trace (false); + return_trace (true); + } + inline bool serialize (hb_serialize_context_t *c, + Supplier &items, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!serialize (c, items_len))) return_trace (false); + for (unsigned int i = 0; i < items_len; i++) + arrayZ[i] = items[i]; + items += items_len; + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && arrayZ[0].sanitize (c)); + + return_trace (true); + } + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base))) + return_trace (false); + return_trace (true); + } + template + inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) + return_trace (false); + return_trace (true); + } + + template + inline int lsearch (const SearchType &x) const + { + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (!this->arrayZ[i].cmp (x)) + return i; + return -1; + } + + inline void qsort (void) + { + ::qsort (arrayZ, len, sizeof (Type), Type::cmp); + } + + private: + inline bool sanitize_shallow (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (len.sanitize (c) && c->check_array (arrayZ, Type::static_size, len)); + } + + public: + LenType len; + Type arrayZ[VAR]; + public: + DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); +}; +template struct LArrayOf : ArrayOf {}; +typedef ArrayOf PString; + +/* Array of Offset's */ +template +struct OffsetArrayOf : ArrayOf > {}; + +/* Array of offsets relative to the beginning of the array itself. */ +template +struct OffsetListOf : OffsetArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= this->len)) return Null(Type); + return this+this->arrayZ[i]; + } + inline const Type& operator [] (unsigned int i) + { + if (unlikely (i >= this->len)) return Crap(Type); + return this+this->arrayZ[i]; + } + + inline bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + struct OffsetListOf *out = c->serializer->embed (*this); + if (unlikely (!out)) return_trace (false); + unsigned int count = this->len; + for (unsigned int i = 0; i < count; i++) + out->arrayZ[i].serialize_subset (c, (*this)[i], out); + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (OffsetArrayOf::sanitize (c, this)); + } + template + inline bool sanitize (hb_sanitize_context_t *c, T user_data) const + { + TRACE_SANITIZE (this); + return_trace (OffsetArrayOf::sanitize (c, this, user_data)); + } +}; + +/* An array starting at second element. */ +template +struct HeadlessArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len || !i)) return Null(Type); + return arrayZ[i-1]; + } + inline Type& operator [] (unsigned int i) + { + if (unlikely (i >= len || !i)) return Crap(Type); + return arrayZ[i-1]; + } + inline unsigned int get_size (void) const + { return len.static_size + (len ? len - 1 : 0) * Type::static_size; } + + inline bool serialize (hb_serialize_context_t *c, + Supplier &items, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + len.set (items_len); /* TODO(serialize) Overflow? */ + if (unlikely (!items_len)) return_trace (true); + if (unlikely (!c->extend (*this))) return_trace (false); + for (unsigned int i = 0; i < items_len - 1; i++) + arrayZ[i] = items[i]; + items += items_len - 1; + return_trace (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return_trace (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && arrayZ[0].sanitize (c)); + + return_trace (true); + } + + private: + inline bool sanitize_shallow (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (len.sanitize (c) && + (!len || c->check_array (arrayZ, Type::static_size, len - 1))); + } + + public: + LenType len; + Type arrayZ[VAR]; + public: + DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); +}; + +/* An array with sorted elements. Supports binary searching. */ +template +struct SortedArrayOf : ArrayOf +{ + template + inline int bsearch (const SearchType &x) const + { + /* Hand-coded bsearch here since this is in the hot inner loop. */ + const Type *arr = this->arrayZ; + int min = 0, max = (int) this->len - 1; + while (min <= max) + { + int mid = (min + max) / 2; + int c = arr[mid].cmp (x); + if (c < 0) + max = mid - 1; + else if (c > 0) + min = mid + 1; + else + return mid; + } + return -1; + } +}; + +/* Binary-search arrays */ +struct BinSearchHeader +{ + inline operator uint32_t (void) const { return len; } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + inline void set (unsigned int v) + { + len.set (v); + assert (len == v); + entrySelector.set (MAX (1u, hb_bit_storage (v)) - 1); + searchRange.set (16 * (1u << entrySelector)); + rangeShift.set (v * 16 > searchRange + ? 16 * v - searchRange + : 0); + } + + protected: + HBUINT16 len; + HBUINT16 searchRange; + HBUINT16 entrySelector; + HBUINT16 rangeShift; + + public: + DEFINE_SIZE_STATIC (8); +}; + +template +struct BinSearchArrayOf : SortedArrayOf {}; + + +} /* namespace OT */ + + +#endif /* HB_OPEN_TYPE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh index 67a9c7dd96b..e6876d12cf6 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh @@ -27,9 +27,8 @@ #ifndef HB_OT_CMAP_TABLE_HH #define HB_OT_CMAP_TABLE_HH -#include "hb-open-type-private.hh" -#include "hb-set-private.hh" -#include "hb-subset-plan.hh" +#include "hb-open-type.hh" +#include "hb-set.hh" /* * cmap -- Character to Glyph Index Mapping @@ -37,10 +36,6 @@ */ #define HB_OT_TAG_cmap HB_TAG('c','m','a','p') -#ifndef HB_MAX_UNICODE_CODEPOINT_VALUE -#define HB_MAX_UNICODE_CODEPOINT_VALUE 0x10FFFF -#endif - namespace OT { @@ -54,6 +49,12 @@ struct CmapSubtableFormat0 *glyph = gid; return true; } + inline void collect_unicodes (hb_set_t *out) const + { + for (unsigned int i = 0; i < 256; i++) + if (glyphIdArray[i]) + out->add (i); + } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -237,15 +238,14 @@ struct CmapSubtableFormat4 glyphIdArray = idRangeOffset + segCount; glyphIdArrayLength = (subtable->length - 16 - 8 * segCount) / 2; } + inline void fini (void) {} - static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) + inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { - const accelerator_t *thiz = (const accelerator_t *) obj; - /* Custom two-array bsearch. */ - int min = 0, max = (int) thiz->segCount - 1; - const HBUINT16 *startCount = thiz->startCount; - const HBUINT16 *endCount = thiz->endCount; + int min = 0, max = (int) this->segCount - 1; + const HBUINT16 *startCount = this->startCount; + const HBUINT16 *endCount = this->endCount; unsigned int i; while (min <= max) { @@ -264,33 +264,55 @@ struct CmapSubtableFormat4 found: hb_codepoint_t gid; - unsigned int rangeOffset = thiz->idRangeOffset[i]; + unsigned int rangeOffset = this->idRangeOffset[i]; if (rangeOffset == 0) - gid = codepoint + thiz->idDelta[i]; + gid = codepoint + this->idDelta[i]; else { /* Somebody has been smoking... */ - unsigned int index = rangeOffset / 2 + (codepoint - thiz->startCount[i]) + i - thiz->segCount; - if (unlikely (index >= thiz->glyphIdArrayLength)) + unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount; + if (unlikely (index >= this->glyphIdArrayLength)) return false; - gid = thiz->glyphIdArray[index]; + gid = this->glyphIdArray[index]; if (unlikely (!gid)) return false; - gid += thiz->idDelta[i]; + gid += this->idDelta[i]; } - - *glyph = gid & 0xFFFFu; + gid &= 0xFFFFu; + if (!gid) + return false; + *glyph = gid; return true; } - - static inline void get_all_codepoints_func (const void *obj, hb_set_t *out) + static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) { - const accelerator_t *thiz = (const accelerator_t *) obj; - for (unsigned int i = 0; i < thiz->segCount; i++) + return ((const accelerator_t *) obj)->get_glyph (codepoint, glyph); + } + inline void collect_unicodes (hb_set_t *out) const + { + unsigned int count = this->segCount; + if (count && this->startCount[count - 1] == 0xFFFFu) + count--; /* Skip sentinel segment. */ + for (unsigned int i = 0; i < count; i++) { - if (thiz->startCount[i] != 0xFFFFu - || thiz->endCount[i] != 0xFFFFu) // Skip the last segment (0xFFFF) - hb_set_add_range (out, thiz->startCount[i], thiz->endCount[i]); + unsigned int rangeOffset = this->idRangeOffset[i]; + if (rangeOffset == 0) + out->add_range (this->startCount[i], this->endCount[i]); + else + { + for (hb_codepoint_t codepoint = this->startCount[i]; + codepoint <= this->endCount[i]; + codepoint++) + { + unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount; + if (unlikely (index >= this->glyphIdArrayLength)) + break; + hb_codepoint_t gid = this->glyphIdArray[index]; + if (unlikely (!gid)) + continue; + out->add (codepoint); + } + } } } @@ -305,10 +327,14 @@ struct CmapSubtableFormat4 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { - accelerator_t accel; - accel.init (this); + hb_auto_t accel (this); return accel.get_glyph_func (&accel, codepoint, glyph); } + inline void collect_unicodes (hb_set_t *out) const + { + hb_auto_t accel (this); + accel.collect_unicodes (out); + } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -383,7 +409,7 @@ struct CmapSubtableLongGroup HBUINT32 startCharCode; /* First character code in this group. */ HBUINT32 endCharCode; /* Last character code in this group. */ HBUINT32 glyphID; /* Glyph index; interpretation depends on - * subtable format. */ + * subtable format. */ public: DEFINE_SIZE_STATIC (12); }; @@ -400,6 +426,14 @@ struct CmapSubtableTrimmed *glyph = gid; return true; } + inline void collect_unicodes (hb_set_t *out) const + { + hb_codepoint_t start = startCharCode; + unsigned int count = glyphIdArray.len; + for (unsigned int i = 0; i < count; i++) + if (glyphIdArray[i]) + out->add (start + i); + } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -432,18 +466,19 @@ struct CmapSubtableLongSegmented int i = groups.bsearch (codepoint); if (i == -1) return false; - *glyph = T::group_get_glyph (groups[i], codepoint); + hb_codepoint_t gid = T::group_get_glyph (groups[i], codepoint); + if (!gid) + return false; + *glyph = gid; return true; } - inline void get_all_codepoints (hb_set_t *out) const + inline void collect_unicodes (hb_set_t *out) const { for (unsigned int i = 0; i < this->groups.len; i++) { - hb_set_add_range (out, - MIN ((unsigned int) this->groups[i].startCharCode, - (unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE), - MIN ((unsigned int) this->groups[i].endCharCode, - (unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE)); + out->add_range (this->groups[i].startCharCode, + MIN ((hb_codepoint_t) this->groups[i].endCharCode, + (hb_codepoint_t) HB_UNICODE_MAX)); } } @@ -574,13 +609,29 @@ struct UnicodeValueRange } HBUINT24 startUnicodeValue; /* First value in this range. */ - HBUINT8 additionalCount; /* Number of additional values in this + HBUINT8 additionalCount; /* Number of additional values in this * range. */ public: DEFINE_SIZE_STATIC (4); }; -typedef SortedArrayOf DefaultUVS; +struct DefaultUVS : SortedArrayOf +{ + inline void collect_unicodes (hb_set_t *out) const + { + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + { + hb_codepoint_t first = arrayZ[i].startUnicodeValue; + hb_codepoint_t last = MIN ((hb_codepoint_t) (first + arrayZ[i].additionalCount), + (hb_codepoint_t) HB_UNICODE_MAX); + out->add_range (first, last); + } + } + + public: + DEFINE_SIZE_ARRAY (4, arrayZ); +}; struct UVSMapping { @@ -601,7 +652,18 @@ struct UVSMapping DEFINE_SIZE_STATIC (5); }; -typedef SortedArrayOf NonDefaultUVS; +struct NonDefaultUVS : SortedArrayOf +{ + inline void collect_unicodes (hb_set_t *out) const + { + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + out->add (arrayZ[i].glyphID); + } + + public: + DEFINE_SIZE_ARRAY (4, arrayZ); +}; struct VariationSelectorRecord { @@ -616,7 +678,7 @@ struct VariationSelectorRecord return GLYPH_VARIANT_USE_DEFAULT; const NonDefaultUVS &nonDefaults = base+nonDefaultUVS; i = nonDefaults.bsearch (codepoint); - if (i != -1) + if (i != -1 && nonDefaults[i].glyphID) { *glyph = nonDefaults[i].glyphID; return GLYPH_VARIANT_FOUND; @@ -624,6 +686,12 @@ struct VariationSelectorRecord return GLYPH_VARIANT_NOT_FOUND; } + inline void collect_unicodes (hb_set_t *out, const void *base) const + { + (base+defaultUVS).collect_unicodes (out); + (base+nonDefaultUVS).collect_unicodes (out); + } + inline int cmp (const hb_codepoint_t &variation_selector) const { return varSelector.cmp (variation_selector); @@ -652,7 +720,19 @@ struct CmapSubtableFormat14 hb_codepoint_t variation_selector, hb_codepoint_t *glyph) const { - return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyph, this); + return record[record.bsearch (variation_selector)].get_glyph (codepoint, glyph, this); + } + + inline void collect_variation_selectors (hb_set_t *out) const + { + unsigned int count = record.len; + for (unsigned int i = 0; i < count; i++) + out->add (record.arrayZ[i].varSelector); + } + inline void collect_variation_unicodes (hb_codepoint_t variation_selector, + hb_set_t *out) const + { + record[record.bsearch (variation_selector)].collect_unicodes (out, this); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -690,6 +770,19 @@ struct CmapSubtable default: return false; } } + inline void collect_unicodes (hb_set_t *out) const + { + switch (u.format) { + case 0: u.format0 .collect_unicodes (out); return; + case 4: u.format4 .collect_unicodes (out); return; + case 6: u.format6 .collect_unicodes (out); return; + case 10: u.format10.collect_unicodes (out); return; + case 12: u.format12.collect_unicodes (out); return; + case 13: u.format13.collect_unicodes (out); return; + case 14: + default: return; + } + } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -754,7 +847,8 @@ struct cmap { static const hb_tag_t tableTag = HB_OT_TAG_cmap; - struct subset_plan { + struct subset_plan + { subset_plan(void) { format4_segments.init(); @@ -895,33 +989,44 @@ struct cmap return result; } + const CmapSubtable *find_best_subtable (bool *symbol = nullptr) const + { + if (symbol) *symbol = false; + + const CmapSubtable *subtable; + + /* 32-bit subtables. */ + if ((subtable = this->find_subtable (3, 10))) return subtable; + if ((subtable = this->find_subtable (0, 6))) return subtable; + if ((subtable = this->find_subtable (0, 4))) return subtable; + + /* 16-bit subtables. */ + if ((subtable = this->find_subtable (3, 1))) return subtable; + if ((subtable = this->find_subtable (0, 3))) return subtable; + if ((subtable = this->find_subtable (0, 2))) return subtable; + if ((subtable = this->find_subtable (0, 1))) return subtable; + if ((subtable = this->find_subtable (0, 0))) return subtable; + + /* Symbol subtable. */ + if ((subtable = this->find_subtable (3, 0))) + { + if (symbol) *symbol = true; + return subtable; + } + + /* Meh. */ + return &Null(CmapSubtable); + } + struct accelerator_t { inline void init (hb_face_t *face) { this->blob = hb_sanitize_context_t().reference_table (face); const cmap *table = this->blob->as (); - const CmapSubtable *subtable = nullptr; const CmapSubtableFormat14 *subtable_uvs = nullptr; - - bool symbol = false; - /* 32-bit subtables. */ - if (!subtable) subtable = table->find_subtable (3, 10); - if (!subtable) subtable = table->find_subtable (0, 6); - if (!subtable) subtable = table->find_subtable (0, 4); - /* 16-bit subtables. */ - if (!subtable) subtable = table->find_subtable (3, 1); - if (!subtable) subtable = table->find_subtable (0, 3); - if (!subtable) subtable = table->find_subtable (0, 2); - if (!subtable) subtable = table->find_subtable (0, 1); - if (!subtable) subtable = table->find_subtable (0, 0); - if (!subtable) - { - subtable = table->find_subtable (3, 0); - if (subtable) symbol = true; - } - /* Meh. */ - if (!subtable) subtable = &Null(CmapSubtable); + bool symbol; + subtable = table->find_best_subtable (&symbol); /* UVS subtable. */ if (!subtable_uvs) @@ -933,30 +1038,26 @@ struct cmap /* Meh. */ if (!subtable_uvs) subtable_uvs = &Null(CmapSubtableFormat14); - this->uvs_table = subtable_uvs; + this->subtable_uvs = subtable_uvs; this->get_glyph_data = subtable; if (unlikely (symbol)) { this->get_glyph_func = get_glyph_from_symbol; - this->get_all_codepoints_func = null_get_all_codepoints_func; } else { switch (subtable->u.format) { /* Accelerate format 4 and format 12. */ default: this->get_glyph_func = get_glyph_from; - this->get_all_codepoints_func = null_get_all_codepoints_func; break; case 12: this->get_glyph_func = get_glyph_from; - this->get_all_codepoints_func = get_all_codepoints_from; break; case 4: { this->format4_accel.init (&subtable->u.format4); this->get_glyph_data = &this->format4_accel; this->get_glyph_func = this->format4_accel.get_glyph_func; - this->get_all_codepoints_func = this->format4_accel.get_all_codepoints_func; } break; } @@ -978,9 +1079,9 @@ struct cmap hb_codepoint_t variation_selector, hb_codepoint_t *glyph) const { - switch (this->uvs_table->get_glyph_variant (unicode, - variation_selector, - glyph)) + switch (this->subtable_uvs->get_glyph_variant (unicode, + variation_selector, + glyph)) { case GLYPH_VARIANT_NOT_FOUND: return false; case GLYPH_VARIANT_FOUND: return true; @@ -990,22 +1091,24 @@ struct cmap return get_nominal_glyph (unicode, glyph); } - inline void get_all_codepoints (hb_set_t *out) const + inline void collect_unicodes (hb_set_t *out) const + { + subtable->collect_unicodes (out); + } + inline void collect_variation_selectors (hb_set_t *out) const + { + subtable_uvs->collect_variation_selectors (out); + } + inline void collect_variation_unicodes (hb_codepoint_t variation_selector, + hb_set_t *out) const { - this->get_all_codepoints_func (get_glyph_data, out); + subtable_uvs->collect_variation_unicodes (variation_selector, out); } protected: typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph); - typedef void (*hb_cmap_get_all_codepoints_func_t) (const void *obj, - hb_set_t *out); - - static inline void null_get_all_codepoints_func (const void *obj, hb_set_t *out) - { - // NOOP - } template static inline bool get_glyph_from (const void *obj, @@ -1016,14 +1119,6 @@ struct cmap return typed_obj->get_glyph (codepoint, glyph); } - template - static inline void get_all_codepoints_from (const void *obj, - hb_set_t *out) - { - const Type *typed_obj = (const Type *) obj; - typed_obj->get_all_codepoints (out); - } - template static inline bool get_glyph_from_symbol (const void *obj, hb_codepoint_t codepoint, @@ -1047,13 +1142,14 @@ struct cmap } private: + const CmapSubtable *subtable; + const CmapSubtableFormat14 *subtable_uvs; + hb_cmap_get_glyph_func_t get_glyph_func; const void *get_glyph_data; - hb_cmap_get_all_codepoints_func_t get_all_codepoints_func; CmapSubtableFormat4::accelerator_t format4_accel; - const CmapSubtableFormat14 *uvs_table; hb_blob_t *blob; }; @@ -1066,10 +1162,7 @@ struct cmap key.platformID.set (platform_id); key.encodingID.set (encoding_id); - /* Note: We can use bsearch, but since it has no performance - * implications, we use lsearch and as such accept fonts with - * unsorted subtable list. */ - int result = encodingRecord./*bsearch*/lsearch (key); + int result = encodingRecord.bsearch (key); if (result == -1 || !encodingRecord[result].subtable) return nullptr; @@ -1084,6 +1177,7 @@ struct cmap DEFINE_SIZE_ARRAY (4, encodingRecord); }; +struct cmap_accelerator_t : cmap::accelerator_t {}; } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh index 21c2f477366..8bedf2224a0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh @@ -27,7 +27,7 @@ #ifndef HB_OT_COLOR_CBDT_TABLE_HH #define HB_OT_COLOR_CBDT_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * CBLC -- Color Bitmap Location @@ -533,6 +533,8 @@ struct CBDT DEFINE_SIZE_ARRAY(4, dataZ); }; +struct CBDT_accelerator_t : CBDT::accelerator_t {}; + } /* namespace OT */ #endif /* HB_OT_COLOR_CBDT_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh index ce6702d2ad3..070226f18e2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh @@ -25,7 +25,7 @@ #ifndef HB_OT_COLOR_COLR_TABLE_HH #define HB_OT_COLOR_COLR_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * COLR -- Color diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh index 2c312748d3b..2c9fced093e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh @@ -28,7 +28,7 @@ #ifndef HB_OT_COLOR_CPAL_TABLE_HH #define HB_OT_COLOR_CPAL_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh index 0461afa3298..1b643c77a59 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh @@ -25,7 +25,7 @@ #ifndef HB_OT_COLOR_SBIX_TABLE_HH #define HB_OT_COLOR_SBIX_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * sbix -- Standard Bitmap Graphics diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh index 3976694f844..ad9162f7c7d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh @@ -25,7 +25,7 @@ #ifndef HB_OT_COLOR_SVG_TABLE_HH #define HB_OT_COLOR_SVG_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * SVG -- SVG (Scalable Vector Graphics) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc index 86171c63353..7cdff380ef2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.cc @@ -25,7 +25,7 @@ * Google Author(s): Sascha Brawer */ -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" #include "hb-ot-color-colr-table.hh" #include "hb-ot-color-cpal-table.hh" #include "hb-ot.h" @@ -33,8 +33,8 @@ #include #include -#include "hb-ot-layout-private.hh" -#include "hb-shaper-private.hh" +#include "hb-ot-layout.hh" +#include "hb-shaper.hh" #if 0 HB_MARK_AS_FLAG_T (hb_ot_color_palette_flags_t) @@ -45,16 +45,14 @@ static inline const OT::COLR& _get_colr (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR); - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->colr.get ()); + return *(hb_ot_face_data (face)->colr.get ()); } static inline const OT::CPAL& _get_cpal (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL); - hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->cpal.get ()); + return *(hb_ot_face_data (face)->cpal.get ()); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc new file mode 100644 index 00000000000..388a5972058 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc @@ -0,0 +1,76 @@ +/* + * 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 + */ + +#include "hb-ot-face.hh" + +#include "hb-ot-cmap-table.hh" +#include "hb-ot-glyf-table.hh" +#include "hb-ot-hmtx-table.hh" +#include "hb-ot-kern-table.hh" +#include "hb-ot-post-table.hh" +#include "hb-ot-color-cbdt-table.hh" +#include "hb-ot-layout-gdef-table.hh" +#include "hb-ot-layout-gsub-table.hh" +#include "hb-ot-layout-gpos-table.hh" + + +void hb_ot_face_data_t::init0 (hb_face_t *face) +{ + this->face = face; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); +#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_ACCELERATOR +#undef HB_OT_LAYOUT_TABLE +} +void hb_ot_face_data_t::fini (void) +{ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); +#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_ACCELERATOR +#undef HB_OT_LAYOUT_TABLE +} + +hb_ot_face_data_t * +_hb_ot_face_data_create (hb_face_t *face) +{ + hb_ot_face_data_t *data = (hb_ot_face_data_t *) calloc (1, sizeof (hb_ot_face_data_t)); + if (unlikely (!data)) + return nullptr; + + data->init0 (face); + + return data; +} + +void +_hb_ot_face_data_destroy (hb_ot_face_data_t *data) +{ + data->fini (); + free (data); +} + diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh new file mode 100644 index 00000000000..5ac3538e44d --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh @@ -0,0 +1,116 @@ +/* + * Copyright © 2007,2008,2009 Red Hat, Inc. + * Copyright © 2012,2013 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_OT_FACE_HH +#define HB_OT_FACE_HH + +#include "hb.hh" + +#include "hb-machinery.hh" + + +#define hb_ot_face_data(face) ((hb_ot_face_data_t *) face->shaper_data.ot.get_relaxed ()) + + +/* + * hb_ot_face_data_t + */ + +/* 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, 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 math. */ \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + /* OpenType fundamentals. */ \ + HB_OT_LAYOUT_ACCELERATOR(OT, GDEF) \ + HB_OT_LAYOUT_ACCELERATOR(OT, GSUB) \ + HB_OT_LAYOUT_ACCELERATOR(OT, GPOS) \ + HB_OT_LAYOUT_ACCELERATOR(OT, cmap) \ + HB_OT_LAYOUT_ACCELERATOR(OT, hmtx) \ + HB_OT_LAYOUT_ACCELERATOR(OT, vmtx) \ + HB_OT_LAYOUT_ACCELERATOR(OT, post) \ + HB_OT_LAYOUT_ACCELERATOR(OT, kern) \ + HB_OT_LAYOUT_ACCELERATOR(OT, glyf) \ + HB_OT_LAYOUT_ACCELERATOR(OT, CBDT) \ + /* */ + +/* Declare tables. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type##_accelerator_t) +HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_ACCELERATOR +#undef HB_OT_LAYOUT_TABLE + +struct hb_ot_face_data_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), +#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_ACCELERATOR +#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 Type; +#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) \ + hb_face_lazy_loader_t Type; + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_ACCELERATOR +#undef HB_OT_LAYOUT_TABLE +}; + + +HB_INTERNAL hb_ot_face_data_t * +_hb_ot_face_data_create (hb_face_t *face); + +HB_INTERNAL void +_hb_ot_face_data_destroy (hb_ot_face_data_t *data); + + +#endif /* HB_OT_FACE_HH */ 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 9da8fc7d497..a4c5584fbd9 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 @@ -24,84 +24,22 @@ * Google Author(s): Behdad Esfahbod, Roozbeh Pournader */ -#include "hb-private.hh" +#include "hb.hh" #include "hb-ot.h" -#include "hb-font-private.hh" -#include "hb-machinery-private.hh" +#include "hb-font.hh" +#include "hb-machinery.hh" +#include "hb-ot-face.hh" #include "hb-ot-cmap-table.hh" -#include "hb-ot-glyf-table.hh" #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" #include "hb-ot-post-table.hh" - +#include "hb-ot-glyf-table.hh" #include "hb-ot-color-cbdt-table.hh" -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; - - hb_face_t *face; /* MUST be JUST before the lazy loaders. */ - hb_face_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; - hb_face_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; - hb_face_lazy_loader_t<3, OT::post::accelerator_t> post; - hb_face_lazy_loader_t<4, OT::kern::accelerator_t> kern; -}; - - -static hb_ot_font_t * -_hb_ot_font_create (hb_face_t *face) -{ - hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t)); - - if (unlikely (!ot_font)) - return nullptr; - - ot_font->init (face); - - return ot_font; -} - -static void -_hb_ot_font_destroy (void *data) -{ - hb_ot_font_t *ot_font = (hb_ot_font_t *) data; - - ot_font->fini (); - - free (ot_font); -} - - static hb_bool_t hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, void *font_data, @@ -110,8 +48,8 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return ot_font->cmap.get_nominal_glyph (unicode, glyph); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + return ot_font->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph); } static hb_bool_t @@ -122,8 +60,8 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return ot_font->cmap.get_variation_glyph (unicode, variation_selector, glyph); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + return ot_font->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph); } static hb_position_t @@ -132,8 +70,8 @@ hb_ot_get_glyph_h_advance (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_x (ot_font->h_metrics.get_advance (glyph, font)); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + return font->em_scale_x (ot_font->hmtx.get_relaxed ()->get_advance (glyph, font)); } static hb_position_t @@ -142,8 +80,8 @@ hb_ot_get_glyph_v_advance (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph, font)); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + return font->em_scale_y (-(int) ot_font->vmtx.get_relaxed ()->get_advance (glyph, font)); } static hb_position_t @@ -153,7 +91,7 @@ hb_ot_get_glyph_h_kerning (hb_font_t *font, hb_codepoint_t right_glyph, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; return font->em_scale_x (ot_font->kern->get_h_kerning (left_glyph, right_glyph)); } @@ -164,10 +102,10 @@ hb_ot_get_glyph_extents (hb_font_t *font, hb_glyph_extents_t *extents, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; bool ret = ot_font->glyf->get_extents (glyph, extents); if (!ret) - ret = ot_font->cbdt->get_extents (glyph, extents); + ret = ot_font->CBDT->get_extents (glyph, extents); // TODO Hook up side-bearings variations. extents->x_bearing = font->em_scale_x (extents->x_bearing); extents->y_bearing = font->em_scale_y (extents->y_bearing); @@ -183,7 +121,7 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED, char *name, unsigned int size, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; return ot_font->post->get_glyph_name (glyph, name, size); } @@ -194,7 +132,7 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; return ot_font->post->get_glyph_from_name (name, len, glyph); } @@ -204,12 +142,12 @@ hb_ot_get_font_h_extents (hb_font_t *font, hb_font_extents_t *metrics, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender); - metrics->descender = font->em_scale_y (ot_font->h_metrics.descender); - metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + metrics->ascender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->ascender); + metrics->descender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->descender); + metrics->line_gap = font->em_scale_y (ot_font->hmtx.get_relaxed ()->line_gap); // TODO Hook up variations. - return ot_font->h_metrics.has_font_extents; + return ot_font->hmtx.get_relaxed ()->has_font_extents; } static hb_bool_t @@ -218,16 +156,17 @@ hb_ot_get_font_v_extents (hb_font_t *font, hb_font_extents_t *metrics, void *user_data HB_UNUSED) { - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender); - metrics->descender = font->em_scale_x (ot_font->v_metrics.descender); - metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap); + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + metrics->ascender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->ascender); + metrics->descender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->descender); + metrics->line_gap = font->em_scale_x (ot_font->vmtx.get_relaxed ()->line_gap); // TODO Hook up variations. - return ot_font->v_metrics.has_font_extents; + return ot_font->vmtx.get_relaxed ()->has_font_extents; } - +#ifdef HB_USE_ATEXIT static void free_static_ot_funcs (void); +#endif static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t { @@ -283,12 +222,16 @@ _hb_ot_get_font_funcs (void) void hb_ot_font_set_funcs (hb_font_t *font) { - hb_ot_font_t *ot_font = _hb_ot_font_create (font->face); - if (unlikely (!ot_font)) - return; + if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return; + hb_ot_face_data_t *ot_font = hb_ot_face_data (font->face); + + /* Load them lazies. We access them with get_relaxed() for performance. */ + ot_font->cmap.get (); + ot_font->hmtx.get (); + ot_font->vmtx.get (); hb_font_set_funcs (font, _hb_ot_get_font_funcs (), ot_font, - _hb_ot_font_destroy); + nullptr); } 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 bcf89e46247..7c20983603f 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 @@ -27,11 +27,9 @@ #ifndef HB_OT_GLYF_TABLE_HH #define HB_OT_GLYF_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" #include "hb-ot-head-table.hh" #include "hb-subset-glyf.hh" -#include "hb-subset-plan.hh" -#include "hb-subset-private.hh" namespace OT { @@ -490,6 +488,8 @@ struct glyf DEFINE_SIZE_ARRAY (0, dataZ); }; +struct glyf_accelerator_t : glyf::accelerator_t {}; + } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh index 0951871ce97..87dd6d01822 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh @@ -27,8 +27,7 @@ #ifndef HB_OT_HDMX_TABLE_HH #define HB_OT_HDMX_TABLE_HH -#include "hb-open-type-private.hh" -#include "hb-subset-plan.hh" +#include "hb-open-type.hh" /* * hdmx -- Horizontal Device Metrics @@ -89,8 +88,13 @@ struct DeviceRecord { TRACE_SERIALIZE (this); - if (unlikely (!c->allocate_size (get_size (subset_view.len())))) + unsigned int size = get_size (subset_view.len()); + if (unlikely (!c->allocate_size (size))) + { + DEBUG_MSG (SUBSET, nullptr, "Couldn't allocate enough space for DeviceRecord: %d.", + size); return_trace (false); + } this->pixel_size.set (subset_view.source_device_record->pixel_size); this->max_width.set (subset_view.source_device_record->max_width); @@ -161,14 +165,14 @@ struct hdmx return_trace (true); } - static inline size_t get_subsetted_size (hb_subset_plan_t *plan) + static inline size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan) { - return min_size + DeviceRecord::get_size (plan->glyphs.len); + return min_size + source_hdmx->num_records * DeviceRecord::get_size (plan->glyphs.len); } inline bool subset (hb_subset_plan_t *plan) const { - size_t dest_size = get_subsetted_size (plan); + size_t dest_size = get_subsetted_size (this, plan); hdmx *dest = (hdmx *) malloc (dest_size); if (unlikely (!dest)) { @@ -178,8 +182,10 @@ struct hdmx hb_serialize_context_t c (dest, dest_size); hdmx *hdmx_prime = c.start_serialize (); - if (!hdmx_prime || !hdmx_prime->serialize (&c, this, plan)) { + if (!hdmx_prime || !hdmx_prime->serialize (&c, this, plan)) + { free (dest); + DEBUG_MSG(SUBSET, nullptr, "Failed to serialize write new hdmx."); return false; } c.end_serialize (); 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 fded120be28..602e365ce5d 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 @@ -29,7 +29,7 @@ #ifndef HB_OT_HEAD_TABLE_HH #define HB_OT_HEAD_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * head -- Font Header diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh index efb42b61616..3336cadd472 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh @@ -27,7 +27,7 @@ #ifndef HB_OT_HHEA_TABLE_HH #define HB_OT_HHEA_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * hhea -- Horizontal Header diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh index 13fa9d6e092..3e4b3bdef5c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh @@ -27,11 +27,10 @@ #ifndef HB_OT_HMTX_TABLE_HH #define HB_OT_HMTX_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" #include "hb-ot-hhea-table.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-var-hvar-table.hh" -#include "hb-subset-plan.hh" /* * hmtx -- Horizontal Metrics @@ -332,6 +331,9 @@ struct vmtx : hmtxvmtx { static const hb_tag_t os2Tag = HB_TAG_NONE; }; +struct hmtx_accelerator_t : hmtx::accelerator_t {}; +struct vmtx_accelerator_t : vmtx::accelerator_t {}; + } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh index b4d81095282..40f94be296f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh @@ -27,7 +27,7 @@ #ifndef HB_OT_KERN_TABLE_HH #define HB_OT_KERN_TABLE_HH -#include "hb-open-type-private.hh" +#include "hb-open-type.hh" /* * kern -- Kerning @@ -390,6 +390,8 @@ struct kern DEFINE_SIZE_UNION (2, major); }; +struct kern_accelerator_t : kern::accelerator_t {}; + } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh index 96da07fb5cd..449e74550e9 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 @@ -28,8 +28,8 @@ #ifndef HB_OT_LAYOUT_BASE_TABLE_HH #define HB_OT_LAYOUT_BASE_TABLE_HH -#include "hb-open-type-private.hh" -#include "hb-ot-layout-common-private.hh" +#include "hb-open-type.hh" +#include "hb-ot-layout-common.hh" namespace OT { 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 deleted file mode 100644 index 89d5eae494f..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common-private.hh +++ /dev/null @@ -1,1806 +0,0 @@ -/* - * Copyright © 2007,2008,2009 Red Hat, Inc. - * Copyright © 2010,2012 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_OT_LAYOUT_COMMON_PRIVATE_HH -#define HB_OT_LAYOUT_COMMON_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-ot-layout-private.hh" -#include "hb-open-type-private.hh" -#include "hb-set-private.hh" - - -#ifndef HB_MAX_NESTING_LEVEL -#define HB_MAX_NESTING_LEVEL 6 -#endif -#ifndef HB_MAX_CONTEXT_LENGTH -#define HB_MAX_CONTEXT_LENGTH 64 -#endif -#ifndef HB_CLOSURE_MAX_STAGES -/* - * The maximum number of times a lookup can be applied during shaping. - * Used to limit the number of iterations of the closure algorithm. - * This must be larger than the number of times add_pause() is - * called in a collect_features call of any shaper. - */ -#define HB_CLOSURE_MAX_STAGES 32 -#endif - - -namespace OT { - - -#define NOT_COVERED ((unsigned int) -1) - - - -/* - * - * OpenType Layout Common Table Formats - * - */ - - -/* - * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList - */ - -template -struct Record -{ - inline int cmp (hb_tag_t a) const { - return tag.cmp (a); - } - - struct sanitize_closure_t { - hb_tag_t tag; - const void *list_base; - }; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - const sanitize_closure_t closure = {tag, base}; - return_trace (c->check_struct (this) && offset.sanitize (c, base, &closure)); - } - - Tag tag; /* 4-byte Tag identifier */ - OffsetTo - offset; /* Offset from beginning of object holding - * the Record */ - public: - DEFINE_SIZE_STATIC (6); -}; - -template -struct RecordArrayOf : SortedArrayOf > { - inline const Tag& get_tag (unsigned int i) const - { - /* We cheat slightly and don't define separate Null objects - * for Record types. Instead, we return the correct Null(Tag) - * here. */ - if (unlikely (i >= this->len)) return Null(Tag); - return (*this)[i].tag; - } - inline unsigned int get_tags (unsigned int start_offset, - unsigned int *record_count /* IN/OUT */, - hb_tag_t *record_tags /* OUT */) const - { - if (record_count) { - const Record *arr = this->sub_array (start_offset, record_count); - unsigned int count = *record_count; - for (unsigned int i = 0; i < count; i++) - record_tags[i] = arr[i].tag; - } - return this->len; - } - inline bool find_index (hb_tag_t tag, unsigned int *index) const - { - /* If we want to allow non-sorted data, we can lsearch(). */ - int i = this->/*lsearch*/bsearch (tag); - if (i != -1) { - if (index) *index = i; - return true; - } else { - if (index) *index = Index::NOT_FOUND_INDEX; - return false; - } - } -}; - -template -struct RecordListOf : RecordArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { return this+RecordArrayOf::operator [](i).offset; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (RecordArrayOf::sanitize (c, this)); - } -}; - - -struct RangeRecord -{ - inline int cmp (hb_codepoint_t g) const { - return g < start ? -1 : g <= end ? 0 : +1 ; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - inline bool intersects (const hb_set_t *glyphs) const { - return glyphs->intersects (start, end); - } - - template - inline bool add_coverage (set_t *glyphs) const { - return glyphs->add_range (start, end); - } - - GlyphID start; /* First GlyphID in the range */ - GlyphID end; /* Last GlyphID in the range */ - HBUINT16 value; /* Value */ - public: - DEFINE_SIZE_STATIC (6); -}; -DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord); - - -struct IndexArray : ArrayOf -{ - inline unsigned int get_indexes (unsigned int start_offset, - unsigned int *_count /* IN/OUT */, - unsigned int *_indexes /* OUT */) const - { - if (_count) { - const HBUINT16 *arr = this->sub_array (start_offset, _count); - unsigned int count = *_count; - for (unsigned int i = 0; i < count; i++) - _indexes[i] = arr[i]; - } - return this->len; - } - - inline void add_indexes_to (hb_set_t* output /* OUT */) const - { - output->add_array (arrayZ, len); - } -}; - - -struct Script; -struct LangSys; -struct Feature; - - -struct LangSys -{ - inline unsigned int get_feature_count (void) const - { return featureIndex.len; } - inline hb_tag_t get_feature_index (unsigned int i) const - { return featureIndex[i]; } - inline unsigned int get_feature_indexes (unsigned int start_offset, - unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */) const - { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); } - inline void add_feature_indexes_to (hb_set_t *feature_indexes) const - { featureIndex.add_indexes_to (feature_indexes); } - - inline bool has_required_feature (void) const { return reqFeatureIndex != 0xFFFFu; } - inline unsigned int get_required_feature_index (void) const - { - if (reqFeatureIndex == 0xFFFFu) - return Index::NOT_FOUND_INDEX; - return reqFeatureIndex;; - } - - inline bool sanitize (hb_sanitize_context_t *c, - const Record::sanitize_closure_t * = nullptr) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && featureIndex.sanitize (c)); - } - - Offset16 lookupOrderZ; /* = Null (reserved for an offset to a - * reordering table) */ - HBUINT16 reqFeatureIndex;/* Index of a feature required for this - * language system--if no required features - * = 0xFFFFu */ - IndexArray featureIndex; /* Array of indices into the FeatureList */ - public: - DEFINE_SIZE_ARRAY (6, featureIndex); -}; -DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys); - -struct Script -{ - inline unsigned int get_lang_sys_count (void) const - { return langSys.len; } - inline const Tag& get_lang_sys_tag (unsigned int i) const - { return langSys.get_tag (i); } - inline unsigned int get_lang_sys_tags (unsigned int start_offset, - unsigned int *lang_sys_count /* IN/OUT */, - hb_tag_t *lang_sys_tags /* OUT */) const - { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } - inline const LangSys& get_lang_sys (unsigned int i) const - { - if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); - return this+langSys[i].offset; - } - inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const - { return langSys.find_index (tag, index); } - - inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } - inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } - - inline bool sanitize (hb_sanitize_context_t *c, - const Record