summaryrefslogtreecommitdiff
path: root/chromium/third_party/harfbuzz-ng
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/harfbuzz-ng')
-rw-r--r--chromium/third_party/harfbuzz-ng/BUILD.gn91
-rw-r--r--chromium/third_party/harfbuzz-ng/README.chromium42
-rwxr-xr-xchromium/third_party/harfbuzz-ng/roll-harfbuzz.sh44
-rw-r--r--chromium/third_party/harfbuzz-ng/src/.circleci/config.yml109
-rw-r--r--chromium/third_party/harfbuzz-ng/src/.codecov.yml7
-rw-r--r--chromium/third_party/harfbuzz-ng/src/.travis.yml5
-rw-r--r--chromium/third_party/harfbuzz-ng/src/AUTHORS12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/BUILD.md2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/CMakeLists.txt149
-rw-r--r--chromium/third_party/harfbuzz-ng/src/NEWS193
-rw-r--r--chromium/third_party/harfbuzz-ng/src/README13
-rw-r--r--chromium/third_party/harfbuzz-ng/src/README.python.md2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/README.wine.md6
-rw-r--r--chromium/third_party/harfbuzz-ng/src/RELEASING.md8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/TODO12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/appveyor.yml18
-rw-r--r--chromium/third_party/harfbuzz-ng/src/azure-pipelines.yml21
-rw-r--r--chromium/third_party/harfbuzz-ng/src/configure.ac9
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/Makefile.am12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml264
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt163
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml778
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml223
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-hello-harfbuzz.xml183
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml443
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml374
-rw-r--r--chromium/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml474
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/HBIndicVowelConstraints.txt97
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/Makefile.am91
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/Makefile.sources18
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/dump-emoji.cc262
-rwxr-xr-xchromium/third_party/harfbuzz-ng/src/src/gen-def.py9
-rwxr-xr-xchromium/third_party/harfbuzz-ng/src/src/gen-emoji-table.py13
-rwxr-xr-xchromium/third_party/harfbuzz-ng/src/src/gen-tag-table.py1126
-rwxr-xr-xchromium/third_party/harfbuzz-ng/src/src/gen-use-table.py10
-rwxr-xr-xchromium/third_party/harfbuzz-ng/src/src/gen-vowel-constraints.py219
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-ankr-table.hh29
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-common.hh550
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-feat-table.hh124
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-just-table.hh417
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-kerx-table.hh1011
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-lcar-table.hh93
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-morx-table.hh444
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-trak-table.hh166
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.cc345
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.h462
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.hh61
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-ltag-table.hh17
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.cc68
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.hh94
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-aat.h (renamed from chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.h)37
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-atomic.hh24
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-blob.cc54
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-blob.hh30
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-buffer-serialize.cc18
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-buffer.cc101
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-buffer.h12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-buffer.hh27
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-common.cc76
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-common.h69
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-coretext.cc325
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-debug.hh29
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-deprecated.h224
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-directwrite.cc32
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-dsalgs.hh273
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-face.cc77
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-face.hh41
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-fallback-shape.cc27
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-font.cc243
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-font.h93
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-font.hh49
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ft.cc105
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-glib.cc66
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-gobject-structs.cc12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.cc69
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.h2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-icu.cc79
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-kern.hh139
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-machinery.hh220
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-map.cc11
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-map.hh8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-mutex.hh10
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-null.hh83
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-object.hh24
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-open-file.hh12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-open-type.hh423
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-cmap-table.hh315
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cbdt-table.hh241
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-colr-table.hh110
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cpal-table.hh204
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-sbix-table.hh202
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-svg-table.hh87
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.cc294
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.h139
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.cc27
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.hh52
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-font.cc151
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-glyf-table.hh290
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-hdmx-table.hh79
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-hmtx-table.hh108
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-kern-table.hh450
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-base-table.hh615
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-common.hh177
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gdef-table.hh42
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gpos-table.hh147
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsub-table.hh57
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh236
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.cc922
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.h111
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.hh68
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.cc34
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.hh12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-math-table.hh54
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-math.cc62
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-maxp-table.hh4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.cc457
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.hh40
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-table.hh215
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.cc224
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.h129
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-table.hh34
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-unicode-ranges.hh10
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-post-table.hh90
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh15
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc19
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-hangul.cc20
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-indic.cc288
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-khmer.cc9
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.cc77
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.hh48
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-thai.cc3
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use-table.cc4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use.cc91
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.cc437
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.hh39
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex.hh49
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.cc140
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.hh12
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.cc111
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.hh2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.cc495
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.hh83
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-stat-table.hh280
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag-table.hh2064
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.cc1118
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-avar-table.hh9
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-fvar-table.hh181
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-hvar-table.hh6
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-mvar-table.hh6
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.cc118
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.h89
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot-vorg-table.hh181
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ot.h3
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-set-digest.hh4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-set.cc13
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-set.hh47
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.cc413
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.hh56
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shape.cc14
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shaper-impl.hh9
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shaper-list.hh2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shaper.cc22
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-shaper.hh148
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-static.cc27
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.cc182
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.hh6
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.cc4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.hh1
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.cc47
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.hh13
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset.cc54
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset.h7
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-subset.hh2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-ucdn.cc34
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-unicode-emoji-table.hh189
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-unicode.cc65
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-unicode.h77
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-unicode.hh5
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-uniscribe.cc102
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-utf.hh241
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-vector.hh177
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb-version.h8
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb.h4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/hb.hh111
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/test-name-table.cc67
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/test-ot-color.cc336
-rw-r--r--chromium/third_party/harfbuzz-ng/src/src/test-size-params.cc2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/Makefile.am4
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/hb-shape.cc28
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/hb-subset.cc2
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/options.cc15
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/options.hh15
-rw-r--r--chromium/third_party/harfbuzz-ng/src/util/view-cairo.hh2
197 files changed, 19273 insertions, 8307 deletions
diff --git a/chromium/third_party/harfbuzz-ng/BUILD.gn b/chromium/third_party/harfbuzz-ng/BUILD.gn
index 56fe4734965..02cddf753a9 100644
--- a/chromium/third_party/harfbuzz-ng/BUILD.gn
+++ b/chromium/third_party/harfbuzz-ng/BUILD.gn
@@ -45,13 +45,22 @@ if (use_system_harfbuzz) {
visibility = [ "//third_party:freetype_harfbuzz" ]
sources = [
- "src/src/hb-atomic-private.hh",
- "src/src/hb-blob-private.hh",
+ "src/src/hb-aat-layout-ankr-table.hh",
+ "src/src/hb-aat-layout-bsln-table.hh",
+ "src/src/hb-aat-layout-feat-table.hh",
+ "src/src/hb-aat-layout-kerx-table.hh",
+ "src/src/hb-aat-layout-morx-table.hh",
+ "src/src/hb-aat-layout-trak-table.hh",
+ "src/src/hb-aat-layout.cc",
+ "src/src/hb-aat-ltag-table.hh",
+ "src/src/hb-aat-map.cc",
+ "src/src/hb-aat-map.hh",
+ "src/src/hb-atomic.hh",
"src/src/hb-blob.cc",
"src/src/hb-blob.h",
+ "src/src/hb-blob.hh",
"src/src/hb-buffer-deserialize-json.hh",
"src/src/hb-buffer-deserialize-text.hh",
- "src/src/hb-buffer-private.hh",
"src/src/hb-buffer-serialize.cc",
"src/src/hb-buffer.cc",
"src/src/hb-buffer.h",
@@ -62,25 +71,25 @@ if (use_system_harfbuzz) {
"src/src/hb-debug.hh",
"src/src/hb-deprecated.h",
"src/src/hb-dsalgs.hh",
- "src/src/hb-face-private.hh",
"src/src/hb-face.cc",
"src/src/hb-face.h",
- "src/src/hb-font-private.hh",
+ "src/src/hb-face.hh",
"src/src/hb-font.cc",
"src/src/hb-font.h",
+ "src/src/hb-font.hh",
"src/src/hb-ft.cc",
"src/src/hb-ft.h",
"src/src/hb-icu.cc",
"src/src/hb-icu.h",
- "src/src/hb-mutex-private.hh",
- "src/src/hb-object-private.hh",
- "src/src/hb-open-file-private.hh",
- "src/src/hb-open-type-private.hh",
+ "src/src/hb-mutex.hh",
+ "src/src/hb-object.hh",
+ "src/src/hb-open-file.hh",
+ "src/src/hb-open-type.hh",
"src/src/hb-ot-color-cbdt-table.hh",
"src/src/hb-ot-color-colr-table.hh",
"src/src/hb-ot-color-cpal-table.hh",
"src/src/hb-ot-face.cc",
- "src/src/hb-ot-face.h",
+ "src/src/hb-ot-face.hh",
"src/src/hb-ot-font.cc",
"src/src/hb-ot-font.h",
"src/src/hb-ot-hdmx-table.hh",
@@ -90,55 +99,59 @@ if (use_system_harfbuzz) {
"src/src/hb-ot-kern-table.hh",
"src/src/hb-ot-layout-base-table.hh",
"src/src/hb-ot-layout-base-table.hh",
- "src/src/hb-ot-layout-common-private.hh",
+ "src/src/hb-ot-layout-common.hh",
"src/src/hb-ot-layout-gdef-table.hh",
"src/src/hb-ot-layout-gpos-table.hh",
"src/src/hb-ot-layout-gsub-table.hh",
- "src/src/hb-ot-layout-gsubgpos-private.hh",
- "src/src/hb-ot-layout-private.hh",
+ "src/src/hb-ot-layout-gsubgpos.hh",
"src/src/hb-ot-layout.cc",
"src/src/hb-ot-layout.h",
- "src/src/hb-ot-map-private.hh",
+ "src/src/hb-ot-layout.hh",
"src/src/hb-ot-map.cc",
+ "src/src/hb-ot-map.hh",
"src/src/hb-ot-math-table.hh",
"src/src/hb-ot-math.cc",
"src/src/hb-ot-math.h",
"src/src/hb-ot-maxp-table.hh",
+ "src/src/hb-ot-name-language.cc",
+ "src/src/hb-ot-name-language.hh",
"src/src/hb-ot-name-table.hh",
+ "src/src/hb-ot-name.cc",
"src/src/hb-ot-os2-unicode-ranges.hh",
"src/src/hb-ot-post-macroman.hh",
"src/src/hb-ot-shape-complex-arabic-fallback.hh",
- "src/src/hb-ot-shape-complex-arabic-private.hh",
"src/src/hb-ot-shape-complex-arabic-table.hh",
"src/src/hb-ot-shape-complex-arabic.cc",
+ "src/src/hb-ot-shape-complex-arabic.hh",
"src/src/hb-ot-shape-complex-default.cc",
"src/src/hb-ot-shape-complex-hangul.cc",
"src/src/hb-ot-shape-complex-hebrew.cc",
"src/src/hb-ot-shape-complex-indic-machine.hh",
- "src/src/hb-ot-shape-complex-indic-private.hh",
"src/src/hb-ot-shape-complex-indic-table.cc",
"src/src/hb-ot-shape-complex-indic.cc",
+ "src/src/hb-ot-shape-complex-indic.hh",
"src/src/hb-ot-shape-complex-khmer-machine.hh",
- "src/src/hb-ot-shape-complex-khmer-private.hh",
"src/src/hb-ot-shape-complex-khmer.cc",
+ "src/src/hb-ot-shape-complex-khmer.hh",
"src/src/hb-ot-shape-complex-myanmar-machine.hh",
- "src/src/hb-ot-shape-complex-myanmar-private.hh",
"src/src/hb-ot-shape-complex-myanmar.cc",
- "src/src/hb-ot-shape-complex-private.hh",
+ "src/src/hb-ot-shape-complex-myanmar.hh",
"src/src/hb-ot-shape-complex-thai.cc",
"src/src/hb-ot-shape-complex-use-machine.hh",
- "src/src/hb-ot-shape-complex-use-private.hh",
"src/src/hb-ot-shape-complex-use-table.cc",
"src/src/hb-ot-shape-complex-use.cc",
- "src/src/hb-ot-shape-fallback-private.hh",
+ "src/src/hb-ot-shape-complex-use.hh",
+ "src/src/hb-ot-shape-complex-vowel-constraints.cc",
+ "src/src/hb-ot-shape-complex-vowel-constraints.hh",
+ "src/src/hb-ot-shape-complex.hh",
"src/src/hb-ot-shape-fallback.cc",
- "src/src/hb-ot-shape-normalize-private.hh",
+ "src/src/hb-ot-shape-fallback.hh",
"src/src/hb-ot-shape-normalize.cc",
- "src/src/hb-ot-shape-private.hh",
+ "src/src/hb-ot-shape-normalize.hh",
"src/src/hb-ot-shape.cc",
"src/src/hb-ot-shape.h",
+ "src/src/hb-ot-shape.hh",
"src/src/hb-ot-tag.cc",
- "src/src/hb-ot-tag.h",
"src/src/hb-ot-var-avar-table.hh",
"src/src/hb-ot-var-fvar-table.hh",
"src/src/hb-ot-var-hvar-table.hh",
@@ -146,34 +159,34 @@ if (use_system_harfbuzz) {
"src/src/hb-ot-var.cc",
"src/src/hb-ot-var.h",
"src/src/hb-ot.h",
- "src/src/hb-private.hh",
- "src/src/hb-set-digest-private.hh",
- "src/src/hb-set-private.hh",
+ "src/src/hb-set-digest.hh",
"src/src/hb-set.cc",
"src/src/hb-set.h",
- "src/src/hb-shape-plan-private.hh",
+ "src/src/hb-set.hh",
"src/src/hb-shape-plan.cc",
"src/src/hb-shape-plan.h",
+ "src/src/hb-shape-plan.hh",
"src/src/hb-shape.cc",
"src/src/hb-shape.h",
- "src/src/hb-shaper-impl-private.hh",
+ "src/src/hb-shaper-impl.hh",
"src/src/hb-shaper-list.hh",
- "src/src/hb-shaper-private.hh",
"src/src/hb-shaper.cc",
+ "src/src/hb-shaper.hh",
"src/src/hb-static.cc",
"src/src/hb-string-array.hh",
"src/src/hb-subset-glyf.hh",
- "src/src/hb-subset-plan.h",
- "src/src/hb-subset-private.hh",
+ "src/src/hb-subset-plan.hh",
"src/src/hb-subset.h",
"src/src/hb-subset.hh",
"src/src/hb-unicode-emoji-table.hh",
"src/src/hb-unicode.cc",
"src/src/hb-unicode.h",
- "src/src/hb-utf-private.hh",
+ "src/src/hb-unicode.hh",
+ "src/src/hb-utf.hh",
"src/src/hb-version.h",
"src/src/hb-warning.cc",
"src/src/hb.h",
+ "src/src/hb.hh",
]
defines = [
@@ -206,13 +219,23 @@ if (use_system_harfbuzz) {
# correctly.
":harfbuzz_warnings",
]
+
+ # This allows the compiler to do further optimizations in the code.
+ if (!is_debug) {
+ configs -= [ "//build/config/compiler:default_optimization" ]
+ configs += [ "//build/config/compiler:optimize_speed" ]
+ }
+
public_configs = [ ":harfbuzz_config" ]
deps = [
"//third_party/icu:icuuc",
]
- if (is_mac) {
+ # TODO(https://crbug.com/894354): Change this to is_mac to revert to
+ # CoreText AAT. Remove this backstop and the whole hb-coretext build clause
+ # here once we have reliably switched to HarfBuzz AAT for one stable cycle.
+ if (false) {
sources += [
"src/src/hb-coretext.cc",
"src/src/hb-coretext.h",
diff --git a/chromium/third_party/harfbuzz-ng/README.chromium b/chromium/third_party/harfbuzz-ng/README.chromium
index 3cbc9ccf0b3..efe27434752 100644
--- a/chromium/third_party/harfbuzz-ng/README.chromium
+++ b/chromium/third_party/harfbuzz-ng/README.chromium
@@ -1,9 +1,9 @@
Name: harfbuzz-ng
Short Name: harfbuzz-ng
URL: http://harfbuzz.org
-Version: 1.9.0.1f14107f7
-Date: 20181005
-Revision: 1f14107f71a6c3da8270ed21c3588f945fa91733
+Version: 2.1.3-182
+Date: 20181129
+Revision: e0307de818ad1f70ef96938642bda61d7a62532a
Security Critical: yes
License: MIT
License File: src/COPYING
@@ -12,18 +12,14 @@ Description:
This is harfbuzz-ng, a new implementation of harfbuzz with a different
API from the old one.
-This copy of harfbuzz is updated by putting the new commit hash matching one in
-https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz/ to the
-top level DEPS file. When upgrading, check in ther HarfBuzz repository whether
-files have been added or removed in upstream and whether the BUILD.gn file needs
-to be updated to reflect that or whether the files can be added to the exception
-lis below.
+This copy of harfbuzz is usually updated by running
+ $ third_party/harfbuzz-ng/roll-harfbuzz.sh
+from your Chromium ./src directory.
-Example:
- $ cd ~/dev/harfbuzz/
- $ git diff --diff-filter=A --stat 1.8.3..1.8.7
-
-Replace 1.8.3 and 1.8.7 with the respective revision hashes for your roll CL.
+This should update your checkout by putting the new upstream HarfBuzz ToT commit
+hash top level DEPS file. In cases added or deleted files have been detected in
+HarfBuzz' src directory, a step in the script will fail and you should edit the
+BUILD.gn file accordingly and continue the roll manually.
Chromium-local cherry picks or patches can be done by pushing new branches to
refs/heads/chromium/ of [1]. The set of HarfBuzz OWNERS has write rights to this
@@ -33,23 +29,15 @@ cherry-pick is needed for M65, push to "refs/heads/chromium/m65" and reference
the new commit in DEPS. Take a look at
https://chromium-review.googlesource.com/c/chromium/src/+/937502 for an example.
-Currently we are intentionally not building the following files from HarfBuzz.
+Currently we are intentionally not building the following files from
+HarfBuzz. Specifically, we are not building hb-coretext any longer, as we rely
+on HarfBuzz' built-in AAT shaping.
dump-indic-data.cc
dump-khmer-data.cc
dump-myanmar-data.cc
dump-use-data.cc
- hb-aat-fmtx-table.hh
- hb-aat-gcid-table.hh
- hb-aat-layout-ankr-table.hh
- hb-aat-layout-bsln-table.hh
- hb-aat-layout-common-private.hh
- hb-aat-layout-feat-table.hh
- hb-aat-layout-kerx-table.hh
- hb-aat-layout-morx-table.hh
- hb-aat-layout-private.hh
- hb-aat-layout-trak-table.hh
- hb-aat-layout.cc
- hb-aat-ltag-table.hh
+ hb-coretext.h
+ hb-coretext.cc
hb-directwrite.cc
hb-directwrite.h
hb-fallback-shape.cc
diff --git a/chromium/third_party/harfbuzz-ng/roll-harfbuzz.sh b/chromium/third_party/harfbuzz-ng/roll-harfbuzz.sh
new file mode 100755
index 00000000000..670930aec04
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/roll-harfbuzz.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+rolldeps() {
+ STEP="roll-deps" &&
+ REVIEWERS=$(grep -E -v "^$|#" third_party/harfbuzz-ng/OWNERS | paste -s -d,) &&
+ roll-dep -r "${REVIEWERS}" --roll-to origin/upstream/master "$@" src/third_party/harfbuzz-ng/src/
+}
+
+updatereadme() {
+ STEP="update README.chromium" &&
+ HBVERSION=$(git -C third_party/harfbuzz-ng/src/ describe --long) &&
+ HBCOMMIT=$(git -C third_party/harfbuzz-ng/src/ rev-parse HEAD) &&
+ HBDATE=$(date "+%Y%m%d")
+ sed -i'' -e "s/^Version: .*\$/Version: ${HBVERSION%-*}/" third_party/harfbuzz-ng/README.chromium &&
+ sed -i'' -e "s/^Revision: .*\$/Revision: ${HBCOMMIT}/" third_party/harfbuzz-ng/README.chromium &&
+ sed -i'' -e "s/^Date: .*\$/Date: ${HBDATE}/" third_party/harfbuzz-ng/README.chromium &&
+ git add third_party/harfbuzz-ng/README.chromium
+}
+
+previousrev() {
+ STEP="original revision" &&
+ PREVIOUS_HARFBUZZ_REV=$(git grep "'harfbuzz_revision':" HEAD~1 -- DEPS | grep -Eho "[0-9a-fA-F]{32}")
+}
+
+check_added_deleted_files() {
+ STEP="Check for added or deleted files since last HarfBuzz revision" &&
+ previousrev &&
+ ADDED_FILES=$(git -C third_party/harfbuzz-ng/src/ diff --diff-filter=A --name-only ${PREVIOUS_HARFBUZZ_REV} -- src/ | paste -s -d,) &&
+ DELETED_FILES=$(git -C third_party/harfbuzz-ng/src/ diff --diff-filter=D --name-only ${PREVIOUS_HARFBUZZ_REV} -- src/ | paste -s -d,) &&
+ if [ -n "$ADDED_FILES" ]; then echo "Added files detected: " $ADDED_FILES; fi &&
+ if [ -n "$DELETED_FILES" ]; then echo "Deleted files detected" $DELETED_FILES; fi &&
+ if [ -n "$ADDED_FILES" ] || [ -n "$DELETED_FILES" ]; then echo -e "\nPlease update src/third_party/harfbuzz-ng/BUILD.gn before continuing."; fi
+}
+
+commit() {
+ STEP="commit" &&
+ git commit --quiet --amend --no-edit
+}
+
+rolldeps "$@" &&
+updatereadme &&
+check_added_deleted_files &&
+commit ||
+{ echo "Failed step ${STEP}"; exit 1; }
diff --git a/chromium/third_party/harfbuzz-ng/src/.circleci/config.yml b/chromium/third_party/harfbuzz-ng/src/.circleci/config.yml
index af443ad929b..320813ad309 100644
--- a/chromium/third_party/harfbuzz-ng/src/.circleci/config.yml
+++ b/chromium/third_party/harfbuzz-ng/src/.circleci/config.yml
@@ -2,30 +2,60 @@ version: 2
jobs:
- macos-llvm-gcc-4.2:
+ macos-10.12.6-aat-fonts:
macos:
- xcode: "8.3.3"
+ xcode: "9.2.0"
steps:
- checkout
- - run: brew update-reset
- - run: brew install wget pkg-config libtool ragel freetype glib cairo
- - run: wget https://packages.macports.org/llvm-gcc42/llvm-gcc42-2336.11_3+universal.darwin_15.i386-x86_64.tbz2 && tar zxvf llvm-gcc42-2336.11_3+universal.darwin_15.i386-x86_64.tbz2
- - run: CC=$PWD/opt/local/bin/llvm-gcc-4.2 CXX=$PWD/opt/local/bin/llvm-g++-4.2 ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo
- # Ignoring assembler complains, https://stackoverflow.com/a/39867021
- - run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
+ - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install wget pkg-config libtool ragel freetype glib cairo
+ - run: ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo
+ - run: make -j4
- run: make check || .ci/fail.sh
- macos-notest-apple-gcc-i686-4.2:
+ macos-10.13.6-aat-fonts:
macos:
- xcode: "8.3.3"
+ xcode: "10.1.0"
steps:
- checkout
- - run: brew update-reset
- - run: brew install wget pkg-config libtool ragel
- - run: wget https://packages.macports.org/apple-gcc42/apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2 && tar zxvf apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2
- - run: CPP=$PWD/opt/local/bin/i686-apple-darwin15-cpp-apple-4.2.1 CC=$PWD/opt/local/bin/i686-apple-darwin15-gcc-apple-4.2.1 CXX=$PWD/opt/local/bin/i686-apple-darwin15-g++-apple-4.2.1 ./autogen.sh
- # Ignoring assembler complains, https://stackoverflow.com/a/39867021
- - run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
+ - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install wget pkg-config libtool ragel freetype glib cairo
+ - run: ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo
+ - run: make -j4
+ - run: make check || .ci/fail.sh
+
+ # macos-llvm-gcc-4.2:
+ # macos:
+ # xcode: "8.3.3"
+ # steps:
+ # - checkout
+ # - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install wget pkg-config libtool ragel freetype glib cairo
+ # - run: wget https://packages.macports.org/llvm-gcc42/llvm-gcc42-2336.11_3+universal.darwin_15.i386-x86_64.tbz2 && tar zxvf llvm-gcc42-2336.11_3+universal.darwin_15.i386-x86_64.tbz2
+ # - run: CC=$PWD/opt/local/bin/llvm-gcc-4.2 CXX=$PWD/opt/local/bin/llvm-g++-4.2 ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo
+ # # Ignoring assembler complains, https://stackoverflow.com/a/39867021
+ # - run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
+ # - run: make check || .ci/fail.sh
+
+ # macos-notest-apple-gcc-i686-4.2:
+ # macos:
+ # xcode: "8.3.3"
+ # steps:
+ # - checkout
+ # - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install wget pkg-config libtool ragel
+ # - run: wget https://packages.macports.org/apple-gcc42/apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2 && tar zxvf apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2
+ # - run: CPP=$PWD/opt/local/bin/i686-apple-darwin15-cpp-apple-4.2.1 CC=$PWD/opt/local/bin/i686-apple-darwin15-gcc-apple-4.2.1 CXX=$PWD/opt/local/bin/i686-apple-darwin15-g++-apple-4.2.1 ./autogen.sh
+ # # Ignoring assembler complains, https://stackoverflow.com/a/39867021
+ # - run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
+
+ macos-notest-ios:
+ macos:
+ xcode: "10.0.0"
+ steps:
+ - checkout
+ - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake
+ # not needed to be a framework but we like to test that also
+ # TODO: wrong way of targeting iOS as it doesn't point to iOS headers thus building
+ # CoreText support is not possible, after the fix feel free HB_IOS from CMake altogether
+ - run: cmake -DBUILD_FRAMEWORK=ON -H. -Bbuild -GXcode -DHB_HAVE_CORETEXT=OFF -DHB_BUILD_SUBSET=OFF -DHB_BUILD_TESTS=OFF
+ - run: cd build && xcodebuild -sdk iphoneos12.0 -configuration Release build -arch arm64
distcheck:
docker:
@@ -79,6 +109,22 @@ jobs:
- run: make -j32
- run: LD_LIBRARY_PATH="$PWD/freetype-2.9/objs/.libs" make check || .ci/fail.sh
+ gcc-valgrind:
+ docker:
+ - image: ubuntu:18.10
+ steps:
+ - checkout
+ - run: apt update || true
+ - run: apt install -y gcc binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libfontconfig1-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip valgrind
+ - run: pip install fonttools
+ - run: ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 --with-fontconfig
+ - run: make -j32
+ # run-shape-fuzzer-tests.py automatically runs valgrind if see available
+ # but test/api runs it by request, we probably should normalize the approaches
+ - run: RUN_VALGRIND=1 make check && make -Ctest/api check-valgrind || .ci/fail.sh
+ # informational for now
+ - run: make -Ctest/api check-symbols || true
+
clang-everything:
docker:
- image: ubuntu:18.10
@@ -91,7 +137,7 @@ jobs:
- run: apt update || true
- run: apt install -y clang lld binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libfontconfig1-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
- run: pip install fonttools
- - run: CFLAGS="-Weverything -Wno-reserved-id-macro -Wno-conversion -Wno-padded -Wno-sign-conversion -Wno-cast-qual -Wno-documentation -Wno-documentation-unknown-command" CXXFLAGS="-Weverything -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-c++98-compat -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-padded -Wno-shorten-64-to-32 -Wno-extra-semi -Wno-reserved-id-macro -Wno-float-conversion -Wno-format-pedantic -Wno-shadow -Wno-conversion -Wno-zero-as-null-pointer-constant -Wno-missing-field-initializers -Wno-used-but-marked-unused -Wno-unused-macros -Wno-comma -Wno-float-equal -Wno-disabled-macro-expansion -Wno-weak-vtables -Wno-unused-parameter -Wno-covered-switch-default -Wno-unreachable-code" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 --with-fontconfig
+ - run: CFLAGS="-Weverything -Wno-reserved-id-macro -Wno-conversion -Wno-padded -Wno-sign-conversion -Wno-cast-qual -Wno-documentation -Wno-documentation-unknown-command" CXXFLAGS="-Weverything -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-c++98-compat -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-padded -Wno-shorten-64-to-32 -Wno-reserved-id-macro -Wno-float-conversion -Wno-format-pedantic -Wno-shadow -Wno-conversion -Wno-zero-as-null-pointer-constant -Wno-missing-field-initializers -Wno-used-but-marked-unused -Wno-unused-macros -Wno-comma -Wno-float-equal -Wno-disabled-macro-expansion -Wno-weak-vtables -Wno-unused-parameter -Wno-covered-switch-default -Wno-unreachable-code" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 --with-fontconfig
- run: make -j32 CPPFLAGS="-Werror"
- run: make check CPPFLAGS="-Werror" || .ci/fail.sh
@@ -126,7 +172,7 @@ jobs:
- run: update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.lld" 10
- run: wget https://ftp.gnome.org/pub/gnome/sources/glib/2.58/glib-2.58.1.tar.xz && tar xf glib-2.58.1.tar.xz && cd glib-2.58.1 && ./autogen.sh --with-pcre CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory" CFLAGS="-fsanitize=memory" CXXFLAGS="-fsanitize=memory" LD=ld.lld CC=clang CXX=clang++ && make -j32 && make install && cd ..
- run: wget http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2 && tar xf freetype-2.9.tar.bz2 && cd freetype-2.9 && ./autogen.sh && ./configure CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ && make -j32 && make install && cd ..
- - run: CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --without-icu
+ - run: CPPFLAGS="-fsanitize=memory -fsanitize-memory-track-origins" LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --without-icu
- run: make -j32 && MSAN_OPTIONS=exitcode=42 make check || .ci/fail.sh | asan_symbolize | c++filt
clang-tsan:
@@ -196,6 +242,7 @@ jobs:
crosscompile-notest-djgpp:
docker:
+ # https://gist.github.com/ebraminio/8551fc74f27951e668102baa2f6b1175
- image: quay.io/ebraminio/djgpp
steps:
- checkout
@@ -258,22 +305,25 @@ jobs:
- run: cmake -Bbuild -H. -GNinja
- run: ninja -Cbuild
- crosscompile-cmake-notest-windows-x64:
- docker:
- - image: dockcross/windows-x64
- steps:
- - checkout
- - run: apt update && apt install ragel
- - run: cmake -Bbuild -H. -GNinja
- - run: ninja -Cbuild
+ #crosscompile-cmake-notest-windows-x64:
+ # docker:
+ # - image: dockcross/windows-x64
+ # steps:
+ # - checkout
+ # - run: apt update && apt install ragel
+ # - run: cmake -Bbuild -H. -GNinja
+ # - run: ninja -Cbuild
workflows:
version: 2
build:
jobs:
# macOS
- - macos-llvm-gcc-4.2
- - macos-notest-apple-gcc-i686-4.2
+ - macos-10.12.6-aat-fonts
+ - macos-10.13.6-aat-fonts
+ #- macos-llvm-gcc-4.2
+ #- macos-notest-apple-gcc-i686-4.2
+ - macos-notest-ios
# both autotools and cmake
- distcheck
@@ -281,6 +331,7 @@ workflows:
# autotools based builds
- alpine-O3-NOMMAP
- archlinux-debug-O0-py3
+ - gcc-valgrind
- clang-O3-O0
- clang-everything
- clang-asan
@@ -305,4 +356,4 @@ workflows:
- crosscompile-cmake-notest-browser-asmjs
- crosscompile-cmake-notest-linux-arm64
- crosscompile-cmake-notest-linux-mips
- - crosscompile-cmake-notest-windows-x64
+ #- crosscompile-cmake-notest-windows-x64
diff --git a/chromium/third_party/harfbuzz-ng/src/.codecov.yml b/chromium/third_party/harfbuzz-ng/src/.codecov.yml
new file mode 100644
index 00000000000..e9b8ab4814d
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/.codecov.yml
@@ -0,0 +1,7 @@
+comment: off
+
+coverage:
+ status:
+ project:
+ default:
+ threshold: 1%
diff --git a/chromium/third_party/harfbuzz-ng/src/.travis.yml b/chromium/third_party/harfbuzz-ng/src/.travis.yml
index eadfa76796a..c2db4ff0127 100644
--- a/chromium/third_party/harfbuzz-ng/src/.travis.yml
+++ b/chromium/third_party/harfbuzz-ng/src/.travis.yml
@@ -11,7 +11,7 @@ env:
- CONFIGURE_OPTS="--with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2"
- NOCONFIGURE=1
# COVERITY_SCAN_TOKEN
- - secure: "MRJtVu/fQoWNwMAamvIJBCX/1SMvEuEUk/ljAif/y2/3syyWgxFGp17UGnDILdoZYyCqTM+jQciY2P0nVqbjjOAUlML4QOAalqw8kPp8iTsnHUe+KOMVrOVP6p6qAQxk1im1O41cCMkmVKvk+NXe/on5euz6LGF2laHZaOAMoes="
+ - secure: "k6l/18dpsoPAf0E5RQWCr+rgjbHns0H3k0WzSYovCoVg0B7RVlV8x8OjyEOBzEvXI4aaHRdH6MHCPDFnX4fa7ysImlT6LxxIG8YhDdLkJWyS0hHbcJiGxko9AhAGzOZcDl8fZi13d697wagMqqXpjN5v2T/AQm8t4X9z2otJosY="
matrix:
include:
@@ -28,7 +28,8 @@ matrix:
- make check || .ci/fail.sh
- rm -rf freetype-2.9
after_success:
- - bash .ci/run-coveralls.sh # for coveralls.io code coverage tracking
+ - bash .ci/run-coveralls.sh # coveralls.io code coverage
+ - bash <(curl -s https://codecov.io/bash) # codecov.io code coverage
- bash .ci/deploy-docs.sh
- bash .ci/trigger-coverity.sh
diff --git a/chromium/third_party/harfbuzz-ng/src/AUTHORS b/chromium/third_party/harfbuzz-ng/src/AUTHORS
index 81cdc4cf37f..0763761bbf8 100644
--- a/chromium/third_party/harfbuzz-ng/src/AUTHORS
+++ b/chromium/third_party/harfbuzz-ng/src/AUTHORS
@@ -1,9 +1,11 @@
Behdad Esfahbod
-Simon Hausmann
-Martin Hosken
+David Turner
+Ebrahim Byagowi
Jonathan Kew
+Khaled Hosny
Lars Knoll
-Werner Lemberg
-Roozbeh Pournader
+Martin Hosken
Owen Taylor
-David Turner
+Roozbeh Pournader
+Simon Hausmann
+Werner Lemberg
diff --git a/chromium/third_party/harfbuzz-ng/src/BUILD.md b/chromium/third_party/harfbuzz-ng/src/BUILD.md
index 8a6b5695a06..4c1c306450c 100644
--- a/chromium/third_party/harfbuzz-ng/src/BUILD.md
+++ b/chromium/third_party/harfbuzz-ng/src/BUILD.md
@@ -26,7 +26,7 @@ as with any other standard package. That should leave you with a shared
library in `src/`, and a few utility programs including `hb-view` and `hb-shape`
under `util/`.
-If you are bootstraping from git, you need a few more tools before you can
+If you are bootstrapping from git, you need a few more tools before you can
run `autogen.sh` for the first time. Namely, `pkg-config` and `ragel`.
Again, on Ubuntu / Debian:
diff --git a/chromium/third_party/harfbuzz-ng/src/CMakeLists.txt b/chromium/third_party/harfbuzz-ng/src/CMakeLists.txt
index 69496561748..019e205bc63 100644
--- a/chromium/third_party/harfbuzz-ng/src/CMakeLists.txt
+++ b/chromium/third_party/harfbuzz-ng/src/CMakeLists.txt
@@ -52,6 +52,9 @@ if (HB_BUILD_UTILS)
set (HB_HAVE_FREETYPE ON)
endif ()
+option(HB_BUILD_SUBSET "Build harfbuzz-subset" ON)
+option(HB_BUILD_TESTS "Build harfbuzz tests" ON)
+
option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF)
if (HB_HAVE_GOBJECT)
set (HB_HAVE_GLIB ON)
@@ -87,7 +90,6 @@ include_directories(AFTER
${PROJECT_BINARY_DIR}/src
)
-add_definitions(-DHAVE_OT)
add_definitions(-DHAVE_FALLBACK)
# We need PYTHON_EXECUTABLE to be set for running the tests...
@@ -98,10 +100,10 @@ include (CheckFunctionExists)
include (CheckIncludeFile)
macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools
foreach (func_name ${ARGN})
- string(TOUPPER ${func_name} definiton_to_add)
- check_function_exists(${func_name} HAVE_${definiton_to_add})
- if (${HAVE_${definiton_to_add}})
- add_definitions(-DHAVE_${definiton_to_add})
+ string(TOUPPER ${func_name} definition_to_add)
+ check_function_exists(${func_name} HAVE_${definition_to_add})
+ if (${HAVE_${definition_to_add}})
+ add_definitions(-DHAVE_${definition_to_add})
endif ()
endforeach ()
endmacro ()
@@ -359,12 +361,32 @@ if (APPLE AND HB_HAVE_CORETEXT)
list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-coretext.cc)
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-coretext.h)
- find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices)
- if (APPLICATION_SERVICES_FRAMEWORK)
- list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK})
- endif (APPLICATION_SERVICES_FRAMEWORK)
+ if (HB_IOS)
+ find_library(COREFOUNDATION CoreFoundation)
+ if (COREFOUNDATION)
+ list(APPEND THIRD_PARTY_LIBS ${COREFOUNDATION})
+ endif ()
+ mark_as_advanced(COREFOUNDATION)
+
+ find_library(CORETEXT CoreText)
+ if (CORETEXT)
+ list(APPEND THIRD_PARTY_LIBS ${CORETEXT})
+ endif ()
+ mark_as_advanced(CORETEXT)
+
+ find_library(COREGRAPHICS CoreGraphics)
+ if (COREGRAPHICS)
+ list(APPEND THIRD_PARTY_LIBS ${COREGRAPHICS})
+ endif ()
+ mark_as_advanced(COREGRAPHICS)
+ else ()
+ find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices)
+ if (APPLICATION_SERVICES_FRAMEWORK)
+ list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK})
+ endif ()
- mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK)
+ mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK)
+ endif ()
endif ()
if (WIN32 AND HB_HAVE_UNISCRIBE)
@@ -527,12 +549,14 @@ add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_heade
target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})
## Define harfbuzz-subset library
-add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers})
-add_dependencies(harfbuzz-subset harfbuzz)
-target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS})
+if (HB_BUILD_SUBSET)
+ add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers})
+ add_dependencies(harfbuzz-subset harfbuzz)
+ target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS})
-if (BUILD_SHARED_LIBS)
- set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
+ if (BUILD_SHARED_LIBS)
+ set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
+ endif ()
endif ()
if (UNIX OR MINGW)
@@ -549,7 +573,9 @@ if (UNIX OR MINGW)
set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm
set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C)
- set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
+ if (HB_BUILD_SUBSET)
+ set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
+ endif ()
# No threadsafe statics as we do it ourselves
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
@@ -574,7 +600,7 @@ if (HB_HAVE_GOBJECT)
endif ()
if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW)
- add_definitions("-DHB_EXTERN=__declspec(dllexport) extern")
+ add_definitions("-DHB_DLL_EXPORT")
endif ()
# On Windows, g-ir-scanner requires a DLL build in order for it to work
@@ -772,6 +798,11 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz
)
if (HB_BUILD_UTILS)
+ if (WIN32 AND BUILD_SHARED_LIBS)
+ install(TARGETS harfbuzz-subset
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+ endif ()
install(TARGETS hb-view
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
@@ -823,51 +854,53 @@ if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
endif ()
-## src/ executables
-foreach (prog main test test-would-substitute test-size-params test-buffer-serialize hb-ot-tag test-unicode-ranges)
- set (prog_name ${prog})
- if (${prog_name} STREQUAL "test")
- # test can not be used as a valid executable name on cmake, lets special case it
- set (prog_name test-test)
- endif ()
- add_executable(${prog_name} ${PROJECT_SOURCE_DIR}/src/${prog}.cc)
- target_link_libraries(${prog_name} harfbuzz ${THIRD_PARTY_LIBS})
-endforeach ()
-set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN")
-
-## Tests
-if (UNIX OR MINGW)
- if (BUILD_SHARED_LIBS)
- # generate harfbuzz.def after build completion
- add_custom_command(TARGET harfbuzz POST_BUILD
- COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers}
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
-
- add_test(NAME check-static-inits.sh
- COMMAND ${PROJECT_SOURCE_DIR}/src/check-static-inits.sh
- WORKING_DIRECTORY ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/harfbuzz.dir/src # ugly hack
- )
- add_test(NAME check-libstdc++.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh)
- add_test(NAME check-symbols.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-symbols.sh)
+if (HB_BUILD_TESTS)
+ ## src/ executables
+ foreach (prog main test test-would-substitute test-size-params test-buffer-serialize hb-ot-tag test-unicode-ranges)
+ set (prog_name ${prog})
+ if (${prog_name} STREQUAL "test")
+ # test can not be used as a valid executable name on cmake, lets special case it
+ set (prog_name test-test)
+ endif ()
+ add_executable(${prog_name} ${PROJECT_SOURCE_DIR}/src/${prog}.cc)
+ target_link_libraries(${prog_name} harfbuzz ${THIRD_PARTY_LIBS})
+ endforeach ()
+ set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN")
+
+ ## Tests
+ if (UNIX OR MINGW)
+ if (BUILD_SHARED_LIBS)
+ # generate harfbuzz.def after build completion
+ add_custom_command(TARGET harfbuzz POST_BUILD
+ COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers}
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
+
+ add_test(NAME check-static-inits.sh
+ COMMAND ${PROJECT_SOURCE_DIR}/src/check-static-inits.sh
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/harfbuzz.dir/src # ugly hack
+ )
+ add_test(NAME check-libstdc++.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh)
+ add_test(NAME check-symbols.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-symbols.sh)
+
+ set_tests_properties(
+ check-static-inits.sh check-libstdc++.sh check-symbols.sh
+ PROPERTIES
+ ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src"
+ SKIP_RETURN_CODE 77)
+ endif ()
+ add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh)
+ add_test(NAME check-header-guards.sh COMMAND ./check-header-guards.sh)
+ add_test(NAME check-externs.sh COMMAND ./check-externs.sh)
+ add_test(NAME check-includes.sh COMMAND ./check-includes.sh)
set_tests_properties(
- check-static-inits.sh check-libstdc++.sh check-symbols.sh
+ check-c-linkage-decls.sh check-header-guards.sh check-externs.sh check-includes.sh
PROPERTIES
- ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src"
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
SKIP_RETURN_CODE 77)
endif ()
- add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh)
- add_test(NAME check-header-guards.sh COMMAND ./check-header-guards.sh)
- add_test(NAME check-externs.sh COMMAND ./check-externs.sh)
- add_test(NAME check-includes.sh COMMAND ./check-includes.sh)
- set_tests_properties(
- check-c-linkage-decls.sh check-header-guards.sh check-externs.sh check-includes.sh
- PROPERTIES
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
- SKIP_RETURN_CODE 77)
+ # Needs to come last so that variables defined above are passed to
+ # subdirectories.
+ add_subdirectory(test)
endif ()
-
-# Needs to come last so that variables defined above are passed to
-# subdirectories.
-add_subdirectory(test)
diff --git a/chromium/third_party/harfbuzz-ng/src/NEWS b/chromium/third_party/harfbuzz-ng/src/NEWS
index c9af0f36853..9bfe99a2d68 100644
--- a/chromium/third_party/harfbuzz-ng/src/NEWS
+++ b/chromium/third_party/harfbuzz-ng/src/NEWS
@@ -1,3 +1,196 @@
+Overview of changes leading to 2.1.3
+Friday, November 16, 2018
+====================================
+- Fix AAT 'mort' shaping, which was broken in 2.1.2
+
+
+Overview of changes leading to 2.1.2
+Friday, November 16, 2018
+====================================
+- Various internal changes.
+- AAT shaping improvements:
+ o Implement kern table Format 1 state-machine-based kerning.
+ o Implement cross-stream kerning (cursive positioning, etc).
+ o Ignore emptyish GSUB tables (zero scripts) if morx present.
+ o Don't apply GPOS if morx is being applied. Matches Apple.
+
+
+-Overview of changes leading to 2.1.1
+Monday, November 5, 2018
+====================================
+- AAT improvements:
+ o Implement 'mort' table.
+ o Implement 'kern' subtables Format 1 and Format 3.
+
+
+Overview of changes leading to 2.1.0
+Tuesday, October 30, 2018
+====================================
+- AAT shaping improvements:
+ o Allow user controlling AAT features, for whole buffer only currently.
+ o Several 'morx' fixes.
+ o Implement tuple-kerns in 'kerx'; Fixes kerning with Apple default
+ San Francisco fonts.
+- Support for color fonts:
+ o COLR/CPAL API to fetch color layers.
+ o SVG table to fetch SVG documents.
+ o CBDT/sbix API to fetch PNG images.
+- New 'name' table API.
+- hb-ot-font now uses 'VORG' table to correctly position CFF glyphs
+ in vertical layout.
+- Various fuzzer-found bug fixes.
+
+Changed API:
+
+A type and a macro added in 2.0.0 were renamed:
+
+hb_name_id_t -> hb_ot_name_id_t
+HB_NAME_ID_INVALID -> HB_OT_NAME_ID_INVALID
+
+New API:
+
++hb_color_t
++HB_COLOR
++hb_color_get_alpha()
++hb_color_get_red()
++hb_color_get_green()
++hb_color_get_blue()
++hb_ot_color_has_palettes()
++hb_ot_color_palette_get_count()
++hb_ot_color_palette_get_name_id()
++hb_ot_color_palette_color_get_name_id()
++hb_ot_color_palette_flags_t
++hb_ot_color_palette_get_flags()
++hb_ot_color_palette_get_colors()
++hb_ot_color_has_layers()
++hb_ot_color_layer_t
++hb_ot_color_glyph_get_layers()
++hb_ot_color_has_svg()
++hb_ot_color_glyph_reference_svg()
++hb_ot_color_has_png()
++hb_ot_color_glyph_reference_png()
+
++hb_ot_name_id_t
++HB_OT_NAME_ID_INVALID
++HB_OT_NAME_ID_COPYRIGHT
++HB_OT_NAME_ID_FONT_FAMILY
++HB_OT_NAME_ID_FONT_SUBFAMILY
++HB_OT_NAME_ID_UNIQUE_ID
++HB_OT_NAME_ID_FULL_NAME
++HB_OT_NAME_ID_VERSION_STRING
++HB_OT_NAME_ID_POSTSCRIPT_NAME
++HB_OT_NAME_ID_TRADEMARK
++HB_OT_NAME_ID_MANUFACTURER
++HB_OT_NAME_ID_DESIGNER
++HB_OT_NAME_ID_DESCRIPTION
++HB_OT_NAME_ID_VENDOR_URL
++HB_OT_NAME_ID_DESIGNER_URL
++HB_OT_NAME_ID_LICENSE
++HB_OT_NAME_ID_LICENSE_URL
++HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY
++HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
++HB_OT_NAME_ID_MAC_FULL_NAME
++HB_OT_NAME_ID_SAMPLE_TEXT
++HB_OT_NAME_ID_CID_FINDFONT_NAME
++HB_OT_NAME_ID_WWS_FAMILY
++HB_OT_NAME_ID_WWS_SUBFAMILY
++HB_OT_NAME_ID_LIGHT_BACKGROUND
++HB_OT_NAME_ID_DARK_BACKGROUND
++HB_OT_NAME_ID_VARIATIONS_PS_PREFIX
++hb_ot_name_entry_t
++hb_ot_name_list_names()
++hb_ot_name_get_utf8()
++hb_ot_name_get_utf16()
++hb_ot_name_get_utf32()
+
+
+Overview of changes leading to 2.0.2
+Saturday, October 20, 2018
+====================================
+- Fix two minor memory access issues in AAT tables.
+
+
+Overview of changes leading to 2.0.1
+Friday, October 19, 2018
+====================================
+- Fix hb-version.h reported release version that went wrong (1.8.0)
+ with previous release.
+- Fix extrapolation in 'trak' table.
+- Fix hb-font infinite-recursion issue with some font funcs and
+ subclassed fonts.
+- Implement variation-kerning format in kerx table, although without
+ variation.
+- Fix return value of hb_map_is_empty().
+
+
+Overview of changes leading to 2.0.0
+Thursday, October 18, 2018
+====================================
+- Added AAT shaping support (morx/kerx/trak).
+ Automatically used if GSUB/GPOS are not available respectively.
+ Set HB_OPTIONS=aat env var to have morx/kerx preferred over
+ GSUB/GPOS.
+- Apply TrueType kern table internally, instead of relying on
+ hb_font_t callbacks.
+- Khmer shaper significantly rewritten to better match Uniscribe.
+- Indic3 tags ('dev3', etc) are passed to USE shaper.
+- .dfont Mac font containers implemented.
+- Script- and language-mapping revamped to better use BCP 47.
+- Misc USE and Indic fixes.
+- Misc everything fixes.
+- Too many things to list. Biggest release since 0.9.1, with
+ over 500 commits in just over 5 weeks! Didn't intend it to
+ be a big release. Just happened to become.
+- hb-ft now locks underlying FT_Face during use.
+
+API changes:
+
+- Newly-created hb_font_t's now have our internal "hb-ot-font"
+ callbacks set on them, so they should work out of the box
+ without any callbacks set. If callbacks are set, everything
+ is back to what it was before, the fallback callbacks are
+ null. If you to get the internal implementation modified,
+ sub_font it.
+
+- New hb_font_funcs_set_nominal_glyphs_func() allows speeding
+ up character to glyph mapping.
+
+New API:
++HB_FEATURE_GLOBAL_START
++HB_FEATURE_GLOBAL_END
++hb_buffer_set_invisible_glyph()
++hb_buffer_get_invisible_glyph()
++hb_font_funcs_set_nominal_glyphs_func()
++hb_ot_layout_table_select_script()
++hb_ot_layout_script_select_language()
++hb_ot_layout_feature_get_name_ids()
++hb_ot_layout_feature_get_characters()
++hb_name_id_t
++HB_NAME_ID_INVALID
++HB_OT_MAX_TAGS_PER_SCRIPT
++hb_ot_tags_from_script_and_language()
++hb_ot_tags_to_script_and_language()
+
+Deprecated API:
+-hb_font_funcs_set_glyph_func()
+-hb_unicode_eastasian_width_func_t
+-hb_unicode_funcs_set_eastasian_width_func()
+-hb_unicode_eastasian_width()
+-hb_unicode_decompose_compatibility_func_t
+-HB_UNICODE_MAX_DECOMPOSITION_LEN
+-hb_unicode_funcs_set_decompose_compatibility_func()
+-hb_unicode_decompose_compatibility()
+-hb_font_funcs_set_glyph_h_kerning_func()
+-hb_font_funcs_set_glyph_v_kerning_func()
+-hb_font_get_glyph_h_kerning()
+-hb_font_get_glyph_v_kerning()
+-hb_font_get_glyph_kerning_for_direction()
+-hb_ot_layout_table_choose_script()
+-hb_ot_layout_script_find_language()
+-hb_ot_tags_from_script()
+-hb_ot_tag_from_language()
+
+
Overview of changes leading to 1.9.0
Monday, September 10, 2018
====================================
diff --git a/chromium/third_party/harfbuzz-ng/src/README b/chromium/third_party/harfbuzz-ng/src/README
index 55775c8bf91..e50f8f06e5d 100644
--- a/chromium/third_party/harfbuzz-ng/src/README
+++ b/chromium/third_party/harfbuzz-ng/src/README
@@ -1,9 +1,10 @@
-[![Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg)](https://travis-ci.org/harfbuzz/harfbuzz)
-[![Build status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true)](https://ci.appveyor.com/project/harfbuzz/harfbuzz)
-[![CircleCI](https://circleci.com/gh/harfbuzz/harfbuzz.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz)
-[![Coverity](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz)
-[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz)
-[![Coverage Status](https://img.shields.io/coveralls/harfbuzz/harfbuzz.svg)](https://coveralls.io/r/harfbuzz/harfbuzz)
+[![Travis Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg)](https://travis-ci.org/harfbuzz/harfbuzz)
+[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true)](https://ci.appveyor.com/project/harfbuzz/harfbuzz)
+[![CircleCI Build Status](https://circleci.com/gh/harfbuzz/harfbuzz.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz)
+[![Coverity Code Health](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz)
+[![Codacy Code Health](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz)
+[![Codecov Code Coverage](https://codecov.io/gh/harfbuzz/harfbuzz/branch/master/graph/badge.svg)](https://codecov.io/gh/harfbuzz/harfbuzz)
+[![Coverals Code Coverage](https://img.shields.io/coveralls/harfbuzz/harfbuzz.svg)](https://coveralls.io/r/harfbuzz/harfbuzz)
[ABI Tracker](http://abi-laboratory.pro/tracker/timeline/harfbuzz/)
This is HarfBuzz, a text shaping library.
diff --git a/chromium/third_party/harfbuzz-ng/src/README.python.md b/chromium/third_party/harfbuzz-ng/src/README.python.md
index 4c0ba9b2776..7cf091a09b1 100644
--- a/chromium/third_party/harfbuzz-ng/src/README.python.md
+++ b/chromium/third_party/harfbuzz-ng/src/README.python.md
@@ -23,7 +23,7 @@ Then make sure you also have GI_TYPELIB_PATH pointing to the resulting
$prefix/lib/girepository-* directory.
Make sure you have pygobject installed. Then check that the following
-import works in your Python interpretter:
+import works in your Python interpreter:
```python
from gi.repository import HarfBuzz
diff --git a/chromium/third_party/harfbuzz-ng/src/README.wine.md b/chromium/third_party/harfbuzz-ng/src/README.wine.md
index 851d2bf3d7e..799eb631f87 100644
--- a/chromium/third_party/harfbuzz-ng/src/README.wine.md
+++ b/chromium/third_party/harfbuzz-ng/src/README.wine.md
@@ -1,6 +1,6 @@
For the development of HarfBuzz, the Microsoft shaping technology, Uniscribe,
as a widely used and tested shaper is used as more-or-less OpenType reference
-implemenetation and that specially is important where OpenType specification
+implementation and that specially is important where OpenType specification
is or wasn't that clear. For having access to Uniscribe on Linux/macOS these
steps are recommended:
@@ -27,8 +27,8 @@ steps are recommended:
Now you can use hb-shape using `wine winbuild/util/hb-shape.exe` but if you like to
to use the original Uniscribe,
-8. Bring a 32bit version of `usp10.dll` for youself from `C:\Windows\SysWOW64\usp10.dll` of your
- Windows installation (asuming you have a 64-bit installation, otherwise `C:\Windows\System32\usp10.dll`)
+8. Bring a 32bit version of `usp10.dll` for yourself from `C:\Windows\SysWOW64\usp10.dll` of your
+ Windows installation (assuming you have a 64-bit installation, otherwise `C:\Windows\System32\usp10.dll`)
that it is not a DirectWrite proxy ([for more info](https://en.wikipedia.org/wiki/Uniscribe)).
Rule of thumb, your `usp10.dll` should have a size more than 500kb, otherwise
it is designed to work with DirectWrite which Wine can't work with its original one.
diff --git a/chromium/third_party/harfbuzz-ng/src/RELEASING.md b/chromium/third_party/harfbuzz-ng/src/RELEASING.md
index d431871c0ac..1fd8365453d 100644
--- a/chromium/third_party/harfbuzz-ng/src/RELEASING.md
+++ b/chromium/third_party/harfbuzz-ng/src/RELEASING.md
@@ -8,7 +8,8 @@ HarfBuzz release walk-through checklist:
Document them in NEWS. All API and API semantic changes should be clearly
marked as API additions, API changes, or API deletions. Document
deprecations. Ensure all new API / deprecations are in listed correctly in
- docs/harfbuzz-sections.txt
+ docs/harfbuzz-sections.txt. If release added new API, add entry for new
+ API index at the end of docs/harfbuzz-docs.xml.
If there's a backward-incompatible API change (including deletions for API
used anywhere), that's a release blocker. Do NOT release.
@@ -27,7 +28,10 @@ HarfBuzz release walk-through checklist:
Otherwise, fix things and commit them separately before making release,
Note: Check src/hb-version.h and make sure the new version number is
there. Sometimes, it does not get updated. If that's the case,
- "touch configure.ac" and rebuild. TODO: debug.
+ "touch configure.ac" and rebuild. Also check that there is no hb-version.h
+ in your build/src file. Typically it will fail the distcheck if there is.
+ That's what happened to 2.0.0 going out with 1.8.0 hb-version.h... So, that's
+ a clue.
7. "make release-files". Enter your GPG password. This creates a sha256 hash
and signs it.
diff --git a/chromium/third_party/harfbuzz-ng/src/TODO b/chromium/third_party/harfbuzz-ng/src/TODO
index 6dac0be5298..d8e41050ec5 100644
--- a/chromium/third_party/harfbuzz-ng/src/TODO
+++ b/chromium/third_party/harfbuzz-ng/src/TODO
@@ -1,9 +1,3 @@
-General fixes:
-=============
-
-- Implement 'rand' feature.
-
-
API issues:
===========
@@ -19,11 +13,7 @@ API additions
- Add hb-cairo glue
-- Add sanitize API (and a cached version, that saves result on blob user-data)
-
-- BCP 47 language handling / API (language_matches?)
-
-- Add hb_font_create_unscaled()?
+- Add sanitize API.
- Add query / enumeration API for aalt-like features?
diff --git a/chromium/third_party/harfbuzz-ng/src/appveyor.yml b/chromium/third_party/harfbuzz-ng/src/appveyor.yml
index f10078fddb5..21d4ea798f7 100644
--- a/chromium/third_party/harfbuzz-ng/src/appveyor.yml
+++ b/chromium/third_party/harfbuzz-ng/src/appveyor.yml
@@ -28,15 +28,19 @@ environment:
MINGW_CHOST: i686-w64-mingw32
MSYS2_ARCH: i686
+
install:
- - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --force --noconfirm -Sy && pacman --noconfirm --force -S pacman-mirrors && pacman --force -Syu --noconfirm"'
+# - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm --force -Sy && pacman --noconfirm --force -S pacman-mirrors && pacman --force -Syu --noconfirm"'
+ - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm --force -S --needed mingw-w64-$MSYS2_ARCH-{gcc,freetype,cairo,icu,gettext,gobject-introspection,gcc,gcc-libs,glib2,graphite2,pkg-config,python2}"'
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-x86_64-ragel"
+ - set PATH=%PATH%;C:\msys64\mingw64\bin # msys2 is added just for having "ragel" on PATH
+ - 'if "%compiler%"=="cygwin" %CYGWIN_PREFIX%\setup-%CYGWIN_ARCH%.exe -g -q -P cygwin-devel,libfreetype-devel,libcairo-devel,libicu-devel,gcc,gcc-g++,gobject-introspection,libglib2.0-devel,libgraphite2-devel,pkg-config,python2'
+ - 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" vcpkg install glib:%triplet% freetype:%triplet% cairo:%triplet%'
build_script:
- - 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" vcpkg install glib:%triplet% freetype:%triplet% cairo:%triplet%'
- 'if "%compiler%"=="msvc" md build'
- 'if "%compiler%"=="msvc" cd build'
- - 'if "%compiler%"=="msvc" set PATH=%PATH%;C:\Program Files (x86)\MSBuild\14.0\Bin;c:\msys64\mingw64\bin' # msys2 is added just for having "ragel" on PATH
+ - 'if "%compiler%"=="msvc" set PATH=%PATH%;C:\Program Files (x86)\MSBuild\14.0\Bin'
- 'if "%compiler%"=="msvc" if "%platform%"=="ARM" cmake -DHB_HAVE_UNISCRIBE=ON -DHB_HAVE_DIRECTWRITE=ON -G "%generator%" ../'
- 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" cmake -DHB_HAVE_UNISCRIBE=ON -DHB_HAVE_DIRECTWRITE=ON -DHB_HAVE_GLIB=ON -DHB_HAVE_FREETYPE=ON -DHB_BUILD_UTILS=ON -G "%generator%" -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ../'
@@ -44,13 +48,12 @@ build_script:
- 'if "%compiler%"=="msvc" msbuild harfbuzz.sln /p:Configuration=%configuration% /p:Platform=%platform%'
- 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" ctest --output-on-failure -C %configuration%'
- - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm --force -Syyu mingw-w64-$MSYS2_ARCH-gcc"'
- - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm --force -S --needed mingw-w64-$MSYS2_ARCH-{freetype,cairo,icu,gettext,gobject-introspection,gcc,gcc-libs,glib2,graphite2,pkg-config,python2}"'
- 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "curl https://raw.githubusercontent.com/mirror/mingw-w64/023eb04c396d4e8d8fcf604cfababc53dae13398/mingw-w64-headers/include/dwrite_1.h > %MINGW_PREFIX%/%MINGW_CHOST%/include/dwrite_1.h"'
- - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh --with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2 --with-directwrite --build=%MINGW_CHOST% --host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make; make check || .ci/fail.sh"'
+ - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh --with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2 --with-directwrite --build=%MINGW_CHOST% --host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make -j3 check || .ci/fail.sh"'
cache:
- c:\tools\vcpkg\installed\
+ - '%CYGWIN_PREFIX%\var\cache\setup'
notifications:
- provider: Email
@@ -60,5 +63,8 @@ notifications:
on_build_failure: true
on_build_status_changed: true
+# Do not build feature branch with open Pull Requests
+skip_branch_with_pr: true
+
# disable automatic tests
test: off
diff --git a/chromium/third_party/harfbuzz-ng/src/azure-pipelines.yml b/chromium/third_party/harfbuzz-ng/src/azure-pipelines.yml
new file mode 100644
index 00000000000..88c0a984aad
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/azure-pipelines.yml
@@ -0,0 +1,21 @@
+pool:
+ vmImage: 'VS2017-Win2016'
+
+variables:
+ buildPlatform: 'x86'
+ buildConfiguration: 'Debug'
+ triplet: 'x86-windows'
+
+steps:
+- script: |
+ git clone https://github.com/Microsoft/vcpkg
+ cd vcpkg
+ .\bootstrap-vcpkg.bat
+ .\vcpkg integrate install
+ .\vcpkg install glib:x86-windows freetype:x86-windows cairo:x86-windows
+ cd ..
+ cmake -Bbuild -H. -DHB_HAVE_UNISCRIBE=ON -DHB_HAVE_DIRECTWRITE=ON -DHB_HAVE_GLIB=ON -DHB_HAVE_FREETYPE=ON -DHB_BUILD_UTILS=ON -G "%generator%" -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ../
+ msbuild harfbuzz.sln /p:Configuration=Debug /p:Platform=Win32
+ cd build
+ ctest --output-on-failure -C Debug
+ displayName: Build and test
diff --git a/chromium/third_party/harfbuzz-ng/src/configure.ac b/chromium/third_party/harfbuzz-ng/src/configure.ac
index 3aa41ff21f0..e9db42a78e9 100644
--- a/chromium/third_party/harfbuzz-ng/src/configure.ac
+++ b/chromium/third_party/harfbuzz-ng/src/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ([2.64])
AC_INIT([HarfBuzz],
- [1.9.0],
+ [2.1.3],
[https://github.com/harfbuzz/harfbuzz/issues/new],
[harfbuzz],
[http://harfbuzz.org/])
@@ -148,12 +148,6 @@ AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
dnl ==========================================================================
-have_ot=true
-if $have_ot; then
- AC_DEFINE(HAVE_OT, 1, [Have native OpenType Layout backend])
-fi
-AM_CONDITIONAL(HAVE_OT, $have_ot)
-
have_fallback=true
if $have_fallback; then
AC_DEFINE(HAVE_FALLBACK, 1, [Have simple TrueType Layout backend])
@@ -514,6 +508,7 @@ test/api/Makefile
test/fuzzing/Makefile
test/shaping/Makefile
test/shaping/data/Makefile
+test/shaping/data/aots/Makefile
test/shaping/data/in-house/Makefile
test/shaping/data/text-rendering-tests/Makefile
test/subset/Makefile
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/Makefile.am b/chromium/third_party/harfbuzz-ng/src/docs/Makefile.am
index a9935385b9a..9b54b40e141 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/Makefile.am
+++ b/chromium/third_party/harfbuzz-ng/src/docs/Makefile.am
@@ -62,7 +62,6 @@ CFILE_GLOB=$(top_srcdir)/src/hb-*.cc
# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
-EXTRA_HFILES=$(top_builddir)/src/hb-version.h
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
@@ -73,14 +72,15 @@ HTML_IMAGES= \
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
content_files= \
+ usermanual-what-is-harfbuzz.xml \
+ usermanual-install-harfbuzz.xml \
+ usermanual-getting-started.xml \
+ usermanual-shaping-concepts.xml \
usermanual-buffers-language-script-and-direction.xml \
- usermanual-clusters.xml \
usermanual-fonts-and-faces.xml \
- usermanual-glyph-information.xml \
- usermanual-hello-harfbuzz.xml \
- usermanual-install-harfbuzz.xml \
+ usermanual-clusters.xml \
usermanual-opentype-features.xml \
- usermanual-what-is-harfbuzz.xml \
+ usermanual-glyph-information.xml \
version.xml
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml b/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml
index 9452a92af58..27353389d7b 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml
@@ -12,28 +12,21 @@
<graphic fileref="HarfBuzz.png" format="PNG" align="center"/>
<para>
HarfBuzz is an <ulink url="http://www.microsoft.com/typography/otspec/">OpenType</ulink>
- text shaping engine.
- </para>
- <para>
- The current HarfBuzz codebase, formerly known as harfbuzz-ng, is
- versioned 1.x.x and is stable and under active maintenance. This is
- what is used in latest versions of Firefox, GNOME, ChromeOS, Chrome,
- LibreOffice, XeTeX, Android, and KDE, among other places. The canonical
- source tree is available
- <ulink url="http://cgit.freedesktop.org/harfbuzz/">here</ulink>.
- Also available on
- <ulink url="https://github.com/harfbuzz/harfbuzz">github</ulink>.
- See <xref linkend="download" endterm="download.title"/> for release tarballs.
+ text shaping engine. Using the HarfBuzz library allows
+ programs to convert a sequence of Unicode input into
+ properly formatted and positioned glyph output&mdash;for any writing
+ system and language.
</para>
+
<para>
- The old HarfBuzz codebase, these days known as harfbuzz-old, was
- derived from <ulink url="http://freetype.org/">FreeType</ulink>,
- <ulink url="http://pango.org/">Pango</ulink>, and
- <ulink url="http://qt-project.org/">Qt</ulink> and is available
- <ulink url="http://cgit.freedesktop.org/harfbuzz.old/">here</ulink>.
- It is not actively developed or maintained, and is extremely buggy. All
- users are encouraged to switch over to the new HarfBuzz as soon as
- possible. There are no release tarballs of old HarfBuzz whatsoever.
+ The canonical source-code tree is available at
+ <ulink
+ url="https://github.com/harfbuzz/harfbuzz">github.com/harfbuzz/harfbuzz</ulink>
+ and is also available at
+ <ulink
+ url="http://cgit.freedesktop.org/harfbuzz/">cgit.freedesktop.org/harfbuzz</ulink>.
+ See <xref linkend="download" endterm="download.title"/> for
+ release tarballs.
</para>
</abstract>
</bookinfo>
@@ -42,7 +35,8 @@
<title>User's manual</title>
<xi:include href="usermanual-what-is-harfbuzz.xml"/>
<xi:include href="usermanual-install-harfbuzz.xml"/>
- <xi:include href="usermanual-hello-harfbuzz.xml"/>
+ <xi:include href="usermanual-getting-started.xml"/>
+ <xi:include href="usermanual-shaping-concepts.xml"/>
<xi:include href="usermanual-buffers-language-script-and-direction.xml"/>
<xi:include href="usermanual-fonts-and-faces.xml"/>
<xi:include href="usermanual-clusters.xml"/>
@@ -58,152 +52,124 @@
<ulink role="online-location" url="http://[SERVER]/libharfbuzz/index.html">http://[SERVER]/libharfbuzz/</ulink>.-->
</releaseinfo>
</partinfo>
+
+ <note>
+ <para>
+ The current HarfBuzz codebase is versioned 2.x.x and is stable
+ and under active maintenance. This is what is used in latest
+ versions of Firefox, GNOME, ChromeOS, Chrome, LibreOffice,
+ XeTeX, Android, and KDE, among other places.
+ </para>
+ <para>
+ Prior to 2012, the original HarfBuzz codebase (which, these
+ days, is referred to as <emphasis>harfbuzz-old</emphasis>) was
+ derived from code in <ulink
+ url="http://freetype.org/">FreeType</ulink>, <ulink
+ url="http://pango.org/">Pango</ulink>, and
+ <ulink url="http://qt-project.org/">Qt</ulink>.
+ It is <emphasis>not</emphasis> actively developed or
+ maintained, and is extremely buggy. All users of harfbuzz-old
+ are encouraged to switch over to the new HarfBuzz as soon as possible.
+ </para>
+ <para>
+ To make this distinction clearer in discussions, the current
+ HarfBuzz codebase is sometimes referred to as
+ <emphasis>harfbuzz-ng</emphasis>.
+ </para>
+ <para>
+ For reference purposes, the harfbuzz-old source tree is archived
+ <ulink
+ url="http://cgit.freedesktop.org/harfbuzz.old/">here</ulink>. There
+ are no release tarballs of harfbuzz-old whatsoever.
+ </para>
+ </note>
+
<title>Reference manual</title>
<chapter>
- <title>HarfBuzz API</title>
- <xi:include href="xml/hb.xml"/>
- <xi:include href="xml/hb-common.xml"/>
- <xi:include href="xml/hb-unicode.xml"/>
- <xi:include href="xml/hb-buffer.xml"/>
+ <title>Core API</title>
<xi:include href="xml/hb-blob.xml"/>
+ <xi:include href="xml/hb-buffer.xml"/>
+ <xi:include href="xml/hb-common.xml"/>
+ <xi:include href="xml/hb-deprecated.xml"/>
<xi:include href="xml/hb-face.xml"/>
<xi:include href="xml/hb-font.xml"/>
+ <xi:include href="xml/hb-map.xml"/>
+ <xi:include href="xml/hb-set.xml"/>
+ <xi:include href="xml/hb-shape-plan.xml"/>
<xi:include href="xml/hb-shape.xml"/>
-
+ <xi:include href="xml/hb-unicode.xml"/>
<xi:include href="xml/hb-version.xml"/>
- <xi:include href="xml/hb-deprecated.xml"/>
-
- <xi:include href="xml/hb-set.xml"/>
+ </chapter>
- <xi:include href="xml/hb-ot.xml"/>
- <xi:include href="xml/hb-ot-layout.xml"/>
- <xi:include href="xml/hb-ot-tag.xml"/>
+ <chapter>
+ <title>OpenType API</title>
+ <xi:include href="xml/hb-ot-color.xml"/>
<xi:include href="xml/hb-ot-font.xml"/>
- <xi:include href="xml/hb-ot-shape.xml"/>
+ <xi:include href="xml/hb-ot-layout.xml"/>
<xi:include href="xml/hb-ot-math.xml"/>
+ <xi:include href="xml/hb-ot-name.xml"/>
+ <xi:include href="xml/hb-ot-shape.xml"/>
+ <xi:include href="xml/hb-ot-var.xml"/>
+ </chapter>
- <xi:include href="xml/hb-shape-plan.xml"/>
-
- <xi:include href="xml/hb-glib.xml"/>
- <xi:include href="xml/hb-icu.xml"/>
+ <chapter>
+ <title>Apple Advanced Typography API</title>
+ <xi:include href="xml/hb-aat-layout.xml"/>
+ </chapter>
+ <chapter>
+ <title>Integration API</title>
+ <xi:include href="xml/hb-coretext.xml"/>
<xi:include href="xml/hb-ft.xml"/>
-
+ <xi:include href="xml/hb-glib.xml"/>
+ <xi:include href="xml/hb-gobject.xml"/>
<xi:include href="xml/hb-graphite2.xml"/>
+ <xi:include href="xml/hb-icu.xml"/>
<xi:include href="xml/hb-uniscribe.xml"/>
- <xi:include href="xml/hb-coretext.xml"/>
-
- <xi:include href="xml/hb-gobject.xml"/>
-
</chapter>
- <chapter id="object-tree">
+
+ <!--chapter id="object-tree">
<title>Object Hierarchy</title>
<xi:include href="xml/tree_index.sgml"/>
- </chapter>
- <index id="api-index-full">
- <title>API Index</title>
- <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-2" role="0.9.2">
- <title>Index of new symbols in 0.9.2</title>
- <xi:include href="xml/api-index-0.9.2.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-5" role="0.9.5">
- <title>Index of new symbols in 0.9.5</title>
- <xi:include href="xml/api-index-0.9.5.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-7" role="0.9.7">
- <title>Index of new symbols in 0.9.7</title>
- <xi:include href="xml/api-index-0.9.7.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-8" role="0.9.8">
- <title>Index of new symbols in 0.9.8</title>
- <xi:include href="xml/api-index-0.9.8.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-10" role="0.9.10">
- <title>Index of new symbols in 0.9.10</title>
- <xi:include href="xml/api-index-0.9.10.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-11" role="0.9.11">
- <title>Index of new symbols in 0.9.11</title>
- <xi:include href="xml/api-index-0.9.11.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-20" role="0.9.20">
- <title>Index of new symbols in 0.9.20</title>
- <xi:include href="xml/api-index-0.9.20.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-22" role="0.9.22">
- <title>Index of new symbols in 0.9.22</title>
- <xi:include href="xml/api-index-0.9.22.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-28" role="0.9.28">
- <title>Index of new symbols in 0.9.28</title>
- <xi:include href="xml/api-index-0.9.28.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-30" role="0.9.30">
- <title>Index of new symbols in 0.9.30</title>
- <xi:include href="xml/api-index-0.9.30.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-31" role="0.9.31">
- <title>Index of new symbols in 0.9.31</title>
- <xi:include href="xml/api-index-0.9.31.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-38" role="0.9.38">
- <title>Index of new symbols in 0.9.38</title>
- <xi:include href="xml/api-index-0.9.38.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-39" role="0.9.39">
- <title>Index of new symbols in 0.9.39</title>
- <xi:include href="xml/api-index-0.9.39.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-41" role="0.9.41">
- <title>Index of new symbols in 0.9.41</title>
- <xi:include href="xml/api-index-0.9.41.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-0-9-42" role="0.9.42">
- <title>Index of new symbols in 0.9.42</title>
- <xi:include href="xml/api-index-0.9.42.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-0-5" role="1.0.5">
- <title>Index of new symbols in 1.0.5</title>
- <xi:include href="xml/api-index-1.0.5.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-1-2" role="1.1.2">
- <title>Index of new symbols in 1.1.2</title>
- <xi:include href="xml/api-index-1.1.2.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-1-3" role="1.1.3">
- <title>Index of new symbols in 1.1.3</title>
- <xi:include href="xml/api-index-1.1.3.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-2-3" role="1.2.3">
- <title>Index of new symbols in 1.2.3</title>
- <xi:include href="xml/api-index-1.2.3.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-3-3" role="1.3.3">
- <title>Index of new symbols in 1.3.3</title>
- <xi:include href="xml/api-index-1.3.3.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-4-2" role="1.4.2">
- <title>Index of new symbols in 1.4.2</title>
- <xi:include href="xml/api-index-1.4.2.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-4-3" role="1.4.3">
- <title>Index of new symbols in 1.4.3</title>
- <xi:include href="xml/api-index-1.4.3.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-5-0" role="1.5.0">
- <title>Index of new symbols in 1.5.0</title>
- <xi:include href="xml/api-index-1.5.0.xml"><xi:fallback /></xi:include>
- </index>
- <index id="api-index-1-6-0" role="1.6.0">
- <title>Index of new symbols in 1.6.0</title>
- <xi:include href="xml/api-index-1.6.0.xml"><xi:fallback /></xi:include>
- </index>
- <index id="deprecated-api-index" role="deprecated">
- <title>Index of deprecated API</title>
- <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
- </index>
+ </chapter-->
+
+ <index id="api-index-full"><title>API Index</title><xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include></index>
+ <index id="deprecated-api-index" role="deprecated"><title>Index of deprecated API</title><xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include></index>
+
+ <index id="api-index-2-1-0" role="2.1.0"><title>Index of new symbols in 2.1.0</title><xi:include href="xml/api-index-2.1.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-2-0-0" role="2.0.0"><title>Index of new symbols in 2.0.0</title><xi:include href="xml/api-index-2.0.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-9-0" role="1.9.0"><title>Index of new symbols in 1.9.0</title><xi:include href="xml/api-index-1.9.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-8-6" role="1.8.6"><title>Index of new symbols in 1.8.6</title><xi:include href="xml/api-index-1.8.6.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-8-5" role="1.8.5"><title>Index of new symbols in 1.8.5</title><xi:include href="xml/api-index-1.8.5.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-8-1" role="1.8.1"><title>Index of new symbols in 1.8.1</title><xi:include href="xml/api-index-1.8.1.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-8-0" role="1.8.0"><title>Index of new symbols in 1.8.0</title><xi:include href="xml/api-index-1.8.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-7-7" role="1.7.7"><title>Index of new symbols in 1.7.7</title><xi:include href="xml/api-index-1.7.7.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-7-5" role="1.7.5"><title>Index of new symbols in 1.7.5</title><xi:include href="xml/api-index-1.7.5.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-6-0" role="1.6.0"><title>Index of new symbols in 1.6.0</title><xi:include href="xml/api-index-1.6.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-5-0" role="1.5.0"><title>Index of new symbols in 1.5.0</title><xi:include href="xml/api-index-1.5.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-4-3" role="1.4.3"><title>Index of new symbols in 1.4.3</title><xi:include href="xml/api-index-1.4.3.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-4-2" role="1.4.2"><title>Index of new symbols in 1.4.2</title><xi:include href="xml/api-index-1.4.2.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-4-0" role="1.4.0"><title>Index of new symbols in 1.4.0</title><xi:include href="xml/api-index-1.4.0.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-3-3" role="1.3.3"><title>Index of new symbols in 1.3.3</title><xi:include href="xml/api-index-1.3.3.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-2-3" role="1.2.3"><title>Index of new symbols in 1.2.3</title><xi:include href="xml/api-index-1.2.3.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-1-3" role="1.1.3"><title>Index of new symbols in 1.1.3</title><xi:include href="xml/api-index-1.1.3.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-1-2" role="1.1.2"><title>Index of new symbols in 1.1.2</title><xi:include href="xml/api-index-1.1.2.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-1-0-5" role="1.0.5"><title>Index of new symbols in 1.0.5</title><xi:include href="xml/api-index-1.0.5.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-42" role="0.9.42"><title>Index of new symbols in 0.9.42</title><xi:include href="xml/api-index-0.9.42.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-41" role="0.9.41"><title>Index of new symbols in 0.9.41</title><xi:include href="xml/api-index-0.9.41.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-39" role="0.9.39"><title>Index of new symbols in 0.9.39</title><xi:include href="xml/api-index-0.9.39.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-38" role="0.9.38"><title>Index of new symbols in 0.9.38</title><xi:include href="xml/api-index-0.9.38.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-31" role="0.9.31"><title>Index of new symbols in 0.9.31</title><xi:include href="xml/api-index-0.9.31.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-30" role="0.9.30"><title>Index of new symbols in 0.9.30</title><xi:include href="xml/api-index-0.9.30.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-28" role="0.9.28"><title>Index of new symbols in 0.9.28</title><xi:include href="xml/api-index-0.9.28.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-22" role="0.9.22"><title>Index of new symbols in 0.9.22</title><xi:include href="xml/api-index-0.9.22.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-20" role="0.9.20"><title>Index of new symbols in 0.9.20</title><xi:include href="xml/api-index-0.9.20.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-11" role="0.9.11"><title>Index of new symbols in 0.9.11</title><xi:include href="xml/api-index-0.9.11.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-10" role="0.9.10"><title>Index of new symbols in 0.9.10</title><xi:include href="xml/api-index-0.9.10.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-8" role="0.9.8"><title>Index of new symbols in 0.9.8</title><xi:include href="xml/api-index-0.9.8.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-7" role="0.9.7"><title>Index of new symbols in 0.9.7</title><xi:include href="xml/api-index-0.9.7.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-5" role="0.9.5"><title>Index of new symbols in 0.9.5</title><xi:include href="xml/api-index-0.9.5.xml"><xi:fallback /></xi:include></index>
+ <index id="api-index-0-9-2" role="0.9.2"><title>Index of new symbols in 0.9.2</title><xi:include href="xml/api-index-0.9.2.xml"><xi:fallback /></xi:include></index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</part>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt b/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt
index b69c1686057..5c45153c343 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt
+++ b/chromium/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt
@@ -1,8 +1,17 @@
-<SECTION>
-<FILE>hb</FILE>
<SUBSECTION Private>
HB_H_IN
-HB_EXTERN
+HB_OT_H_IN
+</SECTION>
+
+<SECTION>
+<FILE>hb-aat-layout</FILE>
+HB_AAT_LAYOUT_NO_SELECTOR_INDEX
+hb_aat_layout_feature_type_t
+hb_aat_layout_get_feature_types
+hb_aat_layout_feature_type_get_name_id
+hb_aat_layout_feature_selector_t
+hb_aat_layout_feature_selector_info_t
+hb_aat_layout_feature_type_get_selector_infos
</SECTION>
<SECTION>
@@ -67,6 +76,8 @@ hb_buffer_set_user_data
hb_buffer_get_user_data
hb_buffer_get_glyph_infos
hb_buffer_get_glyph_positions
+hb_buffer_get_invisible_glyph
+hb_buffer_set_invisible_glyph
hb_buffer_set_replacement_codepoint
hb_buffer_get_replacement_codepoint
hb_buffer_normalize_glyphs
@@ -144,6 +155,10 @@ uint16_t
uint32_t
uint64_t
uint8_t
+<SUBSECTION Private>
+HB_EXTERN
+HB_DEPRECATED
+HB_DEPRECATED_FOR
</SECTION>
<SECTION>
@@ -153,7 +168,30 @@ HB_BUFFER_SERIALIZE_FLAGS_DEFAULT
HB_SCRIPT_CANADIAN_ABORIGINAL
hb_font_funcs_set_glyph_func
hb_font_get_glyph_func_t
+hb_ot_layout_table_choose_script
+hb_ot_layout_table_find_script
+hb_ot_tag_from_language
+hb_ot_tags_from_script
+HB_OT_VAR_NO_AXIS_INDEX
+hb_ot_var_axis_t
+hb_ot_var_find_axis
+hb_ot_var_get_axes
hb_set_invert
+hb_unicode_eastasian_width_func_t
+hb_unicode_eastasian_width
+hb_unicode_funcs_set_eastasian_width_func
+HB_UNICODE_MAX_DECOMPOSITION_LEN
+hb_unicode_decompose_compatibility_func_t
+hb_unicode_decompose_compatibility
+hb_unicode_funcs_set_decompose_compatibility_func
+hb_font_funcs_set_glyph_h_kerning_func
+hb_font_funcs_set_glyph_v_kerning_func
+hb_font_get_glyph_h_kerning
+hb_font_get_glyph_h_kerning_func_t
+hb_font_get_glyph_kerning_for_direction
+hb_font_get_glyph_kerning_func_t
+hb_font_get_glyph_v_kerning
+hb_font_get_glyph_v_kerning_func_t
</SECTION>
<SECTION>
@@ -214,14 +252,13 @@ hb_font_funcs_set_glyph_extents_func
hb_font_funcs_set_glyph_from_name_func
hb_font_funcs_set_glyph_h_advance_func
hb_font_funcs_set_glyph_h_advances_func
-hb_font_funcs_set_glyph_h_kerning_func
hb_font_funcs_set_glyph_h_origin_func
hb_font_funcs_set_glyph_name_func
hb_font_funcs_set_glyph_v_advance_func
hb_font_funcs_set_glyph_v_advances_func
-hb_font_funcs_set_glyph_v_kerning_func
hb_font_funcs_set_glyph_v_origin_func
hb_font_funcs_set_nominal_glyph_func
+hb_font_funcs_set_nominal_glyphs_func
hb_font_funcs_set_user_data
hb_font_funcs_set_variation_glyph_func
hb_font_funcs_t
@@ -244,12 +281,8 @@ hb_font_get_glyph_h_advance
hb_font_get_glyph_h_advance_func_t
hb_font_get_glyph_h_advances
hb_font_get_glyph_h_advances_func_t
-hb_font_get_glyph_h_kerning
-hb_font_get_glyph_h_kerning_func_t
hb_font_get_glyph_h_origin
hb_font_get_glyph_h_origin_func_t
-hb_font_get_glyph_kerning_for_direction
-hb_font_get_glyph_kerning_func_t
hb_font_get_glyph_name
hb_font_get_glyph_name_func_t
hb_font_get_glyph_origin_for_direction
@@ -258,12 +291,12 @@ hb_font_get_glyph_v_advance
hb_font_get_glyph_v_advance_func_t
hb_font_get_glyph_v_advances
hb_font_get_glyph_v_advances_func_t
-hb_font_get_glyph_v_kerning
-hb_font_get_glyph_v_kerning_func_t
hb_font_get_glyph_v_origin
hb_font_get_glyph_v_origin_func_t
hb_font_get_nominal_glyph
hb_font_get_nominal_glyph_func_t
+hb_font_get_nominal_glyphs
+hb_font_get_nominal_glyphs_func_t
hb_font_get_parent
hb_font_get_ppem
hb_font_get_ptem
@@ -342,6 +375,7 @@ HB_GOBJECT_TYPE_FONT_FUNCS
HB_GOBJECT_TYPE_GLYPH_FLAGS
HB_GOBJECT_TYPE_MAP
HB_GOBJECT_TYPE_MEMORY_MODE
+HB_GOBJECT_TYPE_OT_COLOR_PALETTE_FLAGS
HB_GOBJECT_TYPE_OT_LAYOUT_GLYPH_CLASS
HB_GOBJECT_TYPE_OT_MATH_CONSTANT
HB_GOBJECT_TYPE_OT_MATH_GLYPH_PART
@@ -374,6 +408,7 @@ hb_gobject_font_get_type
hb_gobject_glyph_flags_get_type
hb_gobject_map_get_type
hb_gobject_memory_mode_get_type
+hb_gobject_ot_color_palette_flags_get_type
hb_gobject_ot_layout_glyph_class_get_type
hb_gobject_ot_math_constant_get_type
hb_gobject_ot_math_glyph_part_get_type
@@ -397,11 +432,6 @@ HB_GOBJECT_H_IN
</SECTION>
<SECTION>
-<FILE>hb-gobject</FILE>
-
-</SECTION>
-
-<SECTION>
<FILE>hb-graphite2</FILE>
HB_GRAPHITE2_TAG_SILF
hb_graphite2_face_get_gr_face
@@ -436,9 +466,27 @@ hb_map_t
</SECTION>
<SECTION>
-<FILE>hb-ot</FILE>
-<SUBSECTION Private>
-HB_OT_H_IN
+<FILE>hb-ot-color</FILE>
+hb_color_t
+HB_COLOR
+hb_color_get_alpha
+hb_color_get_blue
+hb_color_get_green
+hb_color_get_red
+hb_ot_color_glyph_get_layers
+hb_ot_color_glyph_reference_png
+hb_ot_color_glyph_reference_svg
+hb_ot_color_has_layers
+hb_ot_color_has_palettes
+hb_ot_color_has_png
+hb_ot_color_has_svg
+hb_ot_color_layer_t
+hb_ot_color_palette_color_get_name_id
+hb_ot_color_palette_flags_t
+hb_ot_color_palette_get_colors
+hb_ot_color_palette_get_count
+hb_ot_color_palette_get_flags
+hb_ot_color_palette_get_name_id
</SECTION>
<SECTION>
@@ -447,23 +495,40 @@ hb_ot_font_set_funcs
</SECTION>
<SECTION>
-<FILE>hb-ot-shape</FILE>
-hb_ot_shape_glyphs_closure
+<FILE>hb-ot-name</FILE>
+hb_ot_name_id_t
+HB_OT_NAME_ID_INVALID
+hb_ot_name_entry_t
+hb_ot_name_list_names
+hb_ot_name_get_utf16
+hb_ot_name_get_utf32
+hb_ot_name_get_utf8
</SECTION>
<SECTION>
<FILE>hb-ot-layout</FILE>
+HB_OT_MAX_TAGS_PER_LANGUAGE
+HB_OT_MAX_TAGS_PER_SCRIPT
+HB_OT_TAG_DEFAULT_LANGUAGE
+HB_OT_TAG_DEFAULT_SCRIPT
+hb_ot_tag_to_language
+hb_ot_tag_to_script
+hb_ot_tags_from_script_and_language
+hb_ot_tags_to_script_and_language
HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX
HB_OT_LAYOUT_NO_FEATURE_INDEX
HB_OT_LAYOUT_NO_SCRIPT_INDEX
HB_OT_LAYOUT_NO_VARIATIONS_INDEX
+HB_OT_TAG_BASE
HB_OT_TAG_GDEF
HB_OT_TAG_GPOS
HB_OT_TAG_GSUB
HB_OT_TAG_JSTF
hb_ot_layout_collect_lookups
hb_ot_layout_collect_features
+hb_ot_layout_feature_get_characters
hb_ot_layout_feature_get_lookups
+hb_ot_layout_feature_get_name_ids
hb_ot_layout_feature_with_variations_get_lookups
hb_ot_layout_get_attach_points
hb_ot_layout_get_glyph_class
@@ -485,12 +550,12 @@ hb_ot_layout_lookups_substitute_closure
hb_ot_layout_lookup_would_substitute
hb_ot_layout_script_find_language
hb_ot_layout_script_get_language_tags
-hb_ot_layout_table_choose_script
+hb_ot_layout_script_select_language
hb_ot_layout_table_find_feature_variations
-hb_ot_layout_table_find_script
hb_ot_layout_table_get_feature_tags
hb_ot_layout_table_get_script_tags
hb_ot_layout_table_get_lookup_count
+hb_ot_layout_table_select_script
hb_ot_shape_plan_collect_lookups
hb_ot_layout_language_get_required_feature_index
<SUBSECTION Private>
@@ -500,23 +565,6 @@ Xhb_ot_layout_lookup_substitute
</SECTION>
<SECTION>
-<FILE>hb-ot-var</FILE>
-HB_OT_TAG_VAR_AXIS_ITALIC
-HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE
-HB_OT_TAG_VAR_AXIS_SLANT
-HB_OT_TAG_VAR_AXIS_WEIGHT
-HB_OT_TAG_VAR_AXIS_WIDTH
-HB_OT_VAR_NO_AXIS_INDEX
-hb_ot_var_axis_t
-hb_ot_var_has_data
-hb_ot_var_find_axis
-hb_ot_var_get_axis_count
-hb_ot_var_get_axes
-hb_ot_var_normalize_variations
-hb_ot_var_normalize_coords
-</SECTION>
-
-<SECTION>
<FILE>hb-ot-math</FILE>
HB_OT_TAG_MATH
HB_OT_MATH_SCRIPT
@@ -537,13 +585,29 @@ hb_ot_math_get_glyph_assembly
</SECTION>
<SECTION>
-<FILE>hb-ot-tag</FILE>
-HB_OT_TAG_DEFAULT_LANGUAGE
-HB_OT_TAG_DEFAULT_SCRIPT
-hb_ot_tag_from_language
-hb_ot_tag_to_language
-hb_ot_tag_to_script
-hb_ot_tags_from_script
+<FILE>hb-ot-shape</FILE>
+hb_ot_shape_glyphs_closure
+</SECTION>
+
+<SECTION>
+<FILE>hb-ot-var</FILE>
+HB_OT_TAG_VAR_AXIS_ITALIC
+HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE
+HB_OT_TAG_VAR_AXIS_SLANT
+HB_OT_TAG_VAR_AXIS_WEIGHT
+HB_OT_TAG_VAR_AXIS_WIDTH
+hb_ot_var_has_data
+hb_ot_var_axis_flags_t
+hb_ot_var_axis_info_t
+hb_ot_var_find_axis_info
+hb_ot_var_get_axis_count
+hb_ot_var_get_axis_infos
+hb_ot_var_get_named_instance_count
+hb_ot_var_named_instance_get_subfamily_name_id
+hb_ot_var_named_instance_get_postscript_name_id
+hb_ot_var_named_instance_get_design_coords
+hb_ot_var_normalize_variations
+hb_ot_var_normalize_coords
</SECTION>
<SECTION>
@@ -611,16 +675,13 @@ hb_shape_plan_t
<SECTION>
<FILE>hb-unicode</FILE>
HB_UNICODE_MAX
-HB_UNICODE_MAX_DECOMPOSITION_LEN
hb_unicode_combining_class
hb_unicode_combining_class_func_t
hb_unicode_combining_class_t
hb_unicode_compose
hb_unicode_compose_func_t
hb_unicode_decompose
-hb_unicode_decompose_compatibility
hb_unicode_decompose_func_t
-hb_unicode_eastasian_width
hb_unicode_funcs_create
hb_unicode_funcs_destroy
hb_unicode_funcs_get_default
@@ -632,9 +693,7 @@ hb_unicode_funcs_make_immutable
hb_unicode_funcs_reference
hb_unicode_funcs_set_combining_class_func
hb_unicode_funcs_set_compose_func
-hb_unicode_funcs_set_decompose_compatibility_func
hb_unicode_funcs_set_decompose_func
-hb_unicode_funcs_set_eastasian_width_func
hb_unicode_funcs_set_general_category_func
hb_unicode_funcs_set_mirroring_func
hb_unicode_funcs_set_script_func
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml
index 9eddb71a9cb..68ce9bd0b74 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml
@@ -1,3 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="buffers-language-script-and-direction">
<title>Buffers, language, script and direction</title>
<para>
@@ -74,4 +80,4 @@ void somefunc(hb_buffer_t *buffer) {
<para>
</para>
</section>
-</chapter> \ No newline at end of file
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml
index 608371b00d7..f48e89c203e 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml
@@ -1,304 +1,542 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="clusters">
-<sect1 id="clusters">
<title>Clusters</title>
- <para>
- In shaping text, a <emphasis>cluster</emphasis> is a sequence of
- code points that needs to be treated as a single, indivisible unit.
- </para>
- <para>
- When you add text to a HB buffer, each character is associated with
- a <emphasis>cluster value</emphasis>. This is an arbitrary number as
- far as HB is concerned.
- </para>
- <para>
- Most clients will use UTF-8, UTF-16, or UTF-32 indices, but the
- actual number does not matter. Moreover, it is not required for the
- cluster values to be monotonically increasing, but pretty much all
- of HB's tests are performed on monotonically increasing cluster
- numbers. Nevertheless, there is no such assumption in the code
- itself. With that in mind, let's examine what happens with cluster
- values during shaping under each cluster-level.
- </para>
- <para>
- HarfBuzz provides three <emphasis>levels</emphasis> of clustering
- support. Level 0 is the default behavior and reproduces the behavior
- of the old HarfBuzz library. Level 1 tweaks this behavior slightly
- to produce better results, so level 1 clustering is recommended for
- code that is not required to implement backward compatibility with
- the old HarfBuzz.
- </para>
- <para>
- Level 2 differs significantly in how it treats cluster values.
- Levels 0 and 1 both process ligatures and glyph decomposition by
- merging clusters; level 2 does not.
- </para>
- <para>
- The conceptual model for what the cluster values mean, in levels 0
- and 1, is this:
- </para>
- <itemizedlist spacing="compact">
- <listitem>
- <para>
- the sequence of cluster values will always remain monotone
- </para>
- </listitem>
- <listitem>
- <para>
- each value represents a single cluster
- </para>
- </listitem>
- <listitem>
- <para>
- each cluster contains one or more glyphs and one or more
- characters
- </para>
- </listitem>
- </itemizedlist>
- <para>
- Assuming that initial cluster numbers were monotonically increasing
- and distinct, then all adjacent glyphs having the same cluster
- number belong to the same cluster, and all characters belong to the
- cluster that has the highest number not larger than their initial
- cluster number. This will become clearer with an example.
- </para>
-</sect1>
-<sect1 id="a-clustering-example-for-levels-0-and-1">
- <title>A clustering example for levels 0 and 1</title>
- <para>
- Let's say we start with the following character sequence and cluster
- values:
- </para>
- <programlisting>
- A,B,C,D,E
- 0,1,2,3,4
-</programlisting>
- <para>
- We then map the characters to glyphs. For simplicity, let's assume
- that each character maps to the corresponding, identical-looking
- glyph:
- </para>
- <programlisting>
- A,B,C,D,E
- 0,1,2,3,4
-</programlisting>
- <para>
- Now if, for example, <literal>B</literal> and <literal>C</literal>
- ligate, then the clusters to which they belong &quot;merge&quot;.
- This merged cluster takes for its cluster number the minimum of all
- the cluster numbers of the clusters that went in. In this case, we
- get:
- </para>
- <programlisting>
- A,BC,D,E
- 0,1 ,3,4
-</programlisting>
- <para>
- Now let's assume that the <literal>BC</literal> glyph decomposes
- into three components, and <literal>D</literal> also decomposes into
- two. The components each inherit the cluster value of their parent:
- </para>
- <programlisting>
- A,BC0,BC1,BC2,D0,D1,E
- 0,1 ,1 ,1 ,3 ,3 ,4
-</programlisting>
- <para>
- Now if <literal>BC2</literal> and <literal>D0</literal> ligate, then
- their clusters (numbers 1 and 3) merge into
- <literal>min(1,3) = 1</literal>:
- </para>
- <programlisting>
- A,BC0,BC1,BC2D0,D1,E
- 0,1 ,1 ,1 ,1 ,4
-</programlisting>
- <para>
- At this point, cluster 1 means: the character sequence
- <literal>BCD</literal> is represented by glyphs
- <literal>BC0,BC1,BC2D0,D1</literal> and cannot be broken down any
- further.
- </para>
-</sect1>
-<sect1 id="reordering-in-levels-0-and-1">
- <title>Reordering in levels 0 and 1</title>
- <para>
- Another common operation in the more complex shapers is when things
- reorder. In those cases, to maintain monotone clusters, HB merges
- the clusters of everything in the reordering sequence. For example,
- let's again start with the character sequence:
- </para>
- <programlisting>
- A,B,C,D,E
- 0,1,2,3,4
-</programlisting>
- <para>
- If <literal>D</literal> is reordered before <literal>B</literal>,
- then the <literal>B</literal>, <literal>C</literal>, and
- <literal>D</literal> clusters merge, and we get:
- </para>
- <programlisting>
- A,D,B,C,E
- 0,1,1,1,4
-</programlisting>
- <para>
- This is clearly not ideal, but it is the only sensible way to
- maintain monotone indices and retain the true relationship between
- glyphs and characters.
- </para>
-</sect1>
-<sect1 id="the-distinction-between-levels-0-and-1">
- <title>The distinction between levels 0 and 1</title>
- <para>
- So, the above is pretty much what cluster levels 0 and 1 do. The
- only difference between the two is this: in level 0, at the very
- beginning of the shaping process, we also merge clusters between
- base characters and all Unicode marks (combining or not) following
- them. E.g.:
- </para>
- <programlisting>
- A,acute,B
- 0,1 ,2
-</programlisting>
- <para>
- will become:
- </para>
- <programlisting>
- A,acute,B
- 0,0 ,2
-</programlisting>
- <para>
- This is the default behavior. We do it because Windows did it and
- old HarfBuzz did it, so this remained the default. But this behavior
- makes it impossible to color diacritic marks differently from their
- base characters. That's why in level 1 we do not perform this
- initial merging step.
- </para>
- <para>
- For clients, level 0 is more convenient if they rely on HarfBuzz
- clusters for cursor positioning. But that's wrong anyway: cursor
- positions should be determined based on Unicode grapheme boundaries,
- NOT shaping clusters. As such, level 1 clusters are preferred.
- </para>
- <para>
- One last note about levels 0 and 1. We currently don't allow a
- <literal>MultipleSubst</literal> lookup to replace a glyph with zero
- glyphs (i.e., to delete a glyph). But in some other situations,
- glyphs can be deleted. In those cases, if the glyph being deleted is
- the last glyph of its cluster, we make sure to merge the cluster
- with a neighboring cluster.
- </para>
- <para>
- This is, primarily, to make sure that the starting cluster of the
- text always has the cluster index pointing to the start of the text
- for the run; more than one client currently relies on this
- guarantee.
- </para>
- <para>
- Incidentally, Apple's CoreText does something else to maintain the
- same promise: it inserts a glyph with id 65535 at the beginning of
- the glyph string if the glyph corresponding to the first character
- in the run was deleted. HarfBuzz might do something similar in the
- future.
- </para>
-</sect1>
-<sect1 id="level-2">
- <title>Level 2</title>
- <para>
- Level 2 is a different beast from levels 0 and 1. It is simple to
- describe, but hard to make sense of. It simply doesn't do any
- cluster merging whatsoever. When things ligate or otherwise multiple
- glyphs turn into one, the cluster value of the first glyph is
- retained.
- </para>
- <para>
- Here are a few examples of why processing cluster values produced at
- this level might be tricky:
- </para>
- <sect2 id="ligatures-with-combining-marks">
- <title>Ligatures with combining marks</title>
- <para>
- Imagine capital letters are bases and lower case letters are
- combining marks. With an input sequence like this:
+ <section id="clusters">
+ <title>Clusters</title>
+ <para>
+ In text shaping, a <emphasis>cluster</emphasis> is a sequence of
+ characters that needs to be treated as a single, indivisible
+ unit.
</para>
- <programlisting>
- A,a,B,b,C,c
- 0,1,2,3,4,5
-</programlisting>
<para>
- if <literal>A,B,C</literal> ligate, then here are the cluster
- values one would get under the various levels:
+ A cluster is distinct from a <emphasis>grapheme</emphasis>,
+ which is the smallest unit of a writing system or script,
+ because clusters are only relevant for script shaping and the
+ layout of glyphs.
+ </para>
+ <para>
+ For example, a grapheme may be a letter, a number, a logogram,
+ or a symbol. When two letters form a ligature, however, they
+ combine into a single glyph. They are therefore part of the same
+ cluster and are treated as a unit &mdash; even though the two
+ original, underlying letters are separate graphemes.
+ </para>
+ <para>
+ During the shaping process, there are several shaping operations
+ that may merge adjacent characters (for example, when two code
+ points form a ligature or a conjunct form and are replaced by a
+ single glyph) or split one character into several (for example,
+ when decomposing a code point through the
+ <literal>ccmp</literal> feature).
+ </para>
+ <para>
+ HarfBuzz tracks clusters independently from how these
+ shaping operations affect the individual glyphs that comprise the
+ output HarfBuzz returns in a buffer. Consequently,
+ a client program using HarfBuzz can utilize the cluster
+ information to implement features such as:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Correctly positioning the cursor within a shaped text run,
+ even when characters have formed ligatures, composed or
+ decomposed, reordered, or undergone other shaping operations.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Correctly highlighting a text selection that includes some,
+ but not all, of the characters in a word.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Applying text attributes (such as color or underlining) to
+ part, but not all, of a word.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Generating output document formats (such as PDF) with
+ embedded text that can be fully extracted.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Determining the mapping between input characters and output
+ glyphs, such as which glyphs are ligatures.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Performing line-breaking, justification, and other
+ line-level or paragraph-level operations that must be done
+ after shaping is complete, but which require character-level
+ properties.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ When you add text to a HarfBuzz buffer, each code point must be
+ assigned a <emphasis>cluster value</emphasis>.
+ </para>
+ <para>
+ This cluster value is an arbitrary number; HarfBuzz uses it only
+ to distinguish between clusters. Many client programs will use
+ the index of each code point in the input text stream as the
+ cluster value. This is for the sake of convenience; the actual
+ value does not matter.
+ </para>
+ <para>
+ Client programs can choose how HarfBuzz handles clusters during
+ shaping by setting the
+ <literal>cluster_level</literal> of the
+ buffer. HarfBuzz offers three <emphasis>levels</emphasis> of
+ clustering support for this property:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Level 0</emphasis> is the default and
+ reproduces the behavior of the old HarfBuzz library.
+ </para>
+ <para>
+ The distinguishing feature of level 0 behavior is that, at
+ the beginning of processing the buffer, all code points that
+ are categorized as <emphasis>marks</emphasis>,
+ <emphasis>modifier symbols</emphasis>, or
+ <emphasis>Emoji extended pictographic</emphasis> modifiers,
+ as well as the <emphasis>Zero Width Joiner</emphasis> and
+ <emphasis>Zero Width Non-Joiner</emphasis> code points, are
+ assigned the cluster value of the closest preceding code
+ point from <emphasis>different</emphasis> category.
+ </para>
+ <para>
+ In essence, whenever a base character is followed by a mark
+ character or a sequence of mark characters, those marks are
+ reassigned to the same initial cluster value as the base
+ character. This reassignment is referred to as
+ "merging" the affected clusters. This behavior is based on
+ the Grapheme Cluster Boundary specification in <ulink
+ url="https://www.unicode.org/reports/tr29/#Regex_Definitions">Unicode
+ Technical Report 29</ulink>.
+ </para>
+ <para>
+ Client programs can specify level 0 behavior for a buffer by
+ setting its <literal>cluster_level</literal> to
+ <literal>HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>Level 1</emphasis> tweaks the old behavior
+ slightly to produce better results. Therefore, level 1
+ clustering is recommended for code that is not required to
+ implement backward compatibility with the old HarfBuzz.
+ </para>
+ <para>
+ Level 1 differs from level 0 by not merging the
+ clusters of marks and other modifier code points with the
+ preceding "base" code point's cluster. By preserving the
+ separate cluster values of these marks and modifier code
+ points, script shapers can perform additional operations
+ that might lead to improved results (for example, reordering
+ a sequence of marks).
+ </para>
+ <para>
+ Client programs can specify level 1 behavior for a buffer by
+ setting its <literal>cluster_level</literal> to
+ <literal>HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>Level 2</emphasis> differs significantly in how it
+ treats cluster values. In level 2, HarfBuzz never merges
+ clusters.
+ </para>
+ <para>
+ This difference can be seen most clearly when HarfBuzz processes
+ ligature substitutions and glyph decompositions. In level 0
+ and level 1, ligatures and glyph decomposition both involve
+ merging clusters; in level 2, neither of these operations
+ triggers a merge.
+ </para>
+ <para>
+ Client programs can specify level 2 behavior for a buffer by
+ setting its <literal>cluster_level</literal> to
+ <literal>HB_BUFFER_CLUSTER_LEVEL_CHARACTERS</literal>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ As mentioned earlier, client programs using HarfBuzz often
+ assign initial cluster values in a buffer by reusing the indices
+ of the code points in the input text. This gives a sequence of
+ cluster values that is monotonically increasing (for example,
+ 0,1,2,3,4,5).
</para>
<para>
- level 0:
+ It is not <emphasis>required</emphasis> that the cluster values
+ in a buffer be monotonically increasing. However, if the initial
+ cluster values in a buffer are monotonic and the buffer is
+ configured to use cluster level 0 or 1, then HarfBuzz
+ guarantees that the final cluster values in the shaped buffer
+ will also be monotonic. No such guarantee is made for cluster
+ level 2.
+ </para>
+ <para>
+ In levels 0 and 1, HarfBuzz implements the following conceptual
+ model for cluster values:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ If the sequence of input cluster values is monotonic, the
+ sequence of cluster values will remain monotonic.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Each cluster value represents a single cluster.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Each cluster contains one or more glyphs and one or more
+ characters.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ In practice, this model offers several benefits. Assuming that
+ the initial cluster values were monotonically increasing
+ and distinct before shaping began, then, in the final output:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ All adjacent glyphs having the same final cluster
+ value belong to the same cluster.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Each character belongs to the cluster that has the highest
+ cluster value <emphasis>not larger than</emphasis> its
+ initial cluster value.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ </section>
+ <section id="a-clustering-example-for-levels-0-and-1">
+ <title>A clustering example for levels 0 and 1</title>
+ <para>
+ The guarantees and benefits of level 0 and level 1 can be seen
+ with some examples. First, let us examine what happens with cluster
+ values when shaping involves cluster merging with ligatures and
+ decomposition.
+ </para>
+ <para>
+ Let's say we start with the following character sequence (top row) and
+ initial cluster values (bottom row):
</para>
<programlisting>
- ABC,a,b,c
- 0 ,0,0,0
-</programlisting>
+ A,B,C,D,E
+ 0,1,2,3,4
+ </programlisting>
<para>
- level 1:
+ During shaping, HarfBuzz maps these characters to glyphs from
+ the font. For simplicity, let us assume that each character maps
+ to the corresponding, identical-looking glyph:
</para>
<programlisting>
- ABC,a,b,c
- 0 ,0,0,5
-</programlisting>
+ A,B,C,D,E
+ 0,1,2,3,4
+ </programlisting>
<para>
- level 2:
+ Now if, for example, <literal>B</literal> and <literal>C</literal>
+ form a ligature, then the clusters to which they belong
+ &quot;merge&quot;. This merged cluster takes for its cluster
+ value the minimum of all the cluster values of the clusters that
+ went in to the ligature. In this case, we get:
</para>
<programlisting>
- ABC,a,b,c
- 0 ,1,3,5
-</programlisting>
+ A,BC,D,E
+ 0,1 ,3,4
+ </programlisting>
<para>
- Making sense of the last example is the hardest for a client,
- because there is nothing in the cluster values to suggest that
- <literal>B</literal> and <literal>C</literal> ligated with
- <literal>A</literal>.
+ because 1 is the minimum of the set {1,2}, which were the
+ cluster values of <literal>B</literal> and
+ <literal>C</literal>.
</para>
- </sect2>
- <sect2 id="reordering">
- <title>Reordering</title>
<para>
- Another tricky case is when things reorder. Under level 2:
+ Next, let us say that the <literal>BC</literal> ligature glyph
+ decomposes into three components, and <literal>D</literal> also
+ decomposes into two components. These components each inherit the
+ cluster value of their parent:
+ </para>
+ <programlisting>
+ A,BC0,BC1,BC2,D0,D1,E
+ 0,1 ,1 ,1 ,3 ,3 ,4
+ </programlisting>
+ <para>
+ Next, if <literal>BC2</literal> and <literal>D0</literal> form a
+ ligature, then their clusters (cluster values 1 and 3) merge into
+ <literal>min(1,3) = 1</literal>:
</para>
<programlisting>
- A,B,C,D,E
- 0,1,2,3,4
-</programlisting>
+ A,BC0,BC1,BC2D0,D1,E
+ 0,1 ,1 ,1 ,1 ,4
+ </programlisting>
<para>
- Now imagine <literal>D</literal> moves before
- <literal>B</literal>:
+ At this point, cluster 1 means: the character sequence
+ <literal>BCD</literal> is represented by glyphs
+ <literal>BC0,BC1,BC2D0,D1</literal> and cannot be broken down any
+ further.
+ </para>
+ </section>
+ <section id="reordering-in-levels-0-and-1">
+ <title>Reordering in levels 0 and 1</title>
+ <para>
+ Another common operation in the more complex shapers is glyph
+ reordering. In order to maintain a monotonic cluster sequence
+ when glyph reordering takes place, HarfBuzz merges the clusters
+ of everything in the reordering sequence.
+ </para>
+ <para>
+ For example, let us again start with the character sequence (top
+ row) and initial cluster values (bottom row):
</para>
<programlisting>
- A,D,B,C,E
- 0,3,1,2,4
-</programlisting>
+ A,B,C,D,E
+ 0,1,2,3,4
+ </programlisting>
<para>
- Now, if <literal>D</literal> ligates with <literal>B</literal>, we
+ If <literal>D</literal> is reordered to before <literal>B</literal>,
+ then HarfBuzz merges the <literal>B</literal>,
+ <literal>C</literal>, and <literal>D</literal> clusters, and we
get:
</para>
<programlisting>
- A,DB,C,E
- 0,3 ,2,4
-</programlisting>
+ A,D,B,C,E
+ 0,1,1,1,4
+ </programlisting>
+ <para>
+ This is clearly not ideal, but it is the only sensible way to
+ maintain a monotonic sequence of cluster values and retain the
+ true relationship between glyphs and characters.
+ </para>
+ </section>
+ <section id="the-distinction-between-levels-0-and-1">
+ <title>The distinction between levels 0 and 1</title>
+ <para>
+ The preceding examples demonstrate the main effects of using
+ cluster levels 0 and 1. The only difference between the two
+ levels is this: in level 0, at the very beginning of the shaping
+ process, HarfBuzz also merges clusters between any base character
+ and all Unicode marks (combining or not) that follow it.
+ </para>
+ <para>
+ For example, let us start with the following character sequence
+ (top row) and accompanying initial cluster values (bottom row):
+ </para>
+ <programlisting>
+ A,acute,B
+ 0,1 ,2
+ </programlisting>
<para>
- In a different scenario, <literal>A</literal> and
- <literal>B</literal> could have ligated
- <emphasis>before</emphasis> <literal>D</literal> reordered; that
- would have resulted in:
+ The <literal>acute</literal> is a Unicode mark. If HarfBuzz is
+ using cluster level 0 on this sequence, then the
+ <literal>A</literal> and <literal>acute</literal> clusters will
+ merge, and the result will become:
</para>
<programlisting>
- AB,D,C,E
- 0 ,3,2,4
-</programlisting>
+ A,acute,B
+ 0,0 ,2
+ </programlisting>
<para>
- There's no way to differentiate between these two scenarios based
- on the cluster numbers alone.
+ This initial cluster merging is the default behavior of the
+ Windows shaping engine, and the old HarfBuzz codebase copied
+ that behavior to maintain compatibility. Consequently, it has
+ remained the default behavior in the new HarfBuzz codebase.
</para>
<para>
- Another problem happens with ligatures under level 2 if the
- direction of the text is forced to opposite of its natural
- direction (e.g. left-to-right Arabic). But that's too much of a
- corner case to worry about.
+ But this initial cluster-merging behavior makes it impossible to
+ color diacritic marks differently from their base
+ characters. That is why, in level 1, HarfBuzz does not perform
+ the initial merging step.
</para>
- </sect2>
-</sect1>
+ <para>
+ For client programs that rely on HarfBuzz cluster values to
+ perform cursor positioning, level 0 is more convenient. But
+ relying on cluster boundaries for cursor positioning is wrong: cursor
+ positions should be determined based on Unicode grapheme
+ boundaries, not on shaping-cluster boundaries. As such, level 1
+ clusters are preferred.
+ </para>
+ <para>
+ One last note about levels 0 and 1. HarfBuzz currently does not allow a
+ <literal>MultipleSubst</literal> lookup to replace a glyph with zero
+ glyphs (in other words, to delete a glyph). But, in some other situations,
+ glyphs can be deleted. In those cases, if the glyph being deleted is
+ the last glyph of its cluster, HarfBuzz makes sure to merge the cluster
+ with a neighboring cluster.
+ </para>
+ <para>
+ This is done primarily to make sure that the starting cluster of the
+ text always has the cluster index pointing to the start of the text
+ for the run; more than one client currently relies on this
+ guarantee.
+ </para>
+ <para>
+ Incidentally, Apple's CoreText does something else to maintain the
+ same promise: it inserts a glyph with id 65535 at the beginning of
+ the glyph string if the glyph corresponding to the first character
+ in the run was deleted. HarfBuzz might do something similar in the
+ future.
+ </para>
+ </section>
+ <section id="level-2">
+ <title>Level 2</title>
+ <para>
+ HarfBuzz's level 2 cluster behavior uses a significantly
+ different model than that of level 0 and level 1.
+ </para>
+ <para>
+ The level 2 behavior is easy to describe, but it may be
+ difficult to understand in practical terms. In brief, level 2
+ performs no merging of clusters whatsoever.
+ </para>
+ <para>
+ When glyphs form a ligature (or when some other feature
+ substitutes multiple glyphs with one glyph), the cluster value
+ of the first glyph is retained as the cluster value for the
+ ligature. However, no subsequent clusters &mdash; including
+ marks and modifiers &mdash; are affected.
+ </para>
+ <para>
+ Level 2 cluster behavior is less complex than level 0 or level
+ 1, but there are a few cases in which processing cluster values
+ produced at level 2 may be tricky.
+ </para>
+ <section id="ligatures-with-combining-marks-in-level-2">
+ <title>Ligatures with combining marks in level 2</title>
+ <para>
+ The first example of how HarfBuzz's level 2 cluster behavior
+ can be tricky is when the text to be shaped includes combining
+ marks attached to ligatures.
+ </para>
+ <para>
+ Let us start with an input sequence with the following
+ characters (top row) and initial cluster values (bottom row):
+ </para>
+ <programlisting>
+ A,acute,B,breve,C,circumflex
+ 0,1 ,2,3 ,4,5
+ </programlisting>
+ <para>
+ If the sequence <literal>A,B,C</literal> forms a ligature,
+ then these are the cluster values HarfBuzz will return under
+ the various cluster levels:
+ </para>
+ <para>
+ Level 0:
+ </para>
+ <programlisting>
+ ABC,acute,breve,circumflex
+ 0 ,0 ,0 ,0
+ </programlisting>
+ <para>
+ Level 1:
+ </para>
+ <programlisting>
+ ABC,acute,breve,circumflex
+ 0 ,0 ,0 ,5
+ </programlisting>
+ <para>
+ Level 2:
+ </para>
+ <programlisting>
+ ABC,acute,breve,circumflex
+ 0 ,1 ,3 ,5
+ </programlisting>
+ <para>
+ Making sense of the level 2 result is the hardest for a client
+ program, because there is nothing in the cluster values that
+ indicates that <literal>B</literal> and <literal>C</literal>
+ formed a ligature with <literal>A</literal>.
+ </para>
+ <para>
+ In contrast, the "merged" cluster values of the mark glyphs
+ that are seen in the level 0 and level 1 output are evidence
+ that a ligature substitution took place.
+ </para>
+ </section>
+ <section id="reordering-in-level-2">
+ <title>Reordering in level 2</title>
+ <para>
+ Another example of how HarfBuzz's level 2 cluster behavior
+ can be tricky is when glyphs reorder. Consider an input sequence
+ with the following characters (top row) and initial cluster
+ values (bottom row):
+ </para>
+ <programlisting>
+ A,B,C,D,E
+ 0,1,2,3,4
+ </programlisting>
+ <para>
+ Now imagine <literal>D</literal> moves before
+ <literal>B</literal> in a reordering operation. The cluster
+ values will then be:
+ </para>
+ <programlisting>
+ A,D,B,C,E
+ 0,3,1,2,4
+ </programlisting>
+ <para>
+ Next, if <literal>D</literal> forms a ligature with
+ <literal>B</literal>, the output is:
+ </para>
+ <programlisting>
+ A,DB,C,E
+ 0,3 ,2,4
+ </programlisting>
+ <para>
+ However, in a different scenario, in which the shaping rules
+ of the script instead caused <literal>A</literal> and
+ <literal>B</literal> to form a ligature
+ <emphasis>before</emphasis> the <literal>D</literal> reordered, the
+ result would be:
+ </para>
+ <programlisting>
+ AB,D,C,E
+ 0 ,3,2,4
+ </programlisting>
+ <para>
+ There is no way for a client program to differentiate between
+ these two scenarios based on the cluster values
+ alone. Consequently, client programs that use level 2 might
+ need to undertake additional work in order to manage cursor
+ positioning, text attributes, or other desired features.
+ </para>
+ </section>
+ <section id="other-considerations-in-level-2">
+ <title>Other considerations in level 2</title>
+ <para>
+ There may be other problems encountered with ligatures under
+ level 2, such as if the direction of the text is forced to
+ opposite of its natural direction (for example, left-to-right
+ Arabic). But, generally speaking, these other scenarios are
+ minor corner cases that are too obscure for most client
+ programs to need to worry about.
+ </para>
+ </section>
+ </section>
</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml
index 7de0f051a80..55360043904 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml
@@ -1,3 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="fonts-and-faces">
<title>Fonts and faces</title>
<section id="using-freetype">
@@ -15,4 +21,4 @@
<para>
</para>
</section>
-</chapter> \ No newline at end of file
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml
new file mode 100644
index 00000000000..932bd947193
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml
@@ -0,0 +1,223 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
+<chapter id="getting-started">
+ <title>Getting started with HarfBuzz</title>
+ <section>
+ <title>An overview of the HarfBuzz shaping API</title>
+ <para>
+ The core of the HarfBuzz shaping API is the function
+ <function>hb_shape()</function>. This function takes a font, a
+ buffer containing a string of Unicode codepoints and
+ (optionally) a list of font features as its input. It replaces
+ the codepoints in the buffer with the corresponding glyphs from
+ the font, correctly ordered and positioned, and with any of the
+ optional font features applied.
+ </para>
+ <para>
+ In addition to holding the pre-shaping input (the Unicode
+ codepoints that comprise the input string) and the post-shaping
+ output (the glyphs and positions), a HarfBuzz buffer has several
+ properties that affect shaping. The most important are the
+ text-flow direction (e.g., left-to-right, right-to-left,
+ top-to-bottom, or bottom-to-top), the script tag, and the
+ language tag.
+ </para>
+
+ <para>
+ For input string buffers, flags are available to denote when the
+ buffer represents the beginning or end of a paragraph, to
+ indicate whether or not to visibly render Unicode <literal>Default
+ Ignorable</literal> codepoints, and to modify the cluster-merging
+ behavior for the buffer. For shaped output buffers, the
+ individual X and Y offsets and <literal>advances</literal>
+ (the logical dimensions) of each glyph are
+ accessible. HarfBuzz also flags glyphs as
+ <literal>UNSAFE_TO_BREAK</literal> if breaking the string at
+ that glyph (e.g., in a line-breaking or hyphenation process)
+ would require re-shaping the text.
+ </para>
+
+ <para>
+ HarfBuzz also provides methods to compare the contents of
+ buffers, join buffers, normalize buffer contents, and handle
+ invalid codepoints, as well as to determine the state of a
+ buffer (e.g., input codepoints or output glyphs). Buffer
+ lifecycles are managed and all buffers are reference-counted.
+ </para>
+
+ <para>
+ Although the default <function>hb_shape()</function> function is
+ sufficient for most use cases, a variant is also provide that
+ lets you specify which of HarfBuzz's shapers to use on a buffer.
+ </para>
+
+ <para>
+ HarfBuzz can read TrueType fonts, TrueType collections, OpenType
+ fonts, and OpenType collections. Functions are provided to query
+ font objects about metrics, Unicode coverage, available tables and
+ features, and variation selectors. Individual glyphs can also be
+ queried for metrics, variations, and glyph names. OpenType
+ variable fonts are supported, and HarfBuzz allows you to set
+ variation-axis coordinates on font objects.
+ </para>
+
+ <para>
+ HarfBuzz provides glue code to integrate with various other
+ libraries, including FreeType, GObject, and CoreText. Support
+ for integrating with Uniscribe and DirectWrite is experimental
+ at present.
+ </para>
+ </section>
+
+ <section>
+ <title>Terminology</title>
+ <variablelist>
+ <varlistentry>
+ <term>shaper</term>
+ <listitem>
+ <para>
+ In HarfBuzz, a <emphasis>shaper</emphasis> is a
+ handler for a specific script shaping model. HarfBuzz
+ implements separate shapers for Indic, Arabic, Thai and
+ Lao, Khmer, Myanmar, Tibetan, Hangul, Hebrew, the
+ Universal Shaping Engine (USE), and a default shaper for
+ non-complex scripts.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>cluster</term>
+ <listitem>
+ <para>
+ In text shaping, a <emphasis>cluster</emphasis> is a
+ sequence of codepoints that must be handled as an
+ indivisible unit. Clusters can include codepoint
+ sequences that form a ligature or base-and-mark
+ sequences. Tracking and preserving clusters is important
+ when shaping operations might separate or reorder
+ codepoints.
+ </para>
+ <para>
+ HarfBuzz provides three cluster
+ <emphasis>levels</emphasis> that implement different
+ approaches to the problem of preserving clusters during
+ shaping operations.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
+ </variablelist>
+
+ </section>
+
+
+ <section>
+ <title>A simple shaping example</title>
+
+ <para>
+ Below is the simplest HarfBuzz shaping example possible.
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ Create a buffer and put your text in it.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ #include &lt;hb.h&gt;
+ hb_buffer_t *buf;
+ buf = hb_buffer_create();
+ hb_buffer_add_utf8(buf, text, -1, 0, -1);
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="2">
+ <para>
+ Guess the script, language and direction of the buffer.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ hb_buffer_set_direction(buf, HB_DIRECTION_LTR);
+ hb_buffer_set_script(buf, HB_SCRIPT_LATIN);
+ hb_buffer_set_language(buf, hb_language_from_string("en", -1));
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="3">
+ <para>
+ Create a face and a font, using FreeType for now.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ #include &lt;hb-ft.h&gt;
+ FT_New_Face(ft_library, font_path, index, &amp;face);
+ FT_Set_Char_Size(face, 0, 1000, 0, 0);
+ hb_font_t *font = hb_ft_font_create(face);
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="4">
+ <para>
+ Shape!
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting>
+ hb_shape(font, buf, NULL, 0);
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="5">
+ <para>
+ Get the glyph and position information.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &amp;glyph_count);
+ hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &amp;glyph_count);
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="6">
+ <para>
+ Iterate over each glyph.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ for (i = 0; i &lt; glyph_count; ++i) {
+ glyphid = glyph_info[i].codepoint;
+ x_offset = glyph_pos[i].x_offset / 64.0;
+ y_offset = glyph_pos[i].y_offset / 64.0;
+ x_advance = glyph_pos[i].x_advance / 64.0;
+ y_advance = glyph_pos[i].y_advance / 64.0;
+ draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset);
+ cursor_x += x_advance;
+ cursor_y += y_advance;
+ }
+ </programlisting>
+ <orderedlist numeration="arabic">
+ <listitem override="7">
+ <para>
+ Tidy up.
+ </para>
+ </listitem>
+ </orderedlist>
+ <programlisting language="C">
+ hb_buffer_destroy(buf);
+ hb_font_destroy(hb_ft_font);
+ </programlisting>
+
+ <para>
+ This example shows enough to get us started using HarfBuzz. In
+ the sections that follow, we will use the remainder of
+ HarfBuzz's API to refine and extend the example and improve its
+ text-shaping capabilities.
+ </para>
+ </section>
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml
index ca674c0c588..78f06c73912 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml
@@ -1,3 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<sect1 id="glyph-information">
<title>Glyph information</title>
<sect2 id="names-and-numbers">
@@ -5,4 +11,4 @@
<para>
</para>
</sect2>
-</sect1> \ No newline at end of file
+</sect1>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-hello-harfbuzz.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-hello-harfbuzz.xml
deleted file mode 100644
index 716b2f2dd94..00000000000
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-hello-harfbuzz.xml
+++ /dev/null
@@ -1,183 +0,0 @@
-<chapter id="hello-harfbuzz">
- <title>Hello, HarfBuzz</title>
- <para>
- Here's the simplest HarfBuzz that can possibly work. We will improve
- it later.
- </para>
- <orderedlist numeration="arabic">
- <listitem>
- <para>
- Create a buffer and put your text in it.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- #include &lt;hb.h&gt;
- hb_buffer_t *buf;
- buf = hb_buffer_create();
- hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text));
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="2">
- <para>
- Guess the script, language and direction of the buffer.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- hb_buffer_guess_segment_properties(buf);
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="3">
- <para>
- Create a face and a font, using FreeType for now.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- #include &lt;hb-ft.h&gt;
- FT_New_Face(ft_library, font_path, index, &amp;face)
- hb_font_t *font = hb_ft_font_create(face);
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="4">
- <para>
- Shape!
- </para>
- </listitem>
- </orderedlist>
- <programlisting>
- hb_shape(font, buf, NULL, 0);
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="5">
- <para>
- Get the glyph and position information.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &amp;glyph_count);
- hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &amp;glyph_count);
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="6">
- <para>
- Iterate over each glyph.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- for (i = 0; i &lt; glyph_count; ++i) {
- glyphid = glyph_info[i].codepoint;
- x_offset = glyph_pos[i].x_offset / 64.0;
- y_offset = glyph_pos[i].y_offset / 64.0;
- x_advance = glyph_pos[i].x_advance / 64.0;
- y_advance = glyph_pos[i].y_advance / 64.0;
- draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset);
- cursor_x += x_advance;
- cursor_y += y_advance;
- }
-</programlisting>
- <orderedlist numeration="arabic">
- <listitem override="7">
- <para>
- Tidy up.
- </para>
- </listitem>
- </orderedlist>
- <programlisting language="C">
- hb_buffer_destroy(buf);
- hb_font_destroy(hb_ft_font);
-</programlisting>
- <section id="what-harfbuzz-doesnt-do">
- <title>What HarfBuzz doesn't do</title>
- <para>
- The code above will take a UTF8 string, shape it, and give you the
- information required to lay it out correctly on a single
- horizontal (or vertical) line using the font provided. That is the
- extent of HarfBuzz's responsibility.
- </para>
- <para>
- If you are implementing a text layout engine you may have other
- responsibilities, that HarfBuzz will not help you with:
- </para>
- <itemizedlist>
- <listitem>
- <para>
- HarfBuzz won't help you with bidirectionality. If you want to
- lay out text with mixed Hebrew and English, you will need to
- ensure that the buffer provided to HarfBuzz has those
- characters in the correct layout order. This will be different
- from the logical order in which the Unicode text is stored. In
- other words, the user will hit the keys in the following
- sequence:
- </para>
- <programlisting>
-A B C [space] ג ב א [space] D E F
- </programlisting>
- <para>
- but will expect to see in the output:
- </para>
- <programlisting>
-ABC אבג DEF
- </programlisting>
- <para>
- This reordering is called <emphasis>bidi processing</emphasis>
- (&quot;bidi&quot; is short for bidirectional), and there's an
- algorithm as an annex to the Unicode Standard which tells you how
- to reorder a string from logical order into presentation order.
- Before sending your string to HarfBuzz, you may need to apply the
- bidi algorithm to it. Libraries such as ICU and fribidi can do
- this for you.
- </para>
- </listitem>
- <listitem>
- <para>
- HarfBuzz won't help you with text that contains different font
- properties. For instance, if you have the string &quot;a
- <emphasis>huge</emphasis> breakfast&quot;, and you expect
- &quot;huge&quot; to be italic, you will need to send three
- strings to HarfBuzz: <literal>a</literal>, in your Roman font;
- <literal>huge</literal> using your italic font; and
- <literal>breakfast</literal> using your Roman font again.
- Similarly if you change font, font size, script, language or
- direction within your string, you will need to shape each run
- independently and then output them independently. HarfBuzz
- expects to shape a run of characters sharing the same
- properties.
- </para>
- </listitem>
- <listitem>
- <para>
- HarfBuzz won't help you with line breaking, hyphenation or
- justification. As mentioned above, it lays out the string
- along a <emphasis>single line</emphasis> of, notionally,
- infinite length. If you want to find out where the potential
- word, sentence and line break points are in your text, you
- could use the ICU library's break iterator functions.
- </para>
- <para>
- HarfBuzz can tell you how wide a shaped piece of text is, which is
- useful input to a justification algorithm, but it knows nothing
- about paragraphs, lines or line lengths. Nor will it adjust the
- space between words to fit them proportionally into a line. If you
- want to layout text in paragraphs, you will probably want to send
- each word of your text to HarfBuzz to determine its shaped width
- after glyph substitutions, then work out how many words will fit
- on a line, and then finally output each word of the line separated
- by a space of the correct size to fully justify the paragraph.
- </para>
- </listitem>
- </itemizedlist>
- <para>
- As a layout engine implementor, HarfBuzz will help you with the
- interface between your text and your font, and that's something
- that you'll need - what you then do with the glyphs that your font
- returns is up to you. The example we saw above enough to get us
- started using HarfBuzz. Now we are going to use the remainder of
- HarfBuzz's API to refine that example and improve our text shaping
- capabilities.
- </para>
- </section>
-</chapter> \ No newline at end of file
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml
index 899cc5bd671..a6484fc5aee 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml
@@ -1,70 +1,431 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="install-harfbuzz">
- <title>Install HarfBuzz</title>
+ <title>Installing HarfBuzz</title>
+
<section id="download">
- <title id="download.title">Download</title>
+ <title id="download.title">Downloading HarfBuzz</title>
<para>
- For tarball releases of HarfBuzz, look
- <ulink url="http://www.freedesktop.org/software/harfbuzz/release/">here</ulink>.
- At the same place you will
- also find Win32 binary bundles that include libharfbuzz DLL, hb-view.exe,
- hb-shape.exe, and all dependencies.
+ The HarfBuzz source code is hosted at <ulink
+ url="https://github.com/harfbuzz/harfbuzz">github.com/harfbuzz/harfbuzz</ulink>. The
+ same source tree is also available at the
+ <ulink
+ url="http://cgit.freedesktop.org/harfbuzz/">Freedesktop.org</ulink>
+ site.
</para>
<para>
- The canonical source tree is available
- <ulink url="http://cgit.freedesktop.org/harfbuzz/">here</ulink>.
- Also available on <ulink url="https://github.com/harfbuzz/harfbuzz">github</ulink>.
+ Tarball releases and Win32 binary bundles (which include the
+ libharfbuzz DLL, hb-view.exe, hb-shape.exe, and all
+ dependencies) of HarfBuzz can be downloaded from <ulink
+ url="https://github.com/harfbuzz/harfbuzz">github.com/harfbuzz/harfbuzz/releases</ulink>
+ or from
+ <ulink url="http://www.freedesktop.org/software/harfbuzz/release/">Freedesktop.org</ulink>.
</para>
<para>
- The API that comes with <filename class='headerfile'>hb.h</filename> will
- not change incompatibly. Other, peripheral, headers are more likely to go
- through minor modifications, but again, will do our best to never change
- API in an incompatible way. We will never break the ABI.
+ Release notes are posted with each new release to provide an
+ overview of the changes. The project <ulink url="https://github.com/harfbuzz/harfbuzz/issues">tracks bug
+ reports and other issues</ulink> on GitHub. Discussion and
+ questions are welcome on the <ulink
+ url="http://freedesktop.org/mailman/listinfo/harfbuzz/">HarfBuzz
+ mailing list</ulink>.
</para>
<para>
- If you are not sure whether Pango or HarfBuzz is right for you, read
- <ulink url="http://mces.blogspot.in/2009/11/pango-vs-harfbuzz.html">this</ulink>.
+ The API included in the <filename
+ class='headerfile'>hb.h</filename> file will not change in a
+ compatibility-breaking way in any release. However, other,
+ peripheral headers are more likely to go through minor
+ modifications. We will do our best to never change APIs in an
+ incompatible way. We will <emphasis>never</emphasis> break the ABI.
</para>
</section>
+
<section id="building">
- <title>Building</title>
+ <title>Building HarfBuzz</title>
+
+ <section id="building.linux">
+ <title>Building on Linux</title>
<para>
- On Linux, install the development packages for FreeType, Cairo, and GLib.
- For example, on Ubuntu / Debian, you would do:
- <programlisting>
-<command>sudo apt-get install</command> <package>gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev</package>
- </programlisting>
- whereas on Fedora, RHEL, CentOS, and other Red Hat based systems you would do:
+ <emphasis>(1)</emphasis> To build HarfBuzz on Linux, you must first install the
+ development packages for FreeType, Cairo, and GLib. The exact
+ commands required for this step will vary depending on
+ the Linux distribution you use.
+ </para>
+ <para>
+ For example, on an Ubuntu or Debian system, you would run:
<programlisting>
-<command>sudo yum install</command> <package>gcc gcc-c++ freetype-devel glib2-devel cairo-devel</package>
+ <command>sudo apt install</command> <package>gcc g++
+ libfreetype6-dev libglib2.0-dev libcairo2-dev</package>
</programlisting>
- or using MacPorts:
+ On Fedora, RHEL, CentOS, or other Red-Hat&ndash;based systems, you would run:
<programlisting>
-<command>sudo port install</command> <package>freetype glib2 cairo</package>
+ <command>sudo yum install</command> <package>gcc gcc-c++ freetype-devel glib2-devel cairo-devel</package>
</programlisting>
+
+ </para>
+
+ <para>
+ <emphasis>(2)</emphasis> The next step depends on whether you
+ are building from the source in a downloaded release tarball or
+ from the source directly from the git repository.
+ </para>
+ <para>
+ <emphasis>(2)(a)</emphasis> If you downloaded the HarfBuzz
+ source code in a tarball, you can now extract the source.
+ </para>
+ <para>
+ From a shell in the top-level directory of the extracted source
+ code, you can run <command>./configure</command> followed by
+ <command>make</command> as with any other standard package.
+ </para>
+ <para>
+ This should leave you with a shared
+ library in the <filename>src/</filename> directory, and a few
+ utility programs including <command>hb-view</command> and
+ <command>hb-shape</command> under the <filename>util/</filename>
+ directory.
</para>
<para>
- If you are using a tarball, you can now proceed to running
- <command>configure</command> and <command>make</command> as with any
- other standard package. That should leave you with a shared library in
- <filename>src/</filename>, and a few utility programs including hb-view
- and hb-shape under <filename>util/</filename>.
+ <emphasis>(2)(b)</emphasis> If you are building from the source in the HarfBuzz git
+ repository, rather than installing from a downloaded tarball
+ release, then you must install two more auxiliary tools before you
+ can build for the first time: <package>pkg-config</package> and
+ <ulink url="http://www.complang.org/ragel/">ragel</ulink>.
</para>
<para>
- If you are bootstrapping from git, you need a few more tools before you
- can run <filename>autogen.sh</filename> for the first time. Namely,
- pkg-config and <ulink url="http://www.complang.org/ragel/">ragel</ulink>.
- Again, on Ubuntu / Debian:
+ On Ubuntu or Debian, run:
<programlisting>
-<command>sudo apt-get install</command> <package>autoconf automake libtool pkg-config ragel gtk-doc-tools</package>
+ <command>sudo apt-get install</command> <package>autoconf automake libtool pkg-config ragel gtk-doc-tools</package>
</programlisting>
- and on Fedora, RHEL, CentOS:
+ On Fedora, RHEL, CentOS, run:
<programlisting>
-<command>sudo yum install</command> <package>autoconf automake libtool pkgconfig ragel gtk-doc</package>
+ <command>sudo yum install</command> <package>autoconf automake libtool pkgconfig ragel gtk-doc</package>
</programlisting>
- or using MacPorts:
+
+ </para>
+ <para>
+ With <package>pkg-config</package> and <package>ragel</package>
+ installed, you can now run <command>./autogen.sh</command>,
+ followed by <command>./configure</command> and
+ <command>make</command> to build HarfBuzz.
+ </para>
+ </section>
+
+
+ <section id="building.windows">
+ <title>Building on Windows</title>
+
+ <para>
+ On Windows, consider using Microsoft's free <ulink
+ url="https://github.com/Microsoft/vcpkg">vcpkg</ulink> utility
+ to build HarfBuzz, its dependencies, and other open-source
+ libraries.
+ </para>
+ <para>
+ If you need to build HarfBuzz from source, first put the
+ <program>ragel</program> binary on your
+ <literal>PATH</literal>, then follow the appveyor CI cmake
+ <ulink
+ url="https://github.com/harfbuzz/harfbuzz/blob/master/appveyor.yml">build
+ instructions</ulink>.
+ </para>
+ </section>
+
+
+ <section id="building.macos">
+ <title>Building on macOS</title>
+
+ <para>
+ There are two ways to build HarfBuzz on Mac systems: MacPorts
+ and Homebrew. The process is similar to the process used on a
+ Linux system.
+ </para>
+ <para>
+ <emphasis>(1)</emphasis> You must first install the
+ development packages for FreeType, Cairo, and GLib. If you are
+ using MacPorts, you should run:
<programlisting>
-<command>sudo port install</command> <package>autoconf automake libtool pkgconfig ragel gtk-doc</package>
+ <command>sudo port install</command> <package>freetype glib2 cairo</package>
</programlisting>
- </para>
+ </para>
+ <para>
+ If you are using Homebrew, you should run:
+ <programlisting>
+ <command>brew install</command> <package>freetype glib cairo</package>
+ </programlisting>
+ </para>
+ <para>
+ <emphasis>(2)</emphasis> The next step depends on whether you are building from the
+ source in a downloaded release tarball or from the source directly
+ from the git repository.
+ </para>
+ <para>
+ <emphasis>(2)(a)</emphasis> If you are installing HarfBuzz
+ from a downloaded tarball release, extract the tarball and
+ open a Terminal in the extracted source-code directory. Run:
+ <programlisting>
+ <command>./configure</command>
+ </programlisting>
+ followed by:
+ <programlisting>
+ <command>make</command>
+ </programlisting>
+ to build HarfBuzz.
+ </para>
+ <para>
+ <emphasis>(2)(b)</emphasis> Alternatively, if you are building
+ HarfBuzz from the source in the HarfBuzz git repository, then
+ you must install several built-time dependencies before
+ proceeding.
+ </para>
+ <para>If you are
+ using MacPorts, you should run:
+ <programlisting>
+ <command>sudo port install</command> <package>autoconf
+ automake libtool pkgconfig ragel gtk-doc</package>
+ </programlisting>
+ to install the build dependencies.
+ </para>
+ <para>If you are using Homebrew, you should run:
+ <programlisting>
+ <command>brew install</command> <package>autoconf automake libtool pkgconfig ragel gtk-doc</package>
+ </programlisting>
+ Finally, you can run:
+ <programlisting>
+ <command>./autogen.sh</command>
+ </programlisting>
+ </para>
+ <para>
+ <emphasis>(3)</emphasis> You can now build HarfBuzz (on either
+ a MacPorts or a Homebrew system) by running:
+ <programlisting>
+ <command>./configure</command>
+ </programlisting>
+ followed by:
+ <programlisting>
+ <command>make</command>
+ </programlisting>
+ </para>
+ <para>
+ This should leave you with a shared
+ library in the <filename>src/</filename> directory, and a few
+ utility programs including <command>hb-view</command> and
+ <command>hb-shape</command> under the <filename>util/</filename>
+ directory.
+ </para>
+
+ </section>
+
+ <section id="configuration">
+ <title>Configuration options</title>
+
+ <para>
+ The instructions in the "Building HarfBuzz" section will build
+ the source code under its default configuration. If needed,
+ the following additional configuration options are available.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>--with-libstdc++</term>
+ <listitem>
+ <para>
+ Allow linking with libstdc++. <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables linking HarfBuzz to the
+ system's libstdc++ library.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-glib</term>
+ <listitem>
+ <para>
+ Use <ulink url="https://developer.gnome.org/glib/">GLib</ulink>. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the GLib
+ library. The default setting is to check for the
+ presence of GLib and, if it is found, build with
+ GLib support. GLib is native to GNU/Linux systems but is
+ available on other operating system as well.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-gobject</term>
+ <listitem>
+ <para>
+ Use <ulink url="https://developer.gnome.org/gobject/stable/">GObject</ulink>. <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the GObject
+ library. The default setting is to check for the
+ presence of GObject and, if it is found, build with
+ GObject support. GObject is native to GNU/Linux systems but is
+ available on other operating system as well.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-cairo</term>
+ <listitem>
+ <para>
+ Use <ulink url="https://cairographics.org/">Cairo</ulink>. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the Cairo
+ graphics-rendering library. The default setting is to
+ check for the presence of Cairo and, if it is found,
+ build with Cairo support.
+ </para>
+ <para>
+ Note: Cairo is used only by the HarfBuzz
+ command-line utilities, and not by the HarfBuzz library.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-fontconfig</term>
+ <listitem>
+ <para>
+ Use <ulink url="https://www.freedesktop.org/wiki/Software/fontconfig/">Fontconfig</ulink>. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the Fontconfig
+ library, which provides font-matching functions and
+ provides access to font properties. The default setting
+ is to check for the presence of Fontconfig and, if it is
+ found, build with Fontconfig support.
+ </para>
+ <para>
+ Note: Fontconfig is used only by the HarfBuzz
+ command-line utilities, and not by the HarfBuzz library.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-icu</term>
+ <listitem>
+ <para>
+ Use the <ulink url="http://site.icu-project.org/home">ICU</ulink> library. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the
+ <emphasis>International Components for
+ Unicode</emphasis> (ICU) library, which provides access
+ to Unicode Character Database (UCD) properties as well
+ as normalization and conversion functions. The default
+ setting is to check for the presence of ICU and, if it
+ is found, build with ICU support.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-ucdn</term>
+ <listitem>
+ <para>
+ Use HarfBuzz's <ulink url="https://github.com/harfbuzz/harfbuzz/tree/master/src/hb-ucdn">built-in UCDN library</ulink>. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ The HarfBuzz source tree includes a <emphasis>Unicode
+ Database and Normalization</emphasis> (UCDN) library
+ that provides access to basic character properties in
+ the Unicode Character Database (UCD) as well as low-level
+ normalization functions. HarfBuzz can be built without
+ this UCDN support if the usage of a different UCDN
+ library is desired.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-graphite2</term>
+ <listitem>
+ <para>
+ Use the <ulink url="http://graphite.sil.org/">Graphite2</ulink> library. <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the Graphite2
+ library, which provides support for the Graphite shaping
+ model.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-freetype</term>
+ <listitem>
+ <para>
+ Use the <ulink url="https://www.freetype.org/">FreeType</ulink> library. <emphasis>(Default = auto)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the FreeType
+ font-rendering library. The default setting is to check for the
+ presence of FreeType and, if it is found, build with
+ FreeType support.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-uniscribe</term>
+ <listitem>
+ <para>
+ Use the <ulink
+ url="https://docs.microsoft.com/en-us/windows/desktop/intl/uniscribe">Uniscribe</ulink>
+ library (experimental). <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the Uniscribe
+ font-rendering library. Uniscribe is available on
+ Windows systems. Uniscribe support is used only for
+ testing purposes and does not need to be enabled for
+ HarfBuzz to run on Windows systems.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-directwrite</term>
+ <listitem>
+ <para>
+ Use the <ulink url="https://docs.microsoft.com/en-us/windows/desktop/directwrite/direct-write-portal">DirectWrite</ulink> library (experimental). <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the DirectWrite
+ font-rendering library. DirectWrite is available on
+ Windows systems. DirectWrite support is used only for
+ testing purposes and does not need to be enabled for
+ HarfBuzz to run on Windows systems.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>--with-coretext</term>
+ <listitem>
+ <para>
+ Use the <ulink url="https://developer.apple.com/documentation/coretext">CoreText</ulink> library. <emphasis>(Default = no)</emphasis>
+ </para>
+ <para>
+ This option enables or disables usage of the CoreText
+ library. CoreText is available on macOS and iOS systems.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+
</section>
</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml
index 470bab8d1fb..51ff55a770e 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml
@@ -1,3 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="shaping-and-shape-plans">
<title>Shaping and shape plans</title>
<section id="opentype-features">
@@ -10,4 +16,4 @@
<para>
</para>
</section>
-</chapter> \ No newline at end of file
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml
new file mode 100644
index 00000000000..bc9f1b8302e
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml
@@ -0,0 +1,374 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
+<chapter id="shaping-concepts">
+ <title>Shaping concepts</title>
+ <section id="text-shaping-concepts">
+ <title>Text shaping</title>
+ <para>
+ Text shaping is the process of transforming a sequence of Unicode
+ codepoints that represent individual characters (letters,
+ diacritics, tone marks, numbers, symbols, etc.) into the
+ orthographically and linguistically correct two-dimensional layout
+ of glyph shapes taken from a specified font.
+ </para>
+ <para>
+ For some writing systems (or <emphasis>scripts</emphasis>) and
+ languages, the process is simple, requiring the shaper to do
+ little more than advance the horizontal position forward by the
+ correct amount for each successive glyph.
+ </para>
+ <para>
+ But, for <emphasis>complex scripts</emphasis>, any combination of
+ several shaping operations may be required, and the rules for how
+ and when they are applied vary from script to script. HarfBuzz and
+ other shaping engines implement these rules.
+ </para>
+ <para>
+ The exact rules and necessary operations for a particular script
+ constitute a shaping <emphasis>model</emphasis>. OpenType
+ specifies a set of shaping models that covers all of
+ Unicode. Other shaping models are available, however, including
+ Graphite and Apple Advanced Typography (AAT).
+ </para>
+ </section>
+
+ <section id="complex-scripts">
+ <title>Complex scripts</title>
+ <para>
+ In text-shaping terminology, scripts are generally classified as
+ either <emphasis>complex</emphasis> or <emphasis>non-complex</emphasis>.
+ </para>
+ <para>
+ Complex scripts are those for which transforming the input
+ sequence into the final layout requires some combination of
+ operations&mdash;such as context-dependent substitutions,
+ context-dependent mark positioning, glyph-to-glyph joining,
+ glyph reordering, or glyph stacking.
+ </para>
+ <para>
+ In some complex scripts, the shaping rules require that a text
+ run be divided into syllables before the operations can be
+ applied. Other complex scripts may apply shaping operations over
+ entire words or over the entire text run, with no subdivision
+ required.
+ </para>
+ <para>
+ Non-complex scripts, by definition, do not require these
+ operations. However, correctly shaping a text run in a
+ non-complex script may still involve Unicode normalization,
+ ligature substitutions, mark positioning, kerning, and applying
+ other font features. The key difference is that a text run in a
+ non-complex script can be processed sequentially and in the same
+ order as the input sequence of Unicode codepoints, without
+ requiring an analysis stage.
+ </para>
+ </section>
+
+ <section id="shaping-operations">
+ <title>Shaping operations</title>
+ <para>
+ Shaping a complex-script text run involves transforming the
+ input sequence of Unicode codepoints with some combination of
+ operations that is specified in the shaping model for the
+ script.
+ </para>
+ <para>
+ The specific conditions that trigger a given operation for a
+ text run varies from script to script, as do the order that the
+ operations are performed in and which codepoints are
+ affected. However, the same general set of shaping operations is
+ common to all of the complex-script shaping models.
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ A <emphasis>reordering</emphasis> operation moves a glyph
+ from its original ("logical") position in the sequence to
+ some other ("visual") position.
+ </para>
+ <para>
+ The shaping model for a given complex script might involve
+ more than one reordering step.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ A <emphasis>joining</emphasis> operation replaces a glyph
+ with an alternate form that is designed to connect with one
+ or more of the adjacent glyphs in the sequence.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ A contextual <emphasis>substitution</emphasis> operation
+ replaces either a single glyph or a subsequence of several
+ glyphs with an alternate glyph. This substitution is
+ performed when the original glyph or subsequence of glyphs
+ occurs in a specified position with respect to the
+ surrounding sequence. For example, one substitution might be
+ performed only when the target glyph is the first glyph in
+ the sequence, while another substitution is performed only
+ when a different target glyph occurs immediately after a
+ particular string pattern.
+ </para>
+ <para>
+ The shaping model for a given complex script might involve
+ multiple contextual-substitution operations, each applying
+ to different target glyphs and patterns, and which are
+ performed in separate steps.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ A contextual <emphasis>positioning</emphasis> operation
+ moves the horizontal and/or vertical position of a
+ glyph. This positioning move is performed when the glyph
+ occurs in a specified position with respect to the
+ surrounding sequence.
+ </para>
+ <para>
+ Many contextual positioning operations are used to place
+ <emphasis>mark</emphasis> glyphs (such as diacritics, vowel
+ signs, and tone markers) with respect to
+ <emphasis>base</emphasis> glyphs. However, some complex
+ scripts may use contextual positioning operations to
+ correctly place base glyphs as well, such as
+ when the script uses <emphasis>stacking</emphasis> characters.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+ </section>
+
+ <section id="unicode-character-categories">
+ <title>Unicode character categories</title>
+ <para>
+ Shaping models are typically specified with respect to how
+ scripts are defined in the Unicode standard.
+ </para>
+ <para>
+ Every codepoint in the Unicode Character Database (UCD) is
+ assigned a <emphasis>Unicode General Category</emphasis> (UGC),
+ which provides the most fundamental information about the
+ codepoint: whether the codepoint represents a
+ <emphasis>Letter</emphasis>, a <emphasis>Mark</emphasis>, a
+ <emphasis>Number</emphasis>, <emphasis>Punctuation</emphasis>, a
+ <emphasis>Symbol</emphasis>, a <emphasis>Separator</emphasis>,
+ or something else (<emphasis>Other</emphasis>).
+ </para>
+ <para>
+ These UGC properties are "Major" categories. Each codepoint is
+ further assigned to a "minor" category within its Major
+ category, such as "Letter, uppercase" (<literal>Lu</literal>) or
+ "Letter, modifier" (<literal>Lm</literal>).
+ </para>
+ <para>
+ Shaping models are concerned primarily with Letter and Mark
+ codepoints. The minor categories of Mark codepoints are
+ particularly important for shaping. Marks can be nonspacing
+ (<literal>Mn</literal>), spacing combining
+ (<literal>Mc</literal>), or enclosing (<literal>Me</literal>).
+ </para>
+ <para>
+ In addition to the UGC property, codepoints in the Indic and
+ Southeast Asian scripts are also assigned
+ <emphasis>Unicode Indic Syllabic Category</emphasis> (UISC) and
+ <emphasis>Unicode Indic Positional Category</emphasis> (UIPC)
+ property that provides more detailed information needed for
+ shaping.
+ </para>
+ <para>
+ The UISC property sub-categorizes Letters and Marks according to
+ common script-shaping behaviors. For example, UISC distinguishes
+ between consonant letters, vowel letters, and vowel marks. The
+ UIPC property sub-categorizes Mark codepoints by the visual
+ position that they occupy (above, below, right, left, or in
+ multiple positions).
+ </para>
+ <para>
+ Some complex scripts require that the text run be split into
+ syllables, and what constitutes a valid syllable in these
+ scripts is specified in regular expressions of the Letter and
+ Mark codepoints that take the UISC and UIPC properties into account.
+ </para>
+
+ </section>
+
+ <section id="text-runs">
+ <title>Text runs</title>
+ <para>
+ Real-world text usually contains codepoints from a mixture of
+ different Unicode scripts (including punctuation, numbers, symbols,
+ white-space characters, and other codepoints that do not belong
+ to any script). Real-world text may also be marked up with
+ formatting that changes font properties (including the font,
+ font style, and font size).
+ </para>
+ <para>
+ For shaping purposes, all real-world text streams must be first
+ segmented into runs that have a uniform set of properties.
+ </para>
+ <para>
+ In particular, shaping models always assume that every codepoint
+ in a text run has the same <emphasis>direction</emphasis>,
+ <emphasis>script</emphasis> tag, and
+ <emphasis>language</emphasis> tag.
+ </para>
+ </section>
+
+ <section id="opentype-shaping-models">
+ <title>OpenType shaping models</title>
+ <para>
+ OpenType provides shaping models for the following scripts:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ The <emphasis>default</emphasis> shaping model handles all
+ non-complex scripts, and may also be used as a fallback for
+ handling unrecognized scripts.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Indic</emphasis> shaping model handles the Indic
+ scripts Bengali, Devanagari, Gujarati, Gurmukhi, Kannada,
+ Malayalam, Oriya, Tamil, Telugu, and Sinhala.
+ </para>
+ <para>
+ The Indic shaping model was revised significantly in
+ 2005. To denote the change, a new set of <emphasis>script
+ tags</emphasis> was assigned for Bengali, Devanagari,
+ Gujarati, Gurmukhi, Kannada, Malayalam, Oriya, Tamil, and
+ Telugu. For the sake of clarity, the term "Indic2" is
+ sometimes used to refer to the current, revised shaping
+ model.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Arabic</emphasis> shaping model supports
+ Arabic, Mongolian, N'Ko, Syriac, and several other connected
+ or cursive scripts.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Thai/Lao</emphasis> shaping model supports
+ the Thai and Lao scripts.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Khmer</emphasis> shaping model supports the
+ Khmer script.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Myanmar</emphasis> shaping model supports the
+ Myanmar (or Burmese) script.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Tibetan</emphasis> shaping model supports the
+ Tibetan script.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Hangul</emphasis> shaping model supports the
+ Hangul script.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Hebrew</emphasis> shaping model supports the
+ Hebrew script.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ The <emphasis>Universal Shaping Engine</emphasis> (USE)
+ shaping model supports complex scripts not covered by one of
+ the above, script-specific shaping models, including
+ Javanese, Balinese, Buginese, Batak, Chakma, Lepcha, Modi,
+ Phags-pa, Tagalog, Siddham, Sundanese, Tai Le, Tai Tham, Tai
+ Viet, and many others.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Text runs that do not fall under one of the above shaping
+ models may still require processing by a shaping engine. Of
+ particular note is <emphasis>Emoji</emphasis> shaping, which
+ may involve variation-selector sequences and glyph
+ substitution. Emoji shaping is handled by the default
+ shaping model.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
+ <section id="graphite-shaping">
+ <title>Graphite shaping</title>
+ <para>
+ In contrast to OpenType shaping, Graphite shaping does not
+ specify a predefined set of shaping models or a set of supported
+ scripts.
+ </para>
+ <para>
+ Instead, each Graphite font contains a complete set of rules that
+ implement the required shaping model for the intended
+ script. These rules include finite-state machines to match
+ sequences of codepoints to the shaping operations to perform.
+ </para>
+ <para>
+ Graphite shaping can perform the same shaping operations used in
+ OpenType shaping, as well as other functions that have not been
+ defined for OpenType shaping.
+ </para>
+ </section>
+
+ <section id="aat-shaping">
+ <title>AAT shaping</title>
+ <para>
+ In contrast to OpenType shaping, AAT shaping does not specify a
+ predefined set of shaping models or a set of supported scripts.
+ </para>
+ <para>
+ Instead, each AAT font includes a complete set of rules that
+ implement the desired shaping model for the intended
+ script. These rules include finite-state machines to match glyph
+ sequences and the shaping operations to perform.
+ </para>
+ <para>
+ Notably, AAT shaping rules are expressed for glyphs in the font,
+ not for Unicode codepoints. AAT shaping can perform the same
+ shaping operations used in OpenType shaping, as well as other
+ functions that have not been defined for OpenType shaping.
+ </para>
+ </section>
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml
index 38f40cf119c..8532d7cc2b6 100644
--- a/chromium/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml
+++ b/chromium/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml
@@ -1,115 +1,441 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
+]>
<chapter id="what-is-harfbuzz">
<title>What is HarfBuzz?</title>
<para>
- HarfBuzz is a <emphasis>text shaping engine</emphasis>. It solves
- the problem of selecting and positioning glyphs from a font given a
- Unicode string.
+ HarfBuzz is a <emphasis>text-shaping engine</emphasis>. If you
+ give HarfBuzz a font and a string containing a sequence of Unicode
+ codepoints, HarfBuzz selects and positions the corresponding
+ glyphs from the font, applying all of the necessary layout rules
+ and font features. HarfBuzz then returns the string to you in the
+ form that is correctly arranged for the language and writing
+ system.
</para>
- <section id="why-do-i-need-it">
- <title>Why do I need it?</title>
+ <para>
+ HarfBuzz can properly shape all of the world's major writing
+ systems. It runs on all major operating systems and software
+ platforms and it supports the modern font formats in use
+ today.
+ </para>
+ <section id="what-is-text-shaping">
+ <title>What is text shaping?</title>
+ <para>
+ Text shaping is the process of translating a string of character
+ codes (such as Unicode codepoints) into a properly arranged
+ sequence of glyphs that can be rendered onto a screen or into
+ final output form for inclusion in a document.
+ </para>
+ <para>
+ The shaping process is dependent on the input string, the active
+ font, the script (or writing system) that the string is in, and
+ the language that the string is in.
+ </para>
+ <para>
+ Modern software systems generally only deal with strings in the
+ Unicode encoding scheme (although legacy systems and documents may
+ involve other encodings).
+ </para>
+ <para>
+ There are several font formats that a program might
+ encounter, each of which has a set of standard text-shaping
+ rules.
+ </para>
+ <para>The dominant format is <ulink
+ url="http://www.microsoft.com/typography/otspec/">OpenType</ulink>. The
+ OpenType specification defines a series of <ulink url="https://github.com/n8willis/opentype-shaping-documents">shaping models</ulink> for
+ various scripts from around the world. These shaping models depend on
+ the font including certain features in its <literal>GSUB</literal>
+ and <literal>GPOS</literal> tables.
+ </para>
<para>
- Text shaping is an integral part of preparing text for display. It
- is a fairly low level operation; HarfBuzz is used directly by
- graphic rendering libraries such as Pango, and the layout engines
- in Firefox, LibreOffice and Chromium. Unless you are
- <emphasis>writing</emphasis> one of these layout engines yourself,
- you will probably not need to use HarfBuzz - normally higher level
- libraries will turn text into glyphs for you.
+ Alternatively, OpenType fonts can include shaping features for
+ the <ulink url="https://graphite.sil.org/">Graphite</ulink> shaping model.
+ </para>
+ <para>
+ TrueType fonts can also include OpenType shaping
+ features. Alternatively, TrueType fonts can also include <ulink url="https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html">Apple
+ Advanced Typography</ulink> (AAT) tables to implement shaping
+ support. AAT fonts are generally only found on macOS and iOS systems.
+ </para>
+ <para>
+ Text strings will usually be tagged with a script and language
+ tag that provide the context needed to perform text shaping
+ correctly. The necessary <ulink
+ url="https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags">Script</ulink>
+ and <ulink
+ url="https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags">language</ulink>
+ tags are defined by OpenType.
+ </para>
+ </section>
+
+ <section id="why-do-i-need-a-shaping-engine">
+ <title>Why do I need a shaping engine?</title>
+ <para>
+ Text shaping is an integral part of preparing text for
+ display. Before a Unicode sequence can be rendered, the
+ codepoints in the sequence must be mapped to the corresponding
+ glyphs provided in the font, and those glyphs must be positioned
+ correctly relative to each other. For many of the scripts
+ supported in Unicode, these steps involve script-specific layout
+ rules, including complex joining, reordering, and positioning
+ behavior. Implementing these rules is the job of the shaping engine.
+ </para>
+ <para>
+ Text shaping is a fairly low-level operation. HarfBuzz is
+ used directly by text-handling libraries like <ulink
+ url="https://www.pango.org/">Pango</ulink>, as well as by the layout
+ engines in Firefox, LibreOffice, and Chromium. Unless you are
+ <emphasis>writing</emphasis> one of these layout engines
+ yourself, you will probably not need to use HarfBuzz: normally,
+ a layout engine, toolkit, or other library will turn text into
+ glyphs for you.
</para>
<para>
However, if you <emphasis>are</emphasis> writing a layout engine
- or graphics library yourself, you will need to perform text
- shaping, and this is where HarfBuzz can help you. Here are some
- reasons why you need it:
+ or graphics library yourself, then you will need to perform text
+ shaping, and this is where HarfBuzz can help you.
+ </para>
+ <para>
+ Here are some specific scenarios where a text-shaping engine
+ like HarfBuzz helps you:
</para>
<itemizedlist>
<listitem>
<para>
- OpenType fonts contain a set of glyphs, indexed by glyph ID.
- The glyph ID within the font does not necessarily relate to a
- Unicode codepoint. For instance, some fonts have the letter
- &quot;a&quot; as glyph ID 1. To pull the right glyph out of
- the font in order to display it, you need to consult a table
- within the font (the &quot;cmap&quot; table) which maps
- Unicode codepoints to glyph IDs. Text shaping turns codepoints
- into glyph IDs.
+ OpenType fonts contain a set of glyphs (that is, shapes
+ to represent the letters, numbers, punctuation marks, and
+ all other symbols), which are indexed by a <literal>glyph ID</literal>.
+ </para>
+ <para>
+ A particular glyph ID within the font does not necessarily
+ correlate to a predictable Unicode codepoint. For instance,
+ some fonts have the letter &quot;a&quot; as glyph ID 1, but
+ many others do not. In order to retrieve the right glyph
+ from the font to display &quot;a&quot;, you need to consult
+ the table inside the font (the <literal>cmap</literal>
+ table) that maps Unicode codepoints to glyph IDs. In other
+ words, <emphasis>text shaping turns codepoints into glyph
+ IDs</emphasis>.
</para>
</listitem>
<listitem>
<para>
Many OpenType fonts contain ligatures: combinations of
- characters which are rendered together. For instance, it's
- common for the <literal>fi</literal> combination to appear in
- print as the single ligature &quot;fi&quot;. Whether you should
- render text as <literal>fi</literal> or &quot;fi&quot; does not
- depend on the input text, but on the capabilities of the font
- and the level of ligature application you wish to perform.
- Text shaping involves querying the font's ligature tables and
- determining what substitutions should be made.
+ characters that are rendered as a single unit. For instance,
+ it is common for the <literal>fi</literal> letter
+ combination to appear in print as the single ligature glyph
+ &quot;fi&quot;.
+ </para>
+ <para>
+ Whether you should render an &quot;f, i&quot; sequence
+ as <literal>fi</literal> or as &quot;fi&quot; does not
+ depend on the input text. Instead, it depends on the whether
+ or not the font includes an &quot;fi&quot; glyph and on the
+ level of ligature application you wish to perform. The font
+ and the amount of ligature application used are under your
+ control. In other words, <emphasis>text shaping involves
+ querying the font's ligature tables and determining what
+ substitutions should be made</emphasis>.
</para>
</listitem>
<listitem>
<para>
- While ligatures like &quot;fi&quot; are typographic
- refinements, some languages <emphasis>require</emphasis> such
+ While ligatures like &quot;fi&quot; are optional typographic
+ refinements, some languages <emphasis>require</emphasis> certain
substitutions to be made in order to display text correctly.
- In Tamil, when the letter &quot;TTA&quot; (ட) letter is
- followed by &quot;U&quot; (உ), the combination should appear
- as the single glyph &quot;டு&quot;. The sequence of Unicode
- characters &quot;டஉ&quot; needs to be rendered as a single
- glyph from the font - text shaping chooses the correct glyph
- from the sequence of characters provided.
+ </para>
+ <para>
+ For example, in Tamil, when the letter &quot;TTA&quot; (ட)
+ letter is followed by &quot;U&quot; (உ), the pair
+ must be replaced by the single glyph &quot;டு&quot;. The
+ sequence of Unicode characters &quot;டஉ&quot; needs to be
+ substituted with a single &quot;டு&quot; glyph from the
+ font.
+ </para>
+ <para>
+ But &quot;டு&quot; does not have a Unicode codepoint. To
+ find this glyph, you need to consult the table inside
+ the font (the <literal>GSUB</literal> table) that contains
+ substitution information. In other words, <emphasis>text shaping
+ chooses the correct glyph for a sequence of characters
+ provided</emphasis>.
</para>
</listitem>
<listitem>
<para>
- Similarly, each Arabic character has four different variants:
- within a font, there will be glyphs for the initial, medial,
- final, and isolated forms of each letter. Unicode only encodes
- one codepoint per character, and so a Unicode string will not
- tell you which glyph to use. Text shaping chooses the correct
- form of the letter and returns the correct glyph from the font
- that you need to render.
+ Similarly, each Arabic character has four different variants
+ corresponding to the different positions it might appear in
+ within a sequence. Inside a font, there will be separate
+ glyphs for the initial, medial, final, and isolated forms of
+ each letter, each at a different glyph ID.
+ </para>
+ <para>
+ Unicode only assigns one codepoint per character, so a
+ Unicode string will not tell you which glyph variant to use
+ for each character. To decide, you need to analyze the whole
+ string and determine the appropriate glyph for each character
+ based on its position. In other words, <emphasis>text
+ shaping chooses the correct form of the letter by its
+ position and returns the correct glyph from the font</emphasis>.
</para>
</listitem>
<listitem>
<para>
- Other languages have marks and accents which need to be
- rendered in certain positions around a base character. For
- instance, the Moldovan language has the Cyrillic letter
- &quot;zhe&quot; (ж) with a breve accent, like so: ӂ. Some
- fonts will contain this character as an individual glyph,
- whereas other fonts will not contain a zhe-with-breve glyph
- but expect the rendering engine to form the character by
- overlaying the two glyphs ж and ˘. Where you should draw the
- combining breve depends on the height of the preceding glyph.
- Again, for Arabic, the correct positioning of vowel marks
- depends on the height of the character on which you are
- placing the mark. Text shaping tells you whether you have a
- precomposed glyph within your font or if you need to compose a
- glyph yourself out of combining marks, and if so, where to
- position those marks.
+ Other languages involve marks and accents that need to be
+ rendered in specific positions relative a base character. For
+ instance, the Moldovan language includes the Cyrillic letter
+ &quot;zhe&quot; (ж) with a breve accent, like so: &quot;ӂ&quot;.
+ </para>
+ <para>
+ Some fonts will provide this character as a single
+ zhe-with-breve glyph, but other fonts will not and, instead,
+ will expect the rendering engine to form the character by
+ superimposing the separate &quot;ж&quot; and &quot;˘&quot;
+ glyphs.
+ </para>
+ <para>
+ But exactly where you should draw the breve depends on the
+ height and width of the preceding zhe glyph. To find the
+ right position, you need to consult the table inside
+ the font (the <literal>GPOS</literal> table) that contains
+ positioning information.
+ In other words, <emphasis>text shaping tells you whether you
+ have a precomposed glyph within your font or if you need to
+ compose a glyph yourself out of combining marks&mdash;and,
+ if so, where to position those marks.</emphasis>
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ If tasks like these are something that you need to do, then you
+ need a text shaping engine. You could use Uniscribe if you are
+ writing Windows software; you could use CoreText on macOS; or
+ you could use HarfBuzz.
+ </para>
+ <note>
+ <para>
+ In the rest of this manual, the text will assume that the reader
+ is that implementor of a text-layout engine.
+ </para>
+ </note>
+ </section>
+
+
+ <section>
+ <title>What does HarfBuzz do?</title>
+ <para>
+ HarfBuzz provides text shaping through a cross-platform
+ C API that accepts sequences of Unicode codepoints as input. Currently,
+ the following OpenType shaping models are supported:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Indic (covering Devanagari, Bengali, Gujarati,
+ Gurmukhi, Kannada, Malayalam, Oriya, Tamil, Telugu, and
+ Sinhala)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Arabic (covering Arabic, N'Ko, Syriac, and Mongolian)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Thai and Lao
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Khmer
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Myanmar
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Tibetan
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Hangul
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ Hebrew
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The Universal Shaping Engine or <emphasis>USE</emphasis>
+ (covering complex scripts not covered by the above shaping
+ models)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ A default shaping model for non-complex scripts
+ (covering Latin, Cyrillic, Greek, Armenian, Georgian, Tifinagh,
+ and many others)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Emoji (including emoji modifier sequences, flag sequences,
+ and ZWJ sequences)
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ In addition to OpenType shaping, HarfBuzz supports the latest
+ version of Graphite shaping (the "Graphite 2" model) and AAT
+ shaping.
+ </para>
+
+ <para>
+ HarfBuzz can read and understand TrueType fonts (.ttf), TrueType
+ collections (.ttc), and OpenType fonts (.otf, including those
+ fonts that contain TrueType-style outlines and those that
+ contain PostScript CFF or CFF2 outlines).
+ </para>
+
+ <para>
+ HarfBuzz is designed and tested to run on top of the FreeType
+ font renderer. It can run on Linux, Android, Windows, macOS, and
+ iOS systems.
+ </para>
+
+ <para>
+ In addition to its core shaping functionality, HarfBuzz provides
+ functions for accessing other font features, including optional
+ GSUB and GPOS OpenType features, as well as
+ all color-font formats (<literal>CBDT</literal>,
+ <literal>sbix</literal>, <literal>COLR/CPAL</literal>, and
+ <literal>SVG-OT</literal>) and OpenType variable fonts. HarfBuzz
+ also includes a font-subsetting feature. HarfBuzz can perform
+ some low-level math-shaping operations, although it does not
+ currently perform full shaping for mathematical typesetting.
+ </para>
+
+ <para>
+ A suite of command-line utilities is also provided in the
+ source-code tree, designed to help users test and debug
+ HarfBuzz's features on real-world fonts and input.
+ </para>
+ </section>
+
+ <section id="what-harfbuzz-doesnt-do">
+ <title>What HarfBuzz doesn't do</title>
+ <para>
+ HarfBuzz will take a Unicode string, shape it, and give you the
+ information required to lay it out correctly on a single
+ horizontal (or vertical) line using the font provided. That is the
+ extent of HarfBuzz's responsibility.
+ </para>
+ <para>
+ It is important to note that if you are implementing a complete
+ text-layout engine you may have other responsibilities that
+ HarfBuzz will <emphasis>not</emphasis> help you with. For example:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ HarfBuzz won't help you with bidirectionality. If you want to
+ lay out text that includes a mix of Hebrew and English, you
+ will need to ensure that each buffer provided to HarfBuzz
+ has all of its characters in the same order and that the
+ directionality of the buffer is set correctly. This may mean
+ segmenting the text before it is placed into HarfBuzz buffers. In
+ other words, the user will hit the keys in the following
+ sequence:
+ </para>
+ <programlisting>
+ A B C [space] ג ב א [space] D E F
+ </programlisting>
+ <para>
+ but will expect to see in the output:
+ </para>
+ <programlisting>
+ ABC אבג DEF
+ </programlisting>
+ <para>
+ This reordering is called <emphasis>bidi processing</emphasis>
+ (&quot;bidi&quot; is short for bidirectional), and there's an
+ algorithm as an annex to the Unicode Standard which tells you how
+ to process a string of mixed directionality.
+ Before sending your string to HarfBuzz, you may need to apply the
+ bidi algorithm to it. Libraries such as <ulink
+ url="http://icu-project.org/">ICU</ulink> and <ulink
+ url="http://fribidi.org/">fribidi</ulink> can do this for you.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ HarfBuzz won't help you with text that contains different font
+ properties. For instance, if you have the string &quot;a
+ <emphasis>huge</emphasis> breakfast&quot;, and you expect
+ &quot;huge&quot; to be italic, then you will need to send three
+ strings to HarfBuzz: <literal>a</literal>, in your Roman font;
+ <literal>huge</literal> using your italic font; and
+ <literal>breakfast</literal> using your Roman font again.
+ </para>
+ <para>
+ Similarly, if you change the font, font size, script,
+ language, or direction within your string, then you will
+ need to shape each run independently and output them
+ independently. HarfBuzz expects to shape a run of characters
+ that all share the same properties.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ HarfBuzz won't help you with line breaking, hyphenation, or
+ justification. As mentioned above, HarfBuzz lays out the string
+ along a <emphasis>single line</emphasis> of, notionally,
+ infinite length. If you want to find out where the potential
+ word, sentence and line break points are in your text, you
+ could use the ICU library's break iterator functions.
+ </para>
+ <para>
+ HarfBuzz can tell you how wide a shaped piece of text is, which is
+ useful input to a justification algorithm, but it knows nothing
+ about paragraphs, lines or line lengths. Nor will it adjust the
+ space between words to fit them proportionally into a line.
</para>
</listitem>
</itemizedlist>
<para>
- If this is something that you need to do, then you need a text
- shaping engine: you could use Uniscribe if you are using Windows;
- you could use CoreText on OS X; or you could use HarfBuzz. In the
- rest of this manual, we are going to assume that you are the
- implementor of a text layout engine.
+ As a layout-engine implementor, HarfBuzz will help you with the
+ interface between your text and your font, and that's something
+ that you'll need&mdash;what you then do with the glyphs that your font
+ returns is up to you.
</para>
</section>
+
<section id="why-is-it-called-harfbuzz">
<title>Why is it called HarfBuzz?</title>
<para>
- HarfBuzz began its life as text shaping code within the FreeType
- project, (and you will see references to the FreeType authors
- within the source code copyright declarations) but was then
- abstracted out to its own project. This project is maintained by
- Behdad Esfahbod, and named HarfBuzz. Originally, it was a shaping
- engine for OpenType fonts - &quot;HarfBuzz&quot; is the Persian
- for &quot;open type&quot;.
+ HarfBuzz began its life as text-shaping code within the FreeType
+ project (and you will see references to the FreeType authors
+ within the source code copyright declarations), but was then
+ extracted out to its own project. This project is maintained by
+ Behdad Esfahbod, who named it HarfBuzz. Originally, it was a
+ shaping engine for OpenType fonts&mdash;&quot;HarfBuzz&quot; is
+ the Persian for &quot;open type&quot;.
</para>
</section>
-</chapter> \ No newline at end of file
+</chapter>
diff --git a/chromium/third_party/harfbuzz-ng/src/src/HBIndicVowelConstraints.txt b/chromium/third_party/harfbuzz-ng/src/src/HBIndicVowelConstraints.txt
new file mode 100644
index 00000000000..146ae1cb80c
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/HBIndicVowelConstraints.txt
@@ -0,0 +1,97 @@
+# Copied from https://docs.microsoft.com/en-us/typography/script-development/use
+# On October 23, 2018; with documentd dated 02/07/2018.
+
+ 0905 0946 ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN SHORT E
+ 0905 093E ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN AA
+ 0930 094D 0907 ; # DEVANAGARI LETTER RA, DEVANAGARI SIGN VIRAMA, DEVANAGARI LETTER I
+ 0909 0941 ; # DEVANAGARI LETTER U, DEVANAGARI VOWEL SIGN U
+ 090F 0945 ; # DEVANAGARI LETTER E, DEVANAGARI VOWEL SIGN CANDRA E
+ 090F 0946 ; # DEVANAGARI LETTER E, DEVANAGARI VOWEL SIGN SHORT E
+ 090F 0947 ; # DEVANAGARI LETTER E, DEVANAGARI VOWEL SIGN E
+ 0905 0949 ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN CANDRA O
+ 0906 0945 ; # DEVANAGARI LETTER AA, DEVANAGARI VOWEL SIGN CANDRA E
+ 0905 094A ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN SHORT O
+ 0906 0946 ; # DEVANAGARI LETTER AA, DEVANAGARI VOWEL SIGN SHORT E
+ 0905 094B ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN O
+ 0906 0947 ; # DEVANAGARI LETTER AA, DEVANAGARI VOWEL SIGN E
+ 0905 094C ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN AU
+ 0906 0948 ; # DEVANAGARI LETTER AA, DEVANAGARI VOWEL SIGN AI
+ 0905 0945 ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN CANDRA E
+ 0905 093A ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN OE
+ 0905 093B ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN OOE
+ 0906 093A ; # DEVANAGARI LETTER AA, DEVANAGARI VOWEL SIGN OE
+ 0905 094F ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN AW
+ 0905 0956 ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN UE
+ 0905 0957 ; # DEVANAGARI LETTER A, DEVANAGARI VOWEL SIGN UUE
+ 0985 09BE ; # BENGALI LETTER A, BENGALI VOWEL SIGN AA
+ 098B 09C3 ; # BENGALI LETTER VOCALIC R, BENGALI VOWEL SIGN VOCALIC R
+ 098C 09E2 ; # BENGALI LETTER VOCALIC L, BENGALI VOWEL SIGN VOCALIC L
+ 0A05 0A3E ; # GURMUKHI LETTER A, GURMUKHI VOWEL SIGN AA
+ 0A72 0A3F ; # GURMUKHI IRI, GURMUKHI VOWEL SIGN I
+ 0A72 0A40 ; # GURMUKHI IRI, GURMUKHI VOWEL SIGN II
+ 0A73 0A41 ; # GURMUKHI URA, GURMUKHI VOWEL SIGN U
+ 0A73 0A42 ; # GURMUKHI URA, GURMUKHI VOWEL SIGN UU
+ 0A72 0A47 ; # GURMUKHI IRI, GURMUKHI VOWEL SIGN EE
+ 0A05 0A48 ; # GURMUKHI LETTER A, GURMUKHI VOWEL SIGN AI
+ 0A73 0A4B ; # GURMUKHI URA, GURMUKHI VOWEL SIGN OO
+ 0A05 0A4C ; # GURMUKHI LETTER A, GURMUKHI VOWEL SIGN AU
+ 0A85 0ABE ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN AA
+ 0A85 0AC5 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN CANDRA E
+ 0A85 0AC7 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN E
+ 0A85 0AC8 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN AI
+ 0A85 0AC9 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN CANDRA O
+ 0A85 0ACB ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN O
+ 0A85 0ABE 0AC5 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN AA, GUJARATI VOWEL SIGN CANDRA E
+ 0A85 0ACC ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN AU
+ 0A85 0ABE 0AC8 ; # GUJARATI LETTER A, GUJARATI VOWEL SIGN AA, GUJARATI VOWEL SIGN AI
+ 0AC5 0ABE ; # GUJARATI VOWEL SIGN CANDRA E, GUJARATI VOWEL SIGN AA
+ 0B05 0B3E ; # ORIYA LETTER A, ORIYA VOWEL SIGN AA
+ 0B0F 0B57 ; # ORIYA LETTER E, ORIYA AU LENGTH MARK
+ 0B13 0B57 ; # ORIYA LETTER O, ORIYA AU LENGTH MARK
+ 0C12 0C55 ; # TELUGU LETTER O, TELUGU LENGTH MARK
+ 0C12 0C4C ; # TELUGU LETTER O, TELUGU VOWEL SIGN AU
+ 0C3F 0C55 ; # TELUGU VOWEL SIGN I, TELUGU LENGTH MARK
+ 0C46 0C55 ; # TELUGU VOWEL SIGN E, TELUGU LENGTH MARK
+ 0C4A 0C55 ; # TELUGU VOWEL SIGN O, TELUGU LENGTH MARK
+ 0C89 0CBE ; # KANNADA LETTER U, KANNADA VOWEL SIGN AA
+ 0C92 0CCC ; # KANNADA LETTER O, KANNADA VOWEL SIGN AU
+ 0C8B 0CBE ; # KANNADA LETTER VOCALIC R, KANNADA VOWEL SIGN AA
+ 0D07 0D57 ; # MALAYALAM LETTER I, MALAYALAM AU LENGTH MARK
+ 0D09 0D57 ; # MALAYALAM LETTER U, MALAYALAM AU LENGTH MARK
+ 0D0E 0D46 ; # MALAYALAM LETTER E, MALAYALAM VOWEL SIGN E
+ 0D12 0D3E ; # MALAYALAM LETTER O, MALAYALAM VOWEL SIGN AA
+ 0D12 0D57 ; # MALAYALAM LETTER O, MALAYALAM AU LENGTH MARK
+ 0D85 0DCF ; # SINHALA LETTER AYANNA, SINHALA VOWEL SIGN AELA-PILLA
+ 0D85 0DD0 ; # SINHALA LETTER AYANNA, SINHALA VOWEL SIGN KETTI AEDA-PILLA
+ 0D85 0DD1 ; # SINHALA LETTER AYANNA, SINHALA VOWEL SIGN DIGA AEDA-PILLA
+ 0D8B 0DDF ; # SINHALA LETTER UYANNA, SINHALA VOWEL SIGN GAYANUKITTA
+ 0D8D 0DD8 ; # SINHALA LETTER IRUYANNA, SINHALA VOWEL SIGN GAETTA-PILLA
+ 0D8F 0DDF ; # SINHALA LETTER ILUYANNA, SINHALA VOWEL SIGN GAYANUKITTA
+ 0D91 0DCA ; # SINHALA LETTER EYANNA, SINHALA SIGN AL-LAKUNA
+ 0D91 0DD9 ; # SINHALA LETTER EYANNA, SINHALA VOWEL SIGN KOMBUVA
+ 0D91 0DDA ; # SINHALA LETTER EYANNA, SINHALA VOWEL SIGN DIGA KOMBUVA
+ 0D91 0DDC ; # SINHALA LETTER EYANNA, SINHALA VOWEL SIGN KOMBUVA HAA AELA-PILLA
+ 0D91 0DDD ; # SINHALA LETTER EYANNA, SINHALA VOWEL SIGN KOMBUVA HAA DIGA AELA-PILLA
+ 0D91 0DDD ; # SINHALA LETTER EYANNA, SINHALA VOWEL SIGN KOMBUVA HAA DIGA AELA-PILLA
+ 0D94 0DDF ; # SINHALA LETTER OYANNA, SINHALA VOWEL SIGN GAYANUKITTA
+ 11005 11038 ; # BRAHMI LETTER A, BRAHMI VOWEL SIGN AA
+ 1100B 1103E ; # BRAHMI LETTER VOCALIC R, BRAHMI VOWEL SIGN VOCALIC R
+ 1100F 11042 ; # BRAHMI LETTER E, BRAHMI VOWEL SIGN E
+ 11680 116AD ; # TAKRI LETTER A, TAKRI VOWEL SIGN AA
+ 11686 116B2 ; # TAKRI LETTER E, TAKRI VOWEL SIGN E
+ 11680 116B4 ; # TAKRI LETTER A, TAKRI VOWEL SIGN O
+ 11680 116B5 ; # TAKRI LETTER A, TAKRI VOWEL SIGN AU
+ 112B0 112E0 ; # KHUDAWADI LETTER A, KHUDAWADI VOWEL SIGN AA
+ 112B0 112E5 ; # KHUDAWADI LETTER A, KHUDAWADI VOWEL SIGN E
+ 112B0 112E6 ; # KHUDAWADI LETTER A, KHUDAWADI VOWEL SIGN AI
+ 112B0 112E7 ; # KHUDAWADI LETTER A, KHUDAWADI VOWEL SIGN O
+ 112B0 112E8 ; # KHUDAWADI LETTER A, KHUDAWADI VOWEL SIGN AU
+ 11481 114B0 ; # TIRHUTA LETTER A, TIRHUTA VOWEL SIGN AA
+ 114AA 114B5 ; # TIRHUTA LETTER LA, TIRHUTA VOWEL SIGN VOCALIC R
+ 114AA 114B6 ; # TIRHUTA LETTER LA, TIRHUTA VOWEL SIGN VOCALIC RR
+ 1148B 114BA ; # TIRHUTA LETTER E, TIRHUTA VOWEL SIGN SHORT E
+ 1148D 114BA ; # TIRHUTA LETTER O, TIRHUTA VOWEL SIGN SHORT E
+ 11600 11639 ; # MODI LETTER A, MODI VOWEL SIGN E
+ 11600 1163A ; # MODI LETTER A, MODI VOWEL SIGN AI
+ 11601 11639 ; # MODI LETTER AA, MODI VOWEL SIGN E
+ 11601 1163A ; # MODI LETTER AA, MODI VOWEL SIGN AI
diff --git a/chromium/third_party/harfbuzz-ng/src/src/Makefile.am b/chromium/third_party/harfbuzz-ng/src/src/Makefile.am
index 73631992c50..c726cf2a660 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/Makefile.am
+++ b/chromium/third_party/harfbuzz-ng/src/src/Makefile.am
@@ -13,9 +13,8 @@ TESTS =
check_PROGRAMS =
# Convenience targets:
-lib: $(BUILT_SOURCES) libharfbuzz.la libharfbuzz-subset.la
+lib: $(BUILT_SOURCES) libharfbuzz.la
libs: $(BUILT_SOURCES) $(lib_LTLIBRARIES)
-fuzzing: $(BUILT_SOURCES) libharfbuzz-fuzzing.la libharfbuzz-subset-fuzzing.la
lib_LTLIBRARIES = libharfbuzz.la
@@ -29,11 +28,9 @@ HBSOURCES = $(HB_BASE_sources)
HBSOURCES += $(HB_BASE_RAGEL_GENERATED_sources)
HBHEADERS = $(HB_BASE_headers)
-if HAVE_OT
HBSOURCES += $(HB_OT_sources)
HBSOURCES += $(HB_OT_RAGEL_GENERATED_sources)
HBHEADERS += $(HB_OT_headers)
-endif
if HAVE_FALLBACK
HBSOURCES += $(HB_FALLBACK_sources)
@@ -171,37 +168,6 @@ pkginclude_HEADERS += $(HB_SUBSET_headers)
pkgconfig_DATA += harfbuzz-subset.pc
EXTRA_DIST += harfbuzz-subset.pc.in
-FUZZING_CPPFLAGS = \
- -DHB_NDEBUG \
- -DHB_MAX_NESTING_LEVEL=3 \
- -DHB_SANITIZE_MAX_EDITS=3 \
- -DHB_SANITIZE_MAX_OPS_FACTOR=3 \
- -DHB_SANITIZE_MAX_OPS_MIN=128 \
- -DHB_BUFFER_MAX_LEN_FACTOR=3 \
- -DHB_BUFFER_MAX_LEN_MIN=8 \
- -DHB_BUFFER_MAX_LEN_DEFAULT=128 \
- -DHB_BUFFER_MAX_OPS_FACTOR=8 \
- -DHB_BUFFER_MAX_OPS_MIN=64 \
- -DHB_BUFFER_MAX_OPS_DEFAULT=1024 \
- $(NULL)
-EXTRA_LTLIBRARIES = libharfbuzz-fuzzing.la libharfbuzz-subset-fuzzing.la
-
-libharfbuzz_fuzzing_la_LINK = $(chosen_linker) $(libharfbuzz_fuzzing_la_LDFLAGS)
-libharfbuzz_fuzzing_la_SOURCES = $(libharfbuzz_la_SOURCES)
-libharfbuzz_fuzzing_la_CPPFLAGS = $(HBCFLAGS) $(FUZZING_CPPFLAGS)
-libharfbuzz_fuzzing_la_LDFLAGS = $(AM_LDFLAGS)
-libharfbuzz_fuzzing_la_LIBADD = $(libharfbuzz_la_LIBADD)
-EXTRA_libharfbuzz_fuzzing_la_DEPENDENCIES = $(EXTRA_libharfbuzz_la_DEPENDENCIES)
-CLEANFILES += libharfbuzz-fuzzing.la
-
-libharfbuzz_subset_fuzzing_la_LINK = $(chosen_linker) $(libharfbuzz_subset_fuzzing_la_LDFLAGS)
-libharfbuzz_subset_fuzzing_la_SOURCES = $(libharfbuzz_subset_la_SOURCES)
-libharfbuzz_subset_fuzzing_la_CPPFLAGS = $(HBCFLAGS) $(FUZZING_CPPFLAGS)
-libharfbuzz_subset_fuzzing_la_LDFLAGS = $(AM_LDFLAGS)
-libharfbuzz_subset_fuzzing_la_LIBADD = $(libharfbuzz_subset_la_LIBADD)
-EXTRA_libharfbuzz_subset_fuzzing_la_DEPENDENCIES = $(EXTRA_libharfbuzz_subset_la_DEPENDENCIES)
-CLEANFILES += libharfbuzz-subset-fuzzing.la
-
if HAVE_ICU
if HAVE_ICU_BUILTIN
HBCFLAGS += $(ICU_CFLAGS)
@@ -271,7 +237,7 @@ EXTRA_DIST += \
CLEANFILES += $(pkgconfig_DATA)
-DEF_FILES = harfbuzz.def harfbuzz-subset.def harfbuzz-icu.def
+DEF_FILES = harfbuzz.def harfbuzz-subset.def harfbuzz-icu.def harfbuzz-deprecated-symbols.txt
if HAVE_GOBJECT
DEF_FILES += harfbuzz-gobject.def
endif
@@ -285,6 +251,8 @@ harfbuzz-icu.def: $(HB_ICU_headers)
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
harfbuzz-gobject.def: $(HB_GOBJECT_headers)
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
+harfbuzz-deprecated-symbols.txt: $(srcdir)/hb-deprecated.h
+ $(AM_V_GEN) PLAIN_LIST=1 $(srcdir)/gen-def.py "$@" $^
GENERATORS = \
@@ -293,11 +261,13 @@ GENERATORS = \
gen-emoji-table.py \
gen-indic-table.py \
gen-os2-unicode-ranges.py \
+ gen-tag-table.py \
gen-use-table.py \
+ gen-vowel-constraints.py \
$(NULL)
EXTRA_DIST += $(GENERATORS)
-unicode-tables: arabic-table indic-table use-table emoji-table
+unicode-tables: arabic-table indic-table tag-table use-table emoji-table
arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
$(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-arabic-table.hh \
@@ -307,17 +277,25 @@ indic-table: gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategor
$(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-indic-table.cc \
|| ($(RM) $(srcdir)/hb-ot-shape-complex-indic-table.cc; false)
+tag-table: gen-tag-table.py languagetags language-subtag-registry
+ $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-tag-table.hh \
+ || ($(RM) $(srcdir)/hb-ot-tag-table.hh; false)
+
use-table: gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt
$(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-use-table.cc \
|| ($(RM) $(srcdir)/hb-ot-shape-complex-use-table.cc; false)
+vowel-constraints: gen-vowel-constraints.py HBIndicVowelConstraints.txt Scripts.txt
+ $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-vowel-constraints.cc \
+ || ($(RM) $(srcdir)/hb-ot-shape-complex-vowel-constraints.cc; false)
+
emoji-table: gen-emoji-table.py emoji-data.txt
$(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-unicode-emoji-table.hh \
|| ($(RM) $(srcdir)/hb-unicode-emoji-table.hh; false)
built-sources: $(BUILT_SOURCES)
-.PHONY: unicode-tables arabic-table indic-table use-table emoji-table built-sources
+.PHONY: unicode-tables arabic-table indic-table tag-table use-table vowel-constraints emoji-table built-sources
RAGEL_GENERATED = \
$(patsubst %,$(srcdir)/%,$(HB_BASE_RAGEL_GENERATED_sources)) \
@@ -338,6 +316,7 @@ noinst_PROGRAMS = \
main \
test \
test-buffer-serialize \
+ test-name-table \
test-size-params \
test-would-substitute \
$(NULL)
@@ -351,17 +330,30 @@ test_SOURCES = test.cc
test_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
test_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
-test_would_substitute_SOURCES = test-would-substitute.cc
-test_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
-test_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
+test_buffer_serialize_SOURCES = test-buffer-serialize.cc
+test_buffer_serialize_CPPFLAGS = $(HBCFLAGS)
+test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS)
+
+test_name_table_SOURCES = test-name-table.cc
+test_name_table_CPPFLAGS = $(HBCFLAGS)
+test_name_table_LDADD = libharfbuzz.la $(HBLIBS)
test_size_params_SOURCES = test-size-params.cc
test_size_params_CPPFLAGS = $(HBCFLAGS)
test_size_params_LDADD = libharfbuzz.la $(HBLIBS)
-test_buffer_serialize_SOURCES = test-buffer-serialize.cc
-test_buffer_serialize_CPPFLAGS = $(HBCFLAGS)
-test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS)
+test_would_substitute_SOURCES = test-would-substitute.cc
+test_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
+test_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
+
+if HAVE_FREETYPE
+if HAVE_CAIRO_FT
+noinst_PROGRAMS += test-ot-color
+test_ot_color_SOURCES = test-ot-color.cc
+test_ot_color_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS) $(CAIRO_FT_CFLAGS)
+test_ot_color_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS) $(CAIRO_LIBS) $(CAIRO_FT_LIBS)
+endif # HAVE_CAIRO_FT
+endif # HAVE_FREETYPE
dist_check_SCRIPTS = \
check-c-linkage-decls.sh \
@@ -398,15 +390,6 @@ dump_use_data_SOURCES = dump-use-data.cc hb-ot-shape-complex-use-table.cc
dump_use_data_CPPFLAGS = $(HBCFLAGS)
dump_use_data_LDADD = libharfbuzz.la $(HBLIBS)
-if HAVE_FREETYPE
-if HAVE_CAIRO_FT
-check_PROGRAMS += dump-emoji
-dump_emoji_SOURCES = dump-emoji.cc
-dump_emoji_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS) $(CAIRO_FT_CFLAGS)
-dump_emoji_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS) $(CAIRO_LIBS) $(CAIRO_FT_LIBS)
-endif # HAVE_CAIRO_FT
-endif # HAVE_FREETYPE
-
check_PROGRAMS += test-ot-tag test-unicode-ranges
TESTS += test-ot-tag test-unicode-ranges
@@ -441,6 +424,8 @@ HarfBuzz_0_0_gir_CFLAGS = \
-DHB_H_IN \
-DHB_OT_H \
-DHB_OT_H_IN \
+ -DHB_AAT_H \
+ -DHB_AAT_H_IN \
-DHB_GOBJECT_H \
-DHB_GOBJECT_H_IN \
-DHB_EXTERN= \
diff --git a/chromium/third_party/harfbuzz-ng/src/src/Makefile.sources b/chromium/third_party/harfbuzz-ng/src/src/Makefile.sources
index 8b70381bd1d..ba90ef022ef 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/Makefile.sources
+++ b/chromium/third_party/harfbuzz-ng/src/src/Makefile.sources
@@ -16,6 +16,7 @@ HB_BASE_sources = \
hb-font.hh \
hb-font.cc \
hb-iter.hh \
+ hb-kern.hh \
hb-map.hh \
hb-map.cc \
hb-machinery.hh \
@@ -33,11 +34,15 @@ HB_BASE_sources = \
hb-ot-hmtx-table.hh \
hb-ot-kern-table.hh \
hb-ot-maxp-table.hh \
+ hb-ot-name-language.cc \
+ hb-ot-name-language.hh \
hb-ot-name-table.hh \
+ hb-ot-name.cc \
hb-ot-os2-table.hh \
hb-ot-os2-unicode-ranges.hh \
hb-ot-post-macroman.hh \
hb-ot-post-table.hh \
+ hb-ot-tag-table.hh \
hb-ot-tag.cc \
hb.hh \
hb-set-digest.hh \
@@ -95,11 +100,15 @@ HB_OT_sources = \
hb-aat-layout-ankr-table.hh \
hb-aat-layout-bsln-table.hh \
hb-aat-layout-feat-table.hh \
+ hb-aat-layout-just-table.hh \
hb-aat-layout-kerx-table.hh \
+ hb-aat-layout-lcar-table.hh \
hb-aat-layout-morx-table.hh \
hb-aat-layout-trak-table.hh \
hb-aat-layout.hh \
hb-aat-ltag-table.hh \
+ hb-aat-map.cc \
+ hb-aat-map.hh \
hb-ot-face.hh \
hb-ot-face.cc \
hb-ot-font.cc \
@@ -141,17 +150,21 @@ HB_OT_sources = \
hb-ot-shape-complex-use.cc \
hb-ot-shape-complex-use.hh \
hb-ot-shape-complex-use-table.cc \
+ hb-ot-shape-complex-vowel-constraints.cc \
+ hb-ot-shape-complex-vowel-constraints.hh \
hb-ot-shape-complex.hh \
hb-ot-shape-normalize.hh \
hb-ot-shape-normalize.cc \
hb-ot-shape-fallback.hh \
hb-ot-shape-fallback.cc \
hb-ot-shape.hh \
+ hb-ot-stat-table.hh \
hb-ot-var.cc \
hb-ot-var-avar-table.hh \
hb-ot-var-fvar-table.hh \
hb-ot-var-hvar-table.hh \
hb-ot-var-mvar-table.hh \
+ hb-ot-vorg-table.hh \
$(NULL)
HB_OT_RAGEL_GENERATED_sources = \
@@ -168,12 +181,15 @@ HB_OT_RAGEL_sources = \
$(NULL)
HB_OT_headers = \
+ hb-aat.h \
+ hb-aat-layout.h \
hb-ot.h \
+ hb-ot-color.h \
hb-ot-font.h \
hb-ot-layout.h \
hb-ot-math.h \
+ hb-ot-name.h \
hb-ot-shape.h \
- hb-ot-tag.h \
hb-ot-var.h \
$(NULL)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/dump-emoji.cc b/chromium/third_party/harfbuzz-ng/src/src/dump-emoji.cc
deleted file mode 100644
index b5ec30eadbe..00000000000
--- a/chromium/third_party/harfbuzz-ng/src/src/dump-emoji.cc
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright © 2018 Ebrahim Byagowi
- *
- * 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.
- */
-
-#include "hb-static.cc"
-#include "hb-ot-color-cbdt-table.hh"
-#include "hb-ot-color-colr-table.hh"
-#include "hb-ot-color-cpal-table.hh"
-#include "hb-ot-color-sbix-table.hh"
-#include "hb-ot-color-svg-table.hh"
-
-#include "hb-ft.h"
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-
-#include <cairo.h>
-#include <cairo-ft.h>
-#include <cairo-svg.h>
-
-#ifdef HAVE_GLIB
-#include <glib.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-
-static void cbdt_callback (const uint8_t* data, unsigned int length,
- unsigned int group, unsigned int gid)
-{
- char output_path[255];
- sprintf (output_path, "out/cbdt-%d-%d.png", group, gid);
- FILE *f = fopen (output_path, "wb");
- fwrite (data, 1, length, f);
- fclose (f);
-}
-
-static void sbix_callback (const uint8_t* data, unsigned int length,
- unsigned int group, unsigned int gid)
-{
- char output_path[255];
- sprintf (output_path, "out/sbix-%d-%d.png", group, gid);
- FILE *f = fopen (output_path, "wb");
- fwrite (data, 1, length, f);
- fclose (f);
-}
-
-static void svg_callback (const uint8_t* data, unsigned int length,
- unsigned int start_glyph, unsigned int end_glyph)
-{
- char output_path[255];
- if (start_glyph == end_glyph)
- sprintf (output_path, "out/svg-%d.svg", start_glyph);
- else
- sprintf (output_path, "out/svg-%d-%d.svg", start_glyph, end_glyph);
-
- // append "z" if the content is gzipped
- if ((data[0] == 0x1F) && (data[1] == 0x8B))
- strcat (output_path, "z");
-
- FILE *f = fopen (output_path, "wb");
- fwrite (data, 1, length, f);
- fclose (f);
-}
-
-static void colr_cpal_rendering (cairo_font_face_t *cairo_face, unsigned int upem, unsigned int num_glyphs,
- const OT::COLR *colr, const OT::CPAL *cpal)
-{
- for (unsigned int i = 0; i < num_glyphs; ++i)
- {
- unsigned int first_layer_index, num_layers;
- if (colr->get_base_glyph_record (i, &first_layer_index, &num_layers))
- {
- // Measure
- cairo_text_extents_t extents;
- {
- cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
- cairo_t *cr = cairo_create (surface);
- cairo_set_font_face (cr, cairo_face);
- cairo_set_font_size (cr, upem);
-
- cairo_glyph_t *glyphs = (cairo_glyph_t *) calloc (num_layers, sizeof (cairo_glyph_t));
- for (unsigned int j = 0; j < num_layers; ++j)
- {
- hb_codepoint_t glyph_id;
- unsigned int color_index;
- colr->get_layer_record (first_layer_index + j, &glyph_id, &color_index);
- glyphs[j].index = glyph_id;
- }
- cairo_glyph_extents (cr, glyphs, num_layers, &extents);
- free (glyphs);
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
- }
-
- // Add a slight margin
- extents.width += extents.width / 10;
- extents.height += extents.height / 10;
- extents.x_bearing -= extents.width / 20;
- extents.y_bearing -= extents.height / 20;
-
- // Render
- unsigned int pallet_count = cpal->get_palette_count ();
- for (unsigned int pallet = 0; pallet < pallet_count; ++pallet) {
- char output_path[255];
-
- // If we have more than one pallet, use a better namin
- if (pallet_count == 1)
- sprintf (output_path, "out/colr-%d.svg", i);
- else
- sprintf (output_path, "out/colr-%d-%d.svg", i, pallet);
-
- cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
- cairo_t *cr = cairo_create (surface);
- cairo_set_font_face (cr, cairo_face);
- cairo_set_font_size (cr, upem);
-
- for (unsigned int j = 0; j < num_layers; ++j)
- {
- hb_codepoint_t glyph_id;
- unsigned int color_index;
- colr->get_layer_record (first_layer_index + j, &glyph_id, &color_index);
-
- uint32_t color = cpal->get_color_record_argb (color_index, pallet);
- int alpha = color & 0xFF;
- int r = (color >> 8) & 0xFF;
- int g = (color >> 16) & 0xFF;
- int b = (color >> 24) & 0xFF;
- cairo_set_source_rgba (cr, r / 255., g / 255., b / 255., alpha);
-
- cairo_glyph_t glyph;
- glyph.index = glyph_id;
- glyph.x = -extents.x_bearing;
- glyph.y = -extents.y_bearing;
- cairo_show_glyphs (cr, &glyph, 1);
- }
-
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
- }
- }
- }
-}
-
-static void dump_glyphs (cairo_font_face_t *cairo_face, unsigned int upem,
- unsigned int num_glyphs)
-{
- // Dump every glyph available on the font
- return; // disabled for now
- for (unsigned int i = 0; i < num_glyphs; ++i)
- {
- cairo_text_extents_t extents;
- cairo_glyph_t glyph = {0};
- glyph.index = i;
-
- // Measure
- {
- cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
- cairo_t *cr = cairo_create (surface);
- cairo_set_font_face (cr, cairo_face);
- cairo_set_font_size (cr, upem);
-
- cairo_glyph_extents (cr, &glyph, 1, &extents);
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
- }
-
- // Add a slight margin
- extents.width += extents.width / 10;
- extents.height += extents.height / 10;
- extents.x_bearing -= extents.width / 20;
- extents.y_bearing -= extents.height / 20;
-
- // Render
- {
- char output_path[255];
- sprintf (output_path, "out/%d.svg", i);
- cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
- cairo_t *cr = cairo_create (surface);
- cairo_set_font_face (cr, cairo_face);
- cairo_set_font_size (cr, upem);
- glyph.x = -extents.x_bearing;
- glyph.y = -extents.y_bearing;
- cairo_show_glyphs (cr, &glyph, 1);
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
- }
- }
-}
-
-int main (int argc, char **argv)
-{
- if (argc != 2) {
- fprintf (stderr, "usage: %s font-file.ttf\n", argv[0]);
- exit (1);
- }
-
- hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
- hb_face_t *face = hb_face_create (blob, 0);
- hb_font_t *font = hb_font_create (face);
-
- OT::CBDT::accelerator_t cbdt;
- cbdt.init (face);
- cbdt.dump (cbdt_callback);
- cbdt.fini ();
-
- OT::sbix::accelerator_t sbix;
- sbix.init (face);
- sbix.dump (sbix_callback);
- sbix.fini ();
-
- OT::SVG::accelerator_t svg;
- svg.init (face);
- svg.dump (svg_callback);
- svg.fini ();
-
- hb_blob_t* colr_blob = hb_sanitize_context_t ().reference_table<OT::COLR> (face);
- const OT::COLR *colr = colr_blob->as<OT::COLR> ();
-
- hb_blob_t* cpal_blob = hb_sanitize_context_t ().reference_table<OT::CPAL> (face);
- const OT::CPAL *cpal = cpal_blob->as<OT::CPAL> ();
-
- cairo_font_face_t *cairo_face;
- {
- FT_Library library;
- FT_Init_FreeType (&library);
- FT_Face ftface;
- FT_New_Face (library, argv[1], 0, &ftface);
- cairo_face = cairo_ft_font_face_create_for_ft_face (ftface, 0);
- }
- unsigned int num_glyphs = hb_face_get_glyph_count (face);
- unsigned int upem = hb_face_get_upem (face);
- colr_cpal_rendering (cairo_face, upem, num_glyphs, colr, cpal);
- dump_glyphs (cairo_face, upem, num_glyphs);
-
-
- hb_font_destroy (font);
- hb_face_destroy (face);
- hb_blob_destroy (blob);
-
- return 0;
-}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/gen-def.py b/chromium/third_party/harfbuzz-ng/src/src/gen-def.py
index ba39eaae586..9111c698c36 100755
--- a/chromium/third_party/harfbuzz-ng/src/src/gen-def.py
+++ b/chromium/third_party/harfbuzz-ng/src/src/gen-def.py
@@ -15,11 +15,10 @@ for h in header_paths:
if h.endswith (".h"):
with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ())
-result = """EXPORTS
+symbols = "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M)))
+
+result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
%s
-LIBRARY lib%s-0.dll""" % (
- "\n".join (sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))),
- output_file.replace ('.def', '')
-)
+LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('.def', ''))
with open (output_file, "w") as f: f.write (result)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/gen-emoji-table.py b/chromium/third_party/harfbuzz-ng/src/src/gen-emoji-table.py
index 278e0b2d4a7..9afe747dd7d 100755
--- a/chromium/third_party/harfbuzz-ng/src/src/gen-emoji-table.py
+++ b/chromium/third_party/harfbuzz-ng/src/src/gen-emoji-table.py
@@ -12,7 +12,7 @@ if len (sys.argv) != 2:
f = open(sys.argv[1])
header = [f.readline () for _ in range(10)]
-sets = OrderedDict()
+ranges = OrderedDict()
for line in f.readlines():
line = line.strip()
if not line or line[0] == '#':
@@ -25,9 +25,12 @@ for line in f.readlines():
else:
start = end = rang[0]
- if typ not in sets:
- sets[typ] = set()
- sets[typ].add((start, end))
+ if typ not in ranges:
+ ranges[typ] = []
+ if ranges[typ] and ranges[typ][-1][1] == start - 1:
+ ranges[typ][-1] = (ranges[typ][-1][0], end)
+ else:
+ ranges[typ].append((start, end))
@@ -49,7 +52,7 @@ print ()
print ('#include "hb-unicode.hh"')
print ()
-for typ,s in sets.items():
+for typ,s in ranges.items():
if typ != "Extended_Pictographic": continue
print()
print("static const struct hb_unicode_range_t _hb_unicode_emoji_%s_table[] =" % typ)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/gen-tag-table.py b/chromium/third_party/harfbuzz-ng/src/src/gen-tag-table.py
new file mode 100755
index 00000000000..13004629d2b
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/gen-tag-table.py
@@ -0,0 +1,1126 @@
+#!/usr/bin/python
+
+"""Generator of the mapping from OpenType tags to BCP 47 tags and vice
+versa.
+
+It creates a ``const LangTag[]``, matching the tags from the OpenType
+languages system tag list to the language subtags of the BCP 47 language
+subtag registry, with some manual adjustments. The mappings are
+supplemented with macrolanguages' sublanguages and retired codes'
+replacements, according to BCP 47 and some manual additions where BCP 47
+omits a retired code entirely.
+
+Also generated is a function, ``hb_ot_ambiguous_tag_to_language``,
+intended for use by ``hb_ot_tag_to_language``. It maps OpenType tags
+back to BCP 47 tags. Ambiguous OpenType tags (those that correspond to
+multiple BCP 47 tags) are listed here, except when the alphabetically
+first BCP 47 tag happens to be the chosen disambiguated tag. In that
+case, the fallback behavior will choose the right tag anyway.
+"""
+
+from __future__ import absolute_import, division, print_function, unicode_literals
+
+import collections
+try:
+ from HTMLParser import HTMLParser
+ def write (s):
+ print (s.encode ('utf-8'), end='')
+except ImportError:
+ from html.parser import HTMLParser
+ def write (s):
+ sys.stdout.flush ()
+ sys.stdout.buffer.write (s.encode ('utf-8'))
+import io
+import itertools
+import re
+import sys
+import unicodedata
+
+if len (sys.argv) != 3:
+ print ('usage: ./gen-tag-table.py languagetags language-subtag-registry', file=sys.stderr)
+ sys.exit (1)
+
+try:
+ from html import unescape
+ def html_unescape (parser, entity):
+ return unescape (entity)
+except ImportError:
+ def html_unescape (parser, entity):
+ return parser.unescape (entity)
+
+def expect (condition, message=None):
+ if not condition:
+ if message is None:
+ raise AssertionError
+ raise AssertionError (message)
+
+# from http://www-01.sil.org/iso639-3/iso-639-3.tab
+ISO_639_3_TO_1 = {
+ 'aar': 'aa',
+ 'abk': 'ab',
+ 'afr': 'af',
+ 'aka': 'ak',
+ 'amh': 'am',
+ 'ara': 'ar',
+ 'arg': 'an',
+ 'asm': 'as',
+ 'ava': 'av',
+ 'ave': 'ae',
+ 'aym': 'ay',
+ 'aze': 'az',
+ 'bak': 'ba',
+ 'bam': 'bm',
+ 'bel': 'be',
+ 'ben': 'bn',
+ 'bis': 'bi',
+ 'bod': 'bo',
+ 'bos': 'bs',
+ 'bre': 'br',
+ 'bul': 'bg',
+ 'cat': 'ca',
+ 'ces': 'cs',
+ 'cha': 'ch',
+ 'che': 'ce',
+ 'chu': 'cu',
+ 'chv': 'cv',
+ 'cor': 'kw',
+ 'cos': 'co',
+ 'cre': 'cr',
+ 'cym': 'cy',
+ 'dan': 'da',
+ 'deu': 'de',
+ 'div': 'dv',
+ 'dzo': 'dz',
+ 'ell': 'el',
+ 'eng': 'en',
+ 'epo': 'eo',
+ 'est': 'et',
+ 'eus': 'eu',
+ 'ewe': 'ee',
+ 'fao': 'fo',
+ 'fas': 'fa',
+ 'fij': 'fj',
+ 'fin': 'fi',
+ 'fra': 'fr',
+ 'fry': 'fy',
+ 'ful': 'ff',
+ 'gla': 'gd',
+ 'gle': 'ga',
+ 'glg': 'gl',
+ 'glv': 'gv',
+ 'grn': 'gn',
+ 'guj': 'gu',
+ 'hat': 'ht',
+ 'hau': 'ha',
+ 'hbs': 'sh',
+ 'heb': 'he',
+ 'her': 'hz',
+ 'hin': 'hi',
+ 'hmo': 'ho',
+ 'hrv': 'hr',
+ 'hun': 'hu',
+ 'hye': 'hy',
+ 'ibo': 'ig',
+ 'ido': 'io',
+ 'iii': 'ii',
+ 'iku': 'iu',
+ 'ile': 'ie',
+ 'ina': 'ia',
+ 'ind': 'id',
+ 'ipk': 'ik',
+ 'isl': 'is',
+ 'ita': 'it',
+ 'jav': 'jv',
+ 'jpn': 'ja',
+ 'kal': 'kl',
+ 'kan': 'kn',
+ 'kas': 'ks',
+ 'kat': 'ka',
+ 'kau': 'kr',
+ 'kaz': 'kk',
+ 'khm': 'km',
+ 'kik': 'ki',
+ 'kin': 'rw',
+ 'kir': 'ky',
+ 'kom': 'kv',
+ 'kon': 'kg',
+ 'kor': 'ko',
+ 'kua': 'kj',
+ 'kur': 'ku',
+ 'lao': 'lo',
+ 'lat': 'la',
+ 'lav': 'lv',
+ 'lim': 'li',
+ 'lin': 'ln',
+ 'lit': 'lt',
+ 'ltz': 'lb',
+ 'lub': 'lu',
+ 'lug': 'lg',
+ 'mah': 'mh',
+ 'mal': 'ml',
+ 'mar': 'mr',
+ 'mkd': 'mk',
+ 'mlg': 'mg',
+ 'mlt': 'mt',
+ 'mol': 'mo',
+ 'mon': 'mn',
+ 'mri': 'mi',
+ 'msa': 'ms',
+ 'mya': 'my',
+ 'nau': 'na',
+ 'nav': 'nv',
+ 'nbl': 'nr',
+ 'nde': 'nd',
+ 'ndo': 'ng',
+ 'nep': 'ne',
+ 'nld': 'nl',
+ 'nno': 'nn',
+ 'nob': 'nb',
+ 'nor': 'no',
+ 'nya': 'ny',
+ 'oci': 'oc',
+ 'oji': 'oj',
+ 'ori': 'or',
+ 'orm': 'om',
+ 'oss': 'os',
+ 'pan': 'pa',
+ 'pli': 'pi',
+ 'pol': 'pl',
+ 'por': 'pt',
+ 'pus': 'ps',
+ 'que': 'qu',
+ 'roh': 'rm',
+ 'ron': 'ro',
+ 'run': 'rn',
+ 'rus': 'ru',
+ 'sag': 'sg',
+ 'san': 'sa',
+ 'sin': 'si',
+ 'slk': 'sk',
+ 'slv': 'sl',
+ 'sme': 'se',
+ 'smo': 'sm',
+ 'sna': 'sn',
+ 'snd': 'sd',
+ 'som': 'so',
+ 'sot': 'st',
+ 'spa': 'es',
+ 'sqi': 'sq',
+ 'srd': 'sc',
+ 'srp': 'sr',
+ 'ssw': 'ss',
+ 'sun': 'su',
+ 'swa': 'sw',
+ 'swe': 'sv',
+ 'tah': 'ty',
+ 'tam': 'ta',
+ 'tat': 'tt',
+ 'tel': 'te',
+ 'tgk': 'tg',
+ 'tgl': 'tl',
+ 'tha': 'th',
+ 'tir': 'ti',
+ 'ton': 'to',
+ 'tsn': 'tn',
+ 'tso': 'ts',
+ 'tuk': 'tk',
+ 'tur': 'tr',
+ 'twi': 'tw',
+ 'uig': 'ug',
+ 'ukr': 'uk',
+ 'urd': 'ur',
+ 'uzb': 'uz',
+ 'ven': 've',
+ 'vie': 'vi',
+ 'vol': 'vo',
+ 'wln': 'wa',
+ 'wol': 'wo',
+ 'xho': 'xh',
+ 'yid': 'yi',
+ 'yor': 'yo',
+ 'zha': 'za',
+ 'zho': 'zh',
+ 'zul': 'zu',
+}
+
+class LanguageTag (object):
+ """A BCP 47 language tag.
+
+ Attributes:
+ subtags (List[str]): The list of subtags in this tag.
+ grandfathered (bool): Whether this tag is grandfathered. If
+ ``true``, the entire lowercased tag is the ``language``
+ and the other subtag fields are empty.
+ language (str): The language subtag.
+ script (str): The script subtag.
+ region (str): The region subtag.
+ variant (str): The variant subtag.
+
+ Args:
+ tag (str): A BCP 47 language tag.
+
+ """
+ def __init__ (self, tag):
+ global bcp_47
+ self.subtags = tag.lower ().split ('-')
+ self.grandfathered = tag.lower () in bcp_47.grandfathered
+ if self.grandfathered:
+ self.language = tag.lower ()
+ self.script = ''
+ self.region = ''
+ self.variant = ''
+ else:
+ self.language = self.subtags[0]
+ self.script = self._find_first (lambda s: len (s) == 4 and s[0] > '9', self.subtags)
+ self.region = self._find_first (lambda s: len (s) == 2 and s[0] > '9' or len (s) == 3 and s[0] <= '9', self.subtags[1:])
+ self.variant = self._find_first (lambda s: len (s) > 4 or len (s) == 4 and s[0] <= '9', self.subtags)
+
+ def __str__(self):
+ return '-'.join(self.subtags)
+
+ def __repr__ (self):
+ return 'LanguageTag(%r)' % str(self)
+
+ @staticmethod
+ def _find_first (function, sequence):
+ try:
+ return next (iter (filter (function, sequence)))
+ except StopIteration:
+ return None
+
+ def is_complex (self):
+ """Return whether this tag is too complex to represent as a
+ ``LangTag`` in the generated code.
+
+ Complex tags need to be handled in
+ ``hb_ot_tags_from_complex_language``.
+
+ Returns:
+ Whether this tag is complex.
+ """
+ return not (len (self.subtags) == 1
+ or self.grandfathered
+ and len (self.subtags[1]) != 3
+ and ot.from_bcp_47[self.subtags[0]] == ot.from_bcp_47[self.language])
+
+ def get_group (self):
+ """Return the group into which this tag should be categorized in
+ ``hb_ot_tags_from_complex_language``.
+
+ The group is the first letter of the tag, or ``'und'`` if this tag
+ should not be matched in a ``switch`` statement in the generated
+ code.
+
+ Returns:
+ This tag's group.
+ """
+ return ('und'
+ if (self.language == 'und'
+ or self.variant in bcp_47.prefixes and len (bcp_47.prefixes[self.variant]) == 1)
+ else self.language[0])
+
+class OpenTypeRegistryParser (HTMLParser):
+ """A parser for the OpenType language system tag registry.
+
+ Attributes:
+ header (str): The "last updated" line of the registry.
+ names (Mapping[str, str]): A map of language system tags to the
+ names they are given in the registry.
+ ranks (DefaultDict[str, int]): A map of language system tags to
+ numbers. If a single BCP 47 tag corresponds to multiple
+ OpenType tags, the tags are ordered in increasing order by
+ rank. The rank is based on the number of BCP 47 tags
+ associated with a tag, though it may be manually modified.
+ to_bcp_47 (DefaultDict[str, AbstractSet[str]]): A map of
+ OpenType language system tags to sets of BCP 47 tags.
+ from_bcp_47 (DefaultDict[str, AbstractSet[str]]): ``to_bcp_47``
+ inverted. Its values start as unsorted sets;
+ ``sort_languages`` converts them to sorted lists.
+
+ """
+ def __init__ (self):
+ HTMLParser.__init__ (self)
+ self.header = ''
+ self.names = {}
+ self.ranks = collections.defaultdict (int)
+ self.to_bcp_47 = collections.defaultdict (set)
+ self.from_bcp_47 = collections.defaultdict (set)
+ # Whether the parser is in a <td> element
+ self._td = False
+ # The text of the <td> elements of the current <tr> element.
+ self._current_tr = []
+
+ def handle_starttag (self, tag, attrs):
+ if tag == 'meta':
+ for attr, value in attrs:
+ if attr == 'name' and value == 'updated_at':
+ self.header = self.get_starttag_text ()
+ break
+ elif tag == 'td':
+ self._td = True
+ self._current_tr.append ('')
+ elif tag == 'tr':
+ self._current_tr = []
+
+ def handle_endtag (self, tag):
+ if tag == 'td':
+ self._td = False
+ elif tag == 'tr' and self._current_tr:
+ expect (2 <= len (self._current_tr) <= 3)
+ name = self._current_tr[0].strip ()
+ tag = self._current_tr[1].strip ("\t\n\v\f\r '")
+ rank = 0
+ if len (tag) > 4:
+ expect (tag.endswith (' (deprecated)'), 'ill-formed OpenType tag: %s' % tag)
+ name += ' (deprecated)'
+ tag = tag.split (' ')[0]
+ rank = 1
+ self.names[tag] = re.sub (' languages$', '', name)
+ if not self._current_tr[2]:
+ return
+ iso_codes = self._current_tr[2].strip ()
+ self.to_bcp_47[tag].update (ISO_639_3_TO_1.get (code, code) for code in iso_codes.replace (' ', '').split (','))
+ rank += 2 * len (self.to_bcp_47[tag])
+ self.ranks[tag] = rank
+
+ def handle_data (self, data):
+ if self._td:
+ self._current_tr[-1] += data
+
+ def handle_charref (self, name):
+ self.handle_data (html_unescape (self, '&#%s;' % name))
+
+ def handle_entityref (self, name):
+ self.handle_data (html_unescape (self, '&%s;' % name))
+
+ def parse (self, filename):
+ """Parse the OpenType language system tag registry.
+
+ Args:
+ filename (str): The file name of the registry.
+ """
+ with io.open (filename, encoding='utf-8') as f:
+ self.feed (f.read ())
+ expect (self.header)
+ for tag, iso_codes in self.to_bcp_47.items ():
+ for iso_code in iso_codes:
+ self.from_bcp_47[iso_code].add (tag)
+
+ def add_language (self, bcp_47_tag, ot_tag):
+ """Add a language as if it were in the registry.
+
+ Args:
+ bcp_47_tag (str): A BCP 47 tag. If the tag is more than just
+ a language subtag, and if the language subtag is a
+ macrolanguage, then new languages are added corresponding
+ to the macrolanguages' individual languages with the
+ remainder of the tag appended.
+ ot_tag (str): An OpenType language system tag.
+ """
+ global bcp_47
+ self.to_bcp_47[ot_tag].add (bcp_47_tag)
+ self.from_bcp_47[bcp_47_tag].add (ot_tag)
+ if bcp_47_tag.lower () not in bcp_47.grandfathered:
+ try:
+ [macrolanguage, suffix] = bcp_47_tag.split ('-', 1)
+ if macrolanguage in bcp_47.macrolanguages:
+ s = set ()
+ for language in bcp_47.macrolanguages[macrolanguage]:
+ if language.lower () not in bcp_47.grandfathered:
+ s.add ('%s-%s' % (language, suffix))
+ bcp_47.macrolanguages['%s-%s' % (macrolanguage, suffix)] = s
+ except ValueError:
+ pass
+
+ @staticmethod
+ def _remove_language (tag_1, dict_1, dict_2):
+ for tag_2 in dict_1.pop (tag_1):
+ dict_2[tag_2].remove (tag_1)
+ if not dict_2[tag_2]:
+ del dict_2[tag_2]
+
+ def remove_language_ot (self, ot_tag):
+ """Remove an OpenType tag from the registry.
+
+ Args:
+ ot_tag (str): An OpenType tag.
+ """
+ self._remove_language (ot_tag, self.to_bcp_47, self.from_bcp_47)
+
+ def remove_language_bcp_47 (self, bcp_47_tag):
+ """Remove a BCP 47 tag from the registry.
+
+ Args:
+ bcp_47_tag (str): A BCP 47 tag.
+ """
+ self._remove_language (bcp_47_tag, self.from_bcp_47, self.to_bcp_47)
+
+ def inherit_from_macrolanguages (self):
+ """Copy mappings from macrolanguages to individual languages.
+
+ If a BCP 47 tag for an individual mapping has no OpenType
+ mapping but its macrolanguage does, the mapping is copied to
+ the individual language. For example, als (Tosk Albanian) has no
+ explicit mapping, so it inherits from sq (Albanian) the mapping
+ to SQI.
+
+ If a BCP 47 tag for a macrolanguage has no OpenType mapping but
+ all of its individual languages do and they all map to the same
+ tags, the mapping is copied to the macrolanguage.
+ """
+ global bcp_47
+ original_ot_from_bcp_47 = dict (self.from_bcp_47)
+ for macrolanguage, languages in dict (bcp_47.macrolanguages).items ():
+ ot_macrolanguages = set (original_ot_from_bcp_47.get (macrolanguage, set ()))
+ if ot_macrolanguages:
+ for ot_macrolanguage in ot_macrolanguages:
+ for language in languages:
+ # Remove the following condition if e.g. nn should map to NYN,NOR
+ # instead of just NYN.
+ if language not in original_ot_from_bcp_47:
+ self.add_language (language, ot_macrolanguage)
+ self.ranks[ot_macrolanguage] += 1
+ else:
+ for language in languages:
+ if language in original_ot_from_bcp_47:
+ if ot_macrolanguages:
+ ml = original_ot_from_bcp_47[language]
+ if ml:
+ ot_macrolanguages &= ml
+ else:
+ pass
+ else:
+ ot_macrolanguages |= original_ot_from_bcp_47[language]
+ else:
+ ot_macrolanguages.clear ()
+ if not ot_macrolanguages:
+ break
+ for ot_macrolanguage in ot_macrolanguages:
+ self.add_language (macrolanguage, ot_macrolanguage)
+
+ def sort_languages (self):
+ """Sort the values of ``from_bcp_47`` in ascending rank order."""
+ for language, tags in self.from_bcp_47.items ():
+ self.from_bcp_47[language] = sorted (tags,
+ key=lambda t: (self.ranks[t] + rank_delta (language, t), t))
+
+ot = OpenTypeRegistryParser ()
+
+class BCP47Parser (object):
+ """A parser for the BCP 47 subtag registry.
+
+ Attributes:
+ header (str): The "File-Date" line of the registry.
+ names (Mapping[str, str]): A map of subtags to the names they
+ are given in the registry. Each value is a
+ ``'\\n'``-separated list of names.
+ scopes (Mapping[str, str]): A map of language subtags to strings
+ suffixed to language names, including suffixes to explain
+ language scopes.
+ macrolanguages (DefaultDict[str, AbstractSet[str]]): A map of
+ language subtags to the sets of language subtags which
+ inherit from them. See
+ ``OpenTypeRegistryParser.inherit_from_macrolanguages``.
+ prefixes (DefaultDict[str, AbstractSet[str]]): A map of variant
+ subtags to their prefixes.
+ grandfathered (AbstractSet[str]): The set of grandfathered tags,
+ normalized to lowercase.
+
+ """
+ def __init__ (self):
+ self.header = ''
+ self.names = {}
+ self.scopes = {}
+ self.macrolanguages = collections.defaultdict (set)
+ self.prefixes = collections.defaultdict (set)
+ self.grandfathered = set ()
+
+ def parse (self, filename):
+ """Parse the BCP 47 subtag registry.
+
+ Args:
+ filename (str): The file name of the registry.
+ """
+ with io.open (filename, encoding='utf-8') as f:
+ subtag_type = None
+ subtag = None
+ deprecated = False
+ has_preferred_value = False
+ line_buffer = ''
+ for line in itertools.chain (f, ['']):
+ line = line.rstrip ()
+ if line.startswith (' '):
+ line_buffer += line[1:]
+ continue
+ line, line_buffer = line_buffer, line
+ if line.startswith ('Type: '):
+ subtag_type = line.split (' ')[1]
+ deprecated = False
+ has_preferred_value = False
+ elif line.startswith ('Subtag: ') or line.startswith ('Tag: '):
+ subtag = line.split (' ')[1]
+ if subtag_type == 'grandfathered':
+ self.grandfathered.add (subtag.lower ())
+ elif line.startswith ('Description: '):
+ description = line.split (' ', 1)[1].replace (' (individual language)', '')
+ description = re.sub (' (\((individual |macro)language\)|languages)$', '',
+ description)
+ if subtag in self.names:
+ self.names[subtag] += '\n' + description
+ else:
+ self.names[subtag] = description
+ elif subtag_type == 'language' or subtag_type == 'grandfathered':
+ if line.startswith ('Scope: '):
+ scope = line.split (' ')[1]
+ if scope == 'macrolanguage':
+ scope = ' [macrolanguage]'
+ elif scope == 'collection':
+ scope = ' [family]'
+ else:
+ continue
+ self.scopes[subtag] = scope
+ elif line.startswith ('Deprecated: '):
+ self.scopes[subtag] = ' (retired code)' + self.scopes.get (subtag, '')
+ deprecated = True
+ elif deprecated and line.startswith ('Comments: see '):
+ # If a subtag is split into multiple replacement subtags,
+ # it essentially represents a macrolanguage.
+ for language in line.replace (',', '').split (' ')[2:]:
+ self._add_macrolanguage (subtag, language)
+ elif line.startswith ('Preferred-Value: '):
+ # If a subtag is deprecated in favor of a single replacement subtag,
+ # it is either a dialect or synonym of the preferred subtag. Either
+ # way, it is close enough to the truth to consider the replacement
+ # the macrolanguage of the deprecated language.
+ has_preferred_value = True
+ macrolanguage = line.split (' ')[1]
+ self._add_macrolanguage (macrolanguage, subtag)
+ elif not has_preferred_value and line.startswith ('Macrolanguage: '):
+ self._add_macrolanguage (line.split (' ')[1], subtag)
+ elif subtag_type == 'variant':
+ if line.startswith ('Prefix: '):
+ self.prefixes[subtag].add (line.split (' ')[1])
+ elif line.startswith ('File-Date: '):
+ self.header = line
+ expect (self.header)
+
+ def _add_macrolanguage (self, macrolanguage, language):
+ global ot
+ if language not in ot.from_bcp_47:
+ for l in self.macrolanguages.get (language, set ()):
+ self._add_macrolanguage (macrolanguage, l)
+ if macrolanguage not in ot.from_bcp_47:
+ for ls in list (self.macrolanguages.values ()):
+ if macrolanguage in ls:
+ ls.add (language)
+ return
+ self.macrolanguages[macrolanguage].add (language)
+
+ def remove_extra_macrolanguages (self):
+ """Make every language have at most one macrolanguage."""
+ inverted = collections.defaultdict (list)
+ for macrolanguage, languages in self.macrolanguages.items ():
+ for language in languages:
+ inverted[language].append (macrolanguage)
+ for language, macrolanguages in inverted.items ():
+ if len (macrolanguages) > 1:
+ macrolanguages.sort (key=lambda ml: len (self.macrolanguages[ml]))
+ biggest_macrolanguage = macrolanguages.pop ()
+ for macrolanguage in macrolanguages:
+ self._add_macrolanguage (biggest_macrolanguage, macrolanguage)
+
+ def get_name (self, lt):
+ """Return the names of the subtags in a language tag.
+
+ Args:
+ lt (LanguageTag): A BCP 47 language tag.
+
+ Returns:
+ The name form of ``lt``.
+ """
+ name = self.names[lt.language].split ('\n')[0]
+ if lt.script:
+ name += '; ' + self.names[lt.script.title ()].split ('\n')[0]
+ if lt.region:
+ name += '; ' + self.names[lt.region.upper ()].split ('\n')[0]
+ if lt.variant:
+ name += '; ' + self.names[lt.variant].split ('\n')[0]
+ return name
+
+bcp_47 = BCP47Parser ()
+
+ot.parse (sys.argv[1])
+bcp_47.parse (sys.argv[2])
+
+ot.add_language ('ary', 'MOR')
+
+ot.add_language ('ath', 'ATH')
+
+ot.add_language ('bai', 'BML')
+
+ot.ranks['BAL'] = ot.ranks['KAR'] + 1
+
+ot.add_language ('ber', 'BBR')
+
+ot.remove_language_ot ('PGR')
+ot.add_language ('el-polyton', 'PGR')
+
+bcp_47.macrolanguages['et'] = {'ekk'}
+
+bcp_47.names['flm'] = 'Falam Chin'
+bcp_47.scopes['flm'] = ' (retired code)'
+bcp_47.macrolanguages['flm'] = {'cfm'}
+
+ot.ranks['FNE'] = ot.ranks['TNE'] + 1
+
+ot.add_language ('und-fonipa', 'IPPH')
+
+ot.add_language ('und-fonnapa', 'APPH')
+
+ot.remove_language_ot ('IRT')
+ot.add_language ('ga-Latg', 'IRT')
+
+ot.remove_language_ot ('KGE')
+ot.add_language ('und-Geok', 'KGE')
+
+ot.add_language ('guk', 'GUK')
+ot.names['GUK'] = 'Gumuz (SIL fonts)'
+ot.ranks['GUK'] = ot.ranks['GMZ'] + 1
+
+bcp_47.macrolanguages['id'] = {'in'}
+
+bcp_47.macrolanguages['ijo'] = {'ijc'}
+
+ot.add_language ('kht', 'KHN')
+ot.names['KHN'] = ot.names['KHT'] + ' (Microsoft fonts)'
+ot.names['KHT'] = ot.names['KHT'] + ' (OpenType spec and SIL fonts)'
+ot.ranks['KHN'] = ot.ranks['KHT']
+ot.ranks['KHT'] += 1
+
+ot.ranks['LCR'] = ot.ranks['MCR'] + 1
+
+ot.names['MAL'] = 'Malayalam Traditional'
+ot.ranks['MLR'] += 1
+
+bcp_47.names['mhv'] = 'Arakanese'
+bcp_47.scopes['mhv'] = ' (retired code)'
+
+ot.add_language ('no', 'NOR')
+
+ot.add_language ('oc-provenc', 'PRO')
+
+ot.add_language ('qu', 'QUZ')
+ot.add_language ('qub', 'QWH')
+ot.add_language ('qud', 'QVI')
+ot.add_language ('qug', 'QVI')
+ot.add_language ('qup', 'QVI')
+ot.add_language ('qur', 'QWH')
+ot.add_language ('qus', 'QUH')
+ot.add_language ('quw', 'QVI')
+ot.add_language ('qux', 'QWH')
+ot.add_language ('qva', 'QWH')
+ot.add_language ('qvh', 'QWH')
+ot.add_language ('qvj', 'QVI')
+ot.add_language ('qvl', 'QWH')
+ot.add_language ('qvm', 'QWH')
+ot.add_language ('qvn', 'QWH')
+ot.add_language ('qvo', 'QVI')
+ot.add_language ('qvp', 'QWH')
+ot.add_language ('qvw', 'QWH')
+ot.add_language ('qvz', 'QVI')
+ot.add_language ('qwa', 'QWH')
+ot.add_language ('qws', 'QWH')
+ot.add_language ('qxa', 'QWH')
+ot.add_language ('qxc', 'QWH')
+ot.add_language ('qxh', 'QWH')
+ot.add_language ('qxl', 'QVI')
+ot.add_language ('qxn', 'QWH')
+ot.add_language ('qxo', 'QWH')
+ot.add_language ('qxr', 'QVI')
+ot.add_language ('qxt', 'QWH')
+ot.add_language ('qxw', 'QWH')
+
+bcp_47.macrolanguages['ro'].remove ('mo')
+bcp_47.macrolanguages['ro-MD'].add ('mo')
+
+ot.add_language ('sgw', 'SGW')
+ot.names['SGW'] = ot.names['CHG'] + ' (SIL fonts)'
+ot.ranks['SGW'] = ot.ranks['CHG'] + 1
+
+ot.remove_language_ot ('SYRE')
+ot.remove_language_ot ('SYRJ')
+ot.remove_language_ot ('SYRN')
+ot.add_language ('und-Syre', 'SYRE')
+ot.add_language ('und-Syrj', 'SYRJ')
+ot.add_language ('und-Syrn', 'SYRN')
+
+bcp_47.names['xst'] = u"Silt'e"
+bcp_47.scopes['xst'] = ' (retired code)'
+bcp_47.macrolanguages['xst'] = {'stv', 'wle'}
+
+ot.add_language ('xwo', 'TOD')
+
+ot.remove_language_ot ('ZHH')
+ot.remove_language_ot ('ZHP')
+ot.remove_language_ot ('ZHT')
+bcp_47.macrolanguages['zh'].remove ('lzh')
+bcp_47.macrolanguages['zh'].remove ('yue')
+ot.add_language ('zh-Hant-MO', 'ZHH')
+ot.add_language ('zh-Hant-HK', 'ZHH')
+ot.add_language ('zh-Hans', 'ZHS')
+ot.add_language ('zh-Hant', 'ZHT')
+ot.add_language ('zh-HK', 'ZHH')
+ot.add_language ('zh-MO', 'ZHH')
+ot.add_language ('zh-TW', 'ZHT')
+ot.add_language ('lzh', 'ZHT')
+ot.add_language ('lzh-Hans', 'ZHS')
+ot.add_language ('yue', 'ZHH')
+ot.add_language ('yue-Hans', 'ZHS')
+
+bcp_47.macrolanguages['zom'] = {'yos'}
+
+def rank_delta (bcp_47, ot):
+ """Return a delta to apply to a BCP 47 tag's rank.
+
+ Most OpenType tags have a constant rank, but a few have ranks that
+ depend on the BCP 47 tag.
+
+ Args:
+ bcp_47 (str): A BCP 47 tag.
+ ot (str): An OpenType tag to.
+
+ Returns:
+ A number to add to ``ot``'s rank when sorting ``bcp_47``'s
+ OpenType equivalents.
+ """
+ if bcp_47 == 'ak' and ot == 'AKA':
+ return -1
+ if bcp_47 == 'tw' and ot == 'TWI':
+ return -1
+ return 0
+
+disambiguation = {
+ 'ALT': 'alt',
+ 'ARK': 'rki',
+ 'BHI': 'bhb',
+ 'BLN': 'bjt',
+ 'BTI': 'beb',
+ 'CCHN': 'cco',
+ 'CMR': 'swb',
+ 'CPP': 'crp',
+ 'CRR': 'crx',
+ 'DUJ': 'dwu',
+ 'ECR': 'crj',
+ 'HAL': 'cfm',
+ 'HND': 'hnd',
+ 'KIS': 'kqs',
+ 'LRC': 'bqi',
+ 'NDB': 'nd',
+ 'NIS': 'njz',
+ 'PLG': 'pce',
+ 'PRO': 'pro',
+ 'QIN': 'bgr',
+ 'QUH': 'quh',
+ 'QVI': 'qvi',
+ 'QWH': 'qwh',
+ 'SIG': 'stv',
+ 'TNE': 'yrk',
+ 'ZHH': 'zh-HK',
+ 'ZHS': 'zh-Hans',
+ 'ZHT': 'zh-Hant',
+}
+
+ot.inherit_from_macrolanguages ()
+bcp_47.remove_extra_macrolanguages ()
+ot.inherit_from_macrolanguages ()
+ot.sort_languages ()
+
+print ('/* == Start of generated table == */')
+print ('/*')
+print (' * The following table is generated by running:')
+print (' *')
+print (' * %s languagetags language-subtag-registry' % sys.argv[0])
+print (' *')
+print (' * on files with these headers:')
+print (' *')
+print (' * %s' % ot.header.strip ())
+print (' * %s' % bcp_47.header)
+print (' */')
+print ()
+print ('#ifndef HB_OT_TAG_TABLE_HH')
+print ('#define HB_OT_TAG_TABLE_HH')
+print ()
+print ('static const LangTag ot_languages[] = {')
+
+def hb_tag (tag):
+ """Convert a tag to ``HB_TAG`` form.
+
+ Args:
+ tag (str): An OpenType tag.
+
+ Returns:
+ A snippet of C++ representing ``tag``.
+ """
+ return u"HB_TAG('%s','%s','%s','%s')" % tuple (('%-4s' % tag)[:4])
+
+def get_variant_set (name):
+ """Return a set of variant language names from a name.
+
+ Args:
+ name (str): A list of language names from the BCP 47 registry,
+ joined on ``'\\n'``.
+
+ Returns:
+ A set of normalized language names.
+ """
+ return set (unicodedata.normalize ('NFD', n.replace ('\u2019', u"'"))
+ .encode ('ASCII', 'ignore')
+ .strip ()
+ for n in re.split ('[\n(),]', name) if n)
+
+def language_name_intersection (a, b):
+ """Return the names in common between two language names.
+
+ Args:
+ a (str): A list of language names from the BCP 47 registry,
+ joined on ``'\\n'``.
+ b (str): A list of language names from the BCP 47 registry,
+ joined on ``'\\n'``.
+
+ Returns:
+ The normalized language names shared by ``a`` and ``b``.
+ """
+ return get_variant_set (a).intersection (get_variant_set (b))
+
+def get_matching_language_name (intersection, candidates):
+ return next (iter (c for c in candidates if not intersection.isdisjoint (get_variant_set (c))))
+
+maximum_tags = 0
+for language, tags in sorted (ot.from_bcp_47.items ()):
+ if language == '' or '-' in language:
+ continue
+ print (' {\"%s\",\t{' % language, end='')
+ maximum_tags = max (maximum_tags, len (tags))
+ tag_count = len (tags)
+ for i, tag in enumerate (tags, start=1):
+ if i > 1:
+ print ('\t\t ', end='')
+ print (hb_tag (tag), end='')
+ if i == tag_count:
+ print ('}}', end='')
+ print (',\t/* ', end='')
+ bcp_47_name = bcp_47.names.get (language, '')
+ bcp_47_name_candidates = bcp_47_name.split ('\n')
+ intersection = language_name_intersection (bcp_47_name, ot.names[tag])
+ scope = bcp_47.scopes.get (language, '')
+ if not intersection:
+ write ('%s%s -> %s' % (bcp_47_name_candidates[0], scope, ot.names[tag]))
+ else:
+ name = get_matching_language_name (intersection, bcp_47_name_candidates)
+ bcp_47.names[language] = name
+ write ('%s%s' % (name if len (name) > len (ot.names[tag]) else ot.names[tag], scope))
+ print (' */')
+
+print ('};')
+print ()
+print ('static_assert (HB_OT_MAX_TAGS_PER_LANGUAGE == %iu, "");' % maximum_tags)
+print ()
+
+print ('/**')
+print (' * hb_ot_tags_from_complex_language:')
+print (' * @lang_str: a BCP 47 language tag to convert.')
+print (' * @limit: a pointer to the end of the substring of @lang_str to consider for')
+print (' * conversion.')
+print (' * @count: maximum number of language tags to retrieve (IN) and actual number of')
+print (' * language tags retrieved (OUT). If no tags are retrieved, it is not modified.')
+print (' * @tags: array of size at least @language_count to store the language tag')
+print (' * results')
+print (' *')
+print (' * Converts a multi-subtag BCP 47 language tag to language tags.')
+print (' *')
+print (' * Return value: Whether any language systems were retrieved.')
+print (' **/')
+print ('static bool')
+print ('hb_ot_tags_from_complex_language (const char *lang_str,')
+print ('\t\t\t\t const char *limit,')
+print ('\t\t\t\t unsigned int *count /* IN/OUT */,')
+print ('\t\t\t\t hb_tag_t *tags /* OUT */)')
+print ('{')
+
+def print_subtag_matches (subtag, new_line):
+ if subtag:
+ if new_line:
+ print ()
+ print ('\t&& ', end='')
+ print ('subtag_matches (lang_str, limit, "-%s")' % subtag, end='')
+
+complex_tags = collections.defaultdict (list)
+for initial, group in itertools.groupby ((lt_tags for lt_tags in [
+ (LanguageTag (language), tags)
+ for language, tags in sorted (ot.from_bcp_47.items (),
+ key=lambda i: (-len (i[0]), i[0]))
+ ] if lt_tags[0].is_complex ()),
+ key=lambda lt_tags: lt_tags[0].get_group ()):
+ complex_tags[initial] += group
+
+for initial, items in sorted (complex_tags.items ()):
+ if initial != 'und':
+ continue
+ for lt, tags in items:
+ if lt.variant in bcp_47.prefixes:
+ expect (next (iter (bcp_47.prefixes[lt.variant])) == lt.language,
+ '%s is not a valid prefix of %s' % (lt.language, lt.variant))
+ print (' if (', end='')
+ print_subtag_matches (lt.script, False)
+ print_subtag_matches (lt.region, False)
+ print_subtag_matches (lt.variant, False)
+ print (')')
+ print (' {')
+ write (' /* %s */' % bcp_47.get_name (lt))
+ print ()
+ if len (tags) == 1:
+ write (' tags[0] = %s; /* %s */' % (hb_tag (tags[0]), ot.names[tags[0]]))
+ print ()
+ print (' *count = 1;')
+ else:
+ print (' hb_tag_t possible_tags[] = {')
+ for tag in tags:
+ write (' %s, /* %s */' % (hb_tag (tag), ot.names[tag]))
+ print ()
+ print (' };')
+ print (' for (i = 0; i < %s && i < *count; i++)' % len (tags))
+ print (' tags[i] = possible_tags[i];')
+ print (' *count = i;')
+ print (' return true;')
+ print (' }')
+
+print (' switch (lang_str[0])')
+print (' {')
+for initial, items in sorted (complex_tags.items ()):
+ if initial == 'und':
+ continue
+ print (" case '%s':" % initial)
+ for lt, tags in items:
+ print (' if (', end='')
+ if lt.grandfathered:
+ print ('0 == strcmp (&lang_str[1], "%s")' % lt.language[1:], end='')
+ else:
+ string_literal = lt.language[1:] + '-'
+ if lt.script:
+ string_literal += lt.script
+ lt.script = None
+ if lt.region:
+ string_literal += '-' + lt.region
+ lt.region = None
+ if string_literal[-1] == '-':
+ print ('0 == strncmp (&lang_str[1], "%s", %i)' % (string_literal, len (string_literal)), end='')
+ else:
+ print ('lang_matches (&lang_str[1], "%s")' % string_literal, end='')
+ print_subtag_matches (lt.script, True)
+ print_subtag_matches (lt.region, True)
+ print_subtag_matches (lt.variant, True)
+ print (')')
+ print (' {')
+ write (' /* %s */' % bcp_47.get_name (lt))
+ print ()
+ if len (tags) == 1:
+ write (' tags[0] = %s; /* %s */' % (hb_tag (tags[0]), ot.names[tags[0]]))
+ print ()
+ print (' *count = 1;')
+ else:
+ print (' unsigned int i;')
+ print (' hb_tag_t possible_tags[] = {')
+ for tag in tags:
+ write ('\t%s, /* %s */' % (hb_tag (tag), ot.names[tag]))
+ print ()
+ print (' };')
+ print (' for (i = 0; i < %s && i < *count; i++)' % len (tags))
+ print ('\ttags[i] = possible_tags[i];')
+ print (' *count = i;')
+ print (' return true;')
+ print (' }')
+ print (' break;')
+
+print (' }')
+print (' return false;')
+print ('}')
+print ()
+print ('/**')
+print (' * hb_ot_ambiguous_tag_to_language')
+print (' * @tag: A language tag.')
+print (' *')
+print (' * Converts @tag to a BCP 47 language tag if it is ambiguous (it corresponds to')
+print (' * many language tags) and the best tag is not the alphabetically first, or if')
+print (' * the best tag consists of multiple subtags.')
+print (' *')
+print (' * Return value: The #hb_language_t corresponding to the BCP 47 language tag,')
+print (' * or #HB_LANGUAGE_INVALID if @tag is not ambiguous.')
+print (' **/')
+print ('static hb_language_t')
+print ('hb_ot_ambiguous_tag_to_language (hb_tag_t tag)')
+print ('{')
+print (' switch (tag)')
+print (' {')
+
+def verify_disambiguation_dict ():
+ """Verify and normalize ``disambiguation``.
+
+ ``disambiguation`` is a map of ambiguous OpenType language system
+ tags to the particular BCP 47 tags they correspond to. This function
+ checks that all its keys really are ambiguous and that each key's
+ value is valid for that key. It checks that no ambiguous tag is
+ missing, except when it can figure out which BCP 47 tag is the best
+ by itself.
+
+ It modifies ``disambiguation`` to remove keys whose values are the
+ same as those that the fallback would return anyway, and to add
+ ambiguous keys whose disambiguations it determined automatically.
+
+ Raises:
+ AssertionError: Verification failed.
+ """
+ global bcp_47
+ global disambiguation
+ global ot
+ for ot_tag, bcp_47_tags in ot.to_bcp_47.items ():
+ primary_tags = list (t for t in bcp_47_tags if t not in bcp_47.grandfathered and ot.from_bcp_47.get (t)[0] == ot_tag)
+ if len (primary_tags) == 1:
+ expect (ot_tag not in disambiguation, 'unnecessary disambiguation for OT tag: %s' % ot_tag)
+ if '-' in primary_tags[0]:
+ disambiguation[ot_tag] = primary_tags[0]
+ elif len (primary_tags) == 0:
+ expect (ot_tag not in disambiguation, 'There is no possible valid disambiguation for %s' % ot_tag)
+ else:
+ macrolanguages = list (t for t in primary_tags if bcp_47.scopes.get (t) == ' [macrolanguage]')
+ if len (macrolanguages) != 1:
+ macrolanguages = list (t for t in primary_tags if bcp_47.scopes.get (t) == ' [family]')
+ if len (macrolanguages) != 1:
+ macrolanguages = list (t for t in primary_tags if 'retired code' not in bcp_47.scopes.get (t, ''))
+ if len (macrolanguages) != 1:
+ expect (ot_tag in disambiguation, 'ambiguous OT tag: %s %s' % (ot_tag, str (macrolanguages)))
+ expect (disambiguation[ot_tag] in bcp_47_tags,
+ '%s is not a valid disambiguation for %s' % (disambiguation[ot_tag], ot_tag))
+ elif ot_tag not in disambiguation:
+ disambiguation[ot_tag] = macrolanguages[0]
+ if disambiguation[ot_tag] == sorted (primary_tags)[0] and '-' not in disambiguation[ot_tag]:
+ del disambiguation[ot_tag]
+ for ot_tag in disambiguation.keys ():
+ expect (ot_tag in ot.to_bcp_47, 'unknown OT tag: %s' % ot_tag)
+
+verify_disambiguation_dict ()
+for ot_tag, bcp_47_tag in sorted (disambiguation.items ()):
+ write (' case %s: /* %s */' % (hb_tag (ot_tag), ot.names[ot_tag]))
+ print ()
+ write (' return hb_language_from_string (\"%s\", -1); /* %s */' % (bcp_47_tag, bcp_47.get_name (LanguageTag (bcp_47_tag))))
+ print ()
+
+print (' default:')
+print (' return HB_LANGUAGE_INVALID;')
+print (' }')
+print ('}')
+
+print ()
+print ('#endif /* HB_OT_TAG_TABLE_HH */')
+print ()
+print ('/* == End of generated table == */')
+
diff --git a/chromium/third_party/harfbuzz-ng/src/src/gen-use-table.py b/chromium/third_party/harfbuzz-ng/src/src/gen-use-table.py
index ebfae6fab8f..099f6a18518 100755
--- a/chromium/third_party/harfbuzz-ng/src/src/gen-use-table.py
+++ b/chromium/third_party/harfbuzz-ng/src/src/gen-use-table.py
@@ -50,6 +50,8 @@ data[0][0x20F0] = defaults[0]
# TODO https://github.com/roozbehp/unicode-data/issues/9
data[0][0x11C44] = 'Consonant_Placeholder'
data[0][0x11C45] = 'Consonant_Placeholder'
+# TODO https://github.com/harfbuzz/harfbuzz/pull/1399
+data[0][0x111C8] = 'Consonant_Placeholder'
for u in range (0xFE00, 0xFE0F + 1):
data[0][u] = defaults[0]
@@ -168,7 +170,7 @@ def is_BASE(U, UISC, UGC):
def is_BASE_IND(U, UISC, UGC):
#SPEC-DRAFT return (UISC in [Consonant_Dead, Modifying_Letter] or UGC == Po)
return (UISC in [Consonant_Dead, Modifying_Letter] or
- (UGC == Po and not U in [0x104B, 0x104E, 0x2022, 0x11A3F, 0x11A45, 0x11C44, 0x11C45]) or
+ (UGC == Po and not U in [0x104B, 0x104E, 0x2022, 0x111C8, 0x11A3F, 0x11A45, 0x11C44, 0x11C45]) or
False # SPEC-DRAFT-OUTDATED! U == 0x002D
)
def is_BASE_NUM(U, UISC, UGC):
@@ -200,7 +202,8 @@ def is_HALANT(U, UISC, UGC):
return UISC in [Virama, Invisible_Stacker] and not is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC)
def is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC):
# https://github.com/harfbuzz/harfbuzz/issues/1102
- return U == 0x11046
+ # https://github.com/harfbuzz/harfbuzz/issues/1379
+ return U in [0x11046, 0x1134D]
def is_HALANT_NUM(U, UISC, UGC):
return UISC == Number_Joiner
def is_ZWNJ(U, UISC, UGC):
@@ -353,6 +356,9 @@ def map_to_use(data):
# TODO: https://github.com/harfbuzz/harfbuzz/issues/1105
if U == 0x11134: UISC = Gemination_Mark
+ # TODO: https://github.com/harfbuzz/harfbuzz/pull/1399
+ if U == 0x111C9: UISC = Consonant_Final
+
values = [k for k,v in items if v(U,UISC,UGC)]
assert len(values) == 1, "%s %s %s %s" % (hex(U), UISC, UGC, values)
USE = values[0]
diff --git a/chromium/third_party/harfbuzz-ng/src/src/gen-vowel-constraints.py b/chromium/third_party/harfbuzz-ng/src/src/gen-vowel-constraints.py
new file mode 100755
index 00000000000..b7f6be2236f
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/gen-vowel-constraints.py
@@ -0,0 +1,219 @@
+#!/usr/bin/python
+
+"""Generator of the function to prohibit certain vowel sequences.
+
+It creates ``_hb_preprocess_text_vowel_constraints``, which inserts dotted
+circles into sequences prohibited by the USE script development spec.
+This function should be used as the ``preprocess_text`` of an
+``hb_ot_complex_shaper_t``.
+"""
+
+from __future__ import absolute_import, division, print_function, unicode_literals
+
+import collections
+try:
+ from HTMLParser import HTMLParser
+ def write (s):
+ print (s.encode ('utf-8'), end='')
+except ImportError:
+ from html.parser import HTMLParser
+ def write (s):
+ sys.stdout.flush ()
+ sys.stdout.buffer.write (s.encode ('utf-8'))
+import itertools
+import io
+import sys
+
+if len (sys.argv) != 3:
+ print ('usage: ./gen-vowel-constraints.py HBIndicVowelConstraints.txt Scripts.txt', file=sys.stderr)
+ sys.exit (1)
+
+with io.open (sys.argv[2], encoding='utf-8') as f:
+ scripts_header = [f.readline () for i in range (2)]
+ scripts = {}
+ script_order = {}
+ for line in f:
+ j = line.find ('#')
+ if j >= 0:
+ line = line[:j]
+ fields = [x.strip () for x in line.split (';')]
+ if len (fields) == 1:
+ continue
+ uu = fields[0].split ('..')
+ start = int (uu[0], 16)
+ if len (uu) == 1:
+ end = start
+ else:
+ end = int (uu[1], 16)
+ script = fields[1]
+ for u in range (start, end + 1):
+ scripts[u] = script
+ if script not in script_order:
+ script_order[script] = start
+
+class ConstraintSet (object):
+ """A set of prohibited code point sequences.
+
+ Args:
+ constraint (List[int]): A prohibited code point sequence.
+
+ """
+ def __init__ (self, constraint):
+ # Either a list or a dictionary. As a list of code points, it
+ # represents a prohibited code point sequence. As a dictionary,
+ # it represents a set of prohibited sequences, where each item
+ # represents the set of prohibited sequences starting with the
+ # key (a code point) concatenated with any of the values
+ # (ConstraintSets).
+ self._c = constraint
+
+ def add (self, constraint):
+ """Add a constraint to this set."""
+ if not constraint:
+ return
+ first = constraint[0]
+ rest = constraint[1:]
+ if isinstance (self._c, list):
+ if constraint == self._c[:len (constraint)]:
+ self._c = constraint
+ elif self._c != constraint[:len (self._c)]:
+ self._c = {self._c[0]: ConstraintSet (self._c[1:])}
+ if isinstance (self._c, dict):
+ if first in self._c:
+ self._c[first].add (rest)
+ else:
+ self._c[first] = ConstraintSet (rest)
+
+ def _indent (self, depth):
+ return (' ' * depth).replace (' ', '\t')
+
+ def __str__ (self, index=0, depth=4):
+ s = []
+ indent = self._indent (depth)
+ if isinstance (self._c, list):
+ if len (self._c) == 0:
+ s.append ('{}matched = true;\n'.format (indent))
+ elif len (self._c) == 1:
+ s.append ('{}matched = 0x{:04X}u == buffer->cur ({}).codepoint;\n'.format (indent, next (iter (self._c)), index or ''))
+ else:
+ s.append ('{}if (0x{:04X}u == buffer->cur ({}).codepoint &&\n'.format (indent, self._c[0], index))
+ s.append ('{}buffer->idx + {} < count &&\n'.format (self._indent (depth + 2), len (self._c)))
+ for i, cp in enumerate (self._c[1:], start=1):
+ s.append ('{}0x{:04X}u == buffer->cur ({}).codepoint{}\n'.format (
+ self._indent (depth + 2), cp, index + i, ')' if i == len (self._c) - 1 else ' &&'))
+ s.append ('{}{{\n'.format (indent))
+ for i in range (len (self._c)):
+ s.append ('{}buffer->next_glyph ();\n'.format (self._indent (depth + 1)))
+ s.append ('{}_output_dotted_circle (buffer);\n'.format (self._indent (depth + 1)))
+ s.append ('{}}}\n'.format (indent))
+ else:
+ s.append ('{}switch (buffer->cur ({}).codepoint)\n'.format(indent, index or ''))
+ s.append ('{}{{\n'.format (indent))
+ cases = collections.defaultdict (set)
+ for first, rest in sorted (self._c.items ()):
+ cases[rest.__str__ (index + 1, depth + 2)].add (first)
+ for body, labels in sorted (cases.items (), key=lambda b_ls: sorted (b_ls[1])[0]):
+ for i, cp in enumerate (sorted (labels)):
+ if i % 4 == 0:
+ s.append (self._indent (depth + 1))
+ else:
+ s.append (' ')
+ s.append ('case 0x{:04X}u:{}'.format (cp, '\n' if i % 4 == 3 else ''))
+ if len (labels) % 4 != 0:
+ s.append ('\n')
+ s.append (body)
+ s.append ('{}break;\n'.format (self._indent (depth + 2)))
+ s.append ('{}}}\n'.format (indent))
+ return ''.join (s)
+
+constraints = {}
+with io.open (sys.argv[1], encoding='utf-8') as f:
+ constraints_header = [f.readline ().strip () for i in range (2)]
+ for line in f:
+ j = line.find ('#')
+ if j >= 0:
+ line = line[:j]
+ constraint = [int (cp, 16) for cp in line.split (';')[0].split ()]
+ if not constraint: continue
+ assert 2 <= len (constraint), 'Prohibited sequence is too short: {}'.format (constraint)
+ script = scripts[constraint[0]]
+ if script in constraints:
+ constraints[script].add (constraint)
+ else:
+ constraints[script] = ConstraintSet (constraint)
+ assert constraints, 'No constraints found'
+
+print ('/* == Start of generated functions == */')
+print ('/*')
+print (' * The following functions are generated by running:')
+print (' *')
+print (' * %s use Scripts.txt' % sys.argv[0])
+print (' *')
+print (' * on files with these headers:')
+print (' *')
+for line in constraints_header:
+ print (' * %s' % line.strip ())
+print (' *')
+for line in scripts_header:
+ print (' * %s' % line.strip ())
+print (' */')
+print ()
+print ('#include "hb-ot-shape-complex-vowel-constraints.hh"')
+print ()
+print ('static void')
+print ('_output_dotted_circle (hb_buffer_t *buffer)')
+print ('{')
+print (' hb_glyph_info_t &dottedcircle = buffer->output_glyph (0x25CCu);')
+print (' _hb_glyph_info_reset_continuation (&dottedcircle);')
+print ('}')
+print ()
+print ('static void')
+print ('_output_with_dotted_circle (hb_buffer_t *buffer)')
+print ('{')
+print (' _output_dotted_circle (buffer);')
+print (' buffer->next_glyph ();')
+print ('}')
+print ()
+
+print ('void')
+print ('_hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan HB_UNUSED,')
+print ('\t\t\t\t hb_buffer_t *buffer,')
+print ('\t\t\t\t hb_font_t *font HB_UNUSED)')
+print ('{')
+print (' /* UGLY UGLY UGLY business of adding dotted-circle in the middle of')
+print (' * vowel-sequences that look like another vowel. Data for each script')
+print (' * collected from the USE script development spec.')
+print (' *')
+print (' * https://github.com/harfbuzz/harfbuzz/issues/1019')
+print (' */')
+print (' bool processed = false;')
+print (' buffer->clear_output ();')
+print (' unsigned int count = buffer->len;')
+print (' switch ((unsigned) buffer->props.script)')
+print (' {')
+
+for script, constraints in sorted (constraints.items (), key=lambda s_c: script_order[s_c[0]]):
+ print (' case HB_SCRIPT_{}:'.format (script.upper ()))
+ print (' for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)')
+ print (' {')
+ print ('\tbool matched = false;')
+ write (str (constraints))
+ print ('\tbuffer->next_glyph ();')
+ print ('\tif (matched) _output_with_dotted_circle (buffer);')
+ print (' }')
+ print (' processed = true;')
+ print (' break;')
+ print ()
+
+print (' default:')
+print (' break;')
+print (' }')
+print (' if (processed)')
+print (' {')
+print (' if (buffer->idx < count)')
+print (' buffer->next_glyph ();')
+print (' }')
+print ('}')
+
+print ()
+print ('/* == End of generated functions == */')
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-ankr-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-ankr-table.hh
index a197cec8112..b793245a0c5 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-ankr-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-ankr-table.hh
@@ -36,6 +36,8 @@
namespace AAT {
+using namespace OT;
+
struct Anchor
{
@@ -45,32 +47,49 @@ struct Anchor
return_trace (c->check_struct (this));
}
+ public:
FWORD xCoordinate;
FWORD yCoordinate;
public:
DEFINE_SIZE_STATIC (4);
};
+typedef LArrayOf<Anchor> GlyphAnchors;
+
struct ankr
{
static const hb_tag_t tableTag = HB_AAT_TAG_ankr;
+ inline const Anchor &get_anchor (hb_codepoint_t glyph_id,
+ unsigned int i,
+ unsigned int num_glyphs,
+ const char *end) const
+ {
+ const Offset<HBUINT16, false> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
+ if (!offset)
+ return Null(Anchor);
+ const GlyphAnchors &anchors = StructAtOffset<GlyphAnchors> (&(this+anchorData), *offset);
+ /* TODO Use sanitizer; to avoid overflows and more. */
+ if (unlikely ((const char *) &anchors + anchors.get_size () > end))
+ return Null(Anchor);
+ return anchors[i];
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
version == 0 &&
- lookupTable.sanitize (c, this) &&
- anchors.sanitize (c, this)));
+ lookupTable.sanitize (c, this)));
}
protected:
HBUINT16 version; /* Version number (set to zero) */
HBUINT16 flags; /* Flags (currently unused; set to zero) */
- LOffsetTo<Lookup<HBUINT16> >
+ LOffsetTo<Lookup<Offset<HBUINT16, false> >, false>
lookupTable; /* Offset to the table's lookup table */
- LOffsetTo<LArrayOf<Anchor> >
- anchors; /* Offset to the glyph data table */
+ LOffsetTo<HBUINT8, false>
+ anchorData; /* Offset to the glyph data table */
public:
DEFINE_SIZE_STATIC (12);
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-common.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-common.hh
index b0faa1db5f8..c0b0e3751f3 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-common.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-common.hh
@@ -36,111 +36,6 @@ 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 <typename Type>
-struct BinSearchArrayOf
-{
- inline const Type& operator [] (unsigned int i) const
- {
- if (unlikely (i >= header.nUnits)) return Null(Type);
- return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
- }
- inline Type& operator [] (unsigned int i)
- {
- return StructAtOffset<Type> (&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<Type> (&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 <typename T>
- 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.arrayZ, header.nUnits, header.unitSize));
- }
-
- protected:
- BinSearchHeader header;
- UnsizedArrayOf<HBUINT8> bytesZ;
- public:
- DEFINE_SIZE_ARRAY (10, bytesZ);
-};
-
-
-/*
* Lookup Table
*/
@@ -163,19 +58,26 @@ struct LookupFormat0
TRACE_SANITIZE (this);
return_trace (arrayZ.sanitize (c, c->get_num_glyphs ()));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (arrayZ.sanitize (c, c->get_num_glyphs (), base));
+ }
protected:
HBUINT16 format; /* Format identifier--format = 0 */
UnsizedArrayOf<T>
arrayZ; /* Array of lookup values, indexed by glyph index. */
public:
- DEFINE_SIZE_ARRAY (2, arrayZ);
+ DEFINE_SIZE_UNBOUNDED (2);
};
template <typename T>
struct LookupSegmentSingle
{
+ enum { TerminationWordCount = 2 };
+
inline int cmp (hb_codepoint_t g) const {
return g < first ? -1 : g <= last ? 0 : +1 ;
}
@@ -185,6 +87,11 @@ struct LookupSegmentSingle
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) && value.sanitize (c, base));
+ }
GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */
@@ -210,10 +117,15 @@ struct LookupFormat2
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (segments.sanitize (c, base));
+ }
protected:
HBUINT16 format; /* Format identifier--format = 2 */
- BinSearchArrayOf<LookupSegmentSingle<T> >
+ VarSizedBinSearchArrayOf<LookupSegmentSingle<T> >
segments; /* The actual segments. These must already be sorted,
* according to the first word in each one (the last
* glyph in each segment). */
@@ -224,6 +136,8 @@ struct LookupFormat2
template <typename T>
struct LookupSegmentArray
{
+ enum { TerminationWordCount = 2 };
+
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;
@@ -240,6 +154,14 @@ struct LookupSegmentArray
first <= last &&
valuesZ.sanitize (c, base, last - first + 1));
}
+ template <typename T2>
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base, T2 user_data) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ first <= last &&
+ valuesZ.sanitize (c, base, last - first + 1, user_data));
+ }
GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */
@@ -267,10 +189,15 @@ struct LookupFormat4
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c, this));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (segments.sanitize (c, this, base));
+ }
protected:
- HBUINT16 format; /* Format identifier--format = 2 */
- BinSearchArrayOf<LookupSegmentArray<T> >
+ HBUINT16 format; /* Format identifier--format = 4 */
+ VarSizedBinSearchArrayOf<LookupSegmentArray<T> >
segments; /* The actual segments. These must already be sorted,
* according to the first word in each one (the last
* glyph in each segment). */
@@ -281,6 +208,8 @@ struct LookupFormat4
template <typename T>
struct LookupSingle
{
+ enum { TerminationWordCount = 1 };
+
inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); }
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -288,11 +217,16 @@ struct LookupSingle
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) && value.sanitize (c, base));
+ }
GlyphID glyph; /* Last GlyphID */
T value; /* The lookup value (only one) */
public:
- DEFINE_SIZE_STATIC (4 + T::static_size);
+ DEFINE_SIZE_STATIC (2 + T::static_size);
};
template <typename T>
@@ -312,10 +246,15 @@ struct LookupFormat6
TRACE_SANITIZE (this);
return_trace (entries.sanitize (c));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (entries.sanitize (c, base));
+ }
protected:
HBUINT16 format; /* Format identifier--format = 6 */
- BinSearchArrayOf<LookupSingle<T> >
+ VarSizedBinSearchArrayOf<LookupSingle<T> >
entries; /* The actual entries, sorted by glyph index. */
public:
DEFINE_SIZE_ARRAY (8, entries);
@@ -329,7 +268,8 @@ struct LookupFormat8
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;
+ return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ?
+ &valueArrayZ[glyph_id - firstGlyph] : nullptr;
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -337,9 +277,14 @@ struct LookupFormat8
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount));
}
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount, base));
+ }
protected:
- HBUINT16 format; /* Format identifier--format = 6 */
+ HBUINT16 format; /* Format identifier--format = 8 */
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). */
@@ -351,6 +296,48 @@ struct LookupFormat8
};
template <typename T>
+struct LookupFormat10
+{
+ friend struct Lookup<T>;
+
+ private:
+ inline const typename T::type get_value_or_null (hb_codepoint_t glyph_id) const
+ {
+ if (!(firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount))
+ return Null(T);
+
+ const HBUINT8 *p = &valueArrayZ[(glyph_id - firstGlyph) * valueSize];
+
+ unsigned int v = 0;
+ unsigned int count = valueSize;
+ for (unsigned int i = 0; i < count; i++)
+ v = (v << 8) | *p++;
+
+ return v;
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ valueSize <= 4 &&
+ valueArrayZ.sanitize (c, glyphCount * valueSize));
+ }
+
+ protected:
+ HBUINT16 format; /* Format identifier--format = 8 */
+ HBUINT16 valueSize; /* Byte size of each value. */
+ GlyphID firstGlyph; /* First glyph index included in the trimmed array. */
+ HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last
+ * glyph minus the value of firstGlyph plus 1). */
+ UnsizedArrayOf<HBUINT8>
+ valueArrayZ; /* The lookup values (indexed by the glyph index
+ * minus the value of firstGlyph). */
+ public:
+ DEFINE_SIZE_ARRAY (8, valueArrayZ);
+};
+
+template <typename T>
struct Lookup
{
inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
@@ -365,6 +352,25 @@ struct Lookup
}
}
+ inline const typename T::type get_value_or_null (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
+ {
+ switch (u.format) {
+ /* Format 10 cannot return a pointer. */
+ case 10: return u.format10.get_value_or_null (glyph_id);
+ default:
+ const T *v = get_value (glyph_id, num_glyphs);
+ return v ? *v : Null(T);
+ }
+ }
+
+ inline typename T::type get_class (hb_codepoint_t glyph_id,
+ unsigned int num_glyphs,
+ unsigned int outOfRange) const
+ {
+ const T *v = get_value (glyph_id, num_glyphs);
+ return v ? *v : outOfRange;
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -375,6 +381,21 @@ struct Lookup
case 4: return_trace (u.format4.sanitize (c));
case 6: return_trace (u.format6.sanitize (c));
case 8: return_trace (u.format8.sanitize (c));
+ case 10: return_trace (u.format10.sanitize (c));
+ default:return_trace (true);
+ }
+ }
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ if (!u.format.sanitize (c)) return_trace (false);
+ switch (u.format) {
+ case 0: return_trace (u.format0.sanitize (c, base));
+ case 2: return_trace (u.format2.sanitize (c, base));
+ case 4: return_trace (u.format4.sanitize (c, base));
+ case 6: return_trace (u.format6.sanitize (c, base));
+ case 8: return_trace (u.format8.sanitize (c, base));
+ case 10: return_trace (false); /* No need to support format10 apparently */
default:return_trace (true);
}
}
@@ -387,14 +408,35 @@ struct Lookup
LookupFormat4<T> format4;
LookupFormat6<T> format6;
LookupFormat8<T> format8;
+ LookupFormat10<T> format10;
} u;
public:
DEFINE_SIZE_UNION (2, format);
};
+/* Lookup 0 has unbounded size (dependant on num_glyphs). So we need to defined
+ * special NULL objects for Lookup<> objects, but since it's template our macros
+ * don't work. So we have to hand-code them here. UGLY. */
+} /* Close namespace. */
+/* Ugly hand-coded null objects for template Lookup<> :(. */
+extern HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2];
+template <>
+/*static*/ inline const AAT::Lookup<OT::HBUINT16>& Null<AAT::Lookup<OT::HBUINT16> > (void) {
+ return *reinterpret_cast<const AAT::Lookup<OT::HBUINT16> *> (_hb_Null_AAT_Lookup);
+}
+template <>
+/*static*/ inline const AAT::Lookup<OT::HBUINT32>& Null<AAT::Lookup<OT::HBUINT32> > (void) {
+ return *reinterpret_cast<const AAT::Lookup<OT::HBUINT32> *> (_hb_Null_AAT_Lookup);
+}
+template <>
+/*static*/ inline const AAT::Lookup<OT::Offset<OT::HBUINT16, false> >& Null<AAT::Lookup<OT::Offset<OT::HBUINT16, false> > > (void) {
+ return *reinterpret_cast<const AAT::Lookup<OT::Offset<OT::HBUINT16, false> > *> (_hb_Null_AAT_Lookup);
+}
+namespace AAT {
+enum { DELETED_GLYPH = 0xFFFF };
/*
- * Extended State Table
+ * (Extended) State Table
*/
template <typename T>
@@ -406,7 +448,12 @@ struct Entry
/* 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. */
+ * if I need to remove that as well.
+ *
+ * HOWEVER! Because we are a template, our DEFINE_SIZE_STATIC
+ * assertion wouldn't be checked, hence the line below. */
+ static_assert (T::static_size, "");
+
return_trace (c->check_struct (this));
}
@@ -423,7 +470,7 @@ struct Entry
template <>
struct Entry<void>
{
- inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
+ inline bool sanitize (hb_sanitize_context_t *c, unsigned int count /*XXX Unused?*/) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this));
@@ -436,9 +483,13 @@ struct Entry<void>
DEFINE_SIZE_STATIC (4);
};
-template <typename Extra>
+template <typename Types, typename Extra>
struct StateTable
{
+ typedef typename Types::HBUINT HBUINT;
+ typedef typename Types::HBUSHORT HBUSHORT;
+ typedef typename Types::ClassTypeNarrow ClassType;
+
enum State
{
STATE_START_OF_TEXT = 0,
@@ -452,10 +503,13 @@ struct StateTable
CLASS_END_OF_LINE = 3,
};
+ inline int new_state (unsigned int newState) const
+ { return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / nClasses; }
+
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 ? (unsigned) *v : (unsigned) CLASS_OUT_OF_BOUNDS;
+ if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH;
+ return (this+classTable).get_class (glyph_id, num_glyphs, 1);
}
inline const Entry<Extra> *get_entries () const
@@ -463,14 +517,15 @@ struct StateTable
return (this+entryTable).arrayZ;
}
- inline const Entry<Extra> *get_entryZ (unsigned int state, unsigned int klass) const
+ inline const Entry<Extra> *get_entryZ (int state, unsigned int klass) const
{
if (unlikely (klass >= nClasses)) return nullptr;
- const HBUINT16 *states = (this+stateArrayTable).arrayZ;
+ const HBUSHORT *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ;
unsigned int entry = states[state * nClasses + klass];
+ DEBUG_MSG (APPLY, nullptr, "e%u", entry);
return &entries[entry];
}
@@ -482,33 +537,91 @@ struct StateTable
if (unlikely (!(c->check_struct (this) &&
classTable.sanitize (c, this)))) return_trace (false);
- const HBUINT16 *states = (this+stateArrayTable).arrayZ;
+ const HBUSHORT *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ;
- unsigned int num_states = 1;
+ unsigned int num_classes = nClasses;
+ if (unlikely (hb_unsigned_mul_overflows (num_classes, states[0].static_size)))
+ return_trace (false);
+ unsigned int row_stride = num_classes * states[0].static_size;
+
+ /* Apple 'kern' table has this peculiarity:
+ *
+ * "Because the stateTableOffset in the state table header is (strictly
+ * speaking) redundant, some 'kern' tables use it to record an initial
+ * state where that should not be StartOfText. To determine if this is
+ * done, calculate what the stateTableOffset should be. If it's different
+ * from the actual stateTableOffset, use it as the initial state."
+ *
+ * We implement this by calling the initial state zero, but allow *negative*
+ * states if the start state indeed was not the first state. Since the code
+ * is shared, this will also apply to 'mort' table. The 'kerx' / 'morx'
+ * tables are not affected since those address states by index, not offset.
+ */
+
+ int min_state = 0;
+ int max_state = 0;
unsigned int num_entries = 0;
- unsigned int state = 0;
+ int state_pos = 0;
+ int state_neg = 0;
unsigned int entry = 0;
- while (state < num_states)
+ while (min_state < state_neg || state_pos <= max_state)
{
- if (unlikely (!c->check_array (states,
- num_states,
- states[0].static_size * nClasses)))
- 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<unsigned int> (num_entries, *p + 1);
- state = num_states;
+ if (min_state < state_neg)
+ {
+ /* Negative states. */
+ if (unlikely (hb_unsigned_mul_overflows (min_state, num_classes)))
+ return_trace (false);
+ if (unlikely (!c->check_range (&states[min_state * num_classes],
+ -min_state,
+ row_stride)))
+ return_trace (false);
+ if ((c->max_ops -= state_neg - min_state) < 0)
+ return_trace (false);
+ { /* Sweep new states. */
+ const HBUSHORT *stop = &states[min_state * num_classes];
+ if (unlikely (stop > states))
+ return_trace (false);
+ for (const HBUSHORT *p = states; stop < p; p--)
+ num_entries = MAX<unsigned int> (num_entries, *(p - 1) + 1);
+ state_neg = min_state;
+ }
+ }
+
+ if (state_pos <= max_state)
+ {
+ /* Positive states. */
+ if (unlikely (!c->check_range (states,
+ max_state + 1,
+ row_stride)))
+ return_trace (false);
+ if ((c->max_ops -= max_state - state_pos + 1) < 0)
+ return_trace (false);
+ { /* Sweep new states. */
+ if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes)))
+ return_trace (false);
+ const HBUSHORT *stop = &states[(max_state + 1) * num_classes];
+ if (unlikely (stop < states))
+ return_trace (false);
+ for (const HBUSHORT *p = &states[state_pos * num_classes]; p < stop; p++)
+ num_entries = MAX<unsigned int> (num_entries, *p + 1);
+ state_pos = max_state + 1;
+ }
}
if (unlikely (!c->check_array (entries, num_entries)))
return_trace (false);
+ if ((c->max_ops -= num_entries - entry) < 0)
+ return_trace (false);
{ /* Sweep new entries. */
const Entry<Extra> *stop = &entries[num_entries];
for (const Entry<Extra> *p = &entries[entry]; p < stop; p++)
- num_states = MAX<unsigned int> (num_states, p->newState + 1);
+ {
+ int newState = new_state (p->newState);
+ min_state = MIN (min_state, newState);
+ max_state = MAX (max_state, newState);
+ }
entry = num_entries;
}
}
@@ -520,23 +633,111 @@ struct StateTable
}
protected:
- HBUINT32 nClasses; /* Number of classes, which is the number of indices
+ HBUINT nClasses; /* Number of classes, which is the number of indices
* in a single line in the state array. */
- LOffsetTo<Lookup<HBUINT16>, false>
+ OffsetTo<ClassType, HBUINT, false>
classTable; /* Offset to the class table. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
+ OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT, false>
stateArrayTable;/* Offset to the state array. */
- LOffsetTo<UnsizedArrayOf<Entry<Extra> >, false>
+ OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT, false>
entryTable; /* Offset to the entry array. */
public:
- DEFINE_SIZE_STATIC (16);
+ DEFINE_SIZE_STATIC (4 * sizeof (HBUINT));
};
-template <typename EntryData>
+template <typename HBUCHAR>
+struct ClassTable
+{
+ inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange) const
+ {
+ unsigned int i = glyph_id - firstGlyph;
+ return i >= classArray.len ? outOfRange : classArray.arrayZ[i];
+ }
+ inline unsigned int get_class (hb_codepoint_t glyph_id,
+ unsigned int num_glyphs HB_UNUSED,
+ unsigned int outOfRange) const
+ {
+ return get_class (glyph_id, outOfRange);
+ }
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) && classArray.sanitize (c));
+ }
+ protected:
+ GlyphID firstGlyph; /* First glyph index included in the trimmed array. */
+ ArrayOf<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus
+ * firstGlyph). */
+ public:
+ DEFINE_SIZE_ARRAY (4, classArray);
+};
+
+struct ObsoleteTypes
+{
+ static const bool extended = false;
+ typedef HBUINT16 HBUINT;
+ typedef HBUINT8 HBUSHORT;
+ typedef ClassTable<HBUINT8> ClassTypeNarrow;
+ typedef ClassTable<HBUINT16> ClassTypeWide;
+
+ template <typename T>
+ static inline unsigned int offsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return (offset - ((const char *) array - (const char *) base)) / sizeof (T);
+ }
+ template <typename T>
+ static inline unsigned int byteOffsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return offsetToIndex (offset, base, array);
+ }
+ template <typename T>
+ static inline unsigned int wordOffsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return offsetToIndex (2 * offset, base, array);
+ }
+};
+struct ExtendedTypes
+{
+ static const bool extended = true;
+ typedef HBUINT32 HBUINT;
+ typedef HBUINT16 HBUSHORT;
+ typedef Lookup<HBUINT16> ClassTypeNarrow;
+ typedef Lookup<HBUINT16> ClassTypeWide;
+
+ template <typename T>
+ static inline unsigned int offsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return offset;
+ }
+ template <typename T>
+ static inline unsigned int byteOffsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return offset / 2;
+ }
+ template <typename T>
+ static inline unsigned int wordOffsetToIndex (unsigned int offset,
+ const void *base,
+ const T *array)
+ {
+ return offset;
+ }
+};
+
+template <typename Types, typename EntryData>
struct StateTableDriver
{
- inline StateTableDriver (const StateTable<EntryData> &machine_,
+ inline StateTableDriver (const StateTable<Types, EntryData> &machine_,
hb_buffer_t *buffer_,
hb_face_t *face_) :
machine (machine_),
@@ -546,32 +747,33 @@ struct StateTableDriver
template <typename context_t>
inline void drive (context_t *c)
{
- hb_glyph_info_t *info = buffer->info;
-
if (!c->in_place)
buffer->clear_output ();
- unsigned int state = StateTable<EntryData>::STATE_START_OF_TEXT;
+ int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT;
bool last_was_dont_advance = false;
- for (buffer->idx = 0;;)
+ for (buffer->idx = 0; buffer->successful;)
{
unsigned int klass = buffer->idx < buffer->len ?
- machine.get_class (info[buffer->idx].codepoint, num_glyphs) :
- (unsigned) StateTable<EntryData>::CLASS_END_OF_TEXT;
+ machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
+ (unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT;
+ DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const Entry<EntryData> *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)
+ * go differently if we start from state 0 here.
+ *
+ * Ugh. The indexing here is ugly... */
+ if (state && buffer->backtrack_len () && buffer->idx < buffer->len)
{
/* If there's no action and we're just epsilon-transitioning to state 0,
* safe to break. */
if (c->is_actionable (this, entry) ||
- !(entry->newState == StateTable<EntryData>::STATE_START_OF_TEXT &&
+ !(entry->newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
entry->flags == context_t::DontAdvance))
- buffer->unsafe_to_break (buffer->idx - 1, buffer->idx + 1);
+ buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
}
/* Unsafe-to-break if end-of-text would kick in here. */
@@ -583,36 +785,36 @@ struct StateTableDriver
}
if (unlikely (!c->transition (this, entry)))
- break;
-
- if (unlikely (!buffer->successful)) return;
+ break;
last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0;
- state = entry->newState;
+ state = machine.new_state (entry->newState);
+ DEBUG_MSG (APPLY, nullptr, "s%d", state);
if (buffer->idx == buffer->len)
- break;
+ break;
if (!last_was_dont_advance)
- buffer->next_glyph ();
+ buffer->next_glyph ();
}
if (!c->in_place)
{
- for (; buffer->idx < buffer->len;)
- buffer->next_glyph ();
+ for (; buffer->successful && buffer->idx < buffer->len;)
+ buffer->next_glyph ();
buffer->swap_buffers ();
}
}
public:
- const StateTable<EntryData> &machine;
+ const StateTable<Types, EntryData> &machine;
hb_buffer_t *buffer;
unsigned int num_glyphs;
};
+struct ankr;
struct hb_aat_apply_context_t :
hb_dispatch_context_t<hb_aat_apply_context_t, bool, HB_DEBUG_APPLY>
@@ -623,32 +825,28 @@ struct hb_aat_apply_context_t :
static return_t default_return_value (void) { return false; }
bool stop_sublookup_iteration (return_t r) const { return r; }
+ const hb_ot_shape_plan_t *plan;
hb_font_t *font;
hb_face_t *face;
hb_buffer_t *buffer;
hb_sanitize_context_t sanitizer;
+ const ankr *ankr_table;
+ const char *ankr_end;
/* Unused. For debug tracing only. */
unsigned int lookup_index;
unsigned int debug_depth;
- inline hb_aat_apply_context_t (hb_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 ();
- }
+ HB_INTERNAL hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_,
+ hb_font_t *font_,
+ hb_buffer_t *buffer_,
+ hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t)));
- inline void set_lookup_index (unsigned int i) { lookup_index = i; }
+ HB_INTERNAL ~hb_aat_apply_context_t (void);
- inline ~hb_aat_apply_context_t (void)
- {
- sanitizer.end_processing ();
- }
+ HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_, const char *ankr_end_);
+
+ inline void set_lookup_index (unsigned int i) { lookup_index = i; }
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-feat-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-feat-table.hh
index b670caab83b..4e63ec8e855 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-feat-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-feat-table.hh
@@ -39,6 +39,27 @@ namespace AAT {
struct SettingName
{
+ friend struct FeatureName;
+
+ int cmp (hb_aat_layout_feature_selector_t key) const
+ { return (int) key - (int) setting; }
+
+ inline hb_aat_layout_feature_selector_t get_selector (void) const
+ { return (hb_aat_layout_feature_selector_t) (unsigned) setting; }
+
+ inline void get_info (hb_aat_layout_feature_selector_info_t *s,
+ hb_aat_layout_feature_selector_t default_selector) const
+ {
+ s->name_id = nameIndex;
+
+ s->enable = (hb_aat_layout_feature_selector_t) (unsigned int) setting;
+ s->disable = default_selector == HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID ?
+ (hb_aat_layout_feature_selector_t) (s->enable + 1) :
+ default_selector;
+
+ s->reserved = 0;
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -51,35 +72,76 @@ struct SettingName
public:
DEFINE_SIZE_STATIC (4);
};
+DECLARE_NULL_NAMESPACE_BYTES (AAT, SettingName);
+
+struct feat;
struct FeatureName
{
- inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- (base+settingTable).sanitize (c, nSettings)));
- }
+ int cmp (hb_aat_layout_feature_type_t key) const
+ { return (int) key - (int) feature; }
enum {
- Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
- NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
+ Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
+ NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
* the setting name array for this feature should
* be taken as the default for the feature
* (if one is required). If set, then bits 0-15 of this
* featureFlags field contain the index of the setting
* which is to be taken as the default. */
- IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits
+ IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits
* indicate the index of the setting in the setting name
* array for this feature which should be taken
* as the default. */
};
+ inline unsigned int get_selector_infos (unsigned int start_offset,
+ unsigned int *selectors_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *pdefault_index, /* OUT. May be NULL. */
+ const void *base) const
+ {
+ hb_array_t< const SettingName> settings_table = (base+settingTableZ).as_array (nSettings);
+
+ static_assert (Index::NOT_FOUND_INDEX == HB_AAT_LAYOUT_NO_SELECTOR_INDEX, "");
+
+ hb_aat_layout_feature_selector_t default_selector = HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID;
+ unsigned int default_index = Index::NOT_FOUND_INDEX;
+ if (featureFlags & Exclusive)
+ {
+ default_index = (featureFlags & NotDefault) ? featureFlags & IndexMask : 0;
+ default_selector = settings_table[default_index].get_selector ();
+ }
+ if (pdefault_index)
+ *pdefault_index = default_index;
+
+ if (selectors_count)
+ {
+ hb_array_t<const SettingName> arr = settings_table.sub_array (start_offset, selectors_count);
+ unsigned int count = arr.len;
+ for (unsigned int i = 0; i < count; i++)
+ settings_table[start_offset + i].get_info (&selectors[i], default_selector);
+ }
+ return settings_table.len;
+ }
+
+ inline hb_aat_layout_feature_type_t get_feature_type () const
+ { return (hb_aat_layout_feature_type_t) (unsigned int) feature; }
+
+ inline hb_ot_name_id_t get_feature_name_id () const { return nameIndex; }
+
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ (base+settingTableZ).sanitize (c, nSettings)));
+ }
+
protected:
HBUINT16 feature; /* Feature type. */
HBUINT16 nSettings; /* The number of records in the setting name array. */
LOffsetTo<UnsizedArrayOf<SettingName>, false>
- settingTable; /* Offset in bytes from the beginning of this table to
+ settingTableZ; /* Offset in bytes from the beginning of this table to
* this feature's setting name array. The actual type of
* record this offset refers to will depend on the
* exclusivity value, as described below. */
@@ -95,11 +157,47 @@ struct feat
{
static const hb_tag_t tableTag = HB_AAT_TAG_feat;
+ inline bool has_data (void) const { return version.to_int (); }
+
+ inline unsigned int get_feature_types (unsigned int start_offset,
+ unsigned int *count,
+ hb_aat_layout_feature_type_t *features) const
+ {
+ unsigned int feature_count = featureNameCount;
+ if (count && *count)
+ {
+ unsigned int len = MIN (feature_count - start_offset, *count);
+ for (unsigned int i = 0; i < len; i++)
+ features[i] = namesZ[i + start_offset].get_feature_type ();
+ *count = len;
+ }
+ return featureNameCount;
+ }
+
+ inline const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const
+ {
+ return namesZ.bsearch (featureNameCount, feature_type);
+ }
+
+ inline hb_ot_name_id_t get_feature_name_id (hb_aat_layout_feature_type_t feature) const
+ { return get_feature (feature).get_feature_name_id (); }
+
+ inline unsigned int get_selector_infos (hb_aat_layout_feature_type_t feature_type,
+ unsigned int start_offset,
+ unsigned int *selectors_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *default_index /* OUT. May be NULL. */) const
+ {
+ return get_feature (feature_type).get_selector_infos (start_offset, selectors_count, selectors,
+ default_index, this);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- names.sanitize (c, featureNameCount, this)));
+ version.major == 1 &&
+ namesZ.sanitize (c, featureNameCount, this)));
}
protected:
@@ -109,8 +207,8 @@ struct feat
/* The number of entries in the feature name array. */
HBUINT16 reserved1; /* Reserved (set to zero). */
HBUINT32 reserved2; /* Reserved (set to zero). */
- UnsizedArrayOf<FeatureName>
- names; /* The feature name array. */
+ SortedUnsizedArrayOf<FeatureName>
+ namesZ; /* The feature name array. */
public:
DEFINE_SIZE_STATIC (24);
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-just-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-just-table.hh
new file mode 100644
index 00000000000..92ca6603e16
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-just-table.hh
@@ -0,0 +1,417 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#ifndef HB_AAT_LAYOUT_JUST_TABLE_HH
+#define HB_AAT_LAYOUT_JUST_TABLE_HH
+
+#include "hb-aat-layout-common.hh"
+#include "hb-ot-layout.hh"
+#include "hb-open-type.hh"
+
+#include "hb-aat-layout-morx-table.hh"
+
+/*
+ * just -- Justification
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6just.html
+ */
+#define HB_AAT_TAG_just HB_TAG('j','u','s','t')
+
+
+namespace AAT {
+
+using namespace OT;
+
+
+struct ActionSubrecordHeader
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ HBUINT16 actionClass; /* The JustClass value associated with this
+ * ActionSubrecord. */
+ HBUINT16 actionType; /* The type of postcompensation action. */
+ HBUINT16 actionLength; /* Length of this ActionSubrecord record, which
+ * must be a multiple of 4. */
+ public:
+ DEFINE_SIZE_STATIC (6);
+};
+
+struct DecompositionAction
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ ActionSubrecordHeader
+ header;
+ Fixed lowerLimit; /* If the distance factor is less than this value,
+ * then the ligature is decomposed. */
+ Fixed upperLimit; /* If the distance factor is greater than this value,
+ * then the ligature is decomposed. */
+ HBUINT16 order; /* Numerical order in which this ligature will
+ * be decomposed; you may want infrequent ligatures
+ * to decompose before more frequent ones. The ligatures
+ * on the line of text will decompose in increasing
+ * value of this field. */
+ ArrayOf<HBUINT16>
+ decomposedglyphs;
+ /* Number of 16-bit glyph indexes that follow;
+ * the ligature will be decomposed into these glyphs.
+ *
+ * Array of decomposed glyphs. */
+ public:
+ DEFINE_SIZE_ARRAY (18, decomposedglyphs);
+};
+
+struct UnconditionalAddGlyphAction
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this));
+ }
+
+ protected:
+ ActionSubrecordHeader
+ header;
+ GlyphID addGlyph; /* Glyph that should be added if the distance factor
+ * is growing. */
+
+ public:
+ DEFINE_SIZE_STATIC (8);
+};
+
+struct ConditionalAddGlyphAction
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ ActionSubrecordHeader
+ header;
+ Fixed substThreshold; /* Distance growth factor (in ems) at which
+ * this glyph is replaced and the growth factor
+ * recalculated. */
+ GlyphID addGlyph; /* Glyph to be added as kashida. If this value is
+ * 0xFFFF, no extra glyph will be added. Note that
+ * generally when a glyph is added, justification
+ * will need to be redone. */
+ GlyphID substGlyph; /* Glyph to be substituted for this glyph if the
+ * growth factor equals or exceeds the value of
+ * substThreshold. */
+ public:
+ DEFINE_SIZE_STATIC (14);
+};
+
+struct DuctileGlyphAction
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ ActionSubrecordHeader
+ header;
+ HBUINT32 variationAxis; /* The 4-byte tag identifying the ductile axis.
+ * This would normally be 0x64756374 ('duct'),
+ * but you may use any axis the font contains. */
+ Fixed minimumLimit; /* The lowest value for the ductility axis tha
+ * still yields an acceptable appearance. Normally
+ * this will be 1.0. */
+ Fixed noStretchValue; /* This is the default value that corresponds to
+ * no change in appearance. Normally, this will
+ * be 1.0. */
+ Fixed maximumLimit; /* The highest value for the ductility axis that
+ * still yields an acceptable appearance. */
+ public:
+ DEFINE_SIZE_STATIC (22);
+};
+
+struct RepeatedAddGlyphAction
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ ActionSubrecordHeader
+ header;
+ HBUINT16 flags; /* Currently unused; set to 0. */
+ GlyphID glyph; /* Glyph that should be added if the distance factor
+ * is growing. */
+ public:
+ DEFINE_SIZE_STATIC (10);
+};
+
+struct ActionSubrecord
+{
+ inline unsigned int get_length (void) const { return u.header.actionLength; }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (!c->check_struct (this)))
+ return_trace (false);
+
+ switch (u.header.actionType)
+ {
+ case 0: return_trace (u.decompositionAction.sanitize (c));
+ case 1: return_trace (u.unconditionalAddGlyphAction.sanitize (c));
+ case 2: return_trace (u.conditionalAddGlyphAction.sanitize (c));
+ // case 3: return_trace (u.stretchGlyphAction.sanitize (c));
+ case 4: return_trace (u.decompositionAction.sanitize (c));
+ case 5: return_trace (u.decompositionAction.sanitize (c));
+ default: return_trace (true);
+ }
+ }
+
+ protected:
+ union {
+ ActionSubrecordHeader header;
+ DecompositionAction decompositionAction;
+ UnconditionalAddGlyphAction unconditionalAddGlyphAction;
+ ConditionalAddGlyphAction conditionalAddGlyphAction;
+ /* StretchGlyphAction stretchGlyphAction; -- Not supported by CoreText */
+ DuctileGlyphAction ductileGlyphAction;
+ RepeatedAddGlyphAction repeatedAddGlyphAction;
+ } u; /* Data. The format of this data depends on
+ * the value of the actionType field. */
+ public:
+ DEFINE_SIZE_UNION (6, header);
+};
+
+struct PostcompensationActionChain
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (!c->check_struct (this)))
+ return_trace (false);
+
+ unsigned int offset = min_size;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ const ActionSubrecord& subrecord = StructAtOffset<ActionSubrecord> (this, offset);
+ if (unlikely (!subrecord.sanitize (c))) return_trace (false);
+ offset += subrecord.get_length ();
+ }
+
+ return_trace (true);
+ }
+
+ protected:
+ HBUINT32 count;
+
+ public:
+ DEFINE_SIZE_STATIC (4);
+};
+
+struct JustWidthDeltaEntry
+{
+ enum Flags
+ {
+ Reserved1 =0xE000,/* Reserved. You should set these bits to zero. */
+ UnlimiteGap =0x1000,/* The glyph can take unlimited gap. When this
+ * glyph participates in the justification process,
+ * it and any other glyphs on the line having this
+ * bit set absorb all the remaining gap. */
+ Reserved2 =0x0FF0,/* Reserved. You should set these bits to zero. */
+ Priority =0x000F /* The justification priority of the glyph. */
+ };
+
+ enum Priority
+ {
+ Kashida = 0, /* Kashida priority. This is the highest priority
+ * during justification. */
+ Whitespace = 1, /* Whitespace priority. Any whitespace glyphs (as
+ * identified in the glyph properties table) will
+ * get this priority. */
+ InterCharacter = 2, /* Inter-character priority. Give this to any
+ * remaining glyphs. */
+ NullPriority = 3 /* Null priority. You should set this priority for
+ * glyphs that only participate in justification
+ * after the above priorities. Normally all glyphs
+ * have one of the previous three values. If you
+ * don't want a glyph to participate in justification,
+ * and you don't want to set its factors to zero,
+ * you may instead assign it to the null priority. */
+ };
+
+ protected:
+ Fixed beforeGrowLimit;/* The ratio by which the advance width of the
+ * glyph is permitted to grow on the left or top side. */
+ Fixed beforeShrinkLimit;
+ /* The ratio by which the advance width of the
+ * glyph is permitted to shrink on the left or top side. */
+ Fixed afterGrowLimit; /* The ratio by which the advance width of the glyph
+ * is permitted to shrink on the left or top side. */
+ Fixed afterShrinkLimit;
+ /* The ratio by which the advance width of the glyph
+ * is at most permitted to shrink on the right or
+ * bottom side. */
+ HBUINT16 growFlags; /* Flags controlling the grow case. */
+ HBUINT16 shrinkFlags; /* Flags controlling the shrink case. */
+
+ public:
+ DEFINE_SIZE_STATIC (20);
+};
+
+struct WidthDeltaPair
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT32 justClass; /* The justification category associated
+ * with the wdRecord field. Only 7 bits of
+ * this field are used. (The other bits are
+ * used as padding to guarantee longword
+ * alignment of the following record). */
+ JustWidthDeltaEntry
+ wdRecord; /* The actual width delta record. */
+
+ public:
+ DEFINE_SIZE_STATIC (24);
+};
+
+typedef OT::LArrayOf<WidthDeltaPair> WidthDeltaCluster;
+
+struct JustificationCategory
+{
+ typedef void EntryData;
+
+ enum Flags
+ {
+ SetMark =0x8000,/* If set, make the current glyph the marked
+ * glyph. */
+ DontAdvance =0x4000,/* If set, don't advance to the next glyph before
+ * going to the new state. */
+ MarkCategory =0x3F80,/* The justification category for the marked
+ * glyph if nonzero. */
+ CurrentCategory =0x007F /* The justification category for the current
+ * glyph if nonzero. */
+ };
+
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ morphHeader.sanitize (c) &&
+ stHeader.sanitize (c)));
+ }
+
+ protected:
+ ChainSubtable<ObsoleteTypes>
+ morphHeader; /* Metamorphosis-style subtable header. */
+ StateTable<ObsoleteTypes, EntryData>
+ stHeader; /* The justification insertion state table header */
+ public:
+ DEFINE_SIZE_STATIC (30);
+};
+
+struct JustificationHeader
+{
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ justClassTable.sanitize (c, base, base) &&
+ wdcTable.sanitize (c, base) &&
+ pcTable.sanitize (c, base) &&
+ lookupTable.sanitize (c, base)));
+ }
+
+ protected:
+ OffsetTo<JustificationCategory>
+ justClassTable; /* Offset to the justification category state table. */
+ OffsetTo<WidthDeltaCluster>
+ wdcTable; /* Offset from start of justification table to start
+ * of the subtable containing the width delta factors
+ * for the glyphs in your font.
+ *
+ * The width delta clusters table. */
+ OffsetTo<PostcompensationActionChain>
+ pcTable; /* Offset from start of justification table to start
+ * of postcompensation subtable (set to zero if none).
+ *
+ * The postcompensation subtable, if present in the font. */
+ Lookup<OffsetTo<WidthDeltaCluster> >
+ lookupTable; /* Lookup table associating glyphs with width delta
+ * clusters. See the description of Width Delta Clusters
+ * table for details on how to interpret the lookup values. */
+
+ public:
+ DEFINE_SIZE_MIN (8);
+};
+
+struct just
+{
+ static const hb_tag_t tableTag = HB_AAT_TAG_just;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+
+ return_trace (likely (c->check_struct (this) &&
+ version.major == 1 &&
+ horizData.sanitize (c, this, this) &&
+ vertData.sanitize (c, this, this)));
+ }
+
+ protected:
+ FixedVersion<>version; /* Version of the justification table
+ * (0x00010000u for version 1.0). */
+ HBUINT16 format; /* Format of the justification table (set to 0). */
+ OffsetTo<JustificationHeader>
+ horizData; /* Byte offset from the start of the justification table
+ * to the header for tables that contain justification
+ * information for horizontal text.
+ * If you are not including this information,
+ * store 0. */
+ OffsetTo<JustificationHeader>
+ vertData; /* ditto, vertical */
+
+ public:
+ DEFINE_SIZE_STATIC (10);
+};
+
+} /* namespace AAT */
+
+
+#endif /* HB_AAT_LAYOUT_JUST_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-kerx-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-kerx-table.hh
index 615a8f8d4c3..7caf45d5dd1 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-kerx-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-kerx-table.hh
@@ -28,8 +28,7 @@
#ifndef HB_AAT_LAYOUT_KERX_TABLE_HH
#define HB_AAT_LAYOUT_KERX_TABLE_HH
-#include "hb-open-type.hh"
-#include "hb-aat-layout-common.hh"
+#include "hb-kern.hh"
#include "hb-aat-layout-ankr-table.hh"
/*
@@ -44,12 +43,43 @@ namespace AAT {
using namespace OT;
-struct KerxFormat0Records
+static inline int
+kerxTupleKern (int value,
+ unsigned int tupleCount,
+ const void *base,
+ hb_aat_apply_context_t *c)
{
+ if (likely (!tupleCount || !c)) return value;
+
+ unsigned int offset = value;
+ const FWORD *pv = &StructAtOffset<FWORD> (base, offset);
+ if (unlikely (!c->sanitizer.check_array (pv, tupleCount))) return 0;
+ return *pv;
+}
+
+
+struct hb_glyph_pair_t
+{
+ hb_codepoint_t left;
+ hb_codepoint_t right;
+};
+
+struct KernPair
+{
+ inline int get_kerning (void) const
+ { return value; }
+
+ inline int cmp (const hb_glyph_pair_t &o) const
+ {
+ int ret = left.cmp (o.left);
+ if (ret) return ret;
+ return right.cmp (o.right);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this)));
+ return_trace (c->check_struct (this));
}
protected:
@@ -60,286 +90,921 @@ struct KerxFormat0Records
DEFINE_SIZE_STATIC (6);
};
+template <typename KernSubTableHeader>
struct KerxSubTableFormat0
{
- // TODO(ebraminio) Enable when we got suitable BinSearchArrayOf
- // inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
- // {
- // hb_glyph_pair_t pair = {left, right};
- // int i = pairs.bsearch (pair);
- // if (i == -1)
- // return 0;
- // return pairs[i].get_kerning ();
- // }
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
+ hb_aat_apply_context_t *c = nullptr) const
+ {
+ hb_glyph_pair_t pair = {left, right};
+ int v = pairs.bsearch (pair).get_kerning ();
+ return kerxTupleKern (v, header.tuple_count (), this, c);
+ }
+
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+
+ if (!c->plan->requested_kerning)
+ return false;
+
+ if (header.coverage & header.Backwards)
+ return false;
+
+ accelerator_t accel (*this, c);
+ hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
+ machine.kern (c->font, c->buffer, c->plan->kern_mask);
+
+ return_trace (true);
+ }
+
+ struct accelerator_t
+ {
+ const KerxSubTableFormat0 &table;
+ hb_aat_apply_context_t *c;
+
+ inline accelerator_t (const KerxSubTableFormat0 &table_,
+ hb_aat_apply_context_t *c_) :
+ table (table_), c (c_) {}
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return table.get_kerning (left, right, c); }
+ };
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- recordsZ.sanitize (c, nPairs)));
+ return_trace (likely (pairs.sanitize (c)));
}
protected:
- // TODO(ebraminio): A custom version of "BinSearchArrayOf<KerxPair> pairs;" is
- // needed here to use HBUINT32 instead
- HBUINT32 nPairs; /* The number of kerning pairs in this subtable */
- HBUINT32 searchRange; /* The largest power of two less than or equal to the value of nPairs,
- * multiplied by the size in bytes of an entry in the subtable. */
- HBUINT32 entrySelector; /* This is calculated as log2 of the largest power of two less
- * than or equal to the value of nPairs. */
- HBUINT32 rangeShift; /* The value of nPairs minus the largest power of two less than or equal to nPairs. */
- UnsizedArrayOf<KerxFormat0Records>
- recordsZ; /* VAR=nPairs */
+ KernSubTableHeader header;
+ BinSearchArrayOf<KernPair, typename KernSubTableHeader::Types::HBUINT>
+ pairs; /* Sorted kern records. */
public:
- DEFINE_SIZE_ARRAY (16, recordsZ);
+ DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 16, pairs);
};
-struct KerxSubTableFormat1
+
+template <bool extended>
+struct Format1Entry;
+
+template <>
+struct Format1Entry<true>
{
- inline bool sanitize (hb_sanitize_context_t *c) const
+ enum Flags
{
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- stateHeader.sanitize (c)));
- }
+ Push = 0x8000, /* If set, push this glyph on the kerning stack. */
+ DontAdvance = 0x4000, /* If set, don't advance to the next glyph
+ * before going to the new state. */
+ Reset = 0x2000, /* If set, reset the kerning data (clear the stack) */
+ Reserved = 0x1FFF, /* Not used; set to 0. */
+ };
+
+ struct EntryData
+ {
+ HBUINT16 kernActionIndex;/* Index into the kerning value array. If
+ * this index is 0xFFFF, then no kerning
+ * is to be performed. */
+ public:
+ DEFINE_SIZE_STATIC (2);
+ };
+
+ static inline bool performAction (const Entry<EntryData> *entry)
+ { return entry->data.kernActionIndex != 0xFFFF; }
+
+ static inline unsigned int kernActionIndex (const Entry<EntryData> *entry)
+ { return entry->data.kernActionIndex; }
+};
+template <>
+struct Format1Entry<false>
+{
+ enum Flags
+ {
+ Push = 0x8000, /* If set, push this glyph on the kerning stack. */
+ DontAdvance = 0x4000, /* If set, don't advance to the next glyph
+ * before going to the new state. */
+ Offset = 0x3FFF, /* Byte offset from beginning of subtable to the
+ * value table for the glyphs on the kerning stack. */
- protected:
- StateTable<HBUINT16> stateHeader;
- LOffsetTo<ArrayOf<HBUINT16> > valueTable;
- public:
- DEFINE_SIZE_STATIC (20);
+ Reset = 0x0000, /* Not supported? */
+ };
+
+ typedef void EntryData;
+
+ static inline bool performAction (const Entry<EntryData> *entry)
+ { return entry->flags & Offset; }
+
+ static inline unsigned int kernActionIndex (const Entry<EntryData> *entry)
+ { return entry->flags & Offset; }
};
-// TODO(ebraminio): Maybe this can be replaced with Lookup<HBUINT16>?
-struct KerxClassTable
+template <typename KernSubTableHeader>
+struct KerxSubTableFormat1
{
- inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; }
+ typedef typename KernSubTableHeader::Types Types;
+ typedef typename Types::HBUINT HBUINT;
+
+ typedef Format1Entry<Types::extended> Format1EntryT;
+ typedef typename Format1EntryT::EntryData EntryData;
+
+ struct driver_context_t
+ {
+ static const bool in_place = true;
+ enum
+ {
+ DontAdvance = Format1EntryT::DontAdvance,
+ };
+
+ inline driver_context_t (const KerxSubTableFormat1 *table_,
+ hb_aat_apply_context_t *c_) :
+ c (c_),
+ table (table_),
+ /* Apparently the offset kernAction is from the beginning of the state-machine,
+ * similar to offsets in morx table, NOT from beginning of this table, like
+ * other subtables in kerx. Discovered via testing. */
+ kernAction (&table->machine + table->kernAction),
+ depth (0),
+ crossStream (table->header.coverage & table->header.CrossStream) {}
+
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
+ const Entry<EntryData> *entry)
+ {
+ return Format1EntryT::performAction (entry);
+ }
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
+ const Entry<EntryData> *entry)
+ {
+ hb_buffer_t *buffer = driver->buffer;
+ unsigned int flags = entry->flags;
+
+ if (flags & Format1EntryT::Reset)
+ depth = 0;
+
+ if (flags & Format1EntryT::Push)
+ {
+ if (likely (depth < ARRAY_LENGTH (stack)))
+ stack[depth++] = buffer->idx;
+ else
+ depth = 0; /* Probably not what CoreText does, but better? */
+ }
+
+ if (Format1EntryT::performAction (entry) && depth)
+ {
+ unsigned int tuple_count = MAX (1u, table->header.tuple_count ());
+
+ unsigned int kern_idx = Format1EntryT::kernActionIndex (entry);
+ kern_idx = Types::byteOffsetToIndex (kern_idx, &table->machine, kernAction.arrayZ);
+ const FWORD *actions = &kernAction[kern_idx];
+ if (!c->sanitizer.check_array (actions, depth, tuple_count))
+ {
+ depth = 0;
+ return false;
+ }
+
+ hb_mask_t kern_mask = c->plan->kern_mask;
+
+ /* From Apple 'kern' spec:
+ * "Each pops one glyph from the kerning stack and applies the kerning value to it.
+ * The end of the list is marked by an odd value... */
+ bool last = false;
+ while (!last && depth)
+ {
+ unsigned int idx = stack[--depth];
+ int v = *actions;
+ actions += tuple_count;
+ if (idx >= buffer->len) continue;
+
+ /* "The end of the list is marked by an odd value..." */
+ last = v & 1;
+ v &= ~1;
+
+ hb_glyph_position_t &o = buffer->pos[idx];
+
+ /* Testing shows that CoreText only applies kern (cross-stream or not)
+ * if none has been applied by previous subtables. That is, it does
+ * NOT seem to accumulate as otherwise implied by specs. */
+
+ /* The following flag is undocumented in the spec, but described
+ * in the 'kern' table example. */
+ if (v == -0x8000)
+ {
+ o.attach_type() = ATTACH_TYPE_NONE;
+ o.attach_chain() = 0;
+ o.x_offset = o.y_offset = 0;
+ }
+ else if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
+ {
+ if (crossStream)
+ {
+ if (buffer->pos[idx].attach_type() && !buffer->pos[idx].y_offset)
+ {
+ o.y_offset = c->font->em_scale_y (v);
+ buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
+ }
+ }
+ else if (buffer->info[idx].mask & kern_mask)
+ {
+ if (!buffer->pos[idx].x_offset)
+ {
+ buffer->pos[idx].x_advance += c->font->em_scale_x (v);
+ buffer->pos[idx].x_offset += c->font->em_scale_x (v);
+ }
+ }
+ }
+ else
+ {
+ if (crossStream)
+ {
+ /* CoreText doesn't do crossStream kerning in vertical. We do. */
+ if (buffer->pos[idx].attach_type() && !buffer->pos[idx].x_offset)
+ {
+ o.x_offset = c->font->em_scale_x (v);
+ buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
+ }
+ }
+ else if (buffer->info[idx].mask & kern_mask)
+ {
+ if (!buffer->pos[idx].y_offset)
+ {
+ buffer->pos[idx].y_advance += c->font->em_scale_y (v);
+ buffer->pos[idx].y_offset += c->font->em_scale_y (v);
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private:
+ hb_aat_apply_context_t *c;
+ const KerxSubTableFormat1 *table;
+ const UnsizedArrayOf<FWORD> &kernAction;
+ unsigned int stack[8];
+ unsigned int depth;
+ bool crossStream;
+ };
+
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+
+ if (!c->plan->requested_kerning &&
+ !(header.coverage & header.CrossStream))
+ return false;
+
+ driver_context_t dc (this, c);
+
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
+ driver.drive (&dc);
+
+ return_trace (true);
+ }
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely (firstGlyph.sanitize (c) &&
- classes.sanitize (c)));
+ /* The rest of array sanitizations are done at run-time. */
+ return_trace (likely (c->check_struct (this) &&
+ machine.sanitize (c)));
}
protected:
- HBUINT16 firstGlyph; /* First glyph in class range. */
- ArrayOf<HBUINT16> classes; /* Glyph classes. */
+ KernSubTableHeader header;
+ StateTable<Types, EntryData> machine;
+ OffsetTo<UnsizedArrayOf<FWORD>, HBUINT, false>kernAction;
public:
- DEFINE_SIZE_ARRAY (4, classes);
+ DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 5 * sizeof (HBUINT));
};
+template <typename KernSubTableHeader>
struct KerxSubTableFormat2
{
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
- {
- unsigned int l = (this+leftClassTable).get_class (left);
- unsigned int r = (this+leftClassTable).get_class (left);
- unsigned int offset = l * rowWidth + r * sizeof (FWORD);
- const FWORD *arr = &(this+array);
- if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
- return 0;
- const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
- if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
- return 0;
- return *v;
+ typedef typename KernSubTableHeader::Types Types;
+ typedef typename Types::HBUINT HBUINT;
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
+ hb_aat_apply_context_t *c) const
+ {
+ unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
+ unsigned int l = (this+leftClassTable).get_class (left, num_glyphs, 0);
+ unsigned int r = (this+rightClassTable).get_class (right, num_glyphs, 0);
+
+ const UnsizedArrayOf<FWORD> &arrayZ = this+array;
+ unsigned int kern_idx = l + r;
+ kern_idx = Types::offsetToIndex (kern_idx, this, &arrayZ);
+ const FWORD *v = &arrayZ[kern_idx];
+ if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
+
+ return kerxTupleKern (*v, header.tuple_count (), this, c);
+ }
+
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+
+ if (!c->plan->requested_kerning)
+ return false;
+
+ if (header.coverage & header.Backwards)
+ return false;
+
+ accelerator_t accel (*this, c);
+ hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
+ machine.kern (c->font, c->buffer, c->plan->kern_mask);
+
+ return_trace (true);
}
+ struct accelerator_t
+ {
+ const KerxSubTableFormat2 &table;
+ hb_aat_apply_context_t *c;
+
+ inline accelerator_t (const KerxSubTableFormat2 &table_,
+ hb_aat_apply_context_t *c_) :
+ table (table_), c (c_) {}
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return table.get_kerning (left, right, c); }
+ };
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- rowWidth.sanitize (c) &&
leftClassTable.sanitize (c, this) &&
rightClassTable.sanitize (c, this) &&
- array.sanitize (c, this)));
+ c->check_range (this, array)));
}
protected:
- HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */
- LOffsetTo<KerxClassTable>
- leftClassTable; /* Offset from beginning of this subtable to
- * left-hand class table. */
- LOffsetTo<KerxClassTable>
- rightClassTable;/* Offset from beginning of this subtable to
- * right-hand class table. */
- LOffsetTo<FWORD>
- array; /* Offset from beginning of this subtable to
- * the start of the kerning array. */
+ KernSubTableHeader header;
+ HBUINT rowWidth; /* The width, in bytes, of a row in the table. */
+ OffsetTo<typename Types::ClassTypeWide, HBUINT, false>
+ leftClassTable; /* Offset from beginning of this subtable to
+ * left-hand class table. */
+ OffsetTo<typename Types::ClassTypeWide, HBUINT, false>
+ rightClassTable;/* Offset from beginning of this subtable to
+ * right-hand class table. */
+ OffsetTo<UnsizedArrayOf<FWORD>, HBUINT, false>
+ array; /* Offset from beginning of this subtable to
+ * the start of the kerning array. */
public:
- DEFINE_SIZE_STATIC (16);
+ DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 4 * sizeof (HBUINT));
};
+template <typename KernSubTableHeader>
struct KerxSubTableFormat4
{
+ typedef ExtendedTypes Types;
+
+ struct EntryData
+ {
+ HBUINT16 ankrActionIndex;/* Either 0xFFFF (for no action) or the index of
+ * the action to perform. */
+ public:
+ DEFINE_SIZE_STATIC (2);
+ };
+
+ struct driver_context_t
+ {
+ static const bool in_place = true;
+ enum Flags
+ {
+ Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */
+ DontAdvance = 0x4000, /* If set, don't advance to the next glyph before
+ * going to the new state. */
+ Reserved = 0x3FFF, /* Not used; set to 0. */
+ };
+
+ enum SubTableFlags
+ {
+ ActionType = 0xC0000000, /* A two-bit field containing the action type. */
+ Unused = 0x3F000000, /* Unused - must be zero. */
+ Offset = 0x00FFFFFF, /* Masks the offset in bytes from the beginning
+ * of the subtable to the beginning of the control
+ * point table. */
+ };
+
+ inline driver_context_t (const KerxSubTableFormat4 *table,
+ hb_aat_apply_context_t *c_) :
+ c (c_),
+ action_type ((table->flags & ActionType) >> 30),
+ ankrData ((HBUINT16 *) ((const char *) &table->machine + (table->flags & Offset))),
+ mark_set (false),
+ mark (0) {}
+
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
+ const Entry<EntryData> *entry)
+ {
+ return entry->data.ankrActionIndex != 0xFFFF;
+ }
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
+ const Entry<EntryData> *entry)
+ {
+ hb_buffer_t *buffer = driver->buffer;
+
+ if (mark_set && entry->data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len)
+ {
+ hb_glyph_position_t &o = buffer->cur_pos();
+ switch (action_type)
+ {
+ case 0: /* Control Point Actions.*/
+ {
+ /* indexed into glyph outline. */
+ const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex];
+ if (!c->sanitizer.check_array (data, 2))
+ return false;
+ HB_UNUSED unsigned int markControlPoint = *data++;
+ HB_UNUSED unsigned int currControlPoint = *data++;
+ hb_position_t markX = 0;
+ hb_position_t markY = 0;
+ hb_position_t currX = 0;
+ hb_position_t currY = 0;
+ if (!c->font->get_glyph_contour_point_for_origin (c->buffer->info[mark].codepoint,
+ markControlPoint,
+ HB_DIRECTION_LTR /*XXX*/,
+ &markX, &markY) ||
+ !c->font->get_glyph_contour_point_for_origin (c->buffer->cur ().codepoint,
+ currControlPoint,
+ HB_DIRECTION_LTR /*XXX*/,
+ &currX, &currY))
+ return true; /* True, such that the machine continues. */
+
+ o.x_offset = markX - currX;
+ o.y_offset = markY - currY;
+ }
+ break;
+
+ case 1: /* Anchor Point Actions. */
+ {
+ /* Indexed into 'ankr' table. */
+ const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex];
+ if (!c->sanitizer.check_array (data, 2))
+ return false;
+ unsigned int markAnchorPoint = *data++;
+ unsigned int currAnchorPoint = *data++;
+ const Anchor markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint,
+ markAnchorPoint,
+ c->sanitizer.get_num_glyphs (),
+ c->ankr_end);
+ const Anchor currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint,
+ currAnchorPoint,
+ c->sanitizer.get_num_glyphs (),
+ c->ankr_end);
+
+ o.x_offset = c->font->em_scale_x (markAnchor.xCoordinate) - c->font->em_scale_x (currAnchor.xCoordinate);
+ o.y_offset = c->font->em_scale_y (markAnchor.yCoordinate) - c->font->em_scale_y (currAnchor.yCoordinate);
+ }
+ break;
+
+ case 2: /* Control Point Coordinate Actions. */
+ {
+ const FWORD *data = (const FWORD *) &ankrData[entry->data.ankrActionIndex];
+ if (!c->sanitizer.check_array (data, 4))
+ return false;
+ int markX = *data++;
+ int markY = *data++;
+ int currX = *data++;
+ int currY = *data++;
+
+ o.x_offset = c->font->em_scale_x (markX) - c->font->em_scale_x (currX);
+ o.y_offset = c->font->em_scale_y (markY) - c->font->em_scale_y (currY);
+ }
+ break;
+ }
+ o.attach_type() = ATTACH_TYPE_MARK;
+ o.attach_chain() = (int) mark - (int) buffer->idx;
+ buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
+ }
+
+ if (entry->flags & Mark)
+ {
+ mark_set = true;
+ mark = buffer->idx;
+ }
+
+ return true;
+ }
+
+ private:
+ hb_aat_apply_context_t *c;
+ unsigned int action_type;
+ const HBUINT16 *ankrData;
+ bool mark_set;
+ unsigned int mark;
+ };
+
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+
+ driver_context_t dc (this, c);
+
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
+ driver.drive (&dc);
+
+ return_trace (true);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
+ /* The rest of array sanitizations are done at run-time. */
return_trace (likely (c->check_struct (this) &&
- rowWidth.sanitize (c) &&
- leftClassTable.sanitize (c, this) &&
- rightClassTable.sanitize (c, this) &&
- array.sanitize (c, this)));
+ machine.sanitize (c)));
}
protected:
- HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */
- LOffsetTo<KerxClassTable>
- leftClassTable; /* Offset from beginning of this subtable to
- * left-hand class table. */
- LOffsetTo<KerxClassTable>
- rightClassTable;/* Offset from beginning of this subtable to
- * right-hand class table. */
- LOffsetTo<FWORD>
- array; /* Offset from beginning of this subtable to
- * the start of the kerning array. */
+ KernSubTableHeader header;
+ StateTable<Types, EntryData> machine;
+ HBUINT32 flags;
public:
- DEFINE_SIZE_STATIC (16);
+ DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 20);
};
+template <typename KernSubTableHeader>
struct KerxSubTableFormat6
{
+ enum Flags
+ {
+ ValuesAreLong = 0x00000001,
+ };
+
+ inline bool is_long (void) const { return flags & ValuesAreLong; }
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
+ hb_aat_apply_context_t *c) const
+ {
+ unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
+ if (is_long ())
+ {
+ const typename U::Long &t = u.l;
+ unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
+ unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
+ unsigned int offset = l + r;
+ if (unlikely (offset < l)) return 0; /* Addition overflow. */
+ if (unlikely (hb_unsigned_mul_overflows (offset, sizeof (FWORD32)))) return 0;
+ const FWORD32 *v = &StructAtOffset<FWORD32> (&(this+t.array), offset * sizeof (FWORD32));
+ if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
+ return kerxTupleKern (*v, header.tuple_count (), &(this+vector), c);
+ }
+ else
+ {
+ const typename U::Short &t = u.s;
+ unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
+ unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
+ unsigned int offset = l + r;
+ const FWORD *v = &StructAtOffset<FWORD> (&(this+t.array), offset * sizeof (FWORD));
+ if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
+ return kerxTupleKern (*v, header.tuple_count (), &(this+vector), c);
+ }
+ }
+
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+
+ if (!c->plan->requested_kerning)
+ return false;
+
+ if (header.coverage & header.Backwards)
+ return false;
+
+ accelerator_t accel (*this, c);
+ hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
+ machine.kern (c->font, c->buffer, c->plan->kern_mask);
+
+ return_trace (true);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- rowIndexTable.sanitize (c, this) &&
- columnIndexTable.sanitize (c, this) &&
- kerningArray.sanitize (c, this) &&
- kerningVector.sanitize (c, this)));
+ (is_long () ?
+ (
+ u.l.rowIndexTable.sanitize (c, this) &&
+ u.l.columnIndexTable.sanitize (c, this) &&
+ c->check_range (this, u.l.array)
+ ) : (
+ u.s.rowIndexTable.sanitize (c, this) &&
+ u.s.columnIndexTable.sanitize (c, this) &&
+ c->check_range (this, u.s.array)
+ )) &&
+ (header.tuple_count () == 0 ||
+ c->check_range (this, vector))));
}
+ struct accelerator_t
+ {
+ const KerxSubTableFormat6 &table;
+ hb_aat_apply_context_t *c;
+
+ inline accelerator_t (const KerxSubTableFormat6 &table_,
+ hb_aat_apply_context_t *c_) :
+ table (table_), c (c_) {}
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return table.get_kerning (left, right, c); }
+ };
+
protected:
- HBUINT32 flags;
- HBUINT16 rowCount;
- HBUINT16 columnCount;
- LOffsetTo<Lookup<HBUINT16> > rowIndexTable;
- LOffsetTo<Lookup<HBUINT16> > columnIndexTable;
- LOffsetTo<Lookup<HBUINT16> > kerningArray;
- LOffsetTo<Lookup<HBUINT16> > kerningVector;
+ KernSubTableHeader header;
+ HBUINT32 flags;
+ HBUINT16 rowCount;
+ HBUINT16 columnCount;
+ union U
+ {
+ struct Long
+ {
+ LOffsetTo<Lookup<HBUINT32>, false> rowIndexTable;
+ LOffsetTo<Lookup<HBUINT32>, false> columnIndexTable;
+ LOffsetTo<UnsizedArrayOf<FWORD32>, false> array;
+ } l;
+ struct Short
+ {
+ LOffsetTo<Lookup<HBUINT16>, false> rowIndexTable;
+ LOffsetTo<Lookup<HBUINT16>, false> columnIndexTable;
+ LOffsetTo<UnsizedArrayOf<FWORD>, false> array;
+ } s;
+ } u;
+ LOffsetTo<UnsizedArrayOf<FWORD>, false> vector;
public:
- DEFINE_SIZE_STATIC (24);
+ DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24);
};
-enum coverage_flags_t
+
+struct KerxSubTableHeader
{
- COVERAGE_VERTICAL_FLAG = 0x80u,
- COVERAGE_CROSSSTREAM_FLAG = 0x40u,
- COVERAGE_VARIATION_FLAG = 0x20u,
- COVERAGE_PROCESS_DIRECTION = 0x10u,
+ typedef ExtendedTypes Types;
+
+ inline unsigned int tuple_count (void) const { return tupleCount; }
+ inline bool is_horizontal (void) const { return !(coverage & Vertical); }
+
+ enum Coverage
+ {
+ Vertical = 0x80000000u, /* Set if table has vertical kerning values. */
+ CrossStream = 0x40000000u, /* Set if table has cross-stream kerning values. */
+ Variation = 0x20000000u, /* Set if table has variation kerning values. */
+ Backwards = 0x10000000u, /* If clear, process the glyphs forwards, that
+ * is, from first to last in the glyph stream.
+ * If we, process them from last to first.
+ * This flag only applies to state-table based
+ * 'kerx' subtables (types 1 and 4). */
+ Reserved = 0x0FFFFF00u, /* Reserved, set to zero. */
+ SubtableType= 0x000000FFu, /* Subtable type. */
+ };
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ public:
+ HBUINT32 length;
+ HBUINT32 coverage;
+ HBUINT32 tupleCount;
+ public:
+ DEFINE_SIZE_STATIC (12);
};
-struct KerxTable
+struct KerxSubTable
{
- inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const
+ friend struct kerx;
+
+ inline unsigned int get_size (void) const { return u.header.length; }
+ inline unsigned int get_type (void) const { return u.header.coverage & u.header.SubtableType; }
+
+ template <typename context_t>
+ inline typename context_t::return_t dispatch (context_t *c) const
{
- TRACE_APPLY (this);
- /* TODO */
- return_trace (false);
+ unsigned int subtable_type = get_type ();
+ TRACE_DISPATCH (this, subtable_type);
+ switch (subtable_type) {
+ case 0: return_trace (c->dispatch (u.format0));
+ case 1: return_trace (c->dispatch (u.format1));
+ case 2: return_trace (c->dispatch (u.format2));
+ case 4: return_trace (c->dispatch (u.format4));
+ case 6: return_trace (c->dispatch (u.format6));
+ default: return_trace (c->default_return_value ());
+ }
}
- inline unsigned int get_size (void) const { return length; }
-
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (unlikely (!c->check_struct (this)))
+ if (!u.header.sanitize (c) ||
+ u.header.length <= u.header.static_size ||
+ !c->check_range (this, u.header.length))
return_trace (false);
- switch (format) {
- case 0: return u.format0.sanitize (c);
- case 1: return u.format1.sanitize (c);
- case 2: return u.format2.sanitize (c);
- case 4: return u.format4.sanitize (c);
- case 6: return u.format6.sanitize (c);
- default:return_trace (false);
- }
+ return_trace (dispatch (c));
}
-protected:
- HBUINT32 length;
- HBUINT8 coverage;
- HBUINT16 unused;
- HBUINT8 format;
- HBUINT32 tupleIndex;
+ public:
union {
- KerxSubTableFormat0 format0;
- KerxSubTableFormat1 format1;
- KerxSubTableFormat2 format2;
- KerxSubTableFormat4 format4;
- KerxSubTableFormat6 format6;
+ KerxSubTableHeader header;
+ KerxSubTableFormat0<KerxSubTableHeader> format0;
+ KerxSubTableFormat1<KerxSubTableHeader> format1;
+ KerxSubTableFormat2<KerxSubTableHeader> format2;
+ KerxSubTableFormat4<KerxSubTableHeader> format4;
+ KerxSubTableFormat6<KerxSubTableHeader> format6;
} u;
-public:
+ public:
DEFINE_SIZE_MIN (12);
};
-struct SubtableGlyphCoverageArray
+
+/*
+ * The 'kerx' Table
+ */
+
+template <typename T>
+struct KerxTable
{
- inline bool sanitize (hb_sanitize_context_t *c) const
+ /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
+ inline const T* thiz (void) const { return static_cast<const T *> (this); }
+
+ inline bool has_state_machine (void) const
{
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this)));
+ typedef typename T::SubTable SubTable;
+
+ const SubTable *st = &thiz()->firstSubTable;
+ unsigned int count = thiz()->tableCount;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (st->get_type () == 1)
+ return true;
+ st = &StructAfter<SubTable> (*st);
+ }
+ return false;
}
- protected:
- HBUINT32 length;
- HBUINT32 coverage;
- HBUINT32 tupleCount;
- public:
- DEFINE_SIZE_STATIC (12);
-};
+ inline bool has_cross_stream (void) const
+ {
+ typedef typename T::SubTable SubTable;
-struct kerx
-{
- static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
+ const SubTable *st = &thiz()->firstSubTable;
+ unsigned int count = thiz()->tableCount;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (st->u.header.coverage & st->u.header.CrossStream)
+ return true;
+ st = &StructAfter<SubTable> (*st);
+ }
+ return false;
+ }
- inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- TRACE_APPLY (this);
- const KerxTable &table = StructAfter<KerxTable> (*this);
- return_trace (table.apply (c, ankr));
+ typedef typename T::SubTable SubTable;
+
+ int v = 0;
+ const SubTable *st = &thiz()->firstSubTable;
+ unsigned int count = thiz()->tableCount;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) ||
+ !st->u.header.is_horizontal ())
+ continue;
+ v += st->get_kerning (left, right);
+ st = &StructAfter<SubTable> (*st);
+ }
+ return v;
+ }
+
+ inline bool apply (AAT::hb_aat_apply_context_t *c) const
+ {
+ typedef typename T::SubTable SubTable;
+
+ bool ret = false;
+ bool seenCrossStream = false;
+ c->set_lookup_index (0);
+ const SubTable *st = &thiz()->firstSubTable;
+ unsigned int count = thiz()->tableCount;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ bool reverse;
+
+ if (!T::Types::extended && (st->u.header.coverage & st->u.header.Variation))
+ goto skip;
+
+ if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ())
+ goto skip;
+
+ reverse = bool (st->u.header.coverage & st->u.header.Backwards) !=
+ HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
+
+ if (!c->buffer->message (c->font, "start %c%c%c%c subtable %d", HB_UNTAG (thiz()->tableTag), c->lookup_index))
+ goto skip;
+
+ if (!seenCrossStream &&
+ (st->u.header.coverage & st->u.header.CrossStream))
+ {
+ /* Attach all glyphs into a chain. */
+ seenCrossStream = true;
+ hb_glyph_position_t *pos = c->buffer->pos;
+ unsigned int count = c->buffer->len;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ pos[i].attach_type() = ATTACH_TYPE_CURSIVE;
+ pos[i].attach_chain() = HB_DIRECTION_IS_FORWARD (c->buffer->props.direction) ? -1 : +1;
+ /* We intentionally don't set HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT,
+ * since there needs to be a non-zero attachment for post-positioning to
+ * be needed. */
+ }
+ }
+
+ if (reverse)
+ c->buffer->reverse ();
+
+ {
+ /* See comment in sanitize() for conditional here. */
+ hb_sanitize_with_object_t with (&c->sanitizer, i < count - 1 ? st : (const SubTable *) nullptr);
+ ret |= st->dispatch (c);
+ }
+
+ if (reverse)
+ c->buffer->reverse ();
+
+ (void) c->buffer->message (c->font, "end %c%c%c%c subtable %d", HB_UNTAG (thiz()->tableTag), c->lookup_index);
+
+ skip:
+ st = &StructAfter<SubTable> (*st);
+ c->set_lookup_index (c->lookup_index + 1);
+ }
+
+ return ret;
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (unlikely (!(c->check_struct (this))))
- return_trace (false);
-
- /* TODO: Something like `morx`s ChainSubtable should be done here instead */
- const KerxTable *table = &StructAfter<KerxTable> (*this);
- if (unlikely (!(table->sanitize (c))))
+ if (unlikely (!thiz()->version.sanitize (c) ||
+ thiz()->version < T::minVersion ||
+ !thiz()->tableCount.sanitize (c)))
return_trace (false);
- for (unsigned int i = 0; i < nTables - 1; ++i)
+ typedef typename T::SubTable SubTable;
+
+ const SubTable *st = &thiz()->firstSubTable;
+ unsigned int count = thiz()->tableCount;
+ for (unsigned int i = 0; i < count; i++)
{
- table = &StructAfter<KerxTable> (*table);
- if (unlikely (!(table->sanitize (c))))
- return_trace (false);
+ if (unlikely (!st->u.header.sanitize (c)))
+ return_trace (false);
+ /* OpenType kern table has 2-byte subtable lengths. That's limiting.
+ * MS implementation also only supports one subtable, of format 0,
+ * anyway. Certain versions of some fonts, like Calibry, contain
+ * kern subtable that exceeds 64kb. Looks like, the subtable length
+ * is simply ignored. Which makes sense. It's only needed if you
+ * have multiple subtables. To handle such fonts, we just ignore
+ * the length for the last subtable. */
+ hb_sanitize_with_object_t with (c, i < count - 1 ? st : (const SubTable *) nullptr);
+
+ if (unlikely (!st->sanitize (c)))
+ return_trace (false);
+
+ st = &StructAfter<SubTable> (*st);
}
- // If version is less than 3, we are done here; otherwise better to check footer also
- if (version < 3)
- return_trace (true);
-
- // TODO: Investigate why this just work on some fonts no matter of version
- // const SubtableGlyphCoverageArray &footer =
- // StructAfter<SubtableGlyphCoverageArray> (*table);
- // return_trace (footer.sanitize (c));
-
return_trace (true);
}
+};
+
+struct kerx : KerxTable<kerx>
+{
+ friend struct KerxTable<kerx>;
+
+ static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
+ static const uint16_t minVersion = 2;
+
+ typedef KerxSubTableHeader SubTableHeader;
+ typedef SubTableHeader::Types Types;
+ typedef KerxSubTable SubTable;
+
+ inline bool has_data (void) const { return version; }
protected:
- HBUINT16 version;
- HBUINT16 padding;
- HBUINT32 nTables;
-/*KerxTable tablesZ[VAR]; XXX ArrayOf??? */
-/*SubtableGlyphCoverageArray coverage_array;*/
+ HBUINT16 version; /* The version number of the extended kerning table
+ * (currently 2, 3, or 4). */
+ HBUINT16 unused; /* Set to 0. */
+ HBUINT32 tableCount; /* The number of subtables included in the extended kerning
+ * table. */
+ SubTable firstSubTable; /* Subtables. */
+/*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */
+
public:
- DEFINE_SIZE_STATIC (8);
+ DEFINE_SIZE_MIN (8);
};
+
} /* namespace AAT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-lcar-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-lcar-table.hh
new file mode 100644
index 00000000000..40d34f59bf0
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-lcar-table.hh
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+#ifndef HB_AAT_LAYOUT_LCAR_TABLE_HH
+#define HB_AAT_LAYOUT_LCAR_TABLE_HH
+
+#include "hb-open-type.hh"
+#include "hb-aat-layout-common.hh"
+
+/*
+ * lcar -- Ligature caret
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html
+ */
+#define HB_AAT_TAG_lcar HB_TAG('l','c','a','r')
+
+
+namespace AAT {
+
+typedef ArrayOf<HBINT16> LigCaretClassEntry;
+
+struct lcar
+{
+ static const hb_tag_t tableTag = HB_AAT_TAG_lcar;
+
+ inline unsigned int get_lig_carets (hb_font_t *font,
+ hb_direction_t direction,
+ hb_codepoint_t glyph,
+ unsigned int start_offset,
+ unsigned int *caret_count /* IN/OUT */,
+ hb_position_t *caret_array /* OUT */) const
+ {
+ const OffsetTo<LigCaretClassEntry>* entry_offset = lookup.get_value (glyph,
+ font->face->get_num_glyphs ());
+ const LigCaretClassEntry& array = entry_offset ? this+*entry_offset : Null (LigCaretClassEntry);
+ if (caret_count)
+ {
+ hb_array_t<const HBINT16> arr = array.sub_array (start_offset, caret_count);
+ unsigned int count = arr.len;
+ for (unsigned int i = 0; i < count; ++i)
+ switch (format)
+ {
+ case 0: caret_array[i] = font->em_scale_dir (arr[i], direction); break;
+ case 1:
+ hb_position_t x, y;
+ font->get_glyph_contour_point_for_origin (glyph, arr[i], direction, &x, &y);
+ caret_array[i] = HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
+ break;
+ }
+ }
+ return array.len;
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ version.major == 1 &&
+ lookup.sanitize (c, this)));
+ }
+
+ protected:
+ FixedVersion<>version; /* Version number of the ligature caret table */
+ HBUINT16 format; /* Format of the ligature caret table. */
+ Lookup<OffsetTo<LigCaretClassEntry> >
+ lookup; /* data Lookup table associating glyphs */
+
+ public:
+ DEFINE_SIZE_MIN (8);
+};
+
+} /* namespace AAT */
+
+#endif /* HB_AAT_LAYOUT_LCAR_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-morx-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-morx-table.hh
index 85f1f5794f7..171ee4a10b2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-morx-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-morx-table.hh
@@ -30,21 +30,26 @@
#include "hb-open-type.hh"
#include "hb-aat-layout-common.hh"
#include "hb-ot-layout-common.hh"
+#include "hb-aat-map.hh"
/*
* morx -- Extended Glyph Metamorphosis
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html
*/
#define HB_AAT_TAG_morx HB_TAG('m','o','r','x')
+#define HB_AAT_TAG_mort HB_TAG('m','o','r','t')
namespace AAT {
using namespace OT;
-
+template <typename Types>
struct RearrangementSubtable
{
+ typedef typename Types::HBUINT HBUINT;
+
typedef void EntryData;
struct driver_context_t
@@ -64,16 +69,16 @@ struct RearrangementSubtable
Verb = 0x000F, /* The type of rearrangement specified. */
};
- inline driver_context_t (const RearrangementSubtable *table) :
+ inline driver_context_t (const RearrangementSubtable *table HB_UNUSED) :
ret (false),
start (0), end (0) {}
- inline bool is_actionable (StateTableDriver<EntryData> *driver,
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry)
{
return (entry->flags & Verb) && start < end;
}
- inline bool transition (StateTableDriver<EntryData> *driver,
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry)
{
hb_buffer_t *buffer = driver->buffer;
@@ -164,7 +169,7 @@ struct RearrangementSubtable
driver_context_t dc (this);
- StateTableDriver<void> driver (machine, c->buffer, c->face);
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc);
return_trace (dc.ret);
@@ -177,13 +182,16 @@ struct RearrangementSubtable
}
protected:
- StateTable<EntryData> machine;
+ StateTable<Types, EntryData> machine;
public:
DEFINE_SIZE_STATIC (16);
};
+template <typename Types>
struct ContextualSubtable
{
+ typedef typename Types::HBUINT HBUINT;
+
struct EntryData
{
HBUINT16 markIndex; /* Index of the substitution table for the
@@ -205,13 +213,16 @@ struct ContextualSubtable
Reserved = 0x3FFF, /* These bits are reserved and should be set to 0. */
};
- inline driver_context_t (const ContextualSubtable *table) :
+ inline driver_context_t (const ContextualSubtable *table_,
+ hb_aat_apply_context_t *c_) :
ret (false),
+ c (c_),
mark_set (false),
mark (0),
+ table (table_),
subs (table+table->substitutionTables) {}
- inline bool is_actionable (StateTableDriver<EntryData> *driver,
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry)
{
hb_buffer_t *buffer = driver->buffer;
@@ -221,7 +232,7 @@ struct ContextualSubtable
return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF;
}
- inline bool transition (StateTableDriver<EntryData> *driver,
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry)
{
hb_buffer_t *buffer = driver->buffer;
@@ -231,30 +242,55 @@ struct ContextualSubtable
if (buffer->idx == buffer->len && !mark_set)
return true;
- if (entry->data.markIndex != 0xFFFF)
+ const GlyphID *replacement;
+
+ replacement = nullptr;
+ if (Types::extended)
{
- const Lookup<GlyphID> &lookup = subs[entry->data.markIndex];
- hb_glyph_info_t *info = buffer->info;
- const GlyphID *replacement = lookup.get_value (info[mark].codepoint, driver->num_glyphs);
- if (replacement)
+ if (entry->data.markIndex != 0xFFFF)
{
- buffer->unsafe_to_break (mark, MIN (buffer->idx + 1, buffer->len));
- info[mark].codepoint = *replacement;
- ret = true;
+ const Lookup<GlyphID> &lookup = subs[entry->data.markIndex];
+ replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs);
}
}
- if (entry->data.currentIndex != 0xFFFF)
+ else
+ {
+ unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint;
+ const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
+ replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
+ if (!replacement->sanitize (&c->sanitizer) || !*replacement)
+ replacement = nullptr;
+ }
+ if (replacement)
+ {
+ buffer->unsafe_to_break (mark, MIN (buffer->idx + 1, buffer->len));
+ buffer->info[mark].codepoint = *replacement;
+ ret = true;
+ }
+
+ replacement = nullptr;
+ unsigned int idx = MIN (buffer->idx, buffer->len - 1);
+ if (Types::extended)
{
- unsigned int idx = MIN (buffer->idx, buffer->len - 1);
- const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex];
- hb_glyph_info_t *info = buffer->info;
- const GlyphID *replacement = lookup.get_value (info[idx].codepoint, driver->num_glyphs);
- if (replacement)
+ if (entry->data.currentIndex != 0xFFFF)
{
- info[idx].codepoint = *replacement;
- ret = true;
+ const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex];
+ replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs);
}
}
+ else
+ {
+ unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint;
+ const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
+ replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
+ if (!replacement->sanitize (&c->sanitizer) || !*replacement)
+ replacement = nullptr;
+ }
+ if (replacement)
+ {
+ buffer->info[idx].codepoint = *replacement;
+ ret = true;
+ }
if (entry->flags & SetMark)
{
@@ -268,18 +304,20 @@ struct ContextualSubtable
public:
bool ret;
private:
+ hb_aat_apply_context_t *c;
bool mark_set;
unsigned int mark;
- const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32> &subs;
+ const ContextualSubtable *table;
+ const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false> &subs;
};
inline bool apply (hb_aat_apply_context_t *c) const
{
TRACE_APPLY (this);
- driver_context_t dc (this);
+ driver_context_t dc (this, c);
- StateTableDriver<EntryData> driver (machine, c->buffer, c->face);
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc);
return_trace (dc.ret);
@@ -292,6 +330,8 @@ struct ContextualSubtable
unsigned int num_entries = 0;
if (unlikely (!machine.sanitize (c, &num_entries))) return_trace (false);
+ if (!Types::extended) return_trace (true);
+
unsigned int num_lookups = 0;
const Entry<EntryData> *entries = machine.get_entries ();
@@ -309,16 +349,32 @@ struct ContextualSubtable
}
protected:
- StateTable<EntryData>
+ StateTable<Types, EntryData>
machine;
- LOffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, false>
+ OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false>, HBUINT, false>
substitutionTables;
public:
DEFINE_SIZE_STATIC (20);
};
-struct LigatureSubtable
+
+template <bool extended>
+struct LigatureEntry;
+
+template <>
+struct LigatureEntry<true>
{
+ enum Flags
+ {
+ SetComponent = 0x8000, /* Push this glyph onto the component stack for
+ * eventual processing. */
+ DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the
+ next iteration. */
+ PerformAction = 0x2000, /* Use the ligActionIndex to process a ligature
+ * group. */
+ Reserved = 0x1FFF, /* These bits are reserved and should be set to 0. */
+ };
+
struct EntryData
{
HBUINT16 ligActionIndex; /* Index to the first ligActionTable entry
@@ -328,18 +384,50 @@ struct LigatureSubtable
DEFINE_SIZE_STATIC (2);
};
+ static inline bool performAction (const Entry<EntryData> *entry)
+ { return entry->flags & PerformAction; }
+
+ static inline unsigned int ligActionIndex (const Entry<EntryData> *entry)
+ { return entry->data.ligActionIndex; }
+};
+template <>
+struct LigatureEntry<false>
+{
+ enum Flags
+ {
+ SetComponent = 0x8000, /* Push this glyph onto the component stack for
+ * eventual processing. */
+ DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the
+ next iteration. */
+ Offset = 0x3FFF, /* Byte offset from beginning of subtable to the
+ * ligature action list. This value must be a
+ * multiple of 4. */
+ };
+
+ typedef void EntryData;
+
+ static inline bool performAction (const Entry<EntryData> *entry)
+ { return entry->flags & Offset; }
+
+ static inline unsigned int ligActionIndex (const Entry<EntryData> *entry)
+ { return entry->flags & Offset; }
+};
+
+
+template <typename Types>
+struct LigatureSubtable
+{
+ typedef typename Types::HBUINT HBUINT;
+
+ typedef LigatureEntry<Types::extended> LigatureEntryT;
+ typedef typename LigatureEntryT::EntryData EntryData;
+
struct driver_context_t
{
static const bool in_place = false;
- enum Flags
+ enum
{
- SetComponent = 0x8000, /* Push this glyph onto the component stack for
- * eventual processing. */
- DontAdvance = 0x4000, /* Leave the glyph pointer at this glyph for the
- next iteration. */
- PerformAction = 0x2000, /* Use the ligActionIndex to process a ligature
- * group. */
- Reserved = 0x1FFF, /* These bits are reserved and should be set to 0. */
+ DontAdvance = LigatureEntryT::DontAdvance,
};
enum LigActionFlags
{
@@ -353,27 +441,28 @@ struct LigatureSubtable
* into the component table. */
};
- inline driver_context_t (const LigatureSubtable *table,
+ inline driver_context_t (const LigatureSubtable *table_,
hb_aat_apply_context_t *c_) :
ret (false),
c (c_),
+ table (table_),
ligAction (table+table->ligAction),
component (table+table->component),
ligature (table+table->ligature),
match_length (0) {}
- inline bool is_actionable (StateTableDriver<EntryData> *driver,
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry)
{
- return !!(entry->flags & PerformAction);
+ return LigatureEntryT::performAction (entry);
}
- inline bool transition (StateTableDriver<EntryData> *driver,
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry)
{
hb_buffer_t *buffer = driver->buffer;
- unsigned int flags = entry->flags;
- if (flags & SetComponent)
+ DEBUG_MSG (APPLY, nullptr, "Ligature transition at %u", buffer->idx);
+ if (entry->flags & LigatureEntryT::SetComponent)
{
if (unlikely (match_length >= ARRAY_LENGTH (match_positions)))
return false;
@@ -383,54 +472,81 @@ struct LigatureSubtable
match_length--;
match_positions[match_length++] = buffer->out_len;
+ DEBUG_MSG (APPLY, nullptr, "Set component at %u", buffer->out_len);
}
- if (flags & PerformAction)
+ if (LigatureEntryT::performAction (entry))
{
+ DEBUG_MSG (APPLY, nullptr, "Perform action with %u", match_length);
unsigned int end = buffer->out_len;
- unsigned int action_idx = entry->data.ligActionIndex;
- unsigned int action;
+
+ if (unlikely (!match_length))
+ return true;
+
+ if (buffer->idx >= buffer->len)
+ return false; // TODO Work on previous instead?
+
+ unsigned int cursor = match_length;
+
+ unsigned int action_idx = LigatureEntryT::ligActionIndex (entry);
+ action_idx = Types::offsetToIndex (action_idx, table, ligAction.arrayZ);
+ const HBUINT32 *actionData = &ligAction[action_idx];
+
unsigned int ligature_idx = 0;
+ unsigned int action;
do
{
- if (unlikely (!match_length))
- return false;
+ if (unlikely (!cursor))
+ {
+ /* Stack underflow. Clear the stack. */
+ DEBUG_MSG (APPLY, nullptr, "Stack underflow");
+ match_length = 0;
+ break;
+ }
- buffer->move_to (match_positions[--match_length]);
+ DEBUG_MSG (APPLY, nullptr, "Moving to stack position %u", cursor - 1);
+ buffer->move_to (match_positions[--cursor]);
- const HBUINT32 &actionData = ligAction[action_idx];
- if (unlikely (!actionData.sanitize (&c->sanitizer))) return false;
- action = actionData;
+ if (unlikely (!actionData->sanitize (&c->sanitizer))) return false;
+ action = *actionData;
uint32_t uoffset = action & LigActionOffset;
if (uoffset & 0x20000000)
- uoffset += 0xC0000000;
+ uoffset |= 0xC0000000; /* Sign-extend. */
int32_t offset = (int32_t) uoffset;
unsigned int component_idx = buffer->cur().codepoint + offset;
-
+ component_idx = Types::wordOffsetToIndex (component_idx, table, component.arrayZ);
const HBUINT16 &componentData = component[component_idx];
if (unlikely (!componentData.sanitize (&c->sanitizer))) return false;
ligature_idx += componentData;
+ DEBUG_MSG (APPLY, nullptr, "Action store %u last %u",
+ bool (action & LigActionStore),
+ bool (action & LigActionLast));
if (action & (LigActionStore | LigActionLast))
{
+ ligature_idx = Types::offsetToIndex (ligature_idx, table, ligature.arrayZ);
const GlyphID &ligatureData = ligature[ligature_idx];
if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false;
hb_codepoint_t lig = ligatureData;
- match_positions[match_length++] = buffer->out_len;
+ DEBUG_MSG (APPLY, nullptr, "Produced ligature %u", lig);
buffer->replace_glyph (lig);
- //ligature_idx = 0; // XXX Yes or no?
+ unsigned int lig_end = match_positions[match_length - 1] + 1;
+ /* Now go and delete all subsequent components. */
+ while (match_length - 1 > cursor)
+ {
+ DEBUG_MSG (APPLY, nullptr, "Skipping ligature component");
+ buffer->move_to (match_positions[--match_length]);
+ buffer->replace_glyph (DELETED_GLYPH);
+ }
+
+ buffer->move_to (lig_end);
+ buffer->merge_out_clusters (match_positions[cursor], buffer->out_len);
}
- else
- {
- buffer->skip_glyph ();
- end--;
- }
- /* TODO merge_clusters / unsafe_to_break */
- action_idx++;
+ actionData++;
}
while (!(action & LigActionLast));
buffer->move_to (end);
@@ -443,6 +559,7 @@ struct LigatureSubtable
bool ret;
private:
hb_aat_apply_context_t *c;
+ const LigatureSubtable *table;
const UnsizedArrayOf<HBUINT32> &ligAction;
const UnsizedArrayOf<HBUINT16> &component;
const UnsizedArrayOf<GlyphID> &ligature;
@@ -456,7 +573,7 @@ struct LigatureSubtable
driver_context_t dc (this, c);
- StateTableDriver<EntryData> driver (machine, c->buffer, c->face);
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc);
return_trace (dc.ret);
@@ -471,18 +588,19 @@ struct LigatureSubtable
}
protected:
- StateTable<EntryData>
+ StateTable<Types, EntryData>
machine;
- LOffsetTo<UnsizedArrayOf<HBUINT32>, false>
+ OffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT, false>
ligAction; /* Offset to the ligature action table. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
+ OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT, false>
component; /* Offset to the component table. */
- LOffsetTo<UnsizedArrayOf<GlyphID>, false>
+ OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false>
ligature; /* Offset to the actual ligature lists. */
public:
DEFINE_SIZE_STATIC (28);
};
+template <typename Types>
struct NoncontextualSubtable
{
inline bool apply (hb_aat_apply_context_t *c) const
@@ -519,8 +637,11 @@ struct NoncontextualSubtable
DEFINE_SIZE_MIN (2);
};
+template <typename Types>
struct InsertionSubtable
{
+ typedef typename Types::HBUINT HBUINT;
+
struct EntryData
{
HBUINT16 currentInsertIndex; /* Zero-based index into the insertion glyph table.
@@ -596,13 +717,13 @@ struct InsertionSubtable
mark (0),
insertionAction (table+table->insertionAction) {}
- inline bool is_actionable (StateTableDriver<EntryData> *driver,
+ inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry)
{
return (entry->flags & (CurrentInsertCount | MarkedInsertCount)) &&
(entry->data.currentInsertIndex != 0xFFFF ||entry->data.markedInsertIndex != 0xFFFF);
}
- inline bool transition (StateTableDriver<EntryData> *driver,
+ inline bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry)
{
hb_buffer_t *buffer = driver->buffer;
@@ -620,12 +741,12 @@ struct InsertionSubtable
unsigned int end = buffer->out_len;
buffer->move_to (mark);
- if (!before)
+ if (buffer->idx < buffer->len && !before)
buffer->copy_glyph ();
/* TODO We ignore KashidaLike setting. */
for (unsigned int i = 0; i < count; i++)
buffer->output_glyph (glyphs[i]);
- if (!before)
+ if (buffer->idx < buffer->len && !before)
buffer->skip_glyph ();
buffer->move_to (end + count);
@@ -644,12 +765,12 @@ struct InsertionSubtable
unsigned int end = buffer->out_len;
- if (!before)
+ if (buffer->idx < buffer->len && !before)
buffer->copy_glyph ();
/* TODO We ignore KashidaLike setting. */
for (unsigned int i = 0; i < count; i++)
buffer->output_glyph (glyphs[i]);
- if (!before)
+ if (buffer->idx < buffer->len && !before)
buffer->skip_glyph ();
/* Humm. Not sure where to move to. There's this wording under
@@ -664,6 +785,8 @@ struct InsertionSubtable
* This suggests that if DontAdvance is NOT set, we should move to
* end+count. If it *was*, then move to end, such that newly inserted
* glyphs are now visible.
+ *
+ * https://github.com/harfbuzz/harfbuzz/issues/1224#issuecomment-427691417
*/
buffer->move_to ((flags & DontAdvance) ? end : end + count);
}
@@ -692,7 +815,7 @@ struct InsertionSubtable
driver_context_t dc (this, c);
- StateTableDriver<EntryData> driver (machine, c->buffer, c->face);
+ StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc);
return_trace (dc.ret);
@@ -707,9 +830,9 @@ struct InsertionSubtable
}
protected:
- StateTable<EntryData>
+ StateTable<Types, EntryData>
machine;
- LOffsetTo<UnsizedArrayOf<GlyphID>, false>
+ OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false>
insertionAction; /* Byte offset from stateHeader to the start of
* the insertion glyph table. */
public:
@@ -737,30 +860,32 @@ struct Feature
DEFINE_SIZE_STATIC (12);
};
-
+template <typename Types>
struct ChainSubtable
{
+ typedef typename Types::HBUINT HBUINT;
+
+ template <typename T>
friend struct Chain;
inline unsigned int get_size (void) const { return length; }
- inline unsigned int get_type (void) const { return coverage & SubtableType; }
+ inline unsigned int get_type (void) const { return coverage & 0xFF; }
+ inline unsigned int get_coverage (void) const { return coverage >> (sizeof (HBUINT) * 8 - 8); }
enum Coverage
{
- Vertical = 0x80000000, /* If set, this subtable will only be applied
- * to vertical text. If clear, this subtable
- * will only be applied to horizontal text. */
- Descending = 0x40000000, /* If set, this subtable will process glyphs
- * in descending order. If clear, it will
- * process the glyphs in ascending order. */
- AllDirections = 0x20000000, /* If set, this subtable will be applied to
- * both horizontal and vertical text (i.e.
- * the state of bit 0x80000000 is ignored). */
- Logical = 0x10000000, /* If set, this subtable will process glyphs
- * in logical order (or reverse logical order,
- * depending on the value of bit 0x80000000). */
- Reserved = 0x0FFFFF00, /* Reserved, set to zero. */
- SubtableType = 0x000000FF, /* Subtable type; see following table. */
+ Vertical = 0x80, /* If set, this subtable will only be applied
+ * to vertical text. If clear, this subtable
+ * will only be applied to horizontal text. */
+ Backwards = 0x40, /* If set, this subtable will process glyphs
+ * in descending order. If clear, it will
+ * process the glyphs in ascending order. */
+ AllDirections = 0x20, /* If set, this subtable will be applied to
+ * both horizontal and vertical text (i.e.
+ * the state of bit 0x80000000 is ignored). */
+ Logical = 0x10, /* If set, this subtable will process glyphs
+ * in logical order (or reverse logical order,
+ * depending on the value of bit 0x80000000). */
};
enum Type
{
@@ -786,53 +911,78 @@ struct ChainSubtable
}
}
+ inline bool apply (hb_aat_apply_context_t *c) const
+ {
+ TRACE_APPLY (this);
+ hb_sanitize_with_object_t with (&c->sanitizer, this);
+ return_trace (dispatch (c));
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (!length.sanitize (c) ||
- length < min_size ||
+ length <= min_size ||
!c->check_range (this, length))
return_trace (false);
+ hb_sanitize_with_object_t with (c, this);
return_trace (dispatch (c));
}
protected:
- HBUINT32 length; /* Total subtable length, including this header. */
- HBUINT32 coverage; /* Coverage flags and subtable type. */
+ HBUINT length; /* Total subtable length, including this header. */
+ HBUINT coverage; /* Coverage flags and subtable type. */
HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */
union {
- RearrangementSubtable rearrangement;
- ContextualSubtable contextual;
- LigatureSubtable ligature;
- NoncontextualSubtable noncontextual;
- InsertionSubtable insertion;
+ RearrangementSubtable<Types> rearrangement;
+ ContextualSubtable<Types> contextual;
+ LigatureSubtable<Types> ligature;
+ NoncontextualSubtable<Types> noncontextual;
+ InsertionSubtable<Types> insertion;
} u;
public:
- DEFINE_SIZE_MIN (12);
+ DEFINE_SIZE_MIN (2 * sizeof (HBUINT) + 4);
};
+template <typename Types>
struct Chain
{
- inline void apply (hb_aat_apply_context_t *c) const
+ typedef typename Types::HBUINT HBUINT;
+
+ inline hb_mask_t compile_flags (const hb_aat_map_builder_t *map) const
{
- uint32_t flags = defaultFlags;
+ hb_mask_t flags = defaultFlags;
{
- /* Compute applicable flags. TODO Should move this to planning
- * stage and take user-requested features into account. */
unsigned int count = featureCount;
for (unsigned i = 0; i < count; i++)
{
- const Feature &feature = featureZ[i];
- if (false) /* XXX Check if feature enabled... */
+ const Feature &feature = featureZ[i];
+ hb_aat_layout_feature_type_t type = (hb_aat_layout_feature_type_t) (unsigned int) feature.featureType;
+ hb_aat_layout_feature_selector_t setting = (hb_aat_layout_feature_selector_t) (unsigned int) feature.featureSetting;
+ retry:
+ const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch ((uint16_t) type);
+ if (info && info->setting == setting)
{
flags &= feature.disableFlags;
flags |= feature.enableFlags;
}
+ else if (type == HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE && setting == HB_AAT_LAYOUT_FEATURE_SELECTOR_SMALL_CAPS)
+ {
+ /* Deprecated. https://github.com/harfbuzz/harfbuzz/issues/1342 */
+ type = HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE;
+ setting = HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS;
+ goto retry;
+ }
}
}
+ return flags;
+ }
- const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount);
+ inline void apply (hb_aat_apply_context_t *c,
+ hb_mask_t flags) const
+ {
+ const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount));
unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++)
{
@@ -841,9 +991,9 @@ struct Chain
if (!(subtable->subFeatureFlags & flags))
goto skip;
- if (!(subtable->coverage & ChainSubtable::AllDirections) &&
+ if (!(subtable->get_coverage() & ChainSubtable<Types>::AllDirections) &&
HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) !=
- bool (subtable->coverage & ChainSubtable::Vertical))
+ bool (subtable->get_coverage() & ChainSubtable<Types>::Vertical))
goto skip;
/* Buffer contents is always in logical direction. Determine if
@@ -873,9 +1023,9 @@ struct Chain
(the order opposite that of the characters, which
may be right-to-left or left-to-right).
*/
- reverse = subtable->coverage & ChainSubtable::Logical ?
- bool (subtable->coverage & ChainSubtable::Descending) :
- bool (subtable->coverage & ChainSubtable::Descending) !=
+ reverse = subtable->get_coverage () & ChainSubtable<Types>::Logical ?
+ bool (subtable->get_coverage () & ChainSubtable<Types>::Backwards) :
+ bool (subtable->get_coverage () & ChainSubtable<Types>::Backwards) !=
HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
if (!c->buffer->message (c->font, "start chain subtable %d", c->lookup_index))
@@ -884,7 +1034,7 @@ struct Chain
if (reverse)
c->buffer->reverse ();
- subtable->dispatch (c);
+ subtable->apply (c);
if (reverse)
c->buffer->reverse ();
@@ -894,14 +1044,14 @@ struct Chain
if (unlikely (!c->buffer->successful)) return;
skip:
- subtable = &StructAfter<ChainSubtable> (*subtable);
+ subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
c->set_lookup_index (c->lookup_index + 1);
}
}
inline unsigned int get_size (void) const { return length; }
- inline bool sanitize (hb_sanitize_context_t *c, unsigned int version) const
+ inline bool sanitize (hb_sanitize_context_t *c, unsigned int version HB_UNUSED) const
{
TRACE_SANITIZE (this);
if (!length.sanitize (c) ||
@@ -912,13 +1062,13 @@ struct Chain
if (!c->check_array (featureZ.arrayZ, featureCount))
return_trace (false);
- const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount);
+ const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount));
unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++)
{
if (!subtable->sanitize (c))
return_trace (false);
- subtable = &StructAfter<ChainSubtable> (*subtable);
+ subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
}
return_trace (true);
@@ -927,54 +1077,68 @@ struct Chain
protected:
HBUINT32 defaultFlags; /* The default specification for subtables. */
HBUINT32 length; /* Total byte count, including this header. */
- HBUINT32 featureCount; /* Number of feature subtable entries. */
- HBUINT32 subtableCount; /* The number of subtables in the chain. */
+ HBUINT featureCount; /* Number of feature subtable entries. */
+ HBUINT subtableCount; /* The number of subtables in the chain. */
UnsizedArrayOf<Feature> featureZ; /* Features. */
/*ChainSubtable firstSubtable;*//* Subtables. */
/*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */
public:
- DEFINE_SIZE_MIN (16);
+ DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT));
};
/*
- * The 'mort'/'morx' Tables
+ * The 'mort'/'morx' Table
*/
-struct morx
+template <typename Types>
+struct mortmorx
{
static const hb_tag_t tableTag = HB_AAT_TAG_morx;
+ inline bool has_data (void) const { return version != 0; }
+
+ inline void compile_flags (const hb_aat_map_builder_t *mapper,
+ hb_aat_map_t *map) const
+ {
+ const Chain<Types> *chain = &firstChain;
+ unsigned int count = chainCount;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ map->chain_flags.push (chain->compile_flags (mapper));
+ chain = &StructAfter<Chain<Types> > (*chain);
+ }
+ }
+
inline void apply (hb_aat_apply_context_t *c) const
{
if (unlikely (!c->buffer->successful)) return;
c->set_lookup_index (0);
- const Chain *chain = &firstChain;
+ const Chain<Types> *chain = &firstChain;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
- chain->apply (c);
+ chain->apply (c, c->plan->aat_map.chain_flags[i]);
if (unlikely (!c->buffer->successful)) return;
- chain = &StructAfter<Chain> (*chain);
+ chain = &StructAfter<Chain<Types> > (*chain);
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (!version.sanitize (c) || version < 2 ||
- !chainCount.sanitize (c))
+ if (!version.sanitize (c) || !version || !chainCount.sanitize (c))
return_trace (false);
- const Chain *chain = &firstChain;
+ const Chain<Types> *chain = &firstChain;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
if (!chain->sanitize (c, version))
return_trace (false);
- chain = &StructAfter<Chain> (*chain);
+ chain = &StructAfter<Chain<Types> > (*chain);
}
return_trace (true);
@@ -982,16 +1146,26 @@ struct morx
protected:
HBUINT16 version; /* Version number of the glyph metamorphosis table.
- * 2 or 3. */
+ * 1, 2, or 3. */
HBUINT16 unused; /* Set to 0. */
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
* table. */
- Chain firstChain; /* Chains. */
+ Chain<Types> firstChain; /* Chains. */
public:
DEFINE_SIZE_MIN (8);
};
+struct morx : mortmorx<ExtendedTypes>
+{
+ static const hb_tag_t tableTag = HB_AAT_TAG_morx;
+};
+struct mort : mortmorx<ObsoleteTypes>
+{
+ static const hb_tag_t tableTag = HB_AAT_TAG_mort;
+};
+
+
} /* namespace AAT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-trak-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-trak-table.hh
index 3b7d43881bb..5474d1d11b8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-trak-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout-trak-table.hh
@@ -46,28 +46,32 @@ struct TrackTableEntry
{
friend struct TrackData;
- inline bool sanitize (hb_sanitize_context_t *c, const void *base,
- unsigned int size) const
+ inline float get_track_value () const
{
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- (valuesZ.sanitize (c, base, size))));
+ return track.to_float ();
}
- private:
- inline float get_track_value () const
+ inline int get_value (const void *base,
+ unsigned int index,
+ unsigned int nSizes) const
{
- return track.to_float ();
+ return (base+valuesZ).as_array (nSizes)[index];
}
- inline int get_value (const void *base, unsigned int index) const
+ public:
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base,
+ unsigned int nSizes) const
{
- return (base+valuesZ)[index];
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ (valuesZ.sanitize (c, base, nSizes))));
}
protected:
Fixed track; /* Track value for this record. */
- NameID trackNameID; /* The 'name' table index for this track */
+ NameID trackNameID; /* The 'name' table index for this track.
+ * (a short word or phrase like "loose"
+ * or "very tight") */
OffsetTo<UnsizedArrayOf<FWORD>, HBUINT16, false>
valuesZ; /* Offset from start of tracking table to
* per-size tracking values for this track. */
@@ -78,15 +82,22 @@ struct TrackTableEntry
struct TrackData
{
- inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ inline float interpolate_at (unsigned int idx,
+ float target_size,
+ const TrackTableEntry &trackTableEntry,
+ const void *base) const
{
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- sizeTable.sanitize (c, base, nSizes) &&
- trackTable.sanitize (c, nTracks, base, nSizes));
+ unsigned int sizes = nSizes;
+ hb_array_t<const Fixed> size_table ((base+sizeTable).arrayZ, sizes);
+
+ float s0 = size_table[idx].to_float ();
+ float s1 = size_table[idx + 1].to_float ();
+ float t = unlikely (s0 == s1) ? 0.f : (target_size - s0) / (s1 - s0);
+ return t * trackTableEntry.get_value (base, idx + 1, sizes) +
+ (1.f - t) * trackTableEntry.get_value (base, idx, sizes);
}
- inline float get_tracking (const void *base, float ptem) const
+ inline int get_tracking (const void *base, float ptem) const
{
/* CoreText points are CSS pixels (96 per inch),
* NOT typographic points (72 per inch).
@@ -94,48 +105,58 @@ struct TrackData
* https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
*/
float csspx = ptem * 96.f / 72.f;
- Fixed fixed_size;
- fixed_size.set_float (csspx);
- /* XXX Clean this up. Make it work with nSizes==1 and 0. */
+ /*
+ * Choose track.
+ */
+ const TrackTableEntry *trackTableEntry = nullptr;
+ unsigned int count = nTracks;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ /* Note: Seems like the track entries are sorted by values. But the
+ * spec doesn't explicitly say that. It just mentions it in the example. */
- unsigned int sizes = nSizes;
+ /* For now we only seek for track entries with zero tracking value */
- const TrackTableEntry *trackTableEntry = nullptr;
- for (unsigned int i = 0; i < sizes; ++i)
- // For now we only seek for track entries with zero tracking value
if (trackTable[i].get_track_value () == 0.f)
- trackTableEntry = &trackTable[0];
-
- // We couldn't match any, exit
+ {
+ trackTableEntry = &trackTable[i];
+ break;
+ }
+ }
if (!trackTableEntry) return 0.;
- /* TODO bfind() */
+ /*
+ * Choose size.
+ */
+ unsigned int sizes = nSizes;
+ if (!sizes) return 0.;
+ if (sizes == 1) return trackTableEntry->get_value (base, 0, sizes);
+
+ hb_array_t<const Fixed> size_table ((base+sizeTable).arrayZ, sizes);
unsigned int size_index;
- UnsizedArrayOf<Fixed> size_table = base+sizeTable;
- for (size_index = 0; size_index < sizes; ++size_index)
- if (size_table[size_index] >= fixed_size)
+ for (size_index = 0; size_index < sizes - 1; size_index++)
+ if (size_table[size_index].to_float () >= csspx)
break;
- // TODO(ebraminio): We don't attempt to extrapolate to larger or
- // smaller values for now but we should do, per spec
- if (size_index == sizes)
- return trackTableEntry->get_value (base, sizes - 1);
- if (size_index == 0 || size_table[size_index] == fixed_size)
- return trackTableEntry->get_value (base, size_index);
-
- float s0 = size_table[size_index - 1].to_float ();
- float s1 = size_table[size_index].to_float ();
- float t = (csspx - s0) / (s1 - s0);
- return (float) t * trackTableEntry->get_value (base, size_index) +
- ((float) 1.0 - t) * trackTableEntry->get_value (base, size_index - 1);
+ return round (interpolate_at (size_index ? size_index - 1 : 0, csspx,
+ *trackTableEntry, base));
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ sizeTable.sanitize (c, base, nSizes) &&
+ trackTable.sanitize (c, nTracks, base, nSizes)));
}
protected:
HBUINT16 nTracks; /* Number of separate tracks included in this table. */
HBUINT16 nSizes; /* Number of point sizes included in this table. */
LOffsetTo<UnsizedArrayOf<Fixed>, false>
- sizeTable; /* Offset to array[nSizes] of size values. */
+ sizeTable; /* Offset from start of the tracking table to
+ * Array[nSizes] of size values.. */
UnsizedArrayOf<TrackTableEntry>
trackTable; /* Array[nTracks] of TrackTableEntry records. */
@@ -147,19 +168,14 @@ struct trak
{
static const hb_tag_t tableTag = HB_AAT_TAG_trak;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
-
- return_trace (unlikely (c->check_struct (this) &&
- horizData.sanitize (c, this, this) &&
- vertData.sanitize (c, this, this)));
- }
+ inline bool has_data (void) const { return version.to_int (); }
inline bool apply (hb_aat_apply_context_t *c) const
{
TRACE_APPLY (this);
+ hb_mask_t trak_mask = c->plan->trak_mask;
+
const float ptem = c->font->ptem;
if (unlikely (ptem <= 0.f))
return_trace (false);
@@ -168,41 +184,57 @@ struct trak
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
{
const TrackData &trackData = this+horizData;
- float tracking = trackData.get_tracking (this, ptem);
- hb_position_t advance_to_add = c->font->em_scalef_x (tracking / 2);
+ int tracking = trackData.get_tracking (this, ptem);
+ hb_position_t offset_to_add = c->font->em_scalef_x (tracking / 2);
+ hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
foreach_grapheme (buffer, start, end)
{
- buffer->pos[start].x_offset += advance_to_add;
+ if (!(buffer->info[start].mask & trak_mask)) continue;
buffer->pos[start].x_advance += advance_to_add;
- buffer->pos[end].x_advance += advance_to_add;
+ buffer->pos[start].x_offset += offset_to_add;
}
}
else
{
const TrackData &trackData = this+vertData;
- float tracking = trackData.get_tracking (this, ptem);
- hb_position_t advance_to_add = c->font->em_scalef_y (tracking / 2);
+ int tracking = trackData.get_tracking (this, ptem);
+ hb_position_t offset_to_add = c->font->em_scalef_y (tracking / 2);
+ hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
foreach_grapheme (buffer, start, end)
{
- buffer->pos[start].y_offset += advance_to_add;
+ if (!(buffer->info[start].mask & trak_mask)) continue;
buffer->pos[start].y_advance += advance_to_add;
- buffer->pos[end].y_advance += advance_to_add;
+ buffer->pos[start].y_offset += offset_to_add;
}
}
return_trace (true);
}
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+
+ return_trace (likely (c->check_struct (this) &&
+ version.major == 1 &&
+ horizData.sanitize (c, this, this) &&
+ vertData.sanitize (c, this, this)));
+ }
+
protected:
- FixedVersion<> version; /* Version of the tracking table--currently
- * 0x00010000u for version 1.0. */
- HBUINT16 format; /* Format of the tracking table */
- OffsetTo<TrackData> horizData; /* TrackData for horizontal text */
- OffsetTo<TrackData> vertData; /* TrackData for vertical text */
- HBUINT16 reserved; /* Reserved. Set to 0. */
+ FixedVersion<>version; /* Version of the tracking table
+ * (0x00010000u for version 1.0). */
+ HBUINT16 format; /* Format of the tracking table (set to 0). */
+ OffsetTo<TrackData>
+ horizData; /* Offset from start of tracking table to TrackData
+ * for horizontal text (or 0 if none). */
+ OffsetTo<TrackData>
+ vertData; /* Offset from start of tracking table to TrackData
+ * for vertical text (or 0 if none). */
+ HBUINT16 reserved; /* Reserved. Set to 0. */
public:
- DEFINE_SIZE_MIN (12);
+ DEFINE_SIZE_STATIC (12);
};
} /* namespace AAT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.cc
index a5e36a40a38..727da42a8b9 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.cc
@@ -1,5 +1,6 @@
/*
* Copyright © 2017 Google, Inc.
+ * Copyright © 2018 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -30,52 +31,342 @@
#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.
+#include "hb-aat-layout-feat-table.hh"
+#include "hb-aat-layout-just-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-kerx-table.hh"
#include "hb-aat-layout-morx-table.hh"
#include "hb-aat-layout-trak-table.hh"
-#include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise.
+#include "hb-aat-ltag-table.hh"
+
+
+/**
+ * SECTION:hb-aat-layout
+ * @title: hb-aat-layout
+ * @short_description: Apple Advanced Typography Layout
+ * @include: hb-aat.h
+ *
+ * Functions for querying OpenType Layout features in the font face.
+ **/
+
+
+/* Table data courtesy of Apple. Converted from mnemonics to integers
+ * when moving to this file. */
+static const hb_aat_feature_mapping_t feature_mappings[] =
+{
+ {HB_TAG ('a','f','r','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_VERTICAL_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS},
+ {HB_TAG ('c','2','p','c'), HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE},
+ {HB_TAG ('c','2','s','c'), HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE},
+ {HB_TAG ('c','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_OFF},
+ {HB_TAG ('c','a','s','e'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_OFF},
+ {HB_TAG ('c','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_OFF},
+ {HB_TAG ('c','p','s','p'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_OFF},
+ {HB_TAG ('c','s','w','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF},
+ {HB_TAG ('d','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_OFF},
+ {HB_TAG ('e','x','p','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPERT_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('f','r','a','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAGONAL_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS},
+ {HB_TAG ('f','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('h','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('h','i','s','t'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF},
+ {HB_TAG ('h','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_OFF},
+ {HB_TAG ('h','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF},
+ {HB_TAG ('h','n','g','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION, HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_TRANSLITERATION},
+ {HB_TAG ('h','o','j','o'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_HOJO_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('h','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('i','t','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN, HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF},
+ {HB_TAG ('j','p','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS2004_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('j','p','7','8'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1978_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('j','p','8','3'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1983_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('j','p','9','0'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1990_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('l','i','g','a'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_OFF},
+ {HB_TAG ('l','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_NUMBERS, (hb_aat_layout_feature_selector_t) 2},
+ {HB_TAG ('m','g','r','k'), HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS, HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_OFF},
+ {HB_TAG ('n','l','c','k'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_NLCCHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('o','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_NUMBERS, (hb_aat_layout_feature_selector_t) 2},
+ {HB_TAG ('o','r','d','n'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_ORDINALS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
+ {HB_TAG ('p','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('p','c','a','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE},
+ {HB_TAG ('p','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('p','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_NUMBERS, (hb_aat_layout_feature_selector_t) 4},
+ {HB_TAG ('p','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('q','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('r','u','b','y'), HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF},
+ {HB_TAG ('s','i','n','f'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SCIENTIFIC_INFERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
+ {HB_TAG ('s','m','c','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE},
+ {HB_TAG ('s','m','p','l'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_SIMPLIFIED_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('s','s','0','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_OFF},
+ {HB_TAG ('s','s','0','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_OFF},
+ {HB_TAG ('s','s','0','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_OFF},
+ {HB_TAG ('s','s','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_OFF},
+ {HB_TAG ('s','s','0','5'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_OFF},
+ {HB_TAG ('s','s','0','6'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_OFF},
+ {HB_TAG ('s','s','0','7'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_OFF},
+ {HB_TAG ('s','s','0','8'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_OFF},
+ {HB_TAG ('s','s','0','9'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_OFF},
+ {HB_TAG ('s','s','1','0'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_OFF},
+ {HB_TAG ('s','s','1','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_OFF},
+ {HB_TAG ('s','s','1','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_OFF},
+ {HB_TAG ('s','s','1','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_OFF},
+ {HB_TAG ('s','s','1','4'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_OFF},
+ {HB_TAG ('s','s','1','5'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_OFF},
+ {HB_TAG ('s','s','1','6'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_OFF},
+ {HB_TAG ('s','s','1','7'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_OFF},
+ {HB_TAG ('s','s','1','8'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_OFF},
+ {HB_TAG ('s','s','1','9'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_OFF},
+ {HB_TAG ('s','s','2','0'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_OFF},
+ {HB_TAG ('s','u','b','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_INFERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
+ {HB_TAG ('s','u','p','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUPERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
+ {HB_TAG ('s','w','s','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_OFF},
+ {HB_TAG ('t','i','t','l'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_TITLING_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLE_OPTIONS},
+ {HB_TAG ('t','n','a','m'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_NAMES_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('t','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_NUMBERS, (hb_aat_layout_feature_selector_t) 4},
+ {HB_TAG ('t','r','a','d'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
+ {HB_TAG ('t','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('u','n','i','c'), HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE, (hb_aat_layout_feature_selector_t) 14, (hb_aat_layout_feature_selector_t) 15},
+ {HB_TAG ('v','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('v','e','r','t'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
+ {HB_TAG ('v','h','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('v','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_OFF},
+ {HB_TAG ('v','p','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
+ {HB_TAG ('v','r','t','2'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
+ {HB_TAG ('z','e','r','o'), HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF},
+};
+
+const hb_aat_feature_mapping_t *
+hb_aat_layout_find_feature_mapping (hb_tag_t tag)
+{
+ return (const hb_aat_feature_mapping_t *) bsearch (&tag,
+ feature_mappings,
+ ARRAY_LENGTH (feature_mappings),
+ sizeof (feature_mappings[0]),
+ hb_aat_feature_mapping_t::cmp);
+}
+
+
+/*
+ * hb_aat_apply_context_t
+ */
+
+AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_,
+ hb_font_t *font_,
+ hb_buffer_t *buffer_,
+ hb_blob_t *blob) :
+ plan (plan_),
+ font (font_),
+ face (font->face),
+ buffer (buffer_),
+ sanitizer (),
+ ankr_table (&Null(AAT::ankr)),
+ ankr_end (nullptr),
+ lookup_index (0),
+ debug_depth (0)
+{
+ sanitizer.init (blob);
+ sanitizer.set_num_glyphs (face->get_num_glyphs ());
+ sanitizer.start_processing ();
+ sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX);
+}
+
+AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t (void)
+{
+ sanitizer.end_processing ();
+}
+
+void
+AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_,
+ const char *ankr_end_)
+{
+ ankr_table = ankr_table_;
+ ankr_end = ankr_end_;
+}
+
/*
- * morx/kerx/trak/ankr
+ * mort/morx/kerx/trak
*/
-static inline const AAT::morx&
-_get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
+
+void
+hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
+ hb_aat_map_t *map)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
+ const AAT::morx& morx = *mapper->face->table.morx;
+ if (morx.has_data ())
+ {
+ morx.compile_flags (mapper, map);
+ return;
+ }
+
+ const AAT::mort& mort = *mapper->face->table.mort;
+ if (mort.has_data ())
+ {
+ mort.compile_flags (mapper, map);
+ return;
+ }
+}
+
+
+bool
+hb_aat_layout_has_substitution (hb_face_t *face)
+{
+ return face->table.morx->has_data () ||
+ face->table.mort->has_data ();
+}
+
+void
+hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
+{
+ hb_blob_t *morx_blob = font->face->table.morx.get_blob ();
+ const AAT::morx& morx = *morx_blob->as<AAT::morx> ();
+ if (morx.has_data ())
+ {
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, morx_blob);
+ morx.apply (&c);
+ return;
+ }
+
+ hb_blob_t *mort_blob = font->face->table.mort.get_blob ();
+ const AAT::mort& mort = *mort_blob->as<AAT::mort> ();
+ if (mort.has_data ())
{
- if (blob)
- *blob = hb_blob_get_empty ();
- return Null(AAT::morx);
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, mort_blob);
+ mort.apply (&c);
+ return;
}
- const AAT::morx& morx = *(hb_ot_face_data (face)->morx.get ());
- if (blob)
- *blob = hb_ot_face_data (face)->morx.get_blob ();
- return morx;
}
void
-hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer)
+hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer)
{
- hb_blob_t *blob;
- const AAT::morx& morx = _get_morx (font->face, &blob);
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
+ hb_glyph_position_t *pos = buffer->pos;
+ for (unsigned int i = 0; i < count; i++)
+ if (unlikely (info[i].codepoint == AAT::DELETED_GLYPH))
+ pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0;
+}
+
+static bool
+is_deleted_glyph (const hb_glyph_info_t *info)
+{
+ return info->codepoint == AAT::DELETED_GLYPH;
+}
- AAT::hb_aat_apply_context_t c (font, buffer, blob);
- morx.apply (&c);
+void
+hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer)
+{
+ hb_ot_layout_delete_glyphs_inplace (buffer, is_deleted_glyph);
+}
+
+
+
+bool
+hb_aat_layout_has_positioning (hb_face_t *face)
+{
+ return face->table.kerx->has_data ();
+}
+
+void
+hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
+{
+ hb_blob_t *kerx_blob = font->face->table.kerx.get_blob ();
+ const AAT::kerx& kerx = *kerx_blob->as<AAT::kerx> ();
+
+ hb_blob_t *ankr_blob = font->face->table.ankr.get_blob ();;
+ const AAT::ankr& ankr = *font->face->table.ankr;
+
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, kerx_blob);
+ c.set_ankr_table (&ankr, ankr_blob->data + ankr_blob->length);
+ kerx.apply (&c);
+}
+
+
+bool
+hb_aat_layout_has_tracking (hb_face_t *face)
+{
+ return face->table.trak->has_data ();
}
void
-hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer)
+hb_aat_layout_track (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
{
-#if 0
- hb_blob_t *blob;
- const AAT::ankr& ankr = _get_ankr (font->face, &blob);
- const AAT::kerx& kerx = _get_kerx (font->face, &blob);
- const AAT::trak& trak = _get_trak (font->face, &blob);
+ const AAT::trak& trak = *font->face->table.trak;
- AAT::hb_aat_apply_context_t c (font, buffer, blob);
- kerx.apply (&c, &ankr);
+ AAT::hb_aat_apply_context_t c (plan, font, buffer);
trak.apply (&c);
-#endif
+}
+
+
+hb_language_t
+_hb_aat_language_get (hb_face_t *face,
+ unsigned int i)
+{
+ return face->table.ltag->get_language (i);
+}
+
+/**
+ * hb_aat_layout_get_feature_types:
+ * @face: a face object
+ * @start_offset: iteration's start offset
+ * @feature_count:(inout) (allow-none): buffer size as input, filled size as output
+ * @features: (out caller-allocates) (array length=feature_count): features buffer
+ *
+ * Return value: Number of all available feature types.
+ *
+ * Since: REPLACEME
+ */
+unsigned int
+hb_aat_layout_get_feature_types (hb_face_t *face,
+ unsigned int start_offset,
+ unsigned int *feature_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_type_t *features /* OUT. May be NULL. */)
+{
+ return face->table.feat->get_feature_types (start_offset, feature_count, features);
+}
+
+/**
+ * hb_aat_layout_feature_type_get_name_id:
+ * @face: a face object
+ * @feature_type: feature id
+ *
+ * Return value: Name ID index
+ *
+ * Since: REPLACEME
+ */
+hb_ot_name_id_t
+hb_aat_layout_feature_type_get_name_id (hb_face_t *face,
+ hb_aat_layout_feature_type_t feature_type)
+{ return face->table.feat->get_feature_name_id (feature_type); }
+
+/**
+ * hb_aat_layout_feature_type_get_selectors:
+ * @face: a face object
+ * @feature_type: feature id
+ * @start_offset: iteration's start offset
+ * @selector_count: (inout) (allow-none): buffer size as input, filled size as output
+ * @selectors: (out caller-allocates) (array length=selector_count): settings buffer
+ * @default_index: (out) (allow-none): index of default selector if any
+ *
+ * If upon return, @default_index is set to #HB_AAT_LAYOUT_NO_SELECTOR_INDEX, then
+ * the feature type is non-exclusive. Otherwise, @default_index is the index of
+ * the selector that is selected by default.
+ *
+ * Return value: Number of all available feature selectors.
+ *
+ * Since: REPLACEME
+ */
+unsigned int
+hb_aat_layout_feature_type_get_selector_infos (hb_face_t *face,
+ hb_aat_layout_feature_type_t feature_type,
+ unsigned int start_offset,
+ unsigned int *selector_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *default_index /* OUT. May be NULL. */)
+{
+ return face->table.feat->get_selector_infos (feature_type, start_offset, selector_count, selectors, default_index);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.h b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.h
new file mode 100644
index 00000000000..5912e012bb3
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.h
@@ -0,0 +1,462 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#ifndef HB_AAT_H_IN
+#error "Include <hb-aat.h> instead."
+#endif
+
+#ifndef HB_AAT_LAYOUT_H
+#define HB_AAT_LAYOUT_H
+
+#include "hb.h"
+
+#include "hb-ot.h"
+
+HB_BEGIN_DECLS
+
+/**
+ * hb_aat_layout_feature_type_t:
+ *
+ *
+ * Since: REPLACEME
+ */
+typedef enum
+{
+ HB_AAT_LAYOUT_FEATURE_TYPE_INVALID = 0xFFFF,
+
+ HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC = 0,
+ HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES = 1,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CURISVE_CONNECTION = 2,
+ HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE = 3,
+ HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION = 4,
+ HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT = 5,
+ HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING = 6,
+ HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE = 8,
+ HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE = 9,
+ HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION = 10,
+ HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS = 11,
+ HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE = 13,
+ HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS = 14,
+ HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS = 15,
+ HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE = 16,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES = 17,
+ HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE = 18,
+ HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS = 19,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE = 20,
+ HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE = 21,
+ HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING = 22,
+ HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION = 23,
+ HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE = 24,
+ HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE = 25,
+ HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE = 26,
+ HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE = 27,
+ HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA = 28,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE = 29,
+ HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE = 30,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE = 31,
+ HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN = 32,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT = 33,
+ HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA = 34,
+ HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES = 35,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES = 36,
+ HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE = 37,
+ HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE = 38,
+ HB_AAT_LAYOUT_FEATURE_TYPE_LANGUAGE_TAG_TYPE = 39,
+ HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE = 103,
+
+ _HB_AAT_LAYOUT_FEATURE_TYPE_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
+} hb_aat_layout_feature_type_t;
+
+/**
+ * hb_aat_layout_feature_selector_t:
+ *
+ *
+ * Since: REPLACEME
+ */
+typedef enum
+{
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID = 0xFFFF,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_OFF = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_OFF = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_ON = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_OFF = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_ON = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_OFF = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_ON = 10,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_OFF = 11,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_ON = 12,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_OFF = 13,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_ON = 14,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_OFF = 15,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_ON = 16,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_OFF = 17,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_ON = 18,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_OFF = 19,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON = 20,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF = 21,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_UNCONNECTED = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PARTIALLY_CONNECTED = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CURSIVE = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_AND_LOWER_CASE = 0, /* deprecated */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_CAPS = 1, /* deprecated */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_LOWER_CASE = 2, /* deprecated */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SMALL_CAPS = 3, /* deprecated */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS = 4, /* deprecated */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS_AND_SMALL_CAPS = 5, /* deprecated */
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_OFF = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_NUMBERS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_NUMBERS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_NUMBERS = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_NUMBERS = 3,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_OFF = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_ON = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_OFF = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_ON = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_OFF = 9,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SHOW_DIACRITICS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HIDE_DIACRITICS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DECOMPOSE_DIACRITICS = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SUPERIORS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INFERIORS = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ORDINALS = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SCIENTIFIC_INFERIORS = 4,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_VERTICAL_FRACTIONS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAGONAL_FRACTIONS = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_OFF = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_ON = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_OFF = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_ON = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_OFF = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_ON = 10,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_OFF = 11,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_OFF = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_ON = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_OFF = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_ON = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_OFF = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_ON = 10,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_OFF = 11,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ORNAMENTS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DINGBATS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PI_CHARACTERS = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FLEURONS = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DECORATIVE_BORDERS = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INTERNATIONAL_SYMBOLS = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_MATH_SYMBOLS = 6,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ALTERNATES = 0,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL1 = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL2 = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL3 = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL4 = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL5 = 4,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLE_OPTIONS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DISPLAY_TEXT = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ENGRAVED_TEXT = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ILLUMINATED_CAPS = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TITLING_CAPS = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TALL_CAPS = 5,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_CHARACTERS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SIMPLIFIED_CHARACTERS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1978_CHARACTERS = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1983_CHARACTERS = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1990_CHARACTERS = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_ONE = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_TWO = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_THREE = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FOUR = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FIVE = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPERT_CHARACTERS = 10,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS2004_CHARACTERS = 11,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HOJO_CHARACTERS = 12,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NLCCHARACTERS = 13,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_NAMES_CHARACTERS = 14,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_NUMBERS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_NUMBERS = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_TEXT = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_TEXT = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_TEXT = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_TEXT = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT = 6,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_TRANSLITERATION = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HIRAGANA_TO_KATAKANA = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_KATAKANA_TO_HIRAGANA = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_KANA_TO_ROMANIZATION = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_HIRAGANA = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_KATAKANA = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_ONE = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_TWO = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_THREE = 9,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ANNOTATION = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_BOX_ANNOTATION = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ROUNDED_BOX_ANNOTATION = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CIRCLE_ANNOTATION = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_CIRCLE_ANNOTATION = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PARENTHESIS_ANNOTATION = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIOD_ANNOTATION = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMAN_NUMERAL_ANNOTATION = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAMOND_ANNOTATION = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_BOX_ANNOTATION = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_ROUNDED_BOX_ANNOTATION= 10,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_KANA = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_KANA = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_IDEOGRAPHS = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_IDEOGRAPHS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_IDEOGRAPHS = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_OFF = 5,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_RUBY_KANA = 0, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF instead */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA = 1, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON instead */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF = 3,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_SYMBOL_ALTERNATIVES = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_ONE = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_TWO = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_THREE = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FOUR = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FIVE = 5,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_IDEOGRAPHIC_ALTERNATIVES = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_ONE = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_TWO = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_THREE = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FOUR = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FIVE = 5,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_CENTERED = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_HBASELINE = 1,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_ITALIC_ROMAN = 0, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF instead */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN = 1, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON instead */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF = 3,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_OFF = 3,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_OFF = 3,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLISTIC_ALTERNATES = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_OFF = 5,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_ON = 6,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_OFF = 7,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_ON = 8,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_OFF = 9,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_ON = 10,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_OFF = 11,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_ON = 12,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_OFF = 13,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_ON = 14,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_OFF = 15,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_ON = 16,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_OFF = 17,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_ON = 18,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_OFF = 19,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_ON = 20,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_OFF = 21,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_ON = 22,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_OFF = 23,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_ON = 24,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_OFF = 25,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_ON = 26,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_OFF = 27,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_ON = 28,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_OFF = 29,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_ON = 30,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_OFF = 31,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_ON = 32,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_OFF = 33,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_ON = 34,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_OFF = 35,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_ON = 36,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_OFF = 37,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_ON = 38,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_OFF = 39,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_ON = 40,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_OFF = 41,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_ON = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_OFF = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_ON = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_OFF = 3,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON = 4,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF= 5,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_PETITE_CAPS = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_SMALL_CAPS = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_PETITE_CAPS = 2,
+
+ /* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE */
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_CJK_ROMAN = 0,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_CJK_ROMAN = 1,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_CJK_ROMAN = 2,
+ HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_CJK_ROMAN = 3,
+
+ _HB_AAT_LAYOUT_FEATURE_SELECTOR_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
+} hb_aat_layout_feature_selector_t;
+
+HB_EXTERN unsigned int
+hb_aat_layout_get_feature_types (hb_face_t *face,
+ unsigned int start_offset,
+ unsigned int *feature_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_type_t *features /* OUT. May be NULL. */);
+
+HB_EXTERN hb_ot_name_id_t
+hb_aat_layout_feature_type_get_name_id (hb_face_t *face,
+ hb_aat_layout_feature_type_t feature_type);
+
+typedef struct hb_aat_layout_feature_selector_info_t
+{
+ hb_ot_name_id_t name_id;
+ hb_aat_layout_feature_selector_t enable;
+ hb_aat_layout_feature_selector_t disable;
+ /*< private >*/
+ unsigned int reserved;
+} hb_aat_layout_feature_selector_info_t;
+
+#define HB_AAT_LAYOUT_NO_SELECTOR_INDEX 0xFFFFu
+
+HB_EXTERN unsigned int
+hb_aat_layout_feature_type_get_selector_infos (hb_face_t *face,
+ hb_aat_layout_feature_type_t feature_type,
+ unsigned int start_offset,
+ unsigned int *selector_count, /* IN/OUT. May be NULL. */
+ hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
+ unsigned int *default_index /* OUT. May be NULL. */);
+
+
+HB_END_DECLS
+
+#endif /* HB_AAT_LAYOUT_H */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.hh
index ac9c535395a..5fd47ed62ad 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-layout.hh
@@ -29,15 +29,66 @@
#include "hb.hh"
-#include "hb-font.hh"
-#include "hb-buffer.hh"
-#include "hb-open-type.hh"
+#include "hb-ot-shape.hh"
+struct hb_aat_feature_mapping_t
+{
+ hb_tag_t otFeatureTag;
+ hb_aat_layout_feature_type_t aatFeatureType;
+ hb_aat_layout_feature_selector_t selectorToEnable;
+ hb_aat_layout_feature_selector_t selectorToDisable;
+
+ static inline int cmp (const void *key_, const void *entry_)
+ {
+ hb_tag_t key = * (unsigned int *) key_;
+ const hb_aat_feature_mapping_t * entry = (const hb_aat_feature_mapping_t *) entry_;
+ return key < entry->otFeatureTag ? -1 :
+ key > entry->otFeatureTag ? 1 :
+ 0;
+ }
+};
+
+HB_INTERNAL const hb_aat_feature_mapping_t *
+hb_aat_layout_find_feature_mapping (hb_tag_t tag);
+
+HB_INTERNAL void
+hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
+ hb_aat_map_t *map);
+
+HB_INTERNAL bool
+hb_aat_layout_has_substitution (hb_face_t *face);
+
+HB_INTERNAL void
+hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
+
HB_INTERNAL void
-hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer);
+hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer);
HB_INTERNAL void
-hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer);
+hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer);
+
+HB_INTERNAL bool
+hb_aat_layout_has_positioning (hb_face_t *face);
+
+HB_INTERNAL void
+hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
+
+HB_INTERNAL bool
+hb_aat_layout_has_tracking (hb_face_t *face);
+
+HB_INTERNAL void
+hb_aat_layout_track (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
+
+HB_INTERNAL hb_language_t
+_hb_aat_language_get (hb_face_t *face,
+ unsigned int i);
+
#endif /* HB_AAT_LAYOUT_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-ltag-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-ltag-table.hh
index 08a1b51a9e8..8a42b3510bf 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-ltag-table.hh
+++ b/chromium/third_party/harfbuzz-ng/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.hh"
+#include "hb-open-type.hh"
/*
* ltag -- Language Tag
@@ -36,9 +36,13 @@
namespace AAT {
+using namespace OT;
+
struct FTStringRange
{
+ friend struct ltag;
+
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
@@ -58,10 +62,19 @@ struct ltag
{
static const hb_tag_t tableTag = HB_AAT_TAG_ltag;
+ inline hb_language_t get_language (unsigned int i) const
+ {
+ const FTStringRange &range = tagRanges[i];
+ return hb_language_from_string ((const char *) (this+range.tag).arrayZ,
+ range.length);
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) && tagRanges.sanitize (c, this)));
+ return_trace (likely (c->check_struct (this) &&
+ version >= 1 &&
+ tagRanges.sanitize (c, this)));
}
protected:
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.cc
new file mode 100644
index 00000000000..1c65a6759bc
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.cc
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2009,2010 Red Hat, Inc.
+ * Copyright © 2010,2011,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
+ */
+
+#include "hb-aat-map.hh"
+
+#include "hb-aat-layout.hh"
+
+
+void hb_aat_map_builder_t::add_feature (hb_tag_t tag,
+ unsigned int value)
+{
+ if (tag == HB_TAG ('a','a','l','t'))
+ {
+ feature_info_t *info = features.push();
+ info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
+ info->setting = (hb_aat_layout_feature_selector_t) value;
+ return;
+ }
+
+ const hb_aat_feature_mapping_t *mapping = hb_aat_layout_find_feature_mapping (tag);
+ if (!mapping) return;
+
+ feature_info_t *info = features.push();
+ info->type = mapping->aatFeatureType;
+ info->setting = value ? mapping->selectorToEnable : mapping->selectorToDisable;
+}
+
+void
+hb_aat_map_builder_t::compile (hb_aat_map_t &m)
+{
+ /* Sort features and merge duplicates */
+ if (features.len)
+ {
+ features.qsort ();
+ unsigned int j = 0;
+ for (unsigned int i = 1; i < features.len; i++)
+ if (features[i].type != features[j].type)
+ features[++j] = features[i];
+ features.shrink (j + 1);
+ }
+
+ hb_aat_layout_compile_map (this, &m);
+}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.hh
new file mode 100644
index 00000000000..b033e336872
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat-map.hh
@@ -0,0 +1,94 @@
+/*
+ * 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_AAT_MAP_HH
+#define HB_AAT_MAP_HH
+
+#include "hb.hh"
+
+
+struct hb_aat_map_t
+{
+ friend struct hb_aat_map_builder_t;
+
+ public:
+
+ inline void init (void)
+ {
+ memset (this, 0, sizeof (*this));
+ chain_flags.init ();
+ }
+ inline void fini (void)
+ {
+ chain_flags.fini ();
+ }
+
+ public:
+ hb_vector_t<hb_mask_t, 1> chain_flags;
+};
+
+struct hb_aat_map_builder_t
+{
+ public:
+
+ HB_INTERNAL hb_aat_map_builder_t (hb_face_t *face_,
+ const hb_segment_properties_t *props_ HB_UNUSED) :
+ face (face_) {}
+
+ HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value=1);
+
+ HB_INTERNAL void compile (hb_aat_map_t &m);
+
+ public:
+ struct feature_info_t
+ {
+ hb_aat_layout_feature_type_t type;
+ hb_aat_layout_feature_selector_t setting;
+ unsigned seq; /* For stable sorting only. */
+
+ static int cmp (const void *pa, const void *pb)
+ {
+ const feature_info_t *a = (const feature_info_t *) pa;
+ const feature_info_t *b = (const feature_info_t *) pb;
+ return (a->type != b->type) ? (a->type < b->type ? -1 : 1) :
+ (a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0);
+ }
+
+ int cmp (unsigned int ty) const
+ {
+ return (type != ty) ? (type < ty ? -1 : 1) : 0;
+ }
+ };
+
+ public:
+ hb_face_t *face;
+
+ public:
+ hb_vector_t<feature_info_t, 32> features;
+};
+
+
+#endif /* HB_AAT_MAP_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.h b/chromium/third_party/harfbuzz-ng/src/src/hb-aat.h
index 54fb747f582..c14313d1e2e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-aat.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Red Hat, Inc.
+ * Copyright © 2018 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -20,40 +20,19 @@
* 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
*/
-#ifndef HB_OT_H_IN
-#error "Include <hb-ot.h> instead."
-#endif
-
-#ifndef HB_OT_TAG_H
-#define HB_OT_TAG_H
+#ifndef HB_AAT_H
+#define HB_AAT_H
+#define HB_AAT_H_IN
#include "hb.h"
-HB_BEGIN_DECLS
-
-
-#define HB_OT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
-#define HB_OT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
-
-HB_EXTERN void
-hb_ot_tags_from_script (hb_script_t script,
- hb_tag_t *script_tag_1,
- hb_tag_t *script_tag_2);
-
-HB_EXTERN hb_script_t
-hb_ot_tag_to_script (hb_tag_t tag);
-
-HB_EXTERN hb_tag_t
-hb_ot_tag_from_language (hb_language_t language);
-
-HB_EXTERN hb_language_t
-hb_ot_tag_to_language (hb_tag_t tag);
+#include "hb-aat-layout.h"
+HB_BEGIN_DECLS
HB_END_DECLS
-#endif /* HB_OT_TAG_H */
+#undef HB_AAT_H_IN
+#endif /* HB_AAT_H */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-atomic.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-atomic.hh
index 5cb7ca5d53d..265de1267ac 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-atomic.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-atomic.hh
@@ -100,7 +100,7 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#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__))
+#elif !defined(HB_NO_MT) && defined(_WIN32)
#include <windows.h>
@@ -257,43 +257,43 @@ static_assert ((sizeof (long) == sizeof (void *)), "");
inline void hb_atomic_int_impl_set (int *AI, int v) { _hb_memory_w_barrier (); *AI = v; }
#endif
#ifndef hb_atomic_int_impl_get
-inline int hb_atomic_int_impl_get (int *AI) { int v = *AI; _hb_memory_r_barrier (); return v; }
+inline int hb_atomic_int_impl_get (const int *AI) { int v = *AI; _hb_memory_r_barrier (); return v; }
#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; }
+inline void *hb_atomic_ptr_impl_get (void ** const 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 void set (int v_) const { hb_atomic_int_impl_set (&v, v_); }
+ inline void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); }
+ inline void set (int v_) { hb_atomic_int_impl_set (&v, v_); }
inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); }
inline int get (void) const { return hb_atomic_int_impl_get (&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;
+ int v;
};
-template <typename T> struct hb_remove_ptr_t { typedef T value; };
-template <typename T> struct hb_remove_ptr_t<T *> { typedef T value; };
-
#define HB_ATOMIC_PTR_INIT(V) {V}
template <typename P>
struct hb_atomic_ptr_t
{
- typedef typename hb_remove_ptr_t<P>::value T;
+ typedef typename hb_remove_pointer (P) 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 void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
inline T *get_relaxed (void) const { return (T *) 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 ((void **) &v, (void *) old, (void *) new_); }
- mutable T *v;
+ inline T * operator -> (void) const { return get (); }
+ template <typename C> inline operator C * (void) const { return get (); }
+
+ T *v;
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-blob.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-blob.cc
index c1ed0f2a77b..8ebedca7887 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-blob.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-blob.cc
@@ -40,19 +40,18 @@
#include <stdlib.h>
-DEFINE_NULL_INSTANCE (hb_blob_t) =
-{
- HB_OBJECT_HEADER_STATIC,
-
- true, /* immutable */
-
- nullptr, /* data */
- 0, /* length */
- HB_MEMORY_MODE_READONLY, /* mode */
+/**
+ * SECTION: hb-blob
+ * @title: hb-blob
+ * @short_description: Binary data containers
+ * @include: hb.h
+ *
+ * Blobs wrap a chunk of binary data to handle lifecycle management of data
+ * while it is passed between client and HarfBuzz. Blobs are primarily used
+ * to create font faces, but also to access font face tables, as well as
+ * pass around other binary data.
+ **/
- nullptr, /* user_data */
- nullptr /* destroy */
-};
/**
* hb_blob_create: (skip)
@@ -138,7 +137,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
{
hb_blob_t *blob;
- if (!length || offset >= parent->length)
+ if (!length || !parent || offset >= parent->length)
return hb_blob_get_empty ();
hb_blob_make_immutable (parent);
@@ -286,12 +285,10 @@ hb_blob_get_user_data (hb_blob_t *blob,
void
hb_blob_make_immutable (hb_blob_t *blob)
{
- if (hb_object_is_inert (blob))
- return;
- if (blob->immutable)
+ if (hb_object_is_immutable (blob))
return;
- blob->immutable = true;
+ hb_object_make_immutable (blob);
}
/**
@@ -307,7 +304,7 @@ hb_blob_make_immutable (hb_blob_t *blob)
hb_bool_t
hb_blob_is_immutable (hb_blob_t *blob)
{
- return blob->immutable;
+ return hb_object_is_immutable (blob);
}
@@ -441,7 +438,7 @@ hb_blob_t::try_make_writable_inplace (void)
bool
hb_blob_t::try_make_writable (void)
{
- if (this->immutable)
+ if (hb_object_is_immutable (this))
return false;
if (this->mode == HB_MEMORY_MODE_WRITABLE)
@@ -484,11 +481,11 @@ hb_blob_t::try_make_writable (void)
# include <fcntl.h>
#endif
-#if defined(_WIN32) || defined(__CYGWIN__)
+#ifdef _WIN32
# include <windows.h>
#else
-# ifndef _O_BINARY
-# define _O_BINARY 0
+# ifndef O_BINARY
+# define O_BINARY 0
# endif
#endif
@@ -500,18 +497,19 @@ struct hb_mapped_file_t
{
char *contents;
unsigned long length;
-#if defined(_WIN32) || defined(__CYGWIN__)
+#ifdef _WIN32
HANDLE mapping;
#endif
};
-#if (defined(HAVE_MMAP) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_MMAP)
+#if (defined(HAVE_MMAP) || defined(_WIN32)) && !defined(HB_NO_MMAP)
static void
-_hb_mapped_file_destroy (hb_mapped_file_t *file)
+_hb_mapped_file_destroy (void *file_)
{
+ hb_mapped_file_t *file = (hb_mapped_file_t *) file_;
#ifdef HAVE_MMAP
munmap (file->contents, file->length);
-#elif defined(_WIN32) || defined(__CYGWIN__)
+#elif defined(_WIN32)
UnmapViewOfFile (file->contents);
CloseHandle (file->mapping);
#else
@@ -539,7 +537,7 @@ hb_blob_create_from_file (const char *file_name)
hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t));
if (unlikely (!file)) return hb_blob_get_empty ();
- int fd = open (file_name, O_RDONLY | _O_BINARY, 0);
+ int fd = open (file_name, O_RDONLY | O_BINARY, 0);
if (unlikely (fd == -1)) goto fail_without_close;
struct stat st;
@@ -562,7 +560,7 @@ fail:
fail_without_close:
free (file);
-#elif (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_MMAP)
+#elif defined(_WIN32) && !defined(HB_NO_MMAP)
hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t));
if (unlikely (!file)) return hb_blob_get_empty ();
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-blob.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-blob.hh
index bee8c9794ad..bf2132bda99 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-blob.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-blob.hh
@@ -60,7 +60,7 @@ struct hb_blob_t
template <typename Type>
inline const Type* as (void) const
{
- return unlikely (!data) ? &Null(Type) : reinterpret_cast<const Type *> (data);
+ return length < hb_null_size (Type) ? &Null(Type) : reinterpret_cast<const Type *> (data);
}
inline hb_bytes_t as_bytes (void) const
{
@@ -69,9 +69,6 @@ struct hb_blob_t
public:
hb_object_header_t header;
- ASSERT_POD ();
-
- bool immutable;
const char *data;
unsigned int length;
@@ -80,7 +77,30 @@ struct hb_blob_t
void *user_data;
hb_destroy_func_t destroy;
};
-DECLARE_NULL_INSTANCE (hb_blob_t);
+
+
+/*
+ * hb_blob_ptr_t
+ */
+
+template <typename P>
+struct hb_blob_ptr_t
+{
+ typedef typename hb_remove_pointer (P) T;
+
+ inline hb_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {}
+ inline hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; }
+ inline const T * operator -> (void) const { return get (); }
+ inline const T & operator * (void) const { return *get (); }
+ template <typename C> inline operator const C * (void) const { return get (); }
+ inline operator const char * (void) const { return (const char *) get (); }
+ inline const T * get (void) const { return b->as<T> (); }
+ inline hb_blob_t * get_blob (void) const { return b.get_raw (); }
+ inline unsigned int get_length (void) const { return b.get ()->length; }
+ inline void destroy (void) { hb_blob_destroy (b.get ()); b = nullptr; }
+
+ hb_nonnull_ptr_t<hb_blob_t> b;
+};
#endif /* HB_BLOB_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer-serialize.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer-serialize.cc
index 1b6d14731fd..1bd603d4474 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer-serialize.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer-serialize.cc
@@ -58,7 +58,7 @@ hb_buffer_serialize_list_formats (void)
* @str is a valid buffer serialization format, use
* hb_buffer_serialize_list_formats() to get the list of supported formats.
*
- * Return value:
+ * Return value:
* The parsed #hb_buffer_serialize_format_t.
*
* Since: 0.9.7
@@ -319,7 +319,7 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
* ## json
* TODO.
*
- * Return value:
+ * Return value:
* The number of serialized items.
*
* Since: 0.9.7
@@ -425,14 +425,14 @@ parse_int (const char *pp, const char *end, int32_t *pv)
* hb_buffer_deserialize_glyphs:
* @buffer: an #hb_buffer_t buffer.
* @buf: (array length=buf_len):
- * @buf_len:
+ * @buf_len:
* @end_ptr: (out):
- * @font:
- * @format:
+ * @font:
+ * @format:
*
- *
*
- * Return value:
+ *
+ * Return value:
*
* Since: 0.9.7
**/
@@ -440,8 +440,8 @@ hb_bool_t
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
const char *buf,
int buf_len, /* -1 means nul-terminated */
- const char **end_ptr, /* May be nullptr */
- hb_font_t *font, /* May be nullptr */
+ const char **end_ptr, /* May be NULL */
+ hb_font_t *font, /* May be NULL */
hb_buffer_serialize_format_t format)
{
const char *end;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.cc
index b93b243c90d..1a5547b35f3 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.cc
@@ -33,14 +33,15 @@
/**
* SECTION: hb-buffer
- * @title: Buffers
+ * @title: hb-buffer
* @short_description: Input and output buffers
* @include: hb.h
*
* Buffers serve dual role in HarfBuzz; they hold the input characters that are
- * passed hb_shape(), and after shaping they hold the output glyphs.
+ * passed to hb_shape(), and after shaping they hold the output glyphs.
**/
+
/**
* hb_segment_properties_equal:
* @a: first #hb_segment_properties_t to compare.
@@ -182,7 +183,11 @@ hb_buffer_t::shift_forward (unsigned int count)
if (idx + count > len)
{
/* Under memory failure we might expose this area. At least
- * clean it up. Oh well... */
+ * clean it up. Oh well...
+ *
+ * Ideally, we should at least set Default_Ignorable bits on
+ * these, as well as consistent cluster values. But the former
+ * is layering violation... */
memset (info + len, 0, (idx + count - len) * sizeof (info[0]));
}
len += count;
@@ -212,13 +217,14 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size)
void
hb_buffer_t::reset (void)
{
- if (unlikely (hb_object_is_inert (this)))
+ if (unlikely (hb_object_is_immutable (this)))
return;
hb_unicode_funcs_destroy (unicode);
unicode = hb_unicode_funcs_reference (hb_unicode_funcs_get_default ());
flags = HB_BUFFER_FLAG_DEFAULT;
replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT;
+ invisible = 0;
clear ();
}
@@ -226,7 +232,7 @@ hb_buffer_t::reset (void)
void
hb_buffer_t::clear (void)
{
- if (unlikely (hb_object_is_inert (this)))
+ if (unlikely (hb_object_is_immutable (this)))
return;
hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
@@ -283,7 +289,7 @@ hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info)
void
hb_buffer_t::remove_output (void)
{
- if (unlikely (hb_object_is_inert (this)))
+ if (unlikely (hb_object_is_immutable (this)))
return;
have_output = false;
@@ -296,7 +302,7 @@ hb_buffer_t::remove_output (void)
void
hb_buffer_t::clear_output (void)
{
- if (unlikely (hb_object_is_inert (this)))
+ if (unlikely (hb_object_is_immutable (this)))
return;
have_output = true;
@@ -309,7 +315,7 @@ hb_buffer_t::clear_output (void)
void
hb_buffer_t::clear_positions (void)
{
- if (unlikely (hb_object_is_inert (this)))
+ if (unlikely (hb_object_is_immutable (this)))
return;
have_output = false;
@@ -354,6 +360,8 @@ hb_buffer_t::replace_glyphs (unsigned int num_in,
{
if (unlikely (!make_room_for (num_in, num_out))) return;
+ assert (idx + num_in <= len);
+
merge_clusters (idx, idx + num_in);
hb_glyph_info_t orig_info = info[idx];
@@ -398,8 +406,14 @@ hb_buffer_t::move_to (unsigned int i)
unsigned int count = out_len - i;
/* This will blow in our face if memory allocation fails later
- * in this same lookup... */
- if (unlikely (idx < count && !shift_forward (count + 32))) return false;
+ * in this same lookup...
+ *
+ * We used to shift with extra 32 items, instead of the 0 below.
+ * But that would leave empty slots in the buffer in case of allocation
+ * failures. Setting to zero for now to avoid other problems (see
+ * comments in shift_forward(). This can cause O(N^2) behavior more
+ * severely than adding 32 empty slots can... */
+ if (unlikely (idx < count && !shift_forward (count + 0))) return false;
assert (idx >= count);
@@ -665,6 +679,7 @@ DEFINE_NULL_INSTANCE (hb_buffer_t) =
HB_BUFFER_FLAG_DEFAULT,
HB_BUFFER_CLUSTER_LEVEL_DEFAULT,
HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT,
+ 0, /* invisible */
HB_BUFFER_SCRATCH_FLAG_DEFAULT,
HB_BUFFER_MAX_LEN_DEFAULT,
HB_BUFFER_MAX_OPS_DEFAULT,
@@ -858,7 +873,7 @@ void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode_funcs)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
if (!unicode_funcs)
@@ -905,7 +920,7 @@ hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->props.direction = direction;
@@ -949,7 +964,7 @@ void
hb_buffer_set_script (hb_buffer_t *buffer,
hb_script_t script)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->props.script = script;
@@ -984,7 +999,7 @@ hb_buffer_get_script (hb_buffer_t *buffer)
* are orthogonal to the scripts, and though they are related, they are
* different concepts and should not be confused with each other.
*
- * Use hb_language_from_string() to convert from ISO 639 language codes to
+ * Use hb_language_from_string() to convert from BCP 47 language tags to
* #hb_language_t.
*
* Since: 0.9.2
@@ -993,7 +1008,7 @@ void
hb_buffer_set_language (hb_buffer_t *buffer,
hb_language_t language)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->props.language = language;
@@ -1031,7 +1046,7 @@ void
hb_buffer_set_segment_properties (hb_buffer_t *buffer,
const hb_segment_properties_t *props)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->props = *props;
@@ -1067,7 +1082,7 @@ void
hb_buffer_set_flags (hb_buffer_t *buffer,
hb_buffer_flags_t flags)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->flags = flags;
@@ -1103,7 +1118,7 @@ void
hb_buffer_set_cluster_level (hb_buffer_t *buffer,
hb_buffer_cluster_level_t cluster_level)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->cluster_level = cluster_level;
@@ -1142,7 +1157,7 @@ void
hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
hb_codepoint_t replacement)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->replacement = replacement;
@@ -1167,6 +1182,46 @@ hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer)
/**
+ * hb_buffer_set_invisible_glyph:
+ * @buffer: an #hb_buffer_t.
+ * @invisible: the invisible #hb_codepoint_t
+ *
+ * Sets the #hb_codepoint_t that replaces invisible characters in
+ * the shaping result. If set to zero (default), the glyph for the
+ * U+0020 SPACE character is used. Otherwise, this value is used
+ * verbatim.
+ *
+ * Since: 2.0.0
+ **/
+void
+hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
+ hb_codepoint_t invisible)
+{
+ if (unlikely (hb_object_is_immutable (buffer)))
+ return;
+
+ buffer->invisible = invisible;
+}
+
+/**
+ * hb_buffer_get_invisible_glyph:
+ * @buffer: an #hb_buffer_t.
+ *
+ * See hb_buffer_set_invisible_glyph().
+ *
+ * Return value:
+ * The @buffer invisible #hb_codepoint_t.
+ *
+ * Since: 2.0.0
+ **/
+hb_codepoint_t
+hb_buffer_get_invisible_glyph (hb_buffer_t *buffer)
+{
+ return buffer->invisible;
+}
+
+
+/**
* hb_buffer_reset:
* @buffer: an #hb_buffer_t.
*
@@ -1274,7 +1329,7 @@ hb_bool_t
hb_buffer_set_length (hb_buffer_t *buffer,
unsigned int length)
{
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return length == 0;
if (!buffer->ensure (length))
@@ -1480,7 +1535,7 @@ hb_buffer_add_utf (hb_buffer_t *buffer,
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE ||
(!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID));
- if (unlikely (hb_object_is_inert (buffer)))
+ if (unlikely (hb_object_is_immutable (buffer)))
return;
if (text_length == -1)
@@ -1611,7 +1666,7 @@ hb_buffer_add_utf32 (hb_buffer_t *buffer,
unsigned int item_offset,
int item_length)
{
- hb_buffer_add_utf<hb_utf32_t<> > (buffer, text, text_length, item_offset, item_length);
+ hb_buffer_add_utf<hb_utf32_t> (buffer, text, text_length, item_offset, item_length);
}
/**
@@ -1672,7 +1727,7 @@ hb_buffer_add_codepoints (hb_buffer_t *buffer,
unsigned int item_offset,
int item_length)
{
- hb_buffer_add_utf<hb_utf32_t<false> > (buffer, text, text_length, item_offset, item_length);
+ hb_buffer_add_utf<hb_utf32_novalidate_t> (buffer, text, text_length, item_offset, item_length);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.h b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.h
index 4c746f40126..f989d25d6b4 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.h
@@ -89,11 +89,14 @@ typedef struct hb_glyph_info_t
* of each line after line-breaking, or limiting
* the reshaping to a small piece around the
* breaking point only.
+ * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
+ *
+ * Since: 1.5.0
*/
typedef enum { /*< flags >*/
HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
- HB_GLYPH_FLAG_DEFINED = 0x00000001 /*< skip >*/ /* OR of all defined flags */
+ HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */
} hb_glyph_flags_t;
HB_EXTERN hb_glyph_flags_t
@@ -341,6 +344,13 @@ hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
HB_EXTERN hb_codepoint_t
hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer);
+HB_EXTERN void
+hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
+ hb_codepoint_t invisible);
+
+HB_EXTERN hb_codepoint_t
+hb_buffer_get_invisible_glyph (hb_buffer_t *buffer);
+
HB_EXTERN void
hb_buffer_reset (hb_buffer_t *buffer);
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.hh
index 33ddcbc870f..37adeb083bf 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-buffer.hh
@@ -86,13 +86,13 @@ HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_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_codepoint_t invisible; /* 0 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. */
@@ -228,7 +228,10 @@ struct hb_buffer_t
{
if (unlikely (!make_room_for (0, 1))) return Crap(hb_glyph_info_t);
- out_info[out_len] = info[idx];
+ if (unlikely (idx == len && !out_len))
+ return Crap(hb_glyph_info_t);
+
+ out_info[out_len] = idx < len ? info[idx] : out_info[out_len - 1];
out_info[out_len].codepoint = glyph_index;
out_len++;
@@ -259,7 +262,8 @@ struct hb_buffer_t
{
if (have_output)
{
- if (unlikely (out_info != info || out_len != idx)) {
+ if (out_info != info || out_len != idx)
+ {
if (unlikely (!make_room_for (1, 1))) return;
out_info[out_len] = info[idx];
}
@@ -268,6 +272,23 @@ struct hb_buffer_t
idx++;
}
+ /* Copies n glyphs at idx to output and advance idx.
+ * If there's no output, just advance idx. */
+ inline void
+ next_glyphs (unsigned int n)
+ {
+ if (have_output)
+ {
+ if (out_info != info || out_len != idx)
+ {
+ if (unlikely (!make_room_for (n, n))) return;
+ memmove (out_info + out_len, info + idx, n * sizeof (out_info[0]));
+ }
+ out_len += n;
+ }
+
+ idx += n;
+ }
/* Advance idx without copying to output. */
inline void skip_glyph (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-common.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-common.cc
index 41b1601de60..c3cffccb189 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-common.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-common.cc
@@ -36,6 +36,16 @@
#endif
+/**
+ * SECTION:hb-common
+ * @title: hb-common
+ * @short_description: Common data types
+ * @include: hb.h
+ *
+ * Common data types used across HarfBuzz are defined here.
+ **/
+
+
/* hb_options_t */
hb_atomic_int_t _hb_options;
@@ -45,10 +55,29 @@ _hb_options_init (void)
{
hb_options_union_t u;
u.i = 0;
- u.opts.initialized = 1;
+ u.opts.initialized = true;
- char *c = getenv ("HB_OPTIONS");
- u.opts.uniscribe_bug_compatible = c && strstr (c, "uniscribe-bug-compatible");
+ const char *c = getenv ("HB_OPTIONS");
+ if (c)
+ {
+ while (*c)
+ {
+ const char *p = strchr (c, ':');
+ if (!p)
+ p = c + strlen (c);
+
+#define OPTION(name, symbol) \
+ if (0 == strncmp (c, name, p - c) && strlen (name) == p - c) u.opts.symbol = true;
+
+ OPTION ("uniscribe-bug-compatible", uniscribe_bug_compatible);
+ OPTION ("aat", aat);
+
+#undef OPTION
+
+ c = *p ? p + 1 : p;
+ }
+
+ }
/* This is idempotent and threadsafe. */
_hb_options.set_relaxed (u.i);
@@ -175,7 +204,7 @@ static const char canon_map[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0,
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
- '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '-',
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0
@@ -247,12 +276,12 @@ struct hb_language_item_t {
static hb_atomic_ptr_t <hb_language_item_t> langs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void
free_langs (void)
{
retry:
- hb_language_item_t *first_lang = langs.get ();
+ hb_language_item_t *first_lang = langs;
if (unlikely (!langs.cmpexch (first_lang, nullptr)))
goto retry;
@@ -269,7 +298,7 @@ static hb_language_item_t *
lang_find_or_insert (const char *key)
{
retry:
- hb_language_item_t *first_lang = langs.get ();
+ hb_language_item_t *first_lang = langs;
for (hb_language_item_t *lang = first_lang; lang; lang = lang->next)
if (*lang == key)
@@ -294,7 +323,7 @@ retry:
goto retry;
}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
if (!first_lang)
atexit (free_langs); /* First person registers atexit() callback. */
#endif
@@ -306,14 +335,14 @@ retry:
/**
* hb_language_from_string:
* @str: (array length=len) (element-type uint8_t): a string representing
- * ISO 639 language code
+ * a BCP 47 language tag
* @len: length of the @str, or -1 if it is %NULL-terminated.
*
- * Converts @str representing an ISO 639 language code to the corresponding
+ * Converts @str representing a BCP 47 language tag to the corresponding
* #hb_language_t.
*
* Return value: (transfer none):
- * The #hb_language_t corresponding to the ISO 639 language code.
+ * The #hb_language_t corresponding to the BCP 47 language tag.
*
* Since: 0.9.2
**/
@@ -379,7 +408,7 @@ hb_language_get_default (void)
{
static hb_atomic_ptr_t <hb_language_t> default_language;
- hb_language_t language = default_language.get ();
+ hb_language_t language = default_language;
if (unlikely (language == HB_LANGUAGE_INVALID))
{
language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1);
@@ -596,6 +625,19 @@ hb_user_data_array_t::get (hb_user_data_key_t *key)
/* hb_version */
+
+/**
+ * SECTION:hb-version
+ * @title: hb-version
+ * @short_description: Information about the version of HarfBuzz in use
+ * @include: hb.h
+ *
+ * These functions and macros allow accessing version of the HarfBuzz
+ * library used at compile- as well as run-time, and to direct code
+ * conditionally based on those versions, again, at compile- or run-time.
+ **/
+
+
/**
* hb_version:
* @major: (out): Library major version component.
@@ -738,18 +780,18 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv)
#ifdef USE_XLOCALE
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_C_locale (void);
#endif
-static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<HB_LOCALE_T>::value,
+static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (HB_LOCALE_T),
hb_C_locale_lazy_loader_t>
{
static inline HB_LOCALE_T create (void)
{
HB_LOCALE_T C_locale = HB_CREATE_LOCALE ("C");
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_C_locale);
#endif
@@ -765,7 +807,7 @@ static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<HB_LO
}
} static_C_locale;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_C_locale (void)
{
@@ -892,7 +934,7 @@ parse_feature_indices (const char **pp, const char *end, hb_feature_t *feature)
has_start = parse_uint (pp, end, &feature->start);
- if (parse_char (pp, end, ':')) {
+ if (parse_char (pp, end, ':') || parse_char (pp, end, ';')) {
parse_uint (pp, end, &feature->end);
} else {
if (has_start)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-common.h b/chromium/third_party/harfbuzz-ng/src/src/hb-common.h
index 6101d72fe87..ae23698a576 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-common.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-common.h
@@ -33,6 +33,10 @@
#ifndef HB_COMMON_H
#define HB_COMMON_H
+#ifndef HB_EXTERN
+#define HB_EXTERN extern
+#endif
+
#ifndef HB_BEGIN_DECLS
# ifdef __cplusplus
# define HB_BEGIN_DECLS extern "C" {
@@ -63,6 +67,23 @@ typedef unsigned __int64 uint64_t;
# include <stdint.h>
#endif
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define HB_DEPRECATED __attribute__((__deprecated__))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
+#define HB_DEPRECATED __declspec(deprecated)
+#else
+#define HB_DEPRECATED
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
+#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
+#define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
+#else
+#define HB_DEPRECATED_FOR(f) HB_DEPRECATED
+#endif
+
+
HB_BEGIN_DECLS
@@ -384,13 +405,13 @@ typedef void (*hb_destroy_func_t) (void *user_data);
/**
* HB_FEATURE_GLOBAL_START
*
- * Since: REPLACEME
+ * Since: 2.0.0
*/
#define HB_FEATURE_GLOBAL_START 0
/**
* HB_FEATURE_GLOBAL_END
*
- * Since: REPLACEME
+ * Since: 2.0.0
*/
#define HB_FEATURE_GLOBAL_END ((unsigned int) -1)
@@ -427,6 +448,50 @@ HB_EXTERN void
hb_variation_to_string (hb_variation_t *variation,
char *buf, unsigned int size);
+/**
+ * hb_color_t:
+ *
+ * Data type for holding color values.
+ *
+ * Since: 2.1.0
+ */
+typedef uint32_t hb_color_t;
+
+#define HB_COLOR(b,g,r,a) ((hb_color_t) HB_TAG ((b),(g),(r),(a)))
+
+/**
+ * hb_color_get_alpha:
+ *
+ *
+ *
+ * Since: 2.1.0
+ */
+#define hb_color_get_alpha(color) ((color) & 0xFF)
+/**
+ * hb_color_get_red:
+ *
+ *
+ *
+ * Since: 2.1.0
+ */
+#define hb_color_get_red(color) (((color) >> 8) & 0xFF)
+/**
+ * hb_color_get_green:
+ *
+ *
+ *
+ * Since: 2.1.0
+ */
+#define hb_color_get_green(color) (((color) >> 16) & 0xFF)
+/**
+ * hb_color_get_blue:
+ *
+ *
+ *
+ * Since: 2.1.0
+ */
+#define hb_color_get_blue(color) (((color) >> 24) & 0xFF)
+
HB_END_DECLS
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-coretext.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-coretext.cc
index ab04d72f690..918f649da6c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-coretext.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-coretext.cc
@@ -26,14 +26,23 @@
* Google Author(s): Behdad Esfahbod
*/
-#define HB_SHAPER coretext
-
#include "hb.hh"
#include "hb-shaper-impl.hh"
#include "hb-coretext.h"
+#include "hb-aat-layout.hh"
#include <math.h>
+
+/**
+ * SECTION:hb-coretext
+ * @title: hb-coretext
+ * @short_description: CoreText integration
+ * @include: hb-coretext.h
+ *
+ * Functions for using HarfBuzz with the CoreText fonts.
+ **/
+
/* https://developer.apple.com/documentation/coretext/1508745-ctfontcreatewithgraphicsfont */
#define HB_CORETEXT_DEFAULT_FONT_SIZE 12.f
@@ -90,11 +99,6 @@ _hb_cg_font_release (void *data)
}
-HB_SHAPER_DATA_ENSURE_DEFINE(coretext, face)
-HB_SHAPER_DATA_ENSURE_DEFINE_WITH_CONDITION(coretext, font,
- fabs (CTFontGetSize((CTFontRef) data) - coretext_font_size_from_ptem (font->ptem)) <= .5
-)
-
static CTFontDescriptorRef
get_last_resort_font_desc (void)
{
@@ -210,7 +214,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
}
CFURLRef original_url = nullptr;
-#if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
ATSFontRef atsFont;
FSRef fsref;
OSStatus status;
@@ -240,7 +244,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
* process in Blink. This can be detected by the new file URL location
* that the newly found font points to. */
CFURLRef new_url = nullptr;
-#if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
atsFont = CTFontGetPlatformFont (new_ct_font, NULL);
status = ATSFontGetFileReference (atsFont, &fsref);
if (status == noErr)
@@ -301,8 +305,7 @@ hb_coretext_face_create (CGFontRef cg_font)
CGFontRef
hb_coretext_face_get_cg_font (hb_face_t *face)
{
- if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return nullptr;
- return (CGFontRef) HB_SHAPER_DATA_GET (face);
+ return (CGFontRef) (const void *) face->data.coretext;
}
@@ -310,8 +313,9 @@ hb_coretext_font_data_t *
_hb_coretext_shaper_font_data_create (hb_font_t *font)
{
hb_face_t *face = font->face;
- if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return nullptr;
- CGFontRef cg_font = (CGFontRef) HB_SHAPER_DATA_GET (face);
+ const hb_coretext_face_data_t *face_data = face->data.coretext;
+ if (unlikely (!face_data)) return nullptr;
+ CGFontRef cg_font = (CGFontRef) (const void *) face->data.coretext;
CTFontRef ct_font = create_ct_font (cg_font, coretext_font_size_from_ptem (font->ptem));
@@ -330,6 +334,38 @@ _hb_coretext_shaper_font_data_destroy (hb_coretext_font_data_t *data)
CFRelease ((CTFontRef) data);
}
+static const hb_coretext_font_data_t *
+hb_coretext_font_data_sync (hb_font_t *font)
+{
+retry:
+ const hb_coretext_font_data_t *data = font->data.coretext;
+ if (unlikely (!data)) return nullptr;
+
+ if (fabs (CTFontGetSize((CTFontRef) data) - coretext_font_size_from_ptem (font->ptem)) > .5)
+ {
+ /* XXX-MT-bug
+ * Note that evaluating condition above can be dangerous if another thread
+ * got here first and destructed data. That's, as always, bad use pattern.
+ * If you modify the font (change font size), other threads must not be
+ * using it at the same time. However, since this check is delayed to
+ * when one actually tries to shape something, this is a XXX race condition
+ * (and the only one we have that I know of) right now. Ie. you modify the
+ * font size in one thread, then (supposedly safely) try to use it from two
+ * or more threads and BOOM! I'm not sure how to fix this. We want RCU.
+ */
+
+ /* Drop and recreate. */
+ /* If someone dropped it in the mean time, throw it away and don't touch it.
+ * Otherwise, destruct it. */
+ if (likely (font->data.coretext.cmpexch (const_cast<hb_coretext_font_data_t *> (data), nullptr)))
+ _hb_coretext_shaper_font_data_destroy (const_cast<hb_coretext_font_data_t *> (data));
+ else
+ goto retry;
+ }
+ return font->data.coretext;
+}
+
+
/*
* Since: 1.7.2
*/
@@ -342,13 +378,13 @@ hb_coretext_font_create (CTFontRef ct_font)
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
- if (unlikely (hb_object_is_inert (font)))
+ if (unlikely (hb_object_is_immutable (font)))
return font;
hb_font_set_ptem (font, coretext_font_size_to_ptem (CTFontGetSize(ct_font)));
/* Let there be dragons here... */
- HB_SHAPER_DATA (HB_SHAPER, font).set_relaxed ((hb_coretext_font_data_t *) CFRetain (ct_font));
+ font->data.coretext.cmpexch (nullptr, (hb_coretext_font_data_t *) CFRetain (ct_font));
return font;
}
@@ -356,31 +392,8 @@ hb_coretext_font_create (CTFontRef ct_font)
CTFontRef
hb_coretext_font_get_ct_font (hb_font_t *font)
{
- if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return nullptr;
- return (CTFontRef) HB_SHAPER_DATA_GET (font);
-}
-
-
-
-/*
- * shaper shape_plan data
- */
-
-struct hb_coretext_shape_plan_data_t {};
-
-hb_coretext_shape_plan_data_t *
-_hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_coretext_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shape_plan_data_t *data HB_UNUSED)
-{
+ const hb_coretext_font_data_t *data = hb_coretext_font_data_sync (font);
+ return data ? (CTFontRef) data : nullptr;
}
@@ -431,185 +444,6 @@ struct range_record_t {
};
-/* The following enum members are added in OS X 10.8. */
-#define kAltHalfWidthTextSelector 6
-#define kAltProportionalTextSelector 5
-#define kAlternateHorizKanaOffSelector 1
-#define kAlternateHorizKanaOnSelector 0
-#define kAlternateKanaType 34
-#define kAlternateVertKanaOffSelector 3
-#define kAlternateVertKanaOnSelector 2
-#define kCaseSensitiveLayoutOffSelector 1
-#define kCaseSensitiveLayoutOnSelector 0
-#define kCaseSensitiveLayoutType 33
-#define kCaseSensitiveSpacingOffSelector 3
-#define kCaseSensitiveSpacingOnSelector 2
-#define kContextualAlternatesOffSelector 1
-#define kContextualAlternatesOnSelector 0
-#define kContextualAlternatesType 36
-#define kContextualLigaturesOffSelector 19
-#define kContextualLigaturesOnSelector 18
-#define kContextualSwashAlternatesOffSelector 5
-#define kContextualSwashAlternatesOnSelector 4
-#define kDefaultLowerCaseSelector 0
-#define kDefaultUpperCaseSelector 0
-#define kHistoricalLigaturesOffSelector 21
-#define kHistoricalLigaturesOnSelector 20
-#define kHojoCharactersSelector 12
-#define kJIS2004CharactersSelector 11
-#define kLowerCasePetiteCapsSelector 2
-#define kLowerCaseSmallCapsSelector 1
-#define kLowerCaseType 37
-#define kMathematicalGreekOffSelector 11
-#define kMathematicalGreekOnSelector 10
-#define kNLCCharactersSelector 13
-#define kQuarterWidthTextSelector 4
-#define kScientificInferiorsSelector 4
-#define kStylisticAltEightOffSelector 17
-#define kStylisticAltEightOnSelector 16
-#define kStylisticAltEighteenOffSelector 37
-#define kStylisticAltEighteenOnSelector 36
-#define kStylisticAltElevenOffSelector 23
-#define kStylisticAltElevenOnSelector 22
-#define kStylisticAltFifteenOffSelector 31
-#define kStylisticAltFifteenOnSelector 30
-#define kStylisticAltFiveOffSelector 11
-#define kStylisticAltFiveOnSelector 10
-#define kStylisticAltFourOffSelector 9
-#define kStylisticAltFourOnSelector 8
-#define kStylisticAltFourteenOffSelector 29
-#define kStylisticAltFourteenOnSelector 28
-#define kStylisticAltNineOffSelector 19
-#define kStylisticAltNineOnSelector 18
-#define kStylisticAltNineteenOffSelector 39
-#define kStylisticAltNineteenOnSelector 38
-#define kStylisticAltOneOffSelector 3
-#define kStylisticAltOneOnSelector 2
-#define kStylisticAltSevenOffSelector 15
-#define kStylisticAltSevenOnSelector 14
-#define kStylisticAltSeventeenOffSelector 35
-#define kStylisticAltSeventeenOnSelector 34
-#define kStylisticAltSixOffSelector 13
-#define kStylisticAltSixOnSelector 12
-#define kStylisticAltSixteenOffSelector 33
-#define kStylisticAltSixteenOnSelector 32
-#define kStylisticAltTenOffSelector 21
-#define kStylisticAltTenOnSelector 20
-#define kStylisticAltThirteenOffSelector 27
-#define kStylisticAltThirteenOnSelector 26
-#define kStylisticAltThreeOffSelector 7
-#define kStylisticAltThreeOnSelector 6
-#define kStylisticAltTwelveOffSelector 25
-#define kStylisticAltTwelveOnSelector 24
-#define kStylisticAltTwentyOffSelector 41
-#define kStylisticAltTwentyOnSelector 40
-#define kStylisticAltTwoOffSelector 5
-#define kStylisticAltTwoOnSelector 4
-#define kStylisticAlternativesType 35
-#define kSwashAlternatesOffSelector 3
-#define kSwashAlternatesOnSelector 2
-#define kThirdWidthTextSelector 3
-#define kTraditionalNamesCharactersSelector 14
-#define kUpperCasePetiteCapsSelector 2
-#define kUpperCaseSmallCapsSelector 1
-#define kUpperCaseType 38
-
-/* Table data courtesy of Apple. */
-static const struct feature_mapping_t
-{
- hb_tag_t otFeatureTag;
- uint16_t aatFeatureType;
- uint16_t selectorToEnable;
- uint16_t selectorToDisable;
-} feature_mappings[] =
-{
- { 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector },
- { 'c2sc', kUpperCaseType, kUpperCaseSmallCapsSelector, kDefaultUpperCaseSelector },
- { 'calt', kContextualAlternatesType, kContextualAlternatesOnSelector, kContextualAlternatesOffSelector },
- { 'case', kCaseSensitiveLayoutType, kCaseSensitiveLayoutOnSelector, kCaseSensitiveLayoutOffSelector },
- { 'clig', kLigaturesType, kContextualLigaturesOnSelector, kContextualLigaturesOffSelector },
- { 'cpsp', kCaseSensitiveLayoutType, kCaseSensitiveSpacingOnSelector, kCaseSensitiveSpacingOffSelector },
- { 'cswh', kContextualAlternatesType, kContextualSwashAlternatesOnSelector, kContextualSwashAlternatesOffSelector },
- { 'dlig', kLigaturesType, kRareLigaturesOnSelector, kRareLigaturesOffSelector },
- { 'expt', kCharacterShapeType, kExpertCharactersSelector, 16 },
- { 'frac', kFractionsType, kDiagonalFractionsSelector, kNoFractionsSelector },
- { 'fwid', kTextSpacingType, kMonospacedTextSelector, 7 },
- { 'halt', kTextSpacingType, kAltHalfWidthTextSelector, 7 },
- { 'hist', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector },
- { 'hkna', kAlternateKanaType, kAlternateHorizKanaOnSelector, kAlternateHorizKanaOffSelector, },
- { 'hlig', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector },
- { 'hngl', kTransliterationType, kHanjaToHangulSelector, kNoTransliterationSelector },
- { 'hojo', kCharacterShapeType, kHojoCharactersSelector, 16 },
- { 'hwid', kTextSpacingType, kHalfWidthTextSelector, 7 },
- { 'ital', kItalicCJKRomanType, kCJKItalicRomanOnSelector, kCJKItalicRomanOffSelector },
- { 'jp04', kCharacterShapeType, kJIS2004CharactersSelector, 16 },
- { 'jp78', kCharacterShapeType, kJIS1978CharactersSelector, 16 },
- { 'jp83', kCharacterShapeType, kJIS1983CharactersSelector, 16 },
- { 'jp90', kCharacterShapeType, kJIS1990CharactersSelector, 16 },
- { 'liga', kLigaturesType, kCommonLigaturesOnSelector, kCommonLigaturesOffSelector },
- { 'lnum', kNumberCaseType, kUpperCaseNumbersSelector, 2 },
- { 'mgrk', kMathematicalExtrasType, kMathematicalGreekOnSelector, kMathematicalGreekOffSelector },
- { 'nlck', kCharacterShapeType, kNLCCharactersSelector, 16 },
- { 'onum', kNumberCaseType, kLowerCaseNumbersSelector, 2 },
- { 'ordn', kVerticalPositionType, kOrdinalsSelector, kNormalPositionSelector },
- { 'palt', kTextSpacingType, kAltProportionalTextSelector, 7 },
- { 'pcap', kLowerCaseType, kLowerCasePetiteCapsSelector, kDefaultLowerCaseSelector },
- { 'pkna', kTextSpacingType, kProportionalTextSelector, 7 },
- { 'pnum', kNumberSpacingType, kProportionalNumbersSelector, 4 },
- { 'pwid', kTextSpacingType, kProportionalTextSelector, 7 },
- { 'qwid', kTextSpacingType, kQuarterWidthTextSelector, 7 },
- { 'ruby', kRubyKanaType, kRubyKanaOnSelector, kRubyKanaOffSelector },
- { 'sinf', kVerticalPositionType, kScientificInferiorsSelector, kNormalPositionSelector },
- { 'smcp', kLowerCaseType, kLowerCaseSmallCapsSelector, kDefaultLowerCaseSelector },
- { 'smpl', kCharacterShapeType, kSimplifiedCharactersSelector, 16 },
- { 'ss01', kStylisticAlternativesType, kStylisticAltOneOnSelector, kStylisticAltOneOffSelector },
- { 'ss02', kStylisticAlternativesType, kStylisticAltTwoOnSelector, kStylisticAltTwoOffSelector },
- { 'ss03', kStylisticAlternativesType, kStylisticAltThreeOnSelector, kStylisticAltThreeOffSelector },
- { 'ss04', kStylisticAlternativesType, kStylisticAltFourOnSelector, kStylisticAltFourOffSelector },
- { 'ss05', kStylisticAlternativesType, kStylisticAltFiveOnSelector, kStylisticAltFiveOffSelector },
- { 'ss06', kStylisticAlternativesType, kStylisticAltSixOnSelector, kStylisticAltSixOffSelector },
- { 'ss07', kStylisticAlternativesType, kStylisticAltSevenOnSelector, kStylisticAltSevenOffSelector },
- { 'ss08', kStylisticAlternativesType, kStylisticAltEightOnSelector, kStylisticAltEightOffSelector },
- { 'ss09', kStylisticAlternativesType, kStylisticAltNineOnSelector, kStylisticAltNineOffSelector },
- { 'ss10', kStylisticAlternativesType, kStylisticAltTenOnSelector, kStylisticAltTenOffSelector },
- { 'ss11', kStylisticAlternativesType, kStylisticAltElevenOnSelector, kStylisticAltElevenOffSelector },
- { 'ss12', kStylisticAlternativesType, kStylisticAltTwelveOnSelector, kStylisticAltTwelveOffSelector },
- { 'ss13', kStylisticAlternativesType, kStylisticAltThirteenOnSelector, kStylisticAltThirteenOffSelector },
- { 'ss14', kStylisticAlternativesType, kStylisticAltFourteenOnSelector, kStylisticAltFourteenOffSelector },
- { 'ss15', kStylisticAlternativesType, kStylisticAltFifteenOnSelector, kStylisticAltFifteenOffSelector },
- { 'ss16', kStylisticAlternativesType, kStylisticAltSixteenOnSelector, kStylisticAltSixteenOffSelector },
- { 'ss17', kStylisticAlternativesType, kStylisticAltSeventeenOnSelector, kStylisticAltSeventeenOffSelector },
- { 'ss18', kStylisticAlternativesType, kStylisticAltEighteenOnSelector, kStylisticAltEighteenOffSelector },
- { 'ss19', kStylisticAlternativesType, kStylisticAltNineteenOnSelector, kStylisticAltNineteenOffSelector },
- { 'ss20', kStylisticAlternativesType, kStylisticAltTwentyOnSelector, kStylisticAltTwentyOffSelector },
- { 'subs', kVerticalPositionType, kInferiorsSelector, kNormalPositionSelector },
- { 'sups', kVerticalPositionType, kSuperiorsSelector, kNormalPositionSelector },
- { 'swsh', kContextualAlternatesType, kSwashAlternatesOnSelector, kSwashAlternatesOffSelector },
- { 'titl', kStyleOptionsType, kTitlingCapsSelector, kNoStyleOptionsSelector },
- { 'tnam', kCharacterShapeType, kTraditionalNamesCharactersSelector, 16 },
- { 'tnum', kNumberSpacingType, kMonospacedNumbersSelector, 4 },
- { 'trad', kCharacterShapeType, kTraditionalCharactersSelector, 16 },
- { 'twid', kTextSpacingType, kThirdWidthTextSelector, 7 },
- { 'unic', kLetterCaseType, 14, 15 },
- { 'valt', kTextSpacingType, kAltProportionalTextSelector, 7 },
- { 'vert', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector },
- { 'vhal', kTextSpacingType, kAltHalfWidthTextSelector, 7 },
- { 'vkna', kAlternateKanaType, kAlternateVertKanaOnSelector, kAlternateVertKanaOffSelector },
- { 'vpal', kTextSpacingType, kAltProportionalTextSelector, 7 },
- { 'vrt2', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector },
- { 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector },
-};
-
-static int
-_hb_feature_mapping_cmp (const void *key_, const void *entry_)
-{
- hb_tag_t key = * (unsigned int *) key_;
- const feature_mapping_t * entry = (const feature_mapping_t *) entry_;
- return key < entry->otFeatureTag ? -1 :
- key > entry->otFeatureTag ? 1 :
- 0;
-}
-
hb_bool_t
_hb_coretext_shape (hb_shape_plan_t *shape_plan,
hb_font_t *font,
@@ -618,8 +452,8 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
unsigned int num_features)
{
hb_face_t *face = font->face;
- CGFontRef cg_font = (CGFontRef) HB_SHAPER_DATA_GET (face);
- CTFontRef ct_font = (CTFontRef) HB_SHAPER_DATA_GET (font);
+ CGFontRef cg_font = (CGFontRef) (const void *) face->data.coretext;
+ CTFontRef ct_font = (CTFontRef) hb_coretext_font_data_sync (font);
CGFloat ct_font_size = CTFontGetSize (ct_font);
CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size;
@@ -642,8 +476,8 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
buffer->merge_clusters (i - 1, i + 1);
}
- hb_auto_t<hb_vector_t<feature_record_t> > feature_records;
- hb_auto_t<hb_vector_t<range_record_t> > range_records;
+ hb_vector_t<feature_record_t> feature_records;
+ hb_vector_t<range_record_t> range_records;
/*
* Set up features.
@@ -652,14 +486,10 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
if (num_features)
{
/* Sort features by start/end events. */
- hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
+ hb_vector_t<feature_event_t> feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
- const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag,
- feature_mappings,
- ARRAY_LENGTH (feature_mappings),
- sizeof (feature_mappings[0]),
- _hb_feature_mapping_cmp);
+ const hb_aat_feature_mapping_t * mapping = hb_aat_layout_find_feature_mapping (features[i].tag);
if (!mapping)
continue;
@@ -695,7 +525,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
/* Scan events and save features for each range. */
- hb_auto_t<hb_vector_t<active_feature_t> > active_features;
+ hb_vector_t<active_feature_t> active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
@@ -768,7 +598,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
- active_features.remove (feature - active_features.arrayZ);
+ active_features.remove (feature - active_features);
}
}
}
@@ -825,7 +655,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFStringRef string_ref = nullptr;
CTLineRef line = nullptr;
- if (0)
+ if (false)
{
resize_and_retry:
DEBUG_MSG (CORETEXT, buffer, "Buffer resize");
@@ -1236,7 +1066,7 @@ resize_and_retry:
*
* https://crbug.com/419769
*/
- if (0)
+ if (false)
{
/* Make sure all runs had the expected direction. */
bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
@@ -1324,9 +1154,6 @@ fail:
* AAT shaper
*/
-HB_SHAPER_DATA_ENSURE_DEFINE(coretext_aat, face)
-HB_SHAPER_DATA_ENSURE_DEFINE(coretext_aat, font)
-
/*
* shaper face data
*/
@@ -1344,7 +1171,7 @@ _hb_coretext_aat_shaper_face_data_create (hb_face_t *face)
if (hb_blob_get_length (blob))
{
hb_blob_destroy (blob);
- return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr;
+ return face->data.coretext ? (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr;
}
hb_blob_destroy (blob);
}
@@ -1367,7 +1194,7 @@ struct hb_coretext_aat_font_data_t {};
hb_coretext_aat_font_data_t *
_hb_coretext_aat_shaper_font_data_create (hb_font_t *font)
{
- return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr;
+ return font->data.coretext ? (hb_coretext_aat_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr;
}
void
@@ -1377,28 +1204,6 @@ _hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_font_data_t *data HB_
/*
- * shaper shape_plan data
- */
-
-struct hb_coretext_aat_shape_plan_data_t {};
-
-hb_coretext_aat_shape_plan_data_t *
-_hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_coretext_aat_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
* shaper
*/
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-debug.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-debug.hh
index 12b6c49ae16..f13cfddb9c5 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-debug.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-debug.hh
@@ -43,9 +43,10 @@
struct hb_options_t
{
- unsigned int unused : 1; /* In-case sign bit is here. */
- unsigned int initialized : 1;
- unsigned int uniscribe_bug_compatible : 1;
+ bool unused : 1; /* In-case sign bit is here. */
+ bool initialized : 1;
+ bool uniscribe_bug_compatible : 1;
+ bool aat : 1;
};
union hb_options_union_t {
@@ -172,7 +173,7 @@ _hb_debug_msg_va (const char *what,
fprintf (stderr, "\n");
}
-template <> inline void
+template <> inline void HB_PRINTF_FUNC(7, 0)
_hb_debug_msg_va<0> (const char *what HB_UNUSED,
const void *obj HB_UNUSED,
const char *func HB_UNUSED,
@@ -191,7 +192,7 @@ _hb_debug_msg (const char *what,
int level_dir,
const char *message,
...) HB_PRINTF_FUNC(7, 8);
-template <int max_level> static inline void
+template <int max_level> static inline void HB_PRINTF_FUNC(7, 8)
_hb_debug_msg (const char *what,
const void *obj,
const char *func,
@@ -215,7 +216,7 @@ _hb_debug_msg<0> (const char *what HB_UNUSED,
int level_dir HB_UNUSED,
const char *message HB_UNUSED,
...) HB_PRINTF_FUNC(7, 8);
-template <> inline void
+template <> inline void HB_PRINTF_FUNC(7, 8)
_hb_debug_msg<0> (const char *what HB_UNUSED,
const void *obj HB_UNUSED,
const char *func HB_UNUSED,
@@ -292,14 +293,16 @@ struct hb_auto_trace_t
if (plevel) --*plevel;
}
- inline ret_t ret (ret_t v, unsigned int line = 0)
+ inline ret_t ret (ret_t v,
+ const char *func = "",
+ unsigned int line = 0)
{
if (unlikely (returned)) {
fprintf (stderr, "OUCH, double calls to return_trace(). This is a bug, please report.\n");
return v;
}
- _hb_debug_msg<max_level> (what, obj, nullptr, true, plevel ? *plevel : 1, -1,
+ _hb_debug_msg<max_level> (what, obj, func, true, plevel ? *plevel : 1, -1,
"return %s (line %d)",
hb_printer_t<ret_t>().print (v), line);
if (plevel) --*plevel;
@@ -324,17 +327,21 @@ struct hb_auto_trace_t<0, ret_t>
const char *message,
...) HB_PRINTF_FUNC(6, 7) {}
- inline ret_t ret (ret_t v, unsigned int line HB_UNUSED = 0) { return v; }
+ inline ret_t ret (ret_t v,
+ const char *func HB_UNUSED = 0,
+ unsigned int line HB_UNUSED = 0) { return v; }
};
/* For disabled tracing; optimize out everything.
* https://github.com/harfbuzz/harfbuzz/pull/605 */
template <typename ret_t>
struct hb_no_trace_t {
- inline ret_t ret (ret_t v, unsigned int line HB_UNUSED = 0) { return v; }
+ inline ret_t ret (ret_t v,
+ const char *func HB_UNUSED = "",
+ unsigned int line HB_UNUSED = 0) { return v; }
};
-#define return_trace(RET) return trace.ret (RET, __LINE__)
+#define return_trace(RET) return trace.ret (RET, HB_FUNC, __LINE__)
/*
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-deprecated.h b/chromium/third_party/harfbuzz-ng/src/src/hb-deprecated.h
index eac7efb42f1..a74431f05f6 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-deprecated.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-deprecated.h
@@ -36,6 +36,18 @@
#include "hb-font.h"
#include "hb-set.h"
+
+/**
+ * SECTION:hb-deprecated
+ * @title: hb-deprecated
+ * @short_description: Deprecated API
+ * @include: hb.h
+ *
+ * These API have been deprecated in favor of newer API, or because they
+ * were deemed unnecessary.
+ **/
+
+
HB_BEGIN_DECLS
#ifndef HB_DISABLE_DEPRECATED
@@ -50,14 +62,222 @@ typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t *glyph,
void *user_data);
-HB_EXTERN void
+HB_EXTERN HB_DEPRECATED_FOR(hb_font_funcs_set_nominal_glyph_func or hb_font_funcs_set_variation_glyph_func) void
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t func,
void *user_data, hb_destroy_func_t destroy);
-HB_EXTERN void
+HB_EXTERN HB_DEPRECATED void
hb_set_invert (hb_set_t *set);
+/**
+ * hb_unicode_eastasian_width_func_t:
+ *
+ * Deprecated: 2.0.0
+ */
+typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode,
+ void *user_data);
+
+/**
+ * hb_unicode_funcs_set_eastasian_width_func:
+ * @ufuncs: a Unicode function structure
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 0.9.2
+ * Deprecated: 2.0.0
+ **/
+HB_EXTERN HB_DEPRECATED void
+hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
+ hb_unicode_eastasian_width_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+/**
+ * hb_unicode_eastasian_width:
+ *
+ * Since: 0.9.2
+ * Deprecated: 2.0.0
+ **/
+HB_EXTERN HB_DEPRECATED unsigned int
+hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+
+/**
+ * hb_unicode_decompose_compatibility_func_t:
+ * @ufuncs: a Unicode function structure
+ * @u: codepoint to decompose
+ * @decomposed: address of codepoint array (of length %HB_UNICODE_MAX_DECOMPOSITION_LEN) to write decomposition into
+ * @user_data: user data pointer as passed to hb_unicode_funcs_set_decompose_compatibility_func()
+ *
+ * Fully decompose @u to its Unicode compatibility decomposition. The codepoints of the decomposition will be written to @decomposed.
+ * The complete length of the decomposition will be returned.
+ *
+ * If @u has no compatibility decomposition, zero should be returned.
+ *
+ * The Unicode standard guarantees that a buffer of length %HB_UNICODE_MAX_DECOMPOSITION_LEN codepoints will always be sufficient for any
+ * compatibility decomposition plus an terminating value of 0. Consequently, @decompose must be allocated by the caller to be at least this length. Implementations
+ * of this function type must ensure that they do not write past the provided array.
+ *
+ * Return value: number of codepoints in the full compatibility decomposition of @u, or 0 if no decomposition available.
+ *
+ * Deprecated: 2.0.0
+ */
+typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t u,
+ hb_codepoint_t *decomposed,
+ void *user_data);
+
+/**
+ * HB_UNICODE_MAX_DECOMPOSITION_LEN:
+ *
+ * See Unicode 6.1 for details on the maximum decomposition length.
+ *
+ * Deprecated: 2.0.0
+ */
+#define HB_UNICODE_MAX_DECOMPOSITION_LEN (18+1) /* codepoints */
+
+/**
+ * hb_unicode_funcs_set_decompose_compatibility_func:
+ * @ufuncs: a Unicode function structure
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 0.9.2
+ * Deprecated: 2.0.0
+ **/
+HB_EXTERN HB_DEPRECATED void
+hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs,
+ hb_unicode_decompose_compatibility_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+HB_EXTERN HB_DEPRECATED unsigned int
+hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t u,
+ hb_codepoint_t *decomposed);
+
+
+typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ void *user_data);
+typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
+typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
+
+/**
+ * hb_font_funcs_set_glyph_h_kerning_func:
+ * @ffuncs: font functions.
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 0.9.2
+ * Deprecated: 2.0.0
+ **/
+HB_EXTERN void
+hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_glyph_h_kerning_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+/**
+ * hb_font_funcs_set_glyph_v_kerning_func:
+ * @ffuncs: font functions.
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 0.9.2
+ * Deprecated: 2.0.0
+ **/
+HB_EXTERN void
+hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_glyph_v_kerning_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+HB_EXTERN hb_position_t
+hb_font_get_glyph_h_kerning (hb_font_t *font,
+ hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
+HB_EXTERN hb_position_t
+hb_font_get_glyph_v_kerning (hb_font_t *font,
+ hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
+
+HB_EXTERN void
+hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ hb_direction_t direction,
+ hb_position_t *x, hb_position_t *y);
+
+/* Like hb_ot_layout_table_find_script, but takes zero-terminated array of scripts to test */
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_layout_table_select_script) hb_bool_t
+hb_ot_layout_table_choose_script (hb_face_t *face,
+ hb_tag_t table_tag,
+ const hb_tag_t *script_tags,
+ unsigned int *script_index,
+ hb_tag_t *chosen_script);
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_layout_script_select_language) hb_bool_t
+hb_ot_layout_script_find_language (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int script_index,
+ hb_tag_t language_tag,
+ unsigned int *language_index);
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_tags_from_script_and_language) void
+hb_ot_tags_from_script (hb_script_t script,
+ hb_tag_t *script_tag_1,
+ hb_tag_t *script_tag_2);
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_tags_from_script_and_language) hb_tag_t
+hb_ot_tag_from_language (hb_language_t language);
+
+
+typedef unsigned int hb_ot_name_id_t; /* Since is in hb-ot.h */
+
+/**
+ * HB_OT_VAR_NO_AXIS_INDEX:
+ *
+ * Since: 1.4.2
+ * Deprecated: REPLACEME
+ */
+#define HB_OT_VAR_NO_AXIS_INDEX 0xFFFFFFFFu
+
+/**
+ * hb_ot_var_axis_t:
+ *
+ * Since: 1.4.2
+ * Deprecated: REPLACEME
+ */
+typedef struct hb_ot_var_axis_t
+{
+ hb_tag_t tag;
+ hb_ot_name_id_t name_id;
+ float min_value;
+ float default_value;
+ float max_value;
+} hb_ot_var_axis_t;
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_var_get_axis_infos) unsigned int
+hb_ot_var_get_axes (hb_face_t *face,
+ unsigned int start_offset,
+ unsigned int *axes_count /* IN/OUT */,
+ hb_ot_var_axis_t *axes_array /* OUT */);
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_var_find_axis_info) hb_bool_t
+hb_ot_var_find_axis (hb_face_t *face,
+ hb_tag_t axis_tag,
+ unsigned int *axis_index,
+ hb_ot_var_axis_t *axis_info);
+
#endif
HB_END_DECLS
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-directwrite.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-directwrite.cc
index 35197c23865..f9b2d261a99 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-directwrite.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-directwrite.cc
@@ -23,7 +23,6 @@
*/
#include "hb.hh"
-#define HB_SHAPER directwrite
#include "hb-shaper-impl.hh"
#include <DWrite_1.h>
@@ -31,10 +30,6 @@
#include "hb-directwrite.h"
-HB_SHAPER_DATA_ENSURE_DEFINE (directwrite, face)
-HB_SHAPER_DATA_ENSURE_DEFINE (directwrite, font)
-
-
/*
* hb-directwrite uses new/delete syntatically but as we let users
* to override malloc/free, we will redefine new/delete so users
@@ -240,8 +235,6 @@ struct hb_directwrite_font_data_t
hb_directwrite_font_data_t *
_hb_directwrite_shaper_font_data_create (hb_font_t *font)
{
- if (unlikely (!hb_directwrite_shaper_face_data_ensure (font->face))) return nullptr;
-
hb_directwrite_font_data_t *data = new hb_directwrite_font_data_t;
if (unlikely (!data))
return nullptr;
@@ -256,27 +249,6 @@ _hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data)
}
-/*
- * shaper shape_plan data
- */
-
-struct hb_directwrite_shape_plan_data_t {};
-
-hb_directwrite_shape_plan_data_t *
-_hb_directwrite_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_directwrite_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
// Most of TextAnalysis is originally written by Bas Schouten for Mozilla project
// but now is relicensed to MIT for HarfBuzz use
class TextAnalysis
@@ -555,8 +527,8 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
float lineWidth)
{
hb_face_t *face = font->face;
- hb_directwrite_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
- hb_directwrite_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
+ const hb_directwrite_face_data_t *face_data = face->data.directwrite;
+ const hb_directwrite_font_data_t *font_data = font->data.directwrite;
IDWriteFactory *dwriteFactory = face_data->dwriteFactory;
IDWriteFontFace *fontFace = face_data->fontFace;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-dsalgs.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-dsalgs.hh
index eb15c089eb6..5773596019d 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-dsalgs.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-dsalgs.hh
@@ -264,6 +264,17 @@ static inline unsigned int ARRAY_LENGTH (const Type (&)[n]) { return n; }
/* A const version, but does not detect erratically being called on pointers. */
#define ARRAY_LENGTH_CONST(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
+
+static inline int
+hb_memcmp (const void *a, const void *b, unsigned int len)
+{
+ /* It's illegal to pass NULL to memcmp(), even if len is zero.
+ * So, wrap it.
+ * https://sourceware.org/bugzilla/show_bug.cgi?id=23878 */
+ if (!len) return 0;
+ return memcmp (a, b, len);
+}
+
static inline bool
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
{
@@ -313,6 +324,27 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3)
*/
static inline void *
+hb_bsearch (const void *key, const void *base,
+ size_t nmemb, size_t size,
+ int (*compar)(const void *_key, const void *_item))
+{
+ int min = 0, max = (int) nmemb - 1;
+ while (min <= max)
+ {
+ int mid = (min + max) / 2;
+ const void *p = (const void *) (((const char *) base) + (mid * size));
+ int c = compar (key, p);
+ if (c < 0)
+ max = mid - 1;
+ else if (c > 0)
+ min = mid + 1;
+ else
+ return (void *) p;
+ }
+ return nullptr;
+}
+
+static inline void *
hb_bsearch_r (const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *_key, const void *_item, void *_arg),
@@ -321,7 +353,7 @@ hb_bsearch_r (const void *key, const void *base,
int min = 0, max = (int) nmemb - 1;
while (min <= max)
{
- int mid = (min + max) / 2;
+ int mid = ((unsigned int) min + (unsigned int) max) / 2;
const void *p = (const void *) (((const char *) base) + (mid * size));
int c = compar (key, p, arg);
if (c < 0)
@@ -335,7 +367,12 @@ hb_bsearch_r (const void *key, const void *base,
}
-/* From https://github.com/noporpoise/sort_r */
+/* From https://github.com/noporpoise/sort_r
+ * With following modifications:
+ *
+ * 10 November 2018:
+ * https://github.com/noporpoise/sort_r/issues/7
+ */
/* Isaac Turner 29 April 2014 Public Domain */
@@ -391,7 +428,7 @@ static inline void sort_r_simple(void *base, size_t nel, size_t w,
/* Use median of first, middle and last items as pivot */
char *x, *y, *xend, ch;
- char *pl, *pr;
+ char *pl, *pm, *pr;
char *last = b+w*(nel-1), *tmp;
char *l[3];
l[0] = b;
@@ -413,13 +450,15 @@ static inline void sort_r_simple(void *base, size_t nel, size_t w,
pr = last;
while(pl < pr) {
- for(; pl < pr; pl += w) {
+ pm = pl+((pr-pl+1)>>1);
+ for(; pl < pm; pl += w) {
if(sort_r_cmpswap(pl, pr, w, compar, arg)) {
pr -= w; /* pivot now at pl */
break;
}
}
- for(; pl < pr; pr -= w) {
+ pm = pl+((pr-pl)>>1);
+ for(; pm < pr; pr -= w) {
if(sort_r_cmpswap(pl, pr, w, compar, arg)) {
pl += w; /* pivot now at pr */
break;
@@ -490,50 +529,16 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o
}
-template <typename Type>
-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 <typename T1> explicit hb_auto_t (T1 *t1) { Type::init (t1); }
- template <typename T1> explicit hb_auto_t (T1 &t1) { Type::init (t1); }
- ~hb_auto_t (void) { Type::fini (); }
- private: /* Hide */
- void init (void) {}
- void fini (void) {}
-};
-
-template <typename T>
-struct hb_array_t
-{
- inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
- inline hb_array_t (const T *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
-
- inline const T& operator [] (unsigned int i) const
- {
- if (unlikely (i >= len)) return Null(T);
- return arrayZ[i];
- }
-
- inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
-
- const T *arrayZ;
- unsigned int len;
-};
-
struct hb_bytes_t
{
inline hb_bytes_t (void) : arrayZ (nullptr), len (0) {}
inline hb_bytes_t (const char *bytes_, unsigned int len_) : arrayZ (bytes_), len (len_) {}
inline hb_bytes_t (const void *bytes_, unsigned int len_) : arrayZ ((const char *) bytes_), len (len_) {}
template <typename T>
- inline hb_bytes_t (const T& array) : arrayZ ((const char *) array.arrayZ), len (array.len) {}
+ inline hb_bytes_t (const T& array) : arrayZ ((const char *) array.arrayZ), len (array.len * sizeof (array.arrayZ[0])) {}
+
+ inline operator const void * (void) const { return arrayZ; }
+ inline operator const char * (void) const { return arrayZ; }
inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
@@ -541,8 +546,7 @@ struct hb_bytes_t
{
if (len != a.len)
return (int) a.len - (int) len;
-
- return memcmp (a.arrayZ, arrayZ, len);
+ return hb_memcmp (a.arrayZ, arrayZ, len);
}
static inline int cmp (const void *pa, const void *pb)
{
@@ -555,6 +559,179 @@ struct hb_bytes_t
unsigned int len;
};
+template <typename Type>
+struct hb_sorted_array_t;
+
+template <typename Type>
+struct hb_array_t
+{
+ static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
+ inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
+ inline hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), len (o.len) {}
+ inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
+
+ inline Type& operator [] (unsigned int i) const
+ {
+ if (unlikely (i >= len)) return Null(Type);
+ return arrayZ[i];
+ }
+
+ template <typename T> inline operator T * (void) const { return arrayZ; }
+
+ inline Type * operator & (void) const { return arrayZ; }
+
+ inline unsigned int get_size (void) const { return len * sizeof (Type); }
+
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
+ {
+ if (!seg_count) return hb_array_t<Type> ();
+
+ unsigned int count = len;
+ if (unlikely (start_offset > count))
+ count = 0;
+ else
+ count -= start_offset;
+ count = *seg_count = MIN (count, *seg_count);
+ return hb_array_t<Type> (arrayZ + start_offset, count);
+ }
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
+ { return sub_array (start_offset, &seg_count); }
+
+ inline hb_bytes_t as_bytes (void) const
+ { return hb_bytes_t (arrayZ, len * sizeof (Type)); }
+
+ template <typename T>
+ inline Type *lsearch (const T &x,
+ Type *not_found = nullptr)
+ {
+ unsigned int count = len;
+ for (unsigned int i = 0; i < count; i++)
+ if (!this->arrayZ[i].cmp (x))
+ return &this->arrayZ[i];
+ return not_found;
+ }
+ template <typename T>
+ inline const Type *lsearch (const T &x,
+ const Type *not_found = nullptr) const
+ {
+ unsigned int count = len;
+ for (unsigned int i = 0; i < count; i++)
+ if (!this->arrayZ[i].cmp (x))
+ return &this->arrayZ[i];
+ return not_found;
+ }
+
+ inline hb_sorted_array_t<Type> qsort (int (*cmp)(const void*, const void*))
+ {
+ ::qsort (arrayZ, len, sizeof (Type), cmp);
+ return hb_sorted_array_t<Type> (*this);
+ }
+ inline hb_sorted_array_t<Type> qsort (void)
+ {
+ ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
+ return hb_sorted_array_t<Type> (*this);
+ }
+ inline void qsort (unsigned int start, unsigned int end)
+ {
+ end = MIN (end, len);
+ assert (start <= end);
+ ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp);
+ }
+
+ inline void free (void)
+ { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
+
+ template <typename hb_sanitize_context_t>
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ { return c->check_array (arrayZ, len); }
+
+ public:
+ Type *arrayZ;
+ unsigned int len;
+};
+template <typename T>
+inline hb_array_t<T> hb_array (T *array, unsigned int len)
+{ return hb_array_t<T> (array, len); }
+
+enum hb_bfind_not_found_t
+{
+ HB_BFIND_NOT_FOUND_DONT_STORE,
+ HB_BFIND_NOT_FOUND_STORE,
+ HB_BFIND_NOT_FOUND_STORE_CLOSEST,
+};
+
+template <typename Type>
+struct hb_sorted_array_t : hb_array_t<Type>
+{
+ inline hb_sorted_array_t (void) : hb_array_t<Type> () {}
+ inline hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
+ inline hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t<Type> (array_, len_) {}
+
+ inline hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
+ { return hb_sorted_array_t<Type> (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); }
+ inline hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
+ { return sub_array (start_offset, &seg_count); }
+
+ template <typename T>
+ inline Type *bsearch (const T &x, Type *not_found = nullptr)
+ {
+ unsigned int i;
+ return bfind (x, &i) ? &this->arrayZ[i] : not_found;
+ }
+ template <typename T>
+ inline const Type *bsearch (const T &x, const Type *not_found = nullptr) const
+ {
+ unsigned int i;
+ return bfind (x, &i) ? &this->arrayZ[i] : not_found;
+ }
+ template <typename T>
+ inline bool bfind (const T &x, unsigned int *i = nullptr,
+ hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
+ unsigned int to_store = (unsigned int) -1) const
+ {
+ int min = 0, max = (int) this->len - 1;
+ const Type *array = this->arrayZ;
+ while (min <= max)
+ {
+ int mid = ((unsigned int) min + (unsigned int) max) / 2;
+ int c = array[mid].cmp (x);
+ if (c < 0)
+ max = mid - 1;
+ else if (c > 0)
+ min = mid + 1;
+ else
+ {
+ if (i)
+ *i = mid;
+ return true;
+ }
+ }
+ if (i)
+ {
+ switch (not_found)
+ {
+ case HB_BFIND_NOT_FOUND_DONT_STORE:
+ break;
+
+ case HB_BFIND_NOT_FOUND_STORE:
+ *i = to_store;
+ break;
+
+ case HB_BFIND_NOT_FOUND_STORE_CLOSEST:
+ if (max < 0 || (max < (int) this->len && array[max].cmp (x) > 0))
+ max++;
+ *i = max;
+ break;
+ }
+ }
+ return false;
+ }
+};
+template <typename T>
+inline hb_sorted_array_t<T> hb_sorted_array (T *array, unsigned int len)
+{ return hb_sorted_array_t<T> (array, len); }
+
struct HbOpOr
{
@@ -590,8 +767,10 @@ struct HbOpXor
template <typename elt_t, unsigned int byte_size>
struct hb_vector_size_t
{
- elt_t& operator [] (unsigned int i) { return u.v[i]; }
- const elt_t& operator [] (unsigned int i) const { return u.v[i]; }
+ inline elt_t& operator [] (unsigned int i) { return u.v[i]; }
+ inline const elt_t& operator [] (unsigned int i) const { return u.v[i]; }
+
+ inline void clear (unsigned char v = 0) { memset (this, v, sizeof (*this)); }
template <class Op>
inline hb_vector_size_t process (const hb_vector_size_t &o) const
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-face.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-face.cc
index 3916a4e2471..5b33784f45c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-face.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-face.cc
@@ -36,6 +36,19 @@
/**
+ * SECTION:hb-face
+ * @title: hb-face
+ * @short_description: Font face objects
+ * @include: hb.h
+ *
+ * Font face is objects represent a single face in a font family.
+ * More exactly, a font face represents a single face in a binary font file.
+ * Font faces are typically built from a binary blob and a face index.
+ * Font faces are used to create fonts.
+ **/
+
+
+/**
* hb_face_count:
* @blob: a blob.
*
@@ -69,23 +82,15 @@ DEFINE_NULL_INSTANCE (hb_face_t) =
{
HB_OBJECT_HEADER_STATIC,
- true, /* immutable */
-
nullptr, /* reference_table_func */
nullptr, /* user_data */
nullptr, /* destroy */
0, /* index */
- 1000, /* upem */
- 0, /* num_glyphs */
+ HB_ATOMIC_INT_INIT (1000), /* upem */
+ HB_ATOMIC_INT_INIT (0), /* num_glyphs */
- {
-#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID),
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
- },
-
- HB_ATOMIC_PTR_INIT (nullptr), /* shape_plans */
+ /* Zero for the rest is fine. */
};
@@ -118,8 +123,10 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
face->user_data = user_data;
face->destroy = destroy;
- face->upem = 0;
- face->num_glyphs = (unsigned int) -1;
+ face->num_glyphs.set_relaxed (-1);
+
+ face->data.init0 (face);
+ face->table.init0 (face);
return face;
}
@@ -252,7 +259,7 @@ hb_face_destroy (hb_face_t *face)
{
if (!hb_object_destroy (face)) return;
- for (hb_face_t::plan_node_t *node = face->shape_plans.get (); node; )
+ for (hb_face_t::plan_node_t *node = face->shape_plans; node; )
{
hb_face_t::plan_node_t *next = node->next;
hb_shape_plan_destroy (node->shape_plan);
@@ -260,9 +267,8 @@ hb_face_destroy (hb_face_t *face)
node = next;
}
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
+ face->data.fini ();
+ face->table.fini ();
if (face->destroy)
face->destroy (face->user_data);
@@ -323,12 +329,10 @@ hb_face_get_user_data (const hb_face_t *face,
void
hb_face_make_immutable (hb_face_t *face)
{
- if (unlikely (hb_object_is_inert (face)))
- return;
- if (face->immutable)
+ if (hb_object_is_immutable (face))
return;
- face->immutable = true;
+ hb_object_make_immutable (face);
}
/**
@@ -344,7 +348,7 @@ hb_face_make_immutable (hb_face_t *face)
hb_bool_t
hb_face_is_immutable (const hb_face_t *face)
{
- return face->immutable;
+ return hb_object_is_immutable (face);
}
@@ -395,7 +399,7 @@ void
hb_face_set_index (hb_face_t *face,
unsigned int index)
{
- if (face->immutable)
+ if (hb_object_is_immutable (face))
return;
face->index = index;
@@ -430,10 +434,10 @@ void
hb_face_set_upem (hb_face_t *face,
unsigned int upem)
{
- if (face->immutable)
+ if (hb_object_is_immutable (face))
return;
- face->upem = upem;
+ face->upem.set_relaxed (upem);
}
/**
@@ -465,10 +469,10 @@ void
hb_face_set_glyph_count (hb_face_t *face,
unsigned int glyph_count)
{
- if (face->immutable)
+ if (hb_object_is_immutable (face))
return;
- face->num_glyphs = glyph_count;
+ face->num_glyphs.set_relaxed (glyph_count);
}
/**
@@ -538,8 +542,7 @@ 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);
+ face->table.cmap->collect_unicodes (out);
}
/**
@@ -555,8 +558,7 @@ 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);
+ face->table.cmap->collect_variation_selectors (out);
}
/**
@@ -573,8 +575,7 @@ 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->table.cmap->collect_variation_unicodes (variation_selector, out);
}
@@ -587,10 +588,10 @@ struct hb_face_builder_data_t
{
struct table_entry_t
{
- inline int cmp (const hb_tag_t *t) const
+ inline int cmp (hb_tag_t t) const
{
- if (*t < tag) return -1;
- if (*t > tag) return -1;
+ if (t < tag) return -1;
+ if (t > tag) return -1;
return 0;
}
@@ -634,7 +635,7 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data)
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));
+ face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables[i].blob));
char *buf = (char *) malloc (face_length);
if (unlikely (!buf))
@@ -666,7 +667,7 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data)
}
static hb_blob_t *
-_hb_face_builder_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
+_hb_face_builder_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
{
hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-face.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-face.hh
index f90453dbd1f..0b672336f3e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-face.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-face.hh
@@ -33,28 +33,31 @@
#include "hb-shaper.hh"
#include "hb-shape-plan.hh"
+#include "hb-ot-face.hh"
/*
* hb_face_t
*/
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, face);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
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. */
+ mutable hb_atomic_int_t upem; /* Units-per-EM. */
+ mutable hb_atomic_int_t num_glyphs; /* Number of glyphs. */
- struct hb_shaper_data_t shaper_data; /* Various shaper data. */
+ hb_shaper_object_dataset_t<hb_face_t> data;/* Various shaper data. */
+ hb_ot_face_t table; /* All the face's tables. */
/* Cache */
struct plan_node_t
@@ -80,29 +83,27 @@ struct hb_face_t
inline HB_PURE_FUNC unsigned int get_upem (void) const
{
- if (unlikely (!upem))
- load_upem ();
- return upem;
+ unsigned int ret = upem.get_relaxed ();
+ if (unlikely (!ret))
+ {
+ return load_upem ();
+ }
+ return ret;
}
inline unsigned int get_num_glyphs (void) const
{
- if (unlikely (num_glyphs == (unsigned int) -1))
- load_num_glyphs ();
- return num_glyphs;
+ unsigned int ret = num_glyphs.get_relaxed ();
+ if (unlikely (ret == (unsigned int) -1))
+ return load_num_glyphs ();
+ return ret;
}
private:
- HB_INTERNAL void load_upem (void) const;
- HB_INTERNAL void load_num_glyphs (void) const;
+ HB_INTERNAL unsigned int load_upem (void) const;
+ HB_INTERNAL unsigned int 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/chromium/third_party/harfbuzz-ng/src/src/hb-fallback-shape.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-fallback-shape.cc
index dc8536c8281..09f02900fac 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-fallback-shape.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-fallback-shape.cc
@@ -24,14 +24,9 @@
* Google Author(s): Behdad Esfahbod
*/
-#define HB_SHAPER fallback
#include "hb-shaper-impl.hh"
-HB_SHAPER_DATA_ENSURE_DEFINE(fallback, face)
-HB_SHAPER_DATA_ENSURE_DEFINE(fallback, font)
-
-
/*
* shaper face data
*/
@@ -69,28 +64,6 @@ _hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED)
/*
- * shaper shape_plan data
- */
-
-struct hb_fallback_shape_plan_data_t {};
-
-hb_fallback_shape_plan_data_t *
-_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_fallback_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
* shaper
*/
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-font.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-font.cc
index 5c259dca2a1..237b2a50929 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-font.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-font.cc
@@ -31,6 +31,21 @@
#include "hb-font.hh"
#include "hb-machinery.hh"
+#include "hb-ot.h"
+
+
+/**
+ * SECTION:hb-font
+ * @title: hb-font
+ * @short_description: Font objects
+ * @include: hb.h
+ *
+ * Font objects represent a font face at a certain size and other
+ * parameters (pixels per EM, points per EM, variation settings.)
+ * Fonts are created from font faces, and are used as input to
+ * hb_shape() among other things.
+ **/
+
/*
* hb_font_funcs_t
@@ -39,23 +54,23 @@
static hb_bool_t
hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_font_extents_t *metrics,
+ hb_font_extents_t *extents,
void *user_data HB_UNUSED)
{
- memset (metrics, 0, sizeof (*metrics));
+ memset (extents, 0, sizeof (*extents));
return false;
}
static hb_bool_t
hb_font_get_font_h_extents_default (hb_font_t *font,
void *font_data HB_UNUSED,
- hb_font_extents_t *metrics,
+ hb_font_extents_t *extents,
void *user_data HB_UNUSED)
{
- hb_bool_t ret = font->parent->get_font_h_extents (metrics);
+ hb_bool_t ret = font->parent->get_font_h_extents (extents);
if (ret) {
- metrics->ascender = font->parent_scale_y_distance (metrics->ascender);
- metrics->descender = font->parent_scale_y_distance (metrics->descender);
- metrics->line_gap = font->parent_scale_y_distance (metrics->line_gap);
+ extents->ascender = font->parent_scale_y_distance (extents->ascender);
+ extents->descender = font->parent_scale_y_distance (extents->descender);
+ extents->line_gap = font->parent_scale_y_distance (extents->line_gap);
}
return ret;
}
@@ -63,23 +78,23 @@ hb_font_get_font_h_extents_default (hb_font_t *font,
static hb_bool_t
hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_font_extents_t *metrics,
+ hb_font_extents_t *extents,
void *user_data HB_UNUSED)
{
- memset (metrics, 0, sizeof (*metrics));
+ memset (extents, 0, sizeof (*extents));
return false;
}
static hb_bool_t
hb_font_get_font_v_extents_default (hb_font_t *font,
void *font_data HB_UNUSED,
- hb_font_extents_t *metrics,
+ hb_font_extents_t *extents,
void *user_data HB_UNUSED)
{
- hb_bool_t ret = font->parent->get_font_v_extents (metrics);
+ hb_bool_t ret = font->parent->get_font_v_extents (extents);
if (ret) {
- metrics->ascender = font->parent_scale_x_distance (metrics->ascender);
- metrics->descender = font->parent_scale_x_distance (metrics->descender);
- metrics->line_gap = font->parent_scale_x_distance (metrics->line_gap);
+ extents->ascender = font->parent_scale_x_distance (extents->ascender);
+ extents->descender = font->parent_scale_x_distance (extents->descender);
+ extents->line_gap = font->parent_scale_x_distance (extents->line_gap);
}
return ret;
}
@@ -87,7 +102,7 @@ hb_font_get_font_v_extents_default (hb_font_t *font,
static hb_bool_t
hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t unicode,
+ hb_codepoint_t unicode HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
@@ -101,14 +116,47 @@ hb_font_get_nominal_glyph_default (hb_font_t *font,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
+ if (font->has_nominal_glyphs_func_set ())
+ {
+ return font->get_nominal_glyphs (1, &unicode, 0, glyph, 0);
+ }
return font->parent->get_nominal_glyph (unicode, glyph);
}
+#define hb_font_get_nominal_glyphs_nil hb_font_get_nominal_glyphs_default
+static unsigned int
+hb_font_get_nominal_glyphs_default (hb_font_t *font,
+ void *font_data HB_UNUSED,
+ unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride,
+ void *user_data HB_UNUSED)
+{
+ if (font->has_nominal_glyph_func_set ())
+ {
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (!font->get_nominal_glyph (*first_unicode, first_glyph))
+ return i;
+
+ first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride);
+ first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
+ }
+ return count;
+ }
+
+ return font->parent->get_nominal_glyphs (count,
+ first_unicode, unicode_stride,
+ first_glyph, glyph_stride);
+}
+
static hb_bool_t
hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t unicode,
- hb_codepoint_t variation_selector,
+ hb_codepoint_t unicode HB_UNUSED,
+ hb_codepoint_t variation_selector HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
@@ -141,7 +189,7 @@ hb_font_get_glyph_h_advance_default (hb_font_t *font,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
- if (font->has_glyph_h_advances_func ())
+ if (font->has_glyph_h_advances_func_set ())
{
hb_position_t ret;
font->get_glyph_h_advances (1, &glyph, 0, &ret, 0);
@@ -165,7 +213,7 @@ hb_font_get_glyph_v_advance_default (hb_font_t *font,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
- if (font->has_glyph_v_advances_func ())
+ if (font->has_glyph_v_advances_func_set ())
{
hb_position_t ret;
font->get_glyph_v_advances (1, &glyph, 0, &ret, 0);
@@ -179,13 +227,13 @@ static void
hb_font_get_glyph_h_advances_default (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
- if (font->has_glyph_h_advance_func ())
+ if (font->has_glyph_h_advance_func_set ())
{
for (unsigned int i = 0; i < count; i++)
{
@@ -211,13 +259,13 @@ static void
hb_font_get_glyph_v_advances_default (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
- if (font->has_glyph_v_advance_func ())
+ if (font->has_glyph_v_advance_func_set ())
{
for (unsigned int i = 0; i < count; i++)
{
@@ -241,7 +289,7 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font,
static hb_bool_t
hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t glyph,
+ hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
@@ -266,7 +314,7 @@ hb_font_get_glyph_h_origin_default (hb_font_t *font,
static hb_bool_t
hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t glyph,
+ hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
@@ -291,8 +339,8 @@ hb_font_get_glyph_v_origin_default (hb_font_t *font,
static hb_position_t
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t left_glyph,
- hb_codepoint_t right_glyph,
+ hb_codepoint_t left_glyph HB_UNUSED,
+ hb_codepoint_t right_glyph HB_UNUSED,
void *user_data HB_UNUSED)
{
return 0;
@@ -310,8 +358,8 @@ hb_font_get_glyph_h_kerning_default (hb_font_t *font,
static hb_position_t
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t top_glyph,
- hb_codepoint_t bottom_glyph,
+ hb_codepoint_t top_glyph HB_UNUSED,
+ hb_codepoint_t bottom_glyph HB_UNUSED,
void *user_data HB_UNUSED)
{
return 0;
@@ -329,7 +377,7 @@ hb_font_get_glyph_v_kerning_default (hb_font_t *font,
static hb_bool_t
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t glyph,
+ hb_codepoint_t glyph HB_UNUSED,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
@@ -354,8 +402,8 @@ hb_font_get_glyph_extents_default (hb_font_t *font,
static hb_bool_t
hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t glyph,
- unsigned int point_index,
+ hb_codepoint_t glyph HB_UNUSED,
+ unsigned int point_index HB_UNUSED,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
@@ -381,7 +429,7 @@ hb_font_get_glyph_contour_point_default (hb_font_t *font,
static hb_bool_t
hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- hb_codepoint_t glyph,
+ hb_codepoint_t glyph HB_UNUSED,
char *name, unsigned int size,
void *user_data HB_UNUSED)
{
@@ -401,7 +449,8 @@ hb_font_get_glyph_name_default (hb_font_t *font,
static hb_bool_t
hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
- const char *name, int len, /* -1 means nul-terminated */
+ const char *name HB_UNUSED,
+ int len HB_UNUSED, /* -1 means nul-terminated */
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
@@ -422,8 +471,6 @@ DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
{
HB_OBJECT_HEADER_STATIC,
- true, /* immutable */
-
{
#define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
@@ -446,8 +493,6 @@ DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
static const hb_font_funcs_t _hb_font_funcs_default = {
HB_OBJECT_HEADER_STATIC,
- true, /* immutable */
-
{
#define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
@@ -596,12 +641,10 @@ hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
void
hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
{
- if (unlikely (hb_object_is_inert (ffuncs)))
- return;
- if (ffuncs->immutable)
+ if (hb_object_is_immutable (ffuncs))
return;
- ffuncs->immutable = true;
+ hb_object_make_immutable (ffuncs);
}
/**
@@ -617,7 +660,7 @@ hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
hb_bool_t
hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs)
{
- return ffuncs->immutable;
+ return hb_object_is_immutable (ffuncs);
}
@@ -629,7 +672,7 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \
void *user_data, \
hb_destroy_func_t destroy) \
{ \
- if (ffuncs->immutable) { \
+ if (hb_object_is_immutable (ffuncs)) { \
if (destroy) \
destroy (user_data); \
return; \
@@ -653,9 +696,15 @@ HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
bool
+hb_font_t::has_func_set (unsigned int i)
+{
+ return this->klass->get.array[i] != _hb_font_funcs_default.get.array[i];
+}
+
+bool
hb_font_t::has_func (unsigned int i)
{
- return (this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]) ||
+ return has_func_set (i) ||
(parent && parent != &_hb_Null_hb_font_t && parent->has_func (i));
}
@@ -807,8 +856,8 @@ hb_font_get_glyph_v_advance (hb_font_t *font,
**/
void
hb_font_get_glyph_h_advances (hb_font_t* font,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride)
@@ -825,8 +874,8 @@ hb_font_get_glyph_h_advances (hb_font_t* font,
**/
void
hb_font_get_glyph_v_advances (hb_font_t* font,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride)
@@ -887,6 +936,7 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
* Return value:
*
* Since: 0.9.2
+ * Deprecated: 2.0.0
**/
hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font,
@@ -906,6 +956,7 @@ hb_font_get_glyph_h_kerning (hb_font_t *font,
* Return value:
*
* Since: 0.9.2
+ * Deprecated: 2.0.0
**/
hb_position_t
hb_font_get_glyph_v_kerning (hb_font_t *font,
@@ -1050,8 +1101,8 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
HB_EXTERN void
hb_font_get_glyph_advances_for_direction (hb_font_t* font,
hb_direction_t direction,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride)
@@ -1134,6 +1185,7 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
*
*
* Since: 0.9.2
+ * Deprecated: 2.0.0
**/
void
hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
@@ -1241,8 +1293,6 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
{
HB_OBJECT_HEADER_STATIC,
- true, /* immutable */
-
nullptr, /* parent */
const_cast<hb_face_t *> (&_hb_Null_hb_face_t),
@@ -1256,18 +1306,32 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
0, /* num_coords */
nullptr, /* coords */
- const_cast<hb_font_funcs_t *> (&_hb_Null_hb_font_funcs_t), /* klass */
- nullptr, /* user_data */
- nullptr, /* destroy */
+ const_cast<hb_font_funcs_t *> (&_hb_Null_hb_font_funcs_t),
- {
-#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID),
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
- }
+ /* Zero for the rest is fine. */
};
+static hb_font_t *
+_hb_font_create (hb_face_t *face)
+{
+ hb_font_t *font;
+
+ if (unlikely (!face))
+ face = hb_face_get_empty ();
+ if (!(font = hb_object_create<hb_font_t> ()))
+ return hb_font_get_empty ();
+
+ hb_face_make_immutable (face);
+ font->parent = hb_font_get_empty ();
+ font->face = hb_face_reference (face);
+ font->klass = hb_font_funcs_get_empty ();
+ font->data.init0 (font);
+ font->x_scale = font->y_scale = hb_face_get_upem (face);
+
+ return font;
+}
+
/**
* hb_font_create: (Xconstructor)
* @face: a face.
@@ -1281,19 +1345,10 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
hb_font_t *
hb_font_create (hb_face_t *face)
{
- hb_font_t *font;
+ hb_font_t *font = _hb_font_create (face);
- if (unlikely (!face))
- face = hb_face_get_empty ();
- if (!(font = hb_object_create<hb_font_t> ()))
- return hb_font_get_empty ();
-
- hb_face_make_immutable (face);
- font->parent = hb_font_get_empty ();
- font->face = hb_face_reference (face);
- font->klass = hb_font_funcs_get_empty ();
-
- font->x_scale = font->y_scale = hb_face_get_upem (face);
+ /* Install our in-house, very lightweight, funcs. */
+ hb_ot_font_set_funcs (font);
return font;
}
@@ -1314,9 +1369,9 @@ hb_font_create_sub_font (hb_font_t *parent)
if (unlikely (!parent))
parent = hb_font_get_empty ();
- hb_font_t *font = hb_font_create (parent->face);
+ hb_font_t *font = _hb_font_create (parent->face);
- if (unlikely (hb_object_is_inert (font)))
+ if (unlikely (hb_object_is_immutable (font)))
return font;
font->parent = hb_font_reference (parent);
@@ -1387,9 +1442,7 @@ hb_font_destroy (hb_font_t *font)
{
if (!hb_object_destroy (font)) return;
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
+ font->data.fini ();
if (font->destroy)
font->destroy (font->user_data);
@@ -1456,15 +1509,13 @@ hb_font_get_user_data (hb_font_t *font,
void
hb_font_make_immutable (hb_font_t *font)
{
- if (unlikely (hb_object_is_inert (font)))
- return;
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
if (font->parent)
hb_font_make_immutable (font->parent);
- font->immutable = true;
+ hb_object_make_immutable (font);
}
/**
@@ -1480,7 +1531,7 @@ hb_font_make_immutable (hb_font_t *font)
hb_bool_t
hb_font_is_immutable (hb_font_t *font)
{
- return font->immutable;
+ return hb_object_is_immutable (font);
}
/**
@@ -1496,7 +1547,7 @@ void
hb_font_set_parent (hb_font_t *font,
hb_font_t *parent)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
if (!parent)
@@ -1538,7 +1589,7 @@ void
hb_font_set_face (hb_font_t *font,
hb_face_t *face)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
if (unlikely (!face))
@@ -1585,7 +1636,8 @@ hb_font_set_funcs (hb_font_t *font,
void *font_data,
hb_destroy_func_t destroy)
{
- if (font->immutable) {
+ if (hb_object_is_immutable (font))
+ {
if (destroy)
destroy (font_data);
return;
@@ -1620,7 +1672,8 @@ hb_font_set_funcs_data (hb_font_t *font,
hb_destroy_func_t destroy)
{
/* Destroy user_data? */
- if (font->immutable) {
+ if (hb_object_is_immutable (font))
+ {
if (destroy)
destroy (font_data);
return;
@@ -1649,7 +1702,7 @@ hb_font_set_scale (hb_font_t *font,
int x_scale,
int y_scale)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
font->x_scale = x_scale;
@@ -1690,7 +1743,7 @@ hb_font_set_ppem (hb_font_t *font,
unsigned int x_ppem,
unsigned int y_ppem)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
font->x_ppem = x_ppem;
@@ -1730,7 +1783,7 @@ hb_font_get_ppem (hb_font_t *font,
void
hb_font_set_ptem (hb_font_t *font, float ptem)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
font->ptem = ptem;
@@ -1777,7 +1830,7 @@ hb_font_set_variations (hb_font_t *font,
const hb_variation_t *variations,
unsigned int variations_length)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
if (!variations_length)
@@ -1808,7 +1861,7 @@ hb_font_set_var_coords_design (hb_font_t *font,
const float *coords,
unsigned int coords_length)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr;
@@ -1829,7 +1882,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
const int *coords, /* 2.14 normalized */
unsigned int coords_length)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr;
@@ -1861,8 +1914,6 @@ hb_font_get_var_coords_normalized (hb_font_t *font,
}
-#ifndef HB_DISABLE_DEPRECATED
-
/*
* Deprecated get_glyph_func():
*/
@@ -1985,5 +2036,3 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
trampoline,
trampoline_destroy);
}
-
-#endif /* HB_DISABLE_DEPRECATED */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-font.h b/chromium/third_party/harfbuzz-ng/src/src/hb-font.h
index 6cd486979b0..e2086d8184f 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-font.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-font.h
@@ -110,7 +110,7 @@ typedef struct hb_glyph_extents_t
/* func types */
typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
- hb_font_extents_t *metrics,
+ hb_font_extents_t *extents,
void *user_data);
typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
@@ -125,6 +125,14 @@ typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *
hb_codepoint_t *glyph,
void *user_data);
+typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
+ unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride,
+ void *user_data);
+
typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
@@ -133,8 +141,8 @@ typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride,
@@ -149,12 +157,6 @@ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *fon
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
-typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
- void *user_data);
-typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
-typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
-
typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
@@ -227,6 +229,22 @@ hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
void *user_data, hb_destroy_func_t destroy);
/**
+ * hb_font_funcs_set_nominal_glyphs_func:
+ * @ffuncs: font functions.
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 2.0.0
+ **/
+HB_EXTERN void
+hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_nominal_glyphs_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+/**
* hb_font_funcs_set_variation_glyph_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
@@ -339,38 +357,6 @@ hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
void *user_data, hb_destroy_func_t destroy);
/**
- * hb_font_funcs_set_glyph_h_kerning_func:
- * @ffuncs: font functions.
- * @func: (closure user_data) (destroy destroy) (scope notified):
- * @user_data:
- * @destroy:
- *
- *
- *
- * Since: 0.9.2
- **/
-HB_EXTERN void
-hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_h_kerning_func_t func,
- void *user_data, hb_destroy_func_t destroy);
-
-/**
- * hb_font_funcs_set_glyph_v_kerning_func:
- * @ffuncs: font functions.
- * @func: (closure user_data) (destroy destroy) (scope notified):
- * @user_data:
- * @destroy:
- *
- *
- *
- * Since: 0.9.2
- **/
-HB_EXTERN void
-hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_v_kerning_func_t func,
- void *user_data, hb_destroy_func_t destroy);
-
-/**
* hb_font_funcs_set_glyph_extents_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
@@ -461,15 +447,15 @@ hb_font_get_glyph_v_advance (hb_font_t *font,
HB_EXTERN void
hb_font_get_glyph_h_advances (hb_font_t* font,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride);
HB_EXTERN void
hb_font_get_glyph_v_advances (hb_font_t* font,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride);
@@ -483,13 +469,6 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y);
-HB_EXTERN hb_position_t
-hb_font_get_glyph_h_kerning (hb_font_t *font,
- hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
-HB_EXTERN hb_position_t
-hb_font_get_glyph_v_kerning (hb_font_t *font,
- hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
-
HB_EXTERN hb_bool_t
hb_font_get_glyph_extents (hb_font_t *font,
hb_codepoint_t glyph,
@@ -531,8 +510,8 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
HB_EXTERN void
hb_font_get_glyph_advances_for_direction (hb_font_t* font,
hb_direction_t direction,
- unsigned count,
- hb_codepoint_t *first_glyph,
+ unsigned int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride);
@@ -552,12 +531,6 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y);
-HB_EXTERN void
-hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
- hb_direction_t direction,
- hb_position_t *x, hb_position_t *y);
-
HB_EXTERN hb_bool_t
hb_font_get_glyph_extents_for_origin (hb_font_t *font,
hb_codepoint_t glyph,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-font.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-font.hh
index 4c8d0aeec03..73733b34bb3 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-font.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-font.hh
@@ -43,6 +43,7 @@
HB_FONT_FUNC_IMPLEMENT (font_h_extents) \
HB_FONT_FUNC_IMPLEMENT (font_v_extents) \
HB_FONT_FUNC_IMPLEMENT (nominal_glyph) \
+ HB_FONT_FUNC_IMPLEMENT (nominal_glyphs) \
HB_FONT_FUNC_IMPLEMENT (variation_glyph) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
@@ -61,9 +62,6 @@
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;
@@ -98,12 +96,13 @@ DECLARE_NULL_INSTANCE (hb_font_funcs_t);
* hb_font_t
*/
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, font);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
struct hb_font_t
{
hb_object_header_t header;
- ASSERT_POD ();
-
- hb_bool_t immutable;
hb_font_t *parent;
hb_face_t *face;
@@ -124,7 +123,7 @@ struct hb_font_t
void *user_data;
hb_destroy_func_t destroy;
- struct hb_shaper_data_t shaper_data;
+ hb_shaper_object_dataset_t<hb_font_t> data; /* Various shaper data. */
/* Convert from font-space to user-space */
@@ -170,6 +169,7 @@ struct hb_font_t
/* Public getters */
HB_INTERNAL bool has_func (unsigned int i);
+ HB_INTERNAL bool has_func_set (unsigned int i);
/* has_* ... */
#define HB_FONT_FUNC_IMPLEMENT(name) \
@@ -179,6 +179,13 @@ struct hb_font_t
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); \
+ } \
+ bool \
+ has_##name##_func_set (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_set (i); \
}
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
@@ -212,6 +219,18 @@ struct hb_font_t
unicode, glyph,
klass->user_data.nominal_glyph);
}
+ inline unsigned int get_nominal_glyphs (unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride)
+ {
+ return klass->get.f.nominal_glyphs (this, user_data,
+ count,
+ first_unicode, unicode_stride,
+ first_glyph, glyph_stride,
+ klass->user_data.nominal_glyphs);
+ }
inline hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph)
@@ -237,7 +256,7 @@ struct hb_font_t
}
inline void get_glyph_h_advances (unsigned int count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride)
@@ -250,7 +269,7 @@ struct hb_font_t
}
inline void get_glyph_v_advances (unsigned int count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride)
@@ -377,8 +396,8 @@ struct hb_font_t
*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 int count,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride)
@@ -502,8 +521,8 @@ struct hb_font_t
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;
+ *x = get_glyph_h_kerning (first_glyph, second_glyph);
} else {
*x = 0;
*y = get_glyph_v_kerning (first_glyph, second_glyph);
@@ -594,11 +613,5 @@ struct hb_font_t
};
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/chromium/third_party/harfbuzz-ng/src/src/hb-ft.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ft.cc
index 6da31fc29a6..633e0ecd2c8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ft.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ft.cc
@@ -40,31 +40,38 @@
#include FT_TRUETYPE_TABLES_H
+/**
+ * SECTION:hb-ft
+ * @title: hb-ft
+ * @short_description: FreeType integration
+ * @include: hb-ft.h
+ *
+ * Functions for using HarfBuzz with the FreeType library to provide face and
+ * font data.
+ **/
+
+
/* TODO:
*
* In general, this file does a fine job of what it's supposed to do.
* There are, however, things that need more work:
*
- * - I remember seeing FT_Get_Advance() without the NO_HINTING flag to be buggy.
- * Have not investigated.
- *
* - FreeType works in 26.6 mode. Clients can decide to use that mode, and everything
* would work fine. However, we also abuse this API for performing in font-space,
* but don't pass the correct flags to FreeType. We just abuse the no-hinting mode
* for that, such that no rounding etc happens. As such, we don't set ppem, and
* pass NO_HINTING as load_flags. Would be much better to use NO_SCALE, and scale
- * ourselves, like we do in uniscribe, etc.
+ * ourselves.
*
* - We don't handle / allow for emboldening / obliqueing.
*
* - In the future, we should add constructors to create fonts in font space?
- *
- * - FT_Load_Glyph() is extremely costly. Do something about it?
*/
struct hb_ft_font_t
{
+ mutable hb_mutex_t lock;
FT_Face ft_face;
int load_flags;
bool symbol; /* Whether selected cmap is symbol cmap. */
@@ -82,6 +89,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
if (unlikely (!ft_font))
return nullptr;
+ ft_font->lock.init ();
ft_font->ft_face = ft_face;
ft_font->symbol = symbol;
ft_font->unref = unref;
@@ -110,6 +118,8 @@ _hb_ft_font_destroy (void *data)
if (ft_font->unref)
_hb_ft_face_destroy (ft_font->ft_face);
+ ft_font->lock.fini ();
+
free (ft_font);
}
@@ -125,7 +135,7 @@ _hb_ft_font_destroy (void *data)
void
hb_ft_font_set_load_flags (hb_font_t *font, int load_flags)
{
- if (font->immutable)
+ if (hb_object_is_immutable (font))
return;
if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy)
@@ -177,6 +187,7 @@ hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
unsigned int g = FT_Get_Char_Index (ft_font->ft_face, unicode);
if (unlikely (!g))
@@ -200,6 +211,32 @@ hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED,
return true;
}
+static unsigned int
+hb_ft_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
+ void *font_data,
+ unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride,
+ void *user_data HB_UNUSED)
+{
+ const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
+ unsigned int done;
+ for (done = 0;
+ done < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode));
+ done++)
+ {
+ first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride);
+ first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
+ }
+ /* We don't need to do ft_font->symbol dance here, since HB calls the singular
+ * nominal_glyph() for what we don't handle here. */
+ return done;
+}
+
+
static hb_bool_t
hb_ft_get_variation_glyph (hb_font_t *font HB_UNUSED,
void *font_data,
@@ -209,6 +246,7 @@ hb_ft_get_variation_glyph (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
unsigned int g = FT_Face_GetCharVariantIndex (ft_font->ft_face, unicode, variation_selector);
if (unlikely (!g))
@@ -221,13 +259,14 @@ hb_ft_get_variation_glyph (hb_font_t *font HB_UNUSED,
static void
hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data,
unsigned count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
int load_flags = ft_font->load_flags;
int mult = font->x_scale < 0 ? -1 : +1;
@@ -265,6 +304,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Fixed v;
if (unlikely (FT_Get_Advance (ft_font->ft_face, glyph, ft_font->load_flags | FT_LOAD_VERTICAL_LAYOUT, &v)))
@@ -287,6 +327,7 @@ hb_ft_get_glyph_v_origin (hb_font_t *font,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags)))
@@ -305,23 +346,6 @@ hb_ft_get_glyph_v_origin (hb_font_t *font,
return true;
}
-static hb_position_t
-hb_ft_get_glyph_h_kerning (hb_font_t *font,
- void *font_data,
- hb_codepoint_t left_glyph,
- hb_codepoint_t right_glyph,
- void *user_data HB_UNUSED)
-{
- const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
- FT_Vector kerningv;
-
- FT_Kerning_Mode mode = font->x_ppem ? FT_KERNING_DEFAULT : FT_KERNING_UNFITTED;
- if (FT_Get_Kerning (ft_font->ft_face, left_glyph, right_glyph, mode, &kerningv))
- return 0;
-
- return kerningv.x;
-}
-
static hb_bool_t
hb_ft_get_glyph_extents (hb_font_t *font,
void *font_data,
@@ -330,6 +354,7 @@ hb_ft_get_glyph_extents (hb_font_t *font,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags)))
@@ -362,6 +387,7 @@ hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags)))
@@ -387,8 +413,10 @@ hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
+ FT_Face ft_face = ft_font->ft_face;
- hb_bool_t ret = !FT_Get_Glyph_Name (ft_font->ft_face, glyph, name, size);
+ hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size);
if (ret && (size && !*name))
ret = false;
@@ -403,6 +431,7 @@ hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
if (len < 0)
@@ -435,10 +464,11 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
+ hb_lock_t lock (ft_font->lock);
FT_Face ft_face = ft_font->ft_face;
- metrics->ascender = ft_face->size->metrics.ascender;
- metrics->descender = ft_face->size->metrics.descender;
- metrics->line_gap = ft_face->size->metrics.height - (ft_face->size->metrics.ascender - ft_face->size->metrics.descender);
+ metrics->ascender = FT_MulFix(ft_face->ascender, ft_face->size->metrics.y_scale);
+ metrics->descender = FT_MulFix(ft_face->descender, ft_face->size->metrics.y_scale);
+ metrics->line_gap = FT_MulFix( ft_face->height, ft_face->size->metrics.y_scale ) - (metrics->ascender - metrics->descender);
if (font->y_scale < 0)
{
metrics->ascender = -metrics->ascender;
@@ -448,7 +478,7 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED,
return true;
}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_ft_funcs (void);
#endif
@@ -461,13 +491,12 @@ static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ft
hb_font_funcs_set_font_h_extents_func (funcs, hb_ft_get_font_h_extents, nullptr, nullptr);
//hb_font_funcs_set_font_v_extents_func (funcs, hb_ft_get_font_v_extents, nullptr, nullptr);
hb_font_funcs_set_nominal_glyph_func (funcs, hb_ft_get_nominal_glyph, nullptr, nullptr);
+ hb_font_funcs_set_nominal_glyphs_func (funcs, hb_ft_get_nominal_glyphs, nullptr, nullptr);
hb_font_funcs_set_variation_glyph_func (funcs, hb_ft_get_variation_glyph, nullptr, nullptr);
hb_font_funcs_set_glyph_h_advances_func (funcs, hb_ft_get_glyph_h_advances, nullptr, nullptr);
hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, nullptr, nullptr);
//hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, nullptr, nullptr);
hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ft_get_glyph_v_origin, nullptr, nullptr);
- hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ft_get_glyph_h_kerning, nullptr, nullptr);
- //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ft_get_glyph_v_kerning, nullptr, nullptr);
hb_font_funcs_set_glyph_extents_func (funcs, hb_ft_get_glyph_extents, nullptr, nullptr);
hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ft_get_glyph_contour_point, nullptr, nullptr);
hb_font_funcs_set_glyph_name_func (funcs, hb_ft_get_glyph_name, nullptr, nullptr);
@@ -475,7 +504,7 @@ static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ft
hb_font_funcs_make_immutable (funcs);
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_ft_funcs);
#endif
@@ -483,7 +512,7 @@ static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ft
}
} static_ft_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_ft_funcs (void)
{
@@ -715,11 +744,11 @@ hb_ft_font_create_referenced (FT_Face ft_face)
return hb_ft_font_create (ft_face, _hb_ft_face_destroy);
}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_ft_library (void);
#endif
-static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<FT_Library>::value,
+static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (FT_Library),
hb_ft_library_lazy_loader_t>
{
static inline FT_Library create (void)
@@ -728,7 +757,7 @@ static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<FT_
if (FT_Init_FreeType (&l))
return nullptr;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_ft_library);
#endif
@@ -744,7 +773,7 @@ static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_ptr_t<FT_
}
} static_ft_library;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_ft_library (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-glib.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-glib.cc
index 18f3a81db64..cb7e7096e34 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-glib.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-glib.cc
@@ -30,10 +30,19 @@
#include "hb-glib.h"
-#include "hb-unicode.hh"
#include "hb-machinery.hh"
+/**
+ * SECTION:hb-glib
+ * @title: hb-glib
+ * @short_description: GLib integration
+ * @include: hb-glib.h
+ *
+ * Functions for using HarfBuzz with the GLib library to provide Unicode data.
+ **/
+
+
#if !GLIB_CHECK_VERSION(2,29,14)
static const hb_script_t
glib_script_to_script[] =
@@ -202,14 +211,6 @@ hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return (hb_unicode_combining_class_t) g_unichar_combining_class (unicode);
}
-static unsigned int
-hb_glib_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t unicode,
- void *user_data HB_UNUSED)
-{
- return g_unichar_iswide (unicode) ? 2 : 1;
-}
-
static hb_unicode_general_category_t
hb_glib_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode,
@@ -334,39 +335,8 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ret;
}
-static unsigned int
-hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t u,
- hb_codepoint_t *decomposed,
- void *user_data HB_UNUSED)
-{
-#if GLIB_CHECK_VERSION(2,29,12)
- return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN);
-#endif
-
- /* If the user doesn't have GLib >= 2.29.12 we have to perform
- * a round trip to UTF-8 and the associated memory management dance. */
- gchar utf8[6];
- gchar *utf8_decomposed, *c;
- gsize utf8_len, utf8_decomposed_len, i;
-
- /* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */
- utf8_len = g_unichar_to_utf8 (u, utf8);
- utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD);
- utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1);
-
- assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN);
-
- for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c))
- *decomposed++ = g_utf8_get_char (c);
-
- g_free (utf8_decomposed);
-
- return utf8_decomposed_len;
-}
-
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_glib_funcs (void);
#endif
@@ -376,14 +346,16 @@ static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader
{
hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr);
-#define HB_UNICODE_FUNC_IMPLEMENT(name) \
- hb_unicode_funcs_set_##name##_func (funcs, hb_glib_unicode_##name, nullptr, nullptr);
- HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
-#undef HB_UNICODE_FUNC_IMPLEMENT
+ hb_unicode_funcs_set_combining_class_func (funcs, hb_glib_unicode_combining_class, nullptr, nullptr);
+ hb_unicode_funcs_set_general_category_func (funcs, hb_glib_unicode_general_category, nullptr, nullptr);
+ hb_unicode_funcs_set_mirroring_func (funcs, hb_glib_unicode_mirroring, nullptr, nullptr);
+ hb_unicode_funcs_set_script_func (funcs, hb_glib_unicode_script, nullptr, nullptr);
+ hb_unicode_funcs_set_compose_func (funcs, hb_glib_unicode_compose, nullptr, nullptr);
+ hb_unicode_funcs_set_decompose_func (funcs, hb_glib_unicode_decompose, nullptr, nullptr);
hb_unicode_funcs_make_immutable (funcs);
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_glib_funcs);
#endif
@@ -391,7 +363,7 @@ static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader
}
} static_glib_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_glib_funcs (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-gobject-structs.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-gobject-structs.cc
index 1b87585832e..23ca43656d0 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-gobject-structs.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-gobject-structs.cc
@@ -26,6 +26,18 @@
#include "hb.hh"
+
+/**
+ * SECTION:hb-gobject
+ * @title: hb-gobject
+ * @short_description: GObject integration
+ * @include: hb-gobject.h
+ *
+ * Functions for using HarfBuzz with the GObject library to provide
+ * type data.
+ **/
+
+
/* g++ didn't like older gtype.h gcc-only code path. */
#include <glib.h>
#if !GLIB_CHECK_VERSION(2,29,16)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.cc
index fd5cec1a473..a1c602c293d 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.cc
@@ -26,16 +26,23 @@
* Google Author(s): Behdad Esfahbod
*/
-#define HB_SHAPER graphite2
#include "hb-shaper-impl.hh"
#include "hb-graphite2.h"
#include <graphite2/Segment.h>
+#include "hb-ot-layout.h"
-HB_SHAPER_DATA_ENSURE_DEFINE(graphite2, face)
-HB_SHAPER_DATA_ENSURE_DEFINE(graphite2, font)
+
+/**
+ * SECTION:hb-graphite2
+ * @title: hb-graphite2
+ * @short_description: Graphite2 integration
+ * @include: hb-graphite2.h
+ *
+ * Functions for using HarfBuzz with the Graphite2 fonts.
+ **/
/*
@@ -59,7 +66,7 @@ struct hb_graphite2_face_data_t
static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len)
{
hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data;
- hb_graphite2_tablelist_t *tlist = face_data->tlist.get ();
+ hb_graphite2_tablelist_t *tlist = face_data->tlist;
hb_blob_t *blob = nullptr;
@@ -82,7 +89,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s
p->tag = tag;
retry:
- hb_graphite2_tablelist_t *tlist = face_data->tlist.get ();
+ hb_graphite2_tablelist_t *tlist = face_data->tlist;
p->next = tlist;
if (unlikely (!face_data->tlist.cmpexch (tlist, p)))
@@ -98,7 +105,7 @@ retry:
static void hb_graphite2_release_table(const void *data, const void *table_buffer)
{
hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data;
- hb_graphite2_tablelist_t *tlist = face_data->tlist.get();
+ hb_graphite2_tablelist_t *tlist = face_data->tlist;
hb_graphite2_tablelist_t *prev = nullptr;
hb_graphite2_tablelist_t *curr = tlist;
@@ -152,7 +159,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face)
void
_hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data)
{
- hb_graphite2_tablelist_t *tlist = data->tlist.get ();
+ hb_graphite2_tablelist_t *tlist = data->tlist;
while (tlist)
{
@@ -173,8 +180,8 @@ _hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data)
gr_face *
hb_graphite2_face_get_gr_face (hb_face_t *face)
{
- if (unlikely (!hb_graphite2_shaper_face_data_ensure (face))) return nullptr;
- return HB_SHAPER_DATA_GET (face)->grface;
+ const hb_graphite2_face_data_t *data = face->data.graphite2;
+ return data ? data->grface : nullptr;
}
@@ -195,39 +202,20 @@ _hb_graphite2_shaper_font_data_destroy (hb_graphite2_font_data_t *data HB_UNUSED
{
}
-/*
+/**
+ * hb_graphite2_font_get_gr_font:
+ *
* Since: 0.9.10
+ * Deprecated: 1.4.2
*/
gr_font *
-hb_graphite2_font_get_gr_font (hb_font_t *font)
+hb_graphite2_font_get_gr_font (hb_font_t *font HB_UNUSED)
{
return nullptr;
}
/*
- * shaper shape_plan data
- */
-
-struct hb_graphite2_shape_plan_data_t {};
-
-hb_graphite2_shape_plan_data_t *
-_hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_graphite2_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shape_plan_data_t *data HB_UNUSED)
-{
-}
-
-
-/*
* shaper
*/
@@ -241,14 +229,14 @@ struct hb_graphite2_cluster_t {
};
hb_bool_t
-_hb_graphite2_shape (hb_shape_plan_t *shape_plan,
+_hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer,
const hb_feature_t *features,
unsigned int num_features)
{
hb_face_t *face = font->face;
- gr_face *grface = HB_SHAPER_DATA_GET (face)->grface;
+ gr_face *grface = face->data.graphite2->grface;
const char *lang = hb_language_to_string (hb_buffer_get_language (buffer));
const char *lang_end = lang ? strchr (lang, '-') : nullptr;
@@ -277,11 +265,16 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
/* TODO ensure_native_direction. */
- hb_tag_t script_tag[2];
- hb_ot_tags_from_script (hb_buffer_get_script (buffer), &script_tag[0], &script_tag[1]);
+ hb_tag_t script_tag[HB_OT_MAX_TAGS_PER_SCRIPT];
+ unsigned int count = HB_OT_MAX_TAGS_PER_SCRIPT;
+ hb_ot_tags_from_script_and_language (hb_buffer_get_script (buffer),
+ HB_LANGUAGE_INVALID,
+ &count,
+ script_tag,
+ nullptr, nullptr);
seg = gr_make_seg (nullptr, grface,
- script_tag[1] == HB_TAG_NONE ? script_tag[0] : script_tag[1],
+ count ? script_tag[count - 1] : HB_OT_TAG_DEFAULT_SCRIPT,
feats,
gr_utf32, chars, buffer->len,
2 | (hb_buffer_get_direction (buffer) == HB_DIRECTION_RTL ? 1 : 0));
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.h b/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.h
index 05c55debec9..1720191b42f 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-graphite2.h
@@ -41,7 +41,7 @@ hb_graphite2_face_get_gr_face (hb_face_t *face);
#ifndef HB_DISABLE_DEPRECATED
-HB_EXTERN gr_font *
+HB_EXTERN HB_DEPRECATED_FOR (hb_graphite2_face_get_gr_face) gr_font *
hb_graphite2_font_get_gr_font (hb_font_t *font);
#endif
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-icu.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-icu.cc
index 564f71fe2dc..4e51eb01975 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-icu.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-icu.cc
@@ -31,7 +31,6 @@
#include "hb-icu.h"
-#include "hb-unicode.hh"
#include "hb-machinery.hh"
#include <unicode/uchar.h>
@@ -41,6 +40,16 @@
#include <unicode/uversion.h>
+/**
+ * SECTION:hb-icu
+ * @title: hb-icu
+ * @short_description: ICU integration
+ * @include: hb-icu.h
+ *
+ * Functions for using HarfBuzz with the ICU library to provide Unicode data.
+ **/
+
+
hb_script_t
hb_icu_script_to_script (UScriptCode script)
{
@@ -73,25 +82,6 @@ hb_icu_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return (hb_unicode_combining_class_t) u_getCombiningClass (unicode);
}
-static unsigned int
-hb_icu_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t unicode,
- void *user_data HB_UNUSED)
-{
- switch (u_getIntPropertyValue(unicode, UCHAR_EAST_ASIAN_WIDTH))
- {
- case U_EA_WIDE:
- case U_EA_FULLWIDTH:
- return 2;
- case U_EA_NEUTRAL:
- case U_EA_AMBIGUOUS:
- case U_EA_HALFWIDTH:
- case U_EA_NARROW:
- return 1;
- }
- return 1;
-}
-
static hb_unicode_general_category_t
hb_icu_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode,
@@ -309,41 +299,8 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ret;
}
-static unsigned int
-hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t u,
- hb_codepoint_t *decomposed,
- void *user_data HB_UNUSED)
-{
- UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1];
- unsigned int len;
- int32_t utf32_len;
- hb_bool_t err;
- UErrorCode icu_err;
-
- /* Copy @u into a UTF-16 array to be passed to ICU. */
- len = 0;
- err = false;
- U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err);
- if (err)
- return 0;
-
- /* Normalise the codepoint using NFKD mode. */
- icu_err = U_ZERO_ERROR;
- len = unorm2_normalize (unorm2_getNFKDInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err);
- if (U_FAILURE (icu_err))
- return 0;
-
- /* Convert the decomposed form from UTF-16 to UTF-32. */
- icu_err = U_ZERO_ERROR;
- u_strToUTF32 ((UChar32*) decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN, &utf32_len, normalized, len, &icu_err);
- if (U_FAILURE (icu_err))
- return 0;
-
- return utf32_len;
-}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_icu_funcs (void);
#endif
@@ -360,14 +317,16 @@ static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_
hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr);
-#define HB_UNICODE_FUNC_IMPLEMENT(name) \
- hb_unicode_funcs_set_##name##_func (funcs, hb_icu_unicode_##name, user_data, nullptr);
- HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
-#undef HB_UNICODE_FUNC_IMPLEMENT
+ hb_unicode_funcs_set_combining_class_func (funcs, hb_icu_unicode_combining_class, nullptr, nullptr);
+ hb_unicode_funcs_set_general_category_func (funcs, hb_icu_unicode_general_category, nullptr, nullptr);
+ hb_unicode_funcs_set_mirroring_func (funcs, hb_icu_unicode_mirroring, nullptr, nullptr);
+ hb_unicode_funcs_set_script_func (funcs, hb_icu_unicode_script, nullptr, nullptr);
+ hb_unicode_funcs_set_compose_func (funcs, hb_icu_unicode_compose, user_data, nullptr);
+ hb_unicode_funcs_set_decompose_func (funcs, hb_icu_unicode_decompose, user_data, nullptr);
hb_unicode_funcs_make_immutable (funcs);
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_icu_funcs);
#endif
@@ -375,7 +334,7 @@ static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_
}
} static_icu_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_icu_funcs (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-kern.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-kern.hh
new file mode 100644
index 00000000000..aa01b470f29
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-kern.hh
@@ -0,0 +1,139 @@
+/*
+ * 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_KERN_HH
+#define HB_KERN_HH
+
+#include "hb-open-type.hh"
+#include "hb-aat-layout-common.hh"
+#include "hb-ot-layout-gpos-table.hh"
+
+
+namespace OT {
+
+
+template <typename Driver>
+struct hb_kern_machine_t
+{
+ hb_kern_machine_t (const Driver &driver_,
+ bool crossStream_ = false) :
+ driver (driver_),
+ crossStream (crossStream_) {}
+
+ HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW
+ inline void kern (hb_font_t *font,
+ hb_buffer_t *buffer,
+ hb_mask_t kern_mask,
+ bool scale = true) const
+ {
+ OT::hb_ot_apply_context_t c (1, font, buffer);
+ c.set_lookup_mask (kern_mask);
+ c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
+ OT::hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c.iter_input;
+ skippy_iter.init (&c);
+
+ bool horizontal = HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction);
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
+ hb_glyph_position_t *pos = buffer->pos;
+ for (unsigned int idx = 0; idx < count;)
+ {
+ if (!(info[idx].mask & kern_mask))
+ {
+ idx++;
+ continue;
+ }
+
+ skippy_iter.reset (idx, 1);
+ if (!skippy_iter.next ())
+ {
+ idx++;
+ continue;
+ }
+
+ unsigned int i = idx;
+ unsigned int j = skippy_iter.idx;
+
+ hb_position_t kern = driver.get_kerning (info[i].codepoint,
+ info[j].codepoint);
+
+
+ if (likely (!kern))
+ goto skip;
+
+ if (horizontal)
+ {
+ if (scale)
+ kern = font->em_scale_x (kern);
+ if (crossStream)
+ {
+ pos[j].y_offset = kern;
+ buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
+ }
+ else
+ {
+ hb_position_t kern1 = kern >> 1;
+ hb_position_t kern2 = kern - kern1;
+ pos[i].x_advance += kern1;
+ pos[j].x_advance += kern2;
+ pos[j].x_offset += kern2;
+ }
+ }
+ else
+ {
+ if (scale)
+ kern = font->em_scale_y (kern);
+ if (crossStream)
+ {
+ pos[j].x_offset = kern;
+ buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
+ }
+ else
+ {
+ hb_position_t kern1 = kern >> 1;
+ hb_position_t kern2 = kern - kern1;
+ pos[i].y_advance += kern1;
+ pos[j].y_advance += kern2;
+ pos[j].y_offset += kern2;
+ }
+ }
+
+ buffer->unsafe_to_break (i, j + 1);
+
+ skip:
+ idx = skippy_iter.idx;
+ }
+ }
+
+ const Driver &driver;
+ bool crossStream;
+};
+
+
+} /* namespace OT */
+
+
+#endif /* HB_KERN_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-machinery.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-machinery.hh
index f80cfdb2ec0..39e962936db 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-machinery.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-machinery.hh
@@ -82,10 +82,7 @@ static inline Type& StructAfter(TObject &X)
/* 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. */ \
- }
+ { static_assert ((_assertion), ""); }
# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion)
# define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion)
@@ -98,32 +95,36 @@ static inline Type& StructAfter(TObject &X)
#define DEFINE_SIZE_STATIC(size) \
- DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \
- enum { static_size = (size) }; \
+ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \
+ inline unsigned int get_size (void) const { return (size); } \
+ enum { null_size = (size) }; \
enum { min_size = (size) }; \
- inline unsigned int get_size (void) const { return (size); }
+ enum { static_size = (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_COMPILES_ASSERTION ((void) this->u._member.static_size) \
+ DEFINE_INSTANCE_ASSERTION (sizeof(this->u._member) == (size)) \
+ enum { null_size = (size) }; \
+ enum { min_size = (size) }
#define DEFINE_SIZE_MIN(size) \
- DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)); \
- static const unsigned int min_size = (size)
+ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \
+ enum { null_size = (size) }; \
+ enum { min_size = (size) }
+
+#define DEFINE_SIZE_UNBOUNDED(size) \
+ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \
+ enum { 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_COMPILES_ASSERTION ((void) (array)[0].static_size) \
+ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \
+ enum { null_size = (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)
+ inline unsigned int get_size (void) const { return (size - (array).min_size + (array).get_size ()); } \
+ DEFINE_SIZE_ARRAY(size, array)
/*
@@ -136,7 +137,7 @@ struct hb_dispatch_context_t
enum { max_debug_depth = MaxDebugDepth };
typedef Return return_t;
template <typename T, typename F>
- inline bool may_dispatch (const T *obj, const F *format) { return true; }
+ inline bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; }
static return_t no_dispatch_return_value (void) { return Context::default_return_value (); }
};
@@ -204,7 +205,7 @@ struct hb_dispatch_context_t
* 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.
+ * objects do not need to be validated at each use site.
*/
/* This limits sanitizing time on really broken fonts. */
@@ -217,6 +218,9 @@ struct hb_dispatch_context_t
#ifndef HB_SANITIZE_MAX_OPS_MIN
#define HB_SANITIZE_MAX_OPS_MIN 16384
#endif
+#ifndef HB_SANITIZE_MAX_OPS_MAX
+#define HB_SANITIZE_MAX_OPS_MAX 0x3FFFFFFF
+#endif
struct hb_sanitize_context_t :
hb_dispatch_context_t<hb_sanitize_context_t, bool, HB_DEBUG_SANITIZE>
@@ -224,14 +228,15 @@ struct hb_sanitize_context_t :
inline hb_sanitize_context_t (void) :
debug_depth (0),
start (nullptr), end (nullptr),
- writable (false), edit_count (0), max_ops (0),
+ max_ops (0),
+ writable (false), edit_count (0),
blob (nullptr),
num_glyphs (65536),
num_glyphs_set (false) {}
inline const char *get_name (void) { return "SANITIZE"; }
template <typename T, typename F>
- inline bool may_dispatch (const T *obj, const F *format)
+ inline bool may_dispatch (const T *obj HB_UNUSED, const F *format)
{ return format->sanitize (this); }
template <typename T>
inline return_t dispatch (const T &obj) { return obj.sanitize (this); }
@@ -252,11 +257,38 @@ struct hb_sanitize_context_t :
}
inline unsigned int get_num_glyphs (void) { return num_glyphs; }
- inline void start_processing (void)
+ inline void set_max_ops (int max_ops_) { max_ops = max_ops_; }
+
+ template <typename T>
+ inline void set_object (const T *obj)
+ {
+ reset_object ();
+
+ if (!obj) return;
+
+ const char *obj_start = (const char *) obj;
+ const char *obj_end = (const char *) obj + obj->get_size ();
+ assert (obj_start <= obj_end); /* Must not overflow. */
+
+ if (unlikely (obj_end < this->start || this->end < obj_start))
+ this->start = this->end = nullptr;
+ else
+ {
+ this->start = MAX (this->start, obj_start);
+ this->end = MIN (this->end , obj_end );
+ }
+ }
+
+ inline void reset_object (void)
{
this->start = this->blob->data;
this->end = this->start + this->blob->length;
assert (this->start <= this->end); /* Must not overflow. */
+ }
+
+ inline void start_processing (void)
+ {
+ reset_object ();
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;
@@ -279,13 +311,14 @@ struct hb_sanitize_context_t :
this->start = this->end = nullptr;
}
- inline bool check_range (const void *base, unsigned int len) const
+ 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 &&
+ bool ok = this->start <= p &&
p <= this->end &&
- (unsigned int) (this->end - p) >= len;
+ (unsigned int) (this->end - p) >= len &&
+ this->max_ops-- > 0;
DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0,
"check_range [%p..%p] (%d bytes) in [%p..%p] -> %s",
@@ -297,20 +330,37 @@ struct hb_sanitize_context_t :
}
template <typename T>
- inline bool check_array (const T *base, unsigned int len, unsigned int record_size = T::static_size) const
+ inline bool check_range (const T *base,
+ unsigned int a,
+ unsigned int b) 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);
+ return !hb_unsigned_mul_overflows (a, b) &&
+ this->check_range (base, a * b);
+ }
- 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");
+ template <typename T>
+ inline bool check_range (const T *base,
+ unsigned int a,
+ unsigned int b,
+ unsigned int c) const
+ {
+ return !hb_unsigned_mul_overflows (a, b) &&
+ this->check_range (base, a * b, c);
+ }
- return likely (ok);
+ template <typename T>
+ inline bool check_array (const T *base,
+ unsigned int len) const
+ {
+ return this->check_range (base, len, T::static_size);
+ }
+
+ template <typename T>
+ inline bool check_array (const T *base,
+ unsigned int a,
+ unsigned int b) const
+ {
+ return this->check_range (base, a, b, T::static_size);
}
template <typename Type>
@@ -423,15 +473,32 @@ struct hb_sanitize_context_t :
mutable unsigned int debug_depth;
const char *start, *end;
+ mutable int max_ops;
private:
bool writable;
unsigned int edit_count;
- mutable int max_ops;
hb_blob_t *blob;
unsigned int num_glyphs;
bool num_glyphs_set;
};
+struct hb_sanitize_with_object_t
+{
+ template <typename T>
+ inline hb_sanitize_with_object_t (hb_sanitize_context_t *c,
+ const T& obj) : c (c)
+ {
+ c->set_object (obj);
+ }
+ inline ~hb_sanitize_with_object_t (void)
+ {
+ c->reset_object ();
+ }
+
+ private:
+ hb_sanitize_context_t *c;
+};
+
/*
* Serialize
@@ -591,7 +658,7 @@ struct Supplier
}
inline Supplier (const hb_vector_t<Type> *v)
{
- head = v->arrayZ;
+ head = *v;
len = v->len;
stride = sizeof (Type);
}
@@ -631,6 +698,7 @@ template <typename Type>
struct BEInt<Type, 1>
{
public:
+ typedef Type type;
inline void set (Type V)
{
v = V;
@@ -645,6 +713,7 @@ template <typename Type>
struct BEInt<Type, 2>
{
public:
+ typedef Type type;
inline void set (Type V)
{
v[0] = (V >> 8) & 0xFF;
@@ -652,6 +721,12 @@ struct BEInt<Type, 2>
}
inline operator Type (void) const
{
+#if defined(__GNUC__) || defined(__clang__)
+ /* Spoon-feed the compiler a big-endian integer with alignment 1.
+ * https://github.com/harfbuzz/harfbuzz/pull/1398 */
+ struct __attribute__((packed)) packed_uint16_t { uint16_t v; };
+ return __builtin_bswap16 (((packed_uint16_t *) this)->v);
+#endif
return (v[0] << 8)
+ (v[1] );
}
@@ -661,6 +736,7 @@ template <typename Type>
struct BEInt<Type, 3>
{
public:
+ typedef Type type;
inline void set (Type V)
{
v[0] = (V >> 16) & 0xFF;
@@ -679,6 +755,7 @@ template <typename Type>
struct BEInt<Type, 4>
{
public:
+ typedef Type type;
inline void set (Type V)
{
v[0] = (V >> 24) & 0xFF;
@@ -711,21 +788,18 @@ struct hb_data_wrapper_t
return *(((Data **) (void *) this) - WheresData);
}
+ inline bool is_inert (void) const { return !get_data (); }
+
template <typename Stored, typename Subclass>
- inline Stored * call_create (void) const
- {
- Data *data = this->get_data ();
- return likely (data) ? Subclass::create (data) : nullptr;
- }
+ inline Stored * call_create (void) const { return Subclass::create (get_data ()); }
};
template <>
struct hb_data_wrapper_t<void, 0>
{
+ inline bool is_inert (void) const { return false; }
+
template <typename Stored, typename Funcs>
- inline Stored * call_create (void) const
- {
- return Funcs::create ();
- }
+ inline Stored * call_create (void) const { return Funcs::create (); }
};
template <typename T1, typename T2> struct hb_non_void_t { typedef T1 value; };
@@ -752,31 +826,22 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
{
retry:
Stored *p = instance.get ();
- if (unlikely (p && !this->instance.cmpexch (p, nullptr)))
+ if (unlikely (p && !cmpexch (p, nullptr)))
goto retry;
do_destroy (p);
}
- inline Stored * do_create (void) const
- {
- Stored *p = this->template call_create<Stored, Funcs> ();
- if (unlikely (!p))
- p = const_cast<Stored *> (Funcs::get_null ());
- return p;
- }
static inline void do_destroy (Stored *p)
{
- if (p && p != Funcs::get_null ())
+ if (p && p != const_cast<Stored *> (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);
- }
+ explicit_operator inline operator bool (void) const
+ { return get_stored () != Funcs::get_null (); }
+ template <typename C> inline operator const C * (void) const { return get (); }
inline Stored * get_stored (void) const
{
@@ -784,8 +849,14 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
Stored *p = this->instance.get ();
if (unlikely (!p))
{
- p = do_create ();
- if (unlikely (!this->instance.cmpexch (nullptr, p)))
+ if (unlikely (this->is_inert ()))
+ return const_cast<Stored *> (Funcs::get_null ());
+
+ p = this->template call_create<Stored, Funcs> ();
+ if (unlikely (!p))
+ p = const_cast<Stored *> (Funcs::get_null ());
+
+ if (unlikely (!cmpexch (nullptr, p)))
{
do_destroy (p);
goto retry;
@@ -798,15 +869,10 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
return this->instance.get_relaxed ();
}
- inline void set_stored (Stored *instance_)
+ inline bool cmpexch (Stored *current, Stored *value) const
{
- /* 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);
+ /* This *must* be called when there are no other threads accessing. */
+ return this->instance.cmpexch (current, value);
}
inline const Returned * get (void) const { return Funcs::convert (get_stored ()); }
@@ -838,7 +904,7 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
free (p);
}
- private:
+// private:
/* Must only have one pointer. */
hb_atomic_ptr_t<Stored *> instance;
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-map.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-map.cc
index 225f37bc678..067a2b37169 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-map.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-map.cc
@@ -27,7 +27,16 @@
#include "hb-map.hh"
-/* Public API */
+/**
+ * SECTION:hb-map
+ * @title: hb-map
+ * @short_description: Object representing integer to integer mapping
+ * @include: hb.h
+ *
+ * Map objects are integer-to-integer hash-maps. Currently they are
+ * not used in the HarfBuzz public API, but are provided for client's
+ * use if desired.
+ **/
/**
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-map.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-map.hh
index 21898a7a677..c54c9d7b640 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-map.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-map.hh
@@ -44,6 +44,10 @@ inline uint32_t Hash (const T &v)
struct hb_map_t
{
+ HB_NO_COPY_ASSIGN (hb_map_t);
+ inline hb_map_t (void) { init (); }
+ inline ~hb_map_t (void) { fini (); }
+
struct item_t
{
hb_codepoint_t key;
@@ -77,9 +81,11 @@ struct hb_map_t
inline void fini_shallow (void)
{
free (items);
+ items = nullptr;
}
inline void fini (void)
{
+ population = occupancy = 0;
hb_object_fini (this);
fini_shallow ();
}
@@ -172,7 +178,7 @@ struct hb_map_t
inline bool is_empty (void) const
{
- return population != 0;
+ return population == 0;
}
inline unsigned int get_population () const
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-mutex.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-mutex.hh
index d8cdf4b64ac..b529091d44a 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-mutex.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-mutex.hh
@@ -48,7 +48,7 @@
/* 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__))
+#elif !defined(HB_NO_MT) && defined(_WIN32)
#include <windows.h>
typedef CRITICAL_SECTION hb_mutex_impl_t;
@@ -137,5 +137,13 @@ struct hb_mutex_t
inline void fini (void) { hb_mutex_impl_finish (&m); }
};
+struct hb_lock_t
+{
+ inline hb_lock_t (hb_mutex_t &mutex_) : mutex (mutex_) { mutex.lock (); }
+ inline ~hb_lock_t (void) { mutex.unlock (); }
+ private:
+ hb_mutex_t &mutex;
+};
+
#endif /* HB_MUTEX_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-null.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-null.hh
index 88c1c9cb61c..1583d5b90e0 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-null.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-null.hh
@@ -36,23 +36,62 @@
/* Global nul-content Null pool. Enlarge as necessary. */
-#define HB_NULL_POOL_SIZE 264
+#define HB_NULL_POOL_SIZE 1024
+/* Use SFINAE to sniff whether T has min_size; in which case return T::null_size,
+ * otherwise return sizeof(T). */
+
+/* The hard way...
+ * https://stackoverflow.com/questions/7776448/sfinae-tried-with-bool-gives-compiler-error-template-argument-tvalue-invol
+ */
+
+template<bool> struct _hb_bool_type {};
+
+template <typename T, typename B>
+struct _hb_null_size
+{ enum { value = sizeof (T) }; };
+template <typename T>
+struct _hb_null_size<T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
+{ enum { value = T::null_size }; };
+
+template <typename T>
+struct hb_null_size
+{ enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; };
+#define hb_null_size(T) hb_null_size<T>::value
+
+/* This doesn't belong here, but since is copy/paste from above, put it here. */
+
+template <typename T, typename B>
+struct _hb_static_size
+{ enum { value = sizeof (T) }; };
+template <typename T>
+struct _hb_static_size<T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
+{ enum { value = T::static_size }; };
+
+template <typename T>
+struct hb_static_size
+{ enum { value = _hb_static_size<T, _hb_bool_type<true> >::value }; };
+#define hb_static_size(T) hb_static_size<T>::value
+
+
+/*
+ * Null()
+ */
extern HB_INTERNAL
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];
/* Generic nul-content Null objects. */
template <typename Type>
static inline Type const & Null (void) {
- static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+ static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
return *reinterpret_cast<Type const *> (_hb_NullPool);
}
-#define Null(Type) Null<Type>()
+#define Null(Type) Null<typename hb_remove_const (typename hb_remove_reference (Type))> ()
-/* Specializaitons for arbitrary-content Null objects expressed in bytes. */
+/* Specializations 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]; \
+ extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::null_size]; \
template <> \
/*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \
return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \
@@ -60,9 +99,9 @@ static inline Type const & Null (void) {
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::null_size]
-/* Specializaitons for arbitrary-content Null objects expressed as struct initializer. */
+/* Specializations for arbitrary-content Null objects expressed as struct initializer. */
#define DECLARE_NULL_INSTANCE(Type) \
extern HB_INTERNAL const Type _hb_Null_##Type; \
template <> \
@@ -85,12 +124,12 @@ extern HB_INTERNAL
/* CRAP pool: Common Region for Access Protection. */
template <typename Type>
static inline Type& Crap (void) {
- static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+ static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
Type *obj = reinterpret_cast<Type *> (_hb_CrapPool);
- *obj = Null(Type);
+ memcpy (obj, &Null(Type), sizeof (*obj));
return *obj;
}
-#define Crap(Type) Crap<Type>()
+#define Crap(Type) Crap<typename hb_remove_const (typename hb_remove_reference (Type))> ()
template <typename Type>
struct CrapOrNull {
@@ -103,4 +142,28 @@ struct CrapOrNull<const Type> {
#define CrapOrNull(Type) CrapOrNull<Type>::get ()
+/*
+ * hb_nonnull_ptr_t
+ */
+
+template <typename P>
+struct hb_nonnull_ptr_t
+{
+ typedef typename hb_remove_pointer (P) T;
+
+ inline hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {}
+ inline T * operator = (T *v_) { return v = v_; }
+ inline T * operator -> (void) const { return get (); }
+ inline T & operator * (void) const { return *get (); }
+ inline T ** operator & (void) const { return &v; }
+ /* Only auto-cast to const types. */
+ template <typename C> inline operator const C * (void) const { return get (); }
+ inline operator const char * (void) const { return (const char *) get (); }
+ inline T * get (void) const { return v ? v : const_cast<T *> (&Null(T)); }
+ inline T * get_raw (void) const { return v; }
+
+ T *v;
+};
+
+
#endif /* HB_NULL_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-object.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-object.hh
index ca85af691d9..cdacf49f4c1 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-object.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-object.hh
@@ -194,13 +194,15 @@ struct hb_user_data_array_t
struct hb_object_header_t
{
hb_reference_count_t ref_count;
+ mutable hb_atomic_int_t writable;
hb_atomic_ptr_t<hb_user_data_array_t> user_data;
-
-#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)}
-
- private:
- ASSERT_POD ();
};
+#define HB_OBJECT_HEADER_STATIC \
+ { \
+ HB_REFERENCE_COUNT_INIT, \
+ HB_ATOMIC_INT_INIT (false), \
+ HB_ATOMIC_PTR_INIT (nullptr) \
+ }
/*
@@ -232,6 +234,7 @@ template <typename Type>
static inline void hb_object_init (Type *obj)
{
obj->header.ref_count.init ();
+ obj->header.writable.set_relaxed (true);
obj->header.user_data.init ();
}
template <typename Type>
@@ -245,6 +248,16 @@ static inline bool hb_object_is_valid (const Type *obj)
return likely (obj->header.ref_count.is_valid ());
}
template <typename Type>
+static inline bool hb_object_is_immutable (const Type *obj)
+{
+ return !obj->header.writable.get_relaxed ();
+}
+template <typename Type>
+static inline void hb_object_make_immutable (const Type *obj)
+{
+ obj->header.writable.set_relaxed (false);
+}
+template <typename Type>
static inline Type *hb_object_reference (Type *obj)
{
hb_object_trace (obj, HB_FUNC);
@@ -276,6 +289,7 @@ static inline void hb_object_fini (Type *obj)
{
user_data->fini ();
free (user_data);
+ user_data = nullptr;
}
}
template <typename Type>
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-open-file.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-open-file.hh
index 8772c79fa10..af68892ab11 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-open-file.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-open-file.hh
@@ -111,12 +111,7 @@ typedef struct OffsetTable
{
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;
+ return tables.bfind (t, table_index, HB_BFIND_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
}
inline const TableRecord& get_table_by_tag (hb_tag_t tag) const
{
@@ -160,7 +155,7 @@ typedef struct OffsetTable
memcpy (start, hb_blob_get_data (blob, nullptr), rec.length);
- /* 4-byte allignment. */
+ /* 4-byte alignment. */
c->align (4);
const char *end = (const char *) c->head;
@@ -330,8 +325,7 @@ struct ResourceTypeRecord
inline const ResourceRecord& get_resource_record (unsigned int i,
const void *type_base) const
{
- return hb_array_t<ResourceRecord> ((type_base+resourcesZ).arrayZ,
- get_resource_count ()) [i];
+ return (type_base+resourcesZ).as_array (get_resource_count ())[i];
}
inline bool sanitize (hb_sanitize_context_t *c,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-open-type.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-open-type.hh
index ae7cdfaf623..f4d0238ea07 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-open-type.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-open-type.hh
@@ -56,8 +56,9 @@ namespace OT {
template <typename Type, unsigned int Size>
struct IntType
{
+ typedef Type type;
inline void set (Type i) { v.set (i); }
- inline operator Type(void) const { return v; }
+ inline operator Type (void) const { return v; }
inline bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; }
inline bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); }
static inline int cmp (const IntType<Type,Size> *a, const IntType<Type,Size> *b) { return b->cmp (*a); }
@@ -92,6 +93,9 @@ typedef IntType<uint32_t, 3> HBUINT24; /* 24-bit unsigned integer. */
/* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */
typedef HBINT16 FWORD;
+/* 32-bit signed integer (HBINT32) that describes a quantity in FUnits. */
+typedef HBINT32 FWORD32;
+
/* 16-bit unsigned integer (HBUINT16) that describes a quantity in FUnits. */
typedef HBUINT16 UFWORD;
@@ -145,19 +149,20 @@ struct Tag : HBUINT32
/* 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);
+typedef Index NameID;
+
/* Offset, Null offset = 0 */
template <typename Type, bool has_null=true>
struct Offset : Type
{
+ typedef Type type;
+
inline bool is_null (void) const { return has_null && 0 == *this; }
inline void *serialize (hb_serialize_context_t *c, const void *base)
@@ -168,7 +173,7 @@ struct Offset : Type
}
public:
- DEFINE_SIZE_STATIC (sizeof(Type));
+ DEFINE_SIZE_STATIC (sizeof (Type));
};
typedef Offset<HBUINT16> Offset16;
@@ -206,7 +211,7 @@ struct CheckSum : HBUINT32
template <typename FixedType=HBUINT16>
struct FixedVersion
{
- inline uint32_t to_int (void) const { return (major << (sizeof(FixedType) * 8)) + minor; }
+ inline uint32_t to_int (void) const { return (major << (sizeof (FixedType) * 8)) + minor; }
inline bool sanitize (hb_sanitize_context_t *c) const
{
@@ -217,7 +222,7 @@ struct FixedVersion
FixedType major;
FixedType minor;
public:
- DEFINE_SIZE_STATIC (2 * sizeof(FixedType));
+ DEFINE_SIZE_STATIC (2 * sizeof (FixedType));
};
@@ -226,22 +231,31 @@ struct FixedVersion
* Use: (base+offset)
*/
-template <typename Type, bool has_null_> struct assert_has_min_size { static_assert (Type::min_size > 0, ""); };
-template <typename Type> struct assert_has_min_size<Type, false> {};
+template <typename Type, bool has_null>
+struct _hb_has_null
+{
+ static inline const Type *get_null (void) { return nullptr; }
+ static inline Type *get_crap (void) { return nullptr; }
+};
+template <typename Type>
+struct _hb_has_null<Type, true>
+{
+ static inline const Type *get_null (void) { return &Null(Type); }
+ static inline Type *get_crap (void) { return &Crap(Type); }
+};
template <typename Type, typename OffsetType=HBUINT16, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null>
{
- static_assert (sizeof (assert_has_min_size<Type, has_null>) || true, "");
-
inline const Type& operator () (const void *base) const
{
- if (unlikely (this->is_null ())) return Null(Type);
+ if (unlikely (this->is_null ())) return *_hb_has_null<Type, has_null>::get_null ();
return StructAtOffset<const Type> (base, *this);
}
inline Type& operator () (void *base) const
{
- if (unlikely (this->is_null ())) return Crap(Type);
+ if (unlikely (this->is_null ())) return Crap (Type);
+ if (unlikely (this->is_null ())) return *_hb_has_null<Type, has_null>::get_crap ();
return StructAtOffset<Type> (base, *this);
}
@@ -253,7 +267,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
template <typename T>
inline void serialize_subset (hb_subset_context_t *c, const T &src, const void *base)
{
- if (&src == &Null(T))
+ if (&src == &Null (T))
{
this->set (0);
return;
@@ -314,9 +328,10 @@ struct OffsetTo : Offset<OffsetType, has_null>
if (!has_null) return false;
return c->try_set (this, 0);
}
- DEFINE_SIZE_STATIC (sizeof(OffsetType));
+ DEFINE_SIZE_STATIC (sizeof (OffsetType));
};
template <typename Type, bool has_null=true> struct LOffsetTo : OffsetTo<Type, HBUINT32, has_null> {};
+
template <typename Base, typename OffsetType, bool has_null, typename Type>
static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType, has_null> &offset) { return offset (base); }
template <typename Base, typename OffsetType, bool has_null, typename Type>
@@ -330,8 +345,45 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
template <typename Type>
struct UnsizedArrayOf
{
- inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; }
- inline Type& operator [] (unsigned int i) { return arrayZ[i]; }
+ static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
+ enum { item_size = Type::static_size };
+
+ HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
+
+ inline const Type& operator [] (unsigned int i) const
+ {
+ const Type *p = &arrayZ[i];
+ if (unlikely (p < arrayZ)) return Null (Type); /* Overflowed. */
+ return *p;
+ }
+ inline Type& operator [] (unsigned int i)
+ {
+ Type *p = &arrayZ[i];
+ if (unlikely (p < arrayZ)) return Crap (Type); /* Overflowed. */
+ return *p;
+ }
+
+ template <typename T> inline operator T * (void) { return arrayZ; }
+ template <typename T> inline operator const T * (void) const { return arrayZ; }
+
+ inline unsigned int get_size (unsigned int len) const
+ { return len * Type::static_size; }
+
+ inline hb_array_t<Type> as_array (unsigned int len)
+ { return hb_array (arrayZ, len); }
+ inline hb_array_t<const Type> as_array (unsigned int len) const
+ { return hb_array (arrayZ, len); }
+
+ template <typename T>
+ inline Type &lsearch (unsigned int len, const T &x, Type &not_found = Crap (Type))
+ { return *as_array (len).lsearch (x, &not_found); }
+ template <typename T>
+ inline const Type &lsearch (unsigned int len, const T &x, const Type &not_found = Null (Type)) const
+ { return *as_array (len).lsearch (x, &not_found); }
+
+ inline void qsort (unsigned int len, unsigned int start = 0, unsigned int end = (unsigned int) -1)
+ { as_array (len).qsort (start, end); }
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
@@ -355,7 +407,7 @@ struct UnsizedArrayOf
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 (false);
return_trace (true);
}
template <typename T>
@@ -365,7 +417,7 @@ struct UnsizedArrayOf
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 (false);
return_trace (true);
}
@@ -378,64 +430,105 @@ struct UnsizedArrayOf
public:
Type arrayZ[VAR];
public:
- DEFINE_SIZE_ARRAY (0, arrayZ);
+ DEFINE_SIZE_UNBOUNDED (0);
};
/* Unsized array of offset's */
-template <typename Type, typename OffsetType>
-struct UnsizedOffsetArrayOf : UnsizedArrayOf<OffsetTo<Type, OffsetType> > {};
+template <typename Type, typename OffsetType, bool has_null=true>
+struct UnsizedOffsetArrayOf : UnsizedArrayOf<OffsetTo<Type, OffsetType, has_null> > {};
/* Unsized array of offsets relative to the beginning of the array itself. */
-template <typename Type, typename OffsetType>
-struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType>
+template <typename Type, typename OffsetType, bool has_null=true>
+struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null>
{
inline const Type& operator [] (unsigned int i) const
{
- return this+this->arrayZ[i];
+ const OffsetTo<Type, OffsetType, has_null> *p = &this->arrayZ[i];
+ if (unlikely (p < this->arrayZ)) return Null (Type); /* Overflowed. */
+ return this+*p;
+ }
+ inline Type& operator [] (unsigned int i)
+ {
+ const OffsetTo<Type, OffsetType, has_null> *p = &this->arrayZ[i];
+ if (unlikely (p < this->arrayZ)) return Crap (Type); /* Overflowed. */
+ return this+*p;
}
+
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
- return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this)));
+ return_trace ((UnsizedOffsetArrayOf<Type, OffsetType, has_null>::sanitize (c, count, this)));
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const
{
TRACE_SANITIZE (this);
- return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this, user_data)));
+ return_trace ((UnsizedOffsetArrayOf<Type, OffsetType, has_null>::sanitize (c, count, this, user_data)));
}
};
+/* An array with sorted elements. Supports binary searching. */
+template <typename Type>
+struct SortedUnsizedArrayOf : UnsizedArrayOf<Type>
+{
+ inline hb_sorted_array_t<Type> as_array (unsigned int len)
+ { return hb_sorted_array (this->arrayZ, len); }
+ inline hb_sorted_array_t<const Type> as_array (unsigned int len) const
+ { return hb_sorted_array (this->arrayZ, len); }
+
+ template <typename T>
+ inline Type &bsearch (unsigned int len, const T &x, Type &not_found = Crap (Type))
+ { return *as_array (len).bsearch (x, &not_found); }
+ template <typename T>
+ inline const Type &bsearch (unsigned int len, const T &x, const Type &not_found = Null (Type)) const
+ { return *as_array (len).bsearch (x, &not_found); }
+ template <typename T>
+ inline bool bfind (unsigned int len, const T &x, unsigned int *i = nullptr,
+ hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
+ unsigned int to_store = (unsigned int) -1) const
+ { return as_array (len).bfind (x, i, not_found, to_store); }
+};
+
+
/* An array with a number of elements. */
template <typename Type, typename LenType=HBUINT16>
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;
- }
+ static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
+ enum { item_size = Type::static_size };
+
+ HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType);
inline const Type& operator [] (unsigned int i) const
{
- if (unlikely (i >= len)) return Null(Type);
+ if (unlikely (i >= len)) return Null (Type);
return arrayZ[i];
}
inline Type& operator [] (unsigned int i)
{
- if (unlikely (i >= len)) return Crap(Type);
+ 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 hb_array_t<Type> as_array (void)
+ { return hb_array (arrayZ, len); }
+ inline hb_array_t<const Type> as_array (void) const
+ { return hb_array (arrayZ, len); }
+
+ inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int count) const
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int *count /* IN/OUT */) const
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int count)
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count /* IN/OUT */)
+ { return as_array ().sub_array (start_offset, count);}
+
inline bool serialize (hb_serialize_context_t *c,
unsigned int items_len)
{
@@ -480,7 +573,7 @@ struct ArrayOf
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!arrayZ[i].sanitize (c, base)))
- return_trace (false);
+ return_trace (false);
return_trace (true);
}
template <typename T>
@@ -491,26 +584,20 @@ struct ArrayOf
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 (false);
return_trace (true);
}
- template <typename SearchType>
- 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;
- }
+ template <typename T>
+ inline Type &lsearch (const T &x, Type &not_found = Crap (Type))
+ { return *as_array ().lsearch (x, &not_found); }
+ template <typename T>
+ inline const Type &lsearch (const T &x, const Type &not_found = Null (Type)) const
+ { return *as_array ().lsearch (x, &not_found); }
- inline void qsort (void)
- {
- ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
- }
+ inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
+ { as_array ().qsort (start, end); }
- private:
inline bool sanitize_shallow (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -527,8 +614,12 @@ template <typename Type> struct LArrayOf : ArrayOf<Type, HBUINT32> {};
typedef ArrayOf<HBUINT8, HBUINT8> PString;
/* Array of Offset's */
-template <typename Type, typename OffsetType=HBUINT16>
-struct OffsetArrayOf : ArrayOf<OffsetTo<Type, OffsetType> > {};
+template <typename Type>
+struct OffsetArrayOf : ArrayOf<OffsetTo<Type, HBUINT16> > {};
+template <typename Type>
+struct LOffsetArrayOf : ArrayOf<OffsetTo<Type, HBUINT32> > {};
+template <typename Type>
+struct LOffsetLArrayOf : ArrayOf<OffsetTo<Type, HBUINT32>, HBUINT32> {};
/* Array of offsets relative to the beginning of the array itself. */
template <typename Type>
@@ -536,12 +627,12 @@ struct OffsetListOf : OffsetArrayOf<Type>
{
inline const Type& operator [] (unsigned int i) const
{
- if (unlikely (i >= this->len)) return Null(Type);
+ 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);
+ if (unlikely (i >= this->len)) return Crap (Type);
return this+this->arrayZ[i];
}
@@ -573,14 +664,18 @@ struct OffsetListOf : OffsetArrayOf<Type>
template <typename Type, typename LenType=HBUINT16>
struct HeadlessArrayOf
{
+ enum { item_size = Type::static_size };
+
+ HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType);
+
inline const Type& operator [] (unsigned int i) const
{
- if (unlikely (i >= lenP1 || !i)) return Null(Type);
+ if (unlikely (i >= lenP1 || !i)) return Null (Type);
return arrayZ[i-1];
}
inline Type& operator [] (unsigned int i)
{
- if (unlikely (i >= lenP1 || !i)) return Crap(Type);
+ if (unlikely (i >= lenP1 || !i)) return Crap (Type);
return arrayZ[i-1];
}
inline unsigned int get_size (void) const
@@ -637,14 +732,16 @@ struct HeadlessArrayOf
template <typename Type, typename LenType=HBUINT16>
struct ArrayOfM1
{
+ HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOfM1, Type, LenType);
+
inline const Type& operator [] (unsigned int i) const
{
- if (unlikely (i > lenM1)) return Null(Type);
+ if (unlikely (i > lenM1)) return Null (Type);
return arrayZ[i];
}
inline Type& operator [] (unsigned int i)
{
- if (unlikely (i > lenM1)) return Crap(Type);
+ if (unlikely (i > lenM1)) return Crap (Type);
return arrayZ[i];
}
inline unsigned int get_size (void) const
@@ -658,7 +755,7 @@ struct ArrayOfM1
unsigned int count = lenM1 + 1;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!arrayZ[i].sanitize (c, base, user_data)))
- return_trace (false);
+ return_trace (false);
return_trace (true);
}
@@ -681,28 +778,38 @@ struct ArrayOfM1
template <typename Type, typename LenType=HBUINT16>
struct SortedArrayOf : ArrayOf<Type, LenType>
{
- template <typename SearchType>
- 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;
- }
+ inline hb_sorted_array_t<Type> as_array (void)
+ { return hb_sorted_array (this->arrayZ, this->len); }
+ inline hb_sorted_array_t<const Type> as_array (void) const
+ { return hb_sorted_array (this->arrayZ, this->len); }
+
+ inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int count) const
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int *count /* IN/OUT */) const
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int count)
+ { return as_array ().sub_array (start_offset, count);}
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count /* IN/OUT */)
+ { return as_array ().sub_array (start_offset, count);}
+
+ template <typename T>
+ inline Type &bsearch (const T &x, Type &not_found = Crap (Type))
+ { return *as_array ().bsearch (x, &not_found); }
+ template <typename T>
+ inline const Type &bsearch (const T &x, const Type &not_found = Null (Type)) const
+ { return *as_array ().bsearch (x, &not_found); }
+ template <typename T>
+ inline bool bfind (const T &x, unsigned int *i = nullptr,
+ hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
+ unsigned int to_store = (unsigned int) -1) const
+ { return as_array ().bfind (x, i, not_found, to_store); }
};
-/* Binary-search arrays */
+/*
+ * Binary-search arrays
+ */
+
+template <typename LenType=HBUINT16>
struct BinSearchHeader
{
inline operator uint32_t (void) const { return len; }
@@ -725,17 +832,153 @@ struct BinSearchHeader
}
protected:
- HBUINT16 len;
- HBUINT16 searchRange;
- HBUINT16 entrySelector;
- HBUINT16 rangeShift;
+ LenType len;
+ LenType searchRange;
+ LenType entrySelector;
+ LenType rangeShift;
public:
DEFINE_SIZE_STATIC (8);
};
+template <typename Type, typename LenType=HBUINT16>
+struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader<LenType> > {};
+
+
+struct VarSizedBinSearchHeader
+{
+
+ 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 <typename Type>
-struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader> {};
+struct VarSizedBinSearchArrayOf
+{
+ enum { item_size = Type::static_size };
+
+ HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type);
+
+ inline bool last_is_terminator (void) const
+ {
+ if (unlikely (!header.nUnits)) return false;
+
+ /* Gah.
+ *
+ * "The number of termination values that need to be included is table-specific.
+ * The value that indicates binary search termination is 0xFFFF." */
+ const HBUINT16 *words = &StructAtOffset<HBUINT16> (&bytesZ, (header.nUnits - 1) * header.unitSize);
+ unsigned int count = Type::TerminationWordCount;
+ for (unsigned int i = 0; i < count; i++)
+ if (words[i] != 0xFFFFu)
+ return false;
+ return true;
+ }
+
+ inline const Type& operator [] (unsigned int i) const
+ {
+ if (unlikely (i >= get_length ())) return Null (Type);
+ return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
+ }
+ inline Type& operator [] (unsigned int i)
+ {
+ if (unlikely (i >= get_length ())) return Crap (Type);
+ return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
+ }
+ inline unsigned int get_length (void) const
+ {
+ return header.nUnits - last_is_terminator ();
+ }
+ 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<Type> (&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 = get_length ();
+ for (unsigned int i = 0; i < count; i++)
+ if (unlikely (!(*this)[i].sanitize (c, base)))
+ return_trace (false);
+ return_trace (true);
+ }
+ template <typename T>
+ 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 = get_length ();
+ for (unsigned int i = 0; i < count; i++)
+ if (unlikely (!(*this)[i].sanitize (c, base, user_data)))
+ return_trace (false);
+ return_trace (true);
+ }
+
+ template <typename T>
+ inline const Type *bsearch (const T &key) const
+ {
+ unsigned int size = header.unitSize;
+ int min = 0, max = (int) get_length () - 1;
+ while (min <= max)
+ {
+ int mid = ((unsigned int) min + (unsigned int) 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_range (bytesZ.arrayZ,
+ header.nUnits,
+ header.unitSize));
+ }
+
+ protected:
+ VarSizedBinSearchHeader header;
+ UnsizedArrayOf<HBUINT8> bytesZ;
+ public:
+ DEFINE_SIZE_ARRAY (10, bytesZ);
+};
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-cmap-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-cmap-table.hh
index 3f5fa01f556..cdc610be3ea 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-cmap-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-cmap-table.hh
@@ -53,7 +53,7 @@ struct CmapSubtableFormat0
{
for (unsigned int i = 0; i < 256; i++)
if (glyphIdArray[i])
- out->add (i);
+ out->add (i);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -82,8 +82,8 @@ struct CmapSubtableFormat4
};
bool serialize (hb_serialize_context_t *c,
- const hb_subset_plan_t *plan,
- const hb_vector_t<segment_plan> &segments)
+ const hb_subset_plan_t *plan,
+ const hb_vector_t<segment_plan> &segments)
{
TRACE_SERIALIZE (this);
@@ -96,8 +96,8 @@ struct CmapSubtableFormat4
this->entrySelector.set (MAX (1u, hb_bit_storage (segments.len)) - 1);
this->searchRange.set (2 * (1u << this->entrySelector));
this->rangeShift.set (segments.len * 2 > this->searchRange
- ? 2 * segments.len - this->searchRange
- : 0);
+ ? 2 * segments.len - this->searchRange
+ : 0);
HBUINT16 *end_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.len);
c->allocate_size<HBUINT16> (HBUINT16::static_size); // 2 bytes of padding.
@@ -114,40 +114,40 @@ struct CmapSubtableFormat4
start_count[i].set (segments[i].start_code);
if (segments[i].use_delta)
{
- hb_codepoint_t cp = segments[i].start_code;
- hb_codepoint_t start_gid = 0;
- if (unlikely (!plan->new_gid_for_codepoint (cp, &start_gid) && cp != 0xFFFF))
- return_trace (false);
- id_delta[i].set (start_gid - segments[i].start_code);
+ hb_codepoint_t cp = segments[i].start_code;
+ hb_codepoint_t start_gid = 0;
+ if (unlikely (!plan->new_gid_for_codepoint (cp, &start_gid) && cp != 0xFFFF))
+ return_trace (false);
+ id_delta[i].set (start_gid - segments[i].start_code);
} else {
- id_delta[i].set (0);
- unsigned int num_codepoints = segments[i].end_code - segments[i].start_code + 1;
- HBUINT16 *glyph_id_array = c->allocate_size<HBUINT16> (HBUINT16::static_size * num_codepoints);
- if (glyph_id_array == nullptr)
- return_trace (false);
- // From the cmap spec:
- //
- // id_range_offset[i]/2
- // + (cp - segments[i].start_code)
- // + (id_range_offset + i)
- // =
- // glyph_id_array + (cp - segments[i].start_code)
- //
- // So, solve for id_range_offset[i]:
- //
- // id_range_offset[i]
- // =
- // 2 * (glyph_id_array - id_range_offset - i)
- id_range_offset[i].set (2 * (
- glyph_id_array - id_range_offset - i));
- for (unsigned int j = 0; j < num_codepoints; j++)
- {
- hb_codepoint_t cp = segments[i].start_code + j;
- hb_codepoint_t new_gid;
- if (unlikely (!plan->new_gid_for_codepoint (cp, &new_gid)))
- return_trace (false);
- glyph_id_array[j].set (new_gid);
- }
+ id_delta[i].set (0);
+ unsigned int num_codepoints = segments[i].end_code - segments[i].start_code + 1;
+ HBUINT16 *glyph_id_array = c->allocate_size<HBUINT16> (HBUINT16::static_size * num_codepoints);
+ if (glyph_id_array == nullptr)
+ return_trace (false);
+ // From the cmap spec:
+ //
+ // id_range_offset[i]/2
+ // + (cp - segments[i].start_code)
+ // + (id_range_offset + i)
+ // =
+ // glyph_id_array + (cp - segments[i].start_code)
+ //
+ // So, solve for id_range_offset[i]:
+ //
+ // id_range_offset[i]
+ // =
+ // 2 * (glyph_id_array - id_range_offset - i)
+ id_range_offset[i].set (2 * (
+ glyph_id_array - id_range_offset - i));
+ for (unsigned int j = 0; j < num_codepoints; j++)
+ {
+ hb_codepoint_t cp = segments[i].start_code + j;
+ hb_codepoint_t new_gid;
+ if (unlikely (!plan->new_gid_for_codepoint (cp, &new_gid)))
+ return_trace (false);
+ glyph_id_array[j].set (new_gid);
+ }
}
}
@@ -161,23 +161,23 @@ struct CmapSubtableFormat4
{
// Parallel array entries
segment_size +=
- 2 // end count
- + 2 // start count
- + 2 // delta
- + 2; // range offset
+ 2 // end count
+ + 2 // start count
+ + 2 // delta
+ + 2; // range offset
if (!segments[i].use_delta)
- // Add bytes for the glyph index array entries for this segment.
- segment_size += (segments[i].end_code - segments[i].start_code + 1) * 2;
+ // Add bytes for the glyph index array entries for this segment.
+ segment_size += (segments[i].end_code - segments[i].start_code + 1) * 2;
}
return min_size
- + 2 // Padding
- + segment_size;
+ + 2 // Padding
+ + segment_size;
}
static inline bool create_sub_table_plan (const hb_subset_plan_t *plan,
- hb_vector_t<segment_plan> *segments)
+ hb_vector_t<segment_plan> *segments)
{
segment_plan *segment = nullptr;
hb_codepoint_t last_gid = 0;
@@ -191,24 +191,22 @@ struct CmapSubtableFormat4
return false;
}
- if (cp > 0xFFFF) {
- // We are now outside of unicode BMP, stop adding to this cmap.
- break;
- }
+ /* Stop adding to cmap if we are now outside of unicode BMP. */
+ if (cp > 0xFFFF) break;
- if (!segment
- || cp != segment->end_code + 1u)
+ if (!segment ||
+ cp != segment->end_code + 1u)
{
- segment = segments->push ();
- segment->start_code.set (cp);
- segment->end_code.set (cp);
- segment->use_delta = true;
+ segment = segments->push ();
+ segment->start_code.set (cp);
+ segment->end_code.set (cp);
+ segment->use_delta = true;
} else {
- segment->end_code.set (cp);
- if (last_gid + 1u != new_gid)
- // gid's are not consecutive in this segment so delta
- // cannot be used.
- segment->use_delta = false;
+ segment->end_code.set (cp);
+ if (last_gid + 1u != new_gid)
+ // gid's are not consecutive in this segment so delta
+ // cannot be used.
+ segment->use_delta = false;
}
last_gid = new_gid;
@@ -228,6 +226,10 @@ struct CmapSubtableFormat4
struct accelerator_t
{
+ inline accelerator_t (void) {}
+ inline accelerator_t (const CmapSubtableFormat4 *subtable) { init (subtable); }
+ inline ~accelerator_t (void) { fini (); }
+
inline void init (const CmapSubtableFormat4 *subtable)
{
segCount = subtable->segCountX2 / 2;
@@ -249,7 +251,7 @@ struct CmapSubtableFormat4
unsigned int i;
while (min <= max)
{
- int mid = (min + max) / 2;
+ int mid = ((unsigned int) min + (unsigned int) max) / 2;
if (codepoint < startCount[mid])
max = mid - 1;
else if (codepoint > endCount[mid])
@@ -292,7 +294,7 @@ struct CmapSubtableFormat4
{
unsigned int count = this->segCount;
if (count && this->startCount[count - 1] == 0xFFFFu)
- count--; /* Skip sentinel segment. */
+ count--; /* Skip sentinel segment. */
for (unsigned int i = 0; i < count; i++)
{
unsigned int rangeOffset = this->idRangeOffset[i];
@@ -327,12 +329,12 @@ struct CmapSubtableFormat4
inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
{
- hb_auto_t<accelerator_t> accel (this);
+ accelerator_t accel (this);
return accel.get_glyph_func (&accel, codepoint, glyph);
}
inline void collect_unicodes (hb_set_t *out) const
{
- hb_auto_t<accelerator_t> accel (this);
+ accelerator_t accel (this);
accel.collect_unicodes (out);
}
@@ -415,6 +417,7 @@ struct CmapSubtableLongGroup
public:
DEFINE_SIZE_STATIC (12);
};
+DECLARE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup);
template <typename UINT>
struct CmapSubtableTrimmed
@@ -434,7 +437,7 @@ struct CmapSubtableTrimmed
unsigned int count = glyphIdArray.len;
for (unsigned int i = 0; i < count; i++)
if (glyphIdArray[i])
- out->add (start + i);
+ out->add (start + i);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -465,10 +468,7 @@ struct CmapSubtableLongSegmented
inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
{
- int i = groups.bsearch (codepoint);
- if (i == -1)
- return false;
- hb_codepoint_t gid = T::group_get_glyph (groups[i], codepoint);
+ hb_codepoint_t gid = T::group_get_glyph (groups.bsearch (codepoint), codepoint);
if (!gid)
return false;
*glyph = gid;
@@ -491,11 +491,11 @@ struct CmapSubtableLongSegmented
}
inline bool serialize (hb_serialize_context_t *c,
- const hb_vector_t<CmapSubtableLongGroup> &group_data)
+ const hb_vector_t<CmapSubtableLongGroup> &group_data)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
- Supplier<CmapSubtableLongGroup> supplier (group_data.arrayZ, group_data.len);
+ Supplier<CmapSubtableLongGroup> supplier (group_data, group_data.len);
if (unlikely (!groups.serialize (c, supplier, group_data.len))) return_trace (false);
return true;
}
@@ -515,11 +515,12 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
{
static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group,
hb_codepoint_t u)
- { return group.glyphID + (u - group.startCharCode); }
+ { return likely (group.startCharCode <= group.endCharCode) ?
+ group.glyphID + (u - group.startCharCode) : 0; }
bool serialize (hb_serialize_context_t *c,
- const hb_vector_t<CmapSubtableLongGroup> &groups)
+ const hb_vector_t<CmapSubtableLongGroup> &groups)
{
if (unlikely (!c->extend_min (*this))) return false;
@@ -536,7 +537,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
}
static inline bool create_sub_table_plan (const hb_subset_plan_t *plan,
- hb_vector_t<CmapSubtableLongGroup> *groups)
+ hb_vector_t<CmapSubtableLongGroup> *groups)
{
CmapSubtableLongGroup *group = nullptr;
@@ -551,14 +552,12 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
if (!group || !_is_gid_consecutive (group, cp, new_gid))
{
- group = groups->push ();
- group->startCharCode.set (cp);
- group->endCharCode.set (cp);
- group->glyphID.set (new_gid);
- } else
- {
- group->endCharCode.set (cp);
+ group = groups->push ();
+ group->startCharCode.set (cp);
+ group->endCharCode.set (cp);
+ group->glyphID.set (new_gid);
}
+ else group->endCharCode.set (cp);
}
DEBUG_MSG(SUBSET, nullptr, "cmap");
@@ -632,7 +631,7 @@ struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32>
}
public:
- DEFINE_SIZE_ARRAY (4, arrayZ);
+ DEFINE_SIZE_ARRAY (4, *this);
};
struct UVSMapping
@@ -664,7 +663,7 @@ struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32>
}
public:
- DEFINE_SIZE_ARRAY (4, arrayZ);
+ DEFINE_SIZE_ARRAY (4, *this);
};
struct VariationSelectorRecord
@@ -673,16 +672,12 @@ struct VariationSelectorRecord
hb_codepoint_t *glyph,
const void *base) const
{
- int i;
- const DefaultUVS &defaults = base+defaultUVS;
- i = defaults.bsearch (codepoint);
- if (i != -1)
+ if ((base+defaultUVS).bfind (codepoint))
return GLYPH_VARIANT_USE_DEFAULT;
- const NonDefaultUVS &nonDefaults = base+nonDefaultUVS;
- i = nonDefaults.bsearch (codepoint);
- if (i != -1 && nonDefaults[i].glyphID)
+ const UVSMapping &nonDefault = (base+nonDefaultUVS).bsearch (codepoint);
+ if (nonDefault.glyphID)
{
- *glyph = nonDefaults[i].glyphID;
+ *glyph = nonDefault.glyphID;
return GLYPH_VARIANT_FOUND;
}
return GLYPH_VARIANT_NOT_FOUND;
@@ -709,9 +704,9 @@ struct VariationSelectorRecord
HBUINT24 varSelector; /* Variation selector. */
LOffsetTo<DefaultUVS>
- defaultUVS; /* Offset to Default UVS Table. May be 0. */
+ defaultUVS; /* Offset to Default UVS Table. May be 0. */
LOffsetTo<NonDefaultUVS>
- nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */
+ nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */
public:
DEFINE_SIZE_STATIC (11);
};
@@ -722,7 +717,7 @@ 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.bsearch (variation_selector).get_glyph (codepoint, glyph, this);
}
inline void collect_variation_selectors (hb_set_t *out) const
@@ -734,7 +729,7 @@ struct CmapSubtableFormat14
inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
hb_set_t *out) const
{
- record[record.bsearch (variation_selector)].collect_unicodes (out, this);
+ record.bsearch (variation_selector).collect_unicodes (out, this);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -851,51 +846,29 @@ struct cmap
struct subset_plan
{
- subset_plan(void)
- {
- format4_segments.init();
- format12_groups.init();
- }
-
- ~subset_plan(void)
- {
- format4_segments.fini();
- format12_groups.fini();
- }
-
- inline size_t final_size() const
+ inline size_t final_size () const
{
return 4 // header
- + 8 * 3 // 3 EncodingRecord
- + CmapSubtableFormat4::get_sub_table_size (this->format4_segments)
- + CmapSubtableFormat12::get_sub_table_size (this->format12_groups);
+ + 8 * 3 // 3 EncodingRecord
+ + CmapSubtableFormat4::get_sub_table_size (this->format4_segments)
+ + CmapSubtableFormat12::get_sub_table_size (this->format12_groups);
}
- // Format 4
hb_vector_t<CmapSubtableFormat4::segment_plan> format4_segments;
- // Format 12
hb_vector_t<CmapSubtableLongGroup> format12_groups;
};
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- likely (version == 0) &&
- encodingRecord.sanitize (c, this));
- }
-
inline bool _create_plan (const hb_subset_plan_t *plan,
- subset_plan *cmap_plan) const
+ subset_plan *cmap_plan) const
{
- if (unlikely( !CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments)))
+ if (unlikely (!CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments)))
return false;
return CmapSubtableFormat12::create_sub_table_plan (plan, &cmap_plan->format12_groups);
}
inline bool _subset (const hb_subset_plan_t *plan,
- const subset_plan &cmap_subset_plan,
+ const subset_plan &cmap_subset_plan,
size_t dest_sz,
void *dest) const
{
@@ -937,7 +910,7 @@ struct cmap
CmapSubtableFormat4 &format4 = subtable.u.format4;
if (unlikely (!format4.serialize (&c, plan, cmap_subset_plan.format4_segments)))
- return false;
+ return false;
}
// Write out format 12 sub table.
@@ -947,7 +920,7 @@ struct cmap
CmapSubtableFormat12 &format12 = subtable.u.format12;
if (unlikely (!format12.serialize (&c, cmap_subset_plan.format12_groups)))
- return false;
+ return false;
}
c.end_serialize ();
@@ -966,7 +939,7 @@ struct cmap
}
// We now know how big our blob needs to be
- size_t dest_sz = cmap_subset_plan.final_size();
+ size_t dest_sz = cmap_subset_plan.final_size ();
void *dest = malloc (dest_sz);
if (unlikely (!dest)) {
DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for cmap subset output", (unsigned long) dest_sz);
@@ -981,11 +954,11 @@ struct cmap
}
// all done, write the blob into dest
- hb_blob_t *cmap_prime = hb_blob_create ((const char *)dest,
- dest_sz,
- HB_MEMORY_MODE_READONLY,
- dest,
- free);
+ hb_blob_t *cmap_prime = hb_blob_create ((const char *) dest,
+ dest_sz,
+ HB_MEMORY_MODE_READONLY,
+ dest,
+ free);
bool result = plan->add_table (HB_OT_TAG_cmap, cmap_prime);
hb_blob_destroy (cmap_prime);
return result;
@@ -1017,49 +990,41 @@ struct cmap
}
/* Meh. */
- return &Null(CmapSubtable);
+ return &Null (CmapSubtable);
}
struct accelerator_t
{
inline void init (hb_face_t *face)
{
- this->blob = hb_sanitize_context_t().reference_table<cmap> (face);
- const cmap *table = this->blob->as<cmap> ();
- const CmapSubtableFormat14 *subtable_uvs = nullptr;
+ this->table = hb_sanitize_context_t ().reference_table<cmap> (face);
bool symbol;
- subtable = table->find_best_subtable (&symbol);
-
- /* UVS subtable. */
- if (!subtable_uvs)
+ this->subtable = table->find_best_subtable (&symbol);
+ this->subtable_uvs = &Null (CmapSubtableFormat14);
{
const CmapSubtable *st = table->find_subtable (0, 5);
if (st && st->u.format == 14)
subtable_uvs = &st->u.format14;
}
- /* Meh. */
- if (!subtable_uvs) subtable_uvs = &Null(CmapSubtableFormat14);
-
- this->subtable_uvs = subtable_uvs;
this->get_glyph_data = subtable;
if (unlikely (symbol))
{
- this->get_glyph_func = get_glyph_from_symbol<CmapSubtable>;
+ this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable>;
} else {
switch (subtable->u.format) {
/* Accelerate format 4 and format 12. */
default:
- this->get_glyph_func = get_glyph_from<CmapSubtable>;
+ this->get_glyph_funcZ = get_glyph_from<CmapSubtable>;
break;
case 12:
- this->get_glyph_func = get_glyph_from<CmapSubtableFormat12>;
+ this->get_glyph_funcZ = get_glyph_from<CmapSubtableFormat12>;
break;
case 4:
{
this->format4_accel.init (&subtable->u.format4);
this->get_glyph_data = &this->format4_accel;
- this->get_glyph_func = this->format4_accel.get_glyph_func;
+ this->get_glyph_funcZ = this->format4_accel.get_glyph_func;
}
break;
}
@@ -1068,13 +1033,35 @@ struct cmap
inline void fini (void)
{
- hb_blob_destroy (this->blob);
+ this->table.destroy ();
}
inline bool get_nominal_glyph (hb_codepoint_t unicode,
hb_codepoint_t *glyph) const
{
- return this->get_glyph_func (this->get_glyph_data, unicode, glyph);
+ if (unlikely (!this->get_glyph_funcZ)) return false;
+ return this->get_glyph_funcZ (this->get_glyph_data, unicode, glyph);
+ }
+ inline unsigned int get_nominal_glyphs (unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride) const
+ {
+ if (unlikely (!this->get_glyph_funcZ)) return 0;
+
+ hb_cmap_get_glyph_func_t get_glyph_funcZ = this->get_glyph_funcZ;
+ const void *get_glyph_data = this->get_glyph_data;
+
+ unsigned int done;
+ for (done = 0;
+ done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph);
+ done++)
+ {
+ first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride);
+ first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
+ }
+ return done;
}
inline bool get_variation_glyph (hb_codepoint_t unicode,
@@ -1144,15 +1131,15 @@ struct cmap
}
private:
- const CmapSubtable *subtable;
- const CmapSubtableFormat14 *subtable_uvs;
+ hb_nonnull_ptr_t<const CmapSubtable> subtable;
+ hb_nonnull_ptr_t<const CmapSubtableFormat14> subtable_uvs;
- hb_cmap_get_glyph_func_t get_glyph_func;
+ hb_cmap_get_glyph_func_t get_glyph_funcZ;
const void *get_glyph_data;
CmapSubtableFormat4::accelerator_t format4_accel;
- hb_blob_t *blob;
+ hb_blob_ptr_t<cmap> table;
};
protected:
@@ -1164,11 +1151,21 @@ struct cmap
key.platformID.set (platform_id);
key.encodingID.set (encoding_id);
- int result = encodingRecord.bsearch (key);
- if (result == -1 || !encodingRecord[result].subtable)
+ const EncodingRecord &result = encodingRecord.bsearch (key);
+ if (!result.subtable)
return nullptr;
- return &(this+encodingRecord[result].subtable);
+ return &(this+result.subtable);
+ }
+
+ public:
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ likely (version == 0) &&
+ encodingRecord.sanitize (c, this));
}
protected:
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cbdt-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cbdt-table.hh
index 561c59900ad..47774fd8f0a 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cbdt-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cbdt-table.hh
@@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (offsetArrayZ.arrayZ, glyph_count + 1));
+ offsetArrayZ.sanitize (c, glyph_count + 1));
}
bool get_image_data (unsigned int idx,
@@ -166,7 +166,7 @@ struct IndexSubtable
}
}
- inline bool get_extents (hb_glyph_extents_t *extents) const
+ inline bool get_extents (hb_glyph_extents_t *extents HB_UNUSED) const
{
switch (u.header.indexFormat) {
case 2: case 5: /* TODO */
@@ -206,24 +206,23 @@ struct IndexSubtableRecord
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
firstGlyphIndex <= lastGlyphIndex &&
- offsetToSubtable.sanitize (c, this, lastGlyphIndex - firstGlyphIndex + 1));
+ offsetToSubtable.sanitize (c, base, lastGlyphIndex - firstGlyphIndex + 1));
}
- inline bool get_extents (hb_glyph_extents_t *extents) const
+ inline bool get_extents (hb_glyph_extents_t *extents,
+ const void *base) const
{
- return (this+offsetToSubtable).get_extents (extents);
+ return (base+offsetToSubtable).get_extents (extents);
}
- bool get_image_data (unsigned int gid,
+ bool get_image_data (unsigned int gid,
+ const void *base,
unsigned int *offset,
unsigned int *length,
unsigned int *format) const
{
- if (gid < firstGlyphIndex || gid > lastGlyphIndex)
- {
- return false;
- }
- return (this+offsetToSubtable).get_image_data (gid - firstGlyphIndex,
+ if (gid < firstGlyphIndex || gid > lastGlyphIndex) return false;
+ return (base+offsetToSubtable).get_image_data (gid - firstGlyphIndex,
offset, length, format);
}
@@ -241,12 +240,7 @@ struct IndexSubtableArray
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
- if (unlikely (!c->check_array (indexSubtablesZ.arrayZ, count)))
- return_trace (false);
- for (unsigned int i = 0; i < count; i++)
- if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
- return_trace (false);
- return_trace (true);
+ return_trace (indexSubtablesZ.sanitize (c, count, this));
}
public:
@@ -276,13 +270,15 @@ struct BitmapSizeTable
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
- c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) &&
horizontal.sanitize (c) &&
vertical.sanitize (c));
}
- const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
+ const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
+ const void *base,
+ const void **out_base) const
{
+ *out_base = &(base+indexSubtableArrayOffset);
return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
}
@@ -347,25 +343,30 @@ struct CBLC
}
protected:
- const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
- unsigned int *x_ppem, unsigned int *y_ppem) const
+ const BitmapSizeTable &choose_strike (hb_font_t *font) const
{
- /* TODO: Make it possible to select strike. */
+ unsigned count = sizeTables.len;
+ if (unlikely (!count))
+ return Null(BitmapSizeTable);
+
+ unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
+ if (!requested_ppem)
+ requested_ppem = 1<<30; /* Choose largest strike. */
+ unsigned int best_i = 0;
+ unsigned int best_ppem = MAX (sizeTables[0].ppemX, sizeTables[0].ppemY);
- unsigned int count = sizeTables.len;
- for (uint32_t i = 0; i < count; ++i)
+ for (unsigned int i = 1; i < count; i++)
{
- unsigned int startGlyphIndex = sizeTables.arrayZ[i].startGlyphIndex;
- unsigned int endGlyphIndex = sizeTables.arrayZ[i].endGlyphIndex;
- if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
+ unsigned int ppem = MAX (sizeTables[i].ppemX, sizeTables[i].ppemY);
+ if ((requested_ppem <= ppem && ppem < best_ppem) ||
+ (requested_ppem > best_ppem && ppem > best_ppem))
{
- *x_ppem = sizeTables[i].ppemX;
- *y_ppem = sizeTables[i].ppemY;
- return sizeTables[i].find_table (glyph, this);
+ best_i = i;
+ best_ppem = ppem;
}
}
- return nullptr;
+ return sizeTables[best_i];
}
protected:
@@ -379,58 +380,40 @@ struct CBDT
{
static const hb_tag_t tableTag = HB_OT_TAG_CBDT;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- likely (version.major == 2 || version.major == 3));
- }
-
struct accelerator_t
{
inline void init (hb_face_t *face)
{
- upem = hb_face_get_upem (face);
-
- cblc_blob = hb_sanitize_context_t().reference_table<CBLC> (face);
- cbdt_blob = hb_sanitize_context_t().reference_table<CBDT> (face);
- cbdt_len = hb_blob_get_length (cbdt_blob);
-
- if (hb_blob_get_length (cblc_blob) == 0) {
- cblc = nullptr;
- cbdt = nullptr;
- return; /* Not a bitmap font. */
- }
- cblc = cblc_blob->as<CBLC> ();
- cbdt = cbdt_blob->as<CBDT> ();
+ cblc = hb_sanitize_context_t().reference_table<CBLC> (face);
+ cbdt = hb_sanitize_context_t().reference_table<CBDT> (face);
+ upem = hb_face_get_upem (face);
}
inline void fini (void)
{
- hb_blob_destroy (this->cblc_blob);
- hb_blob_destroy (this->cbdt_blob);
+ this->cblc.destroy ();
+ this->cbdt.destroy ();
}
- inline bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
+ inline bool get_extents (hb_font_t *font, hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents) const
{
- unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */
-
- if (!cblc)
- return false; // Not a color bitmap font.
-
- const IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem);
- if (!subtable_record || !x_ppem || !y_ppem)
+ const void *base;
+ const BitmapSizeTable &strike = this->cblc->choose_strike (font);
+ const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base);
+ if (!subtable_record || !strike.ppemX || !strike.ppemY)
return false;
- if (subtable_record->get_extents (extents))
+ if (subtable_record->get_extents (extents, base))
return true;
unsigned int image_offset = 0, image_length = 0, image_format = 0;
- if (!subtable_record->get_image_data (glyph, &image_offset, &image_length, &image_format))
+ if (!subtable_record->get_image_data (glyph, base, &image_offset, &image_length, &image_format))
return false;
{
+ unsigned int cbdt_len = cbdt.get_length ();
if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
return false;
@@ -439,90 +422,104 @@ struct CBDT
case 17: {
if (unlikely (image_length < GlyphBitmapDataFormat17::min_size))
return false;
-
const GlyphBitmapDataFormat17& glyphFormat17 =
StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
glyphFormat17.glyphMetrics.get_extents (extents);
+ break;
+ }
+ case 18: {
+ if (unlikely (image_length < GlyphBitmapDataFormat18::min_size))
+ return false;
+ const GlyphBitmapDataFormat18& glyphFormat18 =
+ StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
+ glyphFormat18.glyphMetrics.get_extents (extents);
+ break;
}
- break;
default:
// TODO: Support other image formats.
return false;
}
}
- /* Convert to the font units. */
- extents->x_bearing *= upem / (float) x_ppem;
- extents->y_bearing *= upem / (float) y_ppem;
- extents->width *= upem / (float) x_ppem;
- extents->height *= upem / (float) y_ppem;
+ /* Convert to font units. */
+ double x_scale = upem / (double) strike.ppemX;
+ double y_scale = upem / (double) strike.ppemY;
+ extents->x_bearing = round (extents->x_bearing * x_scale);
+ extents->y_bearing = round (extents->y_bearing * y_scale);
+ extents->width = round (extents->width * x_scale);
+ extents->height = round (extents->height * y_scale);
return true;
}
- inline void dump (void (*callback) (const uint8_t* data, unsigned int length,
- unsigned int group, unsigned int gid)) const
+ inline hb_blob_t* reference_png (hb_font_t *font,
+ hb_codepoint_t glyph) const
{
- if (!cblc)
- return; // Not a color bitmap font.
+ const void *base;
+ const BitmapSizeTable &strike = this->cblc->choose_strike (font);
+ const IndexSubtableRecord *subtable_record = strike.find_table (glyph, cblc, &base);
+ if (!subtable_record || !strike.ppemX || !strike.ppemY)
+ return hb_blob_get_empty ();
+
+ unsigned int image_offset = 0, image_length = 0, image_format = 0;
+ if (!subtable_record->get_image_data (glyph, base, &image_offset, &image_length, &image_format))
+ return hb_blob_get_empty ();
- for (unsigned int i = 0; i < cblc->sizeTables.len; ++i)
{
- const BitmapSizeTable &sizeTable = cblc->sizeTables[i];
- const IndexSubtableArray &subtable_array = cblc+sizeTable.indexSubtableArrayOffset;
- for (unsigned int j = 0; j < sizeTable.numberOfIndexSubtables; ++j)
- {
- const IndexSubtableRecord &subtable_record = subtable_array.indexSubtablesZ[j];
- for (unsigned int gid = subtable_record.firstGlyphIndex;
- gid <= subtable_record.lastGlyphIndex; ++gid)
- {
- unsigned int image_offset = 0, image_length = 0, image_format = 0;
-
- if (!subtable_record.get_image_data (gid,
- &image_offset, &image_length, &image_format))
- continue;
-
- switch (image_format)
- {
- case 17: {
- const GlyphBitmapDataFormat17& glyphFormat17 =
- StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
- callback ((const uint8_t *) &glyphFormat17.data.arrayZ,
- glyphFormat17.data.len, i, gid);
- }
- break;
- case 18: {
- const GlyphBitmapDataFormat18& glyphFormat18 =
- StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
- callback ((const uint8_t *) &glyphFormat18.data.arrayZ,
- glyphFormat18.data.len, i, gid);
- }
- break;
- case 19: {
- const GlyphBitmapDataFormat19& glyphFormat19 =
- StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
- callback ((const uint8_t *) &glyphFormat19.data.arrayZ,
- glyphFormat19.data.len, i, gid);
- }
- break;
- default:
- continue;
- }
- }
- }
+ unsigned int cbdt_len = cbdt.get_length ();
+ if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
+ return hb_blob_get_empty ();
+
+ switch (image_format)
+ {
+ case 17: {
+ if (unlikely (image_length < GlyphBitmapDataFormat17::min_size))
+ return hb_blob_get_empty ();
+ const GlyphBitmapDataFormat17& glyphFormat17 =
+ StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
+ return hb_blob_create_sub_blob (cbdt.get_blob (),
+ image_offset + GlyphBitmapDataFormat17::min_size,
+ glyphFormat17.data.len);
+ }
+ case 18: {
+ if (unlikely (image_length < GlyphBitmapDataFormat18::min_size))
+ return hb_blob_get_empty ();
+ const GlyphBitmapDataFormat18& glyphFormat18 =
+ StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
+ return hb_blob_create_sub_blob (cbdt.get_blob (),
+ image_offset + GlyphBitmapDataFormat18::min_size,
+ glyphFormat18.data.len);
+ }
+ case 19: {
+ if (unlikely (image_length < GlyphBitmapDataFormat19::min_size))
+ return hb_blob_get_empty ();
+ const GlyphBitmapDataFormat19& glyphFormat19 =
+ StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
+ return hb_blob_create_sub_blob (cbdt.get_blob (),
+ image_offset + GlyphBitmapDataFormat19::min_size,
+ glyphFormat19.data.len);
+ }
+ }
}
+
+ return hb_blob_get_empty ();
}
+ inline bool has_data () const { return cbdt.get_length (); }
+
private:
- hb_blob_t *cblc_blob;
- hb_blob_t *cbdt_blob;
- const CBLC *cblc;
- const CBDT *cbdt;
+ hb_blob_ptr_t<CBLC> cblc;
+ hb_blob_ptr_t<CBDT> cbdt;
- unsigned int cbdt_len;
unsigned int upem;
};
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ likely (version.major == 2 || version.major == 3));
+ }
protected:
FixedVersion<> version;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-colr-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-colr-table.hh
index a59d2bfa93e..84c34332556 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-colr-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-colr-table.hh
@@ -39,24 +39,32 @@ namespace OT {
struct LayerRecord
{
- friend struct COLR;
-
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this));
}
- protected:
- GlyphID glyphid; /* Glyph ID of layer glyph */
- HBUINT16 colorIdx; /* Index value to use with a selected color palette */
+ public:
+ GlyphID glyphId; /* Glyph ID of layer glyph */
+ Index colorIdx; /* Index value to use with a
+ * selected color palette.
+ * An index value of 0xFFFF
+ * is a special case indicating
+ * that the text foreground
+ * color (defined by a
+ * higher-level client) should
+ * be used and shall not be
+ * treated as actual index
+ * into CPAL ColorRecord array. */
public:
DEFINE_SIZE_STATIC (4);
};
struct BaseGlyphRecord
{
- friend struct COLR;
+ inline int cmp (hb_codepoint_t g) const
+ { return g < glyphId ? -1 : g > glyphId ? 1 : 0; }
inline bool sanitize (hb_sanitize_context_t *c) const
{
@@ -64,29 +72,48 @@ struct BaseGlyphRecord
return_trace (likely (c->check_struct (this)));
}
- inline int cmp (hb_codepoint_t g) const {
- return g < glyphid ? -1 : g > glyphid ? 1 : 0;
- }
-
- protected:
- GlyphID glyphid; /* Glyph ID of reference glyph */
- HBUINT16 firstLayerIdx; /* Index to the layer record */
- HBUINT16 numLayers; /* Number of color layers associated with this glyph */
+ public:
+ GlyphID glyphId; /* Glyph ID of reference glyph */
+ HBUINT16 firstLayerIdx; /* Index (from beginning of
+ * the Layer Records) to the
+ * layer record. There will be
+ * numLayers consecutive entries
+ * for this base glyph. */
+ HBUINT16 numLayers; /* Number of color layers
+ * associated with this glyph */
public:
DEFINE_SIZE_STATIC (6);
};
-static int compare_bgr (const void *pa, const void *pb)
-{
- const hb_codepoint_t *a = (const hb_codepoint_t *) pa;
- const BaseGlyphRecord *b = (const BaseGlyphRecord *) pb;
- return b->cmp (*a);
-}
-
struct COLR
{
static const hb_tag_t tableTag = HB_OT_TAG_COLR;
+ inline bool has_data (void) const { return numBaseGlyphs; }
+
+ inline unsigned int get_glyph_layers (hb_codepoint_t glyph,
+ unsigned int start_offset,
+ unsigned int *count, /* IN/OUT. May be NULL. */
+ hb_ot_color_layer_t *layers /* OUT. May be NULL. */) const
+ {
+ const BaseGlyphRecord &record = (this+baseGlyphsZ).bsearch (numBaseGlyphs, glyph);
+
+ hb_array_t<const LayerRecord> all_layers ((this+layersZ).arrayZ, numLayers);
+ hb_array_t<const LayerRecord> glyph_layers = all_layers.sub_array (record.firstLayerIdx,
+ record.numLayers);
+ if (count)
+ {
+ hb_array_t<const LayerRecord> segment_layers = glyph_layers.sub_array (start_offset, *count);
+ *count = segment_layers.len;
+ for (unsigned int i = 0; i < segment_layers.len; i++)
+ {
+ layers[i].glyph = segment_layers.arrayZ[i].glyphId;
+ layers[i].color_index = segment_layers.arrayZ[i].colorIdx;
+ }
+ }
+ return glyph_layers.len;
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -95,45 +122,14 @@ struct COLR
(this+layersZ).sanitize (c, numLayers)));
}
- inline bool get_base_glyph_record (hb_codepoint_t glyph_id,
- unsigned int *first_layer /* OUT */,
- unsigned int *num_layers /* OUT */) const
- {
- const BaseGlyphRecord* record;
- record = (BaseGlyphRecord *) bsearch (&glyph_id, &(this+baseGlyphsZ), numBaseGlyphs,
- sizeof (BaseGlyphRecord), compare_bgr);
- if (unlikely (!record))
- return false;
-
- *first_layer = record->firstLayerIdx;
- *num_layers = record->numLayers;
- return true;
- }
-
- inline bool get_layer_record (unsigned int record,
- hb_codepoint_t *glyph_id /* OUT */,
- unsigned int *palette_index /* OUT */) const
- {
- if (unlikely (record >= numLayers))
- {
- *glyph_id = 0;
- *palette_index = 0xFFFF;
- return false;
- }
- const LayerRecord &layer = (this+layersZ)[record];
- *glyph_id = layer.glyphid;
- *palette_index = layer.colorIdx;
- return true;
- }
-
protected:
- HBUINT16 version; /* Table version number */
- HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records */
- LOffsetTo<UnsizedArrayOf<BaseGlyphRecord>, false>
+ HBUINT16 version; /* Table version number (starts at 0). */
+ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */
+ LOffsetTo<SortedUnsizedArrayOf<BaseGlyphRecord>, false>
baseGlyphsZ; /* Offset to Base Glyph records. */
LOffsetTo<UnsizedArrayOf<LayerRecord>, false>
- layersZ; /* Offset to Layer Records */
- HBUINT16 numLayers; /* Number of Layer Records */
+ layersZ; /* Offset to Layer Records. */
+ HBUINT16 numLayers; /* Number of Layer Records. */
public:
DEFINE_SIZE_STATIC (14);
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cpal-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cpal-table.hh
index e354ced5c28..332f0dd7452 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cpal-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-cpal-table.hh
@@ -29,53 +29,8 @@
#define HB_OT_COLOR_CPAL_TABLE_HH
#include "hb-open-type.hh"
-
-
-/*
- * Following parts to be moved to a public header.
- */
-
-/**
- * hb_ot_color_t:
- * ARGB data type for holding color values.
- *
- * Since: REPLACEME
- */
-typedef uint32_t hb_ot_color_t;
-
-
-/**
- * hb_ot_color_palette_flags_t:
- * @HB_OT_COLOR_PALETTE_FLAG_DEFAULT: default indicating that there is nothing special to note about a color palette.
- * @HB_OT_COLOR_PALETTE_FLAG_FOR_LIGHT_BACKGROUND: flag indicating that the color palette is suitable for rendering text on light background.
- * @HB_OT_COLOR_PALETTE_FLAG_FOR_DARK_BACKGROUND: flag indicating that the color palette is suitable for rendering text on dark background.
- *
- * Since: REPLACEME
- */
-typedef enum { /*< flags >*/
- HB_OT_COLOR_PALETTE_FLAG_DEFAULT = 0x00000000u,
- HB_OT_COLOR_PALETTE_FLAG_FOR_LIGHT_BACKGROUND = 0x00000001u,
- HB_OT_COLOR_PALETTE_FLAG_FOR_DARK_BACKGROUND = 0x00000002u,
-} hb_ot_color_palette_flags_t;
-
-// HB_EXTERN unsigned int
-// hb_ot_color_get_palette_count (hb_face_t *face);
-
-// HB_EXTERN unsigned int
-// hb_ot_color_get_palette_name_id (hb_face_t *face, unsigned int palette);
-
-// HB_EXTERN hb_ot_color_palette_flags_t
-// hb_ot_color_get_palette_flags (hb_face_t *face, unsigned int palette);
-
-// HB_EXTERN unsigned int
-// hb_ot_color_get_palette_colors (hb_face_t *face,
-// unsigned int palette, /* default=0 */
-// unsigned int start_offset,
-// unsigned int *color_count /* IN/OUT */,
-// hb_ot_color_t *colors /* OUT */);
-
-
-
+#include "hb-ot-color.h"
+#include "hb-ot-name.h"
/*
@@ -92,29 +47,46 @@ struct CPALV1Tail
{
friend struct CPAL;
- inline bool
- sanitize (hb_sanitize_context_t *c, const void *base, unsigned int palettes) const
+ private:
+ inline hb_ot_color_palette_flags_t
+ get_palette_flags (const void *base,
+ unsigned int palette_index,
+ unsigned int palette_count) const
{
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- (base+paletteFlagsZ).sanitize (c, palettes) &&
- (base+paletteLabelZ).sanitize (c, palettes) &&
- (base+paletteEntryLabelZ).sanitize (c, palettes));
+ if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
+ return (hb_ot_color_palette_flags_t) (uint32_t)
+ (base+paletteFlagsZ).as_array (palette_count)[palette_index];
}
- private:
- inline hb_ot_color_palette_flags_t
- get_palette_flags (const void *base, unsigned int palette) const
+ inline hb_ot_name_id_t
+ get_palette_name_id (const void *base,
+ unsigned int palette_index,
+ unsigned int palette_count) const
{
- // range checked at the CPAL caller
- return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette];
+ if (!paletteLabelsZ) return HB_OT_NAME_ID_INVALID;
+ return (base+paletteLabelsZ).as_array (palette_count)[palette_index];
}
- inline unsigned int
- get_palette_name_id (const void *base, unsigned int palette) const
+ inline hb_ot_name_id_t
+ get_color_name_id (const void *base,
+ unsigned int color_index,
+ unsigned int color_count) const
{
- // range checked at the CPAL caller
- return (base+paletteLabelZ)[palette];
+ if (!colorLabelsZ) return HB_OT_NAME_ID_INVALID;
+ return (base+colorLabelsZ).as_array (color_count)[color_index];
+ }
+
+ public:
+ inline bool sanitize (hb_sanitize_context_t *c,
+ const void *base,
+ unsigned int palette_count,
+ unsigned int color_count) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ (!paletteFlagsZ || (base+paletteFlagsZ).sanitize (c, palette_count)) &&
+ (!paletteLabelsZ || (base+paletteLabelsZ).sanitize (c, palette_count)) &&
+ (!colorLabelsZ || (base+colorLabelsZ).sanitize (c, color_count)));
}
protected:
@@ -122,13 +94,13 @@ struct CPALV1Tail
paletteFlagsZ; /* Offset from the beginning of CPAL table to
* the Palette Type Array. Set to 0 if no array
* is provided. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
- paletteLabelZ; /* Offset from the beginning of CPAL table to
- * the Palette Labels Array. Set to 0 if no
+ LOffsetTo<UnsizedArrayOf<NameID>, false>
+ paletteLabelsZ; /* Offset from the beginning of CPAL table to
+ * the palette labels array. Set to 0 if no
* array is provided. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
- paletteEntryLabelZ; /* Offset from the beginning of CPAL table to
- * the Palette Entry Label Array. Set to 0
+ LOffsetTo<UnsizedArrayOf<NameID>, false>
+ colorLabelsZ; /* Offset from the beginning of CPAL table to
+ * the color labels array. Set to 0
* if no array is provided. */
public:
DEFINE_SIZE_STATIC (12);
@@ -140,70 +112,70 @@ struct CPAL
{
static const hb_tag_t tableTag = HB_OT_TAG_CPAL;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- if (unlikely (!(c->check_struct (this) && // it checks colorRecordIndices also
- // see #get_size
- (this+colorRecordsZ).sanitize (c, numColorRecords))))
- return_trace (false);
-
- // Check for indices sanity so no need for doing it runtime
- for (unsigned int i = 0; i < numPalettes; ++i)
- if (unlikely (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords))
- return_trace (false);
-
- // If version is zero, we are done here; otherwise we need to check tail also
- if (version == 0)
- return_trace (true);
-
- const CPALV1Tail &v1 = StructAfter<CPALV1Tail> (*this);
- return_trace (likely (v1.sanitize (c, this, numPalettes)));
- }
+ inline bool has_data (void) const { return numPalettes; }
inline unsigned int get_size (void) const
- {
- return min_size + numPalettes * sizeof (HBUINT16);
- }
+ { return min_size + numPalettes * sizeof (colorRecordIndicesZ[0]); }
- inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette) const
- {
- if (unlikely (version == 0 || palette >= numPalettes))
- return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
+ inline unsigned int get_palette_count () const { return numPalettes; }
+ inline unsigned int get_color_count () const { return numColors; }
- const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_flags (this, palette);
- }
+ inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const
+ { return v1 ().get_palette_flags (this, palette_index, numPalettes); }
- inline unsigned int get_palette_name_id (unsigned int palette) const
- {
- if (unlikely (version == 0 || palette >= numPalettes))
- return 0xFFFF;
+ inline hb_ot_name_id_t get_palette_name_id (unsigned int palette_index) const
+ { return v1 ().get_palette_name_id (this, palette_index, numPalettes); }
- const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_name_id (this, palette);
- }
+ inline hb_ot_name_id_t get_color_name_id (unsigned int color_index) const
+ { return v1 ().get_color_name_id (this, color_index, numColors); }
- inline unsigned int get_palette_count () const
+ inline unsigned int get_palette_colors (unsigned int palette_index,
+ unsigned int start_offset,
+ unsigned int *color_count, /* IN/OUT. May be NULL. */
+ hb_color_t *colors /* OUT. May be NULL. */) const
{
- return numPalettes;
+ if (unlikely (palette_index >= numPalettes))
+ {
+ if (color_count) *color_count = 0;
+ return 0;
+ }
+ unsigned int start_index = colorRecordIndicesZ[palette_index];
+ hb_array_t<const BGRAColor> all_colors ((this+colorRecordsZ).arrayZ, numColorRecords);
+ hb_array_t<const BGRAColor> palette_colors = all_colors.sub_array (start_index,
+ numColors);
+ if (color_count)
+ {
+ hb_array_t<const BGRAColor> segment_colors = palette_colors.sub_array (start_offset, *color_count);
+ /* Always return numColors colors per palette even if it has out-of-bounds start index. */
+ unsigned int count = MIN<unsigned int> (MAX<int> (numColors - start_offset, 0), *color_count);
+ *color_count = count;
+ for (unsigned int i = 0; i < count; i++)
+ colors[i] = segment_colors[i]; /* Bound-checked read. */
+ }
+ return numColors;
}
- inline hb_ot_color_t
- get_color_record_argb (unsigned int color_index, unsigned int palette) const
+ private:
+ inline const CPALV1Tail& v1 (void) const
{
- if (unlikely (color_index >= numPaletteEntries || palette >= numPalettes))
- return 0;
+ if (version == 0) return Null(CPALV1Tail);
+ return StructAfter<CPALV1Tail> (*this);
+ }
- // No need for more range check as it is already done on #sanitize
- const UnsizedArrayOf<BGRAColor>& color_records = this+colorRecordsZ;
- return color_records[colorRecordIndicesZ[palette] + color_index];
+ public:
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ (this+colorRecordsZ).sanitize (c, numColorRecords) &&
+ colorRecordIndicesZ.sanitize (c, numPalettes) &&
+ (version == 0 || v1 ().sanitize (c, this, numPalettes, numColors)));
}
protected:
HBUINT16 version; /* Table version number */
/* Version 0 */
- HBUINT16 numPaletteEntries; /* Number of palette entries in each palette. */
+ HBUINT16 numColors; /* Number of colors in each palette. */
HBUINT16 numPalettes; /* Number of palettes in the table. */
HBUINT16 numColorRecords; /* Total number of color records, combined for
* all palettes. */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-sbix-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-sbix-table.hh
index 1b643c77a59..08dee2a0c67 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-sbix-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-sbix-table.hh
@@ -62,8 +62,6 @@ struct SBIXGlyph
struct SBIXStrike
{
- friend struct sbix;
-
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -71,10 +69,58 @@ struct SBIXStrike
imageOffsetsZ.sanitize_shallow (c, c->get_num_glyphs () + 1));
}
- protected:
+ inline hb_blob_t *get_glyph_blob (unsigned int glyph_id,
+ hb_blob_t *sbix_blob,
+ hb_tag_t file_type,
+ int *x_offset,
+ int *y_offset,
+ unsigned int num_glyphs,
+ unsigned int *strike_ppem) const
+ {
+ if (unlikely (!ppem)) return hb_blob_get_empty (); /* To get Null() object out of the way. */
+
+ unsigned int retry_count = 8;
+ unsigned int sbix_len = sbix_blob->length;
+ unsigned int strike_offset = (const char *) this - (const char *) sbix_blob->data;
+ assert (strike_offset < sbix_len);
+
+ retry:
+ if (unlikely (glyph_id >= num_glyphs ||
+ imageOffsetsZ[glyph_id + 1] <= imageOffsetsZ[glyph_id] ||
+ imageOffsetsZ[glyph_id + 1] - imageOffsetsZ[glyph_id] <= SBIXGlyph::min_size ||
+ (unsigned int) imageOffsetsZ[glyph_id + 1] > sbix_len - strike_offset))
+ return hb_blob_get_empty ();
+
+ unsigned int glyph_offset = strike_offset + (unsigned int) imageOffsetsZ[glyph_id] + SBIXGlyph::min_size;
+ unsigned int glyph_length = imageOffsetsZ[glyph_id + 1] - imageOffsetsZ[glyph_id] - SBIXGlyph::min_size;
+
+ const SBIXGlyph *glyph = &(this+imageOffsetsZ[glyph_id]);
+
+ if (glyph->graphicType == HB_TAG ('d','u','p','e'))
+ {
+ if (glyph_length >= 2)
+ {
+ glyph_id = *((HBUINT16 *) &glyph->data);
+ if (retry_count--)
+ goto retry;
+ }
+ return hb_blob_get_empty ();
+ }
+
+ if (unlikely (file_type != glyph->graphicType))
+ return hb_blob_get_empty ();
+
+ if (strike_ppem) *strike_ppem = ppem;
+ if (x_offset) *x_offset = glyph->xOffset;
+ if (y_offset) *y_offset = glyph->yOffset;
+ return hb_blob_create_sub_blob (sbix_blob, glyph_offset, glyph_length);
+ }
+
+ public:
HBUINT16 ppem; /* The PPEM size for which this strike was designed. */
HBUINT16 resolution; /* The device pixel density (in PPI) for which this
* strike was designed. (E.g., 96 PPI, 192 PPI.) */
+ protected:
UnsizedArrayOf<LOffsetTo<SBIXGlyph> >
imageOffsetsZ; /* Offset from the beginning of the strike data header
* to bitmap data for an individual glyph ID. */
@@ -86,62 +132,162 @@ struct sbix
{
static const hb_tag_t tableTag = HB_OT_TAG_sbix;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) && strikes.sanitize (c, this)));
- }
+ inline bool has_data (void) const { return version; }
+
+ inline const SBIXStrike &get_strike (unsigned int i) const { return this+strikes[i]; }
struct accelerator_t
{
inline void init (hb_face_t *face)
{
- sbix_blob = hb_sanitize_context_t().reference_table<sbix> (face);
- sbix_len = hb_blob_get_length (sbix_blob);
- sbix_table = sbix_blob->as<sbix> ();
+ table = hb_sanitize_context_t().reference_table<sbix> (face);
+ num_glyphs = face->get_num_glyphs ();
}
inline void fini (void)
{
- hb_blob_destroy (sbix_blob);
+ table.destroy ();
+ }
+
+ inline bool has_data () const
+ {
+ return table->has_data ();
+ }
+
+ inline bool get_extents (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents) const
+ {
+ /* We only support PNG right now, and following function checks type. */
+ return get_png_extents (font, glyph, extents);
}
- inline void dump (void (*callback) (const uint8_t* data, unsigned int length,
- unsigned int group, unsigned int gid)) const
+ inline hb_blob_t *reference_png (hb_font_t *font,
+ hb_codepoint_t glyph_id,
+ int *x_offset,
+ int *y_offset,
+ unsigned int *available_ppem) const
{
- for (unsigned group = 0; group < sbix_table->strikes.len; ++group)
+ return choose_strike (font).get_glyph_blob (glyph_id, table.get_blob (),
+ HB_TAG ('p','n','g',' '),
+ x_offset, y_offset,
+ num_glyphs, available_ppem);
+ }
+
+ private:
+
+ inline const SBIXStrike &choose_strike (hb_font_t *font) const
+ {
+ unsigned count = table->strikes.len;
+ if (unlikely (!count))
+ return Null(SBIXStrike);
+
+ unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
+ if (!requested_ppem)
+ requested_ppem = 1<<30; /* Choose largest strike. */
+ /* TODO Add DPI sensitivity as well? */
+ unsigned int best_i = 0;
+ unsigned int best_ppem = table->get_strike (0).ppem;
+
+ for (unsigned int i = 1; i < count; i++)
{
- const SBIXStrike &strike = sbix_table->strikes[group](sbix_table);
- for (unsigned int glyph = 0; glyph < num_glyphs; ++glyph)
- if (strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] > 0)
- {
- const SBIXGlyph &sbixGlyph = strike.imageOffsetsZ[glyph]((const void *) &strike);
- callback ((const uint8_t*) &sbixGlyph.data,
- strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] - 8,
- group, glyph);
- }
+ unsigned int ppem = (table->get_strike (i)).ppem;
+ if ((requested_ppem <= ppem && ppem < best_ppem) ||
+ (requested_ppem > best_ppem && ppem > best_ppem))
+ {
+ best_i = i;
+ best_ppem = ppem;
+ }
}
+
+ return table->get_strike (best_i);
+ }
+
+ struct PNGHeader
+ {
+ HBUINT8 signature[8];
+ struct
+ {
+ struct
+ {
+ HBUINT32 length;
+ Tag type;
+ } header;
+ HBUINT32 width;
+ HBUINT32 height;
+ HBUINT8 bitDepth;
+ HBUINT8 colorType;
+ HBUINT8 compressionMethod;
+ HBUINT8 filterMethod;
+ HBUINT8 interlaceMethod;
+ } IHDR;
+
+ public:
+ DEFINE_SIZE_STATIC (29);
+ };
+
+ inline bool get_png_extents (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents) const
+ {
+ /* Following code is safe to call even without data.
+ * But faster to short-circuit. */
+ if (!has_data ())
+ return false;
+
+ int x_offset = 0, y_offset = 0;
+ unsigned int strike_ppem = 0;
+ hb_blob_t *blob = reference_png (font, glyph, &x_offset, &y_offset, &strike_ppem);
+
+ const PNGHeader &png = *blob->as<PNGHeader>();
+
+ extents->x_bearing = x_offset;
+ extents->y_bearing = y_offset;
+ extents->width = png.IHDR.width;
+ extents->height = png.IHDR.height;
+
+ /* Convert to font units. */
+ if (strike_ppem)
+ {
+ double scale = font->face->get_upem () / (double) strike_ppem;
+ extents->x_bearing = round (extents->x_bearing * scale);
+ extents->y_bearing = round (extents->y_bearing * scale);
+ extents->width = round (extents->width * scale);
+ extents->height = round (extents->height * scale);
+ }
+
+ hb_blob_destroy (blob);
+
+ return strike_ppem;
}
private:
- hb_blob_t *sbix_blob;
- const sbix *sbix_table;
+ hb_blob_ptr_t<sbix> table;
- unsigned int sbix_len;
unsigned int num_glyphs;
};
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ version >= 1 &&
+ strikes.sanitize (c, this)));
+ }
+
protected:
HBUINT16 version; /* Table version number — set to 1 */
HBUINT16 flags; /* Bit 0: Set to 1. Bit 1: Draw outlines.
* Bits 2 to 15: reserved (set to 0). */
- LArrayOf<LOffsetTo<SBIXStrike> >
+ LOffsetLArrayOf<SBIXStrike>
strikes; /* Offsets from the beginning of the 'sbix'
* table to data for each individual bitmap strike. */
public:
DEFINE_SIZE_ARRAY (8, strikes);
};
+struct sbix_accelerator_t : sbix::accelerator_t {};
+
} /* namespace OT */
#endif /* HB_OT_COLOR_SBIX_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-svg-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-svg-table.hh
index 53d466846a4..ad3551035c8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-svg-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color-svg-table.hh
@@ -40,13 +40,21 @@ namespace OT {
struct SVGDocumentIndexEntry
{
- friend struct SVG;
+ inline int cmp (hb_codepoint_t g) const
+ { return g < startGlyphID ? -1 : g > endGlyphID ? 1 : 0; }
- inline bool sanitize (hb_sanitize_context_t *c, const void* base) const
+ inline hb_blob_t *reference_blob (hb_blob_t *svg_blob, unsigned int index_offset) const
+ {
+ return hb_blob_create_sub_blob (svg_blob,
+ index_offset + (unsigned int) svgDoc,
+ svgDocLength);
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- (base+svgDoc).sanitize (c, svgDocLength));
+ svgDoc.sanitize (c, base, svgDocLength));
}
protected:
@@ -57,86 +65,67 @@ struct SVGDocumentIndexEntry
LOffsetTo<UnsizedArrayOf<HBUINT8>, false>
svgDoc; /* Offset from the beginning of the SVG Document Index
* to an SVG document. Must be non-zero. */
- HBUINT32 svgDocLength; /* Length of the SVG document.
+ HBUINT32 svgDocLength; /* Length of the SVG document.
* Must be non-zero. */
public:
DEFINE_SIZE_STATIC (12);
};
-struct SVGDocumentIndex
-{
- friend struct SVG;
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- entries.sanitize (c, this));
- }
-
- protected:
- ArrayOf<SVGDocumentIndexEntry>
- entries; /* Array of SVG Document Index Entries. */
- public:
- DEFINE_SIZE_ARRAY (2, entries);
-};
-
struct SVG
{
static const hb_tag_t tableTag = HB_OT_TAG_SVG;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- (this+svgDocIndex).sanitize (c)));
- }
+ inline bool has_data (void) const { return svgDocEntries; }
struct accelerator_t
{
inline void init (hb_face_t *face)
{
- svg_blob = hb_sanitize_context_t().reference_table<SVG> (face);
- svg_len = hb_blob_get_length (svg_blob);
- svg = svg_blob->as<SVG> ();
+ table = hb_sanitize_context_t().reference_table<SVG> (face);
}
inline void fini (void)
{
- hb_blob_destroy (svg_blob);
+ table.destroy ();
}
- inline void
- dump (void (*callback) (const uint8_t* data, unsigned int length,
- unsigned int start_glyph, unsigned int end_glyph)) const
+ inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const
{
- const SVGDocumentIndex &index = svg+svg->svgDocIndex;
- const ArrayOf<SVGDocumentIndexEntry> &entries = index.entries;
- for (unsigned int i = 0; i < entries.len; ++i)
- {
- const SVGDocumentIndexEntry &entry = entries[i];
- callback ((const uint8_t*) &entry.svgDoc (&index), entry.svgDocLength,
- entry.startGlyphID, entry.endGlyphID);
- }
+ return table->get_glyph_entry (glyph_id).reference_blob (table.get_blob (),
+ table->svgDocEntries);
}
- private:
- hb_blob_t *svg_blob;
- const SVG *svg;
+ inline bool has_data () const { return table->has_data (); }
- unsigned int svg_len;
+ private:
+ hb_blob_ptr_t<SVG> table;
};
+ inline const SVGDocumentIndexEntry &get_glyph_entry (hb_codepoint_t glyph_id) const
+ {
+ return (this+svgDocEntries).bsearch (glyph_id);
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ (this+svgDocEntries).sanitize_shallow (c)));
+ }
+
protected:
HBUINT16 version; /* Table version (starting at 0). */
- LOffsetTo<SVGDocumentIndex>
- svgDocIndex; /* Offset (relative to the start of the SVG table) to the
+ LOffsetTo<SortedArrayOf<SVGDocumentIndexEntry> >
+ svgDocEntries; /* Offset (relative to the start of the SVG table) to the
* SVG Documents Index. Must be non-zero. */
+ /* Array of SVG Document Index Entries. */
HBUINT32 reserved; /* Set to 0. */
public:
DEFINE_SIZE_STATIC (10);
};
+struct SVG_accelerator_t : SVG::accelerator_t {};
+
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.cc
index 7cdff380ef2..791135b100c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.cc
@@ -22,160 +22,278 @@
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
- * Google Author(s): Sascha Brawer
+ * Google Author(s): Sascha Brawer, Behdad Esfahbod
*/
#include "hb-open-type.hh"
+#include "hb-ot-color-cbdt-table.hh"
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
+#include "hb-ot-color-sbix-table.hh"
+#include "hb-ot-color-svg-table.hh"
+#include "hb-ot-face.hh"
#include "hb-ot.h"
#include <stdlib.h>
#include <string.h>
#include "hb-ot-layout.hh"
-#include "hb-shaper.hh"
-#if 0
-HB_MARK_AS_FLAG_T (hb_ot_color_palette_flags_t)
-//HB_SHAPER_DATA_ENSURE_DECLARE(ot, face) Hmm?
+/**
+ * SECTION:hb-ot-color
+ * @title: hb-ot-color
+ * @short_description: OpenType Color Fonts
+ * @include: hb-ot.h
+ *
+ * Functions for fetching color-font information from OpenType font faces.
+ **/
+
+
+/*
+ * CPAL
+ */
-static inline const OT::COLR&
-_get_colr (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR);
- return *(hb_ot_face_data (face)->colr.get ());
-}
-static inline const OT::CPAL&
-_get_cpal (hb_face_t *face)
+/**
+ * hb_ot_color_has_palettes:
+ * @face: a font face.
+ *
+ * Returns: whether CPAL table is available.
+ *
+ * Since: 2.1.0
+ */
+hb_bool_t
+hb_ot_color_has_palettes (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL);
- return *(hb_ot_face_data (face)->cpal.get ());
+ return face->table.CPAL->has_data ();
}
-
/**
- * hb_ot_color_get_palette_count:
+ * hb_ot_color_palette_get_count:
* @face: a font face.
*
* Returns: the number of color palettes in @face, or zero if @face has
* no colors.
*
- * Since: REPLACEME
+ * Since: 2.1.0
*/
unsigned int
-hb_ot_color_get_palette_count (hb_face_t *face)
+hb_ot_color_palette_get_count (hb_face_t *face)
{
- const OT::CPAL& cpal = _get_cpal (face);
- return cpal.get_palette_count ();
+ return face->table.CPAL->get_palette_count ();
}
-
/**
- * hb_ot_color_get_palette_name_id:
- * @face: a font face.
- * @palette: the index of the color palette whose name is being requested.
+ * hb_ot_color_palette_get_name_id:
+ * @face: a font face.
+ * @palette_index: the index of the color palette whose name is being requested.
*
* Retrieves the name id of a color palette. For example, a color font can
* have themed palettes like "Spring", "Summer", "Fall", and "Winter".
*
* Returns: an identifier within @face's `name` table.
- * If the requested palette has no name, or if @face has no colors,
- * or if @palette is not between 0 and hb_ot_color_get_palette_count(),
- * the result is 0xFFFF. The implementation does not check whether
- * the returned palette name id is actually in @face's `name` table.
+ * If the requested palette has no name the result is #HB_OT_NAME_ID_INVALID.
*
- * Since: REPLACEME
+ * Since: 2.1.0
*/
-unsigned int
-hb_ot_color_get_palette_name_id (hb_face_t *face, unsigned int palette)
+hb_ot_name_id_t
+hb_ot_color_palette_get_name_id (hb_face_t *face,
+ unsigned int palette_index)
{
- const OT::CPAL& cpal = _get_cpal (face);
- return cpal.get_palette_name_id (palette);
+ return face->table.CPAL->get_palette_name_id (palette_index);
}
+/**
+ * hb_ot_color_palette_color_get_name_id:
+ * @face: a font face.
+ * @color_index: palette entry index.
+ *
+ * Returns: Name ID associated with a palette entry, e.g. eye color
+ *
+ * Since: 2.1.0
+ */
+hb_ot_name_id_t
+hb_ot_color_palette_color_get_name_id (hb_face_t *face,
+ unsigned int color_index)
+{
+ return face->table.CPAL->get_color_name_id (color_index);
+}
/**
- * hb_ot_color_get_palette_flags:
- * @face: a font face
- * @palette: the index of the color palette whose flags are being requested
+ * hb_ot_color_palette_get_flags:
+ * @face: a font face
+ * @palette_index: the index of the color palette whose flags are being requested
*
- * Returns: the flags for the requested color palette. If @face has no colors,
- * or if @palette is not between 0 and hb_ot_color_get_palette_count(),
- * the result is #HB_OT_COLOR_PALETTE_FLAG_DEFAULT.
+ * Returns: the flags for the requested color palette.
*
- * Since: REPLACEME
+ * Since: 2.1.0
*/
hb_ot_color_palette_flags_t
-hb_ot_color_get_palette_flags (hb_face_t *face, unsigned int palette)
+hb_ot_color_palette_get_flags (hb_face_t *face,
+ unsigned int palette_index)
{
- const OT::CPAL& cpal = _get_cpal(face);
- return cpal.get_palette_flags (palette);
+ return face->table.CPAL->get_palette_flags (palette_index);
}
-
/**
- * hb_ot_color_get_palette_colors:
+ * hb_ot_color_palette_get_colors:
* @face: a font face.
- * @palette: the index of the color palette whose colors
+ * @palette_index:the index of the color palette whose colors
* are being requested.
* @start_offset: the index of the first color being requested.
* @color_count: (inout) (optional): on input, how many colors
* can be maximally stored into the @colors array;
* on output, how many colors were actually stored.
- * @colors: (array length=color_count) (optional):
- * an array of #hb_ot_color_t records. After calling
+ * @colors: (array length=color_count) (out) (optional):
+ * an array of #hb_color_t records. After calling
* this function, @colors will be filled with
* the palette colors. If @colors is NULL, the function
* will just return the number of total colors
* without storing any actual colors; this can be used
* for allocating a buffer of suitable size before calling
- * hb_ot_color_get_palette_colors() a second time.
+ * hb_ot_color_palette_get_colors() a second time.
*
* Retrieves the colors in a color palette.
*
- * Returns: the total number of colors in the palette. All palettes in
- * a font have the same number of colors. If @face has no colors, or if
- * @palette is not between 0 and hb_ot_color_get_palette_count(),
- * the result is zero.
+ * Returns: the total number of colors in the palette.
+ *
+ * Since: 2.1.0
+ */
+unsigned int
+hb_ot_color_palette_get_colors (hb_face_t *face,
+ unsigned int palette_index,
+ unsigned int start_offset,
+ unsigned int *colors_count /* IN/OUT. May be NULL. */,
+ hb_color_t *colors /* OUT. May be NULL. */)
+{
+ return face->table.CPAL->get_palette_colors (palette_index, start_offset, colors_count, colors);
+}
+
+
+/*
+ * COLR
+ */
+
+/**
+ * hb_ot_color_has_layers:
+ * @face: a font face.
+ *
+ * Returns: whether COLR table is available.
+ *
+ * Since: 2.1.0
+ */
+hb_bool_t
+hb_ot_color_has_layers (hb_face_t *face)
+{
+ return face->table.COLR->has_data ();
+}
+
+/**
+ * hb_ot_color_glyph_get_layers:
+ * @face: a font face.
+ * @glyph: a layered color glyph id.
+ * @start_offset: starting offset of layers.
+ * @count: (inout) (optional): gets number of layers available to be written on buffer
+ * and returns number of written layers.
+ * @layers: (array length=count) (out) (optional): layers buffer to buffer.
+ *
+ * Returns: Total number of layers a layered color glyph have.
*
- * Since: REPLACEME
+ * Since: 2.1.0
*/
unsigned int
-hb_ot_color_get_palette_colors (hb_face_t *face,
- unsigned int palette, /* default=0 */
- unsigned int start_offset,
- unsigned int *color_count /* IN/OUT */,
- hb_ot_color_t *colors /* OUT */)
+hb_ot_color_glyph_get_layers (hb_face_t *face,
+ hb_codepoint_t glyph,
+ unsigned int start_offset,
+ unsigned int *count, /* IN/OUT. May be NULL. */
+ hb_ot_color_layer_t *layers /* OUT. May be NULL. */)
{
- const OT::CPAL& cpal = _get_cpal(face);
- if (unlikely (palette >= cpal.numPalettes))
- {
- if (color_count) *color_count = 0;
- return 0;
- }
-
- const OT::ColorRecord* crec = &cpal.offsetFirstColorRecord (&cpal);
- crec += cpal.colorRecordIndices[palette];
-
- unsigned int num_results = 0;
- if (likely (color_count && colors))
- {
- for (unsigned int i = start_offset;
- i < cpal.numPaletteEntries && num_results < *color_count; ++i)
- {
- hb_ot_color_t* result = &colors[num_results];
- result->red = crec[i].red;
- result->green = crec[i].green;
- result->blue = crec[i].blue;
- result->alpha = crec[i].alpha;
- ++num_results;
- }
- }
-
- if (likely (color_count)) *color_count = num_results;
- return cpal.numPaletteEntries;
+ return face->table.COLR->get_glyph_layers (glyph, start_offset, count, layers);
+}
+
+
+/*
+ * SVG
+ */
+
+/**
+ * hb_ot_color_has_svg:
+ * @face: a font face.
+ *
+ * Check whether @face has SVG glyph images.
+ *
+ * Returns true if available, false otherwise.
+ *
+ * Since: 2.1.0
+ */
+hb_bool_t
+hb_ot_color_has_svg (hb_face_t *face)
+{
+ return face->table.SVG->has_data ();
+}
+
+/**
+ * hb_ot_color_glyph_reference_svg:
+ * @face: a font face.
+ * @glyph: a svg glyph index.
+ *
+ * Get SVG document for a glyph. The blob may be either plain text or gzip-encoded.
+ *
+ * Returns: (transfer full): respective svg blob of the glyph, if available.
+ *
+ * Since: 2.1.0
+ */
+hb_blob_t *
+hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph)
+{
+ return face->table.SVG->reference_blob_for_glyph (glyph);
+}
+
+
+/*
+ * PNG: CBDT or sbix
+ */
+
+/**
+ * hb_ot_color_has_png:
+ * @face: a font face.
+ *
+ * Check whether @face has PNG glyph images (either CBDT or sbix tables).
+ *
+ * Returns true if available, false otherwise.
+ *
+ * Since: 2.1.0
+ */
+hb_bool_t
+hb_ot_color_has_png (hb_face_t *face)
+{
+ return face->table.CBDT->has_data () || face->table.sbix->has_data ();
+}
+
+/**
+ * hb_ot_color_glyph_reference_png:
+ * @font: a font object, not face. upem should be set on
+ * that font object if one wants to get optimal png blob, otherwise
+ * return the biggest one
+ * @glyph: a glyph index.
+ *
+ * Get PNG image for a glyph.
+ *
+ * Returns: (transfer full): respective PNG blob of the glyph, if available.
+ *
+ * Since: 2.1.0
+ */
+hb_blob_t *
+hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph)
+{
+ hb_blob_t *blob = hb_blob_get_empty ();
+
+ if (font->face->table.sbix->has_data ())
+ blob = font->face->table.sbix->reference_png (font, glyph, nullptr, nullptr, nullptr);
+
+ if (!blob->length && font->face->table.CBDT->has_data ())
+ blob = font->face->table.CBDT->reference_png (font, glyph);
+
+ return blob;
}
-#endif
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.h b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.h
new file mode 100644
index 00000000000..a4f2053291e
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-color.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2016 Google, Inc.
+ * Copyright © 2018 Khaled Hosny
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * 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): Sascha Brawer, Behdad Esfahbod
+ */
+
+#ifndef HB_OT_H_IN
+#error "Include <hb-ot.h> instead."
+#endif
+
+#ifndef HB_OT_COLOR_H
+#define HB_OT_COLOR_H
+
+#include "hb.h"
+#include "hb-ot-name.h"
+
+HB_BEGIN_DECLS
+
+
+/*
+ * Color palettes.
+ */
+
+HB_EXTERN hb_bool_t
+hb_ot_color_has_palettes (hb_face_t *face);
+
+HB_EXTERN unsigned int
+hb_ot_color_palette_get_count (hb_face_t *face);
+
+HB_EXTERN hb_ot_name_id_t
+hb_ot_color_palette_get_name_id (hb_face_t *face,
+ unsigned int palette_index);
+
+HB_EXTERN hb_ot_name_id_t
+hb_ot_color_palette_color_get_name_id (hb_face_t *face,
+ unsigned int color_index);
+
+/**
+ * hb_ot_color_palette_flags_t:
+ * @HB_OT_COLOR_PALETTE_FLAG_DEFAULT: default indicating that there is nothing special
+ * to note about a color palette.
+ * @HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND: flag indicating that the color
+ * palette is appropriate to use when displaying the font on a light background such as white.
+ * @HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND: flag indicating that the color
+ * palette is appropriate to use when displaying the font on a dark background such as black.
+ *
+ * Since: 2.1.0
+ */
+typedef enum { /*< flags >*/
+ HB_OT_COLOR_PALETTE_FLAG_DEFAULT = 0x00000000u,
+ HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND = 0x00000001u,
+ HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND = 0x00000002u,
+} hb_ot_color_palette_flags_t;
+
+HB_EXTERN hb_ot_color_palette_flags_t
+hb_ot_color_palette_get_flags (hb_face_t *face,
+ unsigned int palette_index);
+
+HB_EXTERN unsigned int
+hb_ot_color_palette_get_colors (hb_face_t *face,
+ unsigned int palette_index,
+ unsigned int start_offset,
+ unsigned int *color_count, /* IN/OUT. May be NULL. */
+ hb_color_t *colors /* OUT. May be NULL. */);
+
+
+/*
+ * Color layers.
+ */
+
+HB_EXTERN hb_bool_t
+hb_ot_color_has_layers (hb_face_t *face);
+
+/**
+ * hb_ot_color_layer_t:
+ *
+ * Pairs of glyph and color index.
+ *
+ * Since: 2.1.0
+ **/
+typedef struct hb_ot_color_layer_t
+{
+ hb_codepoint_t glyph;
+ unsigned int color_index;
+} hb_ot_color_layer_t;
+
+HB_EXTERN unsigned int
+hb_ot_color_glyph_get_layers (hb_face_t *face,
+ hb_codepoint_t glyph,
+ unsigned int start_offset,
+ unsigned int *count, /* IN/OUT. May be NULL. */
+ hb_ot_color_layer_t *layers /* OUT. May be NULL. */);
+
+/*
+ * SVG
+ */
+
+HB_EXTERN hb_bool_t
+hb_ot_color_has_svg (hb_face_t *face);
+
+HB_EXTERN hb_blob_t *
+hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph);
+
+/*
+ * PNG: CBDT or sbix
+ */
+
+HB_EXTERN hb_bool_t
+hb_ot_color_has_png (hb_face_t *face);
+
+HB_EXTERN hb_blob_t *
+hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph);
+
+
+HB_END_DECLS
+
+#endif /* HB_OT_COLOR_H */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.cc
index 1bc68d36690..c7dafdd4ab9 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.cc
@@ -30,14 +30,17 @@
#include "hb-ot-glyf-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
+#include "hb-ot-name-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-color-cbdt-table.hh"
+#include "hb-ot-color-sbix-table.hh"
+#include "hb-ot-color-svg-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)
+void hb_ot_face_t::init0 (hb_face_t *face)
{
this->face = face;
#define HB_OT_TABLE(Namespace, Type) Type.init0 ();
@@ -46,7 +49,7 @@ void hb_ot_face_data_t::init0 (hb_face_t *face)
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
}
-void hb_ot_face_data_t::fini (void)
+void hb_ot_face_t::fini (void)
{
#define HB_OT_TABLE(Namespace, Type) Type.fini ();
#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type)
@@ -54,23 +57,3 @@ void hb_ot_face_data_t::fini (void)
#undef HB_OT_ACCELERATOR
#undef HB_OT_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/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.hh
index e3059221855..4a3260626c2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-face.hh
@@ -34,41 +34,50 @@
#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
+ * hb_ot_face_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_TABLES \
+ /* OpenType fundamentals. */ \
+ HB_OT_TABLE(OT, head) \
+ HB_OT_ACCELERATOR(OT, cmap) \
+ HB_OT_ACCELERATOR(OT, hmtx) \
+ HB_OT_ACCELERATOR(OT, vmtx) \
+ HB_OT_ACCELERATOR(OT, post) \
+ HB_OT_TABLE(OT, kern) \
+ HB_OT_ACCELERATOR(OT, glyf) \
+ HB_OT_TABLE(OT, VORG) \
+ HB_OT_ACCELERATOR(OT, name) \
+ HB_OT_TABLE(OT, OS2) \
+ HB_OT_TABLE(OT, STAT) \
/* OpenType shaping. */ \
- HB_OT_TABLE(OT, JSTF) \
+ HB_OT_ACCELERATOR(OT, GDEF) \
+ HB_OT_ACCELERATOR(OT, GSUB) \
+ HB_OT_ACCELERATOR(OT, GPOS) \
HB_OT_TABLE(OT, BASE) \
+ HB_OT_TABLE(OT, JSTF) \
/* AAT shaping. */ \
+ HB_OT_TABLE(AAT, mort) \
HB_OT_TABLE(AAT, morx) \
HB_OT_TABLE(AAT, kerx) \
HB_OT_TABLE(AAT, ankr) \
HB_OT_TABLE(AAT, trak) \
+ HB_OT_TABLE(AAT, lcar) \
+ HB_OT_TABLE(AAT, ltag) \
+ HB_OT_TABLE(AAT, feat) \
/* OpenType variations. */ \
HB_OT_TABLE(OT, fvar) \
HB_OT_TABLE(OT, avar) \
HB_OT_TABLE(OT, MVAR) \
/* OpenType math. */ \
HB_OT_TABLE(OT, MATH) \
- /* OpenType fundamentals. */ \
- HB_OT_ACCELERATOR(OT, GDEF) \
- HB_OT_ACCELERATOR(OT, GSUB) \
- HB_OT_ACCELERATOR(OT, GPOS) \
- HB_OT_ACCELERATOR(OT, cmap) \
- HB_OT_ACCELERATOR(OT, hmtx) \
- HB_OT_ACCELERATOR(OT, vmtx) \
- HB_OT_ACCELERATOR(OT, post) \
- HB_OT_ACCELERATOR(OT, kern) \
- HB_OT_ACCELERATOR(OT, glyf) \
+ /* OpenType color fonts. */ \
+ HB_OT_TABLE(OT, COLR) \
+ HB_OT_TABLE(OT, CPAL) \
HB_OT_ACCELERATOR(OT, CBDT) \
+ HB_OT_ACCELERATOR(OT, sbix) \
+ HB_OT_ACCELERATOR(OT, SVG) \
/* */
/* Declare tables. */
@@ -78,7 +87,7 @@ HB_OT_TABLES
#undef HB_OT_ACCELERATOR
#undef HB_OT_TABLE
-struct hb_ot_face_data_t
+struct hb_ot_face_t
{
HB_INTERNAL void init0 (hb_face_t *face);
HB_INTERNAL void fini (void);
@@ -106,11 +115,4 @@ struct hb_ot_face_data_t
};
-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/chromium/third_party/harfbuzz-ng/src/src/hb-ot-font.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-font.cc
index 280ade5b69b..7c91362509c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-font.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-font.cc
@@ -33,11 +33,27 @@
#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-os2-table.hh"
#include "hb-ot-post-table.hh"
-#include "hb-ot-glyf-table.hh"
+#include "hb-ot-stat-table.hh" // Just so we compile it; unused otherwise.
+#include "hb-ot-vorg-table.hh"
#include "hb-ot-color-cbdt-table.hh"
+#include "hb-ot-color-sbix-table.hh"
+
+
+/**
+ * SECTION:hb-ot-font
+ * @title: hb-ot-font
+ * @short_description: OpenType font implementation
+ * @include: hb-ot.h
+ *
+ * Functions for using OpenType fonts with hb_shape(). Not that fonts returned
+ * by hb_font_create() default to using these functions, so most clients would
+ * never need to call these functions directly.
+ **/
static hb_bool_t
@@ -47,8 +63,24 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- return ot_face->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph);
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ return ot_face->cmap->get_nominal_glyph (unicode, glyph);
+}
+
+static unsigned int
+hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
+ void *font_data,
+ unsigned int count,
+ const hb_codepoint_t *first_unicode,
+ unsigned int unicode_stride,
+ hb_codepoint_t *first_glyph,
+ unsigned int glyph_stride,
+ void *user_data HB_UNUSED)
+{
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ return ot_face->cmap->get_nominal_glyphs (count,
+ first_unicode, unicode_stride,
+ first_glyph, glyph_stride);
}
static hb_bool_t
@@ -59,21 +91,21 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- return ot_face->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph);
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph);
}
static void
hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
unsigned count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get_relaxed ();
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
for (unsigned int i = 0; i < count; i++)
{
@@ -86,14 +118,14 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
static void
hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
unsigned count,
- hb_codepoint_t *first_glyph,
+ const hb_codepoint_t *first_glyph,
unsigned glyph_stride,
hb_position_t *first_advance,
unsigned advance_stride,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get_relaxed ();
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
for (unsigned int i = 0; i < count; i++)
{
@@ -103,15 +135,39 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
}
}
-static hb_position_t
-hb_ot_get_glyph_h_kerning (hb_font_t *font,
- void *font_data,
- hb_codepoint_t left_glyph,
- hb_codepoint_t right_glyph,
- void *user_data HB_UNUSED)
+static hb_bool_t
+hb_ot_get_glyph_v_origin (hb_font_t *font,
+ void *font_data,
+ hb_codepoint_t glyph,
+ hb_position_t *x,
+ hb_position_t *y,
+ void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- return font->em_scale_x (ot_face->kern->get_h_kerning (left_glyph, right_glyph));
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+
+ *x = font->get_glyph_h_advance (glyph) / 2;
+
+ const OT::VORG &VORG = *ot_face->VORG;
+ if (VORG.has_data ())
+ {
+ *y = font->em_scale_y (VORG.get_y_origin (glyph));
+ return true;
+ }
+
+ hb_glyph_extents_t extents = {0};
+ if (ot_face->glyf->get_extents (glyph, &extents))
+ {
+ const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
+ hb_position_t tsb = vmtx.get_side_bearing (glyph);
+ *y = font->em_scale_y (extents.y_bearing + tsb);
+ return true;
+ }
+
+ hb_font_extents_t font_extents;
+ font->get_h_extents_with_fallback (&font_extents);
+ *y = font_extents.ascender;
+
+ return true;
}
static hb_bool_t
@@ -121,10 +177,12 @@ hb_ot_get_glyph_extents (hb_font_t *font,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- bool ret = ot_face->glyf->get_extents (glyph, extents);
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ bool ret = ot_face->sbix->get_extents (font, glyph, extents);
if (!ret)
- ret = ot_face->CBDT->get_extents (glyph, extents);
+ ret = ot_face->glyf->get_extents (glyph, extents);
+ if (!ret)
+ ret = ot_face->CBDT->get_extents (font, 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);
@@ -140,7 +198,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_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_name (glyph, name, size);
}
@@ -151,7 +209,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_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_from_name (name, len, glyph);
}
@@ -161,12 +219,13 @@ hb_ot_get_font_h_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- metrics->ascender = font->em_scale_y (ot_face->hmtx.get_relaxed ()->ascender);
- metrics->descender = font->em_scale_y (ot_face->hmtx.get_relaxed ()->descender);
- metrics->line_gap = font->em_scale_y (ot_face->hmtx.get_relaxed ()->line_gap);
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
+ metrics->ascender = font->em_scale_y (hmtx.ascender);
+ metrics->descender = font->em_scale_y (hmtx.descender);
+ metrics->line_gap = font->em_scale_y (hmtx.line_gap);
// TODO Hook up variations.
- return ot_face->hmtx.get_relaxed ()->has_font_extents;
+ return hmtx.has_font_extents;
}
static hb_bool_t
@@ -175,19 +234,20 @@ hb_ot_get_font_v_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
- metrics->ascender = font->em_scale_x (ot_face->vmtx.get_relaxed ()->ascender);
- metrics->descender = font->em_scale_x (ot_face->vmtx.get_relaxed ()->descender);
- metrics->line_gap = font->em_scale_x (ot_face->vmtx.get_relaxed ()->line_gap);
+ const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
+ const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
+ metrics->ascender = font->em_scale_x (vmtx.ascender);
+ metrics->descender = font->em_scale_x (vmtx.descender);
+ metrics->line_gap = font->em_scale_x (vmtx.line_gap);
// TODO Hook up variations.
- return ot_face->vmtx.get_relaxed ()->has_font_extents;
+ return vmtx.has_font_extents;
}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_ot_funcs (void);
#endif
-static struct hb_ot_face_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot_face_funcs_lazy_loader_t>
+static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot_font_funcs_lazy_loader_t>
{
static inline hb_font_funcs_t *create (void)
{
@@ -196,13 +256,12 @@ static struct hb_ot_face_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot
hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, nullptr, nullptr);
hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, nullptr, nullptr);
hb_font_funcs_set_nominal_glyph_func (funcs, hb_ot_get_nominal_glyph, nullptr, nullptr);
+ hb_font_funcs_set_nominal_glyphs_func (funcs, hb_ot_get_nominal_glyphs, nullptr, nullptr);
hb_font_funcs_set_variation_glyph_func (funcs, hb_ot_get_variation_glyph, nullptr, nullptr);
hb_font_funcs_set_glyph_h_advances_func (funcs, hb_ot_get_glyph_h_advances, nullptr, nullptr);
hb_font_funcs_set_glyph_v_advances_func (funcs, hb_ot_get_glyph_v_advances, nullptr, nullptr);
//hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, nullptr, nullptr);
- //hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr);
- hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, nullptr, nullptr);
- //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, nullptr, nullptr);
+ hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr);
hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr);
//hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr);
hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr);
@@ -210,7 +269,7 @@ static struct hb_ot_face_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot
hb_font_funcs_make_immutable (funcs);
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_ot_funcs);
#endif
@@ -218,7 +277,7 @@ static struct hb_ot_face_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot
}
} static_ot_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_ot_funcs (void)
{
@@ -241,16 +300,8 @@ _hb_ot_get_font_funcs (void)
void
hb_ot_font_set_funcs (hb_font_t *font)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
- hb_ot_face_data_t *ot_face = hb_ot_face_data (font->face);
-
- /* Load them lazies. We access them with get_relaxed() for performance. */
- ot_face->cmap.get ();
- ot_face->hmtx.get ();
- ot_face->vmtx.get ();
-
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
- ot_face,
+ &font->face->table,
nullptr);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-glyf-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-glyf-table.hh
index 2145ac02b2e..c88f43385b4 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-glyf-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-glyf-table.hh
@@ -47,7 +47,7 @@ struct loca
static const hb_tag_t tableTag = HB_OT_TAG_loca;
- inline bool sanitize (hb_sanitize_context_t *c) const
+ inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const
{
TRACE_SANITIZE (this);
return_trace (true);
@@ -55,7 +55,10 @@ struct loca
protected:
UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */
- DEFINE_SIZE_ARRAY (0, dataZ);
+ public:
+ DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
+ * check the size externally, allow Null() object of it by
+ * defining it MIN() instead. */
};
@@ -70,7 +73,7 @@ struct glyf
{
static const hb_tag_t tableTag = HB_OT_TAG_glyf;
- inline bool sanitize (hb_sanitize_context_t *c) const
+ inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const
{
TRACE_SANITIZE (this);
/* We don't check for anything specific here. The users of the
@@ -101,7 +104,7 @@ struct glyf
static bool
_add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca)
{
- hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (plan->source);
+ hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<head> (plan->source);
hb_blob_t *head_prime_blob = hb_blob_copy_writable_or_fail (head_blob);
hb_blob_destroy (head_blob);
@@ -119,9 +122,9 @@ struct glyf
struct GlyphHeader
{
HBINT16 numberOfContours; /* If the number of contours is
- * greater than or equal to zero,
- * this is a simple glyph; if negative,
- * this is a composite glyph. */
+ * greater than or equal to zero,
+ * this is a simple glyph; if negative,
+ * this is a composite glyph. */
FWORD xMin; /* Minimum x for coordinate data. */
FWORD yMin; /* Minimum y for coordinate data. */
FWORD xMax; /* Maximum x for coordinate data. */
@@ -148,28 +151,23 @@ struct glyf
};
HBUINT16 flags;
- HBUINT16 glyphIndex;
+ GlyphID glyphIndex;
inline unsigned int get_size (void) const
{
unsigned int size = min_size;
- if (flags & ARG_1_AND_2_ARE_WORDS) {
- // arg1 and 2 are int16
- size += 4;
- } else {
- // arg1 and 2 are int8
- size += 2;
- }
- if (flags & WE_HAVE_A_SCALE) {
- // One x 16 bit (scale)
- size += 2;
- } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
- // Two x 16 bit (xscale, yscale)
- size += 4;
- } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
- // Four x 16 bit (xscale, scale01, scale10, yscale)
- size += 8;
- }
+ // arg1 and 2 are int16
+ if (flags & ARG_1_AND_2_ARE_WORDS) size += 4;
+ // arg1 and 2 are int8
+ else size += 2;
+
+ // One x 16 bit (scale)
+ if (flags & WE_HAVE_A_SCALE) size += 2;
+ // Two x 16 bit (xscale, yscale)
+ else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) size += 4;
+ // Four x 16 bit (xscale, scale01, scale10, yscale)
+ else if (flags & WE_HAVE_A_TWO_BY_TWO) size += 8;
+
return size;
}
@@ -197,7 +195,7 @@ struct glyf
{
return (const char *) composite >= glyph_start
&& ((const char *) composite + CompositeGlyphHeader::min_size) <= glyph_end
- && ((const char *) composite + composite->get_size()) <= glyph_end;
+ && ((const char *) composite + composite->get_size ()) <= glyph_end;
}
};
@@ -211,15 +209,15 @@ struct glyf
const GlyphHeader &glyph_header = StructAtOffset<GlyphHeader> (glyph_data, 0);
if (glyph_header.numberOfContours < 0)
{
- const CompositeGlyphHeader *possible =
+ const CompositeGlyphHeader *possible =
&StructAfter<CompositeGlyphHeader, GlyphHeader> (glyph_header);
iterator->glyph_start = glyph_data;
iterator->glyph_end = (const char *) glyph_data + length;
if (!iterator->in_range (possible))
- return false;
- iterator->current = possible;
- return true;
+ return false;
+ iterator->current = possible;
+ return true;
}
return false;
@@ -234,30 +232,22 @@ struct glyf
{
memset (this, 0, sizeof (accelerator_t));
- hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (face);
- const head *head_table = head_blob->as<head> ();
- if (head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0)
- {
+ const OT::head &head = *face->table.head;
+ if (head.indexToLocFormat > 1 || head.glyphDataFormat != 0)
/* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */
- hb_blob_destroy (head_blob);
return;
- }
- short_offset = 0 == head_table->indexToLocFormat;
- hb_blob_destroy (head_blob);
+ short_offset = 0 == head.indexToLocFormat;
- loca_blob = hb_sanitize_context_t().reference_table<loca> (face);
- loca_table = loca_blob->as<loca> ();
- glyf_blob = hb_sanitize_context_t().reference_table<glyf> (face);
- glyf_table = glyf_blob->as<glyf> ();
+ loca_table = hb_sanitize_context_t ().reference_table<loca> (face);
+ glyf_table = hb_sanitize_context_t ().reference_table<glyf> (face);
- num_glyphs = MAX (1u, hb_blob_get_length (loca_blob) / (short_offset ? 2 : 4)) - 1;
- glyf_len = hb_blob_get_length (glyf_blob);
+ num_glyphs = MAX (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1;
}
inline void fini (void)
{
- hb_blob_destroy (loca_blob);
- hb_blob_destroy (glyf_blob);
+ loca_table.destroy ();
+ glyf_table.destroy ();
}
/*
@@ -273,9 +263,9 @@ struct glyf
unsigned int start_offset, end_offset;
if (!get_offsets (glyph, &start_offset, &end_offset))
- return false; /* glyph not found */
+ return false; /* glyph not found */
- return CompositeGlyphHeader::get_iterator ((const char*) this->glyf_table + start_offset,
+ return CompositeGlyphHeader::get_iterator ((const char *) this->glyf_table + start_offset,
end_offset - start_offset,
composite);
}
@@ -289,11 +279,10 @@ struct glyf
};
/* based on FontTools _g_l_y_f.py::trim */
- inline bool remove_padding(unsigned int start_offset,
- unsigned int *end_offset) const
+ inline bool remove_padding (unsigned int start_offset,
+ unsigned int *end_offset) const
{
- if (*end_offset - start_offset < GlyphHeader::static_size)
- return true;
+ if (*end_offset - start_offset < GlyphHeader::static_size) return true;
const char *glyph = ((const char *) glyf_table) + start_offset;
const char * const glyph_end = glyph + (*end_offset - start_offset);
@@ -301,143 +290,139 @@ struct glyf
int16_t num_contours = (int16_t) glyph_header.numberOfContours;
if (num_contours < 0)
- /* Trimming for composites not implemented.
- * If removing hints it falls out of that. */
- return true;
+ /* Trimming for composites not implemented.
+ * If removing hints it falls out of that. */
+ return true;
else if (num_contours > 0)
{
- /* simple glyph w/contours, possibly trimmable */
- glyph += GlyphHeader::static_size + 2 * num_contours;
-
- if (unlikely (glyph + 2 >= glyph_end)) return false;
- uint16_t nCoordinates = (uint16_t) StructAtOffset<HBUINT16>(glyph - 2, 0) + 1;
- uint16_t nInstructions = (uint16_t) StructAtOffset<HBUINT16>(glyph, 0);
-
- glyph += 2 + nInstructions;
- if (unlikely (glyph + 2 >= glyph_end)) return false;
-
- unsigned int coordBytes = 0;
- unsigned int coordsWithFlags = 0;
- while (glyph < glyph_end)
- {
- uint8_t flag = (uint8_t) *glyph;
- glyph++;
-
- unsigned int repeat = 1;
- if (flag & FLAG_REPEAT)
- {
- if (glyph >= glyph_end)
- {
- DEBUG_MSG(SUBSET, nullptr, "Bad flag");
- return false;
- }
- repeat = ((uint8_t) *glyph) + 1;
- glyph++;
- }
-
- unsigned int xBytes, yBytes;
- xBytes = yBytes = 0;
- if (flag & FLAG_X_SHORT)
- xBytes = 1;
- else if ((flag & FLAG_X_SAME) == 0)
- xBytes = 2;
-
- if (flag & FLAG_Y_SHORT)
- yBytes = 1;
- else if ((flag & FLAG_Y_SAME) == 0)
- yBytes = 2;
-
- coordBytes += (xBytes + yBytes) * repeat;
- coordsWithFlags += repeat;
- if (coordsWithFlags >= nCoordinates)
- break;
- }
-
- if (coordsWithFlags != nCoordinates)
- {
- DEBUG_MSG(SUBSET, nullptr, "Expect %d coords to have flags, got flags for %d", nCoordinates, coordsWithFlags);
- return false;
- }
- glyph += coordBytes;
-
- if (glyph < glyph_end)
- *end_offset -= glyph_end - glyph;
+ /* simple glyph w/contours, possibly trimmable */
+ glyph += GlyphHeader::static_size + 2 * num_contours;
+
+ if (unlikely (glyph + 2 >= glyph_end)) return false;
+ uint16_t nCoordinates = (uint16_t) StructAtOffset<HBUINT16> (glyph - 2, 0) + 1;
+ uint16_t nInstructions = (uint16_t) StructAtOffset<HBUINT16> (glyph, 0);
+
+ glyph += 2 + nInstructions;
+ if (unlikely (glyph + 2 >= glyph_end)) return false;
+
+ unsigned int coordBytes = 0;
+ unsigned int coordsWithFlags = 0;
+ while (glyph < glyph_end)
+ {
+ uint8_t flag = (uint8_t) *glyph;
+ glyph++;
+
+ unsigned int repeat = 1;
+ if (flag & FLAG_REPEAT)
+ {
+ if (glyph >= glyph_end)
+ {
+ DEBUG_MSG(SUBSET, nullptr, "Bad flag");
+ return false;
+ }
+ repeat = ((uint8_t) *glyph) + 1;
+ glyph++;
+ }
+
+ unsigned int xBytes, yBytes;
+ xBytes = yBytes = 0;
+ if (flag & FLAG_X_SHORT) xBytes = 1;
+ else if ((flag & FLAG_X_SAME) == 0) xBytes = 2;
+
+ if (flag & FLAG_Y_SHORT) yBytes = 1;
+ else if ((flag & FLAG_Y_SAME) == 0) yBytes = 2;
+
+ coordBytes += (xBytes + yBytes) * repeat;
+ coordsWithFlags += repeat;
+ if (coordsWithFlags >= nCoordinates)
+ break;
+ }
+
+ if (coordsWithFlags != nCoordinates)
+ {
+ DEBUG_MSG(SUBSET, nullptr, "Expect %d coords to have flags, got flags for %d", nCoordinates, coordsWithFlags);
+ return false;
+ }
+ glyph += coordBytes;
+
+ if (glyph < glyph_end)
+ *end_offset -= glyph_end - glyph;
}
return true;
}
inline bool get_offsets (hb_codepoint_t glyph,
- unsigned int *start_offset /* OUT */,
- unsigned int *end_offset /* OUT */) const
+ unsigned int *start_offset /* OUT */,
+ unsigned int *end_offset /* OUT */) const
{
if (unlikely (glyph >= num_glyphs))
return false;
if (short_offset)
{
- const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ;
+ const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ;
*start_offset = 2 * offsets[glyph];
*end_offset = 2 * offsets[glyph + 1];
}
else
{
- const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ;
+ const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ;
*start_offset = offsets[glyph];
*end_offset = offsets[glyph + 1];
}
- if (*start_offset > *end_offset || *end_offset > glyf_len)
+ if (*start_offset > *end_offset || *end_offset > glyf_table.get_length ())
return false;
return true;
}
- inline bool get_instruction_offsets(unsigned int start_offset,
- unsigned int end_offset,
- unsigned int *instruction_start /* OUT */,
- unsigned int *instruction_end /* OUT */) const
+ inline bool get_instruction_offsets (unsigned int start_offset,
+ unsigned int end_offset,
+ unsigned int *instruction_start /* OUT */,
+ unsigned int *instruction_end /* OUT */) const
{
if (end_offset - start_offset < GlyphHeader::static_size)
{
- *instruction_start = 0;
- *instruction_end = 0;
- return true; /* Empty glyph; no instructions. */
+ *instruction_start = 0;
+ *instruction_end = 0;
+ return true; /* Empty glyph; no instructions. */
}
const GlyphHeader &glyph_header = StructAtOffset<GlyphHeader> (glyf_table, start_offset);
int16_t num_contours = (int16_t) glyph_header.numberOfContours;
if (num_contours < 0)
{
- CompositeGlyphHeader::Iterator composite_it;
- if (unlikely (!CompositeGlyphHeader::get_iterator (
- (const char*) this->glyf_table + start_offset,
- end_offset - start_offset, &composite_it))) return false;
- const CompositeGlyphHeader *last;
- do {
- last = composite_it.current;
- } while (composite_it.move_to_next());
-
- if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS)
- *instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size();
- else
- *instruction_start = end_offset;
- *instruction_end = end_offset;
- if (unlikely (*instruction_start > *instruction_end))
- {
- DEBUG_MSG(SUBSET, nullptr, "Invalid instruction offset, %d is outside [%d, %d]", *instruction_start, start_offset, end_offset);
- return false;
- }
+ CompositeGlyphHeader::Iterator composite_it;
+ if (unlikely (!CompositeGlyphHeader::get_iterator (
+ (const char*) this->glyf_table + start_offset,
+ end_offset - start_offset, &composite_it))) return false;
+ const CompositeGlyphHeader *last;
+ do {
+ last = composite_it.current;
+ } while (composite_it.move_to_next ());
+
+ if ((uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS)
+ *instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size ();
+ else
+ *instruction_start = end_offset;
+ *instruction_end = end_offset;
+ if (unlikely (*instruction_start > *instruction_end))
+ {
+ DEBUG_MSG(SUBSET, nullptr, "Invalid instruction offset, %d is outside [%d, %d]", *instruction_start, start_offset, end_offset);
+ return false;
+ }
}
else
{
- unsigned int instruction_length_offset = start_offset + GlyphHeader::static_size + 2 * num_contours;
+ unsigned int instruction_length_offset = start_offset + GlyphHeader::static_size + 2 * num_contours;
if (unlikely (instruction_length_offset + 2 > end_offset))
{
DEBUG_MSG(SUBSET, nullptr, "Glyph size is too short, missing field instructionLength.");
return false;
}
- const HBUINT16 &instruction_length = StructAtOffset<HBUINT16> (glyf_table, instruction_length_offset);
+ const HBUINT16 &instruction_length = StructAtOffset<HBUINT16> (glyf_table, instruction_length_offset);
unsigned int start = instruction_length_offset + 2;
unsigned int end = start + (uint16_t) instruction_length;
if (unlikely (end > end_offset)) // Out of bounds of the current glyph
@@ -447,7 +432,7 @@ struct glyf
}
*instruction_start = start;
- *instruction_end = end;
+ *instruction_end = end;
}
return true;
}
@@ -457,7 +442,7 @@ struct glyf
{
unsigned int start_offset, end_offset;
if (!get_offsets (glyph, &start_offset, &end_offset))
- return false;
+ return false;
if (end_offset - start_offset < GlyphHeader::static_size)
return true; /* Empty glyph; zero extents. */
@@ -475,17 +460,16 @@ struct glyf
private:
bool short_offset;
unsigned int num_glyphs;
- const loca *loca_table;
- const glyf *glyf_table;
- hb_blob_t *loca_blob;
- hb_blob_t *glyf_blob;
- unsigned int glyf_len;
+ hb_blob_ptr_t<loca> loca_table;
+ hb_blob_ptr_t<glyf> glyf_table;
};
protected:
UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */
-
- DEFINE_SIZE_ARRAY (0, dataZ);
+ public:
+ DEFINE_SIZE_MIN (0); /* In reality, this is UNBOUNDED() type; but since we always
+ * check the size externally, allow Null() object of it by
+ * defining it MIN() instead. */
};
struct glyf_accelerator_t : glyf::accelerator_t {};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hdmx-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hdmx-table.hh
index 04511b5d09e..0fea24bca24 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hdmx-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hdmx-table.hh
@@ -44,15 +44,15 @@ struct DeviceRecord
struct SubsetView
{
const DeviceRecord *source_device_record;
- unsigned int size_device_record;
+ unsigned int sizeDeviceRecord;
hb_subset_plan_t *subset_plan;
- inline void init(const DeviceRecord *source_device_record,
- unsigned int size_device_record,
- hb_subset_plan_t *subset_plan)
+ inline void init (const DeviceRecord *source_device_record,
+ unsigned int sizeDeviceRecord,
+ hb_subset_plan_t *subset_plan)
{
this->source_device_record = source_device_record;
- this->size_device_record = size_device_record;
+ this->sizeDeviceRecord = sizeDeviceRecord;
this->subset_plan = subset_plan;
}
@@ -63,15 +63,12 @@ struct DeviceRecord
inline const HBUINT8* operator [] (unsigned int i) const
{
- if (unlikely (i >= len())) return nullptr;
+ if (unlikely (i >= len ())) return nullptr;
hb_codepoint_t gid = this->subset_plan->glyphs [i];
- const HBUINT8* width = &(this->source_device_record->widthsZ[gid]);
-
- if (width < ((const HBUINT8 *) this->source_device_record) + size_device_record)
- return width;
- else
- return nullptr;
+ if (gid >= sizeDeviceRecord - DeviceRecord::min_size)
+ return nullptr;
+ return &(this->source_device_record->widthsZ[gid]);
}
};
@@ -84,18 +81,18 @@ struct DeviceRecord
{
TRACE_SERIALIZE (this);
- unsigned int size = get_size (subset_view.len());
+ unsigned int size = get_size (subset_view.len ());
if (unlikely (!c->allocate_size<DeviceRecord> (size)))
{
- DEBUG_MSG (SUBSET, nullptr, "Couldn't allocate enough space for DeviceRecord: %d.",
- 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);
+ this->pixelSize.set (subset_view.source_device_record->pixelSize);
+ this->maxWidth.set (subset_view.source_device_record->maxWidth);
- for (unsigned int i = 0; i < subset_view.len(); i++)
+ for (unsigned int i = 0; i < subset_view.len (); i++)
{
const HBUINT8 *width = subset_view[i];
if (!width)
@@ -109,16 +106,16 @@ struct DeviceRecord
return_trace (true);
}
- inline bool sanitize (hb_sanitize_context_t *c, unsigned int size_device_record) const
+ inline bool sanitize (hb_sanitize_context_t *c, unsigned int sizeDeviceRecord) const
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- c->check_range (this, size_device_record)));
+ c->check_range (this, sizeDeviceRecord)));
}
- HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */
- HBUINT8 max_width; /* Maximum width. */
- UnsizedArrayOf<HBUINT8> widthsZ; /* Array of widths (numGlyphs is from the 'maxp' table). */
+ HBUINT8 pixelSize; /* Pixel size for following widths (as ppem). */
+ HBUINT8 maxWidth; /* Maximum width. */
+ UnsizedArrayOf<HBUINT8> widthsZ; /* Array of widths (numGlyphs is from the 'maxp' table). */
public:
DEFINE_SIZE_ARRAY (2, widthsZ);
};
@@ -130,13 +127,15 @@ struct hdmx
inline unsigned int get_size (void) const
{
- return min_size + num_records * size_device_record;
+ return min_size + numRecords * sizeDeviceRecord;
}
inline const DeviceRecord& operator [] (unsigned int i) const
{
- if (unlikely (i >= num_records)) return Null(DeviceRecord);
- return StructAtOffset<DeviceRecord> (&this->dataZ, i * size_device_record);
+ /* XXX Null(DeviceRecord) is NOT safe as it's num-glyphs lengthed.
+ * https://github.com/harfbuzz/harfbuzz/issues/1300 */
+ if (unlikely (i >= numRecords)) return Null (DeviceRecord);
+ return StructAtOffset<DeviceRecord> (&this->firstDeviceRecord, i * sizeDeviceRecord);
}
inline bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan)
@@ -146,13 +145,13 @@ struct hdmx
if (unlikely (!c->extend_min ((*this)))) return_trace (false);
this->version.set (source_hdmx->version);
- this->num_records.set (source_hdmx->num_records);
- this->size_device_record.set (DeviceRecord::get_size (plan->glyphs.len));
+ this->numRecords.set (source_hdmx->numRecords);
+ this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->glyphs.len));
- for (unsigned int i = 0; i < source_hdmx->num_records; i++)
+ for (unsigned int i = 0; i < source_hdmx->numRecords; i++)
{
DeviceRecord::SubsetView subset_view;
- subset_view.init (&(*source_hdmx)[i], source_hdmx->size_device_record, plan);
+ subset_view.init (&(*source_hdmx)[i], source_hdmx->sizeDeviceRecord, plan);
if (!c->start_embed<DeviceRecord> ()->serialize (c, subset_view))
return_trace (false);
@@ -163,7 +162,7 @@ struct hdmx
static inline size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan)
{
- return min_size + source_hdmx->num_records * DeviceRecord::get_size (plan->glyphs.len);
+ return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->glyphs.len);
}
inline bool subset (hb_subset_plan_t *plan) const
@@ -200,19 +199,19 @@ struct hdmx
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && version == 0 &&
- !hb_unsigned_mul_overflows (num_records, size_device_record) &&
- size_device_record >= DeviceRecord::min_size &&
- c->check_range (this, get_size()));
+ return_trace (c->check_struct (this) &&
+ !hb_unsigned_mul_overflows (numRecords, sizeDeviceRecord) &&
+ sizeDeviceRecord >= DeviceRecord::min_size &&
+ c->check_range (this, get_size ()));
}
protected:
- HBUINT16 version; /* Table version number (0) */
- HBUINT16 num_records; /* Number of device records. */
- HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */
- UnsizedArrayOf<HBUINT8> dataZ; /* Array of device records. */
+ HBUINT16 version; /* Table version number (0) */
+ HBUINT16 numRecords; /* Number of device records. */
+ HBUINT32 sizeDeviceRecord; /* Size of a device record, 32-bit aligned. */
+ DeviceRecord firstDeviceRecord; /* Array of device records. */
public:
- DEFINE_SIZE_ARRAY (8, dataZ);
+ DEFINE_SIZE_MIN (8);
};
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hmtx-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hmtx-table.hh
index 363395ab082..091b601173f 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hmtx-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-hmtx-table.hh
@@ -48,7 +48,7 @@ namespace OT {
struct LongMetric
{
UFWORD advance; /* Advance width/height. */
- FWORD lsb; /* Leading (left/top) side bearing. */
+ FWORD sb; /* Leading (left/top) side bearing. */
public:
DEFINE_SIZE_STATIC (4);
};
@@ -56,7 +56,7 @@ struct LongMetric
template <typename T, typename H>
struct hmtxvmtx
{
- inline bool sanitize (hb_sanitize_context_t *c) const
+ inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const
{
TRACE_SANITIZE (this);
/* We don't check for anything specific here. The users of the
@@ -66,10 +66,10 @@ struct hmtxvmtx
inline bool subset_update_header (hb_subset_plan_t *plan,
- unsigned int num_hmetrics) const
+ unsigned int num_hmetrics) const
{
- hb_blob_t *src_blob = hb_sanitize_context_t().reference_table<H> (plan->source, H::tableTag);
- hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail(src_blob);
+ hb_blob_t *src_blob = hb_sanitize_context_t ().reference_table<H> (plan->source, H::tableTag);
+ hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail (src_blob);
hb_blob_destroy (src_blob);
if (unlikely (!dest_blob)) {
@@ -96,15 +96,15 @@ struct hmtxvmtx
hb_vector_t<hb_codepoint_t> &gids = plan->glyphs;
unsigned int num_advances = gids.len;
unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]);
- while (num_advances > 1
- && last_advance == _mtx.get_advance (gids[num_advances - 2]))
+ while (num_advances > 1 &&
+ last_advance == _mtx.get_advance (gids[num_advances - 2]))
{
num_advances--;
}
/* alloc the new table */
size_t dest_sz = num_advances * 4
- + (gids.len - num_advances) * 2;
+ + (gids.len - num_advances) * 2;
void *dest = (void *) malloc (dest_sz);
if (unlikely (!dest))
{
@@ -113,7 +113,7 @@ struct hmtxvmtx
DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in src has %d advances, %d lsbs", HB_UNTAG(T::tableTag), _mtx.num_advances, _mtx.num_metrics - _mtx.num_advances);
DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in dest has %d advances, %d lsbs, %u bytes", HB_UNTAG(T::tableTag), num_advances, gids.len - num_advances, (unsigned int) dest_sz);
- const char *source_table = hb_blob_get_data (_mtx.blob, nullptr);
+ const char *source_table = hb_blob_get_data (_mtx.table.get_blob (), nullptr);
// Copy everything over
LongMetric * old_metrics = (LongMetric *) source_table;
FWORD *lsbs = (FWORD *) (old_metrics + _mtx.num_advances);
@@ -134,8 +134,8 @@ struct hmtxvmtx
}
else
{
- /* dest just lsb */
- *((FWORD *) dest_pos) = src_metric->lsb;
+ /* dest just sb */
+ *((FWORD *) dest_pos) = src_metric->sb;
}
}
else
@@ -147,18 +147,18 @@ struct hmtxvmtx
failed = true;
break;
}
- FWORD src_lsb = *(lsbs + gids[i] - _mtx.num_advances);
+ FWORD src_sb = *(lsbs + gids[i] - _mtx.num_advances);
if (i < num_advances)
{
/* dest needs a full LongMetric */
LongMetric *metric = (LongMetric *)dest_pos;
metric->advance = src_metric->advance;
- metric->lsb = src_lsb;
+ metric->sb = src_sb;
}
else
{
- /* dest just needs an lsb */
- *((FWORD *) dest_pos) = src_lsb;
+ /* dest just needs an sb */
+ *((FWORD *) dest_pos) = src_sb;
}
}
dest_pos += (i < num_advances ? 4 : 2);
@@ -194,17 +194,14 @@ struct hmtxvmtx
bool got_font_extents = false;
if (T::os2Tag)
{
- hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<os2> (face);
- const os2 *os2_table = os2_blob->as<os2> ();
#define USE_TYPO_METRICS (1u<<7)
- if (0 != (os2_table->fsSelection & USE_TYPO_METRICS))
+ if (0 != (face->table.OS2->fsSelection & USE_TYPO_METRICS))
{
- ascender = os2_table->sTypoAscender;
- descender = os2_table->sTypoDescender;
- line_gap = os2_table->sTypoLineGap;
+ ascender = abs (face->table.OS2->sTypoAscender);
+ descender = -abs (face->table.OS2->sTypoDescender);
+ line_gap = face->table.OS2->sTypoLineGap;
got_font_extents = (ascender | descender) != 0;
}
- hb_blob_destroy (os2_blob);
}
hb_blob_t *_hea_blob = hb_sanitize_context_t().reference_table<H> (face);
@@ -212,8 +209,8 @@ struct hmtxvmtx
num_advances = _hea_table->numberOfLongMetrics;
if (!got_font_extents)
{
- ascender = _hea_table->ascender;
- descender = _hea_table->descender;
+ ascender = abs (_hea_table->ascender);
+ descender = -abs (_hea_table->descender);
line_gap = _hea_table->lineGap;
got_font_extents = (ascender | descender) != 0;
}
@@ -221,10 +218,10 @@ struct hmtxvmtx
has_font_extents = got_font_extents;
- blob = hb_sanitize_context_t().reference_table<hmtxvmtx> (face, T::tableTag);
+ table = hb_sanitize_context_t().reference_table<hmtxvmtx> (face, T::tableTag);
/* Cap num_metrics() and num_advances() based on table length. */
- unsigned int len = hb_blob_get_length (blob);
+ unsigned int len = table.get_length ();
if (unlikely (num_advances * 4 > len))
num_advances = len / 4;
num_metrics = num_advances + (len - 4 * num_advances) / 2;
@@ -234,32 +231,43 @@ struct hmtxvmtx
if (unlikely (!num_advances))
{
num_metrics = num_advances = 0;
- hb_blob_destroy (blob);
- blob = hb_blob_get_empty ();
+ table.destroy ();
+ table = hb_blob_get_empty ();
}
- table = blob->as<hmtxvmtx> ();
- var_blob = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag);
- var_table = var_blob->as<HVARVVAR> ();
+ var_table = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag);
}
inline void fini (void)
{
- hb_blob_destroy (blob);
- hb_blob_destroy (var_blob);
+ table.destroy ();
+ var_table.destroy ();
}
- inline unsigned int get_advance (hb_codepoint_t glyph) const
+ /* TODO Add variations version. */
+ inline unsigned int get_side_bearing (hb_codepoint_t glyph) const
+ {
+ if (glyph < num_advances)
+ return table->longMetricZ[glyph].sb;
+
+ if (unlikely (glyph >= num_metrics))
+ return 0;
+
+ const FWORD *bearings = (const FWORD *) &table->longMetricZ[num_advances];
+ return bearings[glyph - num_advances];
+ }
+
+ inline unsigned int get_advance (hb_codepoint_t glyph) const
{
if (unlikely (glyph >= num_metrics))
{
- /* If num_metrics is zero, it means we don't have the metrics table
- * for this direction: return default advance. Otherwise, it means that the
- * glyph index is out of bound: return zero. */
- if (num_metrics)
- return 0;
- else
- return default_advance;
+ /* If num_metrics is zero, it means we don't have the metrics table
+ * for this direction: return default advance. Otherwise, it means that the
+ * glyph index is out of bound: return zero. */
+ if (num_metrics)
+ return 0;
+ else
+ return default_advance;
}
return table->longMetricZ[MIN (glyph, (uint32_t) num_advances - 1)].advance;
@@ -269,18 +277,18 @@ struct hmtxvmtx
hb_font_t *font) const
{
unsigned int advance = get_advance (glyph);
- if (likely(glyph < num_metrics))
+ if (likely (glyph < num_metrics))
{
- advance += (font->num_coords ? var_table->get_advance_var (glyph, font->coords, font->num_coords) : 0); // TODO Optimize?!
+ advance += (font->num_coords ? var_table->get_advance_var (glyph, font->coords, font->num_coords) : 0); // TODO Optimize?!
}
return advance;
}
public:
bool has_font_extents;
- unsigned short ascender;
- unsigned short descender;
- unsigned short line_gap;
+ int ascender;
+ int descender;
+ int line_gap;
protected:
unsigned int num_metrics;
@@ -288,10 +296,8 @@ struct hmtxvmtx
unsigned int default_advance;
private:
- const hmtxvmtx *table;
- hb_blob_t *blob;
- const HVARVVAR *var_table;
- hb_blob_t *var_blob;
+ hb_blob_ptr_t<hmtxvmtx> table;
+ hb_blob_ptr_t<HVARVVAR> var_table;
};
protected:
@@ -323,7 +329,7 @@ struct hmtxvmtx
struct hmtx : hmtxvmtx<hmtx, hhea> {
static const hb_tag_t tableTag = HB_OT_TAG_hmtx;
static const hb_tag_t variationsTag = HB_OT_TAG_HVAR;
- static const hb_tag_t os2Tag = HB_OT_TAG_os2;
+ static const hb_tag_t os2Tag = HB_OT_TAG_OS2;
};
struct vmtx : hmtxvmtx<vmtx, vhea> {
static const hb_tag_t tableTag = HB_OT_TAG_vmtx;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-kern-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-kern-table.hh
index 8ed6298f1ac..b57ebaea8dc 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-kern-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-kern-table.hh
@@ -27,7 +27,8 @@
#ifndef HB_OT_KERN_TABLE_HH
#define HB_OT_KERN_TABLE_HH
-#include "hb-open-type.hh"
+#include "hb-aat-layout-kerx-table.hh"
+
/*
* kern -- Kerning
@@ -40,358 +41,299 @@
namespace OT {
-struct hb_glyph_pair_t
-{
- hb_codepoint_t left;
- hb_codepoint_t right;
-};
-
-struct KernPair
-{
- inline int get_kerning (void) const
- { return value; }
-
- inline int cmp (const hb_glyph_pair_t &o) const
- {
- int ret = left.cmp (o.left);
- if (ret) return ret;
- return right.cmp (o.right);
- }
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this));
- }
-
- protected:
- GlyphID left;
- GlyphID right;
- FWORD value;
- public:
- DEFINE_SIZE_STATIC (6);
-};
-
-struct KernSubTableFormat0
+template <typename KernSubTableHeader>
+struct KernSubTableFormat3
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- hb_glyph_pair_t pair = {left, right};
- int i = pairs.bsearch (pair);
- if (i == -1)
+ hb_array_t<const FWORD> kernValue = kernValueZ.as_array (kernValueCount);
+ hb_array_t<const HBUINT8> leftClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (kernValue).as_array (glyphCount);
+ hb_array_t<const HBUINT8> rightClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (leftClass).as_array (glyphCount);
+ hb_array_t<const HBUINT8> kernIndex = StructAfter<const UnsizedArrayOf<HBUINT8> > (rightClass).as_array (leftClassCount * rightClassCount);
+
+ unsigned int leftC = leftClass[left];
+ unsigned int rightC = rightClass[right];
+ if (unlikely (leftC >= leftClassCount || rightC >= rightClassCount))
return 0;
- return pairs[i].get_kerning ();
+ unsigned int i = leftC * rightClassCount + rightC;
+ return kernValue[kernIndex[i]];
}
- inline bool sanitize (hb_sanitize_context_t *c) const
+ inline bool apply (AAT::hb_aat_apply_context_t *c) const
{
- TRACE_SANITIZE (this);
- return_trace (pairs.sanitize (c));
- }
+ TRACE_APPLY (this);
- protected:
- BinSearchArrayOf<KernPair> pairs; /* Array of kerning pairs. */
- public:
- DEFINE_SIZE_ARRAY (8, pairs);
-};
+ if (!c->plan->requested_kerning)
+ return false;
-struct KernClassTable
-{
- inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; }
+ if (header.coverage & header.Backwards)
+ return false;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (firstGlyph.sanitize (c) && classes.sanitize (c));
- }
+ hb_kern_machine_t<KernSubTableFormat3> machine (*this, header.coverage & header.CrossStream);
+ machine.kern (c->font, c->buffer, c->plan->kern_mask);
- protected:
- HBUINT16 firstGlyph; /* First glyph in class range. */
- ArrayOf<HBUINT16> classes; /* Glyph classes. */
- public:
- DEFINE_SIZE_ARRAY (4, classes);
-};
-
-struct KernSubTableFormat2
-{
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
- {
- unsigned int l = (this+leftClassTable).get_class (left);
- unsigned int r = (this+rightClassTable).get_class (right);
- unsigned int offset = l * rowWidth + r * sizeof (FWORD);
- const FWORD *arr = &(this+array);
- if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
- return 0;
- const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
- if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
- return 0;
- return *v;
+ return_trace (true);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (rowWidth.sanitize (c) &&
- leftClassTable.sanitize (c, this) &&
- rightClassTable.sanitize (c, this) &&
- array.sanitize (c, this));
+ return_trace (c->check_struct (this) &&
+ c->check_range (kernValueZ,
+ kernValueCount * sizeof (FWORD) +
+ glyphCount * 2 +
+ leftClassCount * rightClassCount));
}
protected:
- HBUINT16 rowWidth; /* The width, in bytes, of a row in the table. */
- OffsetTo<KernClassTable>
- leftClassTable; /* Offset from beginning of this subtable to
- * left-hand class table. */
- OffsetTo<KernClassTable>
- rightClassTable;/* Offset from beginning of this subtable to
- * right-hand class table. */
- OffsetTo<FWORD>
- array; /* Offset from beginning of this subtable to
- * the start of the kerning array. */
+ KernSubTableHeader header;
+ HBUINT16 glyphCount; /* The number of glyphs in this font. */
+ HBUINT8 kernValueCount; /* The number of kerning values. */
+ HBUINT8 leftClassCount; /* The number of left-hand classes. */
+ HBUINT8 rightClassCount;/* The number of right-hand classes. */
+ HBUINT8 flags; /* Set to zero (reserved for future use). */
+ UnsizedArrayOf<FWORD> kernValueZ; /* The kerning values.
+ * Length kernValueCount. */
+#if 0
+ UnsizedArrayOf<HBUINT8>leftClass; /* The left-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>rightClass; /* The right-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>kernIndex; /* The indices into the kernValue array.
+ * Length leftClassCount * rightClassCount */
+#endif
public:
- DEFINE_SIZE_MIN (8);
+ DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 6, kernValueZ);
};
+template <typename KernSubTableHeader>
struct KernSubTable
{
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end, unsigned int format) const
+ inline unsigned int get_size (void) const { return u.header.length; }
+ inline unsigned int get_type (void) const { return u.header.format; }
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- switch (format) {
+ switch (get_type ()) {
+ /* This method hooks up to hb_font_t's get_h_kerning. Only support Format0. */
case 0: return u.format0.get_kerning (left, right);
- case 2: return u.format2.get_kerning (left, right, end);
default:return 0;
}
}
- inline bool sanitize (hb_sanitize_context_t *c, unsigned int format) const
+ template <typename context_t>
+ inline typename context_t::return_t dispatch (context_t *c) const
{
- TRACE_SANITIZE (this);
- switch (format) {
- case 0: return_trace (u.format0.sanitize (c));
- case 2: return_trace (u.format2.sanitize (c));
- default:return_trace (true);
+ unsigned int subtable_type = get_type ();
+ TRACE_DISPATCH (this, subtable_type);
+ switch (subtable_type) {
+ case 0: return_trace (c->dispatch (u.format0));
+ case 1: return_trace (u.header.apple ? c->dispatch (u.format1) : c->default_return_value ());
+ case 2: return_trace (c->dispatch (u.format2));
+ case 3: return_trace (u.header.apple ? c->dispatch (u.format3) : c->default_return_value ());
+ default: return_trace (c->default_return_value ());
}
}
- protected:
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (!u.header.sanitize (c) ||
+ u.header.length < u.header.min_size ||
+ !c->check_range (this, u.header.length))) return_trace (false);
+
+ return_trace (dispatch (c));
+ }
+
+ public:
union {
- KernSubTableFormat0 format0;
- KernSubTableFormat2 format2;
+ KernSubTableHeader header;
+ AAT::KerxSubTableFormat0<KernSubTableHeader> format0;
+ AAT::KerxSubTableFormat1<KernSubTableHeader> format1;
+ AAT::KerxSubTableFormat2<KernSubTableHeader> format2;
+ KernSubTableFormat3<KernSubTableHeader> format3;
} u;
public:
- DEFINE_SIZE_MIN (0);
+ DEFINE_SIZE_MIN (KernSubTableHeader::static_size);
};
-template <typename T>
-struct KernSubTableWrapper
+struct KernOTSubTableHeader
{
- /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
- inline const T* thiz (void) const { return static_cast<const T *> (this); }
-
- inline bool is_horizontal (void) const
- { return (thiz()->coverage & T::COVERAGE_CHECK_FLAGS) == T::COVERAGE_CHECK_HORIZONTAL; }
+ static const bool apple = false;
+ typedef AAT::ObsoleteTypes Types;
- inline bool is_override (void) const
- { return bool (thiz()->coverage & T::COVERAGE_OVERRIDE_FLAG); }
+ inline unsigned int tuple_count (void) const { return 0; }
+ inline bool is_horizontal (void) const { return (coverage & Horizontal); }
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
- { return thiz()->subtable.get_kerning (left, right, end, thiz()->format); }
-
- inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
- { return is_horizontal () ? get_kerning (left, right, end) : 0; }
-
- inline unsigned int get_size (void) const { return thiz()->length; }
+ enum Coverage
+ {
+ Horizontal = 0x01u,
+ Minimum = 0x02u,
+ CrossStream = 0x04u,
+ Override = 0x08u,
+
+ /* Not supported: */
+ Backwards = 0x00u,
+ Variation = 0x00u,
+ };
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (thiz()) &&
- thiz()->length >= T::min_size &&
- c->check_array (thiz(), thiz()->length, 1) &&
- thiz()->subtable.sanitize (c, thiz()->format));
+ return_trace (c->check_struct (this));
}
+
+ public:
+ HBUINT16 versionZ; /* Unused. */
+ HBUINT16 length; /* Length of the subtable (including this header). */
+ HBUINT8 format; /* Subtable format. */
+ HBUINT8 coverage; /* Coverage bits. */
+ public:
+ DEFINE_SIZE_STATIC (6);
};
-template <typename T>
-struct KernTable
+struct KernOT : AAT::KerxTable<KernOT>
{
- /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
- inline const T* thiz (void) const { return static_cast<const T *> (this); }
+ friend struct AAT::KerxTable<KernOT>;
- inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
- {
- int v = 0;
- const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
- unsigned int count = thiz()->nTables;
- for (unsigned int i = 0; i < count; i++)
- {
- if (st->is_override ())
- v = 0;
- v += st->get_h_kerning (left, right, table_length + (const char *) this);
- st = &StructAfter<typename T::SubTableWrapper> (*st);
- }
- return v;
- }
+ static const hb_tag_t tableTag = HB_OT_TAG_kern;
+ static const uint16_t minVersion = 0;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- if (unlikely (!c->check_struct (thiz()) ||
- thiz()->version != T::VERSION))
- return_trace (false);
-
- const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
- unsigned int count = thiz()->nTables;
- for (unsigned int i = 0; i < count; i++)
- {
- if (unlikely (!st->sanitize (c)))
- return_trace (false);
- st = &StructAfter<typename T::SubTableWrapper> (*st);
- }
+ typedef KernOTSubTableHeader SubTableHeader;
+ typedef SubTableHeader::Types Types;
+ typedef KernSubTable<SubTableHeader> SubTable;
- return_trace (true);
- }
+ protected:
+ HBUINT16 version; /* Version--0x0000u */
+ HBUINT16 tableCount; /* Number of subtables in the kerning table. */
+ SubTable firstSubTable; /* Subtables. */
+ public:
+ DEFINE_SIZE_MIN (4);
};
-struct KernOT : KernTable<KernOT>
+
+struct KernAATSubTableHeader
{
- friend struct KernTable<KernOT>;
+ static const bool apple = true;
+ typedef AAT::ObsoleteTypes Types;
- static const uint16_t VERSION = 0x0000u;
+ inline unsigned int tuple_count (void) const { return 0; }
+ inline bool is_horizontal (void) const { return !(coverage & Vertical); }
- struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
+ enum Coverage
{
- friend struct KernSubTableWrapper<SubTableWrapper>;
-
- enum coverage_flags_t {
- COVERAGE_DIRECTION_FLAG = 0x01u,
- COVERAGE_MINIMUM_FLAG = 0x02u,
- COVERAGE_CROSSSTREAM_FLAG = 0x04u,
- COVERAGE_OVERRIDE_FLAG = 0x08u,
-
- COVERAGE_VARIATION_FLAG = 0x00u, /* Not supported. */
-
- COVERAGE_CHECK_FLAGS = 0x07u,
- COVERAGE_CHECK_HORIZONTAL = 0x01u
- };
-
- protected:
- HBUINT16 versionZ; /* Unused. */
- HBUINT16 length; /* Length of the subtable (including this header). */
- HBUINT8 format; /* Subtable format. */
- HBUINT8 coverage; /* Coverage bits. */
- KernSubTable subtable; /* Subtable data. */
- public:
- DEFINE_SIZE_MIN (6);
+ Vertical = 0x80u,
+ CrossStream = 0x40u,
+ Variation = 0x20u,
+
+ /* Not supported: */
+ Backwards = 0x00u,
};
- protected:
- HBUINT16 version; /* Version--0x0000u */
- HBUINT16 nTables; /* Number of subtables in the kerning table. */
- UnsizedArrayOf<HBUINT8> dataZ;
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this));
+ }
+
public:
- DEFINE_SIZE_ARRAY (4, dataZ);
+ HBUINT32 length; /* Length of the subtable (including this header). */
+ HBUINT8 coverage; /* Coverage bits. */
+ HBUINT8 format; /* Subtable format. */
+ HBUINT16 tupleIndex; /* The tuple index (used for variations fonts).
+ * This value specifies which tuple this subtable covers.
+ * Note: We don't implement. */
+ public:
+ DEFINE_SIZE_STATIC (8);
};
-struct KernAAT : KernTable<KernAAT>
+struct KernAAT : AAT::KerxTable<KernAAT>
{
- friend struct KernTable<KernAAT>;
+ friend struct AAT::KerxTable<KernAAT>;
- static const uint32_t VERSION = 0x00010000u;
+ static const hb_tag_t tableTag = HB_OT_TAG_kern;
+ static const uint32_t minVersion = 0x00010000u;
- struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
- {
- friend struct KernSubTableWrapper<SubTableWrapper>;
-
- enum coverage_flags_t {
- COVERAGE_DIRECTION_FLAG = 0x80u,
- COVERAGE_CROSSSTREAM_FLAG = 0x40u,
- COVERAGE_VARIATION_FLAG = 0x20u,
-
- COVERAGE_OVERRIDE_FLAG = 0x00u, /* Not supported. */
-
- COVERAGE_CHECK_FLAGS = 0xE0u,
- COVERAGE_CHECK_HORIZONTAL = 0x00u
- };
-
- protected:
- HBUINT32 length; /* Length of the subtable (including this header). */
- HBUINT8 coverage; /* Coverage bits. */
- HBUINT8 format; /* Subtable format. */
- HBUINT16 tupleIndex; /* The tuple index (used for variations fonts).
- * This value specifies which tuple this subtable covers. */
- KernSubTable subtable; /* Subtable data. */
- public:
- DEFINE_SIZE_MIN (8);
- };
+ typedef KernAATSubTableHeader SubTableHeader;
+ typedef SubTableHeader::Types Types;
+ typedef KernSubTable<SubTableHeader> SubTable;
protected:
- HBUINT32 version; /* Version--0x00010000u */
- HBUINT32 nTables; /* Number of subtables in the kerning table. */
- UnsizedArrayOf<HBUINT8> dataZ;
+ HBUINT32 version; /* Version--0x00010000u */
+ HBUINT32 tableCount; /* Number of subtables in the kerning table. */
+ SubTable firstSubTable; /* Subtables. */
public:
- DEFINE_SIZE_ARRAY (8, dataZ);
+ DEFINE_SIZE_MIN (8);
};
struct kern
{
static const hb_tag_t tableTag = HB_OT_TAG_kern;
- inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
+ inline bool has_data (void) const { return u.version32; }
+ inline unsigned int get_type (void) const { return u.major; }
+
+ inline bool has_state_machine (void) const
{
- switch (u.major) {
- case 0: return u.ot.get_h_kerning (left, right, table_length);
- case 1: return u.aat.get_h_kerning (left, right, table_length);
- default:return 0;
+ switch (get_type ()) {
+ case 0: return u.ot.has_state_machine ();
+ case 1: return u.aat.has_state_machine ();
+ default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *c) const
+ inline bool has_cross_stream (void) const
{
- TRACE_SANITIZE (this);
- if (!u.major.sanitize (c)) return_trace (false);
- switch (u.major) {
- case 0: return_trace (u.ot.sanitize (c));
- case 1: return_trace (u.aat.sanitize (c));
- default:return_trace (true);
+ switch (get_type ()) {
+ case 0: return u.ot.has_cross_stream ();
+ case 1: return u.aat.has_cross_stream ();
+ default:return false;
}
}
- struct accelerator_t
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- inline void init (hb_face_t *face)
- {
- blob = hb_sanitize_context_t().reference_table<kern> (face);
- table = blob->as<kern> ();
- table_length = blob->length;
- }
- inline void fini (void)
- {
- hb_blob_destroy (blob);
+ switch (get_type ()) {
+ case 0: return u.ot.get_h_kerning (left, right);
+ case 1: return u.aat.get_h_kerning (left, right);
+ default:return 0;
}
+ }
- inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
- { return table->get_h_kerning (left, right, table_length); }
+ inline bool apply (AAT::hb_aat_apply_context_t *c) const
+ { return dispatch (c); }
- private:
- hb_blob_t *blob;
- const kern *table;
- unsigned int table_length;
- };
+ template <typename context_t>
+ inline typename context_t::return_t dispatch (context_t *c) const
+ {
+ unsigned int subtable_type = get_type ();
+ TRACE_DISPATCH (this, subtable_type);
+ switch (subtable_type) {
+ case 0: return_trace (c->dispatch (u.ot));
+ case 1: return_trace (c->dispatch (u.aat));
+ default: return_trace (c->default_return_value ());
+ }
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (!u.version32.sanitize (c)) return_trace (false);
+ return_trace (dispatch (c));
+ }
protected:
union {
+ HBUINT32 version32;
HBUINT16 major;
KernOT ot;
KernAAT aat;
} u;
public:
- DEFINE_SIZE_UNION (2, major);
+ DEFINE_SIZE_UNION (4, version32);
};
-struct kern_accelerator_t : kern::accelerator_t {};
-
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-base-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-base-table.hh
index 449e74550e9..fb57e76242e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-base-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-base-table.hh
@@ -1,6 +1,7 @@
/*
* Copyright © 2016 Elie Roux <elie.roux@telecom-bretagne.eu>
* Copyright © 2018 Google, Inc.
+ * Copyright © 2018 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -31,6 +32,9 @@
#include "hb-open-type.hh"
#include "hb-ot-layout-common.hh"
+/* To be removed */
+typedef hb_tag_t hb_ot_layout_baseline_t;
+
namespace OT {
/*
@@ -38,19 +42,14 @@ namespace OT {
* https://docs.microsoft.com/en-us/typography/opentype/spec/base
*/
-
-/* XXX Review this. */
-#define NOT_INDEXED ((unsigned int) -1)
-
-
struct BaseCoordFormat1
{
- inline int get_coord (void) const { return coordinate; }
+ inline hb_position_t get_coord () const { return coordinate; }
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this));
+ return_trace (likely (c->check_struct (this)));
}
protected:
@@ -62,7 +61,7 @@ struct BaseCoordFormat1
struct BaseCoordFormat2
{
- inline int get_coord (void) const
+ inline hb_position_t get_coord () const
{
/* TODO */
return coordinate;
@@ -86,37 +85,45 @@ struct BaseCoordFormat2
struct BaseCoordFormat3
{
- inline int get_coord (void) const
+ inline hb_position_t get_coord (hb_font_t *font,
+ const VariationStore &var_store,
+ hb_direction_t direction) const
{
- /* TODO */
- return coordinate;
+ const Device &device = this+deviceTable;
+ return coordinate + (HB_DIRECTION_IS_VERTICAL (direction) ?
+ device.get_y_delta (font, var_store) :
+ device.get_x_delta (font, var_store));
}
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && deviceTable.sanitize (c, this));
+ return_trace (likely (c->check_struct (this) &&
+ deviceTable.sanitize (c, this)));
}
protected:
- HBUINT16 format; /* Format identifier--format = 3 */
- FWORD coordinate; /* X or Y value, in design units */
- OffsetTo<Device> deviceTable; /* Offset to Device table for X or
- * Y value, from beginning of
- * BaseCoord table (may be NULL). */
+ HBUINT16 format; /* Format identifier--format = 3 */
+ FWORD coordinate; /* X or Y value, in design units */
+ OffsetTo<Device>
+ deviceTable; /* Offset to Device table for X or
+ * Y value, from beginning of
+ * BaseCoord table (may be NULL). */
public:
DEFINE_SIZE_STATIC (6);
};
struct BaseCoord
{
- inline int get_coord (void) const
+ inline hb_position_t get_coord (hb_font_t *font,
+ const VariationStore &var_store,
+ hb_direction_t direction) const
{
- /* XXX wire up direction and font. */
switch (u.format) {
case 1: return u.format1.get_coord ();
case 2: return u.format2.get_coord ();
- case 3: return u.format3.get_coord ();
+ case 3: return u.format3.get_coord (font, var_store, direction);
default:return 0;
}
}
@@ -124,7 +131,7 @@ struct BaseCoord
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (!u.format.sanitize (c)) return_trace (false);
+ if (unlikely (!u.format.sanitize (c))) return_trace (false);
switch (u.format) {
case 1: return_trace (u.format1.sanitize (c));
case 2: return_trace (u.format2.sanitize (c));
@@ -146,28 +153,40 @@ struct BaseCoord
struct FeatMinMaxRecord
{
- inline int get_min_value (void) const { return (this+minCoord).get_coord(); }
- inline int get_max_value (void) const { return (this+maxCoord).get_coord(); }
+ static int cmp (const void *key_, const void *entry_)
+ {
+ hb_tag_t key = * (hb_tag_t *) key_;
+ const FeatMinMaxRecord &entry = * (const FeatMinMaxRecord *) entry_;
+ return key < (unsigned int) entry.tag ? -1 :
+ key > (unsigned int) entry.tag ? 1 :
+ 0;
+ }
- inline const Tag& get_tag () const { return tag; }
+ inline void get_min_max (const BaseCoord **min, const BaseCoord **max) const
+ {
+ if (likely (min)) *min = &(this+minCoord);
+ if (likely (max)) *max = &(this+maxCoord);
+ }
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- minCoord.sanitize (c, base) &&
- maxCoord.sanitize (c, base));
+ return_trace (likely (c->check_struct (this) &&
+ minCoord.sanitize (c, this) &&
+ maxCoord.sanitize (c, this)));
}
protected:
- Tag tag; /* 4-byte feature identification tag--must
- * match feature tag in FeatureList */
- OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines
- * the minimum extent value, from beginning
- * of MinMax table (may be NULL) */
- OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines
- * the maximum extent value, from beginning
- * of MinMax table (may be NULL) */
+ Tag tag; /* 4-byte feature identification tag--must
+ * match feature tag in FeatureList */
+ OffsetTo<BaseCoord>
+ minCoord; /* Offset to BaseCoord table that defines
+ * the minimum extent value, from beginning
+ * of MinMax table (may be NULL) */
+ OffsetTo<BaseCoord>
+ maxCoord; /* Offset to BaseCoord table that defines
+ * the maximum extent value, from beginning
+ * of MinMax table (may be NULL) */
public:
DEFINE_SIZE_STATIC (8);
@@ -175,257 +194,205 @@ struct FeatMinMaxRecord
struct MinMax
{
- inline unsigned int get_feature_tag_index (Tag featureTableTag) const
- {
- /* TODO bsearch */
- unsigned int count = featMinMaxRecords.len;
- for (unsigned int i = 0; i < count; i++)
+ inline void get_min_max (hb_tag_t feature_tag,
+ const BaseCoord **min,
+ const BaseCoord **max) const
+ {
+ /* TODO Replace hb_bsearch() with .bsearch(). */
+ const FeatMinMaxRecord *minMaxCoord = (const FeatMinMaxRecord *)
+ hb_bsearch (&feature_tag, featMinMaxRecords.arrayZ,
+ featMinMaxRecords.len,
+ FeatMinMaxRecord::static_size,
+ FeatMinMaxRecord::cmp);
+ if (minMaxCoord)
+ minMaxCoord->get_min_max (min, max);
+ else
{
- Tag tag = featMinMaxRecords[i].get_tag ();
- int cmp = tag.cmp(featureTableTag);
- if (cmp == 0) return i;
- if (cmp > 0) return NOT_INDEXED;
+ if (likely (min)) *min = &(this+minCoord);
+ if (likely (max)) *max = &(this+maxCoord);
}
- return NOT_INDEXED;
- }
-
- inline int get_min_value (unsigned int featureTableTagIndex) const
- {
- if (featureTableTagIndex == NOT_INDEXED)
- return (this+minCoord).get_coord();
- return featMinMaxRecords[featureTableTagIndex].get_min_value();
- }
-
- inline int get_max_value (unsigned int featureTableTagIndex) const
- {
- if (featureTableTagIndex == NOT_INDEXED)
- return (this+maxCoord).get_coord();
- return featMinMaxRecords[featureTableTagIndex].get_max_value();
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- minCoord.sanitize (c, this) &&
- maxCoord.sanitize (c, this) &&
- featMinMaxRecords.sanitize (c, this));
+ return_trace (likely (c->check_struct (this) &&
+ minCoord.sanitize (c, this) &&
+ maxCoord.sanitize (c, this) &&
+ featMinMaxRecords.sanitize (c, this)));
}
protected:
- OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines
- * minimum extent value, from the beginning
- * of MinMax table (may be NULL) */
- OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines
- * maximum extent value, from the beginning
- * of MinMax table (may be NULL) */
- ArrayOf<FeatMinMaxRecord>
- featMinMaxRecords; /* Array of FeatMinMaxRecords, in alphabetical
- * order by featureTableTag */
+ OffsetTo<BaseCoord>
+ minCoord; /* Offset to BaseCoord table that defines
+ * minimum extent value, from the beginning
+ * of MinMax table (may be NULL) */
+ OffsetTo<BaseCoord>
+ maxCoord; /* Offset to BaseCoord table that defines
+ * maximum extent value, from the beginning
+ * of MinMax table (may be NULL) */
+ SortedArrayOf<FeatMinMaxRecord>
+ featMinMaxRecords;
+ /* Array of FeatMinMaxRecords, in alphabetical
+ * order by featureTableTag */
public:
DEFINE_SIZE_ARRAY (6, featMinMaxRecords);
};
-/* TODO... */
-struct BaseLangSysRecord
-{
- inline const Tag& get_tag(void) const
- { return baseLangSysTag; }
-
- inline unsigned int get_feature_tag_index (Tag featureTableTag) const
- { return (this+minMax).get_feature_tag_index( featureTableTag); }
-
- inline int get_min_value (unsigned int featureTableTagIndex) const
- { return (this+minMax).get_min_value( featureTableTagIndex); }
-
- inline int get_max_value (unsigned int featureTableTagIndex) const
- { return (this+minMax).get_max_value (featureTableTagIndex); }
-
- inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- minMax.sanitize (c, base));
- }
-
- protected:
- Tag baseLangSysTag;
- OffsetTo<MinMax> minMax;
- public:
- DEFINE_SIZE_STATIC (6);
-
-};
-
struct BaseValues
{
- inline unsigned int get_default_base_tag_index (void) const
- { return defaultIndex; }
-
- inline int get_base_coord (unsigned int baselineTagIndex) const
+ inline const BaseCoord &get_base_coord (int baseline_tag_index) const
{
- return (this+baseCoords[baselineTagIndex]).get_coord ();
+ if (baseline_tag_index == -1) baseline_tag_index = defaultIndex;
+ return this+baseCoords[baseline_tag_index];
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- baseCoords.sanitize (c, this));
+ return_trace (likely (c->check_struct (this) &&
+ baseCoords.sanitize (c, this)));
}
protected:
- Index defaultIndex;
- OffsetArrayOf<BaseCoord> baseCoords;
+ Index defaultIndex; /* Index number of default baseline for this
+ * script — equals index position of baseline tag
+ * in baselineTags array of the BaseTagList */
+ OffsetArrayOf<BaseCoord>
+ baseCoords; /* Number of BaseCoord tables defined — should equal
+ * baseTagCount in the BaseTagList
+ *
+ * Array of offsets to BaseCoord tables, from beginning of
+ * BaseValues table — order matches baselineTags array in
+ * the BaseTagList */
public:
DEFINE_SIZE_ARRAY (4, baseCoords);
};
-struct BaseScript {
-
- inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const
+struct BaseLangSysRecord
+{
+ static int cmp (const void *key_, const void *entry_)
{
- /* XXX bsearch */
- Tag tag;
- int cmp;
- unsigned int count = baseLangSysRecords.len;
- for (unsigned int i = 0; i < count; i++)
- {
- tag = baseLangSysRecords[i].get_tag ();
- // taking advantage of alphabetical order
- cmp = tag.cmp(baseLangSysTag);
- if (cmp == 0) return i;
- if (cmp > 0) return NOT_INDEXED;
- }
- return NOT_INDEXED;
+ hb_tag_t key = * (hb_tag_t *) key_;
+ const BaseLangSysRecord &entry = * (const BaseLangSysRecord *) entry_;
+ return key < (unsigned int) entry.baseLangSysTag ? -1 :
+ key > (unsigned int) entry.baseLangSysTag ? 1 :
+ 0;
}
- inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const
- {
- if (baseLangSysIndex == NOT_INDEXED)
- {
- if (unlikely(defaultMinMax)) return NOT_INDEXED;
- return (this+defaultMinMax).get_feature_tag_index (featureTableTag);
- }
- return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index (featureTableTag);
- }
+ inline const MinMax &get_min_max () const
+ { return this+minMax; }
- inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
- if (baseLangSysIndex == NOT_INDEXED)
- return (this+defaultMinMax).get_min_value (featureTableTagIndex);
- return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex);
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ minMax.sanitize (c, this)));
}
- inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
+ protected:
+ Tag baseLangSysTag; /* 4-byte language system identification tag */
+ OffsetTo<MinMax>
+ minMax; /* Offset to MinMax table, from beginning
+ * of BaseScript table */
+ public:
+ DEFINE_SIZE_STATIC (6);
+};
+
+struct BaseScript
+{
+ inline const MinMax &get_min_max (hb_tag_t language_tag) const
{
- if (baseLangSysIndex == NOT_INDEXED)
- return (this+defaultMinMax).get_min_value (featureTableTagIndex);
- return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex);
+ /* TODO Replace hb_bsearch() with .bsearch(). */
+ const BaseLangSysRecord* record = (const BaseLangSysRecord *)
+ hb_bsearch (&language_tag, baseLangSysRecords.arrayZ,
+ baseLangSysRecords.len,
+ BaseLangSysRecord::static_size,
+ BaseLangSysRecord::cmp);
+ return record ? record->get_min_max () : this+defaultMinMax;
}
- inline unsigned int get_default_base_tag_index (void) const
- { return (this+baseValues).get_default_base_tag_index (); }
+ inline const BaseCoord &get_base_coord (int baseline_tag_index) const
+ { return (this+baseValues).get_base_coord (baseline_tag_index); }
- inline int get_base_coord (unsigned int baselineTagIndex) const
- { return (this+baseValues).get_base_coord (baselineTagIndex); }
+ inline bool is_empty () const
+ { return !baseValues; }
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- baseValues.sanitize (c, this) &&
- defaultMinMax.sanitize (c, this) &&
- baseLangSysRecords.sanitize (c, this));
+ return_trace (likely (c->check_struct (this) &&
+ baseValues.sanitize (c, this) &&
+ defaultMinMax.sanitize (c, this) &&
+ baseLangSysRecords.sanitize (c, this)));
}
protected:
- OffsetTo<BaseValues> baseValues;
- OffsetTo<MinMax> defaultMinMax;
- ArrayOf<BaseLangSysRecord> baseLangSysRecords;
+ OffsetTo<BaseValues>
+ baseValues; /* Offset to BaseValues table, from beginning
+ * of BaseScript table (may be NULL) */
+ OffsetTo<MinMax>
+ defaultMinMax; /* Offset to MinMax table, from beginning of
+ * BaseScript table (may be NULL) */
+ SortedArrayOf<BaseLangSysRecord>
+ baseLangSysRecords;
+ /* Number of BaseLangSysRecords
+ * defined — may be zero (0) */
public:
- DEFINE_SIZE_ARRAY (6, baseLangSysRecords);
+ DEFINE_SIZE_ARRAY (6, baseLangSysRecords);
};
+struct BaseScriptList;
+struct BaseScriptRecord
+{
+ static int cmp (const void *key_, const void *entry_)
+ {
+ hb_tag_t key = * (hb_tag_t *) key_;
+ const BaseScriptRecord &entry = * (const BaseScriptRecord *) entry_;
+ return key < (unsigned int) entry.baseScriptTag ? -1 :
+ key > (unsigned int) entry.baseScriptTag ? 1 :
+ 0;
+ }
-struct BaseScriptRecord {
-
- inline const Tag& get_tag (void) const
- { return baseScriptTag; }
-
- inline unsigned int get_default_base_tag_index(void) const
- { return (this+baseScript).get_default_base_tag_index (); }
-
- inline int get_base_coord(unsigned int baselineTagIndex) const
- { return (this+baseScript).get_base_coord (baselineTagIndex); }
-
- inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const
- { return (this+baseScript).get_lang_tag_index (baseLangSysTag); }
-
- inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const
- { return (this+baseScript).get_feature_tag_index (baseLangSysIndex, featureTableTag); }
-
- inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- { return (this+baseScript).get_max_value (baseLangSysIndex, featureTableTagIndex); }
-
- inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- { return (this+baseScript).get_min_value (baseLangSysIndex, featureTableTagIndex); }
+ inline const BaseScript &get_base_script (const BaseScriptList *list) const
+ { return list+baseScript; }
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- baseScript.sanitize (c, base));
+ return_trace (likely (c->check_struct (this) &&
+ baseScript.sanitize (c, base)));
}
protected:
- Tag baseScriptTag;
- OffsetTo<BaseScript> baseScript;
+ Tag baseScriptTag; /* 4-byte script identification tag */
+ OffsetTo<BaseScript>
+ baseScript; /* Offset to BaseScript table, from beginning
+ * of BaseScriptList */
public:
- DEFINE_SIZE_STATIC (6);
+ DEFINE_SIZE_STATIC (6);
};
-struct BaseScriptList {
-
- inline unsigned int get_base_script_index (Tag baseScriptTag) const
- {
- /* XXX bsearch? */
- unsigned int count = baseScriptRecords.len;
- for (unsigned int i = 0; i < count; i++)
- if (baseScriptRecords[i].get_tag() == baseScriptTag)
- return i;
- return NOT_INDEXED;
- }
-
- inline unsigned int get_default_base_tag_index (unsigned int baseScriptIndex) const
- {
- return baseScriptRecords[baseScriptIndex].get_default_base_tag_index();
- }
-
- inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const
- {
- return baseScriptRecords[baseScriptIndex].get_base_coord(baselineTagIndex);
- }
-
- inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const
+struct BaseScriptList
+{
+ inline const BaseScriptRecord *find_record (hb_tag_t script) const
{
- return baseScriptRecords[baseScriptIndex].get_lang_tag_index(baseLangSysTag);
+ /* TODO Replace hb_bsearch() with .bsearch(). */
+ return (const BaseScriptRecord *) hb_bsearch (&script, baseScriptRecords.arrayZ,
+ baseScriptRecords.len,
+ BaseScriptRecord::static_size,
+ BaseScriptRecord::cmp);
}
- inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const
+ /* TODO: Or client should handle fallback? */
+ inline const BaseScript &get_base_script (hb_tag_t script) const
{
- return baseScriptRecords[baseScriptIndex].get_feature_tag_index(baseLangSysIndex, featureTableTag);
- }
+ const BaseScriptRecord *record = find_record (script);
+ if (!record) record = find_record ((hb_script_t) HB_TAG ('D','F','L','T'));
- inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return baseScriptRecords[baseScriptIndex].get_max_value(baseLangSysIndex, featureTableTagIndex);
- }
-
- inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return baseScriptRecords[baseScriptIndex].get_min_value(baseLangSysIndex, featureTableTagIndex);
+ return record ? record->get_base_script (this) : Null (BaseScript);
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -436,86 +403,61 @@ struct BaseScriptList {
}
protected:
- ArrayOf<BaseScriptRecord> baseScriptRecords;
+ SortedArrayOf<BaseScriptRecord>
+ baseScriptRecords;
public:
DEFINE_SIZE_ARRAY (2, baseScriptRecords);
};
-struct BaseTagList
-{
- inline unsigned int get_tag_index (Tag baselineTag) const
- {
- /* TODO bsearch? */
- unsigned int count = baselineTags.len;
- for (unsigned int i = 0; i < count; i++)
- if (baselineTags[i] == baselineTag)
- return i;
- return NOT_INDEXED;
- }
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this));
- }
-
- protected:
- SortedArrayOf<Tag> baselineTags;
-
- public:
- DEFINE_SIZE_ARRAY (2, baselineTags);
-};
-
struct Axis
{
-
- inline unsigned int get_base_tag_index (Tag baselineTag) const
+ inline bool get_baseline (hb_ot_layout_baseline_t baseline,
+ hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ const BaseCoord **coord) const
{
- return (this+baseTagList).get_tag_index(baselineTag);
- }
+ const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag);
+ if (base_script.is_empty ()) return false;
- inline unsigned int get_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const
- {
- return (this+baseScriptList).get_default_base_tag_index(baseScriptIndex);
- }
+ if (likely (coord)) *coord = &base_script.get_base_coord ((this+baseTagList).bsearch (baseline));
- inline int get_base_coord (unsigned int baseScriptIndex, unsigned int baselineTagIndex) const
- {
- return (this+baseScriptList).get_base_coord(baseScriptIndex, baselineTagIndex);
+ return true;
}
- inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const
+ inline bool get_min_max (hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_tag_t feature_tag,
+ const BaseCoord **min_coord,
+ const BaseCoord **max_coord) const
{
- return (this+baseScriptList).get_lang_tag_index(baseScriptIndex, baseLangSysTag);
- }
+ const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag);
+ if (base_script.is_empty ()) return false;
- inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const
- {
- return (this+baseScriptList).get_feature_tag_index(baseScriptIndex, baseLangSysIndex, featureTableTag);
- }
+ base_script.get_min_max (language_tag).get_min_max (feature_tag, min_coord, max_coord);
- inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+baseScriptList).get_max_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
- }
-
- inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+baseScriptList).get_min_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
+ return true;
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- baseTagList.sanitize (c, this) &&
- baseScriptList.sanitize (c, this));
+ return_trace (likely (c->check_struct (this) &&
+ (this+baseTagList).sanitize (c) &&
+ (this+baseScriptList).sanitize (c)));
}
protected:
- OffsetTo<BaseTagList> baseTagList;
- OffsetTo<BaseScriptList> baseScriptList;
+ OffsetTo<SortedArrayOf<Tag> >
+ baseTagList; /* Offset to BaseTagList table, from beginning
+ * of Axis table (may be NULL)
+ * Array of 4-byte baseline identification tags — must
+ * be in alphabetical order */
+ OffsetTo<BaseScriptList>
+ baseScriptList; /* Offset to BaseScriptList table, from beginning
+ * of Axis table
+ * Array of BaseScriptRecords, in alphabetical order
+ * by baseScriptTag */
public:
DEFINE_SIZE_STATIC (4);
@@ -525,99 +467,70 @@ struct BASE
{
static const hb_tag_t tableTag = HB_OT_TAG_BASE;
- inline bool has_v_axis(void) { return vAxis != 0; }
-
- inline bool has_h_axis(void) { return hAxis != 0; }
+ inline const Axis &get_axis (hb_direction_t direction) const
+ { return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; }
- inline unsigned int get_h_base_tag_index (Tag baselineTag) const
- {
- return (this+hAxis).get_base_tag_index(baselineTag);
- }
+ inline const VariationStore &get_var_store () const
+ { return version.to_int () < 0x00010001u ? Null (VariationStore) : this+varStore; }
- inline unsigned int get_h_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const
+ inline bool get_baseline (hb_font_t *font,
+ hb_ot_layout_baseline_t baseline,
+ hb_direction_t direction,
+ hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_position_t *base) const
{
- return (this+hAxis).get_default_base_tag_index_for_script_index(baseScriptIndex);
- }
+ const BaseCoord *base_coord;
+ if (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord))
+ return false;
- inline int get_h_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const
- {
- return (this+hAxis).get_base_coord(baseScriptIndex, baselineTagIndex);
+ if (likely (base && base_coord)) *base = base_coord->get_coord (font,
+ get_var_store (),
+ direction);
+ return true;
}
- inline unsigned int get_v_base_tag_index(Tag baselineTag) const
+ /* TODO: Expose this separately sometime? */
+ inline bool get_min_max (hb_font_t *font,
+ hb_direction_t direction,
+ hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_tag_t feature_tag,
+ hb_position_t *min,
+ hb_position_t *max)
{
- return (this+vAxis).get_base_tag_index(baselineTag);
- }
+ const BaseCoord *min_coord, *max_coord;
+ if (!get_axis (direction).get_min_max (script_tag, language_tag, feature_tag,
+ &min_coord, &max_coord))
+ return false;
- inline unsigned int get_v_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const
- {
- return (this+vAxis).get_default_base_tag_index_for_script_index(baseScriptIndex);
- }
-
- inline int get_v_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const
- {
- return (this+vAxis).get_base_coord(baseScriptIndex, baselineTagIndex);
- }
-
- inline unsigned int get_h_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const
- {
- return (this+hAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag);
- }
-
- inline unsigned int get_h_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const
- {
- return (this+hAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag);
- }
-
- inline int get_h_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+hAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
- }
-
- inline int get_h_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+hAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
- }
-
- inline unsigned int get_v_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const
- {
- return (this+vAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag);
- }
-
- inline unsigned int get_v_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const
- {
- return (this+vAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag);
- }
-
- inline int get_v_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+vAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
- }
-
- inline int get_v_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const
- {
- return (this+vAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex);
+ const VariationStore &var_store = get_var_store ();
+ if (likely (min && min_coord)) *min = min_coord->get_coord (font, var_store, direction);
+ if (likely (max && max_coord)) *max = max_coord->get_coord (font, var_store, direction);
+ return true;
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- likely (version.major == 1) &&
- hAxis.sanitize (c, this) &&
- vAxis.sanitize (c, this) &&
- (version.to_int () < 0x00010001u || varStore.sanitize (c, this)));
+ return_trace (likely (c->check_struct (this) &&
+ likely (version.major == 1) &&
+ hAxis.sanitize (c, this) &&
+ vAxis.sanitize (c, this) &&
+ (version.to_int () < 0x00010001u || varStore.sanitize (c, this))));
}
protected:
- FixedVersion<> version;
- OffsetTo<Axis> hAxis;
- OffsetTo<Axis> vAxis;
+ FixedVersion<>version; /* Version of the BASE table */
+ OffsetTo<Axis>hAxis; /* Offset to horizontal Axis table, from beginning
+ * of BASE table (may be NULL) */
+ OffsetTo<Axis>vAxis; /* Offset to vertical Axis table, from beginning
+ * of BASE table (may be NULL) */
LOffsetTo<VariationStore>
- varStore; /* Offset to the table of Item Variation
- * Store--from beginning of BASE
- * header (may be NULL). Introduced
- * in version 0x00010001. */
+ varStore; /* Offset to the table of Item Variation
+ * Store--from beginning of BASE
+ * header (may be NULL). Introduced
+ * in version 0x00010001. */
public:
DEFINE_SIZE_MIN (8);
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-common.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-common.hh
index e5e996d4dd1..b5af73af64a 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-common.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-common.hh
@@ -51,6 +51,14 @@
#define HB_CLOSURE_MAX_STAGES 32
#endif
+#ifndef HB_MAX_SCRIPTS
+#define HB_MAX_SCRIPTS 500
+#endif
+
+#ifndef HB_MAX_LANGSYS
+#define HB_MAX_LANGSYS 2000
+#endif
+
namespace OT {
@@ -120,15 +128,7 @@ struct RecordArrayOf : SortedArrayOf<Record<Type> >
}
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;
- }
+ return this->bfind (tag, index, HB_BFIND_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
}
};
@@ -400,7 +400,7 @@ struct FeatureParamsSize
* same subfamily value. If this value is
* zero, the remaining fields in the array
* will be ignored. */
- HBUINT16 subfamilyNameID;/* If the preceding value is non-zero, this
+ NameID subfamilyNameID;/* If the preceding value is non-zero, this
* value must be set in the range 256 - 32767
* (inclusive). It records the value of a
* field in the name table, which must
@@ -473,7 +473,7 @@ struct FeatureParamsCharacterVariants
* specifies a string (or strings,
* for multiple languages) for a
* user-interface label for this
- * feature. (May be nullptr.) */
+ * feature. (May be NULL.) */
NameID featUITooltipTextNameID;/* The ‘name’ table name ID that
* specifies a string (or strings,
* for multiple languages) that an
@@ -483,7 +483,7 @@ struct FeatureParamsCharacterVariants
NameID sampleTextNameID; /* The ‘name’ table name ID that
* specifies sample text that
* illustrates the effect of this
- * feature. (May be nullptr.) */
+ * feature. (May be NULL.) */
HBUINT16 numNamedParameters; /* Number of named parameters. (May
* be zero.) */
NameID firstParamUILabelNameID;/* The first ‘name’ table name ID
@@ -518,7 +518,21 @@ struct FeatureParams
{
if (tag == HB_TAG ('s','i','z','e'))
return u.size;
- return Null(FeatureParamsSize);
+ return Null (FeatureParamsSize);
+ }
+
+ inline const FeatureParamsStylisticSet& get_stylistic_set_params (hb_tag_t tag) const
+ {
+ if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
+ return u.stylisticSet;
+ return Null (FeatureParamsStylisticSet);
+ }
+
+ inline const FeatureParamsCharacterVariants& get_character_variants_params (hb_tag_t tag) const
+ {
+ if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
+ return u.characterVariants;
+ return Null (FeatureParamsCharacterVariants);
}
private:
@@ -541,6 +555,8 @@ struct Feature
unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_tags /* OUT */) const
{ return lookupIndex.get_indexes (start_index, lookup_count, lookup_tags); }
+ inline void add_lookup_indexes_to (hb_set_t *lookup_indexes) const
+ { lookupIndex.add_indexes_to (lookup_indexes); }
inline const FeatureParams &get_feature_params (void) const
{ return this+featureParams; }
@@ -680,7 +696,7 @@ struct Lookup
for (unsigned int i = 0; i < count; i++) {
typename context_t::return_t r = get_subtable<TSubTable> (i).dispatch (c, lookup_type);
if (c->stop_sublookup_iteration (r))
- return_trace (r);
+ return_trace (r);
}
return_trace (c->default_return_value ());
}
@@ -704,7 +720,7 @@ struct Lookup
return_trace (true);
}
- /* Older compileres need this to NOT be locally defined in a function. */
+ /* Older compilers need this to NOT be locally defined in a function. */
template <typename TSubTable>
struct SubTableSubsetWrapper
{
@@ -766,7 +782,7 @@ struct Lookup
unsigned int type = get_subtable<TSubTable> (0).u.extension.get_type ();
unsigned int count = get_subtable_count ();
for (unsigned int i = 1; i < count; i++)
- if (get_subtable<TSubTable> (i).u.extension.get_type () != type)
+ if (get_subtable<TSubTable> (i).u.extension.get_type () != type)
return_trace (false);
}
return_trace (true);
@@ -778,11 +794,11 @@ struct Lookup
HBUINT16 lookupFlag; /* Lookup qualifiers */
ArrayOf<Offset16>
subTable; /* Array of SubTables */
- HBUINT16 markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets
+/*HBUINT16 markFilteringSetX[VAR];*//* Index (base 0) into GDEF mark glyph sets
* structure. This field is only present if bit
* UseMarkFilteringSet of lookup flags is set. */
public:
- DEFINE_SIZE_ARRAY2 (6, subTable, markFilteringSetX);
+ DEFINE_SIZE_ARRAY (6, subTable);
};
typedef OffsetListOf<Lookup> LookupList;
@@ -799,8 +815,8 @@ struct CoverageFormat1
private:
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{
- int i = glyphArray.bsearch (glyph_id);
- static_assert ((((unsigned int) -1) == NOT_COVERED), "");
+ unsigned int i;
+ glyphArray.bfind (glyph_id, &i, HB_BFIND_NOT_FOUND_STORE, NOT_COVERED);
return i;
}
@@ -830,7 +846,7 @@ struct CoverageFormat1
unsigned int count = glyphArray.len;
for (unsigned int i = 0; i < count; i++)
if (glyphs->has (glyphArray[i]))
- return true;
+ return true;
return false;
}
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
@@ -844,8 +860,8 @@ struct CoverageFormat1
public:
/* Older compilers need this to be public. */
struct Iter {
- inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
- inline void fini (void) {};
+ inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; }
+ inline void fini (void) {}
inline bool more (void) { return i < c->glyphArray.len; }
inline void next (void) { i++; }
inline hb_codepoint_t get_glyph (void) { return c->glyphArray[i]; }
@@ -872,12 +888,10 @@ struct CoverageFormat2
private:
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{
- int i = rangeRecord.bsearch (glyph_id);
- if (i != -1) {
- const RangeRecord &range = rangeRecord[i];
- return (unsigned int) range.value + (glyph_id - range.start);
- }
- return NOT_COVERED;
+ const RangeRecord &range = rangeRecord.bsearch (glyph_id);
+ return likely (range.start <= range.end) ?
+ (unsigned int) range.value + (glyph_id - range.start) :
+ NOT_COVERED;
}
inline bool serialize (hb_serialize_context_t *c,
@@ -896,7 +910,7 @@ struct CoverageFormat2
unsigned int num_ranges = 1;
for (unsigned int i = 1; i < num_glyphs; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
- num_ranges++;
+ num_ranges++;
rangeRecord.len.set (num_ranges);
if (unlikely (!c->extend (rangeRecord))) return_trace (false);
@@ -908,9 +922,9 @@ struct CoverageFormat2
range++;
rangeRecord[range].start = glyphs[i];
rangeRecord[range].value.set (i);
- rangeRecord[range].end = glyphs[i];
+ rangeRecord[range].end = glyphs[i];
} else {
- rangeRecord[range].end = glyphs[i];
+ rangeRecord[range].end = glyphs[i];
}
glyphs += num_glyphs;
return_trace (true);
@@ -928,7 +942,7 @@ struct CoverageFormat2
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
if (rangeRecord[i].intersects (glyphs))
- return true;
+ return true;
return false;
}
inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
@@ -940,9 +954,9 @@ struct CoverageFormat2
if (range.value <= index &&
index < (unsigned int) range.value + (range.end - range.start) &&
range.intersects (glyphs))
- return true;
+ return true;
else if (index < range.value)
- return false;
+ return false;
}
return false;
}
@@ -952,7 +966,7 @@ struct CoverageFormat2
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!rangeRecord[i].add_coverage (glyphs)))
- return false;
+ return false;
return true;
}
@@ -968,17 +982,17 @@ struct CoverageFormat2
j = c->rangeRecord.len ? c->rangeRecord[0].start : 0;
if (unlikely (c->rangeRecord[0].start > c->rangeRecord[0].end))
{
- /* Broken table. Skip. */
- i = c->rangeRecord.len;
+ /* Broken table. Skip. */
+ i = c->rangeRecord.len;
}
}
- inline void fini (void) {};
+ inline void fini (void) {}
inline bool more (void) { return i < c->rangeRecord.len; }
inline void next (void)
{
if (j >= c->rangeRecord[i].end)
{
- i++;
+ i++;
if (more ())
{
hb_codepoint_t old = j;
@@ -1036,7 +1050,7 @@ struct Coverage
unsigned int num_ranges = 1;
for (unsigned int i = 1; i < num_glyphs; i++)
if (glyphs[i - 1] + 1 != glyphs[i])
- num_ranges++;
+ num_ranges++;
u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2);
switch (u.format)
{
@@ -1092,9 +1106,9 @@ struct Coverage
struct Iter
{
- Iter (void) : format (0), u () {};
- inline void init (const Coverage &c_)
+ inline Iter (const Coverage &c_)
{
+ memset (this, 0, sizeof (*this));
format = c_.u.format;
switch (format)
{
@@ -1103,7 +1117,6 @@ struct Coverage
default: return;
}
}
- inline void fini (void) {}
inline bool more (void)
{
switch (format)
@@ -1171,10 +1184,7 @@ struct ClassDefFormat1
private:
inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
- unsigned int i = (unsigned int) (glyph_id - startGlyph);
- if (unlikely (i < classValue.len))
- return classValue[i];
- return 0;
+ return classValue[(unsigned int) (glyph_id - startGlyph)];
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -1190,7 +1200,7 @@ struct ClassDefFormat1
for (unsigned int i = 0; i < count; i++)
{
if (classValue[i])
- continue;
+ continue;
if (start != i)
if (unlikely (!glyphs->add_range (startGlyph + start, startGlyph + i)))
@@ -1209,10 +1219,7 @@ struct ClassDefFormat1
inline bool add_class (set_t *glyphs, unsigned int klass) const {
unsigned int count = classValue.len;
for (unsigned int i = 0; i < count; i++)
- {
- if (classValue[i] == klass)
- glyphs->add (startGlyph + i);
- }
+ if (classValue[i] == klass) glyphs->add (startGlyph + i);
return true;
}
@@ -1223,8 +1230,7 @@ struct ClassDefFormat1
hb_codepoint_t end = startGlyph + classValue.len;
for (hb_codepoint_t iter = startGlyph - 1;
hb_set_next (glyphs, &iter) && iter < end;)
- if (classValue[iter - start])
- return true;
+ if (classValue[iter - start]) return true;
return false;
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
@@ -1233,26 +1239,23 @@ struct ClassDefFormat1
{
/* Match if there's any glyph that is not listed! */
hb_codepoint_t g = HB_SET_VALUE_INVALID;
- if (!hb_set_next (glyphs, &g))
- return false;
- if (g < startGlyph)
- return true;
+ if (!hb_set_next (glyphs, &g)) return false;
+ if (g < startGlyph) return true;
g = startGlyph + count - 1;
- if (hb_set_next (glyphs, &g))
- return true;
+ if (hb_set_next (glyphs, &g)) return true;
/* Fall through. */
}
for (unsigned int i = 0; i < count; i++)
if (classValue[i] == klass && glyphs->has (startGlyph + i))
- return true;
+ return true;
return false;
}
protected:
- HBUINT16 classFormat; /* Format identifier--format = 1 */
- GlyphID startGlyph; /* First GlyphID of the classValueArray */
+ HBUINT16 classFormat; /* Format identifier--format = 1 */
+ GlyphID startGlyph; /* First GlyphID of the classValueArray */
ArrayOf<HBUINT16>
- classValue; /* Array of Class Values--one per GlyphID */
+ classValue; /* Array of Class Values--one per GlyphID */
public:
DEFINE_SIZE_ARRAY (6, classValue);
};
@@ -1264,10 +1267,7 @@ struct ClassDefFormat2
private:
inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
- int i = rangeRecord.bsearch (glyph_id);
- if (unlikely (i != -1))
- return rangeRecord[i].value;
- return 0;
+ return rangeRecord.bsearch (glyph_id).value;
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -1294,7 +1294,7 @@ struct ClassDefFormat2
for (unsigned int i = 0; i < count; i++)
{
if (rangeRecord[i].value == klass)
- if (unlikely (!rangeRecord[i].add_coverage (glyphs)))
+ if (unlikely (!rangeRecord[i].add_coverage (glyphs)))
return false;
}
return true;
@@ -1306,7 +1306,7 @@ struct ClassDefFormat2
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
if (rangeRecord[i].intersects (glyphs))
- return true;
+ return true;
return false;
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const
@@ -1325,12 +1325,12 @@ struct ClassDefFormat2
g = rangeRecord[i].end;
}
if (g != HB_SET_VALUE_INVALID && hb_set_next (glyphs, &g))
- return true;
+ return true;
/* Fall through. */
}
for (unsigned int i = 0; i < count; i++)
if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs))
- return true;
+ return true;
return false;
}
@@ -1461,7 +1461,7 @@ struct VarRegionAxis
struct VarRegionList
{
inline float evaluate (unsigned int region_index,
- int *coords, unsigned int coord_len) const
+ const int *coords, unsigned int coord_len) const
{
if (unlikely (region_index >= regionCount))
return 0.;
@@ -1475,7 +1475,7 @@ struct VarRegionList
int coord = i < coord_len ? coords[i] : 0;
float factor = axes[i].evaluate (coord);
if (factor == 0.f)
- return 0.;
+ return 0.;
v *= factor;
}
return v;
@@ -1506,7 +1506,7 @@ struct VarData
{ return itemCount * get_row_size (); }
inline float get_delta (unsigned int inner,
- int *coords, unsigned int coord_count,
+ const int *coords, unsigned int coord_count,
const VarRegionList &regions) const
{
if (unlikely (inner >= itemCount))
@@ -1541,25 +1541,26 @@ struct VarData
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- regionIndices.sanitize(c) &&
+ regionIndices.sanitize (c) &&
shortCount <= regionIndices.len &&
- c->check_array (&StructAfter<HBUINT8> (regionIndices),
- itemCount, get_row_size ()));
+ c->check_range (&StructAfter<HBUINT8> (regionIndices),
+ itemCount,
+ get_row_size ()));
}
protected:
HBUINT16 itemCount;
HBUINT16 shortCount;
ArrayOf<HBUINT16> regionIndices;
- UnsizedArrayOf<HBUINT8>bytesX;
+/*UnsizedArrayOf<HBUINT8>bytesX;*/
public:
- DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX);
+ DEFINE_SIZE_ARRAY (6, regionIndices);
};
struct VariationStore
{
inline float get_delta (unsigned int outer, unsigned int inner,
- int *coords, unsigned int coord_count) const
+ const int *coords, unsigned int coord_count) const
{
if (unlikely (outer >= dataSets.len))
return 0.;
@@ -1570,7 +1571,7 @@ struct VariationStore
}
inline float get_delta (unsigned int index,
- int *coords, unsigned int coord_count) const
+ const int *coords, unsigned int coord_count) const
{
unsigned int outer = index >> 16;
unsigned int inner = index & 0xFFFF;
@@ -1589,7 +1590,7 @@ struct VariationStore
protected:
HBUINT16 format;
LOffsetTo<VarRegionList> regions;
- OffsetArrayOf<VarData, HBUINT32> dataSets;
+ LOffsetArrayOf<VarData> dataSets;
public:
DEFINE_SIZE_ARRAY (8, dataSets);
};
@@ -1660,7 +1661,7 @@ struct ConditionSet
unsigned int count = conditions.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+conditions.arrayZ[i]).evaluate (coords, coord_len))
- return false;
+ return false;
return true;
}
@@ -1671,7 +1672,7 @@ struct ConditionSet
}
protected:
- OffsetArrayOf<Condition, HBUINT32> conditions;
+ LOffsetArrayOf<Condition> conditions;
public:
DEFINE_SIZE_ARRAY (2, conditions);
};
@@ -1918,7 +1919,7 @@ struct DeviceHeader
struct Device
{
- inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const
+ inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const
{
switch (u.b.format)
{
@@ -1930,7 +1931,7 @@ struct Device
return 0;
}
}
- inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const
+ inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const
{
switch (u.b.format)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gdef-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gdef-table.hh
index cad99a3d62e..a0ae27e75cb 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gdef-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gdef-table.hh
@@ -61,9 +61,10 @@ struct AttachList
const AttachPoint &points = this+attachPoint[index];
- if (point_count) {
- const HBUINT16 *array = points.sub_array (start_offset, point_count);
- unsigned int count = *point_count;
+ if (point_count)
+ {
+ hb_array_t<const HBUINT16> array = points.sub_array (start_offset, point_count);
+ unsigned int count = array.len;
for (unsigned int i = 0; i < count; i++)
point_array[i] = array[i];
}
@@ -123,10 +124,8 @@ struct CaretValueFormat2
inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{
hb_position_t x, y;
- if (font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, direction, &x, &y))
- return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
- else
- return 0;
+ font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, direction, &x, &y);
+ return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
}
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -218,9 +217,10 @@ struct LigGlyph
unsigned int *caret_count /* IN/OUT */,
hb_position_t *caret_array /* OUT */) const
{
- if (caret_count) {
- const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
- unsigned int count = *caret_count;
+ if (caret_count)
+ {
+ hb_array_t <const OffsetTo<CaretValue> > array = carets.sub_array (start_offset, caret_count);
+ unsigned int count = array.len;
for (unsigned int i = 0; i < count; i++)
caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store);
}
@@ -350,7 +350,7 @@ struct GDEF
ComponentGlyph = 4
};
- inline bool has_data (void) const { return version.to_int () != 0; }
+ inline bool has_data (void) const { return version.to_int (); }
inline bool has_glyph_classes (void) const { return glyphClassDef != 0; }
inline unsigned int get_glyph_class (hb_codepoint_t glyph) const
{ return (this+glyphClassDef).get_class (glyph); }
@@ -388,7 +388,7 @@ struct GDEF
{ return version.to_int () >= 0x00010003u ? this+varStore : Null(VariationStore); }
/* glyph_props is a 16-bit integer where the lower 8-bit have bits representing
- * glyph class and other bits, and high 8-bit gthe mark attachment type (if any).
+ * glyph class and other bits, and high 8-bit the mark attachment type (if any).
* Not to be confused with lookup_props which is very similar. */
inline unsigned int get_glyph_props (hb_codepoint_t glyph) const
{
@@ -408,17 +408,27 @@ struct GDEF
}
}
+ HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+ hb_face_t *face) const;
+
struct accelerator_t
{
- HB_INTERNAL inline void init (hb_face_t *face);
+ inline void init (hb_face_t *face)
+ {
+ this->table = hb_sanitize_context_t().reference_table<GDEF> (face);
+ if (unlikely (this->table->is_blacklisted (this->table.get_blob (), face)))
+ {
+ hb_blob_destroy (this->table.get_blob ());
+ this->table = hb_blob_get_empty ();
+ }
+ }
inline void fini (void)
{
- hb_blob_destroy (this->blob);
+ this->table.destroy ();
}
- hb_blob_t *blob;
- const GDEF *table;
+ hb_blob_ptr_t<GDEF> table;
};
inline unsigned int get_size (void) const
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gpos-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gpos-table.hh
index 1a96609d0ff..2589218de78 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gpos-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gpos-table.hh
@@ -53,7 +53,7 @@ enum attach_type_t {
typedef HBUINT16 Value;
-typedef Value ValueRecord[VAR];
+typedef UnsizedArrayOf<Value> ValueRecord;
struct ValueFormat : HBUINT16
{
@@ -103,56 +103,58 @@ struct ValueFormat : HBUINT16
inline unsigned int get_size (void) const
{ return get_len () * Value::static_size; }
- void apply_value (hb_ot_apply_context_t *c,
+ bool apply_value (hb_ot_apply_context_t *c,
const void *base,
const Value *values,
hb_glyph_position_t &glyph_pos) const
{
+ bool ret = false;
unsigned int format = *this;
- if (!format) return;
+ if (!format) return ret;
hb_font_t *font = c->font;
- hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
+ bool horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
- if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++));
- if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++));
+ if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++, &ret));
+ if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++, &ret));
if (format & xAdvance) {
- if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values));
+ if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values, &ret));
values++;
}
/* y_advance values grow downward but font-space grows upward, hence negation */
if (format & yAdvance) {
- if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_short (values));
+ if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_short (values, &ret));
values++;
}
- if (!has_device ()) return;
+ if (!has_device ()) return ret;
bool use_x_device = font->x_ppem || font->num_coords;
bool use_y_device = font->y_ppem || font->num_coords;
- if (!use_x_device && !use_y_device) return;
+ if (!use_x_device && !use_y_device) return ret;
const VariationStore &store = c->var_store;
/* pixel -> fractional pixel */
if (format & xPlaDevice) {
- if (use_x_device) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font, store);
+ if (use_x_device) glyph_pos.x_offset += (base + get_device (values, &ret)).get_x_delta (font, store);
values++;
}
if (format & yPlaDevice) {
- if (use_y_device) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font, store);
+ if (use_y_device) glyph_pos.y_offset += (base + get_device (values, &ret)).get_y_delta (font, store);
values++;
}
if (format & xAdvDevice) {
- if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font, store);
+ if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values, &ret)).get_x_delta (font, store);
values++;
}
if (format & yAdvDevice) {
/* y_advance values grow downward but font-space grows upward, hence negation */
- if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font, store);
+ if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values, &ret)).get_y_delta (font, store);
values++;
}
+ return ret;
}
private:
@@ -175,11 +177,17 @@ struct ValueFormat : HBUINT16
static inline OffsetTo<Device>& get_device (Value* value)
{ return *CastP<OffsetTo<Device> > (value); }
- static inline const OffsetTo<Device>& get_device (const Value* value)
- { return *CastP<OffsetTo<Device> > (value); }
+ static inline const OffsetTo<Device>& get_device (const Value* value, bool *worked=nullptr)
+ {
+ if (worked) *worked |= *value;
+ return *CastP<OffsetTo<Device> > (value);
+ }
- static inline const HBINT16& get_short (const Value* value)
- { return *CastP<HBINT16> (value); }
+ static inline const HBINT16& get_short (const Value* value, bool *worked=nullptr)
+ {
+ if (worked) *worked |= *value;
+ return *CastP<HBINT16> (value);
+ }
public:
@@ -199,13 +207,13 @@ struct ValueFormat : HBUINT16
TRACE_SANITIZE (this);
unsigned int len = get_len ();
- if (!c->check_array (values, count, get_size ())) return_trace (false);
+ if (!c->check_range (values, count, get_size ())) return_trace (false);
if (!has_device ()) return_trace (true);
for (unsigned int i = 0; i < count; i++) {
if (!sanitize_value_devices (c, base, values))
- return_trace (false);
+ return_trace (false);
values += len;
}
@@ -221,7 +229,7 @@ struct ValueFormat : HBUINT16
for (unsigned int i = 0; i < count; i++) {
if (!sanitize_value_devices (c, base, values))
- return_trace (false);
+ return_trace (false);
values += stride;
}
@@ -263,10 +271,10 @@ struct AnchorFormat2
unsigned int x_ppem = font->x_ppem;
unsigned int y_ppem = font->y_ppem;
hb_position_t cx = 0, cy = 0;
- hb_bool_t ret;
+ bool ret;
ret = (x_ppem || y_ppem) &&
- font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
+ font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
*x = ret && x_ppem ? cx : font->em_fscale_x (xCoordinate);
*y = ret && y_ppem ? cy : font->em_fscale_y (yCoordinate);
}
@@ -626,7 +634,7 @@ struct PairSet
for (unsigned int i = 0; i < count; i++)
{
if (glyphs->has (record->secondGlyph))
- return true;
+ return true;
record = &StructAtOffset<const PairValueRecord> (record, record_size);
}
return false;
@@ -663,18 +671,19 @@ struct PairSet
int min = 0, max = (int) count - 1;
while (min <= max)
{
- int mid = (min + max) / 2;
+ int mid = ((unsigned int) min + (unsigned int) max) / 2;
const PairValueRecord *record = &StructAtOffset<PairValueRecord> (&firstPairValueRecord, record_size * mid);
hb_codepoint_t mid_x = record->secondGlyph;
if (x < mid_x)
- max = mid - 1;
+ max = mid - 1;
else if (x > mid_x)
- min = mid + 1;
+ min = mid + 1;
else
{
- buffer->unsafe_to_break (buffer->idx, pos + 1);
- valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos());
- valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]);
+ /* Note the intentional use of "|" instead of short-circuit "||". */
+ if (valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos()) |
+ valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]))
+ buffer->unsafe_to_break (buffer->idx, pos + 1);
if (len2)
pos++;
buffer->idx = pos;
@@ -697,7 +706,10 @@ struct PairSet
{
TRACE_SANITIZE (this);
if (!(c->check_struct (this)
- && c->check_array (&firstPairValueRecord, len, HBUINT16::static_size * closure->stride))) return_trace (false);
+ && c->check_range (&firstPairValueRecord,
+ len,
+ HBUINT16::static_size,
+ closure->stride))) return_trace (false);
unsigned int count = len;
const PairValueRecord *record = &firstPairValueRecord;
@@ -719,13 +731,13 @@ struct PairPosFormat1
inline bool intersects (const hb_set_t *glyphs) const
{
unsigned int count = pairSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (glyphs->has (iter.get_glyph ()) &&
(this+pairSet[iter.get_coverage ()]).intersects (glyphs, valueFormat))
- return true;
+ return true;
}
return false;
}
@@ -837,10 +849,11 @@ struct PairPosFormat2
unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false);
- buffer->unsafe_to_break (buffer->idx, skippy_iter.idx + 1);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
- valueFormat1.apply_value (c, this, v, buffer->cur_pos());
- valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]);
+ /* Note the intentional use of "|" instead of short-circuit "||". */
+ if (valueFormat1.apply_value (c, this, v, buffer->cur_pos()) |
+ valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]))
+ buffer->unsafe_to_break (buffer->idx, skippy_iter.idx + 1);
buffer->idx = skippy_iter.idx;
if (len2)
@@ -869,7 +882,9 @@ struct PairPosFormat2
unsigned int stride = len1 + len2;
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
- return_trace (c->check_array (values, count, record_size) &&
+ return_trace (c->check_range ((const void *) values,
+ count,
+ record_size) &&
valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride));
}
@@ -973,22 +988,22 @@ struct CursivePosFormat1
hb_buffer_t *buffer = c->buffer;
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
- if (!this_record.exitAnchor) return_trace (false);
+ if (!this_record.entryAnchor) return_trace (false);
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
- if (!skippy_iter.next ()) return_trace (false);
+ if (!skippy_iter.prev ()) return_trace (false);
- const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
- if (!next_record.entryAnchor) return_trace (false);
+ const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
+ if (!prev_record.exitAnchor) return_trace (false);
- unsigned int i = buffer->idx;
- unsigned int j = skippy_iter.idx;
+ unsigned int i = skippy_iter.idx;
+ unsigned int j = buffer->idx;
buffer->unsafe_to_break (i, j);
float entry_x, entry_y, exit_x, exit_y;
- (this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
- (this+next_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
+ (this+prev_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
+ (this+this_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
hb_glyph_position_t *pos = buffer->pos;
@@ -1035,7 +1050,7 @@ struct CursivePosFormat1
* parent.
*
* Optimize things for the case of RightToLeft, as that's most common in
- * Arabinc. */
+ * Arabic. */
unsigned int child = i;
unsigned int parent = j;
hb_position_t x_offset = entry_x - exit_x;
@@ -1064,7 +1079,7 @@ struct CursivePosFormat1
else
pos[child].x_offset = x_offset;
- buffer->idx = j;
+ buffer->idx++;
return_trace (true);
}
@@ -1164,7 +1179,7 @@ struct MarkBasePosFormat1
))
break;
skippy_iter.reject ();
- } while (1);
+ } while (true);
/* Checking that matched glyph is actually a base glyph by GDEF is too strong; disabled */
//if (!_hb_glyph_info_is_base_glyph (&buffer->info[skippy_iter.idx])) { return_trace (false); }
@@ -1406,7 +1421,7 @@ struct MarkMarkPosFormat1
if (id1 == 0) /* Marks belonging to the same base. */
goto good;
else if (comp1 == comp2) /* Marks belonging to the same ligature component. */
- goto good;
+ goto good;
} else {
/* If ligature ids don't match, it may be the case that one of the marks
* itself is a ligature. In which case match. */
@@ -1628,6 +1643,9 @@ struct GPOS : GSUBGPOS
inline bool sanitize (hb_sanitize_context_t *c) const
{ return GSUBGPOS::sanitize<PosLookup> (c); }
+ HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+ hb_face_t *face) const;
+
typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t;
};
@@ -1658,7 +1676,10 @@ reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direc
pos[j].attach_type() = type;
}
static void
-propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction)
+propagate_attachment_offsets (hb_glyph_position_t *pos,
+ unsigned int len,
+ unsigned int i,
+ hb_direction_t direction)
{
/* Adjusts offsets of attached glyphs (both cursive and mark) to accumulate
* offset of glyph they are attached to. */
@@ -1666,11 +1687,14 @@ propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int i, hb_direc
if (likely (!chain))
return;
+ pos[i].attach_chain() = 0;
+
unsigned int j = (int) i + chain;
- pos[i].attach_chain() = 0;
+ if (unlikely (j >= len))
+ return;
- propagate_attachment_offsets (pos, j, direction);
+ propagate_attachment_offsets (pos, len, j, direction);
assert (!!(type & ATTACH_TYPE_MARK) ^ !!(type & ATTACH_TYPE_CURSIVE));
@@ -1709,7 +1733,7 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
}
void
-GPOS::position_finish_advances (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
+GPOS::position_finish_advances (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSED)
{
//_hb_buffer_assert_gsubgpos_vars (buffer);
}
@@ -1726,22 +1750,25 @@ GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
/* Handle attachments */
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT)
for (unsigned int i = 0; i < len; i++)
- propagate_attachment_offsets (pos, i, direction);
+ propagate_attachment_offsets (pos, len, i, direction);
}
+struct GPOS_accelerator_t : GPOS::accelerator_t {};
+
+
/* Out-of-class implementation for methods recursing */
template <typename context_t>
/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
- const PosLookup &l = _get_gpos_relaxed (c->face)->get_lookup (lookup_index);
+ const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
- const PosLookup &l = _get_gpos_relaxed (c->face).get_lookup (lookup_index);
+ const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@@ -1752,12 +1779,6 @@ template <typename context_t>
return ret;
}
-struct GPOS_accelerator_t : GPOS::accelerator_t {};
-
-
-#undef attach_chain
-#undef attach_type
-
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsub-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsub-table.hh
index b664f15a617..27bd440dabf 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsub-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsub-table.hh
@@ -48,7 +48,7 @@ struct SingleSubstFormat1
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
* https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -62,7 +62,7 @@ struct SingleSubstFormat1
{
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
* https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -103,17 +103,17 @@ struct SingleSubstFormat1
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false);
- deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */
+ deltaGlyphID.set (delta); /* TODO(serialize) overflow? */
return_trace (true);
}
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
- hb_auto_t<hb_vector_t<GlyphID> > from;
- hb_auto_t<hb_vector_t<GlyphID> > to;
+ hb_vector_t<GlyphID> from;
+ hb_vector_t<GlyphID> to;
hb_codepoint_t delta = deltaGlyphID;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (!c->plan->glyphset->has (iter.get_glyph ()))
continue;
@@ -157,7 +157,7 @@ struct SingleSubstFormat2
{
TRACE_CLOSURE (this);
unsigned int count = substitute.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -171,7 +171,7 @@ struct SingleSubstFormat2
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = substitute.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -216,9 +216,9 @@ struct SingleSubstFormat2
inline bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
- hb_auto_t<hb_vector_t<GlyphID> > from;
- hb_auto_t<hb_vector_t<GlyphID> > to;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ hb_vector_t<GlyphID> from;
+ hb_vector_t<GlyphID> to;
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (!c->plan->glyphset->has (iter.get_glyph ()))
continue;
@@ -395,7 +395,7 @@ struct MultipleSubstFormat1
{
TRACE_CLOSURE (this);
unsigned int count = sequence.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -585,10 +585,10 @@ struct AlternateSubstFormat1
{
TRACE_CLOSURE (this);
unsigned int count = alternateSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+alternateSet[iter.get_coverage ()]).closure (c);
}
@@ -599,10 +599,10 @@ struct AlternateSubstFormat1
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = alternateSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
(this+alternateSet[iter.get_coverage ()]).collect_glyphs (c);
}
}
@@ -906,7 +906,7 @@ struct LigatureSubstFormat1
inline bool intersects (const hb_set_t *glyphs) const
{
unsigned int count = ligatureSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -921,7 +921,7 @@ struct LigatureSubstFormat1
{
TRACE_CLOSURE (this);
unsigned int count = ligatureSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -935,7 +935,7 @@ struct LigatureSubstFormat1
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = ligatureSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -1114,7 +1114,7 @@ struct ReverseChainSingleSubstFormat1
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
count = substitute.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
@@ -1449,7 +1449,10 @@ struct SubstLookup : Lookup
hb_closure_context_t::return_t ret = dispatch_recurse_func (c, lookup_index);
- c->flush ();
+ /* While in theory we should flush here, it will cause timeouts because a recursive
+ * lookup can keep growing the glyph set. Skip, and outer loop will retry up to
+ * HB_CLOSURE_MAX_STAGES time, which should be enough for every realistic font. */
+ //c->flush ();
return ret;
}
@@ -1483,10 +1486,16 @@ struct GSUB : GSUBGPOS
inline bool sanitize (hb_sanitize_context_t *c) const
{ return GSUBGPOS::sanitize<SubstLookup> (c); }
+ HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+ hb_face_t *face) const;
+
typedef GSUBGPOS::accelerator_t<GSUB> accelerator_t;
};
+struct GSUB_accelerator_t : GSUB::accelerator_t {};
+
+
/* Out-of-class implementation for methods recursing */
/*static*/ inline bool ExtensionSubst::is_reverse (void) const
@@ -1500,13 +1509,13 @@ struct GSUB : GSUBGPOS
template <typename context_t>
/*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
{
- const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
+ const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
return l.dispatch (c);
}
/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
- const SubstLookup &l = _get_gsub_relaxed (c->face).get_lookup (lookup_index);
+ const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
unsigned int saved_lookup_props = c->lookup_props;
unsigned int saved_lookup_index = c->lookup_index;
c->set_lookup_index (lookup_index);
@@ -1517,8 +1526,6 @@ template <typename context_t>
return ret;
}
-struct GSUB_accelerator_t : GSUB::accelerator_t {};
-
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh
index bdaf35a959d..a9bfee155d8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout-gsubgpos.hh
@@ -93,21 +93,21 @@ struct hb_closure_context_t :
hb_face_t *face;
hb_set_t *glyphs;
- hb_auto_t<hb_set_t> out[1];
+ hb_set_t out[1];
recurse_func_t recurse_func;
unsigned int nesting_level_left;
unsigned int debug_depth;
hb_closure_context_t (hb_face_t *face_,
hb_set_t *glyphs_,
- hb_map_t *done_lookups_,
- unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
+ hb_map_t *done_lookups_,
+ unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
face (face_),
glyphs (glyphs_),
recurse_func (nullptr),
nesting_level_left (nesting_level_left_),
debug_depth (0),
- done_lookups (done_lookups_) {}
+ done_lookups (done_lookups_) {}
~hb_closure_context_t (void)
{
@@ -199,8 +199,6 @@ struct hb_collect_glyphs_context_t :
after = old_after;
recursed_lookups->add (lookup_index);
-
- return;
}
hb_face_t *face;
@@ -214,10 +212,10 @@ struct hb_collect_glyphs_context_t :
unsigned int debug_depth;
hb_collect_glyphs_context_t (hb_face_t *face_,
- hb_set_t *glyphs_before, /* OUT. May be nullptr */
- hb_set_t *glyphs_input, /* OUT. May be nullptr */
- hb_set_t *glyphs_after, /* OUT. May be nullptr */
- hb_set_t *glyphs_output, /* OUT. May be nullptr */
+ hb_set_t *glyphs_before, /* OUT. May be NULL */
+ hb_set_t *glyphs_input, /* OUT. May be NULL */
+ hb_set_t *glyphs_after, /* OUT. May be NULL */
+ hb_set_t *glyphs_output, /* OUT. May be NULL */
unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) :
face (face_),
before (glyphs_before ? glyphs_before : hb_set_get_empty ()),
@@ -273,7 +271,7 @@ struct hb_ot_apply_context_t :
syllable arg1(0),
#undef arg1
match_func (nullptr),
- match_data (nullptr) {};
+ match_data (nullptr) {}
typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const HBUINT16 &value, const void *data);
@@ -293,14 +291,14 @@ struct hb_ot_apply_context_t :
};
inline may_match_t may_match (const hb_glyph_info_t &info,
- const HBUINT16 *glyph_data) const
+ const HBUINT16 *glyph_data) const
{
if (!(info.mask & mask) ||
(syllable && syllable != info.syllable ()))
return MATCH_NO;
if (match_func)
- return match_func (info.codepoint, *glyph_data, match_data) ? MATCH_YES : MATCH_NO;
+ return match_func (info.codepoint, *glyph_data, match_data) ? MATCH_YES : MATCH_NO;
return MATCH_MAYBE;
}
@@ -493,7 +491,7 @@ struct hb_ot_apply_context_t :
iter_input (), iter_context (),
font (font_), face (font->face), buffer (buffer_),
recurse_func (nullptr),
- gdef (_get_gdef (face)),
+ gdef (*face->table.GDEF->table),
var_store (gdef.get_var_store ()),
direction (buffer_->props.direction),
lookup_mask (1),
@@ -582,7 +580,7 @@ struct hb_ot_apply_context_t :
add_in |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED;
/* In the only place that the MULTIPLIED bit is used, Uniscribe
* seems to only care about the "last" transformation between
- * Ligature and Multiple substitions. Ie. if you ligate, expand,
+ * Ligature and Multiple substitutions. Ie. if you ligate, expand,
* and ligate again, it forgives the multiplication and acts as
* if only ligation happened. As such, clear MULTIPLIED bit.
*/
@@ -621,6 +619,64 @@ struct hb_ot_apply_context_t :
};
+struct hb_get_subtables_context_t :
+ hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
+{
+ template <typename Type>
+ static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
+ {
+ const Type *typed_obj = (const Type *) obj;
+ return typed_obj->apply (c);
+ }
+
+ typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
+
+ struct hb_applicable_t
+ {
+ template <typename T>
+ inline void init (const T &obj_, hb_apply_func_t apply_func_)
+ {
+ obj = &obj_;
+ apply_func = apply_func_;
+ digest.init ();
+ obj_.get_coverage ().add_coverage (&digest);
+ }
+
+ inline bool apply (OT::hb_ot_apply_context_t *c) const
+ {
+ return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c);
+ }
+
+ private:
+ const void *obj;
+ hb_apply_func_t apply_func;
+ hb_set_digest_t digest;
+ };
+
+ typedef hb_vector_t<hb_applicable_t, 2> array_t;
+
+ /* Dispatch interface. */
+ inline const char *get_name (void) { return "GET_SUBTABLES"; }
+ template <typename T>
+ inline return_t dispatch (const T &obj)
+ {
+ hb_applicable_t *entry = array.push();
+ entry->init (obj, apply_to<T>);
+ return HB_VOID;
+ }
+ static return_t default_return_value (void) { return HB_VOID; }
+ bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
+
+ hb_get_subtables_context_t (array_t &array_) :
+ array (array_),
+ debug_depth (0) {}
+
+ array_t &array;
+ unsigned int debug_depth;
+};
+
+
+
typedef bool (*intersects_func_t) (const hb_set_t *glyphs, const HBUINT16 &value, const void *data);
typedef void (*collect_glyphs_func_t) (hb_set_t *glyphs, const HBUINT16 &value, const void *data);
@@ -796,9 +852,9 @@ static inline bool match_input (hb_ot_apply_context_t *c,
* component, otherwise we shouldn't ligate them... */
if (first_lig_id != this_lig_id || first_lig_comp != this_lig_comp)
{
- /* ...unless, we are attached to a base ligature and that base
+ /* ...unless, we are attached to a base ligature and that base
* ligature is ignorable. */
- if (ligbase == LIGBASE_NOT_CHECKED)
+ if (ligbase == LIGBASE_NOT_CHECKED)
{
bool found = false;
const hb_glyph_info_t *out = buffer->out_info;
@@ -820,7 +876,7 @@ static inline bool match_input (hb_ot_apply_context_t *c,
ligbase = LIGBASE_MAY_NOT_SKIP;
}
- if (ligbase == LIGBASE_MAY_NOT_SKIP)
+ if (ligbase == LIGBASE_MAY_NOT_SKIP)
return_trace (false);
}
}
@@ -845,7 +901,7 @@ static inline bool match_input (hb_ot_apply_context_t *c,
}
static inline bool ligate_input (hb_ot_apply_context_t *c,
unsigned int count, /* Including the first glyph */
- unsigned int match_positions[HB_MAX_CONTEXT_LENGTH], /* Including the first glyph */
+ const unsigned int match_positions[HB_MAX_CONTEXT_LENGTH], /* Including the first glyph */
unsigned int match_length,
hb_codepoint_t lig_glyph,
unsigned int total_component_count)
@@ -921,7 +977,7 @@ static inline bool ligate_input (hb_ot_apply_context_t *c,
{
if (is_ligature)
{
- unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
+ unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
if (this_comp == 0)
this_comp = last_num_components;
unsigned int new_lig_comp = components_so_far - last_num_components +
@@ -943,7 +999,7 @@ static inline bool ligate_input (hb_ot_apply_context_t *c,
/* Re-adjust components for any marks following. */
for (unsigned int i = buffer->idx; i < buffer->len; i++) {
if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) {
- unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]);
+ unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]);
if (!this_comp)
break;
unsigned int new_lig_comp = components_so_far - last_num_components +
@@ -1077,7 +1133,7 @@ static inline bool apply_lookup (hb_ot_apply_context_t *c,
int delta = new_len - orig_len;
if (!delta)
- continue;
+ continue;
/* Recursed lookup changed buffer len. Adjust.
*
@@ -1252,7 +1308,8 @@ struct Rule
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array ((inputCount ? inputCount - 1 : 0)));
context_closure_lookup (c,
inputCount, inputZ.arrayZ,
lookupCount, lookupRecord.arrayZ,
@@ -1262,7 +1319,8 @@ struct Rule
inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
{
TRACE_COLLECT_GLYPHS (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
context_collect_glyphs_lookup (c,
inputCount, inputZ.arrayZ,
lookupCount, lookupRecord.arrayZ,
@@ -1272,14 +1330,16 @@ struct Rule
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_WOULD_APPLY (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
return_trace (context_would_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_APPLY (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
@@ -1316,7 +1376,7 @@ struct RuleSet
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).intersects (glyphs, lookup_context))
- return true;
+ return true;
return false;
}
@@ -1343,7 +1403,7 @@ struct RuleSet
for (unsigned int i = 0; i < num_rules; i++)
{
if ((this+rule[i]).would_apply (c, lookup_context))
- return_trace (true);
+ return_trace (true);
}
return_trace (false);
}
@@ -1355,7 +1415,7 @@ struct RuleSet
for (unsigned int i = 0; i < num_rules; i++)
{
if ((this+rule[i]).apply (c, lookup_context))
- return_trace (true);
+ return_trace (true);
}
return_trace (false);
}
@@ -1385,13 +1445,13 @@ struct ContextFormat1
};
unsigned int count = ruleSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (glyphs->has (iter.get_glyph ()) &&
(this+ruleSet[iter.get_coverage ()]).intersects (glyphs, lookup_context))
- return true;
+ return true;
}
return false;
}
@@ -1406,10 +1466,10 @@ struct ContextFormat1
};
unsigned int count = ruleSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+ruleSet[iter.get_coverage ()]).closure (c, lookup_context);
}
@@ -1504,7 +1564,7 @@ struct ContextFormat2
for (unsigned int i = 0; i < count; i++)
if (class_def.intersects_class (glyphs, i) &&
(this+ruleSet[i]).intersects (glyphs, lookup_context))
- return true;
+ return true;
return false;
}
@@ -1630,7 +1690,7 @@ struct ContextFormat3
if (!(this+coverageZ[0]).intersects (c->glyphs))
return;
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextClosureLookupContext lookup_context = {
{intersects_coverage},
this
@@ -1646,7 +1706,7 @@ struct ContextFormat3
TRACE_COLLECT_GLYPHS (this);
(this+coverageZ[0]).add_coverage (c->input);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextCollectGlyphsLookupContext lookup_context = {
{collect_coverage},
this
@@ -1662,7 +1722,7 @@ struct ContextFormat3
{
TRACE_WOULD_APPLY (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
@@ -1679,7 +1739,7 @@ struct ContextFormat3
unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
@@ -1703,7 +1763,7 @@ struct ContextFormat3
if (!c->check_array (coverageZ.arrayZ, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!coverageZ[i].sanitize (c, this)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * count);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
return_trace (c->check_array (lookupRecord, lookupCount));
}
@@ -1808,15 +1868,15 @@ static inline void chain_context_closure_lookup (hb_closure_context_t *c,
}
static inline void chain_context_collect_glyphs_lookup (hb_collect_glyphs_context_t *c,
- unsigned int backtrackCount,
- const HBUINT16 backtrack[],
- unsigned int inputCount, /* Including the first glyph (not matched) */
- const HBUINT16 input[], /* Array of input values--start with second glyph */
- unsigned int lookaheadCount,
- const HBUINT16 lookahead[],
- unsigned int lookupCount,
- const LookupRecord lookupRecord[],
- ChainContextCollectGlyphsLookupContext &lookup_context)
+ unsigned int backtrackCount,
+ const HBUINT16 backtrack[],
+ unsigned int inputCount, /* Including the first glyph (not matched) */
+ const HBUINT16 input[], /* Array of input values--start with second glyph */
+ unsigned int lookaheadCount,
+ const HBUINT16 lookahead[],
+ unsigned int lookupCount,
+ const LookupRecord lookupRecord[],
+ ChainContextCollectGlyphsLookupContext &lookup_context)
{
collect_array (c, c->before,
backtrackCount, backtrack,
@@ -1874,10 +1934,10 @@ static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c,
lookup_context.funcs.match, lookup_context.match_data[2],
match_length, &end_index)
&& (c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index),
- apply_lookup (c,
- inputCount, match_positions,
- lookupCount, lookupRecord,
- match_length));
+ apply_lookup (c,
+ inputCount, match_positions,
+ lookupCount, lookupRecord,
+ match_length));
}
struct ChainRule
@@ -1984,7 +2044,7 @@ struct ChainRuleSet
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).intersects (glyphs, lookup_context))
- return true;
+ return true;
return false;
}
inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
@@ -2009,7 +2069,7 @@ struct ChainRuleSet
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).would_apply (c, lookup_context))
- return_trace (true);
+ return_trace (true);
return_trace (false);
}
@@ -2020,7 +2080,7 @@ struct ChainRuleSet
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if ((this+rule[i]).apply (c, lookup_context))
- return_trace (true);
+ return_trace (true);
return_trace (false);
}
@@ -2049,13 +2109,13 @@ struct ChainContextFormat1
};
unsigned int count = ruleSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (glyphs->has (iter.get_glyph ()) &&
(this+ruleSet[iter.get_coverage ()]).intersects (glyphs, lookup_context))
- return true;
+ return true;
}
return false;
}
@@ -2070,10 +2130,10 @@ struct ChainContextFormat1
};
unsigned int count = ruleSet.len;
- for (hb_auto_t<Coverage::Iter> iter (this+coverage); iter.more (); iter.next ())
+ for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+ruleSet[iter.get_coverage ()]).closure (c, lookup_context);
}
@@ -2170,7 +2230,7 @@ struct ChainContextFormat2
for (unsigned int i = 0; i < count; i++)
if (input_class_def.intersects_class (glyphs, i) &&
(this+ruleSet[i]).intersects (glyphs, lookup_context))
- return true;
+ return true;
return false;
}
@@ -2562,9 +2622,42 @@ struct Extension
* GSUB/GPOS Common
*/
+struct hb_ot_layout_lookup_accelerator_t
+{
+ template <typename TLookup>
+ inline void init (const TLookup &lookup)
+ {
+ digest.init ();
+ lookup.add_coverage (&digest);
+
+ subtables.init ();
+ OT::hb_get_subtables_context_t c_get_subtables (subtables);
+ lookup.dispatch (&c_get_subtables);
+ }
+ inline void fini (void)
+ {
+ subtables.fini ();
+ }
+
+ inline bool may_have (hb_codepoint_t g) const
+ { return digest.may_have (g); }
+
+ inline bool apply (hb_ot_apply_context_t *c) const
+ {
+ for (unsigned int i = 0; i < subtables.len; i++)
+ if (subtables[i].apply (c))
+ return true;
+ return false;
+ }
+
+ private:
+ hb_set_digest_t digest;
+ hb_get_subtables_context_t::array_t subtables;
+};
+
struct GSUBGPOS
{
- inline bool has_data (void) const { return version.to_int () != 0; }
+ inline bool has_data (void) const { return version.to_int (); }
inline unsigned int get_script_count (void) const
{ return (this+scriptList).len; }
inline const Tag& get_script_tag (unsigned int i) const
@@ -2609,7 +2702,7 @@ struct GSUBGPOS
const Feature *feature = (this+featureVars).find_substitute (variations_index,
feature_index);
if (feature)
- return *feature;
+ return *feature;
}
return get_feature (feature_index);
}
@@ -2659,14 +2752,18 @@ struct GSUBGPOS
{
inline void init (hb_face_t *face)
{
- this->blob = hb_sanitize_context_t().reference_table<T> (face);
- table = this->blob->template as<T> ();
+ this->table = hb_sanitize_context_t().reference_table<T> (face);
+ if (unlikely (this->table->is_blacklisted (this->table.get_blob (), face)))
+ {
+ hb_blob_destroy (this->table.get_blob ());
+ this->table = hb_blob_get_empty ();
+ }
this->lookup_count = table->get_lookup_count ();
this->accels = (hb_ot_layout_lookup_accelerator_t *) calloc (this->lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t));
if (unlikely (!this->accels))
- this->lookup_count = 0;
+ this->lookup_count = 0;
for (unsigned int i = 0; i < this->lookup_count; i++)
this->accels[i].init (table->get_lookup (i));
@@ -2677,11 +2774,10 @@ struct GSUBGPOS
for (unsigned int i = 0; i < this->lookup_count; i++)
this->accels[i].fini ();
free (this->accels);
- hb_blob_destroy (this->blob);
+ this->table.destroy ();
}
- hb_blob_t *blob;
- const T *table;
+ hb_blob_ptr_t<T> table;
unsigned int lookup_count;
hb_ot_layout_lookup_accelerator_t *accels;
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.cc
index 51c11985828..d0b22efe312 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.cc
@@ -34,60 +34,62 @@
#include "hb-ot-map.hh"
#include "hb-map.hh"
+#include "hb-ot-kern-table.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
-
-// Just so we compile them; unused otherwise:
-#include "hb-ot-layout-base-table.hh"
-#include "hb-ot-layout-jstf-table.hh"
-#include "hb-ot-color-colr-table.hh"
-#include "hb-ot-color-cpal-table.hh"
-#include "hb-ot-color-sbix-table.hh"
-#include "hb-ot-color-svg-table.hh"
+#include "hb-ot-layout-base-table.hh" // Just so we compile it; unused otherwise
+#include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise
#include "hb-ot-name-table.hh"
+#include "hb-ot-os2-table.hh"
+#include "hb-aat-layout-lcar-table.hh"
+#include "hb-aat-layout-morx-table.hh"
-// static inline const OT::BASE&
-// _get_base (hb_face_t *face)
-// {
-// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
-// hb_ot_face_data_t *data = hb_ot_face_data (face);
-// return *(data->base.get ());
-// }
-const OT::GDEF& _get_gdef (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
- return *hb_ot_face_data (face)->GDEF->table;
-}
-static hb_blob_t * _get_gsub_blob (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
- return hb_ot_face_data (face)->GSUB->blob;
-}
-static inline const OT::GSUB& _get_gsub (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
- return *hb_ot_face_data (face)->GSUB->table;
-}
-const OT::GSUB& _get_gsub_relaxed (hb_face_t *face)
+/**
+ * SECTION:hb-ot-layout
+ * @title: hb-ot-layout
+ * @short_description: OpenType Layout
+ * @include: hb-ot.h
+ *
+ * Functions for querying OpenType Layout features in the font face.
+ **/
+
+
+/*
+ * kern
+ */
+
+bool
+hb_ot_layout_has_kerning (hb_face_t *face)
{
- return *hb_ot_face_data (face)->GSUB.get_relaxed ()->table;
+ return face->table.kern->has_data ();
}
-static hb_blob_t * _get_gpos_blob (hb_face_t *face)
+
+bool
+hb_ot_layout_has_machine_kerning (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return hb_blob_get_empty ();
- return hb_ot_face_data (face)->GPOS->blob;
+ return face->table.kern->has_state_machine ();
}
-static inline const OT::GPOS& _get_gpos (hb_face_t *face)
+
+bool
+hb_ot_layout_has_cross_kerning (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
- return *hb_ot_face_data (face)->GPOS->table;
+ return face->table.kern->has_cross_stream ();
}
-const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
+
+void
+hb_ot_layout_kern (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
{
- return *hb_ot_face_data (face)->GPOS.get_relaxed ()->table;
+ hb_blob_t *blob = font->face->table.kern.get_blob ();
+ const AAT::kern& kern = *blob->as<AAT::kern> ();
+
+ AAT::hb_aat_apply_context_t c (plan, font, buffer, blob);
+
+ kern.apply (&c);
}
@@ -95,10 +97,9 @@ const OT::GPOS& _get_gpos_relaxed (hb_face_t *face)
* GDEF
*/
-static bool
-_hb_ot_blacklist_gdef (unsigned int gdef_len,
- unsigned int gsub_len,
- unsigned int gpos_len)
+bool
+OT::GDEF::is_blacklisted (hb_blob_t *blob,
+ hb_face_t *face) const
{
/* The ugly business of blacklisting individual fonts' tables happen here!
* See this thread for why we finally had to bend in and do this:
@@ -117,8 +118,10 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
* https://bugzilla.mozilla.org/show_bug.cgi?id=1279693
* https://bugzilla.mozilla.org/show_bug.cgi?id=1279875
*/
-#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z))
- switch ENCODE(gdef_len, gsub_len, gpos_len)
+#define ENCODE(x,y,z) (((uint64_t) (x) << 48) | ((uint64_t) (y) << 24) | (uint64_t) (z))
+ switch ENCODE(blob->length,
+ face->table.GSUB->table.get_length (),
+ face->table.GPOS->table.get_length ())
{
/* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */
case ENCODE (442, 2874, 42038):
@@ -197,29 +200,13 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
return false;
}
-inline void
-OT::GDEF::accelerator_t::init (hb_face_t *face)
-{
- this->blob = hb_sanitize_context_t().reference_table<GDEF> (face);
-
- if (unlikely (_hb_ot_blacklist_gdef (this->blob->length,
- _get_gsub_blob (face)->length,
- _get_gpos_blob (face)->length)))
- {
- hb_blob_destroy (this->blob);
- this->blob = hb_blob_get_empty ();
- }
-
- table = this->blob->as<GDEF> ();
-}
-
static void
_hb_ot_layout_set_glyph_props (hb_font_t *font,
hb_buffer_t *buffer)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
- const OT::GDEF &gdef = _get_gdef (font->face);
+ const OT::GDEF &gdef = *font->face->table.GDEF->table;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
{
@@ -234,7 +221,7 @@ _hb_ot_layout_set_glyph_props (hb_font_t *font,
hb_bool_t
hb_ot_layout_has_glyph_classes (hb_face_t *face)
{
- return _get_gdef (face).has_glyph_classes ();
+ return face->table.GDEF->table->has_glyph_classes ();
}
/**
@@ -246,7 +233,7 @@ hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class (hb_face_t *face,
hb_codepoint_t glyph)
{
- return (hb_ot_layout_glyph_class_t) _get_gdef (face).get_glyph_class (glyph);
+ return (hb_ot_layout_glyph_class_t) face->table.GDEF->table->get_glyph_class (glyph);
}
/**
@@ -259,7 +246,7 @@ hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
hb_ot_layout_glyph_class_t klass,
hb_set_t *glyphs /* OUT */)
{
- return _get_gdef (face).get_glyphs_in_class (klass, glyphs);
+ return face->table.GDEF->table->get_glyphs_in_class (klass, glyphs);
}
unsigned int
@@ -269,7 +256,10 @@ hb_ot_layout_get_attach_points (hb_face_t *face,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */)
{
- return _get_gdef (face).get_attach_points (glyph, start_offset, point_count, point_array);
+ return face->table.GDEF->table->get_attach_points (glyph,
+ start_offset,
+ point_count,
+ point_array);
}
unsigned int
@@ -280,7 +270,15 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
unsigned int *caret_count /* IN/OUT */,
hb_position_t *caret_array /* OUT */)
{
- return _get_gdef (font->face).get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
+ unsigned int result_caret_count = 0;
+ unsigned int result = font->face->table.GDEF->table->get_lig_carets (font, direction, glyph, start_offset, &result_caret_count, caret_array);
+ if (result)
+ {
+ if (caret_count) *caret_count = result_caret_count;
+ }
+ else
+ result = font->face->table.lcar->get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
+ return result;
}
@@ -288,13 +286,45 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
* GSUB/GPOS
*/
+bool
+OT::GSUB::is_blacklisted (hb_blob_t *blob HB_UNUSED,
+ hb_face_t *face) const
+{
+ /* Mac OS X prefers morx over GSUB. It also ships with various Indic fonts,
+ * all by 'MUTF' foundry (Tamil MN, Tamil Sangam MN, etc.), that have broken
+ * GSUB/GPOS tables. Some have GSUB with zero scripts, those are ignored by
+ * our morx/GSUB preference code. But if GSUB has non-zero scripts, we tend
+ * to prefer it over morx because we want to be consistent with other OpenType
+ * shapers.
+ *
+ * To work around broken Indic Mac system fonts, we ignore GSUB table if
+ * OS/2 VendorId is 'MUTF' and font has morx table as well.
+ *
+ * https://github.com/harfbuzz/harfbuzz/issues/1410
+ * https://github.com/harfbuzz/harfbuzz/issues/1348
+ * https://github.com/harfbuzz/harfbuzz/issues/1391
+ */
+ if (unlikely (face->table.OS2->achVendID == HB_TAG ('M','U','T','F') &&
+ face->table.morx->has_data ()))
+ return true;
+
+ return false;
+}
+
+bool
+OT::GPOS::is_blacklisted (hb_blob_t *blob HB_UNUSED,
+ hb_face_t *face HB_UNUSED) const
+{
+ return false;
+}
+
static const OT::GSUBGPOS&
get_gsubgpos_table (hb_face_t *face,
hb_tag_t table_tag)
{
switch (table_tag) {
- case HB_OT_TAG_GSUB: return _get_gsub (face);
- case HB_OT_TAG_GPOS: return _get_gpos (face);
+ case HB_OT_TAG_GSUB: return *face->table.GSUB->table;
+ case HB_OT_TAG_GPOS: return *face->table.GPOS->table;
default: return Null(OT::GSUBGPOS);
}
}
@@ -305,7 +335,7 @@ hb_ot_layout_table_get_script_tags (hb_face_t *face,
hb_tag_t table_tag,
unsigned int start_offset,
unsigned int *script_count /* IN/OUT */,
- hb_tag_t *script_tags /* OUT */)
+ hb_tag_t *script_tags /* OUT */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
@@ -351,17 +381,36 @@ hb_ot_layout_table_choose_script (hb_face_t *face,
unsigned int *script_index,
hb_tag_t *chosen_script)
{
+ const hb_tag_t *t;
+ for (t = script_tags; *t; t++);
+ return hb_ot_layout_table_select_script (face, table_tag, t - script_tags, script_tags, script_index, chosen_script);
+}
+
+/**
+ * hb_ot_layout_table_select_script:
+ *
+ * Since: 2.0.0
+ **/
+hb_bool_t
+hb_ot_layout_table_select_script (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int script_count,
+ const hb_tag_t *script_tags,
+ unsigned int *script_index /* OUT */,
+ hb_tag_t *chosen_script /* OUT */)
+{
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX), "");
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+ unsigned int i;
- while (*script_tags)
+ for (i = 0; i < script_count; i++)
{
- if (g.find_script_index (*script_tags, script_index)) {
+ if (g.find_script_index (script_tags[i], script_index))
+ {
if (chosen_script)
- *chosen_script = *script_tags;
+ *chosen_script = script_tags[i];
return true;
}
- script_tags++;
}
/* try finding 'DFLT' */
@@ -397,14 +446,14 @@ hb_ot_layout_table_get_feature_tags (hb_face_t *face,
hb_tag_t table_tag,
unsigned int start_offset,
unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */)
+ hb_tag_t *feature_tags /* OUT */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
return g.get_feature_tags (start_offset, feature_count, feature_tags);
}
-hb_bool_t
+bool
hb_ot_layout_table_find_feature (hb_face_t *face,
hb_tag_t table_tag,
hb_tag_t feature_tag,
@@ -433,7 +482,7 @@ hb_ot_layout_script_get_language_tags (hb_face_t *face,
unsigned int script_index,
unsigned int start_offset,
unsigned int *language_count /* IN/OUT */,
- hb_tag_t *language_tags /* OUT */)
+ hb_tag_t *language_tags /* OUT */)
{
const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
@@ -447,13 +496,38 @@ hb_ot_layout_script_find_language (hb_face_t *face,
hb_tag_t language_tag,
unsigned int *language_index)
{
+ return hb_ot_layout_script_select_language (face,
+ table_tag,
+ script_index,
+ 1,
+ &language_tag,
+ language_index);
+}
+
+/**
+ * hb_ot_layout_script_select_language:
+ *
+ * Since: 2.0.0
+ **/
+hb_bool_t
+hb_ot_layout_script_select_language (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int script_index,
+ unsigned int language_count,
+ const hb_tag_t *language_tags,
+ unsigned int *language_index /* OUT */)
+{
static_assert ((OT::Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX), "");
const OT::Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
+ unsigned int i;
- if (s.find_lang_sys_index (language_tag, language_index))
- return true;
+ for (i = 0; i < language_count; i++)
+ {
+ if (s.find_lang_sys_index (language_tags[i], language_index))
+ return true;
+ }
- /* try with 'dflt'; MS site has had typos and many fonts use it now :( */
+ /* try finding 'dflt' */
if (s.find_lang_sys_index (HB_OT_TAG_DEFAULT_LANGUAGE, language_index))
return false;
@@ -499,26 +573,13 @@ hb_ot_layout_language_get_required_feature (hb_face_t *face,
return l.has_required_feature ();
}
-static void
-_hb_ot_layout_language_add_feature_indexes_to (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- hb_set_t *feature_indexes /* OUT */)
-{
- const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
- const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
- l.add_feature_indexes_to (feature_indexes);
-}
-
-
unsigned int
hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
hb_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
unsigned int start_offset,
- unsigned int *feature_count /* IN/OUT */,
+ unsigned int *feature_count /* IN/OUT */,
unsigned int *feature_indexes /* OUT */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
@@ -534,7 +595,7 @@ hb_ot_layout_language_get_feature_tags (hb_face_t *face,
unsigned int language_index,
unsigned int start_offset,
unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */)
+ hb_tag_t *feature_tags /* OUT */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
@@ -588,7 +649,7 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face,
hb_tag_t table_tag,
unsigned int feature_index,
unsigned int start_offset,
- unsigned int *lookup_count /* IN/OUT */,
+ unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */)
{
return hb_ot_layout_feature_with_variations_get_lookups (face,
@@ -609,134 +670,136 @@ unsigned int
hb_ot_layout_table_get_lookup_count (hb_face_t *face,
hb_tag_t table_tag)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return 0;
- switch (table_tag)
- {
- case HB_OT_TAG_GSUB:
- {
- return hb_ot_face_data (face)->GSUB->lookup_count;
- }
- case HB_OT_TAG_GPOS:
- {
- return hb_ot_face_data (face)->GPOS->lookup_count;
- }
- }
- return 0;
+ return get_gsubgpos_table (face, table_tag).get_lookup_count ();
}
-static void
-_hb_ot_layout_collect_lookups_lookups (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int feature_index,
- hb_set_t *lookup_indexes /* OUT */)
+
+struct hb_collect_features_context_t
{
- unsigned int lookup_indices[32];
- unsigned int offset, len;
-
- offset = 0;
- do {
- len = ARRAY_LENGTH (lookup_indices);
- hb_ot_layout_feature_get_lookups (face,
- table_tag,
- feature_index,
- offset, &len,
- lookup_indices);
-
- for (unsigned int i = 0; i < len; i++)
- lookup_indexes->add (lookup_indices[i]);
-
- offset += len;
- } while (len == ARRAY_LENGTH (lookup_indices));
-}
+ hb_collect_features_context_t (hb_face_t *face,
+ hb_tag_t table_tag,
+ hb_set_t *feature_indexes_)
+ : g (get_gsubgpos_table (face, table_tag)),
+ feature_indexes (feature_indexes_),
+ script_count(0),langsys_count(0) {}
+
+ bool inline visited (const OT::Script &s)
+ {
+ /* We might have Null() object here. Don't want to involve
+ * that in the memoize. So, detect empty objects and return. */
+ if (unlikely (!s.has_default_lang_sys () &&
+ !s.get_lang_sys_count ()))
+ return true;
+
+ if (script_count++ > HB_MAX_SCRIPTS)
+ return true;
+
+ return visited (s, visited_script);
+ }
+ bool inline visited (const OT::LangSys &l)
+ {
+ /* We might have Null() object here. Don't want to involve
+ * that in the memoize. So, detect empty objects and return. */
+ if (unlikely (!l.has_required_feature () &&
+ !l.get_feature_count ()))
+ return true;
+
+ if (langsys_count++ > HB_MAX_LANGSYS)
+ return true;
+
+ return visited (l, visited_langsys);
+ }
+
+ private:
+ template <typename T>
+ bool inline visited (const T &p, hb_set_t &visited_set)
+ {
+ hb_codepoint_t delta = (hb_codepoint_t) ((uintptr_t) &p - (uintptr_t) &g);
+ if (visited_set.has (delta))
+ return true;
+
+ visited_set.add (delta);
+ return false;
+ }
+
+ public:
+ const OT::GSUBGPOS &g;
+ hb_set_t *feature_indexes;
+
+ private:
+ hb_set_t visited_script;
+ hb_set_t visited_langsys;
+ unsigned int script_count;
+ unsigned int langsys_count;
+};
static void
-_hb_ot_layout_collect_features_features (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- const hb_tag_t *features,
- hb_set_t *feature_indexes /* OUT */)
+langsys_collect_features (hb_collect_features_context_t *c,
+ const OT::LangSys &l,
+ const hb_tag_t *features)
{
+ if (c->visited (l)) return;
+
if (!features)
{
- unsigned int required_feature_index;
- if (hb_ot_layout_language_get_required_feature (face,
- table_tag,
- script_index,
- language_index,
- &required_feature_index,
- nullptr))
- feature_indexes->add (required_feature_index);
-
- /* All features */
- _hb_ot_layout_language_add_feature_indexes_to (face,
- table_tag,
- script_index,
- language_index,
- feature_indexes);
+ /* All features. */
+ if (l.has_required_feature ())
+ c->feature_indexes->add (l.get_required_feature_index ());
+
+ l.add_feature_indexes_to (c->feature_indexes);
}
else
{
+ /* Ugh. Any faster way? */
for (; *features; features++)
{
- unsigned int feature_index;
- if (hb_ot_layout_language_find_feature (face,
- table_tag,
- script_index,
- language_index,
- *features,
- &feature_index))
- feature_indexes->add (feature_index);
+ hb_tag_t feature_tag = *features;
+ unsigned int num_features = l.get_feature_count ();
+ for (unsigned int i = 0; i < num_features; i++)
+ {
+ unsigned int feature_index = l.get_feature_index (i);
+
+ if (feature_tag == c->g.get_feature_tag (feature_index))
+ {
+ c->feature_indexes->add (feature_index);
+ break;
+ }
+ }
}
}
}
static void
-_hb_ot_layout_collect_features_languages (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- const hb_tag_t *languages,
- const hb_tag_t *features,
- hb_set_t *feature_indexes /* OUT */)
+script_collect_features (hb_collect_features_context_t *c,
+ const OT::Script &s,
+ const hb_tag_t *languages,
+ const hb_tag_t *features)
{
- _hb_ot_layout_collect_features_features (face,
- table_tag,
- script_index,
- HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
- features,
- feature_indexes);
+ if (c->visited (s)) return;
if (!languages)
{
- /* All languages */
- unsigned int count = hb_ot_layout_script_get_language_tags (face,
- table_tag,
- script_index,
- 0, nullptr, nullptr);
+ /* All languages. */
+ if (s.has_default_lang_sys ())
+ langsys_collect_features (c,
+ s.get_default_lang_sys (),
+ features);
+
+ unsigned int count = s.get_lang_sys_count ();
for (unsigned int language_index = 0; language_index < count; language_index++)
- _hb_ot_layout_collect_features_features (face,
- table_tag,
- script_index,
- language_index,
- features,
- feature_indexes);
+ langsys_collect_features (c,
+ s.get_lang_sys (language_index),
+ features);
}
else
{
for (; *languages; languages++)
{
unsigned int language_index;
- if (hb_ot_layout_script_find_language (face,
- table_tag,
- script_index,
- *languages,
- &language_index))
- _hb_ot_layout_collect_features_features (face,
- table_tag,
- script_index,
- language_index,
- features,
- feature_indexes);
+ if (s.find_lang_sys_index (*languages, &language_index))
+ langsys_collect_features (c,
+ s.get_lang_sys (language_index),
+ features);
}
}
}
@@ -754,35 +817,27 @@ hb_ot_layout_collect_features (hb_face_t *face,
const hb_tag_t *features,
hb_set_t *feature_indexes /* OUT */)
{
+ hb_collect_features_context_t c (face, table_tag, feature_indexes);
if (!scripts)
{
- /* All scripts */
- unsigned int count = hb_ot_layout_table_get_script_tags (face,
- table_tag,
- 0, nullptr, nullptr);
+ /* All scripts. */
+ unsigned int count = c.g.get_script_count ();
for (unsigned int script_index = 0; script_index < count; script_index++)
- _hb_ot_layout_collect_features_languages (face,
- table_tag,
- script_index,
- languages,
- features,
- feature_indexes);
+ script_collect_features (&c,
+ c.g.get_script (script_index),
+ languages,
+ features);
}
else
{
for (; *scripts; scripts++)
{
unsigned int script_index;
- if (hb_ot_layout_table_find_script (face,
- table_tag,
- *scripts,
- &script_index))
- _hb_ot_layout_collect_features_languages (face,
- table_tag,
- script_index,
- languages,
- features,
- feature_indexes);
+ if (c.g.find_script_index (*scripts, &script_index))
+ script_collect_features (&c,
+ c.g.get_script (script_index),
+ languages,
+ features);
}
}
}
@@ -800,10 +855,14 @@ hb_ot_layout_collect_lookups (hb_face_t *face,
const hb_tag_t *features,
hb_set_t *lookup_indexes /* OUT */)
{
- hb_auto_t<hb_set_t> feature_indexes;
+ const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+
+ hb_set_t feature_indexes;
hb_ot_layout_collect_features (face, table_tag, scripts, languages, features, &feature_indexes);
- for (hb_codepoint_t feature_index = HB_SET_VALUE_INVALID; hb_set_next (&feature_indexes, &feature_index);)
- _hb_ot_layout_collect_lookups_lookups (face, table_tag, feature_index, lookup_indexes);
+
+ for (hb_codepoint_t feature_index = HB_SET_VALUE_INVALID;
+ hb_set_next (&feature_indexes, &feature_index);)
+ g.get_feature (feature_index).add_lookup_indexes_to (lookup_indexes);
}
/**
@@ -815,13 +874,11 @@ void
hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
hb_tag_t table_tag,
unsigned int lookup_index,
- hb_set_t *glyphs_before, /* OUT. May be nullptr */
- hb_set_t *glyphs_input, /* OUT. May be nullptr */
- hb_set_t *glyphs_after, /* OUT. May be nullptr */
- hb_set_t *glyphs_output /* OUT. May be nullptr */)
+ hb_set_t *glyphs_before, /* OUT. May be NULL */
+ hb_set_t *glyphs_input, /* OUT. May be NULL */
+ hb_set_t *glyphs_after, /* OUT. May be NULL */
+ hb_set_t *glyphs_output /* OUT. May be NULL */)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
-
OT::hb_collect_glyphs_context_t c (face,
glyphs_before,
glyphs_input,
@@ -832,13 +889,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
{
case HB_OT_TAG_GSUB:
{
- const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
case HB_OT_TAG_GPOS:
{
- const OT::PosLookup& l = hb_ot_face_data (face)->GPOS->table->get_lookup (lookup_index);
+ const OT::PosLookup& l = face->table.GPOS->table->get_lookup (lookup_index);
l.collect_glyphs (&c);
return;
}
@@ -885,7 +942,7 @@ hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
hb_bool_t
hb_ot_layout_has_substitution (hb_face_t *face)
{
- return _get_gsub (face).has_data ();
+ return face->table.GSUB->table->has_data ();
}
/**
@@ -900,23 +957,25 @@ hb_ot_layout_lookup_would_substitute (hb_face_t *face,
unsigned int glyphs_length,
hb_bool_t zero_context)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
- return hb_ot_layout_lookup_would_substitute_fast (face, lookup_index, glyphs, glyphs_length, zero_context);
+ return hb_ot_layout_lookup_would_substitute_fast (face,
+ lookup_index,
+ glyphs, glyphs_length,
+ zero_context);
}
-hb_bool_t
+bool
hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
unsigned int lookup_index,
const hb_codepoint_t *glyphs,
unsigned int glyphs_length,
- hb_bool_t zero_context)
+ bool zero_context)
{
- if (unlikely (lookup_index >= hb_ot_face_data (face)->GSUB->lookup_count)) return false;
+ if (unlikely (lookup_index >= face->table.GSUB->lookup_count)) return false;
OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context);
- const OT::SubstLookup& l = hb_ot_face_data (face)->GSUB->table->get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
- return l.would_apply (&c, &hb_ot_face_data (face)->GSUB->accels[lookup_index]);
+ return l.would_apply (&c, &face->table.GSUB->accels[lookup_index]);
}
void
@@ -926,6 +985,56 @@ hb_ot_layout_substitute_start (hb_font_t *font,
_hb_ot_layout_set_glyph_props (font, buffer);
}
+void
+hb_ot_layout_delete_glyphs_inplace (hb_buffer_t *buffer,
+ bool (*filter) (const hb_glyph_info_t *info))
+{
+ /* Merge clusters and delete filtered glyphs.
+ * NOTE! We can't use out-buffer as we have positioning data. */
+ unsigned int j = 0;
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
+ hb_glyph_position_t *pos = buffer->pos;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (filter (&info[i]))
+ {
+ /* Merge clusters.
+ * Same logic as buffer->delete_glyph(), but for in-place removal. */
+
+ unsigned int cluster = info[i].cluster;
+ if (i + 1 < count && cluster == info[i + 1].cluster)
+ continue; /* Cluster survives; do nothing. */
+
+ if (j)
+ {
+ /* Merge cluster backward. */
+ if (cluster < info[j - 1].cluster)
+ {
+ unsigned int mask = info[i].mask;
+ unsigned int old_cluster = info[j - 1].cluster;
+ for (unsigned k = j; k && info[k - 1].cluster == old_cluster; k--)
+ buffer->set_cluster (info[k - 1], cluster, mask);
+ }
+ continue;
+ }
+
+ if (i + 1 < count)
+ buffer->merge_clusters (i, i + 2); /* Merge cluster forward. */
+
+ continue;
+ }
+
+ if (j != i)
+ {
+ info[j] = info[i];
+ pos[j] = pos[i];
+ }
+ j++;
+ }
+ buffer->len = j;
+}
+
/**
* hb_ot_layout_lookup_substitute_closure:
*
@@ -936,10 +1045,10 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
unsigned int lookup_index,
hb_set_t *glyphs)
{
- hb_auto_t<hb_map_t> done_lookups;
+ hb_map_t done_lookups;
OT::hb_closure_context_t c (face, glyphs, &done_lookups);
- const OT::SubstLookup& l = _get_gsub (face).get_lookup (lookup_index);
+ const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index);
l.closure (&c, lookup_index);
}
@@ -957,9 +1066,9 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
const hb_set_t *lookups,
hb_set_t *glyphs)
{
- hb_auto_t<hb_map_t> done_lookups;
+ hb_map_t done_lookups;
OT::hb_closure_context_t c (face, glyphs, &done_lookups);
- const OT::GSUB& gsub = _get_gsub (face);
+ const OT::GSUB& gsub = *face->table.GSUB->table;
unsigned int iteration_count = 0;
unsigned int glyphs_length;
@@ -976,9 +1085,8 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
for (unsigned int i = 0; i < gsub.get_lookup_count (); i++)
gsub.get_lookup (i).closure (&c, i);
}
- iteration_count++;
- } while (iteration_count <= HB_CLOSURE_MAX_STAGES
- && glyphs_length != glyphs->get_population ());
+ } while (iteration_count++ <= HB_CLOSURE_MAX_STAGES &&
+ glyphs_length != glyphs->get_population ());
}
/*
@@ -988,7 +1096,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
hb_bool_t
hb_ot_layout_has_positioning (hb_face_t *face)
{
- return _get_gpos (face).has_data ();
+ return face->table.GPOS->table->has_data ();
}
void
@@ -1015,14 +1123,14 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer)
* Since: 0.9.10
**/
hb_bool_t
-hb_ot_layout_get_size_params (hb_face_t *face,
- unsigned int *design_size, /* OUT. May be nullptr */
- unsigned int *subfamily_id, /* OUT. May be nullptr */
- unsigned int *subfamily_name_id, /* OUT. May be nullptr */
- unsigned int *range_start, /* OUT. May be nullptr */
- unsigned int *range_end /* OUT. May be nullptr */)
+hb_ot_layout_get_size_params (hb_face_t *face,
+ unsigned int *design_size, /* OUT. May be NULL */
+ unsigned int *subfamily_id, /* OUT. May be NULL */
+ hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */
+ unsigned int *range_start, /* OUT. May be NULL */
+ unsigned int *range_end /* OUT. May be NULL */)
{
- const OT::GPOS &gpos = _get_gpos (face);
+ const OT::GPOS &gpos = *face->table.GPOS->table;
const hb_tag_t tag = HB_TAG ('s','i','z','e');
unsigned int num_features = gpos.get_feature_count ();
@@ -1035,30 +1143,152 @@ hb_ot_layout_get_size_params (hb_face_t *face,
if (params.designSize)
{
-#define PARAM(a, A) if (a) *a = params.A
- PARAM (design_size, designSize);
- PARAM (subfamily_id, subfamilyID);
- PARAM (subfamily_name_id, subfamilyNameID);
- PARAM (range_start, rangeStart);
- PARAM (range_end, rangeEnd);
-#undef PARAM
+ if (design_size) *design_size = params.designSize;
+ if (subfamily_id) *subfamily_id = params.subfamilyID;
+ if (subfamily_name_id) *subfamily_name_id = params.subfamilyNameID;
+ if (range_start) *range_start = params.rangeStart;
+ if (range_end) *range_end = params.rangeEnd;
return true;
}
}
}
-#define PARAM(a, A) if (a) *a = 0
- PARAM (design_size, designSize);
- PARAM (subfamily_id, subfamilyID);
- PARAM (subfamily_name_id, subfamilyNameID);
- PARAM (range_start, rangeStart);
- PARAM (range_end, rangeEnd);
-#undef PARAM
+ if (design_size) *design_size = 0;
+ if (subfamily_id) *subfamily_id = 0;
+ if (subfamily_name_id) *subfamily_name_id = HB_OT_NAME_ID_INVALID;
+ if (range_start) *range_start = 0;
+ if (range_end) *range_end = 0;
return false;
}
+/**
+ * hb_ot_layout_feature_get_name_ids:
+ * @face: #hb_face_t to work upon
+ * @table_tag: table tag to query, "GSUB" or "GPOS".
+ * @feature_index: index of feature to query.
+ * @label_id: (out) (allow-none): The ‘name’ table name ID that specifies a string
+ * for a user-interface label for this feature. (May be NULL.)
+ * @tooltip_id: (out) (allow-none): The ‘name’ table name ID that specifies a string
+ * that an application can use for tooltip text for this
+ * feature. (May be NULL.)
+ * @sample_id: (out) (allow-none): The ‘name’ table name ID that specifies sample text
+ * that illustrates the effect of this feature. (May be NULL.)
+ * @num_named_parameters: (out) (allow-none): Number of named parameters. (May be zero.)
+ * @first_param_id: (out) (allow-none): The first ‘name’ table name ID used to specify
+ * strings for user-interface labels for the feature
+ * parameters. (Must be zero if numParameters is zero.)
+ *
+ * Fetches name indices from feature parameters for "Stylistic Set" ('ssXX') or
+ * "Character Variant" ('cvXX') features.
+ *
+ * Return value: true if data found, false otherwise
+ *
+ * Since: 2.0.0
+ **/
+hb_bool_t
+hb_ot_layout_feature_get_name_ids (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int feature_index,
+ hb_ot_name_id_t *label_id, /* OUT. May be NULL */
+ hb_ot_name_id_t *tooltip_id, /* OUT. May be NULL */
+ hb_ot_name_id_t *sample_id, /* OUT. May be NULL */
+ unsigned int *num_named_parameters, /* OUT. May be NULL */
+ hb_ot_name_id_t *first_param_id /* OUT. May be NULL */)
+{
+ const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+
+ hb_tag_t feature_tag = g.get_feature_tag (feature_index);
+ const OT::Feature &f = g.get_feature (feature_index);
+
+ const OT::FeatureParams &feature_params = f.get_feature_params ();
+ if (&feature_params != &Null (OT::FeatureParams))
+ {
+ const OT::FeatureParamsStylisticSet& ss_params =
+ feature_params.get_stylistic_set_params (feature_tag);
+ if (&ss_params != &Null (OT::FeatureParamsStylisticSet)) /* ssXX */
+ {
+ if (label_id) *label_id = ss_params.uiNameID;
+ // ssXX features don't have the rest
+ if (tooltip_id) *tooltip_id = HB_OT_NAME_ID_INVALID;
+ if (sample_id) *sample_id = HB_OT_NAME_ID_INVALID;
+ if (num_named_parameters) *num_named_parameters = 0;
+ if (first_param_id) *first_param_id = HB_OT_NAME_ID_INVALID;
+ return true;
+ }
+ const OT::FeatureParamsCharacterVariants& cv_params =
+ feature_params.get_character_variants_params (feature_tag);
+ if (&cv_params != &Null (OT::FeatureParamsCharacterVariants)) /* cvXX */
+ {
+ if (label_id) *label_id = cv_params.featUILableNameID;
+ if (tooltip_id) *tooltip_id = cv_params.featUITooltipTextNameID;
+ if (sample_id) *sample_id = cv_params.sampleTextNameID;
+ if (num_named_parameters) *num_named_parameters = cv_params.numNamedParameters;
+ if (first_param_id) *first_param_id = cv_params.firstParamUILabelNameID;
+ return true;
+ }
+ }
+
+ if (label_id) *label_id = HB_OT_NAME_ID_INVALID;
+ if (tooltip_id) *tooltip_id = HB_OT_NAME_ID_INVALID;
+ if (sample_id) *sample_id = HB_OT_NAME_ID_INVALID;
+ if (num_named_parameters) *num_named_parameters = 0;
+ if (first_param_id) *first_param_id = HB_OT_NAME_ID_INVALID;
+ return false;
+}
+
+/**
+ * hb_ot_layout_feature_get_characters:
+ * @face: #hb_face_t to work upon
+ * @table_tag: table tag to query, "GSUB" or "GPOS".
+ * @feature_index: index of feature to query.
+ * @start_offset: In case the resulting char_count was equal to its input value, there
+ * is a chance there were more characters on the tag so this API can be
+ * called with an offset till resulting char_count gets to a number
+ * lower than input buffer (or consider using just a bigger buffer for
+ * one shot copying).
+ * @char_count: (inout) (allow-none): The count of characters for which this feature
+ * provides glyph variants. (May be zero.)
+ * @characters: (out caller-allocates) (array length=char_count): A buffer pointer. The Unicode codepoints
+ * of the characters for which this feature provides glyph variants.
+ *
+ * Fetches characters listed by designer under feature parameters for "Character
+ * Variant" ("cvXX") features.
+ *
+ * Return value: Number of total sample characters in the cvXX feature.
+ *
+ * Since: 2.0.0
+ **/
+unsigned int
+hb_ot_layout_feature_get_characters (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int feature_index,
+ unsigned int start_offset,
+ unsigned int *char_count, /* IN/OUT. May be NULL */
+ hb_codepoint_t *characters /* OUT. May be NULL */)
+{
+ const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+
+ hb_tag_t feature_tag = g.get_feature_tag (feature_index);
+ const OT::Feature &f = g.get_feature (feature_index);
+
+ const OT::FeatureParams &feature_params = f.get_feature_params ();
+
+ const OT::FeatureParamsCharacterVariants& cv_params =
+ feature_params.get_character_variants_params(feature_tag);
+
+ unsigned int len = 0;
+ if (char_count && characters && start_offset < cv_params.characters.len)
+ {
+ len = MIN (cv_params.characters.len - start_offset, *char_count);
+ for (unsigned int i = 0; i < len; ++i)
+ characters[i] = cv_params.characters[start_offset + i];
+ }
+ if (char_count) *char_count = len;
+ return cv_params.characters.len;
+}
+
/*
* Parts of different types are implemented here such that they have direct
@@ -1073,11 +1303,11 @@ struct GSUBProxy
typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) :
- table (*hb_ot_face_data (face)->GSUB->table),
- accels (hb_ot_face_data (face)->GSUB->accels) {}
+ table (*face->table.GSUB->table),
+ accels (face->table.GSUB->accels) {}
const OT::GSUB &table;
- const hb_ot_layout_lookup_accelerator_t *accels;
+ const OT::hb_ot_layout_lookup_accelerator_t *accels;
};
struct GPOSProxy
@@ -1087,67 +1317,17 @@ struct GPOSProxy
typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) :
- table (*hb_ot_face_data (face)->GPOS->table),
- accels (hb_ot_face_data (face)->GPOS->accels) {}
+ table (*face->table.GPOS->table),
+ accels (face->table.GPOS->accels) {}
const OT::GPOS &table;
- const hb_ot_layout_lookup_accelerator_t *accels;
+ const OT::hb_ot_layout_lookup_accelerator_t *accels;
};
-struct hb_get_subtables_context_t :
- hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY>
-{
- template <typename Type>
- static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c)
- {
- const Type *typed_obj = (const Type *) obj;
- return typed_obj->apply (c);
- }
-
- typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_ot_apply_context_t *c);
-
- struct hb_applicable_t
- {
- inline void init (const void *obj_, hb_apply_func_t apply_func_)
- {
- obj = obj_;
- apply_func = apply_func_;
- }
-
- inline bool apply (OT::hb_ot_apply_context_t *c) const { return apply_func (obj, c); }
-
- private:
- const void *obj;
- hb_apply_func_t apply_func;
- };
-
- typedef hb_auto_t<hb_vector_t<hb_applicable_t> > array_t;
-
- /* Dispatch interface. */
- inline const char *get_name (void) { return "GET_SUBTABLES"; }
- template <typename T>
- inline return_t dispatch (const T &obj)
- {
- hb_applicable_t *entry = array.push();
- entry->init (&obj, apply_to<T>);
- return HB_VOID;
- }
- static return_t default_return_value (void) { return HB_VOID; }
- bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; }
-
- hb_get_subtables_context_t (array_t &array_) :
- array (array_),
- debug_depth (0) {}
-
- array_t &array;
- unsigned int debug_depth;
-};
-
static inline bool
apply_forward (OT::hb_ot_apply_context_t *c,
- const hb_ot_layout_lookup_accelerator_t &accel,
- const hb_get_subtables_context_t::array_t &subtables)
+ const OT::hb_ot_layout_lookup_accelerator_t &accel)
{
bool ret = false;
hb_buffer_t *buffer = c->buffer;
@@ -1158,12 +1338,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
(buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props))
{
- for (unsigned int i = 0; i < subtables.len; i++)
- if (subtables[i].apply (c))
- {
- applied = true;
- break;
- }
+ applied = accel.apply (c);
}
if (applied)
@@ -1176,8 +1351,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
static inline bool
apply_backward (OT::hb_ot_apply_context_t *c,
- const hb_ot_layout_lookup_accelerator_t &accel,
- const hb_get_subtables_context_t::array_t &subtables)
+ const OT::hb_ot_layout_lookup_accelerator_t &accel)
{
bool ret = false;
hb_buffer_t *buffer = c->buffer;
@@ -1186,14 +1360,8 @@ apply_backward (OT::hb_ot_apply_context_t *c,
if (accel.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props))
- {
- for (unsigned int i = 0; i < subtables.len; i++)
- if (subtables[i].apply (c))
- {
- ret = true;
- break;
- }
- }
+ ret |= accel.apply (c);
+
/* The reverse lookup doesn't "advance" cursor (for good reason). */
buffer->idx--;
@@ -1206,7 +1374,7 @@ template <typename Proxy>
static inline void
apply_string (OT::hb_ot_apply_context_t *c,
const typename Proxy::Lookup &lookup,
- const hb_ot_layout_lookup_accelerator_t &accel)
+ const OT::hb_ot_layout_lookup_accelerator_t &accel)
{
hb_buffer_t *buffer = c->buffer;
@@ -1215,10 +1383,6 @@ apply_string (OT::hb_ot_apply_context_t *c,
c->set_lookup_props (lookup.get_props ());
- hb_get_subtables_context_t::array_t subtables;
- hb_get_subtables_context_t c_get_subtables (subtables);
- lookup.dispatch (&c_get_subtables);
-
if (likely (!lookup.is_reverse ()))
{
/* in/out forward substitution/positioning */
@@ -1227,7 +1391,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
buffer->idx = 0;
bool ret;
- ret = apply_forward (c, accel, subtables);
+ ret = apply_forward (c, accel);
if (ret)
{
if (!Proxy::inplace)
@@ -1243,7 +1407,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
buffer->remove_output ();
buffer->idx = buffer->len - 1;
- apply_backward (c, accel, subtables);
+ apply_backward (c, accel);
}
}
@@ -1302,31 +1466,65 @@ void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_
void
hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
const OT::SubstLookup &lookup,
- const hb_ot_layout_lookup_accelerator_t &accel)
+ const OT::hb_ot_layout_lookup_accelerator_t &accel)
{
apply_string<GSUBProxy> (c, lookup, accel);
}
+#if 0
+static const OT::BASE& _get_base (hb_face_t *face)
+{
+ return *face->table.BASE;
+}
+
+hb_bool_t
+hb_ot_layout_get_baseline (hb_font_t *font,
+ hb_ot_layout_baseline_t baseline,
+ hb_direction_t direction,
+ hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_position_t *coord /* OUT. May be NULL. */)
+{
+ const OT::BASE &base = _get_base (font->face);
+ bool result = base.get_baseline (font, baseline, direction, script_tag,
+ language_tag, coord);
+ /* TODO: Simulate https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags#ideographic-em-box */
+ if (!result && coord) *coord = 0;
+ if (coord) *coord = font->em_scale_dir (*coord, direction);
+ return result;
+}
+
+/* To be moved to public header */
/*
- * OT::BASE
+ * BASE
*/
-// /**
-// * hb_ot_base_has_data:
-// * @face: #hb_face_t to test
-// *
-// * This function allows to verify the presence of an OpenType BASE table on the
-// * face.
-// *
-// * Return value: true if face has a BASE table, false otherwise
-// *
-// * Since: XXX
-// **/
-// hb_bool_t
-// hb_ot_base_has_data (hb_face_t *face)
-// {
-// return _get_base (face).has_data ();
-// }
+/**
+ * hb_ot_layout_baseline_t:
+ *
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags
+ *
+ * Since: DONTREPLACEME
+ */
+typedef enum {
+ HB_OT_LAYOUT_BASELINE_HANG = HB_TAG('h','a','n','g'),
+ HB_OT_LAYOUT_BASELINE_ICFB = HB_TAG('i','c','f','b'),
+ HB_OT_LAYOUT_BASELINE_ICFT = HB_TAG('i','c','f','t'),
+ HB_OT_LAYOUT_BASELINE_IDEO = HB_TAG('i','d','e','o'),
+ HB_OT_LAYOUT_BASELINE_IDTB = HB_TAG('i','d','t','b'),
+ HB_OT_LAYOUT_BASELINE_MATH = HB_TAG('m','a','t','h'),
+ HB_OT_LAYOUT_BASELINE_ROMN = HB_TAG('r','o','m','n')
+} hb_ot_layout_baseline_t;
+
+HB_EXTERN hb_bool_t
+hb_ot_layout_get_baseline (hb_font_t *font,
+ hb_ot_layout_baseline_t baseline,
+ hb_direction_t direction,
+ hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_position_t *coord /* OUT. May be NULL. */);
+
+#endif
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.h b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.h
index 586fb151751..e473954125e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.h
@@ -33,7 +33,7 @@
#include "hb.h"
-#include "hb-ot-tag.h"
+#include "hb-ot-name.h"
HB_BEGIN_DECLS
@@ -46,6 +46,47 @@ HB_BEGIN_DECLS
/*
+ * Script & Language tags.
+ */
+
+#define HB_OT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
+#define HB_OT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
+
+/**
+ * HB_OT_MAX_TAGS_PER_SCRIPT:
+ *
+ * Since: 2.0.0
+ **/
+#define HB_OT_MAX_TAGS_PER_SCRIPT 3u
+/**
+ * HB_OT_MAX_TAGS_PER_LANGUAGE:
+ *
+ * Since: 2.0.0
+ **/
+#define HB_OT_MAX_TAGS_PER_LANGUAGE 3u
+
+HB_EXTERN void
+hb_ot_tags_from_script_and_language (hb_script_t script,
+ hb_language_t language,
+ unsigned int *script_count /* IN/OUT */,
+ hb_tag_t *script_tags /* OUT */,
+ unsigned int *language_count /* IN/OUT */,
+ hb_tag_t *language_tags /* OUT */);
+
+HB_EXTERN hb_script_t
+hb_ot_tag_to_script (hb_tag_t tag);
+
+HB_EXTERN hb_language_t
+hb_ot_tag_to_language (hb_tag_t tag);
+
+HB_EXTERN void
+hb_ot_tags_to_script_and_language (hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_script_t *script /* OUT */,
+ hb_language_t *language /* OUT */);
+
+
+/*
* GDEF
*/
@@ -111,13 +152,13 @@ hb_ot_layout_table_find_script (hb_face_t *face,
hb_tag_t script_tag,
unsigned int *script_index);
-/* Like find_script, but takes zero-terminated array of scripts to test */
HB_EXTERN hb_bool_t
-hb_ot_layout_table_choose_script (hb_face_t *face,
+hb_ot_layout_table_select_script (hb_face_t *face,
hb_tag_t table_tag,
+ unsigned int script_count,
const hb_tag_t *script_tags,
- unsigned int *script_index,
- hb_tag_t *chosen_script);
+ unsigned int *script_index /* OUT */,
+ hb_tag_t *chosen_script /* OUT */);
HB_EXTERN unsigned int
hb_ot_layout_table_get_feature_tags (hb_face_t *face,
@@ -135,11 +176,12 @@ hb_ot_layout_script_get_language_tags (hb_face_t *face,
hb_tag_t *language_tags /* OUT */);
HB_EXTERN hb_bool_t
-hb_ot_layout_script_find_language (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- hb_tag_t language_tag,
- unsigned int *language_index);
+hb_ot_layout_script_select_language (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int script_index,
+ unsigned int language_count,
+ const hb_tag_t *language_tags,
+ unsigned int *language_index /* OUT */);
HB_EXTERN hb_bool_t
hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
@@ -214,10 +256,10 @@ HB_EXTERN void
hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
hb_tag_t table_tag,
unsigned int lookup_index,
- hb_set_t *glyphs_before, /* OUT. May be NULL */
- hb_set_t *glyphs_input, /* OUT. May be NULL */
- hb_set_t *glyphs_after, /* OUT. May be NULL */
- hb_set_t *glyphs_output /* OUT. May be NULL */);
+ hb_set_t *glyphs_before, /* OUT. May be NULL */
+ hb_set_t *glyphs_input, /* OUT. May be NULL */
+ hb_set_t *glyphs_after, /* OUT. May be NULL */
+ hb_set_t *glyphs_output /* OUT. May be NULL */);
#ifdef HB_NOT_IMPLEMENTED
typedef struct
@@ -322,29 +364,32 @@ Xhb_ot_layout_lookup_position (hb_font_t *font,
/* Optical 'size' feature info. Returns true if found.
* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
HB_EXTERN hb_bool_t
-hb_ot_layout_get_size_params (hb_face_t *face,
- unsigned int *design_size, /* OUT. May be NULL */
- unsigned int *subfamily_id, /* OUT. May be NULL */
- unsigned int *subfamily_name_id, /* OUT. May be NULL */
- unsigned int *range_start, /* OUT. May be NULL */
- unsigned int *range_end /* OUT. May be NULL */);
-
+hb_ot_layout_get_size_params (hb_face_t *face,
+ unsigned int *design_size, /* OUT. May be NULL */
+ unsigned int *subfamily_id, /* OUT. May be NULL */
+ hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */
+ unsigned int *range_start, /* OUT. May be NULL */
+ unsigned int *range_end /* OUT. May be NULL */);
-/*
- * BASE
- */
-#if 0
-#define HB_OT_TAG_BASE_HANG HB_TAG('h','a','n','g')
-#define HB_OT_TAG_BASE_ICFB HB_TAG('i','c','f','b')
-#define HB_OT_TAG_BASE_ICFT HB_TAG('i','c','f','t')
-#define HB_OT_TAG_BASE_IDEO HB_TAG('i','d','e','o')
-#define HB_OT_TAG_BASE_IDTB HB_TAG('i','d','t','b')
-#define HB_OT_TAG_BASE_MATH HB_TAG('m','a','t','h')
-#define HB_OT_TAG_BASE_ROMN HB_TAG('r','o','m','n')
+HB_EXTERN hb_bool_t
+hb_ot_layout_feature_get_name_ids (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int feature_index,
+ hb_ot_name_id_t *label_id /* OUT. May be NULL */,
+ hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */,
+ hb_ot_name_id_t *sample_id /* OUT. May be NULL */,
+ unsigned int *num_named_parameters /* OUT. May be NULL */,
+ hb_ot_name_id_t *first_param_id /* OUT. May be NULL */);
-#endif
+HB_EXTERN unsigned int
+hb_ot_layout_feature_get_characters (hb_face_t *face,
+ hb_tag_t table_tag,
+ unsigned int feature_index,
+ unsigned int start_offset,
+ unsigned int *char_count /* IN/OUT. May be NULL */,
+ hb_codepoint_t *characters /* OUT. May be NULL */);
HB_END_DECLS
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.hh
index ac55459b6f6..a00b940b2ab 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-layout.hh
@@ -34,24 +34,35 @@
#include "hb-font.hh"
#include "hb-buffer.hh"
#include "hb-open-type.hh"
+#include "hb-ot-shape.hh"
#include "hb-set-digest.hh"
-namespace OT
-{
- struct GDEF;
- struct GSUB;
- struct GPOS;
-}
+struct hb_ot_shape_plan_t;
+
+
+/*
+ * kern
+ */
-HB_INTERNAL const OT::GDEF& _get_gdef (hb_face_t *face);
-HB_INTERNAL const OT::GSUB& _get_gsub_relaxed (hb_face_t *face);
-HB_INTERNAL const OT::GPOS& _get_gpos_relaxed (hb_face_t *face);
+HB_INTERNAL bool
+hb_ot_layout_has_kerning (hb_face_t *face);
+
+HB_INTERNAL bool
+hb_ot_layout_has_machine_kerning (hb_face_t *face);
+
+HB_INTERNAL bool
+hb_ot_layout_has_cross_kerning (hb_face_t *face);
+
+HB_INTERNAL void
+hb_ot_layout_kern (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
/* Private API corresponding to hb-ot-layout.h: */
-HB_INTERNAL hb_bool_t
+HB_INTERNAL bool
hb_ot_layout_table_find_feature (hb_face_t *face,
hb_tag_t table_tag,
hb_tag_t feature_tag,
@@ -85,12 +96,12 @@ HB_MARK_AS_FLAG_T (hb_ot_layout_glyph_props_flags_t);
* GSUB/GPOS
*/
-HB_INTERNAL hb_bool_t
+HB_INTERNAL bool
hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
unsigned int lookup_index,
const hb_codepoint_t *glyphs,
unsigned int glyphs_length,
- hb_bool_t zero_context);
+ bool zero_context);
/* Should be called before all the substitute_lookup's are done. */
@@ -98,33 +109,20 @@ HB_INTERNAL void
hb_ot_layout_substitute_start (hb_font_t *font,
hb_buffer_t *buffer);
-
-struct hb_ot_layout_lookup_accelerator_t
-{
- template <typename TLookup>
- inline void init (const TLookup &lookup)
- {
- digest.init ();
- lookup.add_coverage (&digest);
- }
- inline void fini (void) {}
-
- inline bool may_have (hb_codepoint_t g) const
- { return digest.may_have (g); }
-
- private:
- hb_set_digest_t digest;
-};
+HB_INTERNAL void
+hb_ot_layout_delete_glyphs_inplace (hb_buffer_t *buffer,
+ bool (*filter) (const hb_glyph_info_t *info));
namespace OT {
struct hb_ot_apply_context_t;
struct SubstLookup;
+ struct hb_ot_layout_lookup_accelerator_t;
}
HB_INTERNAL void
hb_ot_layout_substitute_lookup (OT::hb_ot_apply_context_t *c,
const OT::SubstLookup &lookup,
- const hb_ot_layout_lookup_accelerator_t &accel);
+ const OT::hb_ot_layout_lookup_accelerator_t &accel);
/* Should be called before all the position_lookup's are done. */
@@ -314,13 +312,13 @@ _hb_glyph_info_get_unicode_space_fallback_type (const hb_glyph_info_t *info)
static inline bool _hb_glyph_info_ligated (const hb_glyph_info_t *info);
-static inline hb_bool_t
+static inline bool
_hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info)
{
return (info->unicode_props() & UPROPS_MASK_IGNORABLE) &&
!_hb_glyph_info_ligated (info);
}
-static inline hb_bool_t
+static inline bool
_hb_glyph_info_is_default_ignorable_and_not_hidden (const hb_glyph_info_t *info)
{
return ((info->unicode_props() & (UPROPS_MASK_IGNORABLE|UPROPS_MASK_HIDDEN))
@@ -374,17 +372,17 @@ _hb_glyph_info_is_unicode_format (const hb_glyph_info_t *info)
return _hb_glyph_info_get_general_category (info) ==
HB_UNICODE_GENERAL_CATEGORY_FORMAT;
}
-static inline hb_bool_t
+static inline bool
_hb_glyph_info_is_zwnj (const hb_glyph_info_t *info)
{
return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & UPROPS_MASK_Cf_ZWNJ);
}
-static inline hb_bool_t
+static inline bool
_hb_glyph_info_is_zwj (const hb_glyph_info_t *info)
{
return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & UPROPS_MASK_Cf_ZWJ);
}
-static inline hb_bool_t
+static inline bool
_hb_glyph_info_is_joiner (const hb_glyph_info_t *info)
{
return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & (UPROPS_MASK_Cf_ZWNJ|UPROPS_MASK_Cf_ZWJ));
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.cc
index ebac6d14069..95f794ab4a2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.cc
@@ -27,7 +27,7 @@
*/
#include "hb-ot-map.hh"
-
+#include "hb-ot-shape.hh"
#include "hb-ot-layout.hh"
@@ -54,16 +54,17 @@ hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_,
/* Fetch script/language indices for GSUB/GPOS. We need these later to skip
* features not available in either table and not waste precious bits for them. */
- hb_tag_t script_tags[3] = {HB_TAG_NONE, HB_TAG_NONE, HB_TAG_NONE};
- hb_tag_t language_tag;
+ unsigned int script_count = HB_OT_MAX_TAGS_PER_SCRIPT;
+ unsigned int language_count = HB_OT_MAX_TAGS_PER_LANGUAGE;
+ hb_tag_t script_tags[HB_OT_MAX_TAGS_PER_SCRIPT];
+ hb_tag_t language_tags[HB_OT_MAX_TAGS_PER_LANGUAGE];
- hb_ot_tags_from_script (props.script, &script_tags[0], &script_tags[1]);
- language_tag = hb_ot_tag_from_language (props.language);
+ hb_ot_tags_from_script_and_language (props.script, props.language, &script_count, script_tags, &language_count, language_tags);
for (unsigned int table_index = 0; table_index < 2; table_index++) {
hb_tag_t table_tag = table_tags[table_index];
- found_script[table_index] = (bool) hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index], &chosen_script[table_index]);
- hb_ot_layout_script_find_language (face, table_tag, script_index[table_index], language_tag, &language_index[table_index]);
+ found_script[table_index] = (bool) hb_ot_layout_table_select_script (face, table_tag, script_count, script_tags, &script_index[table_index], &chosen_script[table_index]);
+ hb_ot_layout_script_select_language (face, table_tag, script_index[table_index], language_count, language_tags, &language_index[table_index]);
}
}
@@ -78,8 +79,8 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag,
hb_ot_map_feature_flags_t flags,
unsigned int value)
{
- feature_info_t *info = feature_infos.push();
if (unlikely (!tag)) return;
+ feature_info_t *info = feature_infos.push();
info->tag = tag;
info->seq = feature_infos.len;
info->max_value = value;
@@ -142,9 +143,8 @@ void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus
}
void
-hb_ot_map_builder_t::compile (hb_ot_map_t &m,
- const int *coords,
- unsigned int num_coords)
+hb_ot_map_builder_t::compile (hb_ot_map_t &m,
+ const hb_ot_shape_plan_key_t &key)
{
static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), "");
unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1;
@@ -174,6 +174,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
}
/* Sort features and merge duplicates */
+ if (feature_infos.len)
{
feature_infos.qsort ();
unsigned int j = 0;
@@ -280,13 +281,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
{
/* Collect lookup indices for features */
- unsigned int variations_index;
- hb_ot_layout_table_find_feature_variations (face,
- table_tags[table_index],
- coords,
- num_coords,
- &variations_index);
-
unsigned int stage_index = 0;
unsigned int last_num_lookups = 0;
for (unsigned stage = 0; stage < current_stage[table_index]; stage++)
@@ -295,14 +289,14 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
required_feature_stage[table_index] == stage)
add_lookups (m, table_index,
required_feature_index[table_index],
- variations_index,
+ key.variations_index[table_index],
global_bit_mask);
for (unsigned i = 0; i < m.features.len; i++)
if (m.features[i].stage[table_index] == stage)
add_lookups (m, table_index,
m.features[i].index[table_index],
- variations_index,
+ key.variations_index[table_index],
m.features[i].mask,
m.features[i].auto_zwnj,
m.features[i].auto_zwj,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.hh
index 40b9921fd30..0a5a4fbcb70 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-map.hh
@@ -57,8 +57,8 @@ struct hb_ot_map_t
unsigned int auto_zwj : 1;
unsigned int random : 1;
- inline int cmp (const hb_tag_t *tag_) const
- { return *tag_ < tag ? -1 : *tag_ > tag ? 1 : 0; }
+ inline int cmp (const hb_tag_t tag_) const
+ { return tag_ < tag ? -1 : tag_ > tag ? 1 : 0; }
};
struct lookup_map_t {
@@ -162,7 +162,7 @@ struct hb_ot_map_t
hb_mask_t global_mask;
hb_vector_t<feature_map_t, 8> features;
- hb_vector_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
+ hb_vector_t<lookup_map_t, 16> lookups[2]; /* GSUB/GPOS */
hb_vector_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
};
@@ -188,6 +188,7 @@ struct hb_ot_map_feature_t
hb_ot_map_feature_flags_t flags;
};
+struct hb_ot_shape_plan_key_t;
struct hb_ot_map_builder_t
{
@@ -218,9 +219,8 @@ struct hb_ot_map_builder_t
inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func)
{ add_pause (1, pause_func); }
- HB_INTERNAL void compile (hb_ot_map_t &m,
- const int *coords,
- unsigned int num_coords);
+ HB_INTERNAL void compile (hb_ot_map_t &m,
+ const hb_ot_shape_plan_key_t &key);
private:
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math-table.hh
index 87ebdc7d722..153a417959d 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math-table.hh
@@ -50,7 +50,7 @@ struct MathValueRecord
protected:
HBINT16 value; /* The X or Y value in design units */
OffsetTo<Device> deviceTable; /* Offset to the device table - from the
- * beginning of parent table. May be nullptr.
+ * beginning of parent table. May be NULL.
* Suggested format for device table is 1. */
public:
@@ -74,7 +74,7 @@ struct MathConstants
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && sanitize_math_value_records(c));
+ return_trace (c->check_struct (this) && sanitize_math_value_records (c));
}
inline hb_position_t get_value (hb_ot_math_constant_t constant,
@@ -94,7 +94,7 @@ struct MathConstants
case HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE:
case HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP:
case HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT:
- return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_x_value(font, this);
+ return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_x_value (font, this);
case HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT:
case HB_OT_MATH_CONSTANT_AXIS_HEIGHT:
@@ -143,7 +143,7 @@ struct MathConstants
case HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP:
case HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN:
case HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN:
- return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_y_value(font, this);
+ return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_y_value (font, this);
case HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT:
return radicalDegreeBottomRaisePercent;
@@ -210,7 +210,7 @@ struct MathTopAccentAttachment
unsigned int index = (this+topAccentCoverage).get_coverage (glyph);
if (index == NOT_COVERED)
return font->get_glyph_h_advance (glyph) / 2;
- return topAccentAttachment[index].get_x_value(font, this);
+ return topAccentAttachment[index].get_x_value (font, this);
}
protected:
@@ -265,7 +265,7 @@ struct MathKern
while (count > 0)
{
unsigned int half = count / 2;
- hb_position_t height = correctionHeight[i + half].get_y_value(font, this);
+ hb_position_t height = correctionHeight[i + half].get_y_value (font, this);
if (sign * height < sign * correction_height)
{
i += half + 1;
@@ -273,7 +273,7 @@ struct MathKern
} else
count = half;
}
- return kernValue[i].get_x_value(font, this);
+ return kernValue[i].get_x_value (font, this);
}
protected:
@@ -318,7 +318,7 @@ struct MathKernInfoRecord
protected:
/* Offset to MathKern table for each corner -
- * from the beginning of MathKernInfo table. May be nullptr. */
+ * from the beginning of MathKernInfo table. May be NULL. */
OffsetTo<MathKern> mathKern[4];
public:
@@ -368,7 +368,7 @@ struct MathGlyphInfo
mathItalicsCorrectionInfo.sanitize (c, this) &&
mathTopAccentAttachment.sanitize (c, this) &&
extendedShapeCoverage.sanitize (c, this) &&
- mathKernInfo.sanitize(c, this));
+ mathKernInfo.sanitize (c, this));
}
inline hb_position_t
@@ -401,7 +401,7 @@ struct MathGlyphInfo
* from the beginning of MathGlyphInfo table. When the left or right glyph of
* a box is an extended shape variant, the (ink) box (and not the default
* position defined by values in MathConstants table) should be used for
- * vertical positioning purposes. May be nullptr.. */
+ * vertical positioning purposes. May be NULL.. */
OffsetTo<Coverage> extendedShapeCoverage;
/* Offset to MathKernInfo table -
@@ -425,8 +425,8 @@ struct MathGlyphVariantRecord
protected:
GlyphID variantGlyph; /* Glyph ID for the variant. */
HBUINT16 advanceMeasurement; /* Advance width/height, in design units, of the
- * variant, in the direction of requested
- * glyph extension. */
+ * variant, in the direction of requested
+ * glyph extension. */
public:
DEFINE_SIZE_STATIC (4);
@@ -495,8 +495,8 @@ struct MathGlyphAssembly
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- italicsCorrection.sanitize(c, this) &&
- partRecords.sanitize(c));
+ italicsCorrection.sanitize (c, this) &&
+ partRecords.sanitize (c));
}
inline unsigned int get_parts (hb_direction_t direction,
@@ -509,9 +509,8 @@ struct MathGlyphAssembly
if (parts_count)
{
int scale = font->dir_scale (direction);
- const MathGlyphPartRecord *arr =
- partRecords.sub_array (start_offset, parts_count);
- unsigned int count = *parts_count;
+ hb_array_t<const MathGlyphPartRecord> arr = partRecords.sub_array (start_offset, parts_count);
+ unsigned int count = arr.len;
for (unsigned int i = 0; i < count; i++)
arr[i].extract (parts[i], scale, font);
}
@@ -540,8 +539,8 @@ struct MathGlyphConstruction
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- glyphAssembly.sanitize(c, this) &&
- mathGlyphVariantRecord.sanitize(c));
+ glyphAssembly.sanitize (c, this) &&
+ mathGlyphVariantRecord.sanitize (c));
}
inline const MathGlyphAssembly &get_assembly (void) const
@@ -556,9 +555,8 @@ struct MathGlyphConstruction
if (variants_count)
{
int scale = font->dir_scale (direction);
- const MathGlyphVariantRecord *arr =
- mathGlyphVariantRecord.sub_array (start_offset, variants_count);
- unsigned int count = *variants_count;
+ hb_array_t<const MathGlyphVariantRecord> arr = mathGlyphVariantRecord.sub_array (start_offset, variants_count);
+ unsigned int count = arr.len;
for (unsigned int i = 0; i < count; i++)
{
variants[i].glyph = arr[i].variantGlyph;
@@ -570,7 +568,7 @@ struct MathGlyphConstruction
protected:
/* Offset to MathGlyphAssembly table for this shape - from the beginning of
- MathGlyphConstruction table. May be nullptr. */
+ MathGlyphConstruction table. May be NULL. */
OffsetTo<MathGlyphAssembly> glyphAssembly;
/* MathGlyphVariantRecords for alternative variants of the glyphs. */
@@ -631,7 +629,7 @@ struct MathVariants
inline const MathGlyphConstruction &
get_glyph_construction (hb_codepoint_t glyph,
hb_direction_t direction,
- hb_font_t *font) const
+ hb_font_t *font HB_UNUSED) const
{
bool vertical = HB_DIRECTION_IS_VERTICAL (direction);
unsigned int count = vertical ? vertGlyphCount : horizGlyphCount;
@@ -639,7 +637,7 @@ struct MathVariants
: horizGlyphCoverage;
unsigned int index = (this+coverage).get_coverage (glyph);
- if (unlikely (index >= count)) return Null(MathGlyphConstruction);
+ if (unlikely (index >= count)) return Null (MathGlyphConstruction);
if (!vertical)
index += vertGlyphCount;
@@ -684,7 +682,7 @@ struct MATH
{
static const hb_tag_t tableTag = HB_OT_TAG_MATH;
- inline bool has_data (void) const { return version.to_int () != 0; }
+ inline bool has_data (void) const { return version.to_int (); }
inline bool sanitize (hb_sanitize_context_t *c) const
{
@@ -700,10 +698,10 @@ struct MATH
hb_font_t *font) const
{ return (this+mathConstants).get_value (constant, font); }
- inline const MathGlyphInfo &get_math_glyph_info (void) const
+ inline const MathGlyphInfo &get_glyph_info (void) const
{ return this+mathGlyphInfo; }
- inline const MathVariants &get_math_variants (void) const
+ inline const MathVariants &get_variants (void) const
{ return this+mathVariants; }
protected:
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math.cc
index c693f4807be..bd31bf565ab 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-math.cc
@@ -29,13 +29,16 @@
#include "hb-ot-face.hh"
#include "hb-ot-math-table.hh"
-static inline const OT::MATH&
-_get_math (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
- hb_ot_face_data_t * data = hb_ot_face_data (face);
- return *(data->MATH.get ());
-}
+
+/**
+ * SECTION:hb-ot-math
+ * @title: hb-ot-math
+ * @short_description: OpenType Math information
+ * @include: hb-ot.h
+ *
+ * Functions for fetching mathematics layout data from OpenType fonts.
+ **/
+
/*
* OT::MATH
@@ -55,7 +58,7 @@ _get_math (hb_face_t *face)
hb_bool_t
hb_ot_math_has_data (hb_face_t *face)
{
- return _get_math (face).has_data ();
+ return face->table.MATH->has_data ();
}
/**
@@ -77,8 +80,7 @@ hb_position_t
hb_ot_math_get_constant (hb_font_t *font,
hb_ot_math_constant_t constant)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_constant(constant, font);
+ return font->face->table.MATH->get_constant(constant, font);
}
/**
@@ -94,8 +96,7 @@ hb_position_t
hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_italics_correction (glyph, font);
+ return font->face->table.MATH->get_glyph_info().get_italics_correction (glyph, font);
}
/**
@@ -111,8 +112,7 @@ hb_position_t
hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_top_accent_attachment (glyph, font);
+ return font->face->table.MATH->get_glyph_info().get_top_accent_attachment (glyph, font);
}
/**
@@ -128,8 +128,7 @@ hb_bool_t
hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
hb_codepoint_t glyph)
{
- const OT::MATH &math = _get_math (face);
- return math.get_math_glyph_info().is_extended_shape (glyph);
+ return face->table.MATH->get_glyph_info().is_extended_shape (glyph);
}
/**
@@ -155,8 +154,10 @@ hb_ot_math_get_glyph_kerning (hb_font_t *font,
hb_ot_math_kern_t kern,
hb_position_t correction_height)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
+ return font->face->table.MATH->get_glyph_info().get_kerning (glyph,
+ kern,
+ correction_height,
+ font);
}
/**
@@ -186,11 +187,10 @@ hb_ot_math_get_glyph_variants (hb_font_t *font,
unsigned int *variants_count, /* IN/OUT */
hb_ot_math_glyph_variant_t *variants /* OUT */)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_glyph_variants (glyph, direction, font,
- start_offset,
- variants_count,
- variants);
+ return font->face->table.MATH->get_variants().get_glyph_variants (glyph, direction, font,
+ start_offset,
+ variants_count,
+ variants);
}
/**
@@ -211,8 +211,7 @@ hb_position_t
hb_ot_math_get_min_connector_overlap (hb_font_t *font,
hb_direction_t direction)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_min_connector_overlap (direction, font);
+ return font->face->table.MATH->get_variants().get_min_connector_overlap (direction, font);
}
/**
@@ -244,10 +243,11 @@ hb_ot_math_get_glyph_assembly (hb_font_t *font,
hb_ot_math_glyph_part_t *parts, /* OUT */
hb_position_t *italics_correction /* OUT */)
{
- const OT::MATH &math = _get_math (font->face);
- return math.get_math_variants().get_glyph_parts (glyph, direction, font,
- start_offset,
- parts_count,
- parts,
- italics_correction);
+ return font->face->table.MATH->get_variants().get_glyph_parts (glyph,
+ direction,
+ font,
+ start_offset,
+ parts_count,
+ parts,
+ italics_correction);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-maxp-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-maxp-table.hh
index 2572ad288f5..198dd2518c3 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-maxp-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-maxp-table.hh
@@ -92,7 +92,7 @@ struct maxp
if (version.major == 1)
{
const maxpV1Tail &v1 = StructAfter<maxpV1Tail> (*this);
- return v1.sanitize (c);
+ return_trace (v1.sanitize (c));
}
return_trace (likely (version.major == 0 && version.minor == 0x5000u));
}
@@ -117,7 +117,7 @@ struct maxp
return result;
}
- static inline void drop_hint_fields (hb_subset_plan_t *plan, maxp *maxp_prime)
+ static inline void drop_hint_fields (hb_subset_plan_t *plan HB_UNUSED, maxp *maxp_prime)
{
if (maxp_prime->version.major == 1)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.cc
new file mode 100644
index 00000000000..0e37e0acb09
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.cc
@@ -0,0 +1,457 @@
+/*
+ * 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-name-language.hh"
+
+/* Following two tables were generated by joining FreeType, FontConfig,
+ * and OpenType specification language lists, then filled in missing
+ * entries using:
+ * https://docs.microsoft.com/en-us/windows/desktop/intl/language-identifier-constants-and-strings
+ */
+
+struct hb_ot_language_map_t
+{
+ static int cmp (const void *key, const void *item)
+ {
+ unsigned int a = * (unsigned int *) key;
+ unsigned int b = ((const hb_ot_language_map_t *) item)->code;
+ return a < b ? -1 : a > b ? +1 : 0;
+ }
+
+ uint16_t code;
+ char lang[6];
+};
+
+static const hb_ot_language_map_t
+hb_ms_language_map[] =
+{
+ {0x0001, "ar"}, /* ??? */
+ {0x0004, "zh"}, /* ??? */
+ {0x0009, "en"}, /* ??? */
+ {0x0401, "ar"}, /* Arabic (Saudi Arabia) */
+ {0x0402, "bg"}, /* Bulgarian (Bulgaria) */
+ {0x0403, "ca"}, /* Catalan (Catalan) */
+ {0x0404, "zh-tw"}, /* Chinese (Taiwan) */
+ {0x0405, "cs"}, /* Czech (Czech Republic) */
+ {0x0406, "da"}, /* Danish (Denmark) */
+ {0x0407, "de"}, /* German (Germany) */
+ {0x0408, "el"}, /* Greek (Greece) */
+ {0x0409, "en"}, /* English (United States) */
+ {0x040A, "es"}, /* Spanish (Traditional Sort) (Spain) */
+ {0x040B, "fi"}, /* Finnish (Finland) */
+ {0x040C, "fr"}, /* French (France) */
+ {0x040D, "he"}, /* Hebrew (Israel) */
+ {0x040E, "hu"}, /* Hungarian (Hungary) */
+ {0x040F, "is"}, /* Icelandic (Iceland) */
+ {0x0410, "it"}, /* Italian (Italy) */
+ {0x0411, "ja"}, /* Japanese (Japan) */
+ {0x0412, "ko"}, /* Korean (Korea) */
+ {0x0413, "nl"}, /* Dutch (Netherlands) */
+ {0x0414, "no"}, /* Norwegian (Bokmal) (Norway) */
+ {0x0415, "pl"}, /* Polish (Poland) */
+ {0x0416, "pt"}, /* Portuguese (Brazil) */
+ {0x0417, "rm"}, /* Romansh (Switzerland) */
+ {0x0418, "ro"}, /* Romanian (Romania) */
+ {0x0419, "ru"}, /* Russian (Russia) */
+ {0x041A, "hr"}, /* Croatian (Croatia) */
+ {0x041B, "sk"}, /* Slovak (Slovakia) */
+ {0x041C, "sq"}, /* Albanian (Albania) */
+ {0x041D, "sv"}, /* Swedish (Sweden) */
+ {0x041E, "th"}, /* Thai (Thailand) */
+ {0x041F, "tr"}, /* Turkish (Turkey) */
+ {0x0420, "ur"}, /* Urdu (Islamic Republic of Pakistan) */
+ {0x0421, "id"}, /* Indonesian (Indonesia) */
+ {0x0422, "uk"}, /* Ukrainian (Ukraine) */
+ {0x0423, "be"}, /* Belarusian (Belarus) */
+ {0x0424, "sl"}, /* Slovenian (Slovenia) */
+ {0x0425, "et"}, /* Estonian (Estonia) */
+ {0x0426, "lv"}, /* Latvian (Latvia) */
+ {0x0427, "lt"}, /* Lithuanian (Lithuania) */
+ {0x0428, "tg"}, /* Tajik (Cyrillic) (Tajikistan) */
+ {0x0429, "fa"}, /* Persian (Iran) */
+ {0x042A, "vi"}, /* Vietnamese (Vietnam) */
+ {0x042B, "hy"}, /* Armenian (Armenia) */
+ {0x042C, "az"}, /* Azeri (Latin) (Azerbaijan) */
+ {0x042D, "eu"}, /* Basque (Basque) */
+ {0x042E, "hsb"}, /* Upper Sorbian (Germany) */
+ {0x042F, "mk"}, /* Macedonian (FYROM) (Former Yugoslav Republic of Macedonia) */
+ {0x0430, "st"}, /* ??? */
+ {0x0431, "ts"}, /* ??? */
+ {0x0432, "tn"}, /* Setswana (South Africa) */
+ {0x0433, "ven"}, /* ??? */
+ {0x0434, "xh"}, /* isiXhosa (South Africa) */
+ {0x0435, "zu"}, /* isiZulu (South Africa) */
+ {0x0436, "af"}, /* Afrikaans (South Africa) */
+ {0x0437, "ka"}, /* Georgian (Georgia) */
+ {0x0438, "fo"}, /* Faroese (Faroe Islands) */
+ {0x0439, "hi"}, /* Hindi (India) */
+ {0x043A, "mt"}, /* Maltese (Malta) */
+ {0x043B, "se"}, /* Sami (Northern) (Norway) */
+ {0x043C, "ga"}, /* ??? */
+ {0x043D, "yi"}, /* ??? */
+ {0x043E, "ms"}, /* Malay (Malaysia) */
+ {0x043F, "kk"}, /* Kazakh (Kazakhstan) */
+ {0x0440, "ky"}, /* Kyrgyz (Kyrgyzstan) */
+ {0x0441, "sw"}, /* Kiswahili (Kenya) */
+ {0x0442, "tk"}, /* Turkmen (Turkmenistan) */
+ {0x0443, "uz"}, /* Uzbek (Latin) (Uzbekistan) */
+ {0x0444, "tt"}, /* Tatar (Russia) */
+ {0x0445, "bn"}, /* Bengali (India) */
+ {0x0446, "pa"}, /* Punjabi (India) */
+ {0x0447, "gu"}, /* Gujarati (India) */
+ {0x0448, "or"}, /* Odia (formerly Oriya) (India) */
+ {0x0449, "ta"}, /* Tamil (India) */
+ {0x044A, "te"}, /* Telugu (India) */
+ {0x044B, "kn"}, /* Kannada (India) */
+ {0x044C, "ml"}, /* Malayalam (India) */
+ {0x044D, "as"}, /* Assamese (India) */
+ {0x044E, "mr"}, /* Marathi (India) */
+ {0x044F, "sa"}, /* Sanskrit (India) */
+ {0x0450, "mn"}, /* Mongolian (Cyrillic) (Mongolia) */
+ {0x0451, "bo"}, /* Tibetan (PRC) */
+ {0x0452, "cy"}, /* Welsh (United Kingdom) */
+ {0x0453, "km"}, /* Khmer (Cambodia) */
+ {0x0454, "lo"}, /* Lao (Lao P.D.R.) */
+ {0x0455, "my"}, /* ??? */
+ {0x0456, "gl"}, /* Galician (Galician) */
+ {0x0457, "kok"}, /* Konkani (India) */
+ {0x0458, "mni"}, /* ??? */
+ {0x0459, "sd"}, /* ??? */
+ {0x045A, "syr"}, /* Syriac (Syria) */
+ {0x045B, "si"}, /* Sinhala (Sri Lanka) */
+ {0x045C, "chr"}, /* ??? */
+ {0x045D, "iu"}, /* Inuktitut (Canada) */
+ {0x045E, "am"}, /* Amharic (Ethiopia) */
+ {0x0460, "ks"}, /* ??? */
+ {0x0461, "ne"}, /* Nepali (Nepal) */
+ {0x0462, "fy"}, /* Frisian (Netherlands) */
+ {0x0463, "ps"}, /* Pashto (Afghanistan) */
+ {0x0464, "phi"}, /* Filipino (Philippines) */
+ {0x0465, "div"}, /* Divehi (Maldives) */
+ {0x0468, "ha"}, /* Hausa (Latin) (Nigeria) */
+ {0x046A, "yo"}, /* Yoruba (Nigeria) */
+ {0x046B, "quz"}, /* Quechua (Bolivia) */
+ {0x046C, "nso"}, /* Sesotho sa Leboa (South Africa) */
+ {0x046D, "ba"}, /* Bashkir (Russia) */
+ {0x046E, "lb"}, /* Luxembourgish (Luxembourg) */
+ {0x046F, "kl"}, /* Greenlandic (Greenland) */
+ {0x0470, "ibo"}, /* Igbo (Nigeria) */
+ {0x0471, "kau"}, /* ??? */
+ {0x0472, "om"}, /* ??? */
+ {0x0473, "ti"}, /* ??? */
+ {0x0474, "gn"}, /* ??? */
+ {0x0475, "haw"}, /* ??? */
+ {0x0476, "la"}, /* ??? */
+ {0x0477, "so"}, /* ??? */
+ {0x0478, "ii"}, /* Yi (PRC) */
+ {0x0479, "pap"}, /* ??? */
+ {0x047A, "arn"}, /* Mapudungun (Chile) */
+ {0x047C, "moh"}, /* Mohawk (Mohawk) */
+ {0x047E, "br"}, /* Breton (France) */
+ {0x0480, "ug"}, /* Uighur (PRC) */
+ {0x0481, "mi"}, /* Maori (New Zealand) */
+ {0x0482, "oc"}, /* Occitan (France) */
+ {0x0483, "co"}, /* Corsican (France) */
+ {0x0484, "gsw"}, /* Alsatian (France) */
+ {0x0485, "sah"}, /* Yakut (Russia) */
+ {0x0486, "qut"}, /* K'iche (Guatemala) */
+ {0x0487, "rw"}, /* Kinyarwanda (Rwanda) */
+ {0x0488, "wo"}, /* Wolof (Senegal) */
+ {0x048C, "fa"}, /* Dari (Afghanistan) */
+ {0x0801, "ar"}, /* Arabic (Iraq) */
+ {0x0804, "zh-cn"}, /* Chinese (People’s Republic of China) */
+ {0x0807, "de"}, /* German (Switzerland) */
+ {0x0809, "en"}, /* English (United Kingdom) */
+ {0x080A, "es"}, /* Spanish (Mexico) */
+ {0x080C, "fr"}, /* French (Belgium) */
+ {0x0810, "it"}, /* Italian (Switzerland) */
+ {0x0812, "ko"}, /* ??? */
+ {0x0813, "nl"}, /* Dutch (Belgium) */
+ {0x0814, "nn"}, /* Norwegian (Nynorsk) (Norway) */
+ {0x0816, "pt"}, /* Portuguese (Portugal) */
+ {0x0818, "mo"}, /* ??? */
+ {0x0819, "ru"}, /* ??? */
+ {0x081A, "sr"}, /* Serbian (Latin) (Serbia) */
+ {0x081D, "sv"}, /* Sweden (Finland) */
+ {0x0820, "ur"}, /* ??? */
+ {0x0827, "lt"}, /* ??? */
+ {0x082C, "az"}, /* Azeri (Cyrillic) (Azerbaijan) */
+ {0x082E, "dsb"}, /* Lower Sorbian (Germany) */
+//{0x083B, ""}, /* Sami (Northern) (Sweden) */
+ {0x083C, "gd"}, /* Irish (Ireland) */
+ {0x083E, "ms"}, /* Malay (Brunei Darussalam) */
+ {0x0843, "uz"}, /* Uzbek (Cyrillic) (Uzbekistan) */
+ {0x0845, "bn"}, /* Bengali (Bangladesh) */
+ {0x0846, "ar"}, /* ??? */
+ {0x0850, "mn"}, /* Mongolian (Traditional) (People’s Republic of China) */
+ {0x0851, "dz"}, /* ??? */
+ {0x085D, "iu"}, /* Inuktitut (Latin) (Canada) */
+ {0x085F, "tzm"}, /* Tamazight (Latin) (Algeria) */
+ {0x0861, "ne"}, /* ??? */
+//{0x086B, ""}, /* Quechua (Ecuador) */
+ {0x0873, "ti"}, /* ??? */
+ {0x0C01, "ar"}, /* Arabic (Egypt) */
+ {0x0C04, "zh-hk"}, /* Chinese (Hong Kong S.A.R.) */
+ {0x0C07, "de"}, /* German (Austria) */
+ {0x0C09, "en"}, /* English (Australia) */
+ {0x0C0A, "es"}, /* Spanish (Modern Sort) (Spain) */
+ {0x0C0C, "fr"}, /* French (Canada) */
+ {0x0C1A, "sr"}, /* Serbian (Cyrillic) (Serbia) */
+ {0x0C3B, "se"}, /* Sami (Northern) (Finland) */
+//{0x0C6B, ""}, /* Quechua (Peru) */
+ {0x1001, "ar"}, /* Arabic (Libya) */
+ {0x1004, "zh-sg"}, /* Chinese (Singapore) */
+ {0x1007, "de"}, /* German (Luxembourg) */
+ {0x1009, "en"}, /* English (Canada) */
+ {0x100A, "es"}, /* Spanish (Guatemala) */
+ {0x100C, "fr"}, /* French (Switzerland) */
+ {0x101A, "hr"}, /* Croatian (Latin) (Bosnia and Herzegovina) */
+ {0x103B, "smj"}, /* Sami (Lule) (Norway) */
+ {0x1401, "ar"}, /* Arabic (Algeria) */
+//{0x1404, ""}, /* Chinese (Macao S.A.R.) */
+ {0x1407, "de"}, /* German (Liechtenstein) */
+ {0x1409, "en"}, /* English (New Zealand) */
+ {0x140A, "es"}, /* Spanish (Costa Rica) */
+ {0x140C, "fr"}, /* French (Luxembourg) */
+ {0x141A, "bs"}, /* Bosnian (Latin) (Bosnia and Herzegovina) */
+//{0x143B, ""}, /* Sami (Lule) (Sweden) */
+ {0x1801, "ar"}, /* Arabic (Morocco) */
+ {0x1809, "en"}, /* English (Ireland) */
+ {0x180A, "es"}, /* Spanish (Panama) */
+ {0x180C, "fr"}, /* French (Principality of Monaco) */
+//{0x181A, ""}, /* Serbian (Latin) (Bosnia and Herzegovina) */
+ {0x183B, "sma"}, /* Sami (Southern) (Norway) */
+ {0x1C01, "ar"}, /* Arabic (Tunisia) */
+ {0x1C09, "en"}, /* English (South Africa) */
+ {0x1C0A, "es"}, /* Spanish (Dominican Republic) */
+ {0x1C0C, "fr"}, /* ??? */
+//{0x1C1A, ""}, /* Serbian (Cyrillic) (Bosnia and Herzegovina) */
+//{0x1C3B, ""}, /* Sami (Southern) (Sweden) */
+ {0x2001, "ar"}, /* Arabic (Oman) */
+ {0x2009, "en"}, /* English (Jamaica) */
+ {0x200A, "es"}, /* Spanish (Venezuela) */
+ {0x200C, "fr"}, /* ??? */
+ {0x201A, "bs"}, /* Bosnian (Cyrillic) (Bosnia and Herzegovina) */
+ {0x203B, "sms"}, /* Sami (Skolt) (Finland) */
+ {0x2401, "ar"}, /* Arabic (Yemen) */
+ {0x2409, "en"}, /* English (Caribbean) */
+ {0x240A, "es"}, /* Spanish (Colombia) */
+ {0x240C, "fr"}, /* ??? */
+ {0x243B, "smn"}, /* Sami (Inari) (Finland) */
+ {0x2801, "ar"}, /* Arabic (Syria) */
+ {0x2809, "en"}, /* English (Belize) */
+ {0x280A, "es"}, /* Spanish (Peru) */
+ {0x280C, "fr"}, /* ??? */
+ {0x2C01, "ar"}, /* Arabic (Jordan) */
+ {0x2C09, "en"}, /* English (Trinidad and Tobago) */
+ {0x2C0A, "es"}, /* Spanish (Argentina) */
+ {0x2C0C, "fr"}, /* ??? */
+ {0x3001, "ar"}, /* Arabic (Lebanon) */
+ {0x3009, "en"}, /* English (Zimbabwe) */
+ {0x300A, "es"}, /* Spanish (Ecuador) */
+ {0x300C, "fr"}, /* ??? */
+ {0x3401, "ar"}, /* Arabic (Kuwait) */
+ {0x3409, "en"}, /* English (Republic of the Philippines) */
+ {0x340A, "es"}, /* Spanish (Chile) */
+ {0x340C, "fr"}, /* ??? */
+ {0x3801, "ar"}, /* Arabic (U.A.E.) */
+ {0x380A, "es"}, /* Spanish (Uruguay) */
+ {0x380C, "fr"}, /* ??? */
+ {0x3C01, "ar"}, /* Arabic (Bahrain) */
+ {0x3C09, "en"}, /* ??? */
+ {0x3C0A, "es"}, /* Spanish (Paraguay) */
+ {0x3C0C, "fr"}, /* ??? */
+ {0x4001, "ar"}, /* Arabic (Qatar) */
+ {0x4009, "en"}, /* English (India) */
+ {0x400A, "es"}, /* Spanish (Bolivia) */
+ {0x4409, "en"}, /* English (Malaysia) */
+ {0x440A, "es"}, /* Spanish (El Salvador) */
+ {0x4809, "en"}, /* English (Singapore) */
+ {0x480A, "es"}, /* Spanish (Honduras) */
+ {0x4C0A, "es"}, /* Spanish (Nicaragua) */
+ {0x500A, "es"}, /* Spanish (Puerto Rico) */
+ {0x540A, "es"}, /* Spanish (United States) */
+ {0xE40A, "es"}, /* ??? */
+ {0xE40C, "fr"}, /* ??? */
+};
+
+static const hb_ot_language_map_t
+hb_mac_language_map[] =
+{
+ { 0, "en"}, /* English */
+ { 1, "fr"}, /* French */
+ { 2, "de"}, /* German */
+ { 3, "it"}, /* Italian */
+ { 4, "nl"}, /* Dutch */
+ { 5, "sv"}, /* Swedish */
+ { 6, "es"}, /* Spanish */
+ { 7, "da"}, /* Danish */
+ { 8, "pt"}, /* Portuguese */
+ { 9, "no"}, /* Norwegian */
+ { 10, "he"}, /* Hebrew */
+ { 11, "ja"}, /* Japanese */
+ { 12, "ar"}, /* Arabic */
+ { 13, "fi"}, /* Finnish */
+ { 14, "el"}, /* Greek */
+ { 15, "is"}, /* Icelandic */
+ { 16, "mt"}, /* Maltese */
+ { 17, "tr"}, /* Turkish */
+ { 18, "hr"}, /* Croatian */
+ { 19, "zh-tw"}, /* Chinese (Traditional) */
+ { 20, "ur"}, /* Urdu */
+ { 21, "hi"}, /* Hindi */
+ { 22, "th"}, /* Thai */
+ { 23, "ko"}, /* Korean */
+ { 24, "lt"}, /* Lithuanian */
+ { 25, "pl"}, /* Polish */
+ { 26, "hu"}, /* Hungarian */
+ { 27, "et"}, /* Estonian */
+ { 28, "lv"}, /* Latvian */
+//{ 29, ""}, /* Sami */
+ { 30, "fo"}, /* Faroese */
+ { 31, "fa"}, /* Farsi/Persian */
+ { 32, "ru"}, /* Russian */
+ { 33, "zh-cn"}, /* Chinese (Simplified) */
+ { 34, "nl"}, /* Flemish */
+ { 35, "ga"}, /* Irish Gaelic */
+ { 36, "sq"}, /* Albanian */
+ { 37, "ro"}, /* Romanian */
+ { 38, "cs"}, /* Czech */
+ { 39, "sk"}, /* Slovak */
+ { 40, "sl"}, /* Slovenian */
+ { 41, "yi"}, /* Yiddish */
+ { 42, "sr"}, /* Serbian */
+ { 43, "mk"}, /* Macedonian */
+ { 44, "bg"}, /* Bulgarian */
+ { 45, "uk"}, /* Ukrainian */
+ { 46, "be"}, /* Byelorussian */
+ { 47, "uz"}, /* Uzbek */
+ { 48, "kk"}, /* Kazakh */
+ { 49, "az"}, /* Azerbaijani (Cyrillic script) */
+ { 50, "az"}, /* Azerbaijani (Arabic script) */
+ { 51, "hy"}, /* Armenian */
+ { 52, "ka"}, /* Georgian */
+ { 53, "mo"}, /* Moldavian */
+ { 54, "ky"}, /* Kirghiz */
+ { 55, "tg"}, /* Tajiki */
+ { 56, "tk"}, /* Turkmen */
+ { 57, "mn"}, /* Mongolian (Mongolian script) */
+ { 58, "mn"}, /* Mongolian (Cyrillic script) */
+ { 59, "ps"}, /* Pashto */
+ { 60, "ku"}, /* Kurdish */
+ { 61, "ks"}, /* Kashmiri */
+ { 62, "sd"}, /* Sindhi */
+ { 63, "bo"}, /* Tibetan */
+ { 64, "ne"}, /* Nepali */
+ { 65, "sa"}, /* Sanskrit */
+ { 66, "mr"}, /* Marathi */
+ { 67, "bn"}, /* Bengali */
+ { 68, "as"}, /* Assamese */
+ { 69, "gu"}, /* Gujarati */
+ { 70, "pa"}, /* Punjabi */
+ { 71, "or"}, /* Oriya */
+ { 72, "ml"}, /* Malayalam */
+ { 73, "kn"}, /* Kannada */
+ { 74, "ta"}, /* Tamil */
+ { 75, "te"}, /* Telugu */
+ { 76, "si"}, /* Sinhalese */
+ { 77, "my"}, /* Burmese */
+ { 78, "km"}, /* Khmer */
+ { 79, "lo"}, /* Lao */
+ { 80, "vi"}, /* Vietnamese */
+ { 81, "id"}, /* Indonesian */
+ { 82, "tl"}, /* Tagalog */
+ { 83, "ms"}, /* Malay (Roman script) */
+ { 84, "ms"}, /* Malay (Arabic script) */
+ { 85, "am"}, /* Amharic */
+ { 86, "ti"}, /* Tigrinya */
+ { 87, "om"}, /* Galla */
+ { 88, "so"}, /* Somali */
+ { 89, "sw"}, /* Swahili */
+ { 90, "rw"}, /* Kinyarwanda/Ruanda */
+ { 91, "rn"}, /* Rundi */
+ { 92, "ny"}, /* Nyanja/Chewa */
+ { 93, "mg"}, /* Malagasy */
+ { 94, "eo"}, /* Esperanto */
+ {128, "cy"}, /* Welsh */
+ {129, "eu"}, /* Basque */
+ {130, "ca"}, /* Catalan */
+ {131, "la"}, /* Latin */
+ {132, "qu"}, /* Quechua */
+ {133, "gn"}, /* Guarani */
+ {134, "ay"}, /* Aymara */
+ {135, "tt"}, /* Tatar */
+ {136, "ug"}, /* Uighur */
+ {137, "dz"}, /* Dzongkha */
+ {138, "jw"}, /* Javanese (Roman script) */
+ {139, "su"}, /* Sundanese (Roman script) */
+ {140, "gl"}, /* Galician */
+ {141, "af"}, /* Afrikaans */
+ {142, "br"}, /* Breton */
+ {143, "iu"}, /* Inuktitut */
+ {144, "gd"}, /* Scottish Gaelic */
+ {145, "gv"}, /* Manx Gaelic */
+ {146, "ga"}, /* Irish Gaelic (with dot above) */
+ {147, "to"}, /* Tongan */
+ {148, "el"}, /* Greek (polytonic) */
+ {149, "ik"}, /* Greenlandic */
+ {150, "az"}, /* Azerbaijani (Roman script) */
+};
+
+
+static hb_language_t
+_hb_ot_name_language_for (unsigned int code,
+ const hb_ot_language_map_t *array,
+ unsigned int len)
+{
+ const hb_ot_language_map_t *entry = (const hb_ot_language_map_t *)
+ hb_bsearch (&code,
+ array,
+ len,
+ sizeof (array[0]),
+ hb_ot_language_map_t::cmp);
+
+ if (entry)
+ return hb_language_from_string (entry->lang, -1);
+
+ return HB_LANGUAGE_INVALID;
+}
+
+hb_language_t
+_hb_ot_name_language_for_ms_code (unsigned int code)
+{
+ return _hb_ot_name_language_for (code,
+ hb_ms_language_map,
+ ARRAY_LENGTH (hb_ms_language_map));
+}
+
+hb_language_t
+_hb_ot_name_language_for_mac_code (unsigned int code)
+{
+ return _hb_ot_name_language_for (code,
+ hb_mac_language_map,
+ ARRAY_LENGTH (hb_mac_language_map));
+}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.hh
new file mode 100644
index 00000000000..903076c0d56
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-language.hh
@@ -0,0 +1,40 @@
+/*
+ * 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_OT_NAME_LANGUAGE_HH
+#define HB_OT_NAME_LANGUAGE_HH
+
+#include "hb.hh"
+
+
+HB_INTERNAL hb_language_t
+_hb_ot_name_language_for_ms_code (unsigned int code);
+
+HB_INTERNAL hb_language_t
+_hb_ot_name_language_for_mac_code (unsigned int code);
+
+
+#endif /* HB_OT_NAME_LANGUAGE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-table.hh
index bb49c2cb0d2..ab07b7196ad 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name-table.hh
@@ -28,34 +28,69 @@
#define HB_OT_NAME_TABLE_HH
#include "hb-open-type.hh"
+#include "hb-ot-name-language.hh"
+#include "hb-aat-layout.hh"
namespace OT {
+#define entry_score var.u16[0]
+#define entry_index var.u16[1]
+
+
/*
* name -- Naming
* https://docs.microsoft.com/en-us/typography/opentype/spec/name
*/
#define HB_OT_TAG_name HB_TAG('n','a','m','e')
+#define UNSUPPORTED 42
struct NameRecord
{
- static int cmp (const void *pa, const void *pb)
+ inline hb_language_t language (hb_face_t *face) const
{
- const NameRecord *a = (const NameRecord *) pa;
- const NameRecord *b = (const NameRecord *) pb;
- int ret;
- ret = b->platformID.cmp (a->platformID);
- if (ret) return ret;
- ret = b->encodingID.cmp (a->encodingID);
- if (ret) return ret;
- ret = b->languageID.cmp (a->languageID);
- if (ret) return ret;
- ret = b->nameID.cmp (a->nameID);
- if (ret) return ret;
- return 0;
+ unsigned int p = platformID;
+ unsigned int l = languageID;
+
+ if (p == 3)
+ return _hb_ot_name_language_for_ms_code (l);
+
+ if (p == 1)
+ return _hb_ot_name_language_for_mac_code (l);
+
+ if (p == 0)
+ return _hb_aat_language_get (face, l);
+
+ return HB_LANGUAGE_INVALID;
+ }
+
+ inline uint16_t score (void) const
+ {
+ /* Same order as in cmap::find_best_subtable(). */
+ unsigned int p = platformID;
+ unsigned int e = encodingID;
+
+ /* 32-bit. */
+ if (p == 3 && e == 10) return 0;
+ if (p == 0 && e == 6) return 1;
+ if (p == 0 && e == 4) return 2;
+
+ /* 16-bit. */
+ if (p == 3 && e == 1) return 3;
+ if (p == 0 && e == 3) return 4;
+ if (p == 0 && e == 2) return 5;
+ if (p == 0 && e == 1) return 6;
+ if (p == 0 && e == 0) return 7;
+
+ /* Symbol. */
+ if (p == 3 && e == 0) return 8;
+
+ /* We treat all Mac Latin names as ASCII only. */
+ if (p == 1 && e == 0) return 10; /* 10 is magic number :| */
+
+ return UNSUPPORTED;
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
@@ -75,39 +110,57 @@ struct NameRecord
DEFINE_SIZE_STATIC (12);
};
+static int
+_hb_ot_name_entry_cmp_key (const void *pa, const void *pb)
+{
+ const hb_ot_name_entry_t *a = (const hb_ot_name_entry_t *) pa;
+ const hb_ot_name_entry_t *b = (const hb_ot_name_entry_t *) pb;
+
+ /* Compare by name_id, then language. */
+
+ if (a->name_id != b->name_id)
+ return a->name_id < b->name_id ? -1 : +1;
+
+ if (a->language == b->language) return 0;
+ if (!a->language) return -1;
+ if (!b->language) return +1;
+ return strcmp (hb_language_to_string (a->language),
+ hb_language_to_string (b->language));
+}
+
+static int
+_hb_ot_name_entry_cmp (const void *pa, const void *pb)
+{
+ /* Compare by name_id, then language, then score, then index. */
+
+ int v = _hb_ot_name_entry_cmp_key (pa, pb);
+ if (v)
+ return v;
+
+ const hb_ot_name_entry_t *a = (const hb_ot_name_entry_t *) pa;
+ const hb_ot_name_entry_t *b = (const hb_ot_name_entry_t *) pb;
+
+ if (a->entry_score != b->entry_score)
+ return a->entry_score < b->entry_score ? -1 : +1;
+
+ if (a->entry_index != b->entry_index)
+ return a->entry_index < b->entry_index ? -1 : +1;
+
+ return 0;
+}
+
struct name
{
static const hb_tag_t tableTag = HB_OT_TAG_name;
- inline unsigned int get_name (unsigned int platform_id,
- unsigned int encoding_id,
- unsigned int language_id,
- unsigned int name_id,
- void *buffer,
- unsigned int buffer_length) const
- {
- NameRecord key;
- key.platformID.set (platform_id);
- key.encodingID.set (encoding_id);
- key.languageID.set (language_id);
- key.nameID.set (name_id);
- NameRecord *match = (NameRecord *) bsearch (&key, nameRecordZ.arrayZ, count, sizeof (nameRecordZ[0]), NameRecord::cmp);
-
- if (!match)
- return 0;
-
- unsigned int length = MIN (buffer_length, (unsigned int) match->length);
- memcpy (buffer, (char *) this + stringOffset + match->offset, length);
- return length;
- }
-
inline unsigned int get_size (void) const
{ return min_size + count * nameRecordZ[0].min_size; }
inline bool sanitize_records (hb_sanitize_context_t *c) const {
TRACE_SANITIZE (this);
- char *string_pool = (char *) this + stringOffset;
+ const void *string_pool = (this+stringOffset).arrayZ;
unsigned int _count = count;
+ /* Move to run-time?! */
for (unsigned int i = 0; i < _count; i++)
if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false);
return_trace (true);
@@ -119,19 +172,105 @@ struct name
return_trace (c->check_struct (this) &&
likely (format == 0 || format == 1) &&
c->check_array (nameRecordZ.arrayZ, count) &&
- sanitize_records (c));
+ c->check_range (this, stringOffset));
}
+ struct accelerator_t
+ {
+ inline void init (hb_face_t *face)
+ {
+ this->table = hb_sanitize_context_t().reference_table<name> (face);
+ assert (this->table.get_length () >= this->table->stringOffset);
+ this->pool = (this->table+this->table->stringOffset).arrayZ;
+ this->pool_len = this->table.get_length () - this->table->stringOffset;
+ const hb_array_t<const NameRecord> all_names (this->table->nameRecordZ.arrayZ,
+ this->table->count);
+
+ this->names.init ();
+ this->names.alloc (all_names.len);
+
+ for (uint16_t i = 0; i < all_names.len; i++)
+ {
+ hb_ot_name_entry_t *entry = this->names.push ();
+
+ entry->name_id = all_names[i].nameID;
+ entry->language = all_names[i].language (face);
+ entry->entry_score = all_names[i].score ();
+ entry->entry_index = i;
+ }
+
+ this->names.qsort (_hb_ot_name_entry_cmp);
+ /* Walk and pick best only for each name_id,language pair,
+ * while dropping unsupported encodings. */
+ unsigned int j = 0;
+ for (unsigned int i = 0; i < this->names.len; i++)
+ {
+ if (this->names[i].entry_score == UNSUPPORTED ||
+ this->names[i].language == HB_LANGUAGE_INVALID)
+ continue;
+ if (i &&
+ this->names[i - 1].name_id == this->names[i].name_id &&
+ this->names[i - 1].language == this->names[i].language)
+ continue;
+ this->names[j++] = this->names[i];
+ }
+ this->names.resize (j);
+ }
+
+ inline void fini (void)
+ {
+ this->names.fini ();
+ this->table.destroy ();
+ }
+
+ inline int get_index (hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *width=nullptr) const
+ {
+ const hb_ot_name_entry_t key = {name_id, {0}, language};
+ const hb_ot_name_entry_t *entry = (const hb_ot_name_entry_t *)
+ hb_bsearch (&key,
+ this->names.arrayZ(),
+ this->names.len,
+ sizeof (key),
+ _hb_ot_name_entry_cmp_key);
+ if (!entry)
+ return -1;
+
+ if (width)
+ *width = entry->entry_score < 10 ? 2 : 1;
+
+ return entry->entry_index;
+ }
+
+ inline hb_bytes_t get_name (unsigned int idx) const
+ {
+ const hb_array_t<const NameRecord> all_names (table->nameRecordZ.arrayZ, table->count);
+ const NameRecord &record = all_names[idx];
+ const hb_array_t<const char> string_pool ((const char *) pool, pool_len);
+ return string_pool.sub_array (record.offset, record.length).as_bytes ();
+ }
+
+ private:
+ const void *pool;
+ unsigned int pool_len;
+ public:
+ hb_blob_ptr_t<name> table;
+ hb_vector_t<hb_ot_name_entry_t> names;
+ };
+
/* We only implement format 0 for now. */
HBUINT16 format; /* Format selector (=0/1). */
HBUINT16 count; /* Number of name records. */
- Offset16 stringOffset; /* Offset to start of string storage (from start of table). */
+ OffsetTo<UnsizedArrayOf<HBUINT8>, HBUINT16, false>
+ stringOffset; /* Offset to start of string storage (from start of table). */
UnsizedArrayOf<NameRecord>
nameRecordZ; /* The name records where count is the number of records. */
public:
DEFINE_SIZE_ARRAY (6, nameRecordZ);
};
+struct name_accelerator_t : name::accelerator_t {};
} /* namespace OT */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.cc
new file mode 100644
index 00000000000..4c886609688
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.cc
@@ -0,0 +1,224 @@
+/*
+ * 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.hh"
+
+#include "hb-ot-name-table.hh"
+
+#include "hb-ot-face.hh"
+#include "hb-utf.hh"
+
+
+/**
+ * SECTION:hb-ot-name
+ * @title: hb-ot-name
+ * @short_description: OpenType font name information
+ * @include: hb-ot.h
+ *
+ * Functions for fetching name strings from OpenType fonts.
+ **/
+
+
+/**
+ * hb_ot_name_list_names:
+ * @face: font face.
+ * @num_entries: (out) (allow-none): number of returned entries.
+ *
+ * Enumerates all available name IDs and language combinations. Returned
+ * array is owned by the @face and should not be modified. It can be
+ * used as long as @face is alive.
+ *
+ * Returns: (out) (transfer none) (array length=num_entries): Array of available name entries.
+ * Since: 2.1.0
+ **/
+const hb_ot_name_entry_t *
+hb_ot_name_list_names (hb_face_t *face,
+ unsigned int *num_entries /* OUT */)
+{
+ const OT::name_accelerator_t &name = *face->table.name;
+ if (num_entries) *num_entries = name.names.len;
+ return name.names.arrayZ();
+}
+
+
+template <typename in_utf_t, typename out_utf_t>
+static inline unsigned int
+hb_ot_name_convert_utf (const hb_bytes_t *bytes,
+ unsigned int *text_size /* IN/OUT */,
+ typename out_utf_t::codepoint_t *text /* OUT */)
+{
+ unsigned int src_len = bytes->len / sizeof (typename in_utf_t::codepoint_t);
+ const typename in_utf_t::codepoint_t *src = (const typename in_utf_t::codepoint_t *) bytes->arrayZ;
+ const typename in_utf_t::codepoint_t *src_end = src + src_len;
+
+ typename out_utf_t::codepoint_t *dst = text;
+
+ hb_codepoint_t unicode;
+ const hb_codepoint_t replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT;
+
+ if (text_size && *text_size)
+ {
+ (*text_size)--; /* Same room for NUL-termination. */
+ const typename out_utf_t::codepoint_t *dst_end = text + *text_size;
+
+ while (src < src_end && dst < dst_end)
+ {
+ const typename in_utf_t::codepoint_t *src_next = in_utf_t::next (src, src_end, &unicode, replacement);
+ typename out_utf_t::codepoint_t *dst_next = out_utf_t::encode (dst, dst_end, unicode);
+ if (dst_next == dst)
+ break; /* Out-of-room. */
+
+ dst = dst_next;
+ src = src_next;
+ };
+
+ *text_size = dst - text;
+ *dst = 0; /* NUL-terminate. */
+ }
+
+ /* Accumulate length of rest. */
+ unsigned int dst_len = dst - text;
+ while (src < src_end)
+ {
+ src = in_utf_t::next (src, src_end, &unicode, replacement);
+ dst_len += out_utf_t::encode_len (unicode);
+ };
+ return dst_len;
+}
+
+template <typename utf_t>
+static inline unsigned int
+hb_ot_name_get_utf (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ typename utf_t::codepoint_t *text /* OUT */)
+{
+ const OT::name_accelerator_t &name = *face->table.name;
+
+ if (!language)
+ language = hb_language_from_string ("en", 2);
+
+ unsigned int width;
+ int idx = name.get_index (name_id, language, &width);
+ if (idx != -1)
+ {
+ hb_bytes_t bytes = name.get_name (idx);
+
+ if (width == 2) /* UTF16-BE */
+ return hb_ot_name_convert_utf<hb_utf16_be_t, utf_t> (&bytes, text_size, text);
+
+ if (width == 1) /* ASCII */
+ return hb_ot_name_convert_utf<hb_ascii_t, utf_t> (&bytes, text_size, text);
+ }
+
+ if (text_size)
+ {
+ if (*text_size)
+ *text = 0;
+ *text_size = 0;
+ }
+ return 0;
+}
+
+/**
+ * hb_ot_name_get_utf8:
+ * @face: font face.
+ * @name_id: OpenType name identifier to fetch.
+ * @language: language to fetch the name for.
+ * @text_size: (inout) (allow-none): input size of @text buffer, and output size of
+ * text written to buffer.
+ * @text: (out caller-allocates) (array length=text_size): buffer to write fetched name into.
+ *
+ * Fetches a font name from the OpenType 'name' table.
+ * If @language is #HB_LANGUAGE_INVALID, English ("en") is assumed.
+ * Returns string in UTF-8 encoding.
+ *
+ * Returns: full length of the requested string, or 0 if not found.
+ * Since: 2.1.0
+ **/
+unsigned int
+hb_ot_name_get_utf8 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ char *text /* OUT */)
+{
+ return hb_ot_name_get_utf<hb_utf8_t> (face, name_id, language, text_size,
+ (hb_utf8_t::codepoint_t *) text);
+}
+
+/**
+ * hb_ot_name_get_utf16:
+ * @face: font face.
+ * @name_id: OpenType name identifier to fetch.
+ * @language: language to fetch the name for.
+ * @text_size: (inout) (allow-none): input size of @text buffer, and output size of
+ * text written to buffer.
+ * @text: (out caller-allocates) (array length=text_size): buffer to write fetched name into.
+ *
+ * Fetches a font name from the OpenType 'name' table.
+ * If @language is #HB_LANGUAGE_INVALID, English ("en") is assumed.
+ * Returns string in UTF-16 encoding.
+ *
+ * Returns: full length of the requested string, or 0 if not found.
+ * Since: 2.1.0
+ **/
+unsigned int
+hb_ot_name_get_utf16 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ uint16_t *text /* OUT */)
+{
+ return hb_ot_name_get_utf<hb_utf16_t> (face, name_id, language, text_size, text);
+}
+
+/**
+ * hb_ot_name_get_utf32:
+ * @face: font face.
+ * @name_id: OpenType name identifier to fetch.
+ * @language: language to fetch the name for.
+ * @text_size: (inout) (allow-none): input size of @text buffer, and output size of
+ * text written to buffer.
+ * @text: (out caller-allocates) (array length=text_size): buffer to write fetched name into.
+ *
+ * Fetches a font name from the OpenType 'name' table.
+ * If @language is #HB_LANGUAGE_INVALID, English ("en") is assumed.
+ * Returns string in UTF-32 encoding.
+ *
+ * Returns: full length of the requested string, or 0 if not found.
+ * Since: 2.1.0
+ **/
+unsigned int
+hb_ot_name_get_utf32 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ uint32_t *text /* OUT */)
+{
+ return hb_ot_name_get_utf<hb_utf32_t> (face, name_id, language, text_size, text);
+}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.h b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.h
new file mode 100644
index 00000000000..8b831688427
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-name.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi.
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#ifndef HB_OT_H_IN
+#error "Include <hb-ot.h> instead."
+#endif
+
+#ifndef HB_OT_NAME_H
+#define HB_OT_NAME_H
+
+#include "hb.h"
+
+HB_BEGIN_DECLS
+
+
+/**
+ * hb_ot_name_id_t:
+ * @HB_OT_NAME_ID_INVALID: Value to represent a nonexistent name ID.
+ *
+ * An integral type representing an OpenType 'name' table name identifier.
+ * There are predefined name IDs, as well as name IDs return from other
+ * API. These can be used to fetch name strings from a font face.
+ *
+ * Since: 2.0.0
+ **/
+enum
+{
+ HB_OT_NAME_ID_COPYRIGHT = 0,
+ HB_OT_NAME_ID_FONT_FAMILY = 1,
+ HB_OT_NAME_ID_FONT_SUBFAMILY = 2,
+ HB_OT_NAME_ID_UNIQUE_ID = 3,
+ HB_OT_NAME_ID_FULL_NAME = 4,
+ HB_OT_NAME_ID_VERSION_STRING = 5,
+ HB_OT_NAME_ID_POSTSCRIPT_NAME = 6,
+ HB_OT_NAME_ID_TRADEMARK = 7,
+ HB_OT_NAME_ID_MANUFACTURER = 8,
+ HB_OT_NAME_ID_DESIGNER = 9,
+ HB_OT_NAME_ID_DESCRIPTION = 10,
+ HB_OT_NAME_ID_VENDOR_URL = 11,
+ HB_OT_NAME_ID_DESIGNER_URL = 12,
+ HB_OT_NAME_ID_LICENSE = 13,
+ HB_OT_NAME_ID_LICENSE_URL = 14,
+/*HB_OT_NAME_ID_RESERVED = 15,*/
+ HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY = 16,
+ HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY = 17,
+ HB_OT_NAME_ID_MAC_FULL_NAME = 18,
+ HB_OT_NAME_ID_SAMPLE_TEXT = 19,
+ HB_OT_NAME_ID_CID_FINDFONT_NAME = 20,
+ HB_OT_NAME_ID_WWS_FAMILY = 21,
+ HB_OT_NAME_ID_WWS_SUBFAMILY = 22,
+ HB_OT_NAME_ID_LIGHT_BACKGROUND = 23,
+ HB_OT_NAME_ID_DARK_BACKGROUND = 24,
+ HB_OT_NAME_ID_VARIATIONS_PS_PREFIX = 25,
+
+ HB_OT_NAME_ID_INVALID = 0xFFFF,
+};
+
+typedef unsigned int hb_ot_name_id_t;
+
+
+/**
+ * hb_ot_name_entry_t:
+ * @name_id: name ID
+ * @language: language
+ *
+ * Structure representing a name ID in a particular language.
+ *
+ * Since: 2.1.0
+ **/
+typedef struct hb_ot_name_entry_t
+{
+ hb_ot_name_id_t name_id;
+ /*< private >*/
+ hb_var_int_t var;
+ /*< public >*/
+ hb_language_t language;
+} hb_ot_name_entry_t;
+
+HB_EXTERN const hb_ot_name_entry_t *
+hb_ot_name_list_names (hb_face_t *face,
+ unsigned int *num_entries /* OUT */);
+
+
+HB_EXTERN unsigned int
+hb_ot_name_get_utf8 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ char *text /* OUT */);
+
+HB_EXTERN unsigned int
+hb_ot_name_get_utf16 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ uint16_t *text /* OUT */);
+
+HB_EXTERN unsigned int
+hb_ot_name_get_utf32 (hb_face_t *face,
+ hb_ot_name_id_t name_id,
+ hb_language_t language,
+ unsigned int *text_size /* IN/OUT */,
+ uint32_t *text /* OUT */);
+
+
+HB_END_DECLS
+
+#endif /* HB_OT_NAME_H */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-table.hh
index 71d2bf59d66..a5a9c07eadb 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-table.hh
@@ -36,11 +36,11 @@ namespace OT {
* OS/2 and Windows Metrics
* https://docs.microsoft.com/en-us/typography/opentype/spec/os2
*/
-#define HB_OT_TAG_os2 HB_TAG('O','S','/','2')
+#define HB_OT_TAG_OS2 HB_TAG('O','S','/','2')
-struct os2
+struct OS2
{
- static const hb_tag_t tableTag = HB_OT_TAG_os2;
+ static const hb_tag_t tableTag = HB_OT_TAG_OS2;
inline bool sanitize (hb_sanitize_context_t *c) const
{
@@ -50,12 +50,12 @@ struct os2
inline bool subset (hb_subset_plan_t *plan) const
{
- hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<os2> (plan->source);
+ hb_blob_t *os2_blob = hb_sanitize_context_t ().reference_table<OS2> (plan->source);
hb_blob_t *os2_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1);
// TODO(grieger): move to hb_blob_copy_writable_or_fail
hb_blob_destroy (os2_blob);
- os2 *os2_prime = (os2 *) hb_blob_get_data_writable (os2_prime_blob, nullptr);
+ OS2 *os2_prime = (OS2 *) hb_blob_get_data_writable (os2_prime_blob, nullptr);
if (unlikely (!os2_prime)) {
hb_blob_destroy (os2_prime_blob);
return false;
@@ -67,14 +67,14 @@ struct os2
os2_prime->usLastCharIndex.set (max_cp);
_update_unicode_ranges (plan->unicodes, os2_prime->ulUnicodeRange);
- bool result = plan->add_table (HB_OT_TAG_os2, os2_prime_blob);
+ bool result = plan->add_table (HB_OT_TAG_OS2, os2_prime_blob);
hb_blob_destroy (os2_prime_blob);
return result;
}
inline void _update_unicode_ranges (const hb_set_t *codepoints,
- HBUINT32 ulUnicodeRange[4]) const
+ HBUINT32 ulUnicodeRange[4]) const
{
for (unsigned int i = 0; i < 4; i++)
ulUnicodeRange[i].set (0);
@@ -84,24 +84,24 @@ struct os2
unsigned int bit = _hb_ot_os2_get_unicode_range_bit (cp);
if (bit < 128)
{
- unsigned int block = bit / 32;
- unsigned int bit_in_block = bit % 32;
- unsigned int mask = 1 << bit_in_block;
- ulUnicodeRange[block].set (ulUnicodeRange[block] | mask);
+ unsigned int block = bit / 32;
+ unsigned int bit_in_block = bit % 32;
+ unsigned int mask = 1 << bit_in_block;
+ ulUnicodeRange[block].set (ulUnicodeRange[block] | mask);
}
if (cp >= 0x10000 && cp <= 0x110000)
{
- /* the spec says that bit 57 ("Non Plane 0") implies that there's
- at least one codepoint beyond the BMP; so I also include all
- the non-BMP codepoints here */
- ulUnicodeRange[1].set (ulUnicodeRange[1] | (1 << 25));
+ /* the spec says that bit 57 ("Non Plane 0") implies that there's
+ at least one codepoint beyond the BMP; so I also include all
+ the non-BMP codepoints here */
+ ulUnicodeRange[1].set (ulUnicodeRange[1] | (1 << 25));
}
}
}
static inline void find_min_and_max_codepoint (const hb_set_t *codepoints,
- uint16_t *min_cp, /* OUT */
- uint16_t *max_cp /* OUT */)
+ uint16_t *min_cp, /* OUT */
+ uint16_t *max_cp /* OUT */)
{
*min_cp = codepoints->get_min ();
*max_cp = codepoints->get_max ();
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-unicode-ranges.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-unicode-ranges.hh
index 19780088a7a..b0ccd00d7b6 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-unicode-ranges.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-os2-unicode-ranges.hh
@@ -34,7 +34,7 @@ namespace OT {
struct OS2Range
{
static int
- cmp (const void *_key, const void *_item, void *_arg)
+ cmp (const void *_key, const void *_item)
{
hb_codepoint_t cp = *((hb_codepoint_t *) _key);
const OS2Range *range = (OS2Range *) _item;
@@ -233,10 +233,10 @@ static const OS2Range _hb_os2_unicode_ranges[] =
static unsigned int
_hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp)
{
- OS2Range *range = (OS2Range*) hb_bsearch_r (&cp, _hb_os2_unicode_ranges,
- ARRAY_LENGTH (_hb_os2_unicode_ranges),
- sizeof (OS2Range),
- OS2Range::cmp, nullptr);
+ OS2Range *range = (OS2Range*) hb_bsearch (&cp, _hb_os2_unicode_ranges,
+ ARRAY_LENGTH (_hb_os2_unicode_ranges),
+ sizeof (OS2Range),
+ OS2Range::cmp);
if (range != nullptr)
return range->bit;
return -1;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-post-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-post-table.hh
index f81de37d56e..98df3e7801c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-post-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-post-table.hh
@@ -49,48 +49,39 @@ namespace OT {
struct postV2Tail
{
+ friend struct post;
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (glyphNameIndex.sanitize (c));
}
+ protected:
ArrayOf<HBUINT16> glyphNameIndex; /* This is not an offset, but is the
* ordinal number of the glyph in 'post'
* string tables. */
- UnsizedArrayOf<HBUINT8>
- namesX; /* Glyph names with length bytes [variable]
+/*UnsizedArrayOf<HBUINT8>
+ namesX;*/ /* Glyph names with length bytes [variable]
* (a Pascal string). */
- DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
+ public:
+ DEFINE_SIZE_ARRAY (2, glyphNameIndex);
};
struct post
{
static const hb_tag_t tableTag = HB_OT_TAG_post;
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- if (unlikely (!c->check_struct (this)))
- return_trace (false);
- if (version.to_int () == 0x00020000)
- {
- const postV2Tail &v2 = StructAfter<postV2Tail> (*this);
- return_trace (v2.sanitize (c));
- }
- return_trace (true);
- }
-
inline bool subset (hb_subset_plan_t *plan) const
{
unsigned int post_prime_length;
- hb_blob_t *post_blob = hb_sanitize_context_t().reference_table<post>(plan->source);
- hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::static_size);
+ hb_blob_t *post_blob = hb_sanitize_context_t ().reference_table<post>(plan->source);
+ hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::min_size);
post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, &post_prime_length);
hb_blob_destroy (post_blob);
- if (unlikely (!post_prime || post_prime_length != post::static_size))
+ if (unlikely (!post_prime || post_prime_length != post::min_size))
{
hb_blob_destroy (post_prime_blob);
DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", post_prime_length);
@@ -110,42 +101,39 @@ struct post
{
index_to_offset.init ();
- blob = hb_sanitize_context_t().reference_table<post> (face);
- const post *table = blob->as<post> ();
- unsigned int table_length = blob->length;
+ table = hb_sanitize_context_t ().reference_table<post> (face);
+ unsigned int table_length = table.get_length ();
version = table->version.to_int ();
- if (version != 0x00020000)
- return;
+ if (version != 0x00020000) return;
- const postV2Tail &v2 = StructAfter<postV2Tail> (*table);
+ const postV2Tail &v2 = table->v2;
glyphNameIndex = &v2.glyphNameIndex;
pool = &StructAfter<uint8_t> (v2.glyphNameIndex);
- const uint8_t *end = (uint8_t *) table + table_length;
- for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data)
+ const uint8_t *end = (const uint8_t *) (const void *) table + table_length;
+ for (const uint8_t *data = pool;
+ index_to_offset.len < 65535 && data < end && data + *data < end;
+ data += 1 + *data)
index_to_offset.push (data - pool);
}
inline void fini (void)
{
index_to_offset.fini ();
free (gids_sorted_by_name.get ());
- hb_blob_destroy (blob);
+ table.destroy ();
}
inline bool get_glyph_name (hb_codepoint_t glyph,
char *buf, unsigned int buf_len) const
{
hb_bytes_t s = find_glyph_name (glyph);
- if (!s.len)
- return false;
- if (!buf_len)
- return true;
- if (buf_len <= s.len) /* What to do with truncation? Returning false for now. */
- return false;
- strncpy (buf, s.arrayZ, s.len);
- buf[s.len] = '\0';
+ if (!s.len) return false;
+ if (!buf_len) return true;
+ unsigned int len = MIN (buf_len - 1, s.len);
+ strncpy (buf, s.arrayZ, len);
+ buf[len] = '\0';
return true;
}
@@ -153,14 +141,11 @@ struct post
hb_codepoint_t *glyph) const
{
unsigned int count = get_glyph_count ();
- if (unlikely (!count))
- return false;
+ if (unlikely (!count)) return false;
- if (len < 0)
- len = strlen (name);
+ if (len < 0) len = strlen (name);
- if (unlikely (!len))
- return false;
+ if (unlikely (!len)) return false;
retry:
uint16_t *gids = gids_sorted_by_name.get ();
@@ -198,10 +183,10 @@ struct post
inline unsigned int get_glyph_count (void) const
{
if (version == 0x00010000)
- return NUM_FORMAT1_NAMES;
+ return NUM_FORMAT1_NAMES;
if (version == 0x00020000)
- return glyphNameIndex->len;
+ return glyphNameIndex->len;
return 0;
}
@@ -242,7 +227,7 @@ struct post
if (index >= index_to_offset.len)
return hb_bytes_t ();
- unsigned int offset = index_to_offset.arrayZ[index];
+ unsigned int offset = index_to_offset[index];
const uint8_t *data = pool + offset;
unsigned int name_length = *data;
@@ -252,7 +237,7 @@ struct post
}
private:
- hb_blob_t *blob;
+ hb_blob_ptr_t<post> table;
uint32_t version;
const ArrayOf<HBUINT16> *glyphNameIndex;
hb_vector_t<uint32_t, 1> index_to_offset;
@@ -260,6 +245,15 @@ struct post
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;
};
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ (version.to_int () == 0x00010000 ||
+ (version.to_int () == 0x00020000 && v2.sanitize (c)) ||
+ version.to_int () == 0x00030000)));
+ }
+
public:
FixedVersion<>version; /* 0x00010000 for version 1.0
* 0x00020000 for version 2.0
@@ -292,8 +286,8 @@ struct post
* is downloaded as a Type 1 font. */
HBUINT32 maxMemType1; /* Maximum memory usage when an OpenType font
* is downloaded as a Type 1 font. */
-/*postV2Tail v2[VAR];*/
- DEFINE_SIZE_STATIC (32);
+ postV2Tail v2;
+ DEFINE_SIZE_MIN (32);
};
struct post_accelerator_t : post::accelerator_t {};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh
index 0ef60f64347..5be6f8d69e9 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic-fallback.hh
@@ -194,17 +194,15 @@ arabic_fallback_synthesize_lookup (const hb_ot_shape_plan_t *plan,
struct arabic_fallback_plan_t
{
- ASSERT_POD ();
-
unsigned int num_lookups;
bool free_lookups;
hb_mask_t mask_array[ARABIC_FALLBACK_MAX_LOOKUPS];
OT::SubstLookup *lookup_array[ARABIC_FALLBACK_MAX_LOOKUPS];
- hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS];
+ OT::hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS];
};
-#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_WIN1256)
+#if defined(_WIN32) && !defined(HB_NO_WIN1256)
#define HB_WITH_WIN1256
#endif
@@ -214,15 +212,18 @@ struct arabic_fallback_plan_t
struct ManifestLookup
{
+ public:
OT::Tag tag;
OT::OffsetTo<OT::SubstLookup> lookupOffset;
+ public:
+ DEFINE_SIZE_STATIC (6);
};
typedef OT::ArrayOf<ManifestLookup> Manifest;
static bool
-arabic_fallback_plan_init_win1256 (arabic_fallback_plan_t *fallback_plan,
- const hb_ot_shape_plan_t *plan,
- hb_font_t *font)
+arabic_fallback_plan_init_win1256 (arabic_fallback_plan_t *fallback_plan HB_UNUSED,
+ const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_font_t *font HB_UNUSED)
{
#ifdef HB_WITH_WIN1256
/* Does this font look like it's Windows-1256-encoded? */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc
index 2cdd7ba8aad..50a52136b7f 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-arabic.cc
@@ -243,8 +243,6 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
struct arabic_shape_plan_t
{
- ASSERT_POD ();
-
/* The "+ 1" in the next array is to accommodate for the "NONE" command,
* which is not an OpenType feature, but this simplifies the code by not
* having to do a "if (... < NONE) ..." and just rely on the fact that
@@ -281,7 +279,7 @@ data_destroy_arabic (void *data)
{
arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) data;
- arabic_fallback_plan_destroy (arabic_plan->fallback_plan.get ());
+ arabic_fallback_plan_destroy (arabic_plan->fallback_plan);
free (data);
}
@@ -391,7 +389,7 @@ arabic_fallback_shape (const hb_ot_shape_plan_t *plan,
return;
retry:
- arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan.get ();
+ arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan;
if (unlikely (!fallback_plan))
{
/* This sucks. We need a font to build the fallback plan... */
@@ -416,7 +414,7 @@ retry:
static void
record_stch (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
+ hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
const arabic_shape_plan_t *arabic_plan = (const arabic_shape_plan_t *) plan->data;
@@ -440,7 +438,7 @@ record_stch (const hb_ot_shape_plan_t *plan,
}
static void
-apply_stch (const hb_ot_shape_plan_t *plan,
+apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_buffer_t *buffer,
hb_font_t *font)
{
@@ -458,9 +456,9 @@ apply_stch (const hb_ot_shape_plan_t *plan,
int sign = font->x_scale < 0 ? -1 : +1;
unsigned int extra_glyphs_needed = 0; // Set during MEASURE, used during CUT
- typedef enum { MEASURE, CUT } step_t;
+ enum { MEASURE, CUT } /* step_t */;
- for (step_t step = MEASURE; step <= CUT; step = (step_t) (step + 1))
+ for (unsigned int step = MEASURE; step <= CUT; step = step + 1)
{
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
@@ -599,7 +597,7 @@ postprocess_glyphs_arabic (const hb_ot_shape_plan_t *plan,
HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
}
-/* https://unicode.org/reports/tr53/tr53-1.pdf */
+/* http://www.unicode.org/reports/tr53/ */
static hb_codepoint_t
modifier_combining_marks[] =
@@ -611,6 +609,7 @@ modifier_combining_marks[] =
0x06E3u, /* ARABIC SMALL LOW SEEN */
0x06E7u, /* ARABIC SMALL HIGH YEH */
0x06E8u, /* ARABIC SMALL HIGH NOON */
+ 0x08D3u, /* ARABIC SMALL LOW WAW */
0x08F3u, /* ARABIC SMALL HIGH WAW */
};
@@ -625,7 +624,7 @@ info_is_mcm (const hb_glyph_info_t &info)
}
static void
-reorder_marks_arabic (const hb_ot_shape_plan_t *plan,
+reorder_marks_arabic (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_buffer_t *buffer,
unsigned int start,
unsigned int end)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-hangul.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-hangul.cc
index 0e7abadbef4..e143867e13a 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-hangul.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-hangul.cc
@@ -70,8 +70,6 @@ override_features_hangul (hb_ot_shape_planner_t *plan)
struct hangul_shape_plan_t
{
- ASSERT_POD ();
-
hb_mask_t mask_array[HANGUL_FEATURE_COUNT];
};
@@ -128,7 +126,7 @@ is_zero_width_char (hb_font_t *font,
}
static void
-preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
+preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_buffer_t *buffer,
hb_font_t *font)
{
@@ -345,13 +343,6 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
{
unsigned int s_len = tindex ? 3 : 2;
buffer->replace_glyphs (1, s_len, decomposed);
- if (unlikely (!buffer->successful))
- return;
-
- /* We decomposed S: apply jamo features to the individual glyphs
- * that are now in buffer->out_info.
- */
- hb_glyph_info_t *info = buffer->out_info;
/* If we decomposed an LV because of a non-combining T following,
* we want to include this T in the syllable.
@@ -361,6 +352,14 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
buffer->next_glyph ();
s_len++;
}
+
+ if (unlikely (!buffer->successful))
+ return;
+
+ /* We decomposed S: apply jamo features to the individual glyphs
+ * that are now in buffer->out_info.
+ */
+ hb_glyph_info_t *info = buffer->out_info;
end = start + s_len;
unsigned int i = start;
@@ -368,6 +367,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
info[i++].hangul_shaping_feature() = VJMO;
if (i < end)
info[i++].hangul_shaping_feature() = TJMO;
+
if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
buffer->merge_out_clusters (start, end);
continue;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-indic.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-indic.cc
index f1ae303adcc..8933c1822a8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-indic.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-indic.cc
@@ -25,6 +25,7 @@
*/
#include "hb-ot-shape-complex-indic.hh"
+#include "hb-ot-shape-complex-vowel-constraints.hh"
#include "hb-ot-layout.hh"
@@ -115,7 +116,8 @@ indic_features[] =
{HB_TAG('c','j','c','t'), F_GLOBAL_MANUAL_JOINERS},
/*
* Other features.
- * These features are applied all at once, after final_reordering.
+ * These features are applied all at once, after final_reordering
+ * but before clearing syllables.
* Default Bengali font in Windows for example has intermixed
* lookups for init,pres,abvs,blws features.
*/
@@ -250,8 +252,6 @@ struct would_substitute_feature_t
struct indic_shape_plan_t
{
- ASSERT_POD ();
-
inline bool load_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const
{
hb_codepoint_t glyph = virama_glyph.get_relaxed ();
@@ -331,275 +331,6 @@ data_destroy_indic (void *data)
free (data);
}
-static void
-_output_with_dotted_circle (hb_buffer_t *buffer)
-{
- hb_glyph_info_t &dottedcircle = buffer->output_glyph (0x25CCu);
- _hb_glyph_info_reset_continuation (&dottedcircle);
-
- buffer->next_glyph ();
-}
-
-static void
-preprocess_text_indic (const hb_ot_shape_plan_t *plan,
- hb_buffer_t *buffer,
- hb_font_t *font)
-{
- /* UGLY UGLY UGLY business of adding dotted-circle in the middle of
- * vowel-sequences that look like another vowel. Data for each script
- * collected from Unicode 11 book, tables named "Vowel Letters" with
- * "Use" and "Do Not Use" columns.
- *
- * https://github.com/harfbuzz/harfbuzz/issues/1019
- */
- bool processed = false;
- buffer->clear_output ();
- unsigned int count = buffer->len;
- switch ((unsigned) buffer->props.script)
- {
- case HB_SCRIPT_DEVANAGARI:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0905u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x093Au: case 0x093Bu: case 0x093Eu: case 0x0945u:
- case 0x0946u: case 0x0949u: case 0x094Au: case 0x094Bu:
- case 0x094Cu: case 0x094Fu: case 0x0956u: case 0x0957u:
- matched = true;
- break;
- }
- break;
- case 0x0906u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x093Au: case 0x0945u: case 0x0946u: case 0x0947u:
- case 0x0948u:
- matched = true;
- break;
- }
- break;
- case 0x0909u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0941u:
- matched = true;
- break;
- }
- break;
- case 0x090Fu:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0945u: case 0x0946u: case 0x0947u:
- matched = true;
- break;
- }
- break;
- case 0x0930u:
- if (0x094Du == buffer->cur(1).codepoint &&
- buffer->idx + 2 < count &&
- 0x0907u == buffer->cur(2).codepoint)
- {
- buffer->next_glyph ();
- buffer->next_glyph ();
- buffer->output_glyph (0x25CCu);
- }
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_BENGALI:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0985u:
- matched = 0x09BE == buffer->cur(1).codepoint;
- break;
- case 0x098Bu:
- matched = 0x09C3 == buffer->cur(1).codepoint;
- break;
- case 0x098Cu:
- matched = 0x09E2 == buffer->cur(1).codepoint;
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_GURMUKHI:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0A05u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0A3Eu: case 0x0A48u: case 0x0A4Cu:
- matched = true;
- break;
- }
- break;
- case 0x0A72u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0A3Fu: case 0x0A40u: case 0x0A47u:
- matched = true;
- break;
- }
- break;
- case 0x0A73u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0A41u: case 0x0A42u: case 0x0A4Bu:
- matched = true;
- break;
- }
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_GUJARATI:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0A85u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0ABEu: case 0x0AC5u: case 0x0AC7u: case 0x0AC8u:
- case 0x0AC9u: case 0x0ACBu: case 0x0ACCu:
- matched = true;
- break;
- }
- break;
- case 0x0AC5u:
- matched = 0x0ABE == buffer->cur(1).codepoint;
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_ORIYA:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0B05u:
- matched = 0x0B3E == buffer->cur(1).codepoint;
- break;
- case 0x0B0Fu: case 0x0B13u:
- matched = 0x0B57 == buffer->cur(1).codepoint;
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_TELUGU:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0C12u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0C4Cu: case 0x0C55u:
- matched = true;
- break;
- }
- break;
- case 0x0C3Fu: case 0x0C46u: case 0xC4Au:
- matched = 0x0C55 == buffer->cur(1).codepoint;
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_KANNADA:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0C89u: case 0x0C8Bu:
- matched = 0x0CBE == buffer->cur(1).codepoint;
- break;
- case 0x0C92u:
- matched = 0x0CCC == buffer->cur(1).codepoint;
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- case HB_SCRIPT_MALAYALAM:
- for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
- {
- bool matched = false;
- switch (buffer->cur().codepoint)
- {
- case 0x0D07u: case 0x0D09u:
- matched = 0x0D57 == buffer->cur(1).codepoint;
- break;
- case 0x0D0Eu:
- matched = 0x0D46 == buffer->cur(1).codepoint;
- break;
- case 0x0D12u:
- switch (buffer->cur(1).codepoint)
- {
- case 0x0D3Eu: case 0x0D57u:
- matched = true;
- break;
- }
- break;
- }
- buffer->next_glyph ();
- if (matched) _output_with_dotted_circle (buffer);
- }
- processed = true;
- break;
-
- default:
- break;
- }
- if (processed)
- {
- if (buffer->idx < count)
- buffer->next_glyph ();
- if (likely (buffer->successful))
- buffer->swap_buffers ();
- }
-}
-
static indic_position_t
consonant_position_from_face (const indic_shape_plan_t *indic_plan,
const hb_codepoint_t consonant,
@@ -1055,8 +786,10 @@ initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan,
*
* We could use buffer->sort() for this, if there was no special
* reordering of pre-base stuff happening later...
+ * We don't want to merge_clusters all of that, which buffer->sort()
+ * would.
*/
- if (indic_plan->is_old_spec || end - base > 127)
+ if (indic_plan->is_old_spec || end - start > 127)
buffer->merge_clusters (base, end);
else
{
@@ -1285,7 +1018,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
else
buffer->next_glyph ();
}
-
buffer->swap_buffers ();
}
@@ -1785,6 +1517,14 @@ clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
}
+static void
+preprocess_text_indic (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font)
+{
+ _hb_preprocess_text_vowel_constraints (plan, buffer, font);
+}
+
static bool
decompose_indic (const hb_ot_shape_normalize_context_t *c,
hb_codepoint_t ab,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-khmer.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-khmer.cc
index 88d16267b39..497891ea045 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-khmer.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-khmer.cc
@@ -46,7 +46,7 @@ khmer_features[] =
{HB_TAG('c','f','a','r'), F_MANUAL_JOINERS},
/*
* Other features.
- * These features are applied all at once.
+ * These features are applied all at once after clearing syllables.
*/
{HB_TAG('p','r','e','s'), F_GLOBAL_MANUAL_JOINERS},
{HB_TAG('a','b','v','s'), F_GLOBAL_MANUAL_JOINERS},
@@ -174,8 +174,6 @@ struct would_substitute_feature_t
struct khmer_shape_plan_t
{
- ASSERT_POD ();
-
inline bool get_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const
{
hb_codepoint_t glyph = virama_glyph;
@@ -267,7 +265,7 @@ setup_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
static void
reorder_consonant_syllable (const hb_ot_shape_plan_t *plan,
- hb_face_t *face,
+ hb_face_t *face HB_UNUSED,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
@@ -416,7 +414,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
else
buffer->next_glyph ();
}
-
buffer->swap_buffers ();
}
@@ -438,8 +435,6 @@ clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
- /* TODO: In USE, we clear syllables right after reorder. Figure out
- * what Uniscribe does. */
hb_glyph_info_t *info = buffer->info;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.cc
index bebb8ec5230..8fdf2f4bcfd 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.cc
@@ -36,7 +36,7 @@ basic_features[] =
{
/*
* Basic features.
- * These features are applied in order, one at a time, after initial_reordering.
+ * These features are applied in order, one at a time, after reordering.
*/
HB_TAG('r','p','h','f'),
HB_TAG('p','r','e','f'),
@@ -48,7 +48,7 @@ other_features[] =
{
/*
* Other features.
- * These features are applied all at once, after final_reordering.
+ * These features are applied all at once, after clearing syllables.
*/
HB_TAG('p','r','e','s'),
HB_TAG('a','b','v','s'),
@@ -80,13 +80,13 @@ setup_syllables (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
static void
-initial_reordering (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer);
+reorder (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
static void
-final_reordering (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer);
+clear_syllables (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
static void
collect_features_myanmar (hb_ot_shape_planner_t *plan)
@@ -102,7 +102,7 @@ collect_features_myanmar (hb_ot_shape_planner_t *plan)
map->enable_feature (HB_TAG('c','c','m','p'));
- map->add_gsub_pause (initial_reordering);
+ map->add_gsub_pause (reorder);
for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++)
{
@@ -110,7 +110,7 @@ collect_features_myanmar (hb_ot_shape_planner_t *plan)
map->add_gsub_pause (nullptr);
}
- map->add_gsub_pause (final_reordering);
+ map->add_gsub_pause (clear_syllables);
for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++)
map->enable_feature (other_features[i], F_MANUAL_ZWJ);
@@ -274,8 +274,8 @@ initial_reordering_consonant_syllable (hb_buffer_t *buffer,
}
static void
-initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
- hb_face_t *face,
+initial_reordering_syllable (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_face_t *face HB_UNUSED,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
@@ -343,72 +343,71 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
else
buffer->next_glyph ();
}
-
buffer->swap_buffers ();
}
static void
-initial_reordering (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer)
+reorder (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
{
insert_dotted_circles (plan, font, buffer);
foreach_syllable (buffer, start, end)
initial_reordering_syllable (plan, font->face, buffer, start, end);
+
+ HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category);
+ HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position);
}
static void
-final_reordering (const hb_ot_shape_plan_t *plan,
- hb_font_t *font HB_UNUSED,
- hb_buffer_t *buffer)
+clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_font_t *font HB_UNUSED,
+ hb_buffer_t *buffer)
{
hb_glyph_info_t *info = buffer->info;
unsigned int count = buffer->len;
-
- /* Zero syllables now... */
for (unsigned int i = 0; i < count; i++)
info[i].syllable() = 0;
-
- HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_category);
- HB_BUFFER_DEALLOCATE_VAR (buffer, myanmar_position);
}
-/* Uniscribe seems to have a shaper for 'mymr' that is like the
- * generic shaper, except that it zeros mark advances GDEF_LATE. */
-const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old =
+const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar =
{
- nullptr, /* collect_features */
- nullptr, /* override_features */
+ collect_features_myanmar,
+ override_features_myanmar,
nullptr, /* data_create */
nullptr, /* data_destroy */
nullptr, /* preprocess_text */
nullptr, /* postprocess_glyphs */
- HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
+ HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
nullptr, /* decompose */
nullptr, /* compose */
- nullptr, /* setup_masks */
+ setup_masks_myanmar,
HB_TAG_NONE, /* gpos_tag */
nullptr, /* reorder_marks */
- HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
- true, /* fallback_position */
+ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
+ false, /* fallback_position */
};
-const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar =
+
+/* Ugly Zawgyi encoding.
+ * Disable all auto processing.
+ * https://github.com/harfbuzz/harfbuzz/issues/1162 */
+const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_zawgyi =
{
- collect_features_myanmar,
- override_features_myanmar,
+ nullptr, /* collect_features */
+ nullptr, /* override_features */
nullptr, /* data_create */
nullptr, /* data_destroy */
nullptr, /* preprocess_text */
nullptr, /* postprocess_glyphs */
- HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
+ HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
nullptr, /* decompose */
nullptr, /* compose */
- setup_masks_myanmar,
+ nullptr, /* setup_masks */
HB_TAG_NONE, /* gpos_tag */
nullptr, /* reorder_marks */
- HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
+ HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
false, /* fallback_position */
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.hh
index 7b6fd4837c7..3e9537a6447 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-myanmar.hh
@@ -64,42 +64,42 @@ set_myanmar_properties (hb_glyph_info_t &info)
{
hb_codepoint_t u = info.codepoint;
unsigned int type = hb_indic_get_categories (u);
- indic_category_t cat = (indic_category_t) (type & 0x7Fu);
+ unsigned int cat = type & 0x7Fu;
indic_position_t pos = (indic_position_t) (type >> 8);
/* Myanmar
* https://docs.microsoft.com/en-us/typography/script-development/myanmar#analyze
*/
if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xFE00u, 0xFE0Fu)))
- cat = (indic_category_t) OT_VS;
+ cat = OT_VS;
switch (u)
{
case 0x104Eu:
- cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory doesn't have. */
+ cat = OT_C; /* The spec says C, IndicSyllableCategory doesn't have. */
break;
case 0x002Du: case 0x00A0u: case 0x00D7u: case 0x2012u:
case 0x2013u: case 0x2014u: case 0x2015u: case 0x2022u:
case 0x25CCu: case 0x25FBu: case 0x25FCu: case 0x25FDu:
case 0x25FEu:
- cat = (indic_category_t) OT_GB;
+ cat = OT_GB;
break;
case 0x1004u: case 0x101Bu: case 0x105Au:
- cat = (indic_category_t) OT_Ra;
+ cat = OT_Ra;
break;
case 0x1032u: case 0x1036u:
- cat = (indic_category_t) OT_A;
+ cat = OT_A;
break;
case 0x1039u:
- cat = (indic_category_t) OT_H;
+ cat = OT_H;
break;
case 0x103Au:
- cat = (indic_category_t) OT_As;
+ cat = OT_As;
break;
case 0x1041u: case 0x1042u: case 0x1043u: case 0x1044u:
@@ -107,47 +107,47 @@ set_myanmar_properties (hb_glyph_info_t &info)
case 0x1049u: case 0x1090u: case 0x1091u: case 0x1092u:
case 0x1093u: case 0x1094u: case 0x1095u: case 0x1096u:
case 0x1097u: case 0x1098u: case 0x1099u:
- cat = (indic_category_t) OT_D;
+ cat = OT_D;
break;
case 0x1040u:
- cat = (indic_category_t) OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */
+ cat = OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */
break;
case 0x103Eu: case 0x1060u:
- cat = (indic_category_t) OT_MH;
+ cat = OT_MH;
break;
case 0x103Cu:
- cat = (indic_category_t) OT_MR;
+ cat = OT_MR;
break;
case 0x103Du: case 0x1082u:
- cat = (indic_category_t) OT_MW;
+ cat = OT_MW;
break;
case 0x103Bu: case 0x105Eu: case 0x105Fu:
- cat = (indic_category_t) OT_MY;
+ cat = OT_MY;
break;
case 0x1063u: case 0x1064u: case 0x1069u: case 0x106Au:
case 0x106Bu: case 0x106Cu: case 0x106Du: case 0xAA7Bu:
- cat = (indic_category_t) OT_PT;
+ cat = OT_PT;
break;
case 0x1038u: case 0x1087u: case 0x1088u: case 0x1089u:
case 0x108Au: case 0x108Bu: case 0x108Cu: case 0x108Du:
case 0x108Fu: case 0x109Au: case 0x109Bu: case 0x109Cu:
- cat = (indic_category_t) OT_SM;
+ cat = OT_SM;
break;
case 0x104Au: case 0x104Bu:
- cat = (indic_category_t) OT_P;
+ cat = OT_P;
break;
case 0xAA74u: case 0xAA75u: case 0xAA76u:
/* https://github.com/roozbehp/unicode-data/issues/3 */
- cat = (indic_category_t) OT_C;
+ cat = OT_C;
break;
}
@@ -155,15 +155,15 @@ set_myanmar_properties (hb_glyph_info_t &info)
{
switch ((int) pos)
{
- case POS_PRE_C: cat = (indic_category_t) OT_VPre;
- pos = POS_PRE_M; break;
- case POS_ABOVE_C: cat = (indic_category_t) OT_VAbv; break;
- case POS_BELOW_C: cat = (indic_category_t) OT_VBlw; break;
- case POS_POST_C: cat = (indic_category_t) OT_VPst; break;
+ case POS_PRE_C: cat = OT_VPre;
+ pos = POS_PRE_M; break;
+ case POS_ABOVE_C: cat = OT_VAbv; break;
+ case POS_BELOW_C: cat = OT_VBlw; break;
+ case POS_POST_C: cat = OT_VPst; break;
}
}
- info.myanmar_category() = (myanmar_category_t) cat;
+ info.myanmar_category() = cat;
info.myanmar_position() = pos;
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-thai.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-thai.cc
index b687fe61e3d..650c9800ac2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-thai.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-thai.cc
@@ -357,8 +357,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan,
buffer->merge_out_clusters (start - 1, end);
}
}
- if (likely (buffer->successful))
- buffer->swap_buffers ();
+ buffer->swap_buffers ();
/* If font has Thai GSUB, we are done. */
if (plan->props.script == HB_SCRIPT_THAI && !plan->map.found_script[0])
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use-table.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use-table.cc
index e9c88aec4c4..2f3eb703eaa 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use-table.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use-table.cc
@@ -544,7 +544,7 @@ static const USE_TABLE_ELEMENT_TYPE use_table[] = {
/* 11190 */ B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
/* 111A0 */ B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
/* 111B0 */ B, B, B, VPst, VPre, VPst, VBlw, VBlw, VBlw, VBlw, VBlw, VBlw, VAbv, VAbv, VAbv, VAbv,
- /* 111C0 */ H, B, R, R, O, O, O, O, O, FM, CMBlw, VAbv, VBlw, O, O, O,
+ /* 111C0 */ H, B, R, R, O, O, O, O, GB, FBlw, CMBlw, VAbv, VBlw, O, O, O,
/* 111D0 */ B, B, B, B, B, B, B, B, B, B, O, O, O, O, O, O,
/* Sinhala Archaic Numbers */
@@ -582,7 +582,7 @@ static const USE_TABLE_ELEMENT_TYPE use_table[] = {
/* 11310 */ B, O, O, B, B, B, B, B, B, B, B, B, B, B, B, B,
/* 11320 */ B, B, B, B, B, B, B, B, B, O, B, B, B, B, B, B,
/* 11330 */ B, O, B, B, O, B, B, B, B, B, O, CMBlw, CMBlw, B, VPst, VPst,
- /* 11340 */ VAbv, VPst, VPst, VPst, VPst, O, O, VPre, VPre, O, O, VPst, VPst, H, O, O,
+ /* 11340 */ VAbv, VPst, VPst, VPst, VPst, O, O, VPre, VPre, O, O, VPst, VPst, HVM, O, O,
/* 11350 */ O, O, O, O, O, O, O, VPst, O, O, O, O, O, O, B, B,
/* 11360 */ B, B, VPst, VPst, O, O, VMAbv, VMAbv, VMAbv, VMAbv, VMAbv, VMAbv, VMAbv, O, O, O,
/* 11370 */ VMAbv, VMAbv, VMAbv, VMAbv, VMAbv, O, O, O,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use.cc
index f9a580ca207..2e3f202f59d 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-use.cc
@@ -28,6 +28,7 @@
#include "hb-ot-shape-complex-use.hh"
#include "hb-ot-shape-complex-arabic.hh"
+#include "hb-ot-shape-complex-vowel-constraints.hh"
/* buffer var allocations */
#define use_category() complex_var_u8_0()
@@ -79,7 +80,8 @@ other_features[] =
{
/*
* Other features.
- * These features are applied all at once, after reordering.
+ * These features are applied all at once, after reordering and
+ * clearing syllables.
*/
HB_TAG('a','b','v','s'),
HB_TAG('b','l','w','s'),
@@ -119,6 +121,10 @@ static void
reorder (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
+static void
+clear_syllables (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
static void
collect_features_use (hb_ot_shape_planner_t *plan)
@@ -147,6 +153,7 @@ collect_features_use (hb_ot_shape_planner_t *plan)
map->enable_feature (basic_features[i], F_MANUAL_ZWJ);
map->add_gsub_pause (reorder);
+ map->add_gsub_pause (clear_syllables);
/* "Topographical features" */
for (unsigned int i = 0; i < ARRAY_LENGTH (arabic_features); i++)
@@ -164,8 +171,6 @@ collect_features_use (hb_ot_shape_planner_t *plan)
struct use_shape_plan_t
{
- ASSERT_POD ();
-
hb_mask_t rphf_mask;
arabic_shape_plan_t *arabic_plan;
@@ -372,7 +377,7 @@ setup_syllables (const hb_ot_shape_plan_t *plan,
}
static void
-clear_substitution_flags (const hb_ot_shape_plan_t *plan,
+clear_substitution_flags (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
@@ -384,7 +389,7 @@ clear_substitution_flags (const hb_ot_shape_plan_t *plan,
static void
record_rphf (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
+ hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
@@ -406,8 +411,8 @@ record_rphf (const hb_ot_shape_plan_t *plan,
}
static void
-record_pref (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
+record_pref (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
hb_glyph_info_t *info = buffer->info;
@@ -427,7 +432,8 @@ record_pref (const hb_ot_shape_plan_t *plan,
static inline bool
is_halant (const hb_glyph_info_t &info)
{
- return info.use_category() == USE_H && !_hb_glyph_info_ligated (&info);
+ return (info.use_category() == USE_H || info.use_category() == USE_HVM) &&
+ !_hb_glyph_info_ligated (&info);
}
static void
@@ -444,19 +450,38 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end)
hb_glyph_info_t *info = buffer->info;
-#define BASE_FLAGS (FLAG (USE_B) | FLAG (USE_GB))
+#define POST_BASE_FLAGS64 (FLAG64 (USE_FM) | \
+ FLAG64 (USE_FAbv) | \
+ FLAG64 (USE_FBlw) | \
+ FLAG64 (USE_FPst) | \
+ FLAG64 (USE_MAbv) | \
+ FLAG64 (USE_MBlw) | \
+ FLAG64 (USE_MPst) | \
+ FLAG64 (USE_MPre) | \
+ FLAG64 (USE_VAbv) | \
+ FLAG64 (USE_VBlw) | \
+ FLAG64 (USE_VPst) | \
+ FLAG64 (USE_VPre) | \
+ FLAG64 (USE_VMAbv) | \
+ FLAG64 (USE_VMBlw) | \
+ FLAG64 (USE_VMPst) | \
+ FLAG64 (USE_VMPre))
/* Move things forward. */
if (info[start].use_category() == USE_R && end - start > 1)
{
- /* Got a repha. Reorder it to after first base, before first halant. */
+ /* Got a repha. Reorder it towards the end, but before the first post-base
+ * glyph. */
for (unsigned int i = start + 1; i < end; i++)
- if ((FLAG_UNSAFE (info[i].use_category()) & (BASE_FLAGS)) || is_halant (info[i]))
+ {
+ bool is_post_base_glyph = (FLAG64_UNSAFE (info[i].use_category()) & POST_BASE_FLAGS64) ||
+ is_halant (info[i]);
+ if (is_post_base_glyph || i == end - 1)
{
- /* If we hit a halant, move before it; otherwise it's a base: move to it's
- * place, and shift things in between backward. */
+ /* If we hit a post-base glyph, move before it; otherwise move to the
+ * end. Shift things in between backward. */
- if (is_halant (info[i]))
+ if (is_post_base_glyph)
i--;
buffer->merge_clusters (start, i + 1);
@@ -466,21 +491,19 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end)
break;
}
+ }
}
/* Move things back. */
- unsigned int j = end;
+ unsigned int j = start;
for (unsigned int i = start; i < end; i++)
{
uint32_t flag = FLAG_UNSAFE (info[i].use_category());
- if ((flag & (BASE_FLAGS)) || is_halant (info[i]))
+ if (is_halant (info[i]))
{
- /* If we hit a halant, move after it; otherwise it's a base: move to it's
- * place, and shift things in between backward. */
- if (is_halant (info[i]))
- j = i + 1;
- else
- j = i;
+ /* If we hit a halant, move after it; otherwise move to the beginning, and
+ * shift things in between forward. */
+ j = i + 1;
}
else if (((flag) & (FLAG (USE_VPre) | FLAG (USE_VMPre))) &&
/* Only move the first component of a MultipleSubst. */
@@ -547,7 +570,6 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
else
buffer->next_glyph ();
}
-
buffer->swap_buffers ();
}
@@ -558,17 +580,30 @@ reorder (const hb_ot_shape_plan_t *plan,
{
insert_dotted_circles (plan, font, buffer);
- hb_glyph_info_t *info = buffer->info;
-
foreach_syllable (buffer, start, end)
reorder_syllable (buffer, start, end);
- /* Zero syllables now... */
+ HB_BUFFER_DEALLOCATE_VAR (buffer, use_category);
+}
+
+static void
+clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_font_t *font HB_UNUSED,
+ hb_buffer_t *buffer)
+{
+ hb_glyph_info_t *info = buffer->info;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
info[i].syllable() = 0;
+}
- HB_BUFFER_DEALLOCATE_VAR (buffer, use_category);
+
+static void
+preprocess_text_use (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font)
+{
+ _hb_preprocess_text_vowel_constraints (plan, buffer, font);
}
static bool
@@ -591,7 +626,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_use =
nullptr, /* override_features */
data_create_use,
data_destroy_use,
- nullptr, /* preprocess_text */
+ preprocess_text_use,
nullptr, /* postprocess_glyphs */
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
nullptr, /* decompose */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.cc
new file mode 100644
index 00000000000..0e532581d94
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.cc
@@ -0,0 +1,437 @@
+/* == Start of generated functions == */
+/*
+ * The following functions are generated by running:
+ *
+ * ./gen-vowel-constraints.py use Scripts.txt
+ *
+ * on files with these headers:
+ *
+ * # Copied from https://docs.microsoft.com/en-us/typography/script-development/use
+ * # On October 23, 2018; with documentd dated 02/07/2018.
+ *
+ * # Scripts-11.0.0.txt
+ * # Date: 2018-02-21, 05:34:31 GMT
+ */
+
+#include "hb-ot-shape-complex-vowel-constraints.hh"
+
+static void
+_output_dotted_circle (hb_buffer_t *buffer)
+{
+ hb_glyph_info_t &dottedcircle = buffer->output_glyph (0x25CCu);
+ _hb_glyph_info_reset_continuation (&dottedcircle);
+}
+
+static void
+_output_with_dotted_circle (hb_buffer_t *buffer)
+{
+ _output_dotted_circle (buffer);
+ buffer->next_glyph ();
+}
+
+void
+_hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_buffer_t *buffer,
+ hb_font_t *font HB_UNUSED)
+{
+ /* UGLY UGLY UGLY business of adding dotted-circle in the middle of
+ * vowel-sequences that look like another vowel. Data for each script
+ * collected from the USE script development spec.
+ *
+ * https://github.com/harfbuzz/harfbuzz/issues/1019
+ */
+ bool processed = false;
+ buffer->clear_output ();
+ unsigned int count = buffer->len;
+ switch ((unsigned) buffer->props.script)
+ {
+ case HB_SCRIPT_DEVANAGARI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0905u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x093Au: case 0x093Bu: case 0x093Eu: case 0x0945u:
+ case 0x0946u: case 0x0949u: case 0x094Au: case 0x094Bu:
+ case 0x094Cu: case 0x094Fu: case 0x0956u: case 0x0957u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0906u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x093Au: case 0x0945u: case 0x0946u: case 0x0947u:
+ case 0x0948u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0909u:
+ matched = 0x0941u == buffer->cur (1).codepoint;
+ break;
+ case 0x090Fu:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0945u: case 0x0946u: case 0x0947u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0930u:
+ if (0x094Du == buffer->cur (1).codepoint &&
+ buffer->idx + 2 < count &&
+ 0x0907u == buffer->cur (2).codepoint)
+ {
+ buffer->next_glyph ();
+ buffer->next_glyph ();
+ _output_dotted_circle (buffer);
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_BENGALI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0985u:
+ matched = 0x09BEu == buffer->cur (1).codepoint;
+ break;
+ case 0x098Bu:
+ matched = 0x09C3u == buffer->cur (1).codepoint;
+ break;
+ case 0x098Cu:
+ matched = 0x09E2u == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_GURMUKHI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0A05u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0A3Eu: case 0x0A48u: case 0x0A4Cu:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0A72u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0A3Fu: case 0x0A40u: case 0x0A47u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0A73u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0A41u: case 0x0A42u: case 0x0A4Bu:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_GUJARATI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0A85u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0ABEu: case 0x0AC5u: case 0x0AC7u: case 0x0AC8u:
+ case 0x0AC9u: case 0x0ACBu: case 0x0ACCu:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0AC5u:
+ matched = 0x0ABEu == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_ORIYA:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0B05u:
+ matched = 0x0B3Eu == buffer->cur (1).codepoint;
+ break;
+ case 0x0B0Fu: case 0x0B13u:
+ matched = 0x0B57u == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_TELUGU:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0C12u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0C4Cu: case 0x0C55u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0C3Fu: case 0x0C46u: case 0x0C4Au:
+ matched = 0x0C55u == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_KANNADA:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0C89u: case 0x0C8Bu:
+ matched = 0x0CBEu == buffer->cur (1).codepoint;
+ break;
+ case 0x0C92u:
+ matched = 0x0CCCu == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_MALAYALAM:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0D07u: case 0x0D09u:
+ matched = 0x0D57u == buffer->cur (1).codepoint;
+ break;
+ case 0x0D0Eu:
+ matched = 0x0D46u == buffer->cur (1).codepoint;
+ break;
+ case 0x0D12u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0D3Eu: case 0x0D57u:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_SINHALA:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x0D85u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0DCFu: case 0x0DD0u: case 0x0DD1u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x0D8Bu: case 0x0D8Fu: case 0x0D94u:
+ matched = 0x0DDFu == buffer->cur (1).codepoint;
+ break;
+ case 0x0D8Du:
+ matched = 0x0DD8u == buffer->cur (1).codepoint;
+ break;
+ case 0x0D91u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x0DCAu: case 0x0DD9u: case 0x0DDAu: case 0x0DDCu:
+ case 0x0DDDu:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_BRAHMI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x11005u:
+ matched = 0x11038u == buffer->cur (1).codepoint;
+ break;
+ case 0x1100Bu:
+ matched = 0x1103Eu == buffer->cur (1).codepoint;
+ break;
+ case 0x1100Fu:
+ matched = 0x11042u == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_KHUDAWADI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x112B0u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x112E0u: case 0x112E5u: case 0x112E6u: case 0x112E7u:
+ case 0x112E8u:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_TIRHUTA:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x11481u:
+ matched = 0x114B0u == buffer->cur (1).codepoint;
+ break;
+ case 0x1148Bu: case 0x1148Du:
+ matched = 0x114BAu == buffer->cur (1).codepoint;
+ break;
+ case 0x114AAu:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x114B5u: case 0x114B6u:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_MODI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x11600u: case 0x11601u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x11639u: case 0x1163Au:
+ matched = true;
+ break;
+ }
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ case HB_SCRIPT_TAKRI:
+ for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)
+ {
+ bool matched = false;
+ switch (buffer->cur ().codepoint)
+ {
+ case 0x11680u:
+ switch (buffer->cur (1).codepoint)
+ {
+ case 0x116ADu: case 0x116B4u: case 0x116B5u:
+ matched = true;
+ break;
+ }
+ break;
+ case 0x11686u:
+ matched = 0x116B2u == buffer->cur (1).codepoint;
+ break;
+ }
+ buffer->next_glyph ();
+ if (matched) _output_with_dotted_circle (buffer);
+ }
+ processed = true;
+ break;
+
+ default:
+ break;
+ }
+ if (processed)
+ {
+ if (buffer->idx < count)
+ buffer->next_glyph ();
+ buffer->swap_buffers ();
+ }
+}
+
+/* == End of generated functions == */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.hh
new file mode 100644
index 00000000000..d9082d4eadb
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex-vowel-constraints.hh
@@ -0,0 +1,39 @@
+/*
+ * 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_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS_HH
+#define HB_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS_HH
+
+#include "hb.hh"
+
+#include "hb-ot-shape-complex.hh"
+
+HB_INTERNAL void
+_hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font);
+
+#endif /* HB_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex.hh
index e3b7dee612f..a2499de9c92 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-complex.hh
@@ -57,7 +57,7 @@ enum hb_ot_shape_zero_width_marks_type_t {
HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
HB_COMPLEX_SHAPER_IMPLEMENT (khmer) \
HB_COMPLEX_SHAPER_IMPLEMENT (myanmar) \
- HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_old) \
+ HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_zawgyi) \
HB_COMPLEX_SHAPER_IMPLEMENT (thai) \
HB_COMPLEX_SHAPER_IMPLEMENT (use) \
/* ^--- Add new shapers here */
@@ -68,7 +68,7 @@ struct hb_ot_complex_shaper_t
/* collect_features()
* Called during shape_plan().
* Shapers should use plan->map to add their features and callbacks.
- * May be nullptr.
+ * May be NULL.
*/
void (*collect_features) (hb_ot_shape_planner_t *plan);
@@ -76,7 +76,7 @@ struct hb_ot_complex_shaper_t
* Called during shape_plan().
* Shapers should use plan->map to override features and add callbacks after
* common features are added.
- * May be nullptr.
+ * May be NULL.
*/
void (*override_features) (hb_ot_shape_planner_t *plan);
@@ -92,7 +92,7 @@ struct hb_ot_complex_shaper_t
* Called when the shape_plan is being destroyed.
* plan->data is passed here for destruction.
* If nullptr is returned, means a plan failure.
- * May be nullptr.
+ * May be NULL.
*/
void (*data_destroy) (void *data);
@@ -100,7 +100,7 @@ struct hb_ot_complex_shaper_t
/* preprocess_text()
* Called during shape().
* Shapers can use to modify text before shaping starts.
- * May be nullptr.
+ * May be NULL.
*/
void (*preprocess_text) (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
@@ -109,7 +109,7 @@ struct hb_ot_complex_shaper_t
/* postprocess_glyphs()
* Called during shape().
* Shapers can use to modify glyphs after shaping ends.
- * May be nullptr.
+ * May be NULL.
*/
void (*postprocess_glyphs) (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
@@ -120,7 +120,7 @@ struct hb_ot_complex_shaper_t
/* decompose()
* Called during shape()'s normalization.
- * May be nullptr.
+ * May be NULL.
*/
bool (*decompose) (const hb_ot_shape_normalize_context_t *c,
hb_codepoint_t ab,
@@ -129,7 +129,7 @@ struct hb_ot_complex_shaper_t
/* compose()
* Called during shape()'s normalization.
- * May be nullptr.
+ * May be NULL.
*/
bool (*compose) (const hb_ot_shape_normalize_context_t *c,
hb_codepoint_t a,
@@ -140,7 +140,7 @@ struct hb_ot_complex_shaper_t
* Called during shape().
* Shapers should use map to get feature masks and set on buffer.
* Shapers may NOT modify characters.
- * May be nullptr.
+ * May be NULL.
*/
void (*setup_masks) (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
@@ -155,7 +155,7 @@ struct hb_ot_complex_shaper_t
/* reorder_marks()
* Called during shape().
* Shapers can use to modify ordering of combining marks.
- * May be nullptr.
+ * May be NULL.
*/
void (*reorder_marks) (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
@@ -254,11 +254,13 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
/* If the designer designed the font for the 'DFLT' script,
* (or we ended up arbitrarily pick 'latn'), use the default shaper.
* Otherwise, use the specific shaper.
- * Note that for some simple scripts, there may not be *any*
- * GSUB/GPOS needed, so there may be no scripts found! */
+ *
+ * If it's indy3 tag, send to USE. */
if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
planner->map.chosen_script[0] == HB_TAG ('l','a','t','n'))
return &_hb_ot_complex_shaper_default;
+ else if ((planner->map.chosen_script[0] & 0x000000FF) == '3')
+ return &_hb_ot_complex_shaper_use;
else
return &_hb_ot_complex_shaper_indic;
@@ -266,12 +268,25 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
return &_hb_ot_complex_shaper_khmer;
case HB_SCRIPT_MYANMAR:
- if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','2'))
- return &_hb_ot_complex_shaper_myanmar;
- else if (planner->map.chosen_script[0] == HB_TAG ('m','y','m','r'))
- return &_hb_ot_complex_shaper_myanmar_old;
- else
+ /* If the designer designed the font for the 'DFLT' script,
+ * (or we ended up arbitrarily pick 'latn'), use the default shaper.
+ * Otherwise, use the specific shaper.
+ *
+ * If designer designed for 'mymr' tag, also send to default
+ * shaper. That's tag used from before Myanmar shaping spec
+ * was developed. The shaping spec uses 'mym2' tag. */
+ if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
+ planner->map.chosen_script[0] == HB_TAG ('l','a','t','n') ||
+ planner->map.chosen_script[0] == HB_TAG ('m','y','m','r'))
return &_hb_ot_complex_shaper_default;
+ else
+ return &_hb_ot_complex_shaper_myanmar;
+
+
+ /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
+ case HB_SCRIPT_MYANMAR_ZAWGYI:
+
+ return &_hb_ot_complex_shaper_myanmar_zawgyi;
/* Unicode-2.0 additions */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.cc
index 6673abd149e..d3afdffaf2c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.cc
@@ -25,7 +25,7 @@
*/
#include "hb-ot-shape-fallback.hh"
-#include "hb-ot-layout-gsubgpos.hh"
+#include "hb-kern.hh"
static unsigned int
recategorize_combining_class (hb_codepoint_t u,
@@ -162,9 +162,9 @@ recategorize_combining_class (hb_codepoint_t u,
}
void
-_hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan HB_UNUSED,
- hb_font_t *font HB_UNUSED,
- hb_buffer_t *buffer)
+_hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_font_t *font HB_UNUSED,
+ hb_buffer_t *buffer)
{
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
@@ -192,7 +192,7 @@ zero_mark_advances (hb_buffer_t *buffer,
}
static inline void
-position_mark (const hb_ot_shape_plan_t *plan,
+position_mark (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer,
hb_glyph_extents_t &base_extents,
@@ -417,9 +417,9 @@ position_cluster (const hb_ot_shape_plan_t *plan,
}
void
-_hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer)
+_hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
@@ -435,81 +435,59 @@ _hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan,
}
-/* Performs old-style TrueType kerning. */
-void
-_hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer)
+struct hb_ot_shape_fallback_kern_driver_t
{
- if (!plan->kerning_requested) return;
-
- OT::hb_ot_apply_context_t c (1, font, buffer);
- hb_mask_t kern_mask = plan->kern_mask;
- c.set_lookup_mask (kern_mask);
- c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
- OT::hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c.iter_input;
- skippy_iter.init (&c);
+ hb_ot_shape_fallback_kern_driver_t (hb_font_t *font_,
+ hb_buffer_t *buffer) :
+ font (font_), direction (buffer->props.direction) {}
- unsigned int count = buffer->len;
- hb_glyph_info_t *info = buffer->info;
- hb_glyph_position_t *pos = buffer->pos;
- for (unsigned int idx = 0; idx < count;)
+ hb_position_t get_kerning (hb_codepoint_t first, hb_codepoint_t second) const
{
- if (!(info[idx].mask & kern_mask))
- {
- idx++;
- continue;
- }
+ hb_position_t kern = 0;
+ font->get_glyph_kerning_for_direction (first, second,
+ direction,
+ &kern, &kern);
+ return kern;
+ }
- skippy_iter.reset (idx, 1);
- if (!skippy_iter.next ())
- {
- idx++;
- continue;
- }
+ hb_font_t *font;
+ hb_direction_t direction;
+};
+
+/* Performs font-assisted kerning. */
+void
+_hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
+{
+ if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction) ?
+ !font->has_glyph_h_kerning_func () :
+ !font->has_glyph_v_kerning_func ())
+ return;
- hb_position_t x_kern, y_kern;
- font->get_glyph_kerning_for_direction (info[idx].codepoint,
- info[skippy_iter.idx].codepoint,
- buffer->props.direction,
- &x_kern, &y_kern);
+ bool reverse = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
- if (x_kern)
- {
- hb_position_t kern1 = x_kern >> 1;
- hb_position_t kern2 = x_kern - kern1;
- pos[idx].x_advance += kern1;
- pos[skippy_iter.idx].x_advance += kern2;
- pos[skippy_iter.idx].x_offset += kern2;
- buffer->unsafe_to_break (idx, skippy_iter.idx + 1);
- }
+ if (reverse)
+ buffer->reverse ();
- if (y_kern)
- {
- hb_position_t kern1 = y_kern >> 1;
- hb_position_t kern2 = y_kern - kern1;
- pos[idx].y_advance += kern1;
- pos[skippy_iter.idx].y_advance += kern2;
- pos[skippy_iter.idx].y_offset += kern2;
- buffer->unsafe_to_break (idx, skippy_iter.idx + 1);
- }
+ hb_ot_shape_fallback_kern_driver_t driver (font, buffer);
+ OT::hb_kern_machine_t<hb_ot_shape_fallback_kern_driver_t> machine (driver);
+ machine.kern (font, buffer, plan->kern_mask, false);
- idx = skippy_iter.idx;
- }
+ if (reverse)
+ buffer->reverse ();
}
/* Adjusts width of various spaces. */
void
-_hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan,
+_hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
{
- if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
- return;
-
hb_glyph_info_t *info = buffer->info;
hb_glyph_position_t *pos = buffer->pos;
+ bool horizontal = HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction);
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
if (_hb_glyph_info_is_unicode_space (&info[i]) && !_hb_glyph_info_ligated (&info[i]))
@@ -530,27 +508,40 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan,
case t::SPACE_EM_5:
case t::SPACE_EM_6:
case t::SPACE_EM_16:
- pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type;
+ if (horizontal)
+ pos[i].x_advance = +(font->x_scale + ((int) space_type)/2) / (int) space_type;
+ else
+ pos[i].y_advance = -(font->y_scale + ((int) space_type)/2) / (int) space_type;
break;
case t::SPACE_4_EM_18:
- pos[i].x_advance = (int64_t) font->x_scale * 4 / 18;
+ if (horizontal)
+ pos[i].x_advance = (int64_t) +font->x_scale * 4 / 18;
+ else
+ pos[i].y_advance = (int64_t) -font->y_scale * 4 / 18;
break;
case t::SPACE_FIGURE:
for (char u = '0'; u <= '9'; u++)
if (font->get_nominal_glyph (u, &glyph))
{
- pos[i].x_advance = font->get_glyph_h_advance (glyph);
+ if (horizontal)
+ pos[i].x_advance = font->get_glyph_h_advance (glyph);
+ else
+ pos[i].y_advance = font->get_glyph_v_advance (glyph);
break;
}
break;
case t::SPACE_PUNCTUATION:
- if (font->get_nominal_glyph ('.', &glyph))
- pos[i].x_advance = font->get_glyph_h_advance (glyph);
- else if (font->get_nominal_glyph (',', &glyph))
- pos[i].x_advance = font->get_glyph_h_advance (glyph);
+ if (font->get_nominal_glyph ('.', &glyph) ||
+ font->get_nominal_glyph (',', &glyph))
+ {
+ if (horizontal)
+ pos[i].x_advance = font->get_glyph_h_advance (glyph);
+ else
+ pos[i].y_advance = font->get_glyph_v_advance (glyph);
+ }
break;
case t::SPACE_NARROW:
@@ -559,7 +550,10 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan,
* However, in my testing, many fonts have their regular space being about that
* size. To me, a percentage of the space width makes more sense. Half is as
* good as any. */
- pos[i].x_advance /= 2;
+ if (horizontal)
+ pos[i].x_advance /= 2;
+ else
+ pos[i].y_advance /= 2;
break;
}
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.hh
index 730e7f28068..12f18ed12f2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-fallback.hh
@@ -32,13 +32,13 @@
#include "hb-ot-shape.hh"
-HB_INTERNAL void _hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer);
+HB_INTERNAL void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
-HB_INTERNAL void _hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
- hb_font_t *font,
- hb_buffer_t *buffer);
+HB_INTERNAL void _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
HB_INTERNAL void _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.cc
index 0e13707ed13..82bb24b7db6 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.cc
@@ -213,17 +213,19 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
}
static inline void
-handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit)
+handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c,
+ unsigned int end,
+ bool short_circuit HB_UNUSED)
{
/* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
hb_buffer_t * const buffer = c->buffer;
hb_font_t * const font = c->font;
for (; buffer->idx < end - 1 && buffer->successful;) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) {
- /* The next two lines are some ugly lines... But work. */
if (font->get_variation_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index()))
{
- buffer->replace_glyphs (2, 1, &buffer->cur().codepoint);
+ hb_codepoint_t unicode = buffer->cur().codepoint;
+ buffer->replace_glyphs (2, 1, &unicode);
}
else
{
@@ -264,15 +266,6 @@ decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned
decompose_current_character (c, short_circuit);
}
-static inline void
-decompose_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool might_short_circuit, bool always_short_circuit)
-{
- if (likely (c->buffer->idx + 1 == end))
- decompose_current_character (c, might_short_circuit);
- else
- decompose_multi_char_cluster (c, end, always_short_circuit);
-}
-
static int
compare_combining_class (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
@@ -328,45 +321,80 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
/* First round, decompose */
- buffer->clear_output ();
- count = buffer->len;
- for (buffer->idx = 0; buffer->idx < count && buffer->successful;)
+ bool all_simple = true;
{
- unsigned int end;
- for (end = buffer->idx + 1; end < count; end++)
- if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end]))))
- break;
+ buffer->clear_output ();
+ count = buffer->len;
+ buffer->idx = 0;
+ do
+ {
+ unsigned int end;
+ for (end = buffer->idx + 1; end < count; end++)
+ if (unlikely (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end]))))
+ break;
+
+ if (end < count)
+ end--; /* Leave one base for the marks to cluster with. */
+
+ /* From idx to end are simple clusters. */
+ if (might_short_circuit)
+ {
+ unsigned int done = font->get_nominal_glyphs (end - buffer->idx,
+ &buffer->cur().codepoint,
+ sizeof (buffer->info[0]),
+ &buffer->cur().glyph_index(),
+ sizeof (buffer->info[0]));
+ buffer->next_glyphs (done);
+ }
+ while (buffer->idx < end && buffer->successful)
+ decompose_current_character (&c, might_short_circuit);
+
+ if (buffer->idx == count || !buffer->successful)
+ break;
- decompose_cluster (&c, end, might_short_circuit, always_short_circuit);
+ all_simple = false;
+
+ /* Find all the marks now. */
+ for (end = buffer->idx + 1; end < count; end++)
+ if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end])))
+ break;
+
+ /* idx to end is one non-simple cluster. */
+ decompose_multi_char_cluster (&c, end, always_short_circuit);
+ }
+ while (buffer->idx < count && buffer->successful);
+ buffer->swap_buffers ();
}
- buffer->swap_buffers ();
/* Second round, reorder (inplace) */
- count = buffer->len;
- for (unsigned int i = 0; i < count; i++)
+ if (!all_simple)
{
- if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]) == 0)
- continue;
+ count = buffer->len;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]) == 0)
+ continue;
+
+ unsigned int end;
+ for (end = i + 1; end < count; end++)
+ if (_hb_glyph_info_get_modified_combining_class (&buffer->info[end]) == 0)
+ break;
+
+ /* We are going to do a O(n^2). Only do this if the sequence is short. */
+ if (end - i > HB_OT_SHAPE_COMPLEX_MAX_COMBINING_MARKS) {
+ i = end;
+ continue;
+ }
+
+ buffer->sort (i, end, compare_combining_class);
- unsigned int end;
- for (end = i + 1; end < count; end++)
- if (_hb_glyph_info_get_modified_combining_class (&buffer->info[end]) == 0)
- break;
+ if (plan->shaper->reorder_marks)
+ plan->shaper->reorder_marks (plan, buffer, i, end);
- /* We are going to do a O(n^2). Only do this if the sequence is short. */
- if (end - i > HB_OT_SHAPE_COMPLEX_MAX_COMBINING_MARKS) {
i = end;
- continue;
}
-
- buffer->sort (i, end, compare_combining_class);
-
- if (plan->shaper->reorder_marks)
- plan->shaper->reorder_marks (plan, buffer, i, end);
-
- i = end;
}
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_CGJ)
{
@@ -385,8 +413,9 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
/* Third round, recompose */
- if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS ||
- mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT)
+ if (!all_simple &&
+ (mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS ||
+ mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT))
{
/* As noted in the comment earlier, we don't try to combine
* ccc=0 chars with their previous Starter. */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.hh
index 80755f775de..04f1a800912 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape-normalize.hh
@@ -41,7 +41,7 @@ enum hb_ot_shape_normalization_mode_t {
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS, /* Never composes base-to-base */
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, /* Always fully decomposes and then recompose back */
- HB_OT_SHAPE_NORMALIZATION_MODE_AUTO, /* Choose decomposed if GPOS mark feature available, compose otherwise. */
+ HB_OT_SHAPE_NORMALIZATION_MODE_AUTO, /* See hb-ot-shape-normalize.cc for logic. */
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT = HB_OT_SHAPE_NORMALIZATION_MODE_AUTO
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.cc
index 748af9693c2..ef97435782c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.cc
@@ -26,8 +26,6 @@
* Google Author(s): Behdad Esfahbod
*/
-#define HB_SHAPER ot
-#define hb_ot_shape_plan_data_t hb_ot_shape_plan_t
#include "hb-shaper-impl.hh"
#include "hb-ot-shape.hh"
@@ -42,31 +40,189 @@
#include "hb-aat-layout.hh"
+/**
+ * SECTION:hb-ot-shape
+ * @title: hb-ot-shape
+ * @short_description: OpenType shaping support
+ * @include: hb-ot.h
+ *
+ * Support functions for OpenType shaping related queries.
+ **/
+
+
+static void
+hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features);
+
+static bool
+_hb_apply_morx (hb_face_t *face)
+{
+ if (hb_options ().aat &&
+ hb_aat_layout_has_substitution (face))
+ return true;
+
+ /* Ignore empty GSUB tables. */
+ return (!hb_ot_layout_has_substitution (face) ||
+ !hb_ot_layout_table_get_script_tags (face,
+ HB_OT_TAG_GSUB,
+ 0, nullptr, nullptr)) &&
+ hb_aat_layout_has_substitution (face);
+}
+
+hb_ot_shape_planner_t::hb_ot_shape_planner_t (hb_face_t *face,
+ const hb_segment_properties_t *props) :
+ face (face),
+ props (*props),
+ map (face, props),
+ aat_map (face, props),
+ apply_morx (_hb_apply_morx (face))
+{
+ shaper = hb_ot_shape_complex_categorize (this);
+
+ script_zero_marks = shaper->zero_width_marks != HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE;
+ script_fallback_mark_positioning = shaper->fallback_position;
+
+ if (apply_morx)
+ shaper = &_hb_ot_complex_shaper_default;
+}
+
void
-hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
- const int *coords,
- unsigned int num_coords)
+hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
+ const hb_ot_shape_plan_key_t &key)
{
plan.props = props;
plan.shaper = shaper;
- map.compile (plan.map, coords, num_coords);
+ map.compile (plan.map, key);
+ if (apply_morx)
+ aat_map.compile (plan.aat_map);
- plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c'));
plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r'));
plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m'));
+ plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask);
+ plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
+ hb_tag_t kern_tag = HB_DIRECTION_IS_HORIZONTAL (props.direction) ?
+ HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
+ plan.kern_mask = plan.map.get_mask (kern_tag);
+ plan.trak_mask = plan.map.get_mask (HB_TAG ('t','r','a','k'));
+
+ plan.requested_kerning = !!plan.kern_mask;
+ plan.requested_tracking = !!plan.trak_mask;
+ bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
+ bool disable_gpos = plan.shaper->gpos_tag &&
+ plan.shaper->gpos_tag != plan.map.chosen_script[1];
- plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ?
- HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'));
+ /*
+ * Decide who provides glyph classes. GDEF or Unicode.
+ */
- plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask);
- plan.kerning_requested = !!plan.kern_mask;
+ if (!hb_ot_layout_has_glyph_classes (face))
+ plan.fallback_glyph_classes = true;
+
+ /*
+ * Decide who does substitutions. GSUB, morx, or fallback.
+ */
+
+ plan.apply_morx = apply_morx;
+
+ /*
+ * Decide who does positioning. GPOS, kerx, kern, or fallback.
+ */
+
+ if (hb_options ().aat && hb_aat_layout_has_positioning (face))
+ plan.apply_kerx = true;
+ else if (!apply_morx && !disable_gpos && hb_ot_layout_has_positioning (face))
+ plan.apply_gpos = true;
+ else if (hb_aat_layout_has_positioning (face))
+ plan.apply_kerx = true;
+
+ if (!plan.apply_kerx && !has_gpos_kern)
+ {
+ /* Apparently Apple applies kerx if GPOS kern was not applied. */
+ if (hb_aat_layout_has_positioning (face))
+ plan.apply_kerx = true;
+ else if (hb_ot_layout_has_kerning (face))
+ plan.apply_kern = true;
+ }
+
+ plan.zero_marks = script_zero_marks &&
+ !plan.apply_kerx &&
+ (!plan.apply_kern || !hb_ot_layout_has_machine_kerning (face));
plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k'));
- bool disable_gpos = plan.shaper->gpos_tag &&
- plan.shaper->gpos_tag != plan.map.chosen_script[1];
- plan.fallback_positioning = disable_gpos || !hb_ot_layout_has_positioning (face);
- plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face);
+ plan.adjust_mark_positioning_when_zeroing = !plan.apply_gpos &&
+ !plan.apply_kerx &&
+ (!plan.apply_kern || !hb_ot_layout_has_cross_kerning (face));
+
+ plan.fallback_mark_positioning = plan.adjust_mark_positioning_when_zeroing &&
+ script_fallback_mark_positioning;
+
+ /* Currently we always apply trak. */
+ plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
+}
+
+bool
+hb_ot_shape_plan_t::init0 (hb_face_t *face,
+ const hb_shape_plan_key_t *key)
+{
+ map.init ();
+ aat_map.init ();
+
+ hb_ot_shape_planner_t planner (face,
+ &key->props);
+
+ hb_ot_shape_collect_features (&planner,
+ key->user_features,
+ key->num_user_features);
+
+ planner.compile (*this, key->ot);
+
+ if (shaper->data_create)
+ {
+ data = shaper->data_create (this);
+ if (unlikely (!data))
+ return false;
+ }
+
+ return true;
+}
+
+void
+hb_ot_shape_plan_t::fini (void)
+{
+ if (shaper->data_destroy)
+ shaper->data_destroy (const_cast<void *> (data));
+
+ map.fini ();
+ aat_map.fini ();
+}
+
+void
+hb_ot_shape_plan_t::substitute (hb_font_t *font,
+ hb_buffer_t *buffer) const
+{
+ if (unlikely (apply_morx))
+ hb_aat_layout_substitute (this, font, buffer);
+ else
+ map.substitute (this, font, buffer);
+}
+
+void
+hb_ot_shape_plan_t::position (hb_font_t *font,
+ hb_buffer_t *buffer) const
+{
+ if (this->apply_gpos)
+ map.position (this, font, buffer);
+ else if (this->apply_kerx)
+ hb_aat_layout_position (this, font, buffer);
+ else if (this->apply_kern)
+ hb_ot_layout_kern (this, font, buffer);
+ else
+ _hb_ot_shape_fallback_kern (this, font, buffer);
+
+ if (this->apply_trak)
+ hb_aat_layout_track (this, font, buffer);
}
@@ -94,7 +250,6 @@ horizontal_features[] =
static void
hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
- const hb_segment_properties_t *props,
const hb_feature_t *user_features,
unsigned int num_user_features)
{
@@ -103,7 +258,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
map->enable_feature (HB_TAG('r','v','r','n'));
map->add_gsub_pause (nullptr);
- switch (props->direction) {
+ switch (planner->props.direction) {
case HB_DIRECTION_LTR:
map->enable_feature (HB_TAG ('l','t','r','a'));
map->enable_feature (HB_TAG ('l','t','r','m'));
@@ -127,13 +282,22 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
/* Random! */
map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE);
+ /* Tracking. We enable dummy feature here just to allow disabling
+ * AAT 'trak' table using features.
+ * https://github.com/harfbuzz/harfbuzz/issues/1303 */
+ map->enable_feature (HB_TAG ('t','r','a','k'), F_HAS_FALLBACK);
+
+ map->enable_feature (HB_TAG ('H','A','R','F'));
+
if (planner->shaper->collect_features)
planner->shaper->collect_features (planner);
+ map->enable_feature (HB_TAG ('B','U','Z','Z'));
+
for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++)
map->add_feature (common_features[i]);
- if (HB_DIRECTION_IS_HORIZONTAL (props->direction))
+ if (HB_DIRECTION_IS_HORIZONTAL (planner->props.direction))
for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++)
map->add_feature (horizontal_features[i]);
else
@@ -156,6 +320,16 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
feature->end == HB_FEATURE_GLOBAL_END) ? F_GLOBAL : F_NONE,
feature->value);
}
+
+ if (planner->apply_morx)
+ {
+ hb_aat_map_builder_t *aat_map = &planner->aat_map;
+ for (unsigned int i = 0; i < num_user_features; i++)
+ {
+ const hb_feature_t *feature = &user_features[i];
+ aat_map->add_feature (feature->tag, feature->value);
+ }
+ }
}
@@ -163,18 +337,17 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
* shaper face data
*/
-HB_SHAPER_DATA_ENSURE_DEFINE(ot, face)
+struct hb_ot_face_data_t {};
hb_ot_face_data_t *
_hb_ot_shaper_face_data_create (hb_face_t *face)
{
- return _hb_ot_face_data_create (face);
+ return (hb_ot_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
}
void
_hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data)
{
- _hb_ot_face_data_destroy (data);
}
@@ -182,8 +355,6 @@ _hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data)
* shaper font data
*/
-HB_SHAPER_DATA_ENSURE_DEFINE(ot, font)
-
struct hb_ot_font_data_t {};
hb_ot_font_data_t *
@@ -193,62 +364,12 @@ _hb_ot_shaper_font_data_create (hb_font_t *font HB_UNUSED)
}
void
-_hb_ot_shaper_font_data_destroy (hb_ot_font_data_t *data)
+_hb_ot_shaper_font_data_destroy (hb_ot_font_data_t *data HB_UNUSED)
{
}
/*
- * shaper shape_plan data
- */
-
-hb_ot_shape_plan_data_t *
-_hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan,
- const hb_feature_t *user_features,
- unsigned int num_user_features,
- const int *coords,
- unsigned int num_coords)
-{
- hb_ot_shape_plan_t *plan = (hb_ot_shape_plan_t *) calloc (1, sizeof (hb_ot_shape_plan_t));
- if (unlikely (!plan))
- return nullptr;
-
- plan->init ();
-
- hb_ot_shape_planner_t planner (shape_plan);
-
- planner.shaper = hb_ot_shape_complex_categorize (&planner);
-
- hb_ot_shape_collect_features (&planner, &shape_plan->props,
- user_features, num_user_features);
-
- planner.compile (*plan, coords, num_coords);
-
- if (plan->shaper->data_create) {
- plan->data = plan->shaper->data_create (plan);
- if (unlikely (!plan->data))
- {
- free (plan);
- return nullptr;
- }
- }
-
- return plan;
-}
-
-void
-_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shape_plan_data_t *plan)
-{
- if (plan->shaper->data_destroy)
- plan->shaper->data_destroy (const_cast<void *> (plan->data));
-
- plan->fini ();
-
- free (plan);
-}
-
-
-/*
* shaper
*/
@@ -334,7 +455,6 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font)
buffer->output_info (info);
while (buffer->idx < buffer->len && buffer->successful)
buffer->next_glyph ();
-
buffer->swap_buffers ();
}
@@ -386,10 +506,12 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
}
-/* Substitute */
+/*
+ * Substitute
+ */
static inline void
-hb_ot_mirror_chars (hb_ot_shape_context_t *c)
+hb_ot_mirror_chars (const hb_ot_shape_context_t *c)
{
if (HB_DIRECTION_IS_FORWARD (c->target_direction))
return;
@@ -410,7 +532,7 @@ hb_ot_mirror_chars (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c)
+hb_ot_shape_setup_masks_fraction (const hb_ot_shape_context_t *c)
{
if (!(c->buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII) ||
!c->plan->has_frac)
@@ -460,7 +582,7 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_shape_initialize_masks (hb_ot_shape_context_t *c)
+hb_ot_shape_initialize_masks (const hb_ot_shape_context_t *c)
{
hb_ot_map_t *map = &c->plan->map;
hb_buffer_t *buffer = c->buffer;
@@ -470,7 +592,7 @@ hb_ot_shape_initialize_masks (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
+hb_ot_shape_setup_masks (const hb_ot_shape_context_t *c)
{
hb_ot_map_t *map = &c->plan->map;
hb_buffer_t *buffer = c->buffer;
@@ -492,10 +614,8 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
}
static void
-hb_ot_zero_width_default_ignorables (hb_ot_shape_context_t *c)
+hb_ot_zero_width_default_ignorables (const hb_buffer_t *buffer)
{
- hb_buffer_t *buffer = c->buffer;
-
if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES) ||
(buffer->flags & HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES) ||
(buffer->flags & HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES))
@@ -511,83 +631,29 @@ hb_ot_zero_width_default_ignorables (hb_ot_shape_context_t *c)
}
static void
-hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
+hb_ot_hide_default_ignorables (hb_buffer_t *buffer,
+ hb_font_t *font)
{
- hb_buffer_t *buffer = c->buffer;
-
if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES) ||
(buffer->flags & HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES))
return;
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
- hb_glyph_position_t *pos = buffer->pos;
- unsigned int i = 0;
- for (i = 0; i < count; i++)
- {
- if (unlikely (_hb_glyph_info_is_default_ignorable (&info[i])))
- break;
- }
- /* No default-ignorables found; return. */
- if (i == count)
- return;
-
- hb_codepoint_t space;
+ hb_codepoint_t invisible = buffer->invisible;
if (!(buffer->flags & HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES) &&
- c->font->get_nominal_glyph (' ', &space))
+ (invisible || font->get_nominal_glyph (' ', &invisible)))
{
- /* Replace default-ignorables with a zero-advance space glyph. */
- for (/*continue*/; i < count; i++)
+ /* Replace default-ignorables with a zero-advance invisible glyph. */
+ for (unsigned int i = 0; i < count; i++)
{
if (_hb_glyph_info_is_default_ignorable (&info[i]))
- info[i].codepoint = space;
+ info[i].codepoint = invisible;
}
}
else
- {
- /* Merge clusters and delete default-ignorables.
- * NOTE! We can't use out-buffer as we have positioning data. */
- unsigned int j = i;
- for (; i < count; i++)
- {
- if (_hb_glyph_info_is_default_ignorable (&info[i]))
- {
- /* Merge clusters.
- * Same logic as buffer->delete_glyph(), but for in-place removal. */
-
- unsigned int cluster = info[i].cluster;
- if (i + 1 < count && cluster == info[i + 1].cluster)
- continue; /* Cluster survives; do nothing. */
-
- if (j)
- {
- /* Merge cluster backward. */
- if (cluster < info[j - 1].cluster)
- {
- unsigned int mask = info[i].mask;
- unsigned int old_cluster = info[j - 1].cluster;
- for (unsigned k = j; k && info[k - 1].cluster == old_cluster; k--)
- buffer->set_cluster (info[k - 1], cluster, mask);
- }
- continue;
- }
-
- if (i + 1 < count)
- buffer->merge_clusters (i, i + 2); /* Merge cluster forward. */
-
- continue;
- }
-
- if (j != i)
- {
- info[j] = info[i];
- pos[j] = pos[i];
- }
- j++;
- }
- buffer->len = j;
- }
+ hb_ot_layout_delete_glyphs_inplace (buffer, _hb_glyph_info_is_default_ignorable);
}
@@ -604,10 +670,10 @@ hb_ot_map_glyphs_fast (hb_buffer_t *buffer)
}
static inline void
-hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
+hb_synthesize_glyph_classes (hb_buffer_t *buffer)
{
- unsigned int count = c->buffer->len;
- hb_glyph_info_t *info = c->buffer->info;
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
for (unsigned int i = 0; i < count; i++)
{
hb_ot_layout_glyph_props_flags_t klass;
@@ -630,7 +696,7 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_substitute_default (hb_ot_shape_context_t *c)
+hb_ot_substitute_default (const hb_ot_shape_context_t *c)
{
hb_buffer_t *buffer = c->buffer;
@@ -643,8 +709,8 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c)
hb_ot_shape_setup_masks (c);
/* This is unfortunate to go here, but necessary... */
- if (c->plan->fallback_positioning)
- _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, buffer);
+ if (c->plan->fallback_mark_positioning)
+ _hb_ot_shape_fallback_mark_position_recategorize_marks (c->plan, c->font, buffer);
hb_ot_map_glyphs_fast (buffer);
@@ -652,23 +718,20 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_substitute_complex (hb_ot_shape_context_t *c)
+hb_ot_substitute_complex (const hb_ot_shape_context_t *c)
{
hb_buffer_t *buffer = c->buffer;
hb_ot_layout_substitute_start (c->font, buffer);
if (c->plan->fallback_glyph_classes)
- hb_synthesize_glyph_classes (c);
+ hb_synthesize_glyph_classes (c->buffer);
c->plan->substitute (c->font, buffer);
-
- if (0) /* XXX Call morx instead. */
- hb_aat_layout_substitute (c->font, c->buffer);
}
static inline void
-hb_ot_substitute (hb_ot_shape_context_t *c)
+hb_ot_substitute_pre (const hb_ot_shape_context_t *c)
{
hb_ot_substitute_default (c);
@@ -677,7 +740,21 @@ hb_ot_substitute (hb_ot_shape_context_t *c)
hb_ot_substitute_complex (c);
}
-/* Position */
+static inline void
+hb_ot_substitute_post (const hb_ot_shape_context_t *c)
+{
+ hb_ot_hide_default_ignorables (c->buffer, c->font);
+ if (c->plan->apply_morx)
+ hb_aat_layout_remove_deleted_glyphs (c->buffer);
+
+ if (c->plan->shaper->postprocess_glyphs)
+ c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font);
+}
+
+
+/*
+ * Position
+ */
static inline void
adjust_mark_offsets (hb_glyph_position_t *pos)
@@ -708,7 +785,7 @@ zero_mark_widths_by_gdef (hb_buffer_t *buffer, bool adjust_offsets)
}
static inline void
-hb_ot_position_default (hb_ot_shape_context_t *c)
+hb_ot_position_default (const hb_ot_shape_context_t *c)
{
hb_direction_t direction = c->buffer->props.direction;
unsigned int count = c->buffer->len;
@@ -742,23 +819,22 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
}
static inline void
-hb_ot_position_complex (hb_ot_shape_context_t *c)
+hb_ot_position_complex (const hb_ot_shape_context_t *c)
{
unsigned int count = c->buffer->len;
hb_glyph_info_t *info = c->buffer->info;
hb_glyph_position_t *pos = c->buffer->pos;
- /* If the font has no GPOS, AND, no fallback positioning will
- * happen, AND, direction is forward, then when zeroing mark
- * widths, we shift the mark with it, such that the mark
- * is positioned hanging over the previous glyph. When
+ /* If the font has no GPOS and direction is forward, then when
+ * zeroing mark widths, we shift the mark with it, such that the
+ * mark is positioned hanging over the previous glyph. When
* direction is backward we don't shift and it will end up
* hanging over the next glyph after the final reordering.
- * If fallback positinoing happens or GPOS is present, we don't
- * care.
+ *
+ * Note: If fallback positinoing happens, we don't care about
+ * this as it will be overriden.
*/
- bool adjust_offsets_when_zeroing = c->plan->fallback_positioning &&
- !c->plan->shaper->fallback_position &&
+ bool adjust_offsets_when_zeroing = c->plan->adjust_mark_positioning_when_zeroing &&
HB_DIRECTION_IS_FORWARD (c->buffer->props.direction);
/* We change glyph origin to what GPOS expects (horizontal), apply GPOS, change it back. */
@@ -772,36 +848,39 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
hb_ot_layout_position_start (c->font, c->buffer);
- switch (c->plan->shaper->zero_width_marks)
- {
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
- zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
- break;
-
- default:
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
- break;
- }
-
- if (likely (!c->plan->fallback_positioning))
- c->plan->position (c->font, c->buffer);
+ if (c->plan->zero_marks)
+ switch (c->plan->shaper->zero_width_marks)
+ {
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
+ zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
+ break;
+
+ default:
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
+ break;
+ }
- switch (c->plan->shaper->zero_width_marks)
- {
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
- zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
- break;
+ c->plan->position (c->font, c->buffer);
- default:
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
- case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
- break;
- }
+ if (c->plan->zero_marks)
+ switch (c->plan->shaper->zero_width_marks)
+ {
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
+ zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing);
+ break;
+
+ default:
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE:
+ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
+ break;
+ }
- /* Finishing off GPOS has to follow a certain order. */
+ /* Finish off. Has to follow a certain order. */
hb_ot_layout_position_finish_advances (c->font, c->buffer);
- hb_ot_zero_width_default_ignorables (c);
+ hb_ot_zero_width_default_ignorables (c->buffer);
+ if (c->plan->apply_morx)
+ hb_aat_layout_zero_width_deleted_glyphs (c->buffer);
hb_ot_layout_position_finish_offsets (c->font, c->buffer);
/* The nil glyph_h_origin() func returns 0, so no need to apply it. */
@@ -810,10 +889,13 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
c->font->subtract_glyph_h_origin (info[i].codepoint,
&pos[i].x_offset,
&pos[i].y_offset);
+
+ if (c->plan->fallback_mark_positioning)
+ _hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer);
}
static inline void
-hb_ot_position (hb_ot_shape_context_t *c)
+hb_ot_position (const hb_ot_shape_context_t *c)
{
c->buffer->clear_positions ();
@@ -821,20 +903,10 @@ hb_ot_position (hb_ot_shape_context_t *c)
hb_ot_position_complex (c);
- if (c->plan->fallback_positioning && c->plan->shaper->fallback_position)
- _hb_ot_shape_fallback_position (c->plan, c->font, c->buffer);
-
if (HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction))
hb_buffer_reverse (c->buffer);
- /* Visual fallback goes here. */
-
- if (c->plan->fallback_positioning)
- _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer);
-
_hb_buffer_deallocate_gsubgpos_vars (c->buffer);
-
- //hb_aat_layout_position (c->font, c->buffer);
}
static inline void
@@ -899,13 +971,9 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
if (c->plan->shaper->preprocess_text)
c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font);
- hb_ot_substitute (c);
+ hb_ot_substitute_pre (c);
hb_ot_position (c);
-
- hb_ot_hide_default_ignorables (c);
-
- if (c->plan->shaper->postprocess_glyphs)
- c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font);
+ hb_ot_substitute_post (c);
hb_propagate_flags (c->buffer);
@@ -926,7 +994,7 @@ _hb_ot_shape (hb_shape_plan_t *shape_plan,
const hb_feature_t *features,
unsigned int num_features)
{
- hb_ot_shape_context_t c = {HB_SHAPER_DATA_GET (shape_plan), font, font->face, buffer, features, num_features};
+ hb_ot_shape_context_t c = {&shape_plan->ot, font, font->face, buffer, features, num_features};
hb_ot_shape_internal (&c);
return true;
@@ -943,8 +1011,7 @@ hb_ot_shape_plan_collect_lookups (hb_shape_plan_t *shape_plan,
hb_tag_t table_tag,
hb_set_t *lookup_indexes /* OUT */)
{
- /* XXX Does the first part always succeed? */
- HB_SHAPER_DATA_GET (shape_plan)->collect_lookups (table_tag, lookup_indexes);
+ shape_plan->ot.collect_lookups (table_tag, lookup_indexes);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.hh
index 88c72dc1588..6e1478d0085 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-shape.hh
@@ -30,24 +30,60 @@
#include "hb.hh"
#include "hb-ot-map.hh"
-#include "hb-shape-plan.hh"
+#include "hb-aat-map.hh"
+struct hb_ot_shape_plan_key_t
+{
+ unsigned int variations_index[2];
+
+ inline void init (hb_face_t *face,
+ const int *coords,
+ unsigned int num_coords)
+ {
+ for (unsigned int table_index = 0; table_index < 2; table_index++)
+ hb_ot_layout_table_find_feature_variations (face,
+ table_tags[table_index],
+ coords,
+ num_coords,
+ &variations_index[table_index]);
+ }
+
+ inline bool equal (const hb_ot_shape_plan_key_t *other)
+ {
+ return 0 == memcmp (this, other, sizeof (*this));
+ }
+};
+
+
+struct hb_shape_plan_key_t;
struct hb_ot_shape_plan_t
{
hb_segment_properties_t props;
const struct hb_ot_complex_shaper_t *shaper;
hb_ot_map_t map;
+ hb_aat_map_t aat_map;
const void *data;
- hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask;
+ hb_mask_t frac_mask, numr_mask, dnom_mask;
+ hb_mask_t rtlm_mask;
hb_mask_t kern_mask;
+ hb_mask_t trak_mask;
+ bool requested_kerning : 1;
+ bool requested_tracking : 1;
bool has_frac : 1;
- bool kerning_requested : 1;
bool has_gpos_mark : 1;
- bool fallback_positioning : 1;
+ bool zero_marks : 1;
bool fallback_glyph_classes : 1;
+ bool fallback_mark_positioning : 1;
+ bool adjust_mark_positioning_when_zeroing : 1;
+
+ bool apply_gpos : 1;
+ bool apply_kerx : 1;
+ bool apply_kern : 1;
+ bool apply_morx : 1;
+ bool apply_trak : 1;
inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const
{
@@ -59,39 +95,34 @@ struct hb_ot_shape_plan_t
}
map.collect_lookups (table_index, lookups);
}
- inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); }
- inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); }
- void init (void)
- {
- memset (this, 0, sizeof (*this));
- map.init ();
- }
- void fini (void) {
- map.fini ();
- }
+ HB_INTERNAL bool init0 (hb_face_t *face,
+ const hb_shape_plan_key_t *key);
+ HB_INTERNAL void fini (void);
+
+ HB_INTERNAL void substitute (hb_font_t *font, hb_buffer_t *buffer) const;
+ HB_INTERNAL void position (hb_font_t *font, hb_buffer_t *buffer) const;
};
+struct hb_shape_plan_t;
+
struct hb_ot_shape_planner_t
{
/* In the order that they are filled in. */
hb_face_t *face;
hb_segment_properties_t props;
- const struct hb_ot_complex_shaper_t *shaper;
hb_ot_map_builder_t map;
+ hb_aat_map_builder_t aat_map;
+ bool apply_morx : 1;
+ bool script_zero_marks : 1;
+ bool script_fallback_mark_positioning : 1;
+ const struct hb_ot_complex_shaper_t *shaper;
- hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) :
- face (master_plan->face_unsafe),
- props (master_plan->props),
- shaper (nullptr),
- map (face, &props) {}
-
- HB_INTERNAL void compile (hb_ot_shape_plan_t &plan,
- const int *coords,
- unsigned int num_coords);
+ HB_INTERNAL hb_ot_shape_planner_t (hb_face_t *face,
+ const hb_segment_properties_t *props);
- private:
- HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t);
+ HB_INTERNAL void compile (hb_ot_shape_plan_t &plan,
+ const hb_ot_shape_plan_key_t &key);
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-stat-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-stat-table.hh
new file mode 100644
index 00000000000..02c376e5de2
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-stat-table.hh
@@ -0,0 +1,280 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#ifndef HB_OT_STAT_TABLE_HH
+#define HB_OT_STAT_TABLE_HH
+
+#include "hb-open-type.hh"
+#include "hb-ot-layout-common.hh"
+
+/*
+ * STAT -- Style Attributes
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/stat
+ */
+#define HB_OT_TAG_STAT HB_TAG('S','T','A','T')
+
+
+namespace OT {
+
+enum
+{
+ OLDER_SIBLING_FONT_ATTRIBUTE = 0x0001, /* If set, this axis value table
+ * provides axis value information
+ * that is applicable to other fonts
+ * within the same font family. This
+ * is used if the other fonts were
+ * released earlier and did not include
+ * information about values for some axis.
+ * If newer versions of the other
+ * fonts include the information
+ * themselves and are present,
+ * then this record is ignored. */
+ ELIDABLE_AXIS_VALUE_NAME = 0x0002 /* If set, it indicates that the axis
+ * value represents the “normal” value
+ * for the axis and may be omitted when
+ * composing name strings. */
+ // Reserved = 0xFFFC /* Reserved for future use — set to zero. */
+};
+
+struct StatAxisRecord
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ Tag axisTag; /* A tag identifying the axis of design variation. */
+ NameID axisNameID; /* The name ID for entries in the 'name' table that
+ * provide a display string for this axis. */
+ HBUINT16 axisOrdering; /* A value that applications can use to determine
+ * primary sorting of face names, or for ordering
+ * of descriptors when composing family or face names. */
+ public:
+ DEFINE_SIZE_STATIC (8);
+};
+
+struct AxisValueFormat1
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT16 format; /* Format identifier — set to 1. */
+ HBUINT16 axisIndex; /* Zero-base index into the axis record array
+ * identifying the axis of design variation
+ * to which the axis value record applies.
+ * Must be less than designAxisCount. */
+ HBUINT16 flags; /* Flags — see below for details. */
+ NameID valueNameID; /* The name ID for entries in the 'name' table
+ * that provide a display string for this
+ * attribute value. */
+ Fixed value; /* A numeric value for this attribute value. */
+ public:
+ DEFINE_SIZE_STATIC (12);
+};
+
+struct AxisValueFormat2
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT16 format; /* Format identifier — set to 2. */
+ HBUINT16 axisIndex; /* Zero-base index into the axis record array
+ * identifying the axis of design variation
+ * to which the axis value record applies.
+ * Must be less than designAxisCount. */
+ HBUINT16 flags; /* Flags — see below for details. */
+ NameID valueNameID; /* The name ID for entries in the 'name' table
+ * that provide a display string for this
+ * attribute value. */
+ Fixed nominalValue; /* A numeric value for this attribute value. */
+ Fixed rangeMinValue; /* The minimum value for a range associated
+ * with the specified name ID. */
+ Fixed rangeMaxValue; /* The maximum value for a range associated
+ * with the specified name ID. */
+ public:
+ DEFINE_SIZE_STATIC (20);
+};
+
+struct AxisValueFormat3
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT16 format; /* Format identifier — set to 3. */
+ HBUINT16 axisIndex; /* Zero-base index into the axis record array
+ * identifying the axis of design variation
+ * to which the axis value record applies.
+ * Must be less than designAxisCount. */
+ HBUINT16 flags; /* Flags — see below for details. */
+ NameID valueNameID; /* The name ID for entries in the 'name' table
+ * that provide a display string for this
+ * attribute value. */
+ Fixed value; /* A numeric value for this attribute value. */
+ Fixed linkedValue; /* The numeric value for a style-linked mapping
+ * from this value. */
+ public:
+ DEFINE_SIZE_STATIC (16);
+};
+
+struct AxisValueRecord
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT16 axisIndex; /* Zero-base index into the axis record array
+ * identifying the axis to which this value
+ * applies. Must be less than designAxisCount. */
+ Fixed value; /* A numeric value for this attribute value. */
+ public:
+ DEFINE_SIZE_STATIC (6);
+};
+
+struct AxisValueFormat4
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ protected:
+ HBUINT16 format; /* Format identifier — set to 4. */
+ HBUINT16 axisCount; /* The total number of axes contributing to
+ * this axis-values combination. */
+ HBUINT16 flags; /* Flags — see below for details. */
+ NameID valueNameID; /* The name ID for entries in the 'name' table
+ * that provide a display string for this
+ * attribute value. */
+ UnsizedArrayOf<AxisValueRecord>
+ axisValues; /* Array of AxisValue records that provide the
+ * combination of axis values, one for each
+ * contributing axis. */
+ public:
+ DEFINE_SIZE_ARRAY (8, axisValues);
+};
+
+struct AxisValue
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (c->check_struct (this)))
+ return_trace (false);
+
+ switch (u.format)
+ {
+ case 1: return_trace (likely (u.format1.sanitize (c)));
+ case 2: return_trace (likely (u.format2.sanitize (c)));
+ case 3: return_trace (likely (u.format3.sanitize (c)));
+ case 4: return_trace (likely (u.format4.sanitize (c)));
+ default: return_trace (true);
+ }
+ }
+
+ protected:
+ union
+ {
+ HBUINT16 format;
+ AxisValueFormat1 format1;
+ AxisValueFormat2 format2;
+ AxisValueFormat3 format3;
+ AxisValueFormat4 format4;
+ } u;
+ public:
+ DEFINE_SIZE_UNION (2, format);
+};
+
+struct STAT
+{
+ static const hb_tag_t tableTag = HB_OT_TAG_STAT;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ majorVersion == 1 &&
+ minorVersion > 0 &&
+ designAxesOffset.sanitize (c, this, designAxisCount) &&
+ offsetToAxisValueOffsets.sanitize (c, this, axisValueCount, &(this+offsetToAxisValueOffsets))));
+ }
+
+ protected:
+ HBUINT16 majorVersion; /* Major version number of the style attributes
+ * table — set to 1. */
+ HBUINT16 minorVersion; /* Minor version number of the style attributes
+ * table — set to 2. */
+ HBUINT16 designAxisSize; /* The size in bytes of each axis record. */
+ HBUINT16 designAxisCount;/* The number of design axis records. In a
+ * font with an 'fvar' table, this value must be
+ * greater than or equal to the axisCount value
+ * in the 'fvar' table. In all fonts, must
+ * be greater than zero if axisValueCount
+ * is greater than zero. */
+ LOffsetTo<UnsizedArrayOf<StatAxisRecord>, false>
+ designAxesOffset;
+ /* Offset in bytes from the beginning of
+ * the STAT table to the start of the design
+ * axes array. If designAxisCount is zero,
+ * set to zero; if designAxisCount is greater
+ * than zero, must be greater than zero. */
+ HBUINT16 axisValueCount; /* The number of axis value tables. */
+ LOffsetTo<UnsizedArrayOf<OffsetTo<AxisValue> >, false>
+ offsetToAxisValueOffsets;
+ /* Offset in bytes from the beginning of
+ * the STAT table to the start of the design
+ * axes value offsets array. If axisValueCount
+ * is zero, set to zero; if axisValueCount is
+ * greater than zero, must be greater than zero. */
+ NameID elidedFallbackNameID;
+ /* Name ID used as fallback when projection of
+ * names into a particular font model produces
+ * a subfamily name containing only elidable
+ * elements. */
+ public:
+ DEFINE_SIZE_STATIC (20);
+};
+
+
+} /* namespace OT */
+
+
+#endif /* HB_OT_STAT_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag-table.hh
new file mode 100644
index 00000000000..b7090a0a787
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag-table.hh
@@ -0,0 +1,2064 @@
+/* == Start of generated table == */
+/*
+ * The following table is generated by running:
+ *
+ * ./gen-tag-table.py languagetags language-subtag-registry
+ *
+ * on files with these headers:
+ *
+ * <meta name="updated_at" content="2018-09-07 07:45 PM" />
+ * File-Date: 2018-08-08
+ */
+
+#ifndef HB_OT_TAG_TABLE_HH
+#define HB_OT_TAG_TABLE_HH
+
+static const LangTag ot_languages[] = {
+ {"aa", {HB_TAG('A','F','R',' ')}}, /* Afar */
+ {"aae", {HB_TAG('S','Q','I',' ')}}, /* Arbëreshë Albanian -> Albanian */
+ {"aao", {HB_TAG('A','R','A',' ')}}, /* Algerian Saharan Arabic -> Arabic */
+ {"aat", {HB_TAG('S','Q','I',' ')}}, /* Arvanitika Albanian -> Albanian */
+ {"ab", {HB_TAG('A','B','K',' ')}}, /* Abkhazian */
+ {"abh", {HB_TAG('A','R','A',' ')}}, /* Tajiki Arabic -> Arabic */
+ {"abq", {HB_TAG('A','B','A',' ')}}, /* Abaza */
+ {"abv", {HB_TAG('A','R','A',' ')}}, /* Baharna Arabic -> Arabic */
+ {"acf", {HB_TAG('F','A','N',' ')}}, /* Saint Lucian Creole French -> French Antillean */
+ {"ach", {HB_TAG('A','C','H',' ')}}, /* Acoli -> Acholi */
+ {"acm", {HB_TAG('A','R','A',' ')}}, /* Mesopotamian Arabic -> Arabic */
+ {"acq", {HB_TAG('A','R','A',' ')}}, /* Ta'izzi-Adeni Arabic -> Arabic */
+ {"acr", {HB_TAG('A','C','R',' ')}}, /* Achi */
+ {"acw", {HB_TAG('A','R','A',' ')}}, /* Hijazi Arabic -> Arabic */
+ {"acx", {HB_TAG('A','R','A',' ')}}, /* Omani Arabic -> Arabic */
+ {"acy", {HB_TAG('A','R','A',' ')}}, /* Cypriot Arabic -> Arabic */
+ {"ada", {HB_TAG('D','N','G',' ')}}, /* Adangme -> Dangme */
+ {"adf", {HB_TAG('A','R','A',' ')}}, /* Dhofari Arabic -> Arabic */
+ {"adp", {HB_TAG('D','Z','N',' ')}}, /* Adap (retired code) -> Dzongkha */
+ {"ady", {HB_TAG('A','D','Y',' ')}}, /* Adyghe */
+ {"aeb", {HB_TAG('A','R','A',' ')}}, /* Tunisian Arabic -> Arabic */
+ {"aec", {HB_TAG('A','R','A',' ')}}, /* Saidi Arabic -> Arabic */
+ {"af", {HB_TAG('A','F','K',' ')}}, /* Afrikaans */
+ {"afb", {HB_TAG('A','R','A',' ')}}, /* Gulf Arabic -> Arabic */
+ {"ahg", {HB_TAG('A','G','W',' ')}}, /* Qimant -> Agaw */
+ {"aht", {HB_TAG('A','T','H',' ')}}, /* Ahtena -> Athapaskan */
+ {"aii", {HB_TAG('S','W','A',' '), /* Assyrian Neo-Aramaic -> Swadaya Aramaic */
+ HB_TAG('S','Y','R',' ')}}, /* Assyrian Neo-Aramaic -> Syriac */
+ {"aio", {HB_TAG('A','I','O',' ')}}, /* Aiton */
+ {"aiw", {HB_TAG('A','R','I',' ')}}, /* Aari */
+ {"ajp", {HB_TAG('A','R','A',' ')}}, /* South Levantine Arabic -> Arabic */
+ {"ak", {HB_TAG('A','K','A',' '), /* Akan [macrolanguage] */
+ HB_TAG('T','W','I',' ')}}, /* Akan [macrolanguage] -> Twi */
+ {"aln", {HB_TAG('S','Q','I',' ')}}, /* Gheg Albanian -> Albanian */
+ {"als", {HB_TAG('S','Q','I',' ')}}, /* Tosk Albanian -> Albanian */
+ {"alt", {HB_TAG('A','L','T',' ')}}, /* Southern Altai -> Altai */
+ {"am", {HB_TAG('A','M','H',' ')}}, /* Amharic */
+ {"amf", {HB_TAG('H','B','N',' ')}}, /* Hamer-Banna -> Hammer-Banna */
+ {"amw", {HB_TAG('S','Y','R',' ')}}, /* Western Neo-Aramaic -> Syriac */
+ {"an", {HB_TAG('A','R','G',' ')}}, /* Aragonese */
+ {"ang", {HB_TAG('A','N','G',' ')}}, /* Old English (ca. 450-1100) -> Anglo-Saxon */
+ {"apc", {HB_TAG('A','R','A',' ')}}, /* North Levantine Arabic -> Arabic */
+ {"apd", {HB_TAG('A','R','A',' ')}}, /* Sudanese Arabic -> Arabic */
+ {"apj", {HB_TAG('A','T','H',' ')}}, /* Jicarilla Apache -> Athapaskan */
+ {"apk", {HB_TAG('A','T','H',' ')}}, /* Kiowa Apache -> Athapaskan */
+ {"apl", {HB_TAG('A','T','H',' ')}}, /* Lipan Apache -> Athapaskan */
+ {"apm", {HB_TAG('A','T','H',' ')}}, /* Mescalero-Chiricahua Apache -> Athapaskan */
+ {"apw", {HB_TAG('A','T','H',' ')}}, /* Western Apache -> Athapaskan */
+ {"ar", {HB_TAG('A','R','A',' ')}}, /* Arabic [macrolanguage] */
+ {"arb", {HB_TAG('A','R','A',' ')}}, /* Standard Arabic -> Arabic */
+ {"arn", {HB_TAG('M','A','P',' ')}}, /* Mapudungun */
+ {"arq", {HB_TAG('A','R','A',' ')}}, /* Algerian Arabic -> Arabic */
+ {"ars", {HB_TAG('A','R','A',' ')}}, /* Najdi Arabic -> Arabic */
+ {"ary", {HB_TAG('M','O','R',' ')}}, /* Moroccan Arabic -> Moroccan */
+ {"arz", {HB_TAG('A','R','A',' ')}}, /* Egyptian Arabic -> Arabic */
+ {"as", {HB_TAG('A','S','M',' ')}}, /* Assamese */
+ {"ast", {HB_TAG('A','S','T',' ')}}, /* Asturian */
+ {"ath", {HB_TAG('A','T','H',' ')}}, /* Athapascan [family] -> Athapaskan */
+ {"atj", {HB_TAG('R','C','R',' ')}}, /* Atikamekw -> R-Cree */
+ {"atv", {HB_TAG('A','L','T',' ')}}, /* Northern Altai -> Altai */
+ {"auz", {HB_TAG('A','R','A',' ')}}, /* Uzbeki Arabic -> Arabic */
+ {"av", {HB_TAG('A','V','R',' ')}}, /* Avaric -> Avar */
+ {"avl", {HB_TAG('A','R','A',' ')}}, /* Eastern Egyptian Bedawi Arabic -> Arabic */
+ {"awa", {HB_TAG('A','W','A',' ')}}, /* Awadhi */
+ {"ay", {HB_TAG('A','Y','M',' ')}}, /* Aymara [macrolanguage] */
+ {"ayc", {HB_TAG('A','Y','M',' ')}}, /* Southern Aymara -> Aymara */
+ {"ayh", {HB_TAG('A','R','A',' ')}}, /* Hadrami Arabic -> Arabic */
+ {"ayl", {HB_TAG('A','R','A',' ')}}, /* Libyan Arabic -> Arabic */
+ {"ayn", {HB_TAG('A','R','A',' ')}}, /* Sanaani Arabic -> Arabic */
+ {"ayp", {HB_TAG('A','R','A',' ')}}, /* North Mesopotamian Arabic -> Arabic */
+ {"ayr", {HB_TAG('A','Y','M',' ')}}, /* Central Aymara -> Aymara */
+ {"az", {HB_TAG('A','Z','E',' ')}}, /* Azerbaijani [macrolanguage] */
+ {"azb", {HB_TAG('A','Z','B',' ')}}, /* South Azerbaijani -> Torki */
+ {"azj", {HB_TAG('A','Z','E',' ')}}, /* North Azerbaijani -> Azerbaijani */
+ {"ba", {HB_TAG('B','S','H',' ')}}, /* Bashkir */
+ {"bad", {HB_TAG('B','A','D','0')}}, /* Banda [family] */
+ {"bai", {HB_TAG('B','M','L',' ')}}, /* Bamileke [family] */
+ {"bal", {HB_TAG('B','L','I',' ')}}, /* Baluchi [macrolanguage] */
+ {"ban", {HB_TAG('B','A','N',' ')}}, /* Balinese */
+ {"bar", {HB_TAG('B','A','R',' ')}}, /* Bavarian */
+ {"bbc", {HB_TAG('B','B','C',' ')}}, /* Batak Toba */
+ {"bbz", {HB_TAG('A','R','A',' ')}}, /* Babalia Creole Arabic -> Arabic */
+ {"bcc", {HB_TAG('B','L','I',' ')}}, /* Southern Balochi -> Baluchi */
+ {"bci", {HB_TAG('B','A','U',' ')}}, /* Baoulé -> Baulé */
+ {"bcl", {HB_TAG('B','I','K',' ')}}, /* Central Bikol -> Bikol */
+ {"bcq", {HB_TAG('B','C','H',' ')}}, /* Bench */
+ {"bcr", {HB_TAG('A','T','H',' ')}}, /* Babine -> Athapaskan */
+ {"bdy", {HB_TAG('B','D','Y',' ')}}, /* Bandjalang */
+ {"be", {HB_TAG('B','E','L',' ')}}, /* Belarusian -> Belarussian */
+ {"bea", {HB_TAG('A','T','H',' ')}}, /* Beaver -> Athapaskan */
+ {"beb", {HB_TAG('B','T','I',' ')}}, /* Bebele -> Beti */
+ {"bem", {HB_TAG('B','E','M',' ')}}, /* Bemba (Zambia) */
+ {"ber", {HB_TAG('B','B','R',' ')}}, /* Berber [family] */
+ {"bfq", {HB_TAG('B','A','D',' ')}}, /* Badaga */
+ {"bft", {HB_TAG('B','L','T',' ')}}, /* Balti */
+ {"bfu", {HB_TAG('L','A','H',' ')}}, /* Gahri -> Lahuli */
+ {"bfy", {HB_TAG('B','A','G',' ')}}, /* Bagheli -> Baghelkhandi */
+ {"bg", {HB_TAG('B','G','R',' ')}}, /* Bulgarian */
+ {"bgc", {HB_TAG('B','G','C',' ')}}, /* Haryanvi */
+ {"bgn", {HB_TAG('B','L','I',' ')}}, /* Western Balochi -> Baluchi */
+ {"bgp", {HB_TAG('B','L','I',' ')}}, /* Eastern Balochi -> Baluchi */
+ {"bgq", {HB_TAG('B','G','Q',' ')}}, /* Bagri */
+ {"bgr", {HB_TAG('Q','I','N',' ')}}, /* Bawm Chin -> Chin */
+ {"bhb", {HB_TAG('B','H','I',' ')}}, /* Bhili */
+ {"bhi", {HB_TAG('B','H','I',' ')}}, /* Bhilali -> Bhili */
+ {"bhk", {HB_TAG('B','I','K',' ')}}, /* Albay Bicolano (retired code) -> Bikol */
+ {"bho", {HB_TAG('B','H','O',' ')}}, /* Bhojpuri */
+ {"bhr", {HB_TAG('M','L','G',' ')}}, /* Bara Malagasy -> Malagasy */
+ {"bi", {HB_TAG('B','I','S',' ')}}, /* Bislama */
+ {"bik", {HB_TAG('B','I','K',' ')}}, /* Bikol [macrolanguage] */
+ {"bin", {HB_TAG('E','D','O',' ')}}, /* Edo */
+ {"bjj", {HB_TAG('B','J','J',' ')}}, /* Kanauji */
+ {"bjn", {HB_TAG('M','L','Y',' ')}}, /* Banjar -> Malay */
+ {"bjq", {HB_TAG('M','L','G',' ')}}, /* Southern Betsimisaraka Malagasy (retired code) -> Malagasy */
+ {"bjt", {HB_TAG('B','L','N',' ')}}, /* Balanta-Ganja -> Balante */
+ {"bla", {HB_TAG('B','K','F',' ')}}, /* Siksika -> Blackfoot */
+ {"ble", {HB_TAG('B','L','N',' ')}}, /* Balanta-Kentohe -> Balante */
+ {"blk", {HB_TAG('B','L','K',' ')}}, /* Pa'o Karen */
+ {"bln", {HB_TAG('B','I','K',' ')}}, /* Southern Catanduanes Bikol -> Bikol */
+ {"bm", {HB_TAG('B','M','B',' ')}}, /* Bambara (Bamanankan) */
+ {"bmm", {HB_TAG('M','L','G',' ')}}, /* Northern Betsimisaraka Malagasy -> Malagasy */
+ {"bn", {HB_TAG('B','E','N',' ')}}, /* Bengali */
+ {"bo", {HB_TAG('T','I','B',' ')}}, /* Tibetan */
+ {"bpy", {HB_TAG('B','P','Y',' ')}}, /* Bishnupriya -> Bishnupriya Manipuri */
+ {"bqi", {HB_TAG('L','R','C',' ')}}, /* Bakhtiari -> Luri */
+ {"br", {HB_TAG('B','R','E',' ')}}, /* Breton */
+ {"bra", {HB_TAG('B','R','I',' ')}}, /* Braj -> Braj Bhasha */
+ {"brh", {HB_TAG('B','R','H',' ')}}, /* Brahui */
+ {"brx", {HB_TAG('B','R','X',' ')}}, /* Bodo (India) */
+ {"bs", {HB_TAG('B','O','S',' ')}}, /* Bosnian */
+ {"bsk", {HB_TAG('B','S','K',' ')}}, /* Burushaski */
+ {"btb", {HB_TAG('B','T','I',' ')}}, /* Beti (Cameroon) (retired code) */
+ {"btj", {HB_TAG('M','L','Y',' ')}}, /* Bacanese Malay -> Malay */
+ {"bto", {HB_TAG('B','I','K',' ')}}, /* Rinconada Bikol -> Bikol */
+ {"bts", {HB_TAG('B','T','S',' ')}}, /* Batak Simalungun */
+ {"bug", {HB_TAG('B','U','G',' ')}}, /* Buginese -> Bugis */
+ {"bum", {HB_TAG('B','T','I',' ')}}, /* Bulu (Cameroon) -> Beti */
+ {"bve", {HB_TAG('M','L','Y',' ')}}, /* Berau Malay -> Malay */
+ {"bvu", {HB_TAG('M','L','Y',' ')}}, /* Bukit Malay -> Malay */
+ {"bxk", {HB_TAG('L','U','H',' ')}}, /* Bukusu -> Luyia */
+ {"bxp", {HB_TAG('B','T','I',' ')}}, /* Bebil -> Beti */
+ {"bxr", {HB_TAG('R','B','U',' ')}}, /* Russia Buriat -> Russian Buriat */
+ {"byn", {HB_TAG('B','I','L',' ')}}, /* Bilin -> Bilen */
+ {"byv", {HB_TAG('B','Y','V',' ')}}, /* Medumba */
+ {"bzc", {HB_TAG('M','L','G',' ')}}, /* Southern Betsimisaraka Malagasy -> Malagasy */
+ {"ca", {HB_TAG('C','A','T',' ')}}, /* Catalan */
+ {"caf", {HB_TAG('C','R','R',' '), /* Southern Carrier -> Carrier */
+ HB_TAG('A','T','H',' ')}}, /* Southern Carrier -> Athapaskan */
+ {"cak", {HB_TAG('C','A','K',' ')}}, /* Kaqchikel */
+ {"cbk", {HB_TAG('C','B','K',' ')}}, /* Chavacano -> Zamboanga Chavacano */
+ {"cbl", {HB_TAG('Q','I','N',' ')}}, /* Bualkhaw Chin -> Chin */
+ {"cco", {HB_TAG('C','C','H','N')}}, /* Comaltepec Chinantec -> Chinantec */
+ {"ccq", {HB_TAG('A','R','K',' ')}}, /* Chaungtha (retired code) -> Rakhine */
+ {"cdo", {HB_TAG('Z','H','S',' ')}}, /* Min Dong Chinese -> Chinese Simplified */
+ {"ce", {HB_TAG('C','H','E',' ')}}, /* Chechen */
+ {"ceb", {HB_TAG('C','E','B',' ')}}, /* Cebuano */
+ {"cfm", {HB_TAG('H','A','L',' ')}}, /* Halam (Falam Chin) */
+ {"cgg", {HB_TAG('C','G','G',' ')}}, /* Chiga */
+ {"ch", {HB_TAG('C','H','A',' ')}}, /* Chamorro */
+ {"chj", {HB_TAG('C','C','H','N')}}, /* Ojitlán Chinantec -> Chinantec */
+ {"chk", {HB_TAG('C','H','K','0')}}, /* Chuukese */
+ {"cho", {HB_TAG('C','H','O',' ')}}, /* Choctaw */
+ {"chp", {HB_TAG('C','H','P',' '), /* Chipewyan */
+ HB_TAG('S','A','Y',' '), /* Chipewyan -> Sayisi */
+ HB_TAG('A','T','H',' ')}}, /* Chipewyan -> Athapaskan */
+ {"chq", {HB_TAG('C','C','H','N')}}, /* Quiotepec Chinantec -> Chinantec */
+ {"chr", {HB_TAG('C','H','R',' ')}}, /* Cherokee */
+ {"chy", {HB_TAG('C','H','Y',' ')}}, /* Cheyenne */
+ {"chz", {HB_TAG('C','C','H','N')}}, /* Ozumacín Chinantec -> Chinantec */
+ {"ciw", {HB_TAG('O','J','B',' ')}}, /* Chippewa -> Ojibway */
+ {"cja", {HB_TAG('C','J','A',' ')}}, /* Western Cham */
+ {"cjm", {HB_TAG('C','J','M',' ')}}, /* Eastern Cham */
+ {"cjy", {HB_TAG('Z','H','S',' ')}}, /* Jinyu Chinese -> Chinese Simplified */
+ {"cka", {HB_TAG('Q','I','N',' ')}}, /* Khumi Awa Chin (retired code) -> Chin */
+ {"ckb", {HB_TAG('K','U','R',' ')}}, /* Central Kurdish -> Kurdish */
+ {"ckt", {HB_TAG('C','H','K',' ')}}, /* Chukot -> Chukchi */
+ {"clc", {HB_TAG('A','T','H',' ')}}, /* Chilcotin -> Athapaskan */
+ {"cld", {HB_TAG('S','Y','R',' ')}}, /* Chaldean Neo-Aramaic -> Syriac */
+ {"cle", {HB_TAG('C','C','H','N')}}, /* Lealao Chinantec -> Chinantec */
+ {"cmn", {HB_TAG('Z','H','S',' ')}}, /* Mandarin Chinese -> Chinese Simplified */
+ {"cmr", {HB_TAG('Q','I','N',' ')}}, /* Mro-Khimi Chin -> Chin */
+ {"cnb", {HB_TAG('Q','I','N',' ')}}, /* Chinbon Chin -> Chin */
+ {"cnh", {HB_TAG('Q','I','N',' ')}}, /* Hakha Chin -> Chin */
+ {"cnk", {HB_TAG('Q','I','N',' ')}}, /* Khumi Chin -> Chin */
+ {"cnl", {HB_TAG('C','C','H','N')}}, /* Lalana Chinantec -> Chinantec */
+ {"cnt", {HB_TAG('C','C','H','N')}}, /* Tepetotutla Chinantec -> Chinantec */
+ {"cnw", {HB_TAG('Q','I','N',' ')}}, /* Ngawn Chin -> Chin */
+ {"co", {HB_TAG('C','O','S',' ')}}, /* Corsican */
+ {"coa", {HB_TAG('M','L','Y',' ')}}, /* Cocos Islands Malay -> Malay */
+ {"cop", {HB_TAG('C','O','P',' ')}}, /* Coptic */
+ {"coq", {HB_TAG('A','T','H',' ')}}, /* Coquille -> Athapaskan */
+ {"cpa", {HB_TAG('C','C','H','N')}}, /* Palantla Chinantec -> Chinantec */
+ {"cpe", {HB_TAG('C','P','P',' ')}}, /* English-based creoles and pidgins [family] -> Creoles */
+ {"cpf", {HB_TAG('C','P','P',' ')}}, /* French-based creoles and pidgins [family] -> Creoles */
+ {"cpp", {HB_TAG('C','P','P',' ')}}, /* Portuguese-based creoles and pidgins [family] -> Creoles */
+ {"cpx", {HB_TAG('Z','H','S',' ')}}, /* Pu-Xian Chinese -> Chinese Simplified */
+ {"cqd", {HB_TAG('H','M','N',' ')}}, /* Chuanqiandian Cluster Miao -> Hmong */
+ {"cqu", {HB_TAG('Q','U','H',' ')}}, /* Chilean Quechua (retired code) -> Quechua (Bolivia) */
+ {"cr", {HB_TAG('C','R','E',' '), /* Cree [macrolanguage] */
+ HB_TAG('Y','C','R',' ')}}, /* Cree [macrolanguage] -> Y-Cree */
+ {"crh", {HB_TAG('C','R','T',' ')}}, /* Crimean Tatar */
+ {"crj", {HB_TAG('E','C','R',' ')}}, /* Southern East Cree -> Eastern Cree */
+ {"crk", {HB_TAG('W','C','R',' ')}}, /* Plains Cree -> West-Cree */
+ {"crl", {HB_TAG('E','C','R',' ')}}, /* Northern East Cree -> Eastern Cree */
+ {"crm", {HB_TAG('M','C','R',' '), /* Moose Cree */
+ HB_TAG('L','C','R',' ')}}, /* Moose Cree -> L-Cree */
+ {"crp", {HB_TAG('C','P','P',' ')}}, /* Creoles and pidgins [family] -> Creoles */
+ {"crx", {HB_TAG('C','R','R',' '), /* Carrier */
+ HB_TAG('A','T','H',' ')}}, /* Carrier -> Athapaskan */
+ {"cs", {HB_TAG('C','S','Y',' ')}}, /* Czech */
+ {"csa", {HB_TAG('C','C','H','N')}}, /* Chiltepec Chinantec -> Chinantec */
+ {"csb", {HB_TAG('C','S','B',' ')}}, /* Kashubian */
+ {"csh", {HB_TAG('Q','I','N',' ')}}, /* Asho Chin -> Chin */
+ {"cso", {HB_TAG('C','C','H','N')}}, /* Sochiapam Chinantec -> Chinantec */
+ {"csw", {HB_TAG('N','C','R',' '), /* Swampy Cree -> N-Cree */
+ HB_TAG('N','H','C',' ')}}, /* Swampy Cree -> Norway House Cree */
+ {"csy", {HB_TAG('Q','I','N',' ')}}, /* Siyin Chin -> Chin */
+ {"ctc", {HB_TAG('A','T','H',' ')}}, /* Chetco -> Athapaskan */
+ {"ctd", {HB_TAG('Q','I','N',' ')}}, /* Tedim Chin -> Chin */
+ {"cte", {HB_TAG('C','C','H','N')}}, /* Tepinapa Chinantec -> Chinantec */
+ {"ctg", {HB_TAG('C','T','G',' ')}}, /* Chittagonian */
+ {"ctl", {HB_TAG('C','C','H','N')}}, /* Tlacoatzintepec Chinantec -> Chinantec */
+ {"cts", {HB_TAG('B','I','K',' ')}}, /* Northern Catanduanes Bikol -> Bikol */
+ {"cu", {HB_TAG('C','S','L',' ')}}, /* Church Slavonic */
+ {"cuc", {HB_TAG('C','C','H','N')}}, /* Usila Chinantec -> Chinantec */
+ {"cuk", {HB_TAG('C','U','K',' ')}}, /* San Blas Kuna */
+ {"cv", {HB_TAG('C','H','U',' ')}}, /* Chuvash */
+ {"cvn", {HB_TAG('C','C','H','N')}}, /* Valle Nacional Chinantec -> Chinantec */
+ {"cwd", {HB_TAG('D','C','R',' '), /* Woods Cree */
+ HB_TAG('T','C','R',' ')}}, /* Woods Cree -> TH-Cree */
+ {"cy", {HB_TAG('W','E','L',' ')}}, /* Welsh */
+ {"czh", {HB_TAG('Z','H','S',' ')}}, /* Huizhou Chinese -> Chinese Simplified */
+ {"czo", {HB_TAG('Z','H','S',' ')}}, /* Min Zhong Chinese -> Chinese Simplified */
+ {"czt", {HB_TAG('Q','I','N',' ')}}, /* Zotung Chin -> Chin */
+ {"da", {HB_TAG('D','A','N',' ')}}, /* Danish */
+ {"dao", {HB_TAG('Q','I','N',' ')}}, /* Daai Chin -> Chin */
+ {"dap", {HB_TAG('N','I','S',' ')}}, /* Nisi (India) (retired code) */
+ {"dar", {HB_TAG('D','A','R',' ')}}, /* Dargwa */
+ {"dax", {HB_TAG('D','A','X',' ')}}, /* Dayi */
+ {"de", {HB_TAG('D','E','U',' ')}}, /* German */
+ {"den", {HB_TAG('S','L','A',' '), /* Slave (Athapascan) [macrolanguage] -> Slavey */
+ HB_TAG('A','T','H',' ')}}, /* Slave (Athapascan) [macrolanguage] -> Athapaskan */
+ {"dgo", {HB_TAG('D','G','O',' ')}}, /* Dogri */
+ {"dgr", {HB_TAG('A','T','H',' ')}}, /* Dogrib -> Athapaskan */
+ {"dhd", {HB_TAG('M','A','W',' ')}}, /* Dhundari -> Marwari */
+ {"dhg", {HB_TAG('D','H','G',' ')}}, /* Dhangu */
+ {"dib", {HB_TAG('D','N','K',' ')}}, /* South Central Dinka -> Dinka */
+ {"dik", {HB_TAG('D','N','K',' ')}}, /* Southwestern Dinka -> Dinka */
+ {"din", {HB_TAG('D','N','K',' ')}}, /* Dinka [macrolanguage] */
+ {"dip", {HB_TAG('D','N','K',' ')}}, /* Northeastern Dinka -> Dinka */
+ {"diq", {HB_TAG('D','I','Q',' ')}}, /* Dimli */
+ {"diw", {HB_TAG('D','N','K',' ')}}, /* Northwestern Dinka -> Dinka */
+ {"dje", {HB_TAG('D','J','R',' ')}}, /* Zarma */
+ {"djr", {HB_TAG('D','J','R','0')}}, /* Djambarrpuyngu */
+ {"dks", {HB_TAG('D','N','K',' ')}}, /* Southeastern Dinka -> Dinka */
+ {"dng", {HB_TAG('D','U','N',' ')}}, /* Dungan */
+ {"dnj", {HB_TAG('D','N','J',' ')}}, /* Dan */
+ {"doi", {HB_TAG('D','G','R',' ')}}, /* Dogri [macrolanguage] */
+ {"drh", {HB_TAG('M','N','G',' ')}}, /* Darkhat (retired code) -> Mongolian */
+ {"drw", {HB_TAG('D','R','I',' ')}}, /* Darwazi (retired code) -> Dari */
+ {"dsb", {HB_TAG('L','S','B',' ')}}, /* Lower Sorbian */
+ {"dty", {HB_TAG('N','E','P',' ')}}, /* Dotyali -> Nepali */
+ {"duj", {HB_TAG('D','U','J',' ')}}, /* Dhuwal (retired code) */
+ {"dup", {HB_TAG('M','L','Y',' ')}}, /* Duano -> Malay */
+ {"dv", {HB_TAG('D','I','V',' '), /* Divehi (Dhivehi, Maldivian) */
+ HB_TAG('D','H','V',' ')}}, /* Divehi (Dhivehi, Maldivian) (deprecated) */
+ {"dwu", {HB_TAG('D','U','J',' ')}}, /* Dhuwal */
+ {"dwy", {HB_TAG('D','U','J',' ')}}, /* Dhuwaya -> Dhuwal */
+ {"dyu", {HB_TAG('J','U','L',' ')}}, /* Dyula -> Jula */
+ {"dz", {HB_TAG('D','Z','N',' ')}}, /* Dzongkha */
+ {"ee", {HB_TAG('E','W','E',' ')}}, /* Ewe */
+ {"efi", {HB_TAG('E','F','I',' ')}}, /* Efik */
+ {"ekk", {HB_TAG('E','T','I',' ')}}, /* Standard Estonian -> Estonian */
+ {"el", {HB_TAG('E','L','L',' ')}}, /* Modern Greek (1453-) -> Greek */
+ {"emk", {HB_TAG('E','M','K',' '), /* Eastern Maninkakan */
+ HB_TAG('M','N','K',' ')}}, /* Eastern Maninkakan -> Maninka */
+ {"en", {HB_TAG('E','N','G',' ')}}, /* English */
+ {"enb", {HB_TAG('K','A','L',' ')}}, /* Markweeta -> Kalenjin */
+ {"enf", {HB_TAG('F','N','E',' ')}}, /* Forest Enets -> Forest Nenets */
+ {"enh", {HB_TAG('T','N','E',' ')}}, /* Tundra Enets -> Tundra Nenets */
+ {"eo", {HB_TAG('N','T','O',' ')}}, /* Esperanto */
+ {"es", {HB_TAG('E','S','P',' ')}}, /* Spanish */
+ {"esg", {HB_TAG('G','O','N',' ')}}, /* Aheri Gondi -> Gondi */
+ {"esi", {HB_TAG('I','P','K',' ')}}, /* North Alaskan Inupiatun -> Inupiat */
+ {"esk", {HB_TAG('I','P','K',' ')}}, /* Northwest Alaska Inupiatun -> Inupiat */
+ {"esu", {HB_TAG('E','S','U',' ')}}, /* Central Yupik */
+ {"et", {HB_TAG('E','T','I',' ')}}, /* Estonian [macrolanguage] */
+ {"eto", {HB_TAG('B','T','I',' ')}}, /* Eton (Cameroon) -> Beti */
+ {"eu", {HB_TAG('E','U','Q',' ')}}, /* Basque */
+ {"eve", {HB_TAG('E','V','N',' ')}}, /* Even */
+ {"evn", {HB_TAG('E','V','K',' ')}}, /* Evenki */
+ {"ewo", {HB_TAG('B','T','I',' ')}}, /* Ewondo -> Beti */
+ {"eyo", {HB_TAG('K','A','L',' ')}}, /* Keiyo -> Kalenjin */
+ {"fa", {HB_TAG('F','A','R',' ')}}, /* Persian [macrolanguage] */
+ {"fan", {HB_TAG('F','A','N','0')}}, /* Fang (Equatorial Guinea) */
+ {"fat", {HB_TAG('F','A','T',' ')}}, /* Fanti */
+ {"fbl", {HB_TAG('B','I','K',' ')}}, /* West Albay Bikol -> Bikol */
+ {"ff", {HB_TAG('F','U','L',' ')}}, /* Fulah [macrolanguage] */
+ {"ffm", {HB_TAG('F','U','L',' ')}}, /* Maasina Fulfulde -> Fulah */
+ {"fi", {HB_TAG('F','I','N',' ')}}, /* Finnish */
+ {"fil", {HB_TAG('P','I','L',' ')}}, /* Filipino */
+ {"fj", {HB_TAG('F','J','I',' ')}}, /* Fijian */
+ {"flm", {HB_TAG('H','A','L',' '), /* Halam (Falam Chin) (retired code) */
+ HB_TAG('Q','I','N',' ')}}, /* Falam Chin (retired code) -> Chin */
+ {"fmp", {HB_TAG('F','M','P',' ')}}, /* Fe'fe' */
+ {"fo", {HB_TAG('F','O','S',' ')}}, /* Faroese */
+ {"fon", {HB_TAG('F','O','N',' ')}}, /* Fon */
+ {"fr", {HB_TAG('F','R','A',' ')}}, /* French */
+ {"frc", {HB_TAG('F','R','C',' ')}}, /* Cajun French */
+ {"frp", {HB_TAG('F','R','P',' ')}}, /* Arpitan */
+ {"fub", {HB_TAG('F','U','L',' ')}}, /* Adamawa Fulfulde -> Fulah */
+ {"fuc", {HB_TAG('F','U','L',' ')}}, /* Pulaar -> Fulah */
+ {"fue", {HB_TAG('F','U','L',' ')}}, /* Borgu Fulfulde -> Fulah */
+ {"fuf", {HB_TAG('F','T','A',' ')}}, /* Pular -> Futa */
+ {"fuh", {HB_TAG('F','U','L',' ')}}, /* Western Niger Fulfulde -> Fulah */
+ {"fui", {HB_TAG('F','U','L',' ')}}, /* Bagirmi Fulfulde -> Fulah */
+ {"fuq", {HB_TAG('F','U','L',' ')}}, /* Central-Eastern Niger Fulfulde -> Fulah */
+ {"fur", {HB_TAG('F','R','L',' ')}}, /* Friulian */
+ {"fuv", {HB_TAG('F','U','V',' ')}}, /* Nigerian Fulfulde */
+ {"fy", {HB_TAG('F','R','I',' ')}}, /* Western Frisian -> Frisian */
+ {"ga", {HB_TAG('I','R','I',' ')}}, /* Irish */
+ {"gaa", {HB_TAG('G','A','D',' ')}}, /* Ga */
+ {"gag", {HB_TAG('G','A','G',' ')}}, /* Gagauz */
+ {"gan", {HB_TAG('Z','H','S',' ')}}, /* Gan Chinese -> Chinese Simplified */
+ {"gax", {HB_TAG('O','R','O',' ')}}, /* Borana-Arsi-Guji Oromo -> Oromo */
+ {"gaz", {HB_TAG('O','R','O',' ')}}, /* West Central Oromo -> Oromo */
+ {"gbm", {HB_TAG('G','A','W',' ')}}, /* Garhwali */
+ {"gce", {HB_TAG('A','T','H',' ')}}, /* Galice -> Athapaskan */
+ {"gd", {HB_TAG('G','A','E',' ')}}, /* Scottish Gaelic (Gaelic) */
+ {"gda", {HB_TAG('R','A','J',' ')}}, /* Gade Lohar -> Rajasthani */
+ {"gez", {HB_TAG('G','E','Z',' ')}}, /* Geez */
+ {"ggo", {HB_TAG('G','O','N',' ')}}, /* Southern Gondi (retired code) -> Gondi */
+ {"gih", {HB_TAG('G','I','H',' ')}}, /* Githabul */
+ {"gil", {HB_TAG('G','I','L','0')}}, /* Kiribati (Gilbertese) */
+ {"gju", {HB_TAG('R','A','J',' ')}}, /* Gujari -> Rajasthani */
+ {"gkp", {HB_TAG('G','K','P',' ')}}, /* Guinea Kpelle -> Kpelle (Guinea) */
+ {"gl", {HB_TAG('G','A','L',' ')}}, /* Galician */
+ {"gld", {HB_TAG('N','A','N',' ')}}, /* Nanai */
+ {"glk", {HB_TAG('G','L','K',' ')}}, /* Gilaki */
+ {"gn", {HB_TAG('G','U','A',' ')}}, /* Guarani [macrolanguage] */
+ {"gnn", {HB_TAG('G','N','N',' ')}}, /* Gumatj */
+ {"gno", {HB_TAG('G','O','N',' ')}}, /* Northern Gondi -> Gondi */
+ {"gnw", {HB_TAG('G','U','A',' ')}}, /* Western Bolivian Guaraní -> Guarani */
+ {"gog", {HB_TAG('G','O','G',' ')}}, /* Gogo */
+ {"gom", {HB_TAG('K','O','K',' ')}}, /* Goan Konkani -> Konkani */
+ {"gon", {HB_TAG('G','O','N',' ')}}, /* Gondi [macrolanguage] */
+ {"grt", {HB_TAG('G','R','O',' ')}}, /* Garo */
+ {"gru", {HB_TAG('S','O','G',' ')}}, /* Kistane -> Sodo Gurage */
+ {"gsw", {HB_TAG('A','L','S',' ')}}, /* Alsatian */
+ {"gu", {HB_TAG('G','U','J',' ')}}, /* Gujarati */
+ {"guc", {HB_TAG('G','U','C',' ')}}, /* Wayuu */
+ {"guf", {HB_TAG('G','U','F',' ')}}, /* Gupapuyngu */
+ {"gug", {HB_TAG('G','U','A',' ')}}, /* Paraguayan Guaraní -> Guarani */
+ {"gui", {HB_TAG('G','U','A',' ')}}, /* Eastern Bolivian Guaraní -> Guarani */
+ {"guk", {HB_TAG('G','M','Z',' '), /* Gumuz */
+ HB_TAG('G','U','K',' ')}}, /* Gumuz (SIL fonts) */
+ {"gun", {HB_TAG('G','U','A',' ')}}, /* Mbyá Guaraní -> Guarani */
+ {"guz", {HB_TAG('G','U','Z',' ')}}, /* Gusii */
+ {"gv", {HB_TAG('M','N','X',' ')}}, /* Manx */
+ {"gwi", {HB_TAG('A','T','H',' ')}}, /* Gwichʼin -> Athapaskan */
+ {"ha", {HB_TAG('H','A','U',' ')}}, /* Hausa */
+ {"haa", {HB_TAG('A','T','H',' ')}}, /* Han -> Athapaskan */
+ {"hae", {HB_TAG('O','R','O',' ')}}, /* Eastern Oromo -> Oromo */
+ {"hak", {HB_TAG('Z','H','S',' ')}}, /* Hakka Chinese -> Chinese Simplified */
+ {"har", {HB_TAG('H','R','I',' ')}}, /* Harari */
+ {"haw", {HB_TAG('H','A','W',' ')}}, /* Hawaiian */
+ {"hay", {HB_TAG('H','A','Y',' ')}}, /* Haya */
+ {"haz", {HB_TAG('H','A','Z',' ')}}, /* Hazaragi */
+ {"he", {HB_TAG('I','W','R',' ')}}, /* Hebrew */
+ {"hea", {HB_TAG('H','M','N',' ')}}, /* Northern Qiandong Miao -> Hmong */
+ {"hi", {HB_TAG('H','I','N',' ')}}, /* Hindi */
+ {"hil", {HB_TAG('H','I','L',' ')}}, /* Hiligaynon */
+ {"hji", {HB_TAG('M','L','Y',' ')}}, /* Haji -> Malay */
+ {"hlt", {HB_TAG('Q','I','N',' ')}}, /* Matu Chin -> Chin */
+ {"hma", {HB_TAG('H','M','N',' ')}}, /* Southern Mashan Hmong -> Hmong */
+ {"hmc", {HB_TAG('H','M','N',' ')}}, /* Central Huishui Hmong -> Hmong */
+ {"hmd", {HB_TAG('H','M','N',' ')}}, /* Large Flowery Miao -> Hmong */
+ {"hme", {HB_TAG('H','M','N',' ')}}, /* Eastern Huishui Hmong -> Hmong */
+ {"hmg", {HB_TAG('H','M','N',' ')}}, /* Southwestern Guiyang Hmong -> Hmong */
+ {"hmh", {HB_TAG('H','M','N',' ')}}, /* Southwestern Huishui Hmong -> Hmong */
+ {"hmi", {HB_TAG('H','M','N',' ')}}, /* Northern Huishui Hmong -> Hmong */
+ {"hmj", {HB_TAG('H','M','N',' ')}}, /* Ge -> Hmong */
+ {"hml", {HB_TAG('H','M','N',' ')}}, /* Luopohe Hmong -> Hmong */
+ {"hmm", {HB_TAG('H','M','N',' ')}}, /* Central Mashan Hmong -> Hmong */
+ {"hmn", {HB_TAG('H','M','N',' ')}}, /* Hmong [macrolanguage] */
+ {"hmp", {HB_TAG('H','M','N',' ')}}, /* Northern Mashan Hmong -> Hmong */
+ {"hmq", {HB_TAG('H','M','N',' ')}}, /* Eastern Qiandong Miao -> Hmong */
+ {"hms", {HB_TAG('H','M','N',' ')}}, /* Southern Qiandong Miao -> Hmong */
+ {"hmw", {HB_TAG('H','M','N',' ')}}, /* Western Mashan Hmong -> Hmong */
+ {"hmy", {HB_TAG('H','M','N',' ')}}, /* Southern Guiyang Hmong -> Hmong */
+ {"hmz", {HB_TAG('H','M','N',' ')}}, /* Hmong Shua -> Hmong */
+ {"hnd", {HB_TAG('H','N','D',' ')}}, /* Southern Hindko -> Hindko */
+ {"hne", {HB_TAG('C','H','H',' ')}}, /* Chhattisgarhi -> Chattisgarhi */
+ {"hnj", {HB_TAG('H','M','N',' ')}}, /* Hmong Njua -> Hmong */
+ {"hno", {HB_TAG('H','N','D',' ')}}, /* Northern Hindko -> Hindko */
+ {"ho", {HB_TAG('H','M','O',' ')}}, /* Hiri Motu */
+ {"hoc", {HB_TAG('H','O',' ',' ')}}, /* Ho */
+ {"hoi", {HB_TAG('A','T','H',' ')}}, /* Holikachuk -> Athapaskan */
+ {"hoj", {HB_TAG('H','A','R',' ')}}, /* Hadothi -> Harauti */
+ {"hr", {HB_TAG('H','R','V',' ')}}, /* Croatian */
+ {"hrm", {HB_TAG('H','M','N',' ')}}, /* Horned Miao -> Hmong */
+ {"hsb", {HB_TAG('U','S','B',' ')}}, /* Upper Sorbian */
+ {"hsn", {HB_TAG('Z','H','S',' ')}}, /* Xiang Chinese -> Chinese Simplified */
+ {"ht", {HB_TAG('H','A','I',' ')}}, /* Haitian (Haitian Creole) */
+ {"hu", {HB_TAG('H','U','N',' ')}}, /* Hungarian */
+ {"huj", {HB_TAG('H','M','N',' ')}}, /* Northern Guiyang Hmong -> Hmong */
+ {"hup", {HB_TAG('A','T','H',' ')}}, /* Hupa -> Athapaskan */
+ {"hy", {HB_TAG('H','Y','E','0'), /* Armenian -> Armenian East */
+ HB_TAG('H','Y','E',' ')}}, /* Armenian */
+ {"hyw", {HB_TAG('H','Y','E',' ')}}, /* Western Armenian -> Armenian */
+ {"hz", {HB_TAG('H','E','R',' ')}}, /* Herero */
+ {"ia", {HB_TAG('I','N','A',' ')}}, /* Interlingua (International Auxiliary Language Association) */
+ {"iba", {HB_TAG('I','B','A',' ')}}, /* Iban */
+ {"ibb", {HB_TAG('I','B','B',' ')}}, /* Ibibio */
+ {"id", {HB_TAG('I','N','D',' ')}}, /* Indonesian */
+ {"ida", {HB_TAG('L','U','H',' ')}}, /* Idakho-Isukha-Tiriki -> Luyia */
+ {"ie", {HB_TAG('I','L','E',' ')}}, /* Interlingue */
+ {"ig", {HB_TAG('I','B','O',' ')}}, /* Igbo */
+ {"igb", {HB_TAG('E','B','I',' ')}}, /* Ebira */
+ {"ii", {HB_TAG('Y','I','M',' ')}}, /* Sichuan Yi -> Yi Modern */
+ {"ijc", {HB_TAG('I','J','O',' ')}}, /* Izon -> Ijo */
+ {"ijo", {HB_TAG('I','J','O',' ')}}, /* Ijo [family] */
+ {"ik", {HB_TAG('I','P','K',' ')}}, /* Inupiaq [macrolanguage] -> Inupiat */
+ {"ike", {HB_TAG('I','N','U',' ')}}, /* Eastern Canadian Inuktitut -> Inuktitut */
+ {"ikt", {HB_TAG('I','N','U',' ')}}, /* Inuinnaqtun -> Inuktitut */
+ {"ilo", {HB_TAG('I','L','O',' ')}}, /* Iloko -> Ilokano */
+ {"in", {HB_TAG('I','N','D',' ')}}, /* Indonesian (retired code) */
+ {"ing", {HB_TAG('A','T','H',' ')}}, /* Degexit'an -> Athapaskan */
+ {"inh", {HB_TAG('I','N','G',' ')}}, /* Ingush */
+ {"io", {HB_TAG('I','D','O',' ')}}, /* Ido */
+ {"is", {HB_TAG('I','S','L',' ')}}, /* Icelandic */
+ {"it", {HB_TAG('I','T','A',' ')}}, /* Italian */
+ {"iu", {HB_TAG('I','N','U',' ')}}, /* Inuktitut [macrolanguage] */
+ {"iw", {HB_TAG('I','W','R',' ')}}, /* Hebrew (retired code) */
+ {"ja", {HB_TAG('J','A','N',' ')}}, /* Japanese */
+ {"jak", {HB_TAG('M','L','Y',' ')}}, /* Jakun -> Malay */
+ {"jam", {HB_TAG('J','A','M',' ')}}, /* Jamaican Creole English -> Jamaican Creole */
+ {"jax", {HB_TAG('M','L','Y',' ')}}, /* Jambi Malay -> Malay */
+ {"jbo", {HB_TAG('J','B','O',' ')}}, /* Lojban */
+ {"jct", {HB_TAG('J','C','T',' ')}}, /* Krymchak */
+ {"ji", {HB_TAG('J','I','I',' ')}}, /* Yiddish (retired code) */
+ {"jv", {HB_TAG('J','A','V',' ')}}, /* Javanese */
+ {"jw", {HB_TAG('J','A','V',' ')}}, /* Javanese (retired code) */
+ {"ka", {HB_TAG('K','A','T',' ')}}, /* Georgian */
+ {"kaa", {HB_TAG('K','R','K',' ')}}, /* Kara-Kalpak -> Karakalpak */
+ {"kab", {HB_TAG('K','A','B','0')}}, /* Kabyle */
+ {"kam", {HB_TAG('K','M','B',' ')}}, /* Kamba (Kenya) */
+ {"kar", {HB_TAG('K','R','N',' ')}}, /* Karen [family] */
+ {"kbd", {HB_TAG('K','A','B',' ')}}, /* Kabardian */
+ {"kby", {HB_TAG('K','N','R',' ')}}, /* Manga Kanuri -> Kanuri */
+ {"kca", {HB_TAG('K','H','K',' '), /* Khanty -> Khanty-Kazim */
+ HB_TAG('K','H','S',' '), /* Khanty -> Khanty-Shurishkar */
+ HB_TAG('K','H','V',' ')}}, /* Khanty -> Khanty-Vakhi */
+ {"kde", {HB_TAG('K','D','E',' ')}}, /* Makonde */
+ {"kdr", {HB_TAG('K','R','M',' ')}}, /* Karaim */
+ {"kdt", {HB_TAG('K','U','Y',' ')}}, /* Kuy */
+ {"kea", {HB_TAG('K','E','A',' ')}}, /* Kabuverdianu (Crioulo) */
+ {"kek", {HB_TAG('K','E','K',' ')}}, /* Kekchi */
+ {"kex", {HB_TAG('K','K','N',' ')}}, /* Kukna -> Kokni */
+ {"kfa", {HB_TAG('K','O','D',' ')}}, /* Kodava -> Kodagu */
+ {"kfr", {HB_TAG('K','A','C',' ')}}, /* Kachhi -> Kachchi */
+ {"kfx", {HB_TAG('K','U','L',' ')}}, /* Kullu Pahari -> Kulvi */
+ {"kfy", {HB_TAG('K','M','N',' ')}}, /* Kumaoni */
+ {"kg", {HB_TAG('K','O','N','0')}}, /* Kongo [macrolanguage] */
+ {"kha", {HB_TAG('K','S','I',' ')}}, /* Khasi */
+ {"khb", {HB_TAG('X','B','D',' ')}}, /* Lü */
+ {"khk", {HB_TAG('M','N','G',' ')}}, /* Halh Mongolian -> Mongolian */
+ {"kht", {HB_TAG('K','H','N',' '), /* Khamti -> Khamti Shan (Microsoft fonts) */
+ HB_TAG('K','H','T',' ')}}, /* Khamti -> Khamti Shan (OpenType spec and SIL fonts) */
+ {"khw", {HB_TAG('K','H','W',' ')}}, /* Khowar */
+ {"ki", {HB_TAG('K','I','K',' ')}}, /* Kikuyu (Gikuyu) */
+ {"kiu", {HB_TAG('K','I','U',' ')}}, /* Kirmanjki */
+ {"kj", {HB_TAG('K','U','A',' ')}}, /* Kuanyama */
+ {"kjd", {HB_TAG('K','J','D',' ')}}, /* Southern Kiwai */
+ {"kjh", {HB_TAG('K','H','A',' ')}}, /* Khakas -> Khakass */
+ {"kjp", {HB_TAG('K','J','P',' ')}}, /* Pwo Eastern Karen -> Eastern Pwo Karen */
+ {"kjz", {HB_TAG('K','J','Z',' ')}}, /* Bumthangkha */
+ {"kk", {HB_TAG('K','A','Z',' ')}}, /* Kazakh */
+ {"kkz", {HB_TAG('A','T','H',' ')}}, /* Kaska -> Athapaskan */
+ {"kl", {HB_TAG('G','R','N',' ')}}, /* Greenlandic */
+ {"kln", {HB_TAG('K','A','L',' ')}}, /* Kalenjin [macrolanguage] */
+ {"km", {HB_TAG('K','H','M',' ')}}, /* Khmer */
+ {"kmb", {HB_TAG('M','B','N',' ')}}, /* Kimbundu -> Mbundu */
+ {"kmr", {HB_TAG('K','U','R',' ')}}, /* Northern Kurdish -> Kurdish */
+ {"kmw", {HB_TAG('K','M','O',' ')}}, /* Komo (Democratic Republic of Congo) */
+ {"kmz", {HB_TAG('K','M','Z',' ')}}, /* Khorasani Turkish -> Khorasani Turkic */
+ {"kn", {HB_TAG('K','A','N',' ')}}, /* Kannada */
+ {"knc", {HB_TAG('K','N','R',' ')}}, /* Central Kanuri -> Kanuri */
+ {"kng", {HB_TAG('K','O','N','0')}}, /* Koongo -> Kongo */
+ {"knn", {HB_TAG('K','O','K',' ')}}, /* Konkani */
+ {"ko", {HB_TAG('K','O','R',' ')}}, /* Korean */
+ {"koi", {HB_TAG('K','O','P',' ')}}, /* Komi-Permyak */
+ {"kok", {HB_TAG('K','O','K',' ')}}, /* Konkani [macrolanguage] */
+ {"kos", {HB_TAG('K','O','S',' ')}}, /* Kosraean */
+ {"koy", {HB_TAG('A','T','H',' ')}}, /* Koyukon -> Athapaskan */
+ {"kpe", {HB_TAG('K','P','L',' ')}}, /* Kpelle [macrolanguage] */
+ {"kpv", {HB_TAG('K','O','Z',' ')}}, /* Komi-Zyrian */
+ {"kpy", {HB_TAG('K','Y','K',' ')}}, /* Koryak */
+ {"kqs", {HB_TAG('K','I','S',' ')}}, /* Northern Kissi -> Kisii */
+ {"kqy", {HB_TAG('K','R','T',' ')}}, /* Koorete */
+ {"kr", {HB_TAG('K','N','R',' ')}}, /* Kanuri [macrolanguage] */
+ {"krc", {HB_TAG('K','A','R',' '), /* Karachay-Balkar -> Karachay */
+ HB_TAG('B','A','L',' ')}}, /* Karachay-Balkar -> Balkar */
+ {"kri", {HB_TAG('K','R','I',' ')}}, /* Krio */
+ {"krl", {HB_TAG('K','R','L',' ')}}, /* Karelian */
+ {"krt", {HB_TAG('K','N','R',' ')}}, /* Tumari Kanuri -> Kanuri */
+ {"kru", {HB_TAG('K','U','U',' ')}}, /* Kurukh */
+ {"ks", {HB_TAG('K','S','H',' ')}}, /* Kashmiri */
+ {"ksh", {HB_TAG('K','S','H','0')}}, /* Kölsch -> Ripuarian */
+ {"kss", {HB_TAG('K','I','S',' ')}}, /* Southern Kisi -> Kisii */
+ {"ksw", {HB_TAG('K','S','W',' ')}}, /* S’gaw Karen */
+ {"ktb", {HB_TAG('K','E','B',' ')}}, /* Kambaata -> Kebena */
+ {"ktu", {HB_TAG('K','O','N',' ')}}, /* Kituba (Democratic Republic of Congo) -> Kikongo */
+ {"ktw", {HB_TAG('A','T','H',' ')}}, /* Kato -> Athapaskan */
+ {"ku", {HB_TAG('K','U','R',' ')}}, /* Kurdish [macrolanguage] */
+ {"kum", {HB_TAG('K','U','M',' ')}}, /* Kumyk */
+ {"kuu", {HB_TAG('A','T','H',' ')}}, /* Upper Kuskokwim -> Athapaskan */
+ {"kv", {HB_TAG('K','O','M',' ')}}, /* Komi [macrolanguage] */
+ {"kvb", {HB_TAG('M','L','Y',' ')}}, /* Kubu -> Malay */
+ {"kvr", {HB_TAG('M','L','Y',' ')}}, /* Kerinci -> Malay */
+ {"kw", {HB_TAG('C','O','R',' ')}}, /* Cornish */
+ {"kwy", {HB_TAG('K','O','N','0')}}, /* San Salvador Kongo -> Kongo */
+ {"kxc", {HB_TAG('K','M','S',' ')}}, /* Konso -> Komso */
+ {"kxd", {HB_TAG('M','L','Y',' ')}}, /* Brunei -> Malay */
+ {"kxu", {HB_TAG('K','U','I',' ')}}, /* Kui (India) */
+ {"ky", {HB_TAG('K','I','R',' ')}}, /* Kirghiz (Kyrgyz) */
+ {"kyu", {HB_TAG('K','Y','U',' ')}}, /* Western Kayah */
+ {"la", {HB_TAG('L','A','T',' ')}}, /* Latin */
+ {"lad", {HB_TAG('J','U','D',' ')}}, /* Ladino */
+ {"lb", {HB_TAG('L','T','Z',' ')}}, /* Luxembourgish */
+ {"lbe", {HB_TAG('L','A','K',' ')}}, /* Lak */
+ {"lbj", {HB_TAG('L','D','K',' ')}}, /* Ladakhi */
+ {"lbl", {HB_TAG('B','I','K',' ')}}, /* Libon Bikol -> Bikol */
+ {"lce", {HB_TAG('M','L','Y',' ')}}, /* Loncong -> Malay */
+ {"lcf", {HB_TAG('M','L','Y',' ')}}, /* Lubu -> Malay */
+ {"ldi", {HB_TAG('K','O','N','0')}}, /* Laari -> Kongo */
+ {"lez", {HB_TAG('L','E','Z',' ')}}, /* Lezghian -> Lezgi */
+ {"lg", {HB_TAG('L','U','G',' ')}}, /* Ganda */
+ {"li", {HB_TAG('L','I','M',' ')}}, /* Limburgish */
+ {"lif", {HB_TAG('L','M','B',' ')}}, /* Limbu */
+ {"lij", {HB_TAG('L','I','J',' ')}}, /* Ligurian */
+ {"lis", {HB_TAG('L','I','S',' ')}}, /* Lisu */
+ {"liw", {HB_TAG('M','L','Y',' ')}}, /* Col -> Malay */
+ {"ljp", {HB_TAG('L','J','P',' ')}}, /* Lampung Api -> Lampung */
+ {"lkb", {HB_TAG('L','U','H',' ')}}, /* Kabras -> Luyia */
+ {"lki", {HB_TAG('L','K','I',' ')}}, /* Laki */
+ {"lko", {HB_TAG('L','U','H',' ')}}, /* Khayo -> Luyia */
+ {"lks", {HB_TAG('L','U','H',' ')}}, /* Kisa -> Luyia */
+ {"lld", {HB_TAG('L','A','D',' ')}}, /* Ladin */
+ {"lmn", {HB_TAG('L','A','M',' ')}}, /* Lambadi -> Lambani */
+ {"lmo", {HB_TAG('L','M','O',' ')}}, /* Lombard */
+ {"ln", {HB_TAG('L','I','N',' ')}}, /* Lingala */
+ {"lo", {HB_TAG('L','A','O',' ')}}, /* Lao */
+ {"lom", {HB_TAG('L','O','M',' ')}}, /* Loma (Liberia) */
+ {"lrc", {HB_TAG('L','R','C',' ')}}, /* Northern Luri -> Luri */
+ {"lri", {HB_TAG('L','U','H',' ')}}, /* Marachi -> Luyia */
+ {"lrm", {HB_TAG('L','U','H',' ')}}, /* Marama -> Luyia */
+ {"lsm", {HB_TAG('L','U','H',' ')}}, /* Saamia -> Luyia */
+ {"lt", {HB_TAG('L','T','H',' ')}}, /* Lithuanian */
+ {"ltg", {HB_TAG('L','V','I',' ')}}, /* Latgalian -> Latvian */
+ {"lto", {HB_TAG('L','U','H',' ')}}, /* Tsotso -> Luyia */
+ {"lts", {HB_TAG('L','U','H',' ')}}, /* Tachoni -> Luyia */
+ {"lu", {HB_TAG('L','U','B',' ')}}, /* Luba-Katanga */
+ {"lua", {HB_TAG('L','U','A',' ')}}, /* Luba-Lulua */
+ {"luo", {HB_TAG('L','U','O',' ')}}, /* Luo (Kenya and Tanzania) */
+ {"lus", {HB_TAG('M','I','Z',' ')}}, /* Lushai -> Mizo */
+ {"luy", {HB_TAG('L','U','H',' ')}}, /* Luyia [macrolanguage] */
+ {"luz", {HB_TAG('L','R','C',' ')}}, /* Southern Luri -> Luri */
+ {"lv", {HB_TAG('L','V','I',' ')}}, /* Latvian [macrolanguage] */
+ {"lvs", {HB_TAG('L','V','I',' ')}}, /* Standard Latvian -> Latvian */
+ {"lwg", {HB_TAG('L','U','H',' ')}}, /* Wanga -> Luyia */
+ {"lzh", {HB_TAG('Z','H','T',' ')}}, /* Literary Chinese -> Chinese Traditional */
+ {"lzz", {HB_TAG('L','A','Z',' ')}}, /* Laz */
+ {"mad", {HB_TAG('M','A','D',' ')}}, /* Madurese -> Madura */
+ {"mag", {HB_TAG('M','A','G',' ')}}, /* Magahi */
+ {"mai", {HB_TAG('M','T','H',' ')}}, /* Maithili */
+ {"mak", {HB_TAG('M','K','R',' ')}}, /* Makasar */
+ {"mam", {HB_TAG('M','A','M',' ')}}, /* Mam */
+ {"man", {HB_TAG('M','N','K',' ')}}, /* Mandingo [macrolanguage] -> Maninka */
+ {"max", {HB_TAG('M','L','Y',' ')}}, /* North Moluccan Malay -> Malay */
+ {"mbo", {HB_TAG('M','B','O',' ')}}, /* Mbo (Cameroon) */
+ {"mct", {HB_TAG('B','T','I',' ')}}, /* Mengisa -> Beti */
+ {"mdf", {HB_TAG('M','O','K',' ')}}, /* Moksha */
+ {"mdr", {HB_TAG('M','D','R',' ')}}, /* Mandar */
+ {"mdy", {HB_TAG('M','L','E',' ')}}, /* Male (Ethiopia) */
+ {"men", {HB_TAG('M','D','E',' ')}}, /* Mende (Sierra Leone) */
+ {"meo", {HB_TAG('M','L','Y',' ')}}, /* Kedah Malay -> Malay */
+ {"mer", {HB_TAG('M','E','R',' ')}}, /* Meru */
+ {"mfa", {HB_TAG('M','F','A',' ')}}, /* Pattani Malay */
+ {"mfb", {HB_TAG('M','L','Y',' ')}}, /* Bangka -> Malay */
+ {"mfe", {HB_TAG('M','F','E',' ')}}, /* Morisyen */
+ {"mg", {HB_TAG('M','L','G',' ')}}, /* Malagasy [macrolanguage] */
+ {"mh", {HB_TAG('M','A','H',' ')}}, /* Marshallese */
+ {"mhr", {HB_TAG('L','M','A',' ')}}, /* Eastern Mari -> Low Mari */
+ {"mhv", {HB_TAG('A','R','K',' ')}}, /* Arakanese (retired code) -> Rakhine */
+ {"mi", {HB_TAG('M','R','I',' ')}}, /* Maori */
+ {"min", {HB_TAG('M','I','N',' ')}}, /* Minangkabau */
+ {"mk", {HB_TAG('M','K','D',' ')}}, /* Macedonian */
+ {"mku", {HB_TAG('M','N','K',' ')}}, /* Konyanka Maninka -> Maninka */
+ {"mkw", {HB_TAG('M','K','W',' ')}}, /* Kituba (Congo) */
+ {"ml", {HB_TAG('M','A','L',' '), /* Malayalam -> Malayalam Traditional */
+ HB_TAG('M','L','R',' ')}}, /* Malayalam -> Malayalam Reformed */
+ {"mlq", {HB_TAG('M','L','N',' '), /* Western Maninkakan -> Malinke */
+ HB_TAG('M','N','K',' ')}}, /* Western Maninkakan -> Maninka */
+ {"mmr", {HB_TAG('H','M','N',' ')}}, /* Western Xiangxi Miao -> Hmong */
+ {"mn", {HB_TAG('M','N','G',' ')}}, /* Mongolian [macrolanguage] */
+ {"mnc", {HB_TAG('M','C','H',' ')}}, /* Manchu */
+ {"mni", {HB_TAG('M','N','I',' ')}}, /* Manipuri */
+ {"mnk", {HB_TAG('M','N','D',' '), /* Mandinka */
+ HB_TAG('M','N','K',' ')}}, /* Mandinka -> Maninka */
+ {"mnp", {HB_TAG('Z','H','S',' ')}}, /* Min Bei Chinese -> Chinese Simplified */
+ {"mns", {HB_TAG('M','A','N',' ')}}, /* Mansi */
+ {"mnw", {HB_TAG('M','O','N',' ')}}, /* Mon */
+ {"mo", {HB_TAG('M','O','L',' ')}}, /* Moldavian (retired code) */
+ {"moh", {HB_TAG('M','O','H',' ')}}, /* Mohawk */
+ {"mos", {HB_TAG('M','O','S',' ')}}, /* Mossi */
+ {"mpe", {HB_TAG('M','A','J',' ')}}, /* Majang */
+ {"mqg", {HB_TAG('M','L','Y',' ')}}, /* Kota Bangun Kutai Malay -> Malay */
+ {"mr", {HB_TAG('M','A','R',' ')}}, /* Marathi */
+ {"mrh", {HB_TAG('Q','I','N',' ')}}, /* Mara Chin -> Chin */
+ {"mrj", {HB_TAG('H','M','A',' ')}}, /* Western Mari -> High Mari */
+ {"ms", {HB_TAG('M','L','Y',' ')}}, /* Malay [macrolanguage] */
+ {"msc", {HB_TAG('M','N','K',' ')}}, /* Sankaran Maninka -> Maninka */
+ {"msh", {HB_TAG('M','L','G',' ')}}, /* Masikoro Malagasy -> Malagasy */
+ {"msi", {HB_TAG('M','L','Y',' ')}}, /* Sabah Malay -> Malay */
+ {"mt", {HB_TAG('M','T','S',' ')}}, /* Maltese */
+ {"mtr", {HB_TAG('M','A','W',' ')}}, /* Mewari -> Marwari */
+ {"mui", {HB_TAG('M','L','Y',' ')}}, /* Musi -> Malay */
+ {"mup", {HB_TAG('R','A','J',' ')}}, /* Malvi -> Rajasthani */
+ {"muq", {HB_TAG('H','M','N',' ')}}, /* Eastern Xiangxi Miao -> Hmong */
+ {"mus", {HB_TAG('M','U','S',' ')}}, /* Creek -> Muscogee */
+ {"mvb", {HB_TAG('A','T','H',' ')}}, /* Mattole -> Athapaskan */
+ {"mve", {HB_TAG('M','A','W',' ')}}, /* Marwari (Pakistan) */
+ {"mvf", {HB_TAG('M','N','G',' ')}}, /* Peripheral Mongolian -> Mongolian */
+ {"mwk", {HB_TAG('M','N','K',' ')}}, /* Kita Maninkakan -> Maninka */
+ {"mwl", {HB_TAG('M','W','L',' ')}}, /* Mirandese */
+ {"mwr", {HB_TAG('M','A','W',' ')}}, /* Marwari [macrolanguage] */
+ {"mww", {HB_TAG('M','W','W',' ')}}, /* Hmong Daw */
+ {"my", {HB_TAG('B','R','M',' ')}}, /* Burmese */
+ {"mym", {HB_TAG('M','E','N',' ')}}, /* Me'en */
+ {"myn", {HB_TAG('M','Y','N',' ')}}, /* Mayan [family] */
+ {"myq", {HB_TAG('M','N','K',' ')}}, /* Forest Maninka (retired code) -> Maninka */
+ {"myv", {HB_TAG('E','R','Z',' ')}}, /* Erzya */
+ {"mzn", {HB_TAG('M','Z','N',' ')}}, /* Mazanderani */
+ {"na", {HB_TAG('N','A','U',' ')}}, /* Nauru -> Nauruan */
+ {"nag", {HB_TAG('N','A','G',' ')}}, /* Naga Pidgin -> Naga-Assamese */
+ {"nah", {HB_TAG('N','A','H',' ')}}, /* Nahuatl [family] */
+ {"nan", {HB_TAG('Z','H','S',' ')}}, /* Min Nan Chinese -> Chinese Simplified */
+ {"nap", {HB_TAG('N','A','P',' ')}}, /* Neapolitan */
+ {"nb", {HB_TAG('N','O','R',' ')}}, /* Norwegian Bokmål -> Norwegian */
+ {"nd", {HB_TAG('N','D','B',' ')}}, /* North Ndebele -> Ndebele */
+ {"ndc", {HB_TAG('N','D','C',' ')}}, /* Ndau */
+ {"nds", {HB_TAG('N','D','S',' ')}}, /* Low Saxon */
+ {"ne", {HB_TAG('N','E','P',' ')}}, /* Nepali [macrolanguage] */
+ {"new", {HB_TAG('N','E','W',' ')}}, /* Newari */
+ {"ng", {HB_TAG('N','D','G',' ')}}, /* Ndonga */
+ {"nga", {HB_TAG('N','G','A',' ')}}, /* Ngbaka */
+ {"ngl", {HB_TAG('L','M','W',' ')}}, /* Lomwe */
+ {"ngo", {HB_TAG('S','X','T',' ')}}, /* Ngoni -> Sutu */
+ {"nhd", {HB_TAG('G','U','A',' ')}}, /* Chiripá -> Guarani */
+ {"niq", {HB_TAG('K','A','L',' ')}}, /* Nandi -> Kalenjin */
+ {"niu", {HB_TAG('N','I','U',' ')}}, /* Niuean */
+ {"niv", {HB_TAG('G','I','L',' ')}}, /* Gilyak */
+ {"njz", {HB_TAG('N','I','S',' ')}}, /* Nyishi -> Nisi */
+ {"nl", {HB_TAG('N','L','D',' ')}}, /* Dutch */
+ {"nle", {HB_TAG('L','U','H',' ')}}, /* East Nyala -> Luyia */
+ {"nn", {HB_TAG('N','Y','N',' ')}}, /* Norwegian Nynorsk (Nynorsk, Norwegian) */
+ {"no", {HB_TAG('N','O','R',' ')}}, /* Norwegian [macrolanguage] */
+ {"nod", {HB_TAG('N','T','A',' ')}}, /* Northern Thai -> Northern Tai */
+ {"noe", {HB_TAG('N','O','E',' ')}}, /* Nimadi */
+ {"nog", {HB_TAG('N','O','G',' ')}}, /* Nogai */
+ {"nov", {HB_TAG('N','O','V',' ')}}, /* Novial */
+ {"npi", {HB_TAG('N','E','P',' ')}}, /* Nepali */
+ {"nqo", {HB_TAG('N','K','O',' ')}}, /* N'Ko */
+ {"nr", {HB_TAG('N','D','B',' ')}}, /* South Ndebele -> Ndebele */
+ {"nsk", {HB_TAG('N','A','S',' ')}}, /* Naskapi */
+ {"nso", {HB_TAG('N','S','O',' ')}}, /* Pedi -> Sotho, Northern */
+ {"nv", {HB_TAG('N','A','V',' '), /* Navajo */
+ HB_TAG('A','T','H',' ')}}, /* Navajo -> Athapaskan */
+ {"ny", {HB_TAG('C','H','I',' ')}}, /* Chichewa (Chewa, Nyanja) */
+ {"nyd", {HB_TAG('L','U','H',' ')}}, /* Nyore -> Luyia */
+ {"nym", {HB_TAG('N','Y','M',' ')}}, /* Nyamwezi */
+ {"nyn", {HB_TAG('N','K','L',' ')}}, /* Nyankole */
+ {"nza", {HB_TAG('N','Z','A',' ')}}, /* Tigon Mbembe -> Mbembe Tigon */
+ {"oc", {HB_TAG('O','C','I',' ')}}, /* Occitan (post 1500) */
+ {"oj", {HB_TAG('O','J','B',' ')}}, /* Ojibwa [macrolanguage] -> Ojibway */
+ {"ojb", {HB_TAG('O','J','B',' ')}}, /* Northwestern Ojibwa -> Ojibway */
+ {"ojc", {HB_TAG('O','J','B',' ')}}, /* Central Ojibwa -> Ojibway */
+ {"ojg", {HB_TAG('O','J','B',' ')}}, /* Eastern Ojibwa -> Ojibway */
+ {"ojs", {HB_TAG('O','C','R',' ')}}, /* Severn Ojibwa -> Oji-Cree */
+ {"ojw", {HB_TAG('O','J','B',' ')}}, /* Western Ojibwa -> Ojibway */
+ {"oki", {HB_TAG('K','A','L',' ')}}, /* Okiek -> Kalenjin */
+ {"okm", {HB_TAG('K','O','H',' ')}}, /* Middle Korean (10th-16th cent.) -> Korean Old Hangul */
+ {"om", {HB_TAG('O','R','O',' ')}}, /* Oromo [macrolanguage] */
+ {"or", {HB_TAG('O','R','I',' ')}}, /* Odia (formerly Oriya) [macrolanguage] */
+ {"orc", {HB_TAG('O','R','O',' ')}}, /* Orma -> Oromo */
+ {"orn", {HB_TAG('M','L','Y',' ')}}, /* Orang Kanaq -> Malay */
+ {"ors", {HB_TAG('M','L','Y',' ')}}, /* Orang Seletar -> Malay */
+ {"ory", {HB_TAG('O','R','I',' ')}}, /* Odia (formerly Oriya) */
+ {"os", {HB_TAG('O','S','S',' ')}}, /* Ossetian */
+ {"otw", {HB_TAG('O','J','B',' ')}}, /* Ottawa -> Ojibway */
+ {"pa", {HB_TAG('P','A','N',' ')}}, /* Punjabi */
+ {"pag", {HB_TAG('P','A','G',' ')}}, /* Pangasinan */
+ {"pam", {HB_TAG('P','A','M',' ')}}, /* Pampanga -> Pampangan */
+ {"pap", {HB_TAG('P','A','P','0')}}, /* Papiamento -> Papiamentu */
+ {"pau", {HB_TAG('P','A','U',' ')}}, /* Palauan */
+ {"pbt", {HB_TAG('P','A','S',' ')}}, /* Southern Pashto -> Pashto */
+ {"pbu", {HB_TAG('P','A','S',' ')}}, /* Northern Pashto -> Pashto */
+ {"pcc", {HB_TAG('P','C','C',' ')}}, /* Bouyei */
+ {"pcd", {HB_TAG('P','C','D',' ')}}, /* Picard */
+ {"pce", {HB_TAG('P','L','G',' ')}}, /* Ruching Palaung -> Palaung */
+ {"pck", {HB_TAG('Q','I','N',' ')}}, /* Paite Chin -> Chin */
+ {"pdc", {HB_TAG('P','D','C',' ')}}, /* Pennsylvania German */
+ {"pel", {HB_TAG('M','L','Y',' ')}}, /* Pekal -> Malay */
+ {"pes", {HB_TAG('F','A','R',' ')}}, /* Iranian Persian -> Persian */
+ {"pga", {HB_TAG('A','R','A',' ')}}, /* Sudanese Creole Arabic -> Arabic */
+ {"phk", {HB_TAG('P','H','K',' ')}}, /* Phake */
+ {"pi", {HB_TAG('P','A','L',' ')}}, /* Pali */
+ {"pih", {HB_TAG('P','I','H',' ')}}, /* Pitcairn-Norfolk -> Norfolk */
+ {"pko", {HB_TAG('K','A','L',' ')}}, /* Pökoot -> Kalenjin */
+ {"pl", {HB_TAG('P','L','K',' ')}}, /* Polish */
+ {"pll", {HB_TAG('P','L','G',' ')}}, /* Shwe Palaung -> Palaung */
+ {"plp", {HB_TAG('P','A','P',' ')}}, /* Palpa */
+ {"plt", {HB_TAG('M','L','G',' ')}}, /* Plateau Malagasy -> Malagasy */
+ {"pms", {HB_TAG('P','M','S',' ')}}, /* Piemontese */
+ {"pnb", {HB_TAG('P','N','B',' ')}}, /* Western Panjabi */
+ {"poh", {HB_TAG('P','O','H',' ')}}, /* Poqomchi' -> Pocomchi */
+ {"pon", {HB_TAG('P','O','N',' ')}}, /* Pohnpeian */
+ {"ppa", {HB_TAG('B','A','G',' ')}}, /* Pao (retired code) -> Baghelkhandi */
+ {"pro", {HB_TAG('P','R','O',' ')}}, /* Old Provençal (to 1500) -> Provençal / Old Provençal */
+ {"prs", {HB_TAG('D','R','I',' ')}}, /* Dari */
+ {"ps", {HB_TAG('P','A','S',' ')}}, /* Pashto [macrolanguage] */
+ {"pse", {HB_TAG('M','L','Y',' ')}}, /* Central Malay -> Malay */
+ {"pst", {HB_TAG('P','A','S',' ')}}, /* Central Pashto -> Pashto */
+ {"pt", {HB_TAG('P','T','G',' ')}}, /* Portuguese */
+ {"pwo", {HB_TAG('P','W','O',' ')}}, /* Pwo Western Karen -> Western Pwo Karen */
+ {"qu", {HB_TAG('Q','U','Z',' ')}}, /* Quechua [macrolanguage] */
+ {"qub", {HB_TAG('Q','W','H',' ')}}, /* Huallaga Huánuco Quechua -> Quechua (Peru) */
+ {"quc", {HB_TAG('Q','U','C',' ')}}, /* K’iche’ */
+ {"qud", {HB_TAG('Q','V','I',' ')}}, /* Calderón Highland Quichua -> Quechua (Ecuador) */
+ {"quf", {HB_TAG('Q','U','Z',' ')}}, /* Lambayeque Quechua -> Quechua */
+ {"qug", {HB_TAG('Q','V','I',' ')}}, /* Chimborazo Highland Quichua -> Quechua (Ecuador) */
+ {"quh", {HB_TAG('Q','U','H',' ')}}, /* South Bolivian Quechua -> Quechua (Bolivia) */
+ {"quk", {HB_TAG('Q','U','Z',' ')}}, /* Chachapoyas Quechua -> Quechua */
+ {"qul", {HB_TAG('Q','U','Z',' ')}}, /* North Bolivian Quechua -> Quechua */
+ {"qup", {HB_TAG('Q','V','I',' ')}}, /* Southern Pastaza Quechua -> Quechua (Ecuador) */
+ {"qur", {HB_TAG('Q','W','H',' ')}}, /* Yanahuanca Pasco Quechua -> Quechua (Peru) */
+ {"qus", {HB_TAG('Q','U','H',' ')}}, /* Santiago del Estero Quichua -> Quechua (Bolivia) */
+ {"quw", {HB_TAG('Q','V','I',' ')}}, /* Tena Lowland Quichua -> Quechua (Ecuador) */
+ {"qux", {HB_TAG('Q','W','H',' ')}}, /* Yauyos Quechua -> Quechua (Peru) */
+ {"quy", {HB_TAG('Q','U','Z',' ')}}, /* Ayacucho Quechua -> Quechua */
+ {"quz", {HB_TAG('Q','U','Z',' ')}}, /* Cusco Quechua -> Quechua */
+ {"qva", {HB_TAG('Q','W','H',' ')}}, /* Ambo-Pasco Quechua -> Quechua (Peru) */
+ {"qvc", {HB_TAG('Q','U','Z',' ')}}, /* Cajamarca Quechua -> Quechua */
+ {"qve", {HB_TAG('Q','U','Z',' ')}}, /* Eastern Apurímac Quechua -> Quechua */
+ {"qvh", {HB_TAG('Q','W','H',' ')}}, /* Huamalíes-Dos de Mayo Huánuco Quechua -> Quechua (Peru) */
+ {"qvi", {HB_TAG('Q','V','I',' ')}}, /* Imbabura Highland Quichua -> Quechua (Ecuador) */
+ {"qvj", {HB_TAG('Q','V','I',' ')}}, /* Loja Highland Quichua -> Quechua (Ecuador) */
+ {"qvl", {HB_TAG('Q','W','H',' ')}}, /* Cajatambo North Lima Quechua -> Quechua (Peru) */
+ {"qvm", {HB_TAG('Q','W','H',' ')}}, /* Margos-Yarowilca-Lauricocha Quechua -> Quechua (Peru) */
+ {"qvn", {HB_TAG('Q','W','H',' ')}}, /* North Junín Quechua -> Quechua (Peru) */
+ {"qvo", {HB_TAG('Q','V','I',' ')}}, /* Napo Lowland Quechua -> Quechua (Ecuador) */
+ {"qvp", {HB_TAG('Q','W','H',' ')}}, /* Pacaraos Quechua -> Quechua (Peru) */
+ {"qvs", {HB_TAG('Q','U','Z',' ')}}, /* San Martín Quechua -> Quechua */
+ {"qvw", {HB_TAG('Q','W','H',' ')}}, /* Huaylla Wanca Quechua -> Quechua (Peru) */
+ {"qvz", {HB_TAG('Q','V','I',' ')}}, /* Northern Pastaza Quichua -> Quechua (Ecuador) */
+ {"qwa", {HB_TAG('Q','W','H',' ')}}, /* Corongo Ancash Quechua -> Quechua (Peru) */
+ {"qwc", {HB_TAG('Q','U','Z',' ')}}, /* Classical Quechua -> Quechua */
+ {"qwh", {HB_TAG('Q','W','H',' ')}}, /* Huaylas Ancash Quechua -> Quechua (Peru) */
+ {"qws", {HB_TAG('Q','W','H',' ')}}, /* Sihuas Ancash Quechua -> Quechua (Peru) */
+ {"qxa", {HB_TAG('Q','W','H',' ')}}, /* Chiquián Ancash Quechua -> Quechua (Peru) */
+ {"qxc", {HB_TAG('Q','W','H',' ')}}, /* Chincha Quechua -> Quechua (Peru) */
+ {"qxh", {HB_TAG('Q','W','H',' ')}}, /* Panao Huánuco Quechua -> Quechua (Peru) */
+ {"qxl", {HB_TAG('Q','V','I',' ')}}, /* Salasaca Highland Quichua -> Quechua (Ecuador) */
+ {"qxn", {HB_TAG('Q','W','H',' ')}}, /* Northern Conchucos Ancash Quechua -> Quechua (Peru) */
+ {"qxo", {HB_TAG('Q','W','H',' ')}}, /* Southern Conchucos Ancash Quechua -> Quechua (Peru) */
+ {"qxp", {HB_TAG('Q','U','Z',' ')}}, /* Puno Quechua -> Quechua */
+ {"qxr", {HB_TAG('Q','V','I',' ')}}, /* Cañar Highland Quichua -> Quechua (Ecuador) */
+ {"qxt", {HB_TAG('Q','W','H',' ')}}, /* Santa Ana de Tusi Pasco Quechua -> Quechua (Peru) */
+ {"qxu", {HB_TAG('Q','U','Z',' ')}}, /* Arequipa-La Unión Quechua -> Quechua */
+ {"qxw", {HB_TAG('Q','W','H',' ')}}, /* Jauja Wanca Quechua -> Quechua (Peru) */
+ {"rag", {HB_TAG('L','U','H',' ')}}, /* Logooli -> Luyia */
+ {"raj", {HB_TAG('R','A','J',' ')}}, /* Rajasthani [macrolanguage] */
+ {"rar", {HB_TAG('R','A','R',' ')}}, /* Rarotongan */
+ {"rbb", {HB_TAG('P','L','G',' ')}}, /* Rumai Palaung -> Palaung */
+ {"rbl", {HB_TAG('B','I','K',' ')}}, /* Miraya Bikol -> Bikol */
+ {"rej", {HB_TAG('R','E','J',' ')}}, /* Rejang */
+ {"ria", {HB_TAG('R','I','A',' ')}}, /* Riang (India) */
+ {"rif", {HB_TAG('R','I','F',' ')}}, /* Tarifit */
+ {"rit", {HB_TAG('R','I','T',' ')}}, /* Ritarungo */
+ {"rki", {HB_TAG('A','R','K',' ')}}, /* Rakhine */
+ {"rkw", {HB_TAG('R','K','W',' ')}}, /* Arakwal */
+ {"rm", {HB_TAG('R','M','S',' ')}}, /* Romansh */
+ {"rmc", {HB_TAG('R','O','Y',' ')}}, /* Carpathian Romani -> Romany */
+ {"rmf", {HB_TAG('R','O','Y',' ')}}, /* Kalo Finnish Romani -> Romany */
+ {"rml", {HB_TAG('R','O','Y',' ')}}, /* Baltic Romani -> Romany */
+ {"rmn", {HB_TAG('R','O','Y',' ')}}, /* Balkan Romani -> Romany */
+ {"rmo", {HB_TAG('R','O','Y',' ')}}, /* Sinte Romani -> Romany */
+ {"rmw", {HB_TAG('R','O','Y',' ')}}, /* Welsh Romani -> Romany */
+ {"rmy", {HB_TAG('R','M','Y',' ')}}, /* Vlax Romani */
+ {"rmz", {HB_TAG('A','R','K',' ')}}, /* Marma -> Rakhine */
+ {"rn", {HB_TAG('R','U','N',' ')}}, /* Rundi */
+ {"rnl", {HB_TAG('H','A','L',' ')}}, /* Ranglong -> Halam (Falam Chin) */
+ {"ro", {HB_TAG('R','O','M',' ')}}, /* Romanian */
+ {"rom", {HB_TAG('R','O','Y',' ')}}, /* Romany [macrolanguage] */
+ {"rtm", {HB_TAG('R','T','M',' ')}}, /* Rotuman */
+ {"ru", {HB_TAG('R','U','S',' ')}}, /* Russian */
+ {"rue", {HB_TAG('R','S','Y',' ')}}, /* Rusyn */
+ {"rup", {HB_TAG('R','U','P',' ')}}, /* Aromanian */
+ {"rw", {HB_TAG('R','U','A',' ')}}, /* Kinyarwanda */
+ {"rwr", {HB_TAG('M','A','W',' ')}}, /* Marwari (India) */
+ {"sa", {HB_TAG('S','A','N',' ')}}, /* Sanskrit */
+ {"sah", {HB_TAG('Y','A','K',' ')}}, /* Yakut -> Sakha */
+ {"sam", {HB_TAG('P','A','A',' ')}}, /* Samaritan Aramaic -> Palestinian Aramaic */
+ {"sas", {HB_TAG('S','A','S',' ')}}, /* Sasak */
+ {"sat", {HB_TAG('S','A','T',' ')}}, /* Santali */
+ {"sc", {HB_TAG('S','R','D',' ')}}, /* Sardinian [macrolanguage] */
+ {"sck", {HB_TAG('S','A','D',' ')}}, /* Sadri */
+ {"scn", {HB_TAG('S','C','N',' ')}}, /* Sicilian */
+ {"sco", {HB_TAG('S','C','O',' ')}}, /* Scots */
+ {"scs", {HB_TAG('S','C','S',' '), /* North Slavey */
+ HB_TAG('S','L','A',' '), /* North Slavey -> Slavey */
+ HB_TAG('A','T','H',' ')}}, /* North Slavey -> Athapaskan */
+ {"sd", {HB_TAG('S','N','D',' ')}}, /* Sindhi */
+ {"sdc", {HB_TAG('S','R','D',' ')}}, /* Sassarese Sardinian -> Sardinian */
+ {"sdh", {HB_TAG('K','U','R',' ')}}, /* Southern Kurdish -> Kurdish */
+ {"sdn", {HB_TAG('S','R','D',' ')}}, /* Gallurese Sardinian -> Sardinian */
+ {"se", {HB_TAG('N','S','M',' ')}}, /* Northern Sami */
+ {"seh", {HB_TAG('S','N','A',' ')}}, /* Sena */
+ {"sek", {HB_TAG('A','T','H',' ')}}, /* Sekani -> Athapaskan */
+ {"sel", {HB_TAG('S','E','L',' ')}}, /* Selkup */
+ {"sez", {HB_TAG('Q','I','N',' ')}}, /* Senthang Chin -> Chin */
+ {"sfm", {HB_TAG('H','M','N',' ')}}, /* Small Flowery Miao -> Hmong */
+ {"sg", {HB_TAG('S','G','O',' ')}}, /* Sango */
+ {"sga", {HB_TAG('S','G','A',' ')}}, /* Old Irish (to 900) */
+ {"sgc", {HB_TAG('K','A','L',' ')}}, /* Kipsigis -> Kalenjin */
+ {"sgs", {HB_TAG('S','G','S',' ')}}, /* Samogitian */
+ {"sgw", {HB_TAG('C','H','G',' '), /* Sebat Bet Gurage -> Chaha Gurage */
+ HB_TAG('S','G','W',' ')}}, /* Sebat Bet Gurage -> Chaha Gurage (SIL fonts) */
+ {"shi", {HB_TAG('S','H','I',' ')}}, /* Tachelhit */
+ {"shn", {HB_TAG('S','H','N',' ')}}, /* Shan */
+ {"shu", {HB_TAG('A','R','A',' ')}}, /* Chadian Arabic -> Arabic */
+ {"si", {HB_TAG('S','N','H',' ')}}, /* Sinhala (Sinhalese) */
+ {"sid", {HB_TAG('S','I','D',' ')}}, /* Sidamo */
+ {"sjd", {HB_TAG('K','S','M',' ')}}, /* Kildin Sami */
+ {"sjo", {HB_TAG('S','I','B',' ')}}, /* Xibe -> Sibe */
+ {"sk", {HB_TAG('S','K','Y',' ')}}, /* Slovak */
+ {"skg", {HB_TAG('M','L','G',' ')}}, /* Sakalava Malagasy -> Malagasy */
+ {"skr", {HB_TAG('S','R','K',' ')}}, /* Saraiki */
+ {"sl", {HB_TAG('S','L','V',' ')}}, /* Slovenian */
+ {"sm", {HB_TAG('S','M','O',' ')}}, /* Samoan */
+ {"sma", {HB_TAG('S','S','M',' ')}}, /* Southern Sami */
+ {"smj", {HB_TAG('L','S','M',' ')}}, /* Lule Sami */
+ {"smn", {HB_TAG('I','S','M',' ')}}, /* Inari Sami */
+ {"sms", {HB_TAG('S','K','S',' ')}}, /* Skolt Sami */
+ {"sn", {HB_TAG('S','N','A','0')}}, /* Shona */
+ {"snk", {HB_TAG('S','N','K',' ')}}, /* Soninke */
+ {"so", {HB_TAG('S','M','L',' ')}}, /* Somali */
+ {"sop", {HB_TAG('S','O','P',' ')}}, /* Songe */
+ {"spv", {HB_TAG('O','R','I',' ')}}, /* Sambalpuri -> Odia (formerly Oriya) */
+ {"spy", {HB_TAG('K','A','L',' ')}}, /* Sabaot -> Kalenjin */
+ {"sq", {HB_TAG('S','Q','I',' ')}}, /* Albanian [macrolanguage] */
+ {"sr", {HB_TAG('S','R','B',' ')}}, /* Serbian */
+ {"src", {HB_TAG('S','R','D',' ')}}, /* Logudorese Sardinian -> Sardinian */
+ {"sro", {HB_TAG('S','R','D',' ')}}, /* Campidanese Sardinian -> Sardinian */
+ {"srr", {HB_TAG('S','R','R',' ')}}, /* Serer */
+ {"srs", {HB_TAG('A','T','H',' ')}}, /* Sarsi -> Athapaskan */
+ {"ss", {HB_TAG('S','W','Z',' ')}}, /* Swati */
+ {"ssh", {HB_TAG('A','R','A',' ')}}, /* Shihhi Arabic -> Arabic */
+ {"st", {HB_TAG('S','O','T',' ')}}, /* Southern Sotho -> Sotho, Southern */
+ {"stq", {HB_TAG('S','T','Q',' ')}}, /* Saterfriesisch -> Saterland Frisian */
+ {"stv", {HB_TAG('S','I','G',' ')}}, /* Silt'e -> Silte Gurage */
+ {"su", {HB_TAG('S','U','N',' ')}}, /* Sundanese */
+ {"suk", {HB_TAG('S','U','K',' ')}}, /* Sukuma */
+ {"suq", {HB_TAG('S','U','R',' ')}}, /* Suri */
+ {"sv", {HB_TAG('S','V','E',' ')}}, /* Swedish */
+ {"sva", {HB_TAG('S','V','A',' ')}}, /* Svan */
+ {"sw", {HB_TAG('S','W','K',' ')}}, /* Swahili [macrolanguage] */
+ {"swb", {HB_TAG('C','M','R',' ')}}, /* Maore Comorian -> Comorian */
+ {"swc", {HB_TAG('S','W','K',' ')}}, /* Congo Swahili -> Swahili */
+ {"swh", {HB_TAG('S','W','K',' ')}}, /* Swahili */
+ {"swv", {HB_TAG('M','A','W',' ')}}, /* Shekhawati -> Marwari */
+ {"sxu", {HB_TAG('S','X','U',' ')}}, /* Upper Saxon */
+ {"syc", {HB_TAG('S','Y','R',' ')}}, /* Classical Syriac -> Syriac */
+ {"syl", {HB_TAG('S','Y','L',' ')}}, /* Sylheti */
+ {"syr", {HB_TAG('S','Y','R',' ')}}, /* Syriac [macrolanguage] */
+ {"szl", {HB_TAG('S','Z','L',' ')}}, /* Silesian */
+ {"ta", {HB_TAG('T','A','M',' ')}}, /* Tamil */
+ {"taa", {HB_TAG('A','T','H',' ')}}, /* Lower Tanana -> Athapaskan */
+ {"tab", {HB_TAG('T','A','B',' ')}}, /* Tabassaran -> Tabasaran */
+ {"taq", {HB_TAG('T','M','H',' ')}}, /* Tamasheq -> Tamashek */
+ {"tau", {HB_TAG('A','T','H',' ')}}, /* Upper Tanana -> Athapaskan */
+ {"tcb", {HB_TAG('A','T','H',' ')}}, /* Tanacross -> Athapaskan */
+ {"tce", {HB_TAG('A','T','H',' ')}}, /* Southern Tutchone -> Athapaskan */
+ {"tcp", {HB_TAG('Q','I','N',' ')}}, /* Tawr Chin -> Chin */
+ {"tcy", {HB_TAG('T','U','L',' ')}}, /* Tulu -> Tumbuka */
+ {"tcz", {HB_TAG('Q','I','N',' ')}}, /* Thado Chin -> Chin */
+ {"tdd", {HB_TAG('T','D','D',' ')}}, /* Tai Nüa -> Dehong Dai */
+ {"tdx", {HB_TAG('M','L','G',' ')}}, /* Tandroy-Mahafaly Malagasy -> Malagasy */
+ {"te", {HB_TAG('T','E','L',' ')}}, /* Telugu */
+ {"tec", {HB_TAG('K','A','L',' ')}}, /* Terik -> Kalenjin */
+ {"tem", {HB_TAG('T','M','N',' ')}}, /* Timne -> Temne */
+ {"tet", {HB_TAG('T','E','T',' ')}}, /* Tetum */
+ {"tfn", {HB_TAG('A','T','H',' ')}}, /* Tanaina -> Athapaskan */
+ {"tg", {HB_TAG('T','A','J',' ')}}, /* Tajik -> Tajiki */
+ {"tgj", {HB_TAG('N','I','S',' ')}}, /* Tagin -> Nisi */
+ {"tgx", {HB_TAG('A','T','H',' ')}}, /* Tagish -> Athapaskan */
+ {"th", {HB_TAG('T','H','A',' ')}}, /* Thai */
+ {"tht", {HB_TAG('A','T','H',' ')}}, /* Tahltan -> Athapaskan */
+ {"thv", {HB_TAG('T','M','H',' ')}}, /* Tahaggart Tamahaq -> Tamashek */
+ {"thz", {HB_TAG('T','M','H',' ')}}, /* Tayart Tamajeq -> Tamashek */
+ {"ti", {HB_TAG('T','G','Y',' ')}}, /* Tigrinya */
+ {"tig", {HB_TAG('T','G','R',' ')}}, /* Tigre */
+ {"tiv", {HB_TAG('T','I','V',' ')}}, /* Tiv */
+ {"tk", {HB_TAG('T','K','M',' ')}}, /* Turkmen */
+ {"tkg", {HB_TAG('M','L','G',' ')}}, /* Tesaka Malagasy -> Malagasy */
+ {"tl", {HB_TAG('T','G','L',' ')}}, /* Tagalog */
+ {"tmh", {HB_TAG('T','M','H',' ')}}, /* Tamashek [macrolanguage] */
+ {"tmw", {HB_TAG('M','L','Y',' ')}}, /* Temuan -> Malay */
+ {"tn", {HB_TAG('T','N','A',' ')}}, /* Tswana */
+ {"tnf", {HB_TAG('D','R','I',' ')}}, /* Tangshewi (retired code) -> Dari */
+ {"to", {HB_TAG('T','G','N',' ')}}, /* Tonga (Tonga Islands) -> Tongan */
+ {"tod", {HB_TAG('T','O','D','0')}}, /* Toma */
+ {"toi", {HB_TAG('T','N','G',' ')}}, /* Tonga (Zambia) */
+ {"tol", {HB_TAG('A','T','H',' ')}}, /* Tolowa -> Athapaskan */
+ {"tpi", {HB_TAG('T','P','I',' ')}}, /* Tok Pisin */
+ {"tr", {HB_TAG('T','R','K',' ')}}, /* Turkish */
+ {"tru", {HB_TAG('T','U','A',' '), /* Turoyo -> Turoyo Aramaic */
+ HB_TAG('S','Y','R',' ')}}, /* Turoyo -> Syriac */
+ {"ts", {HB_TAG('T','S','G',' ')}}, /* Tsonga */
+ {"tsj", {HB_TAG('T','S','J',' ')}}, /* Tshangla */
+ {"tt", {HB_TAG('T','A','T',' ')}}, /* Tatar */
+ {"ttm", {HB_TAG('A','T','H',' ')}}, /* Northern Tutchone -> Athapaskan */
+ {"ttq", {HB_TAG('T','M','H',' ')}}, /* Tawallammat Tamajaq -> Tamashek */
+ {"tum", {HB_TAG('T','U','M',' ')}}, /* Tumbuka -> Tulu */
+ {"tuu", {HB_TAG('A','T','H',' ')}}, /* Tututni -> Athapaskan */
+ {"tuy", {HB_TAG('K','A','L',' ')}}, /* Tugen -> Kalenjin */
+ {"tvl", {HB_TAG('T','V','L',' ')}}, /* Tuvalu */
+ {"tw", {HB_TAG('T','W','I',' '), /* Twi */
+ HB_TAG('A','K','A',' ')}}, /* Twi -> Akan */
+ {"txc", {HB_TAG('A','T','H',' ')}}, /* Tsetsaut -> Athapaskan */
+ {"txy", {HB_TAG('M','L','G',' ')}}, /* Tanosy Malagasy -> Malagasy */
+ {"ty", {HB_TAG('T','H','T',' ')}}, /* Tahitian */
+ {"tyv", {HB_TAG('T','U','V',' ')}}, /* Tuvinian -> Tuvin */
+ {"tyz", {HB_TAG('T','Y','Z',' ')}}, /* Tày */
+ {"tzm", {HB_TAG('T','Z','M',' ')}}, /* Central Atlas Tamazight -> Tamazight */
+ {"tzo", {HB_TAG('T','Z','O',' ')}}, /* Tzotzil */
+ {"ubl", {HB_TAG('B','I','K',' ')}}, /* Buhi'non Bikol -> Bikol */
+ {"udm", {HB_TAG('U','D','M',' ')}}, /* Udmurt */
+ {"ug", {HB_TAG('U','Y','G',' ')}}, /* Uyghur */
+ {"uk", {HB_TAG('U','K','R',' ')}}, /* Ukrainian */
+ {"umb", {HB_TAG('U','M','B',' ')}}, /* Umbundu */
+ {"unr", {HB_TAG('M','U','N',' ')}}, /* Mundari */
+ {"ur", {HB_TAG('U','R','D',' ')}}, /* Urdu */
+ {"urk", {HB_TAG('M','L','Y',' ')}}, /* Urak Lawoi' -> Malay */
+ {"uz", {HB_TAG('U','Z','B',' ')}}, /* Uzbek [macrolanguage] */
+ {"uzn", {HB_TAG('U','Z','B',' ')}}, /* Northern Uzbek -> Uzbek */
+ {"uzs", {HB_TAG('U','Z','B',' ')}}, /* Southern Uzbek -> Uzbek */
+ {"ve", {HB_TAG('V','E','N',' ')}}, /* Venda */
+ {"vec", {HB_TAG('V','E','C',' ')}}, /* Venetian */
+ {"vi", {HB_TAG('V','I','T',' ')}}, /* Vietnamese */
+ {"vkk", {HB_TAG('M','L','Y',' ')}}, /* Kaur -> Malay */
+ {"vkt", {HB_TAG('M','L','Y',' ')}}, /* Tenggarong Kutai Malay -> Malay */
+ {"vls", {HB_TAG('F','L','E',' ')}}, /* Vlaams -> Dutch (Flemish) */
+ {"vmw", {HB_TAG('M','A','K',' ')}}, /* Makhuwa */
+ {"vo", {HB_TAG('V','O','L',' ')}}, /* Volapük */
+ {"vro", {HB_TAG('V','R','O',' ')}}, /* Võro */
+ {"wa", {HB_TAG('W','L','N',' ')}}, /* Walloon */
+ {"war", {HB_TAG('W','A','R',' ')}}, /* Waray (Philippines) -> Waray-Waray */
+ {"wbm", {HB_TAG('W','A',' ',' ')}}, /* Wa */
+ {"wbr", {HB_TAG('W','A','G',' ')}}, /* Wagdi */
+ {"wlc", {HB_TAG('C','M','R',' ')}}, /* Mwali Comorian -> Comorian */
+ {"wle", {HB_TAG('S','I','G',' ')}}, /* Wolane -> Silte Gurage */
+ {"wlk", {HB_TAG('A','T','H',' ')}}, /* Wailaki -> Athapaskan */
+ {"wni", {HB_TAG('C','M','R',' ')}}, /* Ndzwani Comorian -> Comorian */
+ {"wo", {HB_TAG('W','L','F',' ')}}, /* Wolof */
+ {"wry", {HB_TAG('M','A','W',' ')}}, /* Merwari -> Marwari */
+ {"wsg", {HB_TAG('G','O','N',' ')}}, /* Adilabad Gondi -> Gondi */
+ {"wtm", {HB_TAG('W','T','M',' ')}}, /* Mewati */
+ {"wuu", {HB_TAG('Z','H','S',' ')}}, /* Wu Chinese -> Chinese Simplified */
+ {"xal", {HB_TAG('K','L','M',' '), /* Kalmyk */
+ HB_TAG('T','O','D',' ')}}, /* Kalmyk -> Todo */
+ {"xan", {HB_TAG('S','E','K',' ')}}, /* Xamtanga -> Sekota */
+ {"xh", {HB_TAG('X','H','S',' ')}}, /* Xhosa */
+ {"xjb", {HB_TAG('X','J','B',' ')}}, /* Minjungbal -> Minjangbal */
+ {"xkf", {HB_TAG('X','K','F',' ')}}, /* Khengkha */
+ {"xmm", {HB_TAG('M','L','Y',' ')}}, /* Manado Malay -> Malay */
+ {"xmv", {HB_TAG('M','L','G',' ')}}, /* Antankarana Malagasy -> Malagasy */
+ {"xmw", {HB_TAG('M','L','G',' ')}}, /* Tsimihety Malagasy -> Malagasy */
+ {"xnr", {HB_TAG('D','G','R',' ')}}, /* Kangri -> Dogri */
+ {"xog", {HB_TAG('X','O','G',' ')}}, /* Soga */
+ {"xpe", {HB_TAG('X','P','E',' ')}}, /* Liberia Kpelle -> Kpelle (Liberia) */
+ {"xsl", {HB_TAG('S','S','L',' '), /* South Slavey */
+ HB_TAG('S','L','A',' '), /* South Slavey -> Slavey */
+ HB_TAG('A','T','H',' ')}}, /* South Slavey -> Athapaskan */
+ {"xst", {HB_TAG('S','I','G',' ')}}, /* Silt'e (retired code) -> Silte Gurage */
+ {"xwo", {HB_TAG('T','O','D',' ')}}, /* Written Oirat -> Todo */
+ {"yao", {HB_TAG('Y','A','O',' ')}}, /* Yao */
+ {"yap", {HB_TAG('Y','A','P',' ')}}, /* Yapese */
+ {"ybd", {HB_TAG('A','R','K',' ')}}, /* Yangbye (retired code) -> Rakhine */
+ {"ydd", {HB_TAG('J','I','I',' ')}}, /* Eastern Yiddish -> Yiddish */
+ {"yi", {HB_TAG('J','I','I',' ')}}, /* Yiddish [macrolanguage] */
+ {"yih", {HB_TAG('J','I','I',' ')}}, /* Western Yiddish -> Yiddish */
+ {"yo", {HB_TAG('Y','B','A',' ')}}, /* Yoruba */
+ {"yos", {HB_TAG('Q','I','N',' ')}}, /* Yos (retired code) -> Chin */
+ {"yrk", {HB_TAG('T','N','E',' '), /* Nenets -> Tundra Nenets */
+ HB_TAG('F','N','E',' ')}}, /* Nenets -> Forest Nenets */
+ {"yue", {HB_TAG('Z','H','H',' ')}}, /* Yue Chinese -> Chinese, Hong Kong SAR */
+ {"za", {HB_TAG('Z','H','A',' ')}}, /* Zhuang [macrolanguage] */
+ {"zch", {HB_TAG('Z','H','A',' ')}}, /* Central Hongshuihe Zhuang -> Zhuang */
+ {"zdj", {HB_TAG('C','M','R',' ')}}, /* Ngazidja Comorian -> Comorian */
+ {"zea", {HB_TAG('Z','E','A',' ')}}, /* Zeeuws -> Zealandic */
+ {"zeh", {HB_TAG('Z','H','A',' ')}}, /* Eastern Hongshuihe Zhuang -> Zhuang */
+ {"zgb", {HB_TAG('Z','H','A',' ')}}, /* Guibei Zhuang -> Zhuang */
+ {"zgh", {HB_TAG('Z','G','H',' ')}}, /* Standard Moroccan Tamazight */
+ {"zgm", {HB_TAG('Z','H','A',' ')}}, /* Minz Zhuang -> Zhuang */
+ {"zgn", {HB_TAG('Z','H','A',' ')}}, /* Guibian Zhuang -> Zhuang */
+ {"zh", {HB_TAG('Z','H','S',' ')}}, /* Chinese [macrolanguage] -> Chinese Simplified */
+ {"zhd", {HB_TAG('Z','H','A',' ')}}, /* Dai Zhuang -> Zhuang */
+ {"zhn", {HB_TAG('Z','H','A',' ')}}, /* Nong Zhuang -> Zhuang */
+ {"zlj", {HB_TAG('Z','H','A',' ')}}, /* Liujiang Zhuang -> Zhuang */
+ {"zlm", {HB_TAG('M','L','Y',' ')}}, /* Malay */
+ {"zln", {HB_TAG('Z','H','A',' ')}}, /* Lianshan Zhuang -> Zhuang */
+ {"zlq", {HB_TAG('Z','H','A',' ')}}, /* Liuqian Zhuang -> Zhuang */
+ {"zmi", {HB_TAG('M','L','Y',' ')}}, /* Negeri Sembilan Malay -> Malay */
+ {"zne", {HB_TAG('Z','N','D',' ')}}, /* Zande */
+ {"zom", {HB_TAG('Q','I','N',' ')}}, /* Zou -> Chin */
+ {"zqe", {HB_TAG('Z','H','A',' ')}}, /* Qiubei Zhuang -> Zhuang */
+ {"zsm", {HB_TAG('M','L','Y',' ')}}, /* Standard Malay -> Malay */
+ {"zu", {HB_TAG('Z','U','L',' ')}}, /* Zulu */
+ {"zum", {HB_TAG('L','R','C',' ')}}, /* Kumzari -> Luri */
+ {"zyb", {HB_TAG('Z','H','A',' ')}}, /* Yongbei Zhuang -> Zhuang */
+ {"zyg", {HB_TAG('Z','H','A',' ')}}, /* Yang Zhuang -> Zhuang */
+ {"zyj", {HB_TAG('Z','H','A',' ')}}, /* Youjiang Zhuang -> Zhuang */
+ {"zyn", {HB_TAG('Z','H','A',' ')}}, /* Yongnan Zhuang -> Zhuang */
+ {"zza", {HB_TAG('Z','Z','A',' ')}}, /* Zazaki [macrolanguage] */
+ {"zzj", {HB_TAG('Z','H','A',' ')}}, /* Zuojiang Zhuang -> Zhuang */
+};
+
+static_assert (HB_OT_MAX_TAGS_PER_LANGUAGE == 3u, "");
+
+/**
+ * hb_ot_tags_from_complex_language:
+ * @lang_str: a BCP 47 language tag to convert.
+ * @limit: a pointer to the end of the substring of @lang_str to consider for
+ * conversion.
+ * @count: maximum number of language tags to retrieve (IN) and actual number of
+ * language tags retrieved (OUT). If no tags are retrieved, it is not modified.
+ * @tags: array of size at least @language_count to store the language tag
+ * results
+ *
+ * Converts a multi-subtag BCP 47 language tag to language tags.
+ *
+ * Return value: Whether any language systems were retrieved.
+ **/
+static bool
+hb_ot_tags_from_complex_language (const char *lang_str,
+ const char *limit,
+ unsigned int *count /* IN/OUT */,
+ hb_tag_t *tags /* OUT */)
+{
+ if (subtag_matches (lang_str, limit, "-fonnapa"))
+ {
+ /* Undetermined; North American Phonetic Alphabet */
+ tags[0] = HB_TAG('A','P','P','H'); /* Phonetic transcription—Americanist conventions */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-polyton"))
+ {
+ /* Modern Greek (1453-); Polytonic Greek */
+ tags[0] = HB_TAG('P','G','R',' '); /* Polytonic Greek */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-provenc"))
+ {
+ /* Occitan (post 1500); Provençal */
+ tags[0] = HB_TAG('P','R','O',' '); /* Provençal / Old Provençal */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-fonipa"))
+ {
+ /* Undetermined; International Phonetic Alphabet */
+ tags[0] = HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-geok"))
+ {
+ /* Undetermined; Khutsuri (Asomtavruli and Nuskhuri) */
+ tags[0] = HB_TAG('K','G','E',' '); /* Khutsuri Georgian */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-syre"))
+ {
+ /* Undetermined; Syriac (Estrangelo variant) */
+ tags[0] = HB_TAG('S','Y','R','E'); /* Syriac, Estrangela script-variant (equivalent to ISO 15924 'Syre') */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-syrj"))
+ {
+ /* Undetermined; Syriac (Western variant) */
+ tags[0] = HB_TAG('S','Y','R','J'); /* Syriac, Western script-variant (equivalent to ISO 15924 'Syrj') */
+ *count = 1;
+ return true;
+ }
+ if (subtag_matches (lang_str, limit, "-syrn"))
+ {
+ /* Undetermined; Syriac (Eastern variant) */
+ tags[0] = HB_TAG('S','Y','R','N'); /* Syriac, Eastern script-variant (equivalent to ISO 15924 'Syrn') */
+ *count = 1;
+ return true;
+ }
+ switch (lang_str[0])
+ {
+ case 'a':
+ if (0 == strcmp (&lang_str[1], "rt-lojban"))
+ {
+ /* Lojban */
+ tags[0] = HB_TAG('J','B','O',' '); /* Lojban */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'c':
+ if (lang_matches (&lang_str[1], "do-hant-hk"))
+ {
+ /* Min Dong Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "do-hant-mo"))
+ {
+ /* Min Dong Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "jy-hant-hk"))
+ {
+ /* Jinyu Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "jy-hant-mo"))
+ {
+ /* Jinyu Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "mn-hant-hk"))
+ {
+ /* Mandarin Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "mn-hant-mo"))
+ {
+ /* Mandarin Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "px-hant-hk"))
+ {
+ /* Pu-Xian Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "px-hant-mo"))
+ {
+ /* Pu-Xian Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zh-hant-hk"))
+ {
+ /* Huizhou Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zh-hant-mo"))
+ {
+ /* Huizhou Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zo-hant-hk"))
+ {
+ /* Min Zhong Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zo-hant-mo"))
+ {
+ /* Min Zhong Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "do-hans"))
+ {
+ /* Min Dong Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "do-hant"))
+ {
+ /* Min Dong Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "jy-hans"))
+ {
+ /* Jinyu Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "jy-hant"))
+ {
+ /* Jinyu Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "mn-hans"))
+ {
+ /* Mandarin Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "mn-hant"))
+ {
+ /* Mandarin Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "px-hans"))
+ {
+ /* Pu-Xian Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "px-hant"))
+ {
+ /* Pu-Xian Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zh-hans"))
+ {
+ /* Huizhou Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zh-hant"))
+ {
+ /* Huizhou Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zo-hans"))
+ {
+ /* Min Zhong Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "zo-hant"))
+ {
+ /* Min Zhong Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "do-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Min Dong Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "do-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Min Dong Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "do-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Min Dong Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "jy-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Jinyu Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "jy-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Jinyu Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "jy-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Jinyu Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "mn-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Mandarin Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "mn-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Mandarin Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "mn-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Mandarin Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "px-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Pu-Xian Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "px-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Pu-Xian Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "px-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Pu-Xian Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zh-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Huizhou Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zh-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Huizhou Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zh-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Huizhou Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zo-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Min Zhong Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zo-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Min Zhong Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "zo-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Min Zhong Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'g':
+ if (lang_matches (&lang_str[1], "an-hant-hk"))
+ {
+ /* Gan Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hant-mo"))
+ {
+ /* Gan Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hans"))
+ {
+ /* Gan Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hant"))
+ {
+ /* Gan Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "a-latg"))
+ {
+ /* Irish */
+ tags[0] = HB_TAG('I','R','T',' '); /* Irish Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Gan Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Gan Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Gan Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'h':
+ if (lang_matches (&lang_str[1], "ak-hant-hk"))
+ {
+ /* Hakka Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "ak-hant-mo"))
+ {
+ /* Hakka Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "sn-hant-hk"))
+ {
+ /* Xiang Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "sn-hant-mo"))
+ {
+ /* Xiang Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "ak-hans"))
+ {
+ /* Hakka Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "ak-hant"))
+ {
+ /* Hakka Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "sn-hans"))
+ {
+ /* Xiang Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "sn-hant"))
+ {
+ /* Xiang Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "ak-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Hakka Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "ak-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Hakka Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "ak-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Hakka Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "sn-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Xiang Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "sn-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Xiang Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "sn-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Xiang Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'i':
+ if (0 == strcmp (&lang_str[1], "-navajo"))
+ {
+ /* Navajo */
+ unsigned int i;
+ hb_tag_t possible_tags[] = {
+ HB_TAG('N','A','V',' '), /* Navajo */
+ HB_TAG('A','T','H',' '), /* Athapaskan */
+ };
+ for (i = 0; i < 2 && i < *count; i++)
+ tags[i] = possible_tags[i];
+ *count = i;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "-hak"))
+ {
+ /* Hakka */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "-lux"))
+ {
+ /* Luxembourgish */
+ tags[0] = HB_TAG('L','T','Z',' '); /* Luxembourgish */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'l':
+ if (lang_matches (&lang_str[1], "zh-hans"))
+ {
+ /* Literary Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'm':
+ if (lang_matches (&lang_str[1], "np-hant-hk"))
+ {
+ /* Min Bei Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "np-hant-mo"))
+ {
+ /* Min Bei Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "np-hans"))
+ {
+ /* Min Bei Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "np-hant"))
+ {
+ /* Min Bei Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "np-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Min Bei Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "np-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Min Bei Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "np-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Min Bei Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'n':
+ if (lang_matches (&lang_str[1], "an-hant-hk"))
+ {
+ /* Min Nan Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hant-mo"))
+ {
+ /* Min Nan Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hans"))
+ {
+ /* Min Nan Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "an-hant"))
+ {
+ /* Min Nan Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Min Nan Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Min Nan Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "an-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Min Nan Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "o-bok"))
+ {
+ /* Norwegian Bokmal */
+ tags[0] = HB_TAG('N','O','R',' '); /* Norwegian */
+ *count = 1;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "o-nyn"))
+ {
+ /* Norwegian Nynorsk */
+ tags[0] = HB_TAG('N','Y','N',' '); /* Norwegian Nynorsk (Nynorsk, Norwegian) */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'r':
+ if (0 == strncmp (&lang_str[1], "o-", 2)
+ && subtag_matches (lang_str, limit, "-md"))
+ {
+ /* Romanian; Moldova */
+ tags[0] = HB_TAG('M','O','L',' '); /* Moldavian */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'w':
+ if (lang_matches (&lang_str[1], "uu-hant-hk"))
+ {
+ /* Wu Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "uu-hant-mo"))
+ {
+ /* Wu Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "uu-hans"))
+ {
+ /* Wu Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "uu-hant"))
+ {
+ /* Wu Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "uu-", 3)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Wu Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "uu-", 3)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Wu Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "uu-", 3)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Wu Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'y':
+ if (lang_matches (&lang_str[1], "ue-hans"))
+ {
+ /* Yue Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ break;
+ case 'z':
+ if (lang_matches (&lang_str[1], "h-hant-hk"))
+ {
+ /* Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "h-hant-mo"))
+ {
+ /* Chinese */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "h-min-nan"))
+ {
+ /* Minnan, Hokkien, Amoy, Taiwanese, Southern Min, Southern Fujian, Hoklo, Southern Fukien, Ho-lo */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "h-hans"))
+ {
+ /* Chinese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (lang_matches (&lang_str[1], "h-hant"))
+ {
+ /* Chinese */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ if (0 == strcmp (&lang_str[1], "h-min"))
+ {
+ /* Min, Fuzhou, Hokkien, Amoy, or Taiwanese */
+ tags[0] = HB_TAG('Z','H','S',' '); /* Chinese Simplified */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "h-", 2)
+ && subtag_matches (lang_str, limit, "-hk"))
+ {
+ /* Chinese; Hong Kong */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "h-", 2)
+ && subtag_matches (lang_str, limit, "-mo"))
+ {
+ /* Chinese; Macao */
+ tags[0] = HB_TAG('Z','H','H',' '); /* Chinese, Hong Kong SAR */
+ *count = 1;
+ return true;
+ }
+ if (0 == strncmp (&lang_str[1], "h-", 2)
+ && subtag_matches (lang_str, limit, "-tw"))
+ {
+ /* Chinese; Taiwan, Province of China */
+ tags[0] = HB_TAG('Z','H','T',' '); /* Chinese Traditional */
+ *count = 1;
+ return true;
+ }
+ break;
+ }
+ return false;
+}
+
+/**
+ * hb_ot_ambiguous_tag_to_language
+ * @tag: A language tag.
+ *
+ * Converts @tag to a BCP 47 language tag if it is ambiguous (it corresponds to
+ * many language tags) and the best tag is not the alphabetically first, or if
+ * the best tag consists of multiple subtags.
+ *
+ * Return value: The #hb_language_t corresponding to the BCP 47 language tag,
+ * or #HB_LANGUAGE_INVALID if @tag is not ambiguous.
+ **/
+static hb_language_t
+hb_ot_ambiguous_tag_to_language (hb_tag_t tag)
+{
+ switch (tag)
+ {
+ case HB_TAG('A','P','P','H'): /* Phonetic transcription—Americanist conventions */
+ return hb_language_from_string ("und-fonnapa", -1); /* Undetermined; North American Phonetic Alphabet */
+ case HB_TAG('A','R','A',' '): /* Arabic */
+ return hb_language_from_string ("ar", -1); /* Arabic */
+ case HB_TAG('A','R','K',' '): /* Rakhine */
+ return hb_language_from_string ("rki", -1); /* Rakhine */
+ case HB_TAG('A','T','H',' '): /* Athapaskan */
+ return hb_language_from_string ("ath", -1); /* Athapascan */
+ case HB_TAG('B','I','K',' '): /* Bikol */
+ return hb_language_from_string ("bik", -1); /* Bikol */
+ case HB_TAG('C','P','P',' '): /* Creoles */
+ return hb_language_from_string ("crp", -1); /* Creoles and pidgins */
+ case HB_TAG('C','R','R',' '): /* Carrier */
+ return hb_language_from_string ("crx", -1); /* Carrier */
+ case HB_TAG('D','N','K',' '): /* Dinka */
+ return hb_language_from_string ("din", -1); /* Dinka */
+ case HB_TAG('D','R','I',' '): /* Dari */
+ return hb_language_from_string ("prs", -1); /* Dari */
+ case HB_TAG('D','U','J',' '): /* Dhuwal */
+ return hb_language_from_string ("dwu", -1); /* Dhuwal */
+ case HB_TAG('D','Z','N',' '): /* Dzongkha */
+ return hb_language_from_string ("dz", -1); /* Dzongkha */
+ case HB_TAG('E','T','I',' '): /* Estonian */
+ return hb_language_from_string ("et", -1); /* Estonian */
+ case HB_TAG('G','O','N',' '): /* Gondi */
+ return hb_language_from_string ("gon", -1); /* Gondi */
+ case HB_TAG('H','M','N',' '): /* Hmong */
+ return hb_language_from_string ("hmn", -1); /* Hmong */
+ case HB_TAG('I','J','O',' '): /* Ijo */
+ return hb_language_from_string ("ijo", -1); /* Ijo */
+ case HB_TAG('I','N','U',' '): /* Inuktitut */
+ return hb_language_from_string ("iu", -1); /* Inuktitut */
+ case HB_TAG('I','P','K',' '): /* Inupiat */
+ return hb_language_from_string ("ik", -1); /* Inupiaq */
+ case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */
+ return hb_language_from_string ("und-fonipa", -1); /* Undetermined; International Phonetic Alphabet */
+ case HB_TAG('I','R','T',' '): /* Irish Traditional */
+ return hb_language_from_string ("ga-Latg", -1); /* Irish; Latin (Gaelic variant) */
+ case HB_TAG('J','I','I',' '): /* Yiddish */
+ return hb_language_from_string ("yi", -1); /* Yiddish */
+ case HB_TAG('K','A','L',' '): /* Kalenjin */
+ return hb_language_from_string ("kln", -1); /* Kalenjin */
+ case HB_TAG('K','G','E',' '): /* Khutsuri Georgian */
+ return hb_language_from_string ("und-Geok", -1); /* Undetermined; Khutsuri (Asomtavruli and Nuskhuri) */
+ case HB_TAG('K','N','R',' '): /* Kanuri */
+ return hb_language_from_string ("kr", -1); /* Kanuri */
+ case HB_TAG('K','O','K',' '): /* Konkani */
+ return hb_language_from_string ("kok", -1); /* Konkani */
+ case HB_TAG('K','U','R',' '): /* Kurdish */
+ return hb_language_from_string ("ku", -1); /* Kurdish */
+ case HB_TAG('L','U','H',' '): /* Luyia */
+ return hb_language_from_string ("luy", -1); /* Luyia */
+ case HB_TAG('L','V','I',' '): /* Latvian */
+ return hb_language_from_string ("lv", -1); /* Latvian */
+ case HB_TAG('M','A','W',' '): /* Marwari */
+ return hb_language_from_string ("mwr", -1); /* Marwari */
+ case HB_TAG('M','L','G',' '): /* Malagasy */
+ return hb_language_from_string ("mg", -1); /* Malagasy */
+ case HB_TAG('M','L','Y',' '): /* Malay */
+ return hb_language_from_string ("ms", -1); /* Malay */
+ case HB_TAG('M','N','G',' '): /* Mongolian */
+ return hb_language_from_string ("mn", -1); /* Mongolian */
+ case HB_TAG('M','O','L',' '): /* Moldavian */
+ return hb_language_from_string ("ro-MD", -1); /* Romanian; Moldova */
+ case HB_TAG('N','E','P',' '): /* Nepali */
+ return hb_language_from_string ("ne", -1); /* Nepali */
+ case HB_TAG('N','I','S',' '): /* Nisi */
+ return hb_language_from_string ("njz", -1); /* Nyishi */
+ case HB_TAG('N','O','R',' '): /* Norwegian */
+ return hb_language_from_string ("no", -1); /* Norwegian */
+ case HB_TAG('O','J','B',' '): /* Ojibway */
+ return hb_language_from_string ("oj", -1); /* Ojibwa */
+ case HB_TAG('O','R','O',' '): /* Oromo */
+ return hb_language_from_string ("om", -1); /* Oromo */
+ case HB_TAG('P','A','S',' '): /* Pashto */
+ return hb_language_from_string ("ps", -1); /* Pashto */
+ case HB_TAG('P','G','R',' '): /* Polytonic Greek */
+ return hb_language_from_string ("el-polyton", -1); /* Modern Greek (1453-); Polytonic Greek */
+ case HB_TAG('P','R','O',' '): /* Provençal / Old Provençal */
+ return hb_language_from_string ("pro", -1); /* Old Provençal (to 1500) */
+ case HB_TAG('Q','U','H',' '): /* Quechua (Bolivia) */
+ return hb_language_from_string ("quh", -1); /* South Bolivian Quechua */
+ case HB_TAG('Q','V','I',' '): /* Quechua (Ecuador) */
+ return hb_language_from_string ("qvi", -1); /* Imbabura Highland Quichua */
+ case HB_TAG('Q','W','H',' '): /* Quechua (Peru) */
+ return hb_language_from_string ("qwh", -1); /* Huaylas Ancash Quechua */
+ case HB_TAG('R','A','J',' '): /* Rajasthani */
+ return hb_language_from_string ("raj", -1); /* Rajasthani */
+ case HB_TAG('R','O','Y',' '): /* Romany */
+ return hb_language_from_string ("rom", -1); /* Romany */
+ case HB_TAG('S','Q','I',' '): /* Albanian */
+ return hb_language_from_string ("sq", -1); /* Albanian */
+ case HB_TAG('S','Y','R',' '): /* Syriac */
+ return hb_language_from_string ("syr", -1); /* Syriac */
+ case HB_TAG('S','Y','R','E'): /* Syriac, Estrangela script-variant (equivalent to ISO 15924 'Syre') */
+ return hb_language_from_string ("und-Syre", -1); /* Undetermined; Syriac (Estrangelo variant) */
+ case HB_TAG('S','Y','R','J'): /* Syriac, Western script-variant (equivalent to ISO 15924 'Syrj') */
+ return hb_language_from_string ("und-Syrj", -1); /* Undetermined; Syriac (Western variant) */
+ case HB_TAG('S','Y','R','N'): /* Syriac, Eastern script-variant (equivalent to ISO 15924 'Syrn') */
+ return hb_language_from_string ("und-Syrn", -1); /* Undetermined; Syriac (Eastern variant) */
+ case HB_TAG('T','M','H',' '): /* Tamashek */
+ return hb_language_from_string ("tmh", -1); /* Tamashek */
+ case HB_TAG('T','N','E',' '): /* Tundra Nenets */
+ return hb_language_from_string ("yrk", -1); /* Nenets */
+ case HB_TAG('Z','H','H',' '): /* Chinese, Hong Kong SAR */
+ return hb_language_from_string ("zh-HK", -1); /* Chinese; Hong Kong */
+ case HB_TAG('Z','H','S',' '): /* Chinese Simplified */
+ return hb_language_from_string ("zh-Hans", -1); /* Chinese; Han (Simplified variant) */
+ case HB_TAG('Z','H','T',' '): /* Chinese Traditional */
+ return hb_language_from_string ("zh-Hant", -1); /* Chinese; Han (Traditional variant) */
+ default:
+ return HB_LANGUAGE_INVALID;
+ }
+}
+
+#endif /* HB_OT_TAG_TABLE_HH */
+
+/* == End of generated table == */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.cc
index 283723e27d8..a569b8c22a2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-tag.cc
@@ -36,7 +36,8 @@ hb_ot_old_tag_from_script (hb_script_t script)
{
/* This seems to be accurate as of end of 2012. */
- switch ((hb_tag_t) script) {
+ switch ((hb_tag_t) script)
+ {
case HB_SCRIPT_INVALID: return HB_OT_TAG_DEFAULT_SCRIPT;
/* KATAKANA and HIRAGANA both map to 'kana' */
@@ -49,8 +50,6 @@ hb_ot_old_tag_from_script (hb_script_t script)
case HB_SCRIPT_NKO: return HB_TAG('n','k','o',' ');
/* Unicode-5.1 additions */
case HB_SCRIPT_VAI: return HB_TAG('v','a','i',' ');
- /* Unicode-5.2 additions */
- /* Unicode-6.0 additions */
}
/* Else, just change first char to lowercase and return */
@@ -114,6 +113,18 @@ hb_ot_new_tag_to_script (hb_tag_t tag)
return HB_SCRIPT_UNKNOWN;
}
+void
+hb_ot_tags_from_script (hb_script_t script,
+ hb_tag_t *script_tag_1,
+ hb_tag_t *script_tag_2)
+{
+ unsigned int count = 2;
+ hb_tag_t tags[2];
+ hb_ot_tags_from_script_and_language (script, HB_LANGUAGE_INVALID, &count, tags, nullptr, nullptr);
+ *script_tag_1 = count > 0 ? tags[0] : HB_OT_TAG_DEFAULT_SCRIPT;
+ *script_tag_2 = count > 1 ? tags[1] : HB_OT_TAG_DEFAULT_SCRIPT;
+}
+
/*
* Complete list at:
* https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags
@@ -122,28 +133,37 @@ hb_ot_new_tag_to_script (hb_tag_t tag)
* So we just do that, and handle the exceptional cases in a switch.
*/
-void
-hb_ot_tags_from_script (hb_script_t script,
- hb_tag_t *script_tag_1,
- hb_tag_t *script_tag_2)
+static void
+hb_ot_all_tags_from_script (hb_script_t script,
+ unsigned int *count /* IN/OUT */,
+ hb_tag_t *tags /* OUT */)
{
- hb_tag_t new_tag;
+ unsigned int i = 0;
- *script_tag_2 = HB_OT_TAG_DEFAULT_SCRIPT;
- *script_tag_1 = hb_ot_old_tag_from_script (script);
+ hb_tag_t new_tag = hb_ot_new_tag_from_script (script);
+ if (unlikely (new_tag != HB_OT_TAG_DEFAULT_SCRIPT))
+ {
+ tags[i++] = new_tag | '3';
+ if (*count > i)
+ tags[i++] = new_tag;
+ }
- new_tag = hb_ot_new_tag_from_script (script);
- if (unlikely (new_tag != HB_OT_TAG_DEFAULT_SCRIPT)) {
- *script_tag_2 = *script_tag_1;
- *script_tag_1 = new_tag;
+ if (*count > i)
+ {
+ hb_tag_t old_tag = hb_ot_old_tag_from_script (script);
+ if (old_tag != HB_OT_TAG_DEFAULT_SCRIPT)
+ tags[i++] = old_tag;
}
+
+ *count = i;
}
hb_script_t
hb_ot_tag_to_script (hb_tag_t tag)
{
- if (unlikely ((tag & 0x000000FFu) == '2'))
- return hb_ot_new_tag_to_script (tag);
+ unsigned char digit = tag & 0x000000FFu;
+ if (unlikely (digit == '2' || digit == '3'))
+ return hb_ot_new_tag_to_script (tag & 0xFFFFFF32);
return hb_ot_old_tag_to_script (tag);
}
@@ -151,732 +171,6 @@ hb_ot_tag_to_script (hb_tag_t tag)
/* hb_language_t */
-typedef struct {
- char language[4];
- hb_tag_t tag;
-} LangTag;
-
-/*
- * Complete list at:
- * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
- *
- * Generated by intersecting the OpenType language tag list from
- * Draft OpenType 1.5 spec, with with the ISO 639-3 codes from
- * 2008-08-04, matching on name, and finally adjusted manually.
- *
- * Updated on 2012-12-07 with more research into remaining codes.
- *
- * Updated on 2013-11-23 based on usage in SIL and Microsoft fonts,
- * the new proposal from Microsoft, and latest ISO 639-3 names.
- *
- * Some items still missing. Those are commented out at the end.
- * Keep sorted for bsearch.
- *
- * Updated as of 2015-05-06: OT1.7 on MS website has some newer
- * items that we don't have here, eg. Zazaki. This is the new
- * items in OpenType 1.7 (red items), most of which we have:
- * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
- */
-
-static const LangTag ot_languages[] = {
- {"aa", HB_TAG('A','F','R',' ')}, /* Afar */
- {"ab", HB_TAG('A','B','K',' ')}, /* Abkhazian */
- {"abq", HB_TAG('A','B','A',' ')}, /* Abaza */
- {"acf", HB_TAG('F','A','N',' ')}, /* French Antillean */
- {"ach", HB_TAG('A','C','H',' ')}, /* Acoli */
- {"acr", HB_TAG('A','C','R',' ')}, /* Achi */
- {"ada", HB_TAG('D','N','G',' ')}, /* Dangme */
- {"ady", HB_TAG('A','D','Y',' ')}, /* Adyghe */
- {"af", HB_TAG('A','F','K',' ')}, /* Afrikaans */
- {"ahg", HB_TAG('A','G','W',' ')}, /* Agaw */
- {"aii", HB_TAG('S','W','A',' ')}, /* Swadaya Aramaic */
- {"aio", HB_TAG('A','I','O',' ')}, /* Aiton */
- {"aiw", HB_TAG('A','R','I',' ')}, /* Aari */
- {"ak", HB_TAG('T','W','I',' ')}, /* Akan [macrolanguage] */
- {"aka", HB_TAG('A','K','A',' ')}, /* Akan */
- {"alt", HB_TAG('A','L','T',' ')}, /* [Southern] Altai */
- {"am", HB_TAG('A','M','H',' ')}, /* Amharic */
- {"amf", HB_TAG('H','B','N',' ')}, /* Hammer-Banna */
- {"amw", HB_TAG('S','Y','R',' ')}, /* Western Neo-Aramaic */
- {"an", HB_TAG('A','R','G',' ')}, /* Aragonese */
- {"ang", HB_TAG('A','N','G',' ')}, /* Old English (ca. 450-1100) */
- {"ar", HB_TAG('A','R','A',' ')}, /* Arabic [macrolanguage] */
- {"arb", HB_TAG('A','R','A',' ')}, /* Standard Arabic */
- {"arn", HB_TAG('M','A','P',' ')}, /* Mapudungun */
- {"ary", HB_TAG('M','O','R',' ')}, /* Moroccan Arabic */
- {"as", HB_TAG('A','S','M',' ')}, /* Assamese */
- {"ast", HB_TAG('A','S','T',' ')}, /* Asturian/Asturleonese/Bable/Leonese */
- {"ath", HB_TAG('A','T','H',' ')}, /* Athapaskan [family] */
- {"atj", HB_TAG('R','C','R',' ')}, /* R-Cree */
- {"atv", HB_TAG('A','L','T',' ')}, /* [Northern] Altai */
- {"av", HB_TAG('A','V','R',' ')}, /* Avaric */
- {"awa", HB_TAG('A','W','A',' ')}, /* Awadhi */
- {"ay", HB_TAG('A','Y','M',' ')}, /* Aymara [macrolanguage] */
- {"az", HB_TAG('A','Z','E',' ')}, /* Azerbaijani [macrolanguage] */
- {"azb", HB_TAG('A','Z','B',' ')}, /* South Azerbaijani */
- {"azj", HB_TAG('A','Z','E',' ')}, /* North Azerbaijani */
- {"ba", HB_TAG('B','S','H',' ')}, /* Bashkir */
- {"bad", HB_TAG('B','A','D','0')}, /* Banda */
- {"bai", HB_TAG('B','M','L',' ')}, /* Bamileke [family] */
- {"bal", HB_TAG('B','L','I',' ')}, /* Baluchi [macrolangauge] */
- {"ban", HB_TAG('B','A','N',' ')}, /* Balinese */
- {"bar", HB_TAG('B','A','R',' ')}, /* Bavarian */
- {"bbc", HB_TAG('B','B','C',' ')}, /* Batak Toba */
- {"bci", HB_TAG('B','A','U',' ')}, /* Baoulé */
- {"bcl", HB_TAG('B','I','K',' ')}, /* Central Bikol */
- {"bcq", HB_TAG('B','C','H',' ')}, /* Bench */
- {"bdy", HB_TAG('B','D','Y',' ')}, /* Bandjalang */
- {"be", HB_TAG('B','E','L',' ')}, /* Belarusian */
- {"bem", HB_TAG('B','E','M',' ')}, /* Bemba (Zambia) */
- {"ber", HB_TAG('B','E','R',' ')}, /* Berber [family] */
- {"bfq", HB_TAG('B','A','D',' ')}, /* Badaga */
- {"bft", HB_TAG('B','L','T',' ')}, /* Balti */
- {"bfu", HB_TAG('L','A','H',' ')}, /* Lahuli */
- {"bfy", HB_TAG('B','A','G',' ')}, /* Baghelkhandi */
- {"bg", HB_TAG('B','G','R',' ')}, /* Bulgarian */
- {"bgc", HB_TAG('B','G','C',' ')}, /* Haryanvi */
- {"bgq", HB_TAG('B','G','Q',' ')}, /* Bagri */
- {"bgr", HB_TAG('Q','I','N',' ')}, /* Bawm Chin */
- {"bhb", HB_TAG('B','H','I',' ')}, /* Bhili */
- {"bhk", HB_TAG('B','I','K',' ')}, /* Albay Bicolano (retired code) */
- {"bho", HB_TAG('B','H','O',' ')}, /* Bhojpuri */
- {"bi", HB_TAG('B','I','S',' ')}, /* Bislama */
- {"bik", HB_TAG('B','I','K',' ')}, /* Bikol [macrolanguage] */
- {"bin", HB_TAG('E','D','O',' ')}, /* Bini */
- {"bjj", HB_TAG('B','J','J',' ')}, /* Kanauji */
- {"bjt", HB_TAG('B','L','N',' ')}, /* Balanta-Ganja */
- {"bla", HB_TAG('B','K','F',' ')}, /* Blackfoot */
- {"ble", HB_TAG('B','L','N',' ')}, /* Balanta-Kentohe */
- {"blk", HB_TAG('B','L','K',' ')}, /* Pa'O/Pa'o Karen */
- {"bln", HB_TAG('B','I','K',' ')}, /* Southern Catanduanes Bikol */
- {"bm", HB_TAG('B','M','B',' ')}, /* Bambara */
- {"bn", HB_TAG('B','E','N',' ')}, /* Bengali */
- {"bo", HB_TAG('T','I','B',' ')}, /* Tibetan */
- {"bpy", HB_TAG('B','P','Y',' ')}, /* Bishnupriya */
- {"bqi", HB_TAG('L','R','C',' ')}, /* Bakhtiari */
- {"br", HB_TAG('B','R','E',' ')}, /* Breton */
- {"bra", HB_TAG('B','R','I',' ')}, /* Braj Bhasha */
- {"brh", HB_TAG('B','R','H',' ')}, /* Brahui */
- {"brx", HB_TAG('B','R','X',' ')}, /* Bodo (India) */
- {"bs", HB_TAG('B','O','S',' ')}, /* Bosnian */
- {"btb", HB_TAG('B','T','I',' ')}, /* Beti (Cameroon) */
- {"bto", HB_TAG('B','I','K',' ')}, /* Rinconada Bikol */
- {"bts", HB_TAG('B','T','S',' ')}, /* Batak Simalungun */
- {"bug", HB_TAG('B','U','G',' ')}, /* Buginese */
- {"bxr", HB_TAG('R','B','U',' ')}, /* Russian Buriat */
- {"byn", HB_TAG('B','I','L',' ')}, /* Bilen */
- {"ca", HB_TAG('C','A','T',' ')}, /* Catalan */
- {"cak", HB_TAG('C','A','K',' ')}, /* Kaqchikel */
- {"cbk", HB_TAG('C','B','K',' ')}, /* Chavacano */
- {"cbl", HB_TAG('Q','I','N',' ')}, /* Bualkhaw Chin */
- {"cco", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"ce", HB_TAG('C','H','E',' ')}, /* Chechen */
- {"ceb", HB_TAG('C','E','B',' ')}, /* Cebuano */
- {"cfm", HB_TAG('H','A','L',' ')}, /* Halam/Falam Chin */
- {"cgg", HB_TAG('C','G','G',' ')}, /* Chiga */
- {"ch", HB_TAG('C','H','A',' ')}, /* Chamorro */
- {"chj", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"chk", HB_TAG('C','H','K','0')}, /* Chuukese */
- {"cho", HB_TAG('C','H','O',' ')}, /* Choctaw */
- {"chp", HB_TAG('C','H','P',' ')}, /* Chipewyan */
- {"chq", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"chr", HB_TAG('C','H','R',' ')}, /* Cherokee */
- {"chy", HB_TAG('C','H','Y',' ')}, /* Cheyenne */
- {"chz", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cja", HB_TAG('C','J','A',' ')}, /* Western Cham */
- {"cjm", HB_TAG('C','J','M',' ')}, /* Eastern Cham */
- {"cka", HB_TAG('Q','I','N',' ')}, /* Khumi Awa Chin */
- {"ckb", HB_TAG('K','U','R',' ')}, /* Central Kurdish (Sorani) */
- {"ckt", HB_TAG('C','H','K',' ')}, /* Chukchi */
- {"cld", HB_TAG('S','Y','R',' ')}, /* Chaldean Neo-Aramaic */
- {"cle", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cmr", HB_TAG('Q','I','N',' ')}, /* Mro-Khimi Chin */
- {"cnb", HB_TAG('Q','I','N',' ')}, /* Chinbon Chin */
- {"cnh", HB_TAG('Q','I','N',' ')}, /* Hakha Chin */
- {"cnk", HB_TAG('Q','I','N',' ')}, /* Khumi Chin */
- {"cnl", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cnt", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cnw", HB_TAG('Q','I','N',' ')}, /* Ngawn Chin */
- {"cop", HB_TAG('C','O','P',' ')}, /* Coptic */
- {"cpa", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cpp", HB_TAG('C','P','P',' ')}, /* Creoles */
- {"cr", HB_TAG('C','R','E',' ')}, /* Cree */
- {"cre", HB_TAG('Y','C','R',' ')}, /* Y-Cree */
- {"crh", HB_TAG('C','R','T',' ')}, /* Crimean Tatar */
- {"crj", HB_TAG('E','C','R',' ')}, /* [Southern] East Cree */
- {"crk", HB_TAG('W','C','R',' ')}, /* West-Cree */
- {"crl", HB_TAG('E','C','R',' ')}, /* [Northern] East Cree */
- {"crm", HB_TAG('M','C','R',' ')}, /* Moose Cree */
- {"crx", HB_TAG('C','R','R',' ')}, /* Carrier */
- {"cs", HB_TAG('C','S','Y',' ')}, /* Czech */
- {"csa", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"csb", HB_TAG('C','S','B',' ')}, /* Kashubian */
- {"csh", HB_TAG('Q','I','N',' ')}, /* Asho Chin */
- {"cso", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"csy", HB_TAG('Q','I','N',' ')}, /* Siyin Chin */
- {"ctd", HB_TAG('Q','I','N',' ')}, /* Tedim Chin */
- {"cte", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"ctg", HB_TAG('C','T','G',' ')}, /* Chittagonian */
- {"ctl", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cts", HB_TAG('B','I','K',' ')}, /* Northern Catanduanes Bikol */
- {"cu", HB_TAG('C','S','L',' ')}, /* Church Slavic */
- {"cuc", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cuk", HB_TAG('C','U','K',' ')}, /* San Blas Kuna */
- {"cv", HB_TAG('C','H','U',' ')}, /* Chuvash */
- {"cvn", HB_TAG('C','C','H','N')}, /* Chinantec */
- {"cwd", HB_TAG('D','C','R',' ')}, /* Woods Cree */
- {"cy", HB_TAG('W','E','L',' ')}, /* Welsh */
- {"czt", HB_TAG('Q','I','N',' ')}, /* Zotung Chin */
- {"da", HB_TAG('D','A','N',' ')}, /* Danish */
- {"dao", HB_TAG('Q','I','N',' ')}, /* Daai Chin */
- {"dap", HB_TAG('N','I','S',' ')}, /* Nisi (India) */
- {"dar", HB_TAG('D','A','R',' ')}, /* Dargwa */
- {"dax", HB_TAG('D','A','X',' ')}, /* Dayi */
- {"de", HB_TAG('D','E','U',' ')}, /* German */
- {"dgo", HB_TAG('D','G','O',' ')}, /* Dogri */
- {"dhd", HB_TAG('M','A','W',' ')}, /* Dhundari */
- {"dhg", HB_TAG('D','H','G',' ')}, /* Dhangu */
- {"din", HB_TAG('D','N','K',' ')}, /* Dinka [macrolanguage] */
- {"diq", HB_TAG('D','I','Q',' ')}, /* Dimli */
- {"dje", HB_TAG('D','J','R',' ')}, /* Zarma */
- {"djr", HB_TAG('D','J','R','0')}, /* Djambarrpuyngu */
- {"dng", HB_TAG('D','U','N',' ')}, /* Dungan */
- {"dnj", HB_TAG('D','N','J',' ')}, /* Dan */
- {"doi", HB_TAG('D','G','R',' ')}, /* Dogri [macrolanguage] */
- {"dsb", HB_TAG('L','S','B',' ')}, /* Lower Sorbian */
- {"duj", HB_TAG('D','U','J',' ')}, /* Dhuwal */
- {"dv", HB_TAG('D','I','V',' ')}, /* Dhivehi/Divehi/Maldivian */
- {"dyu", HB_TAG('J','U','L',' ')}, /* Jula */
- {"dz", HB_TAG('D','Z','N',' ')}, /* Dzongkha */
- {"ee", HB_TAG('E','W','E',' ')}, /* Ewe */
- {"efi", HB_TAG('E','F','I',' ')}, /* Efik */
- {"ekk", HB_TAG('E','T','I',' ')}, /* Standard Estonian */
- {"el", HB_TAG('E','L','L',' ')}, /* Modern Greek (1453-) */
- {"emk", HB_TAG('M','N','K',' ')}, /* Eastern Maninkakan */
- {"en", HB_TAG('E','N','G',' ')}, /* English */
- {"enf", HB_TAG('F','N','E',' ')}, /* Forest Nenets */
- {"enh", HB_TAG('T','N','E',' ')}, /* Tundra Nenets */
- {"eo", HB_TAG('N','T','O',' ')}, /* Esperanto */
- {"eot", HB_TAG('B','T','I',' ')}, /* Beti (Côte d'Ivoire) */
- {"es", HB_TAG('E','S','P',' ')}, /* Spanish */
- {"esu", HB_TAG('E','S','U',' ')}, /* Central Yupik */
- {"et", HB_TAG('E','T','I',' ')}, /* Estonian [macrolanguage] */
- {"eu", HB_TAG('E','U','Q',' ')}, /* Basque */
- {"eve", HB_TAG('E','V','N',' ')}, /* Even */
- {"evn", HB_TAG('E','V','K',' ')}, /* Evenki */
- {"fa", HB_TAG('F','A','R',' ')}, /* Persian [macrolanguage] */
- {"fan", HB_TAG('F','A','N','0')}, /* Fang */
- {"fat", HB_TAG('F','A','T',' ')}, /* Fanti */
- {"ff", HB_TAG('F','U','L',' ')}, /* Fulah [macrolanguage] */
- {"fi", HB_TAG('F','I','N',' ')}, /* Finnish */
- {"fil", HB_TAG('P','I','L',' ')}, /* Filipino */
- {"fj", HB_TAG('F','J','I',' ')}, /* Fijian */
- {"flm", HB_TAG('H','A','L',' ')}, /* Halam/Falam Chin [retired ISO639 code] */
- {"fo", HB_TAG('F','O','S',' ')}, /* Faroese */
- {"fon", HB_TAG('F','O','N',' ')}, /* Fon */
- {"fr", HB_TAG('F','R','A',' ')}, /* French */
- {"frc", HB_TAG('F','R','C',' ')}, /* Cajun French */
- {"frp", HB_TAG('F','R','P',' ')}, /* Arpitan/Francoprovençal */
- {"fuf", HB_TAG('F','T','A',' ')}, /* Futa */
- {"fur", HB_TAG('F','R','L',' ')}, /* Friulian */
- {"fuv", HB_TAG('F','U','V',' ')}, /* Nigerian Fulfulde */
- {"fy", HB_TAG('F','R','I',' ')}, /* Western Frisian */
- {"ga", HB_TAG('I','R','I',' ')}, /* Irish */
- {"gaa", HB_TAG('G','A','D',' ')}, /* Ga */
- {"gag", HB_TAG('G','A','G',' ')}, /* Gagauz */
- {"gbm", HB_TAG('G','A','W',' ')}, /* Garhwali */
- {"gd", HB_TAG('G','A','E',' ')}, /* Scottish Gaelic */
- {"gez", HB_TAG('G','E','Z',' ')}, /* Ge'ez */
- {"ggo", HB_TAG('G','O','N',' ')}, /* Southern Gondi */
- {"gih", HB_TAG('G','I','H',' ')}, /* Githabul */
- {"gil", HB_TAG('G','I','L','0')}, /* Kiribati (Gilbertese) */
- {"gkp", HB_TAG('G','K','P',' ')}, /* Kpelle (Guinea) */
- {"gl", HB_TAG('G','A','L',' ')}, /* Galician */
- {"gld", HB_TAG('N','A','N',' ')}, /* Nanai */
- {"glk", HB_TAG('G','L','K',' ')}, /* Gilaki */
- {"gn", HB_TAG('G','U','A',' ')}, /* Guarani [macrolanguage] */
- {"gnn", HB_TAG('G','N','N',' ')}, /* Gumatj */
- {"gno", HB_TAG('G','O','N',' ')}, /* Northern Gondi */
- {"gog", HB_TAG('G','O','G',' ')}, /* Gogo */
- {"gon", HB_TAG('G','O','N',' ')}, /* Gondi [macrolanguage] */
- {"grt", HB_TAG('G','R','O',' ')}, /* Garo */
- {"gru", HB_TAG('S','O','G',' ')}, /* Sodo Gurage */
- {"gsw", HB_TAG('A','L','S',' ')}, /* Alsatian */
- {"gu", HB_TAG('G','U','J',' ')}, /* Gujarati */
- {"guc", HB_TAG('G','U','C',' ')}, /* Wayuu */
- {"guf", HB_TAG('G','U','F',' ')}, /* Gupapuyngu */
- {"guk", HB_TAG('G','M','Z',' ')}, /* Gumuz */
-/*{"guk", HB_TAG('G','U','K',' ')},*/ /* Gumuz (in SIL fonts) */
- {"guz", HB_TAG('G','U','Z',' ')}, /* Ekegusii/Gusii */
- {"gv", HB_TAG('M','N','X',' ')}, /* Manx */
- {"ha", HB_TAG('H','A','U',' ')}, /* Hausa */
- {"har", HB_TAG('H','R','I',' ')}, /* Harari */
- {"haw", HB_TAG('H','A','W',' ')}, /* Hawaiian */
- {"hay", HB_TAG('H','A','Y',' ')}, /* Haya */
- {"haz", HB_TAG('H','A','Z',' ')}, /* Hazaragi */
- {"he", HB_TAG('I','W','R',' ')}, /* Hebrew */
- {"hi", HB_TAG('H','I','N',' ')}, /* Hindi */
- {"hil", HB_TAG('H','I','L',' ')}, /* Hiligaynon */
- {"hlt", HB_TAG('Q','I','N',' ')}, /* Matu Chin */
- {"hmn", HB_TAG('H','M','N',' ')}, /* Hmong */
- {"hnd", HB_TAG('H','N','D',' ')}, /* [Southern] Hindko */
- {"hne", HB_TAG('C','H','H',' ')}, /* Chattisgarhi */
- {"hno", HB_TAG('H','N','D',' ')}, /* [Northern] Hindko */
- {"ho", HB_TAG('H','M','O',' ')}, /* Hiri Motu */
- {"hoc", HB_TAG('H','O',' ',' ')}, /* Ho */
- {"hoj", HB_TAG('H','A','R',' ')}, /* Harauti */
- {"hr", HB_TAG('H','R','V',' ')}, /* Croatian */
- {"hsb", HB_TAG('U','S','B',' ')}, /* Upper Sorbian */
- {"ht", HB_TAG('H','A','I',' ')}, /* Haitian/Haitian Creole */
- {"hu", HB_TAG('H','U','N',' ')}, /* Hungarian */
- {"hy", HB_TAG('H','Y','E',' ')}, /* Armenian */
- {"hz", HB_TAG('H','E','R',' ')}, /* Herero */
- {"ia", HB_TAG('I','N','A',' ')}, /* Interlingua (International Auxiliary Language Association) */
- {"iba", HB_TAG('I','B','A',' ')}, /* Iban */
- {"ibb", HB_TAG('I','B','B',' ')}, /* Ibibio */
- {"id", HB_TAG('I','N','D',' ')}, /* Indonesian */
- {"ie", HB_TAG('I','L','E',' ')}, /* Interlingue/Occidental */
- {"ig", HB_TAG('I','B','O',' ')}, /* Igbo */
- {"igb", HB_TAG('E','B','I',' ')}, /* Ebira */
- {"ii", HB_TAG('Y','I','M',' ')}, /* Yi Modern */
- {"ijc", HB_TAG('I','J','O',' ')}, /* Izon */
- {"ijo", HB_TAG('I','J','O',' ')}, /* Ijo [family] */
- {"ik", HB_TAG('I','P','K',' ')}, /* Inupiaq [macrolanguage] */
- {"ilo", HB_TAG('I','L','O',' ')}, /* Ilokano */
- {"inh", HB_TAG('I','N','G',' ')}, /* Ingush */
- {"io", HB_TAG('I','D','O',' ')}, /* Ido */
- {"is", HB_TAG('I','S','L',' ')}, /* Icelandic */
- {"it", HB_TAG('I','T','A',' ')}, /* Italian */
- {"iu", HB_TAG('I','N','U',' ')}, /* Inuktitut [macrolanguage] */
- {"ja", HB_TAG('J','A','N',' ')}, /* Japanese */
- {"jam", HB_TAG('J','A','M',' ')}, /* Jamaican Creole English */
- {"jbo", HB_TAG('J','B','O',' ')}, /* Lojban */
- {"jv", HB_TAG('J','A','V',' ')}, /* Javanese */
- {"ka", HB_TAG('K','A','T',' ')}, /* Georgian */
- {"kaa", HB_TAG('K','R','K',' ')}, /* Karakalpak */
- {"kab", HB_TAG('K','A','B','0')}, /* Kabyle */
- {"kam", HB_TAG('K','M','B',' ')}, /* Kamba (Kenya) */
- {"kar", HB_TAG('K','R','N',' ')}, /* Karen [family] */
- {"kat", HB_TAG('K','G','E',' ')}, /* Khutsuri Georgian */
- {"kbd", HB_TAG('K','A','B',' ')}, /* Kabardian */
- {"kde", HB_TAG('K','D','E',' ')}, /* Makonde */
- {"kdr", HB_TAG('K','R','M',' ')}, /* Karaim */
- {"kdt", HB_TAG('K','U','Y',' ')}, /* Kuy */
- {"kea", HB_TAG('K','E','A',' ')}, /* Kabuverdianu (Crioulo) */
- {"kek", HB_TAG('K','E','K',' ')}, /* Kekchi */
- {"kex", HB_TAG('K','K','N',' ')}, /* Kokni */
- {"kfa", HB_TAG('K','O','D',' ')}, /* Kodagu */
- {"kfr", HB_TAG('K','A','C',' ')}, /* Kachchi */
- {"kfx", HB_TAG('K','U','L',' ')}, /* Kulvi */
- {"kfy", HB_TAG('K','M','N',' ')}, /* Kumaoni */
- {"kg", HB_TAG('K','O','N',' ')}, /* Kongo [macrolanguage] */
- {"kha", HB_TAG('K','S','I',' ')}, /* Khasi */
- {"khb", HB_TAG('X','B','D',' ')}, /* Lü */
- {"kht", HB_TAG('K','H','N',' ')}, /* Khamti (Microsoft fonts) */
-/*{"kht", HB_TAG('K','H','T',' ')},*/ /* Khamti (OpenType spec and SIL fonts) */
- {"khw", HB_TAG('K','H','W',' ')}, /* Khowar */
- {"ki", HB_TAG('K','I','K',' ')}, /* Gikuyu/Kikuyu */
- {"kiu", HB_TAG('K','I','U',' ')}, /* Kirmanjki */
- {"kj", HB_TAG('K','U','A',' ')}, /* Kuanyama/Kwanyama */
- {"kjd", HB_TAG('K','J','D',' ')}, /* Southern Kiwai */
- {"kjh", HB_TAG('K','H','A',' ')}, /* Khakass */
- {"kjp", HB_TAG('K','J','P',' ')}, /* Pwo Eastern Karen */
- {"kk", HB_TAG('K','A','Z',' ')}, /* Kazakh */
- {"kl", HB_TAG('G','R','N',' ')}, /* Kalaallisut */
- {"kln", HB_TAG('K','A','L',' ')}, /* Kalenjin */
- {"km", HB_TAG('K','H','M',' ')}, /* Central Khmer */
- {"kmb", HB_TAG('M','B','N',' ')}, /* Kimbundu */
- {"kmw", HB_TAG('K','M','O',' ')}, /* Komo (Democratic Republic of Congo) */
- {"kn", HB_TAG('K','A','N',' ')}, /* Kannada */
- {"knn", HB_TAG('K','O','K',' ')}, /* Konkani */
- {"ko", HB_TAG('K','O','R',' ')}, /* Korean */
- {"koi", HB_TAG('K','O','P',' ')}, /* Komi-Permyak */
- {"kok", HB_TAG('K','O','K',' ')}, /* Konkani [macrolanguage] */
- {"kon", HB_TAG('K','O','N','0')}, /* Kongo */
- {"kos", HB_TAG('K','O','S',' ')}, /* Kosraean */
- {"kpe", HB_TAG('K','P','L',' ')}, /* Kpelle [macrolanguage] */
- {"kpv", HB_TAG('K','O','Z',' ')}, /* Komi-Zyrian */
- {"kpy", HB_TAG('K','Y','K',' ')}, /* Koryak */
- {"kqy", HB_TAG('K','R','T',' ')}, /* Koorete */
- {"kr", HB_TAG('K','N','R',' ')}, /* Kanuri [macrolanguage] */
- {"kri", HB_TAG('K','R','I',' ')}, /* Krio */
- {"krl", HB_TAG('K','R','L',' ')}, /* Karelian */
- {"kru", HB_TAG('K','U','U',' ')}, /* Kurukh */
- {"ks", HB_TAG('K','S','H',' ')}, /* Kashmiri */
- {"ksh", HB_TAG('K','S','H','0')}, /* Ripuarian, Kölsch */
-/*{"ksw", HB_TAG('K','R','N',' ')},*/ /* S'gaw Karen (Microsoft fonts?) */
- {"ksw", HB_TAG('K','S','W',' ')}, /* S'gaw Karen (OpenType spec and SIL fonts) */
- {"ktb", HB_TAG('K','E','B',' ')}, /* Kebena */
- {"ktu", HB_TAG('K','O','N',' ')}, /* Kikongo */
- {"ku", HB_TAG('K','U','R',' ')}, /* Kurdish [macrolanguage] */
- {"kum", HB_TAG('K','U','M',' ')}, /* Kumyk */
- {"kv", HB_TAG('K','O','M',' ')}, /* Komi [macrolanguage] */
- {"kvd", HB_TAG('K','U','I',' ')}, /* Kui (Indonesia) */
- {"kw", HB_TAG('C','O','R',' ')}, /* Cornish */
- {"kxc", HB_TAG('K','M','S',' ')}, /* Komso */
- {"kxu", HB_TAG('K','U','I',' ')}, /* Kui (India) */
- {"ky", HB_TAG('K','I','R',' ')}, /* Kirghiz/Kyrgyz */
- {"kyu", HB_TAG('K','Y','U',' ')}, /* Western Kayah */
- {"la", HB_TAG('L','A','T',' ')}, /* Latin */
- {"lad", HB_TAG('J','U','D',' ')}, /* Ladino */
- {"lb", HB_TAG('L','T','Z',' ')}, /* Luxembourgish */
- {"lbe", HB_TAG('L','A','K',' ')}, /* Lak */
- {"lbj", HB_TAG('L','D','K',' ')}, /* Ladakhi */
- {"lez", HB_TAG('L','E','Z',' ')}, /* Lezgi */
- {"lg", HB_TAG('L','U','G',' ')}, /* Ganda */
- {"li", HB_TAG('L','I','M',' ')}, /* Limburgan/Limburger/Limburgish */
- {"lif", HB_TAG('L','M','B',' ')}, /* Limbu */
- {"lij", HB_TAG('L','I','J',' ')}, /* Ligurian */
- {"lis", HB_TAG('L','I','S',' ')}, /* Lisu */
- {"ljp", HB_TAG('L','J','P',' ')}, /* Lampung Api */
- {"lki", HB_TAG('L','K','I',' ')}, /* Laki */
- {"lld", HB_TAG('L','A','D',' ')}, /* Ladin */
- {"lmn", HB_TAG('L','A','M',' ')}, /* Lambani */
- {"lmo", HB_TAG('L','M','O',' ')}, /* Lombard */
- {"ln", HB_TAG('L','I','N',' ')}, /* Lingala */
- {"lo", HB_TAG('L','A','O',' ')}, /* Lao */
- {"lom", HB_TAG('L','O','M',' ')}, /* Loma */
- {"lrc", HB_TAG('L','R','C',' ')}, /* Northern Luri */
- {"lt", HB_TAG('L','T','H',' ')}, /* Lithuanian */
- {"lu", HB_TAG('L','U','B',' ')}, /* Luba-Katanga */
- {"lua", HB_TAG('L','U','B',' ')}, /* Luba-Kasai */
- {"luo", HB_TAG('L','U','O',' ')}, /* Luo (Kenya and Tanzania) */
- {"lus", HB_TAG('M','I','Z',' ')}, /* Mizo */
- {"luy", HB_TAG('L','U','H',' ')}, /* Luyia/Oluluyia [macrolanguage] */
- {"luz", HB_TAG('L','R','C',' ')}, /* Southern Luri */
- {"lv", HB_TAG('L','V','I',' ')}, /* Latvian */
- {"lzz", HB_TAG('L','A','Z',' ')}, /* Laz */
- {"mad", HB_TAG('M','A','D',' ')}, /* Madurese */
- {"mag", HB_TAG('M','A','G',' ')}, /* Magahi */
- {"mai", HB_TAG('M','T','H',' ')}, /* Maithili */
- {"mak", HB_TAG('M','K','R',' ')}, /* Makasar */
- {"mam", HB_TAG('M','A','M',' ')}, /* Mam */
- {"man", HB_TAG('M','N','K',' ')}, /* Manding/Mandingo [macrolanguage] */
- {"mdc", HB_TAG('M','L','E',' ')}, /* Male (Papua New Guinea) */
- {"mdf", HB_TAG('M','O','K',' ')}, /* Moksha */
- {"mdr", HB_TAG('M','D','R',' ')}, /* Mandar */
- {"mdy", HB_TAG('M','L','E',' ')}, /* Male (Ethiopia) */
- {"men", HB_TAG('M','D','E',' ')}, /* Mende (Sierra Leone) */
- {"mer", HB_TAG('M','E','R',' ')}, /* Meru */
- {"mfe", HB_TAG('M','F','E',' ')}, /* Morisyen */
- {"mg", HB_TAG('M','L','G',' ')}, /* Malagasy [macrolanguage] */
- {"mh", HB_TAG('M','A','H',' ')}, /* Marshallese */
- {"mhr", HB_TAG('L','M','A',' ')}, /* Low Mari */
- {"mi", HB_TAG('M','R','I',' ')}, /* Maori */
- {"min", HB_TAG('M','I','N',' ')}, /* Minangkabau */
- {"mk", HB_TAG('M','K','D',' ')}, /* Macedonian */
- {"mku", HB_TAG('M','N','K',' ')}, /* Konyanka Maninka */
- {"mkw", HB_TAG('M','K','W',' ')}, /* Kituba (Congo) */
- {"ml", HB_TAG('M','L','R',' ')}, /* Malayalam */
- {"mlq", HB_TAG('M','N','K',' ')}, /* Western Maninkakan */
- {"mn", HB_TAG('M','N','G',' ')}, /* Mongolian [macrolanguage] */
- {"mnc", HB_TAG('M','C','H',' ')}, /* Manchu */
- {"mni", HB_TAG('M','N','I',' ')}, /* Manipuri */
- {"mnk", HB_TAG('M','N','D',' ')}, /* Mandinka */
- {"mns", HB_TAG('M','A','N',' ')}, /* Mansi */
- {"mnw", HB_TAG('M','O','N',' ')}, /* Mon */
- {"mo", HB_TAG('M','O','L',' ')}, /* Moldavian */
- {"moh", HB_TAG('M','O','H',' ')}, /* Mohawk */
- {"mos", HB_TAG('M','O','S',' ')}, /* Mossi */
- {"mpe", HB_TAG('M','A','J',' ')}, /* Majang */
- {"mr", HB_TAG('M','A','R',' ')}, /* Marathi */
- {"mrh", HB_TAG('Q','I','N',' ')}, /* Mara Chin */
- {"mrj", HB_TAG('H','M','A',' ')}, /* High Mari */
- {"ms", HB_TAG('M','L','Y',' ')}, /* Malay [macrolanguage] */
- {"msc", HB_TAG('M','N','K',' ')}, /* Sankaran Maninka */
- {"mt", HB_TAG('M','T','S',' ')}, /* Maltese */
- {"mtr", HB_TAG('M','A','W',' ')}, /* Mewari */
- {"mus", HB_TAG('M','U','S',' ')}, /* Creek */
- {"mve", HB_TAG('M','A','W',' ')}, /* Marwari (Pakistan) */
- {"mwk", HB_TAG('M','N','K',' ')}, /* Kita Maninkakan */
- {"mwl", HB_TAG('M','W','L',' ')}, /* Mirandese */
- {"mwr", HB_TAG('M','A','W',' ')}, /* Marwari [macrolanguage] */
- {"mww", HB_TAG('M','W','W',' ')}, /* Hmong Daw */
- {"my", HB_TAG('B','R','M',' ')}, /* Burmese */
- {"mym", HB_TAG('M','E','N',' ')}, /* Me'en */
- {"myn", HB_TAG('M','Y','N',' ')}, /* Mayan */
- {"myq", HB_TAG('M','N','K',' ')}, /* Forest Maninka (retired code) */
- {"myv", HB_TAG('E','R','Z',' ')}, /* Erzya */
- {"mzn", HB_TAG('M','Z','N',' ')}, /* Mazanderani */
- {"na", HB_TAG('N','A','U',' ')}, /* Nauru */
- {"nag", HB_TAG('N','A','G',' ')}, /* Naga-Assamese */
- {"nah", HB_TAG('N','A','H',' ')}, /* Nahuatl [family] */
- {"nap", HB_TAG('N','A','P',' ')}, /* Neapolitan */
- {"nb", HB_TAG('N','O','R',' ')}, /* Norwegian Bokmål */
- {"nco", HB_TAG('S','I','B',' ')}, /* Sibe */
- {"nd", HB_TAG('N','D','B',' ')}, /* [North] Ndebele */
- {"ndc", HB_TAG('N','D','C',' ')}, /* Ndau */
- {"nds", HB_TAG('N','D','S',' ')}, /* Low German/Low Saxon */
- {"ne", HB_TAG('N','E','P',' ')}, /* Nepali */
- {"new", HB_TAG('N','E','W',' ')}, /* Newari */
- {"ng", HB_TAG('N','D','G',' ')}, /* Ndonga */
- {"nga", HB_TAG('N','G','A',' ')}, /* Ngabaka */
- {"ngl", HB_TAG('L','M','W',' ')}, /* Lomwe */
- {"ngo", HB_TAG('S','X','T',' ')}, /* Sutu */
- {"niu", HB_TAG('N','I','U',' ')}, /* Niuean */
- {"niv", HB_TAG('G','I','L',' ')}, /* Gilyak */
- {"nl", HB_TAG('N','L','D',' ')}, /* Dutch */
- {"nn", HB_TAG('N','Y','N',' ')}, /* Norwegian Nynorsk */
- {"no", HB_TAG('N','O','R',' ')}, /* Norwegian [macrolanguage] */
- {"nod", HB_TAG('N','T','A',' ')}, /* Northern Thai */
- {"noe", HB_TAG('N','O','E',' ')}, /* Nimadi */
- {"nog", HB_TAG('N','O','G',' ')}, /* Nogai */
- {"nov", HB_TAG('N','O','V',' ')}, /* Novial */
- {"nqo", HB_TAG('N','K','O',' ')}, /* N'Ko */
- {"nr", HB_TAG('N','D','B',' ')}, /* [South] Ndebele */
- {"nsk", HB_TAG('N','A','S',' ')}, /* Naskapi */
- {"nso", HB_TAG('S','O','T',' ')}, /* [Northern] Sotho */
- {"nv", HB_TAG('N','A','V',' ')}, /* Navajo */
- {"ny", HB_TAG('C','H','I',' ')}, /* Chewa/Chichwa/Nyanja */
- {"nym", HB_TAG('N','Y','M',' ')}, /* Nyamwezi */
- {"nyn", HB_TAG('N','K','L',' ')}, /* Nyankole */
- {"oc", HB_TAG('O','C','I',' ')}, /* Occitan (post 1500) */
- {"oj", HB_TAG('O','J','B',' ')}, /* Ojibwa [macrolanguage] */
- {"ojs", HB_TAG('O','C','R',' ')}, /* Oji-Cree */
- {"okm", HB_TAG('K','O','H',' ')}, /* Korean Old Hangul */
- {"om", HB_TAG('O','R','O',' ')}, /* Oromo [macrolanguage] */
- {"or", HB_TAG('O','R','I',' ')}, /* Oriya */
- {"os", HB_TAG('O','S','S',' ')}, /* Ossetian */
- {"pa", HB_TAG('P','A','N',' ')}, /* Panjabi */
- {"pag", HB_TAG('P','A','G',' ')}, /* Pangasinan */
- {"pam", HB_TAG('P','A','M',' ')}, /* Kapampangan/Pampanga */
- {"pap", HB_TAG('P','A','P','0')}, /* Papiamento */
- {"pau", HB_TAG('P','A','U',' ')}, /* Palauan */
- {"pcc", HB_TAG('P','C','C',' ')}, /* Bouyei */
- {"pcd", HB_TAG('P','C','D',' ')}, /* Picard */
- {"pce", HB_TAG('P','L','G',' ')}, /* [Ruching] Palaung */
- {"pck", HB_TAG('Q','I','N',' ')}, /* Paite Chin */
- {"pdc", HB_TAG('P','D','C',' ')}, /* Pennsylvania German */
- {"pes", HB_TAG('F','A','R',' ')}, /* Iranian Persian */
- {"phk", HB_TAG('P','H','K',' ')}, /* Phake */
- {"pi", HB_TAG('P','A','L',' ')}, /* Pali */
- {"pih", HB_TAG('P','I','H',' ')}, /* Pitcairn-Norfolk */
- {"pl", HB_TAG('P','L','K',' ')}, /* Polish */
- {"pll", HB_TAG('P','L','G',' ')}, /* [Shwe] Palaung */
- {"plp", HB_TAG('P','A','P',' ')}, /* Palpa */
- {"pms", HB_TAG('P','M','S',' ')}, /* Piemontese */
- {"pnb", HB_TAG('P','N','B',' ')}, /* Western Panjabi */
- {"poh", HB_TAG('P','O','H',' ')}, /* Pocomchi */
- {"pon", HB_TAG('P','O','N',' ')}, /* Pohnpeian */
- {"prs", HB_TAG('D','R','I',' ')}, /* Afghan Persian/Dari */
- {"ps", HB_TAG('P','A','S',' ')}, /* Pashto/Pushto [macrolanguage] */
- {"pt", HB_TAG('P','T','G',' ')}, /* Portuguese */
- {"pwo", HB_TAG('P','W','O',' ')}, /* Pwo Western Karen */
- {"qu", HB_TAG('Q','U','Z',' ')}, /* Quechua [macrolanguage] */
- {"quc", HB_TAG('Q','U','C',' ')}, /* K'iche'/Quiché */
- {"quh", HB_TAG('Q','U','H',' ')}, /* Quechua (Bolivia) */
- {"quz", HB_TAG('Q','U','Z',' ')}, /* Cusco Quechua */
- {"qvi", HB_TAG('Q','V','I',' ')}, /* Quechua (Ecuador) */
- {"qwh", HB_TAG('Q','W','H',' ')}, /* Quechua (Peru) */
- {"raj", HB_TAG('R','A','J',' ')}, /* Rajasthani [macrolanguage] */
- {"rar", HB_TAG('R','A','R',' ')}, /* Rarotongan */
- {"rbb", HB_TAG('P','L','G',' ')}, /* Rumai Palaung */
- {"rej", HB_TAG('R','E','J',' ')}, /* Rejang */
- {"ria", HB_TAG('R','I','A',' ')}, /* Riang (India) */
- {"rif", HB_TAG('R','I','F',' ')}, /* Tarifit */
- {"ril", HB_TAG('R','I','A',' ')}, /* Riang (Myanmar) */
- {"rit", HB_TAG('R','I','T',' ')}, /* Ritarungo */
- {"rki", HB_TAG('A','R','K',' ')}, /* Rakhine */
- {"rkw", HB_TAG('R','K','W',' ')}, /* Arakwal */
- {"rm", HB_TAG('R','M','S',' ')}, /* Romansh */
- {"rmy", HB_TAG('R','M','Y',' ')}, /* Vlax Romani */
- {"rn", HB_TAG('R','U','N',' ')}, /* Rundi */
- {"ro", HB_TAG('R','O','M',' ')}, /* Romanian */
- {"rom", HB_TAG('R','O','Y',' ')}, /* Romany [macrolanguage] */
- {"rtm", HB_TAG('R','T','M',' ')}, /* Rotuman */
- {"ru", HB_TAG('R','U','S',' ')}, /* Russian */
- {"rue", HB_TAG('R','S','Y',' ')}, /* Rusyn */
- {"rup", HB_TAG('R','U','P',' ')}, /* Aromanian/Arumanian/Macedo-Romanian */
- {"rw", HB_TAG('R','U','A',' ')}, /* Kinyarwanda */
- {"rwr", HB_TAG('M','A','W',' ')}, /* Marwari (India) */
- {"sa", HB_TAG('S','A','N',' ')}, /* Sanskrit */
- {"sah", HB_TAG('Y','A','K',' ')}, /* Yakut */
- {"sam", HB_TAG('P','A','A',' ')}, /* Palestinian Aramaic */
- {"sas", HB_TAG('S','A','S',' ')}, /* Sasak */
- {"sat", HB_TAG('S','A','T',' ')}, /* Santali */
- {"sc", HB_TAG('S','R','D',' ')}, /* Sardinian [macrolanguage] */
- {"sck", HB_TAG('S','A','D',' ')}, /* Sadri */
- {"scn", HB_TAG('S','C','N',' ')}, /* Sicilian */
- {"sco", HB_TAG('S','C','O',' ')}, /* Scots */
- {"scs", HB_TAG('S','L','A',' ')}, /* [North] Slavey */
- {"sd", HB_TAG('S','N','D',' ')}, /* Sindhi */
- {"se", HB_TAG('N','S','M',' ')}, /* Northern Sami */
- {"seh", HB_TAG('S','N','A',' ')}, /* Sena */
- {"sel", HB_TAG('S','E','L',' ')}, /* Selkup */
- {"sez", HB_TAG('Q','I','N',' ')}, /* Senthang Chin */
- {"sg", HB_TAG('S','G','O',' ')}, /* Sango */
- {"sga", HB_TAG('S','G','A',' ')}, /* Old Irish (to 900) */
- {"sgs", HB_TAG('S','G','S',' ')}, /* Samogitian */
- {"sgw", HB_TAG('C','H','G',' ')}, /* Sebat Bet Gurage */
-/*{"sgw", HB_TAG('S','G','W',' ')},*/ /* Sebat Bet Gurage (in SIL fonts) */
- {"shi", HB_TAG('S','H','I',' ')}, /* Tachelhit */
- {"shn", HB_TAG('S','H','N',' ')}, /* Shan */
- {"si", HB_TAG('S','N','H',' ')}, /* Sinhala */
- {"sid", HB_TAG('S','I','D',' ')}, /* Sidamo */
- {"sjd", HB_TAG('K','S','M',' ')}, /* Kildin Sami */
- {"sk", HB_TAG('S','K','Y',' ')}, /* Slovak */
- {"skr", HB_TAG('S','R','K',' ')}, /* Seraiki */
- {"sl", HB_TAG('S','L','V',' ')}, /* Slovenian */
- {"sm", HB_TAG('S','M','O',' ')}, /* Samoan */
- {"sma", HB_TAG('S','S','M',' ')}, /* Southern Sami */
- {"smj", HB_TAG('L','S','M',' ')}, /* Lule Sami */
- {"smn", HB_TAG('I','S','M',' ')}, /* Inari Sami */
- {"sms", HB_TAG('S','K','S',' ')}, /* Skolt Sami */
- {"sn", HB_TAG('S','N','A','0')}, /* Shona */
- {"snk", HB_TAG('S','N','K',' ')}, /* Soninke */
- {"so", HB_TAG('S','M','L',' ')}, /* Somali */
- {"sop", HB_TAG('S','O','P',' ')}, /* Songe */
- {"sq", HB_TAG('S','Q','I',' ')}, /* Albanian [macrolanguage] */
- {"sr", HB_TAG('S','R','B',' ')}, /* Serbian */
- {"srr", HB_TAG('S','R','R',' ')}, /* Serer */
- {"ss", HB_TAG('S','W','Z',' ')}, /* Swati */
- {"st", HB_TAG('S','O','T',' ')}, /* [Southern] Sotho */
- {"stq", HB_TAG('S','T','Q',' ')}, /* Saterfriesisch */
- {"stv", HB_TAG('S','I','G',' ')}, /* Silt'e */
- {"su", HB_TAG('S','U','N',' ')}, /* Sundanese */
- {"suk", HB_TAG('S','U','K',' ')}, /* Sukama */
- {"suq", HB_TAG('S','U','R',' ')}, /* Suri */
- {"sv", HB_TAG('S','V','E',' ')}, /* Swedish */
- {"sva", HB_TAG('S','V','A',' ')}, /* Svan */
- {"sw", HB_TAG('S','W','K',' ')}, /* Swahili [macrolanguage] */
- {"swb", HB_TAG('C','M','R',' ')}, /* Comorian */
- {"swh", HB_TAG('S','W','K',' ')}, /* Kiswahili/Swahili */
- {"swv", HB_TAG('M','A','W',' ')}, /* Shekhawati */
- {"sxu", HB_TAG('S','X','U',' ')}, /* Upper Saxon */
- {"syc", HB_TAG('S','Y','R',' ')}, /* Classical Syriac */
- {"syl", HB_TAG('S','Y','L',' ')}, /* Sylheti */
- {"syr", HB_TAG('S','Y','R',' ')}, /* Syriac [macrolanguage] */
- {"szl", HB_TAG('S','Z','L',' ')}, /* Silesian */
- {"ta", HB_TAG('T','A','M',' ')}, /* Tamil */
- {"tab", HB_TAG('T','A','B',' ')}, /* Tabasaran */
- {"tcp", HB_TAG('Q','I','N',' ')}, /* Tawr Chin */
- {"tcy", HB_TAG('T','U','L',' ')}, /* Tulu */
- {"tcz", HB_TAG('Q','I','N',' ')}, /* Thado Chin */
- {"tdd", HB_TAG('T','D','D',' ')}, /* Tai Nüa */
- {"te", HB_TAG('T','E','L',' ')}, /* Telugu */
- {"tem", HB_TAG('T','M','N',' ')}, /* Temne */
- {"tet", HB_TAG('T','E','T',' ')}, /* Tetum */
- {"tg", HB_TAG('T','A','J',' ')}, /* Tajik */
- {"th", HB_TAG('T','H','A',' ')}, /* Thai */
- {"ti", HB_TAG('T','G','Y',' ')}, /* Tigrinya */
- {"tig", HB_TAG('T','G','R',' ')}, /* Tigre */
- {"tiv", HB_TAG('T','I','V',' ')}, /* Tiv */
- {"tk", HB_TAG('T','K','M',' ')}, /* Turkmen */
- {"tl", HB_TAG('T','G','L',' ')}, /* Tagalog */
- {"tmh", HB_TAG('T','M','H',' ')}, /* Tamashek */
- {"tn", HB_TAG('T','N','A',' ')}, /* Tswana */
- {"to", HB_TAG('T','G','N',' ')}, /* Tonga (Tonga Islands) */
- {"tod", HB_TAG('T','O','D','0')}, /* Toma */
- {"toi", HB_TAG('T','N','G',' ')}, /* Tonga */
- {"tpi", HB_TAG('T','P','I',' ')}, /* Tok Pisin */
- {"tr", HB_TAG('T','R','K',' ')}, /* Turkish */
- {"tru", HB_TAG('T','U','A',' ')}, /* Turoyo Aramaic */
- {"ts", HB_TAG('T','S','G',' ')}, /* Tsonga */
- {"tt", HB_TAG('T','A','T',' ')}, /* Tatar */
- {"tum", HB_TAG('T','U','M',' ')}, /* Tumbuka */
- {"tvl", HB_TAG('T','V','L',' ')}, /* Tuvalu */
- {"tw", HB_TAG('T','W','I',' ')}, /* Twi */
- {"ty", HB_TAG('T','H','T',' ')}, /* Tahitian */
- {"tyv", HB_TAG('T','U','V',' ')}, /* Tuvin */
- {"tyz", HB_TAG('T','Y','Z',' ')}, /* Tày */
- {"tzm", HB_TAG('T','Z','M',' ')}, /* Central Atlas Tamazight */
- {"tzo", HB_TAG('T','Z','O',' ')}, /* Tzotzil */
- {"udm", HB_TAG('U','D','M',' ')}, /* Udmurt */
- {"ug", HB_TAG('U','Y','G',' ')}, /* Uighur */
- {"uk", HB_TAG('U','K','R',' ')}, /* Ukrainian */
- {"umb", HB_TAG('U','M','B',' ')}, /* Umbundu */
- {"unr", HB_TAG('M','U','N',' ')}, /* Mundari */
- {"ur", HB_TAG('U','R','D',' ')}, /* Urdu */
- {"uz", HB_TAG('U','Z','B',' ')}, /* Uzbek [macrolanguage] */
- {"uzn", HB_TAG('U','Z','B',' ')}, /* Northern Uzbek */
- {"uzs", HB_TAG('U','Z','B',' ')}, /* Southern Uzbek */
- {"ve", HB_TAG('V','E','N',' ')}, /* Venda */
- {"vec", HB_TAG('V','E','C',' ')}, /* Venetian */
- {"vi", HB_TAG('V','I','T',' ')}, /* Vietnamese */
- {"vls", HB_TAG('F','L','E',' ')}, /* Vlaams */
- {"vmw", HB_TAG('M','A','K',' ')}, /* Makhuwa */
- {"vo", HB_TAG('V','O','L',' ')}, /* Volapük */
- {"vro", HB_TAG('V','R','O',' ')}, /* Võro */
- {"wa", HB_TAG('W','L','N',' ')}, /* Walloon */
- {"war", HB_TAG('W','A','R',' ')}, /* Waray (Philippines) */
- {"wbm", HB_TAG('W','A',' ',' ')}, /* Wa */
- {"wbr", HB_TAG('W','A','G',' ')}, /* Wagdi */
- {"wle", HB_TAG('S','I','G',' ')}, /* Wolane */
- {"wo", HB_TAG('W','L','F',' ')}, /* Wolof */
- {"wry", HB_TAG('M','A','W',' ')}, /* Merwari */
- {"wtm", HB_TAG('W','T','M',' ')}, /* Mewati */
- {"xal", HB_TAG('K','L','M',' ')}, /* Kalmyk */
- {"xan", HB_TAG('S','E','K',' ')}, /* Sekota */
- {"xh", HB_TAG('X','H','S',' ')}, /* Xhosa */
- {"xjb", HB_TAG('X','J','B',' ')}, /* Minjangbal */
- {"xog", HB_TAG('X','O','G',' ')}, /* Soga */
- {"xom", HB_TAG('K','M','O',' ')}, /* Komo (Sudan) */
- {"xpe", HB_TAG('X','P','E',' ')}, /* Kpelle (Liberia) */
- {"xsl", HB_TAG('S','S','L',' ')}, /* South Slavey */
- {"xst", HB_TAG('S','I','G',' ')}, /* Silt'e (retired code) */
- {"xwo", HB_TAG('T','O','D',' ')}, /* Written Oirat (Todo) */
- {"yao", HB_TAG('Y','A','O',' ')}, /* Yao */
- {"yap", HB_TAG('Y','A','P',' ')}, /* Yapese */
- {"yi", HB_TAG('J','I','I',' ')}, /* Yiddish [macrolanguage] */
- {"yo", HB_TAG('Y','B','A',' ')}, /* Yoruba */
- {"yos", HB_TAG('Q','I','N',' ')}, /* Yos, deprecated by IANA in favor of Zou [zom] */
- {"yso", HB_TAG('N','I','S',' ')}, /* Nisi (China) */
- {"za", HB_TAG('Z','H','A',' ')}, /* Chuang/Zhuang [macrolanguage] */
- {"zea", HB_TAG('Z','E','A',' ')}, /* Zeeuws */
- {"zgh", HB_TAG('Z','G','H',' ')}, /* Standard Morrocan Tamazigh */
- {"zne", HB_TAG('Z','N','D',' ')}, /* Zande */
- {"zom", HB_TAG('Q','I','N',' ')}, /* Zou */
- {"zu", HB_TAG('Z','U','L',' ')}, /* Zulu */
- {"zum", HB_TAG('L','R','C',' ')}, /* Kumzari */
- {"zza", HB_TAG('Z','Z','A',' ')}, /* Zazaki */
-
- /* The corresponding languages IDs for the following IDs are unclear,
- * overlap, or are architecturally weird. Needs more research. */
-
-/*{"chp", HB_TAG('S','A','Y',' ')},*/ /* Sayisi */
-/*{"cwd", HB_TAG('T','C','R',' ')},*/ /* TH-Cree */
-/*{"emk", HB_TAG('E','M','K',' ')},*/ /* Eastern Maninkakan */
-/*{"krc", HB_TAG('B','A','L',' ')},*/ /* Balkar */
-/*{"??", HB_TAG('B','C','R',' ')},*/ /* Bible Cree */
-/*{"zh?", HB_TAG('C','H','N',' ')},*/ /* Chinese (seen in Microsoft fonts) */
-/*{"ar-Syrc?", HB_TAG('G','A','R',' ')},*/ /* Garshuni */
-/*{"hy?", HB_TAG('H','Y','E','0')},*/ /* Armenian East (ISO 639-3 hye according to Microsoft, but that’s equivalent to ISO 639-1 hy) */
-/*{"ga-Latg?/" HB_TAG('I','R','T',' ')},*/ /* Irish Traditional */
-/*{"krc", HB_TAG('K','A','R',' ')},*/ /* Karachay */
-/*{"ka-Geok?", HB_TAG('K','G','E',' ')},*/ /* Khutsuri Georgian */
-/*{"kca", HB_TAG('K','H','K',' ')},*/ /* Khanty-Kazim */
-/*{"kca", HB_TAG('K','H','S',' ')},*/ /* Khanty-Shurishkar */
-/*{"kca", HB_TAG('K','H','V',' ')},*/ /* Khanty-Vakhi */
-/*{"kqs, kss", HB_TAG('K','I','S',' ')},*/ /* Kisii */
-/*{"lua", HB_TAG('L','U','A',' ')},*/ /* Luba-Lulua */
-/*{"mlq", HB_TAG('M','L','N',' ')},*/ /* Malinke */
-/*{"nso", HB_TAG('N','S','O',' ')},*/ /* Sotho, Northern */
-/*{"??", HB_TAG('M','A','L',' ')},*/ /* Malayalam Traditional */
-/*{"csw", HB_TAG('N','C','R',' ')},*/ /* N-Cree */
-/*{"csw", HB_TAG('N','H','C',' ')},*/ /* Norway House Cree */
-/*{"el-polyton", HB_TAG('P','G','R',' ')},*/ /* Polytonic Greek */
-/*{"bgr, cnh, cnw, czt, sez, tcp, csy, ctd, flm, pck, tcz, zom, cmr, dao, hlt, cka, cnk, mrh, mwg, cbl, cnb, csh", HB_TAG('Q','I','N',' ')},*/ /* Chin */
-/*{"??", HB_TAG('Y','I','C',' ')},*/ /* Yi Classic */
-/*{"zh-Latn-pinyin", HB_TAG('Z','H','P',' ')},*/ /* Chinese Phonetic */
-};
-
-typedef struct {
- char language[11];
- hb_tag_t tag;
-} LangTagLong;
-static const LangTagLong ot_languages_zh[] = {
- /* Store longest-first, if one is a prefix of another. */
- {"zh-cn", HB_TAG('Z','H','S',' ')}, /* Chinese (China) */
- {"zh-hk", HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */
- {"zh-mo", HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */
- {"zh-sg", HB_TAG('Z','H','S',' ')}, /* Chinese (Singapore) */
- {"zh-tw", HB_TAG('Z','H','T',' ')}, /* Chinese (Taiwan) */
- {"zh-hans", HB_TAG('Z','H','S',' ')}, /* Chinese (Simplified) */
- {"zh-hant-hk",HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */
- {"zh-hant-mo",HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */
- {"zh-hant", HB_TAG('Z','H','T',' ')}, /* Chinese (Traditional) */
-};
-
static int
lang_compare_first_component (const void *pa,
const void *pb)
@@ -895,6 +189,21 @@ lang_compare_first_component (const void *pa,
return strncmp (a, b, MAX (da, db));
}
+static bool
+subtag_matches (const char *lang_str,
+ const char *limit,
+ const char *subtag)
+{
+ do {
+ const char *s = strstr (lang_str, subtag);
+ if (!s || s >= limit)
+ return false;
+ if (!ISALNUM (s[strlen (subtag)]))
+ return true;
+ lang_str = s + strlen (subtag);
+ } while (true);
+}
+
static hb_bool_t
lang_matches (const char *lang_str, const char *spec)
{
@@ -904,106 +213,186 @@ lang_matches (const char *lang_str, const char *spec)
(lang_str[len] == '\0' || lang_str[len] == '-');
}
+typedef struct {
+ char language[4];
+ hb_tag_t tags[HB_OT_MAX_TAGS_PER_LANGUAGE];
+} LangTag;
+
+#include "hb-ot-tag-table.hh"
+
+/* The corresponding languages IDs for the following IDs are unclear,
+ * overlap, or are architecturally weird. Needs more research. */
+
+/*{"??", {HB_TAG('B','C','R',' ')}},*/ /* Bible Cree */
+/*{"zh?", {HB_TAG('C','H','N',' ')}},*/ /* Chinese (seen in Microsoft fonts) */
+/*{"ar-Syrc?", {HB_TAG('G','A','R',' ')}},*/ /* Garshuni */
+/*{"??", {HB_TAG('N','G','R',' ')}},*/ /* Nagari */
+/*{"??", {HB_TAG('Y','I','C',' ')}},*/ /* Yi Classic */
+/*{"zh?", {HB_TAG('Z','H','P',' ')}},*/ /* Chinese Phonetic */
+
hb_tag_t
hb_ot_tag_from_language (hb_language_t language)
{
- const char *lang_str, *s;
+ unsigned int count = 1;
+ hb_tag_t tags[1];
+ hb_ot_tags_from_script_and_language (HB_SCRIPT_UNKNOWN, language, nullptr, nullptr, &count, tags);
+ return count > 0 ? tags[0] : HB_OT_TAG_DEFAULT_LANGUAGE;
+}
- if (language == HB_LANGUAGE_INVALID)
- return HB_OT_TAG_DEFAULT_LANGUAGE;
+static void
+hb_ot_tags_from_language (const char *lang_str,
+ const char *limit,
+ unsigned int *count,
+ hb_tag_t *tags)
+{
+ const char *s;
- lang_str = hb_language_to_string (language);
+ /* Check for matches of multiple subtags. */
+ if (hb_ot_tags_from_complex_language (lang_str, limit, count, tags))
+ return;
- s = strstr (lang_str, "x-hbot");
- if (s) {
- char tag[4];
- int i;
- s += 6;
- for (i = 0; i < 4 && ISALNUM (s[i]); i++)
- tag[i] = TOUPPER (s[i]);
- if (i) {
- for (; i < 4; i++)
- tag[i] = ' ';
- return HB_TAG (tag[0], tag[1], tag[2], tag[3]);
+ /* Find a language matching in the first component. */
+ s = strchr (lang_str, '-');
+ {
+ const LangTag *lang_tag;
+ if (s && limit - lang_str >= 6)
+ {
+ const char *extlang_end = strchr (s + 1, '-');
+ /* If there is an extended language tag, use it. */
+ if (3 == (extlang_end ? extlang_end - s - 1 : strlen (s + 1)) &&
+ ISALPHA (s[1]))
+ lang_str = s + 1;
+ }
+ lang_tag = (LangTag *) bsearch (lang_str, ot_languages,
+ ARRAY_LENGTH (ot_languages), sizeof (LangTag),
+ lang_compare_first_component);
+ if (lang_tag)
+ {
+ unsigned int i;
+ for (i = 0; i < *count && lang_tag->tags[i] != HB_TAG_NONE; i++)
+ tags[i] = lang_tag->tags[i];
+ *count = i;
+ return;
}
}
- /*
- * "fonipa" is a variant tag in BCP-47, meaning the International Phonetic Alphabet.
- * It can be applied to any language.
- */
- if (strstr (lang_str, "-fonipa")) {
- return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions */
- }
-
- /*
- * "fonnapa" is a variant tag in BCP-47, meaning the North American Phonetic Alphabet
- * also known as Americanist Phonetic Notation. It can be applied to any language.
- */
- if (strstr (lang_str, "-fonnapa")) {
- return HB_TAG('A','P','P','H'); /* Phonetic transcription—Americanist conventions */
+ if (!s)
+ s = lang_str + strlen (lang_str);
+ if (s - lang_str == 3) {
+ /* Assume it's ISO-639-3 and upper-case and use it. */
+ tags[0] = hb_tag_from_string (lang_str, s - lang_str) & ~0x20202000u;
+ *count = 1;
+ return;
}
- /*
- * "Syre" is a BCP-47 script tag, meaning the Estrangela variant of the Syriac script.
- * It can be applied to any language.
- */
- if (strstr (lang_str, "-syre")) {
- return HB_TAG('S','Y','R','E'); /* Estrangela Syriac */
- }
+ *count = 0;
+}
- /*
- * "Syrj" is a BCP-47 script tag, meaning the Western variant of the Syriac script.
- * It can be applied to any language.
- */
- if (strstr (lang_str, "-syrj")) {
- return HB_TAG('S','Y','R','J'); /* Western Syriac */
+static bool
+parse_private_use_subtag (const char *private_use_subtag,
+ unsigned int *count,
+ hb_tag_t *tags,
+ const char *prefix,
+ unsigned char (*normalize) (unsigned char))
+{
+ if (private_use_subtag && count && tags && *count)
+ {
+ const char *s = strstr (private_use_subtag, prefix);
+ if (s)
+ {
+ char tag[4];
+ int i;
+ s += strlen (prefix);
+ for (i = 0; i < 4 && ISALNUM (s[i]); i++)
+ tag[i] = normalize (s[i]);
+ if (i)
+ {
+ for (; i < 4; i++)
+ tag[i] = ' ';
+ tags[0] = HB_TAG (tag[0], tag[1], tag[2], tag[3]);
+ if ((tags[0] & 0xDFDFDFDF) == HB_OT_TAG_DEFAULT_SCRIPT)
+ tags[0] ^= ~0xDFDFDFDF;
+ *count = 1;
+ return false;
+ }
+ }
}
+ return true;
+}
- /*
- * "Syrn" is a BCP-47 script tag, meaning the Eastern variant of the Syriac script.
- * It can be applied to any language.
- */
- if (strstr (lang_str, "-syrn")) {
- return HB_TAG('S','Y','R','N'); /* Eastern Syriac */
- }
+/**
+ * hb_ot_tags_from_script_and_language:
+ * @script: an #hb_script_t to convert.
+ * @language: an #hb_language_t to convert.
+ * @script_count: (allow-none): maximum number of script tags to retrieve (IN)
+ * and actual number of script tags retrieved (OUT)
+ * @script_tags: (out) (allow-none): array of size at least @script_count to store the
+ * script tag results
+ * @language_count: (allow-none): maximum number of language tags to retrieve
+ * (IN) and actual number of language tags retrieved (OUT)
+ * @language_tags: (out) (allow-none): array of size at least @language_count to store
+ * the language tag results
+ *
+ * Converts an #hb_script_t and an #hb_language_t to script and language tags.
+ *
+ * Since: 2.0.0
+ **/
+void
+hb_ot_tags_from_script_and_language (hb_script_t script,
+ hb_language_t language,
+ unsigned int *script_count /* IN/OUT */,
+ hb_tag_t *script_tags /* OUT */,
+ unsigned int *language_count /* IN/OUT */,
+ hb_tag_t *language_tags /* OUT */)
+{
+ bool needs_script = true;
- /* Find a language matching in the first component */
+ if (language == HB_LANGUAGE_INVALID)
{
- const LangTag *lang_tag;
- lang_tag = (LangTag *) bsearch (lang_str, ot_languages,
- ARRAY_LENGTH (ot_languages), sizeof (LangTag),
- lang_compare_first_component);
- if (lang_tag)
- return lang_tag->tag;
+ if (language_count && language_tags && *language_count)
+ *language_count = 0;
}
-
- /* Otherwise, check the Chinese ones */
- if (0 == lang_compare_first_component (lang_str, "zh"))
+ else
{
- unsigned int i;
+ const char *lang_str, *s, *limit, *private_use_subtag;
+ bool needs_language;
- for (i = 0; i < ARRAY_LENGTH (ot_languages_zh); i++)
+ lang_str = hb_language_to_string (language);
+ limit = nullptr;
+ private_use_subtag = nullptr;
+ if (lang_str[0] == 'x' && lang_str[1] == '-')
{
- const LangTagLong *lang_tag;
- lang_tag = &ot_languages_zh[i];
- if (lang_matches (lang_str, lang_tag->language))
- return lang_tag->tag;
+ private_use_subtag = lang_str;
+ } else {
+ for (s = lang_str + 1; *s; s++)
+ {
+ if (s[-1] == '-' && s[1] == '-')
+ {
+ if (s[0] == 'x')
+ {
+ private_use_subtag = s;
+ if (!limit)
+ limit = s - 1;
+ break;
+ } else if (!limit)
+ {
+ limit = s - 1;
+ }
+ }
+ }
+ if (!limit)
+ limit = s;
}
- /* Otherwise just return 'ZHS ' */
- return HB_TAG('Z','H','S',' ');
- }
+ needs_script = parse_private_use_subtag (private_use_subtag, script_count, script_tags, "-hbsc", TOLOWER);
+ needs_language = parse_private_use_subtag (private_use_subtag, language_count, language_tags, "-hbot", TOUPPER);
- s = strchr (lang_str, '-');
- if (!s)
- s = lang_str + strlen (lang_str);
- if (s - lang_str == 3) {
- /* Assume it's ISO-639-3 and upper-case and use it. */
- return hb_tag_from_string (lang_str, s - lang_str) & ~0x20202000u;
+ if (needs_language && language_count && language_tags && *language_count)
+ hb_ot_tags_from_language (lang_str, limit, language_count, language_tags);
}
- return HB_OT_TAG_DEFAULT_LANGUAGE;
+ if (needs_script && script_count && script_tags && *script_count)
+ hb_ot_all_tags_from_script (script, script_count, script_tags);
}
/**
@@ -1023,36 +412,16 @@ hb_ot_tag_to_language (hb_tag_t tag)
if (tag == HB_OT_TAG_DEFAULT_LANGUAGE)
return nullptr;
- /* struct LangTag has only room for 3-letter language tags. */
- switch (tag) {
- case HB_TAG('A','P','P','H'): /* Phonetic transcription—Americanist conventions */
- return hb_language_from_string ("und-fonnapa", -1);
- case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */
- return hb_language_from_string ("und-fonipa", -1);
- case HB_TAG('S','Y','R',' '): /* Syriac [macrolanguage] */
- return hb_language_from_string ("syr", -1);
- case HB_TAG('S','Y','R','E'): /* Estrangela Syriac */
- return hb_language_from_string ("und-Syre", -1);
- case HB_TAG('S','Y','R','J'): /* Western Syriac */
- return hb_language_from_string ("und-Syrj", -1);
- case HB_TAG('S','Y','R','N'): /* Eastern Syriac */
- return hb_language_from_string ("und-Syrn", -1);
+ {
+ hb_language_t disambiguated_tag = hb_ot_ambiguous_tag_to_language (tag);
+ if (disambiguated_tag != HB_LANGUAGE_INVALID)
+ return disambiguated_tag;
}
for (i = 0; i < ARRAY_LENGTH (ot_languages); i++)
- if (ot_languages[i].tag == tag)
+ if (ot_languages[i].tags[0] == tag)
return hb_language_from_string (ot_languages[i].language, -1);
- /* If tag starts with ZH, it's Chinese */
- if ((tag & 0xFFFF0000u) == 0x5A480000u) {
- switch (tag) {
- case HB_TAG('Z','H','H',' '): return hb_language_from_string ("zh-hk", -1); /* Hong Kong */
- case HB_TAG('Z','H','S',' '): return hb_language_from_string ("zh-Hans", -1); /* Simplified */
- case HB_TAG('Z','H','T',' '): return hb_language_from_string ("zh-Hant", -1); /* Traditional */
- default: break; /* Fall through */
- }
- }
-
/* Else return a custom language in the form of "x-hbotABCD" */
{
unsigned char buf[11] = "x-hbot";
@@ -1067,6 +436,71 @@ hb_ot_tag_to_language (hb_tag_t tag)
}
}
+/**
+ * hb_ot_tags_to_script_and_language:
+ * @script_tag: a script tag
+ * @language_tag: a language tag
+ * @script: (allow-none): the #hb_script_t corresponding to @script_tag (OUT).
+ * @language: (allow-none): the #hb_language_t corresponding to @script_tag and
+ * @language_tag (OUT).
+ *
+ * Converts a script tag and a language tag to an #hb_script_t and an
+ * #hb_language_t.
+ *
+ * Since: 2.0.0
+ **/
+void
+hb_ot_tags_to_script_and_language (hb_tag_t script_tag,
+ hb_tag_t language_tag,
+ hb_script_t *script /* OUT */,
+ hb_language_t *language /* OUT */)
+{
+ hb_script_t script_out = hb_ot_tag_to_script (script_tag);
+ if (script)
+ *script = script_out;
+ if (language)
+ {
+ unsigned int script_count = 1;
+ hb_tag_t primary_script_tag[1];
+ hb_ot_tags_from_script_and_language (script_out,
+ HB_LANGUAGE_INVALID,
+ &script_count,
+ primary_script_tag,
+ nullptr, nullptr);
+ *language = hb_ot_tag_to_language (language_tag);
+ if (script_count == 0 || primary_script_tag[0] != script_tag)
+ {
+ unsigned char *buf;
+ const char *lang_str = hb_language_to_string (*language);
+ size_t len = strlen (lang_str);
+ buf = (unsigned char *) malloc (len + 11);
+ if (unlikely (!buf))
+ {
+ *language = nullptr;
+ }
+ else
+ {
+ memcpy (buf, lang_str, len);
+ if (lang_str[0] != 'x' || lang_str[1] != '-') {
+ buf[len++] = '-';
+ buf[len++] = 'x';
+ }
+ buf[len++] = '-';
+ buf[len++] = 'h';
+ buf[len++] = 'b';
+ buf[len++] = 's';
+ buf[len++] = 'c';
+ buf[len++] = script_tag >> 24;
+ buf[len++] = (script_tag >> 16) & 0xFF;
+ buf[len++] = (script_tag >> 8) & 0xFF;
+ buf[len++] = script_tag & 0xFF;
+ *language = hb_language_from_string ((char *) buf, len);
+ free (buf);
+ }
+ }
+ }
+}
+
#ifdef MAIN
static inline void
test_langs_sorted (void)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-avar-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-avar-table.hh
index d100ca21ef8..c2b110a2199 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-avar-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-avar-table.hh
@@ -94,7 +94,7 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
}
public:
- DEFINE_SIZE_ARRAY (2, arrayZ);
+ DEFINE_SIZE_ARRAY (2, *this);
};
struct avar
@@ -109,7 +109,7 @@ struct avar
c->check_struct (this))))
return_trace (false);
- const SegmentMaps *map = axisSegmentMapsZ.arrayZ;
+ const SegmentMaps *map = &firstAxisSegmentMaps;
unsigned int count = axisCount;
for (unsigned int i = 0; i < count; i++)
{
@@ -125,7 +125,7 @@ struct avar
{
unsigned int count = MIN<unsigned int> (coords_length, axisCount);
- const SegmentMaps *map = axisSegmentMapsZ.arrayZ;
+ const SegmentMaps *map = &firstAxisSegmentMaps;
for (unsigned int i = 0; i < count; i++)
{
coords[i] = map->map (coords[i]);
@@ -140,8 +140,7 @@ struct avar
HBUINT16 axisCount; /* The number of variation axes in the font. This
* must be the same number as axisCount in the
* 'fvar' table. */
- UnsizedArrayOf<SegmentMaps>
- axisSegmentMapsZ;
+ SegmentMaps firstAxisSegmentMaps;
public:
DEFINE_SIZE_MIN (8);
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-fvar-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-fvar-table.hh
index 96c39c10954..fed334e8a61 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-fvar-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-fvar-table.hh
@@ -42,6 +42,11 @@ namespace OT {
struct InstanceRecord
{
+ friend struct fvar;
+
+ inline hb_array_t<const Fixed> get_coordinates (unsigned int axis_count) const
+ { return coordinatesZ.as_array (axis_count); }
+
inline bool sanitize (hb_sanitize_context_t *c, unsigned int axis_count) const
{
TRACE_SANITIZE (this);
@@ -52,7 +57,7 @@ struct InstanceRecord
protected:
NameID subfamilyNameID;/* The name ID for entries in the 'name' table
* that provide subfamily names for this instance. */
- HBUINT16 reserved; /* Reserved for future use — set to 0. */
+ HBUINT16 flags; /* Reserved for future use — set to 0. */
UnsizedArrayOf<Fixed>
coordinatesZ; /* The coordinates array for this instance. */
//NameID postScriptNameIDX;/*Optional. The name ID for entries in the 'name'
@@ -60,11 +65,16 @@ struct InstanceRecord
// * instance. */
public:
- DEFINE_SIZE_ARRAY (4, coordinatesZ);
+ DEFINE_SIZE_UNBOUNDED (4);
};
struct AxisRecord
{
+ enum
+ {
+ AXIS_FLAG_HIDDEN = 0x0001,
+ };
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -76,7 +86,7 @@ struct AxisRecord
Fixed minValue; /* The minimum coordinate value for the axis. */
Fixed defaultValue; /* The default coordinate value for the axis. */
Fixed maxValue; /* The maximum coordinate value for the axis. */
- HBUINT16 reserved; /* Reserved for future use — set to 0. */
+ HBUINT16 flags; /* Axis flags. */
NameID axisNameID; /* The name ID for entries in the 'name' table that
* provide a display name for this axis. */
@@ -88,7 +98,7 @@ struct fvar
{
static const hb_tag_t tableTag = HB_OT_TAG_fvar;
- inline bool has_data (void) const { return version.to_int () != 0; }
+ inline bool has_data (void) const { return version.to_int (); }
inline bool sanitize (hb_sanitize_context_t *c) const
{
@@ -96,42 +106,71 @@ struct fvar
return_trace (version.sanitize (c) &&
likely (version.major == 1) &&
c->check_struct (this) &&
+ axisSize == 20 && /* Assumed in our code. */
instanceSize >= axisCount * 4 + 4 &&
- axisSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
- instanceSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
- c->check_range (this, things) &&
- c->check_range (&StructAtOffset<char> (this, things),
- axisCount * axisSize + instanceCount * instanceSize));
+ get_axes ().sanitize (c) &&
+ c->check_range (get_instance (0), instanceCount, instanceSize));
}
inline unsigned int get_axis_count (void) const
{ return axisCount; }
- inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const
+ inline void get_axis_deprecated (unsigned int axis_index,
+ hb_ot_var_axis_t *info) const
{
- if (unlikely (index >= axisCount))
- return false;
+ const AxisRecord &axis = get_axes ()[axis_index];
+ info->tag = axis.axisTag;
+ info->name_id = axis.axisNameID;
+ info->default_value = axis.defaultValue / 65536.;
+ /* Ensure order, to simplify client math. */
+ info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
+ info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+ }
- if (info)
+ inline void get_axis_info (unsigned int axis_index,
+ hb_ot_var_axis_info_t *info) const
+ {
+ const AxisRecord &axis = get_axes ()[axis_index];
+ info->axis_index = axis_index;
+ info->tag = axis.axisTag;
+ info->name_id = axis.axisNameID;
+ info->flags = (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
+ info->default_value = axis.defaultValue / 65536.;
+ /* Ensure order, to simplify client math. */
+ info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
+ info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+ info->reserved = 0;
+ }
+
+ inline unsigned int get_axes_deprecated (unsigned int start_offset,
+ unsigned int *axes_count /* IN/OUT */,
+ hb_ot_var_axis_t *axes_array /* OUT */) const
+ {
+ if (axes_count)
{
- const AxisRecord &axis = get_axes ()[index];
- info->tag = axis.axisTag;
- info->name_id = axis.axisNameID;
- info->default_value = axis.defaultValue / 65536.;
- /* Ensure order, to simplify client math. */
- info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
- info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
- }
+ /* TODO Rewrite as hb_array_t<>::sub-array() */
+ unsigned int count = axisCount;
+ start_offset = MIN (start_offset, count);
- return true;
+ count -= start_offset;
+ axes_array += start_offset;
+
+ count = MIN (count, *axes_count);
+ *axes_count = count;
+
+ for (unsigned int i = 0; i < count; i++)
+ get_axis_deprecated (start_offset + i, axes_array + i);
+ }
+ return axisCount;
}
- inline unsigned int get_axis_infos (unsigned int start_offset,
- unsigned int *axes_count /* IN/OUT */,
- hb_ot_var_axis_t *axes_array /* OUT */) const
+ inline unsigned int get_axis_infos (unsigned int start_offset,
+ unsigned int *axes_count /* IN/OUT */,
+ hb_ot_var_axis_info_t *axes_array /* OUT */) const
{
if (axes_count)
{
+ /* TODO Rewrite as hb_array_t<>::sub-array() */
unsigned int count = axisCount;
start_offset = MIN (start_offset, count);
@@ -142,32 +181,48 @@ struct fvar
*axes_count = count;
for (unsigned int i = 0; i < count; i++)
- get_axis (start_offset + i, axes_array + i);
+ get_axis_info (start_offset + i, axes_array + i);
}
return axisCount;
}
- inline bool find_axis (hb_tag_t tag, unsigned int *index, hb_ot_var_axis_t *info) const
+ inline bool find_axis_deprecated (hb_tag_t tag,
+ unsigned int *axis_index,
+ hb_ot_var_axis_t *info) const
+ {
+ const AxisRecord *axes = get_axes ();
+ unsigned int count = get_axis_count ();
+ for (unsigned int i = 0; i < count; i++)
+ if (axes[i].axisTag == tag)
+ {
+ if (axis_index)
+ *axis_index = i;
+ get_axis_deprecated (i, info);
+ return true;
+ }
+ if (axis_index)
+ *axis_index = HB_OT_VAR_NO_AXIS_INDEX;
+ return false;
+ }
+
+ inline bool find_axis_info (hb_tag_t tag,
+ hb_ot_var_axis_info_t *info) const
{
const AxisRecord *axes = get_axes ();
unsigned int count = get_axis_count ();
for (unsigned int i = 0; i < count; i++)
if (axes[i].axisTag == tag)
{
- if (index)
- *index = i;
- return get_axis (i, info);
+ get_axis_info (i, info);
+ return true;
}
- if (index)
- *index = HB_OT_VAR_NO_AXIS_INDEX;
return false;
}
inline int normalize_axis_value (unsigned int axis_index, float v) const
{
- hb_ot_var_axis_t axis;
- if (!get_axis (axis_index, &axis))
- return 0;
+ hb_ot_var_axis_info_t axis;
+ get_axis_info (axis_index, &axis);
v = MAX (MIN (v, axis.max_value), axis.min_value); /* Clamp. */
@@ -180,17 +235,63 @@ struct fvar
return (int) (v * 16384.f + (v >= 0.f ? .5f : -.5f));
}
+ inline unsigned int get_instance_count (void) const
+ { return instanceCount; }
+
+ inline hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int instance_index) const
+ {
+ const InstanceRecord *instance = get_instance (instance_index);
+ if (unlikely (!instance)) return HB_OT_NAME_ID_INVALID;
+ return instance->subfamilyNameID;
+ }
+
+ inline hb_ot_name_id_t get_instance_postscript_name_id (unsigned int instance_index) const
+ {
+ const InstanceRecord *instance = get_instance (instance_index);
+ if (unlikely (!instance)) return HB_OT_NAME_ID_INVALID;
+ if (instanceSize >= axisCount * 4 + 6)
+ return StructAfter<NameID> (instance->get_coordinates (axisCount));
+ return HB_OT_NAME_ID_INVALID;
+ }
+
+ inline unsigned int get_instance_coords (unsigned int instance_index,
+ unsigned int *coords_length, /* IN/OUT */
+ float *coords /* OUT */) const
+ {
+ const InstanceRecord *instance = get_instance (instance_index);
+ if (unlikely (!instance))
+ {
+ if (coords_length)
+ *coords_length = 0;
+ return 0;
+ }
+
+ if (coords_length && *coords_length)
+ {
+ hb_array_t<const Fixed> instanceCoords = instance->get_coordinates (axisCount)
+ .sub_array (0, *coords_length);
+ for (unsigned int i = 0; i < instanceCoords.len; i++)
+ coords[i] = instanceCoords.arrayZ[i].to_float ();
+ }
+ return axisCount;
+ }
+
protected:
- inline const AxisRecord * get_axes (void) const
- { return &StructAtOffset<AxisRecord> (this, things); }
+ inline hb_array_t<const AxisRecord> get_axes (void) const
+ { return hb_array (&(this+firstAxis), axisCount); }
- inline const InstanceRecord * get_instances (void) const
- { return &StructAtOffset<InstanceRecord> (get_axes () + axisCount, 0); }
+ inline const InstanceRecord *get_instance (unsigned int i) const
+ {
+ if (unlikely (i >= instanceCount)) return nullptr;
+ return &StructAtOffset<InstanceRecord> (&StructAfter<InstanceRecord> (get_axes ()),
+ i * instanceSize);
+ }
protected:
FixedVersion<>version; /* Version of the fvar table
* initially set to 0x00010000u */
- Offset16 things; /* Offset in bytes from the beginning of the table
+ OffsetTo<AxisRecord>
+ firstAxis; /* Offset in bytes from the beginning of the table
* to the start of the AxisRecord array. */
HBUINT16 reserved; /* This field is permanently reserved. Set to 2. */
HBUINT16 axisCount; /* The number of variation axes in the font (the
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-hvar-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-hvar-table.hh
index d87285b7f5d..62a6547b50c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-hvar-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-hvar-table.hh
@@ -39,7 +39,9 @@ struct DeltaSetIndexMap
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (mapDataZ.arrayZ, mapCount, get_width ()));
+ c->check_range (mapDataZ.arrayZ,
+ mapCount,
+ get_width ()));
}
unsigned int map (unsigned int v) const /* Returns 16.16 outer.inner. */
@@ -115,7 +117,7 @@ struct HVARVVAR
}
inline float get_advance_var (hb_codepoint_t glyph,
- int *coords, unsigned int coord_count) const
+ const int *coords, unsigned int coord_count) const
{
unsigned int varidx = (this+advMap).map (glyph);
return (this+varStore).get_delta (varidx, coords, coord_count);
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-mvar-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-mvar-table.hh
index d60c6b910e9..b16a09b3d14 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-mvar-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var-mvar-table.hh
@@ -68,11 +68,13 @@ struct MVAR
c->check_struct (this) &&
valueRecordSize >= VariationValueRecord::static_size &&
varStore.sanitize (c, this) &&
- c->check_array (valuesZ.arrayZ, valueRecordCount, valueRecordSize));
+ c->check_range (valuesZ.arrayZ,
+ valueRecordCount,
+ valueRecordSize));
}
inline float get_var (hb_tag_t tag,
- int *coords, unsigned int coord_count) const
+ const int *coords, unsigned int coord_count) const
{
const VariationValueRecord *record;
record = (VariationValueRecord *) bsearch (&tag, valuesZ.arrayZ,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.cc
index 472ee845224..56d2481787e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.cc
@@ -32,31 +32,27 @@
#include "hb-ot-var-mvar-table.hh"
#include "hb-ot-var.h"
+
+/**
+ * SECTION:hb-ot-var
+ * @title: hb-ot-var
+ * @short_description: OpenType Font Variations
+ * @include: hb-ot.h
+ *
+ * Functions for fetching information about OpenType Variable Fonts.
+ **/
+
+
/*
* fvar/avar
*/
-static inline const OT::fvar&
-_get_fvar (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar);
- hb_ot_face_data_t *layout = hb_ot_face_data (face);
- return *(layout->fvar.get ());
-}
-static inline const OT::avar&
-_get_avar (hb_face_t *face)
-{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar);
- hb_ot_face_data_t *layout = hb_ot_face_data (face);
- return *(layout->avar.get ());
-}
/**
* hb_ot_var_has_data:
* @face: #hb_face_t to test
*
* This function allows to verify the presence of OpenType variation data on the face.
- * Alternatively, use hb_ot_var_get_axis_count().
*
* Return value: true if face has a `fvar' table and false otherwise
*
@@ -65,7 +61,7 @@ _get_avar (hb_face_t *face)
hb_bool_t
hb_ot_var_has_data (hb_face_t *face)
{
- return _get_fvar (face).has_data ();
+ return face->table.fvar->has_data ();
}
/**
@@ -76,14 +72,14 @@ hb_ot_var_has_data (hb_face_t *face)
unsigned int
hb_ot_var_get_axis_count (hb_face_t *face)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.get_axis_count ();
+ return face->table.fvar->get_axis_count ();
}
/**
* hb_ot_var_get_axes:
*
* Since: 1.4.2
+ * Deprecated: REPLACEME
**/
unsigned int
hb_ot_var_get_axes (hb_face_t *face,
@@ -91,14 +87,14 @@ hb_ot_var_get_axes (hb_face_t *face,
unsigned int *axes_count /* IN/OUT */,
hb_ot_var_axis_t *axes_array /* OUT */)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.get_axis_infos (start_offset, axes_count, axes_array);
+ return face->table.fvar->get_axes_deprecated (start_offset, axes_count, axes_array);
}
/**
* hb_ot_var_find_axis:
*
* Since: 1.4.2
+ * Deprecated: REPLACEME
**/
hb_bool_t
hb_ot_var_find_axis (hb_face_t *face,
@@ -106,8 +102,68 @@ hb_ot_var_find_axis (hb_face_t *face,
unsigned int *axis_index,
hb_ot_var_axis_t *axis_info)
{
- const OT::fvar &fvar = _get_fvar (face);
- return fvar.find_axis (axis_tag, axis_index, axis_info);
+ return face->table.fvar->find_axis_deprecated (axis_tag, axis_index, axis_info);
+}
+
+/**
+ * hb_ot_var_get_axis_infos:
+ *
+ * Since: REPLACEME
+ **/
+HB_EXTERN unsigned int
+hb_ot_var_get_axis_infos (hb_face_t *face,
+ unsigned int start_offset,
+ unsigned int *axes_count /* IN/OUT */,
+ hb_ot_var_axis_info_t *axes_array /* OUT */)
+{
+ return face->table.fvar->get_axis_infos (start_offset, axes_count, axes_array);
+}
+
+/**
+ * hb_ot_var_find_axis_info:
+ *
+ * Since: REPLACEME
+ **/
+HB_EXTERN hb_bool_t
+hb_ot_var_find_axis_info (hb_face_t *face,
+ hb_tag_t axis_tag,
+ hb_ot_var_axis_info_t *axis_info)
+{
+ return face->table.fvar->find_axis_info (axis_tag, axis_info);
+}
+
+
+/*
+ * Named instances.
+ */
+
+unsigned int
+hb_ot_var_get_named_instance_count (hb_face_t *face)
+{
+ return face->table.fvar->get_instance_count ();
+}
+
+hb_ot_name_id_t
+hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face,
+ unsigned int instance_index)
+{
+ return face->table.fvar->get_instance_subfamily_name_id (instance_index);
+}
+
+hb_ot_name_id_t
+hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face,
+ unsigned int instance_index)
+{
+ return face->table.fvar->get_instance_postscript_name_id (instance_index);
+}
+
+unsigned int
+hb_ot_var_named_instance_get_design_coords (hb_face_t *face,
+ unsigned int instance_index,
+ unsigned int *coords_length, /* IN/OUT */
+ float *coords /* OUT */)
+{
+ return face->table.fvar->get_instance_coords (instance_index, coords_length, coords);
}
@@ -126,17 +182,16 @@ hb_ot_var_normalize_variations (hb_face_t *face,
for (unsigned int i = 0; i < coords_length; i++)
coords[i] = 0;
- const OT::fvar &fvar = _get_fvar (face);
+ const OT::fvar &fvar = *face->table.fvar;
for (unsigned int i = 0; i < variations_length; i++)
{
- unsigned int axis_index;
- if (hb_ot_var_find_axis (face, variations[i].tag, &axis_index, nullptr) &&
- axis_index < coords_length)
- coords[axis_index] = fvar.normalize_axis_value (axis_index, variations[i].value);
+ hb_ot_var_axis_info_t info;
+ if (hb_ot_var_find_axis_info (face, variations[i].tag, &info) &&
+ info.axis_index < coords_length)
+ coords[info.axis_index] = fvar.normalize_axis_value (info.axis_index, variations[i].value);
}
- const OT::avar &avar = _get_avar (face);
- avar.map_coords (coords, coords_length);
+ face->table.avar->map_coords (coords, coords_length);
}
/**
@@ -150,10 +205,9 @@ hb_ot_var_normalize_coords (hb_face_t *face,
const float *design_coords, /* IN */
int *normalized_coords /* OUT */)
{
- const OT::fvar &fvar = _get_fvar (face);
+ const OT::fvar &fvar = *face->table.fvar;
for (unsigned int i = 0; i < coords_length; i++)
normalized_coords[i] = fvar.normalize_axis_value (i, design_coords[i]);
- const OT::avar &avar = _get_avar (face);
- avar.map_coords (normalized_coords, coords_length);
+ face->table.avar->map_coords (normalized_coords, coords_length);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.h b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.h
index a2c0c5f2b02..779be10437e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-var.h
@@ -47,44 +47,85 @@ HB_BEGIN_DECLS
* fvar / avar
*/
+HB_EXTERN hb_bool_t
+hb_ot_var_has_data (hb_face_t *face);
+
+
+/*
+ * Variation axes.
+ */
+
+
+HB_EXTERN unsigned int
+hb_ot_var_get_axis_count (hb_face_t *face);
+
/**
- * hb_ot_var_axis_t:
+ * hb_ot_var_axis_flags_t:
+ * @HB_OT_VAR_AXIS_FLAG_HIDDEN: The axis should not be exposed directly in user interfaces.
*
- * Since: 1.4.2
+ * Since: REPLACEME
*/
-typedef struct hb_ot_var_axis_t {
- hb_tag_t tag;
- unsigned int name_id;
- float min_value;
- float default_value;
- float max_value;
-} hb_ot_var_axis_t;
+typedef enum { /*< flags >*/
+ HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x00000001u,
-HB_EXTERN hb_bool_t
-hb_ot_var_has_data (hb_face_t *face);
+ _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
+} hb_ot_var_axis_flags_t;
/**
- * HB_OT_VAR_NO_AXIS_INDEX:
+ * hb_ot_var_axis_info_t:
*
- * Since: 1.4.2
+ * Since: REPLACEME
*/
-#define HB_OT_VAR_NO_AXIS_INDEX 0xFFFFFFFFu
+typedef struct hb_ot_var_axis_info_t
+{
+ unsigned int axis_index;
+ hb_tag_t tag;
+ hb_ot_name_id_t name_id;
+ hb_ot_var_axis_flags_t flags;
+ float min_value;
+ float default_value;
+ float max_value;
+ /*< private >*/
+ unsigned int reserved;
+} hb_ot_var_axis_info_t;
HB_EXTERN unsigned int
-hb_ot_var_get_axis_count (hb_face_t *face);
+hb_ot_var_get_axis_infos (hb_face_t *face,
+ unsigned int start_offset,
+ unsigned int *axes_count /* IN/OUT */,
+ hb_ot_var_axis_info_t *axes_array /* OUT */);
+
+HB_EXTERN hb_bool_t
+hb_ot_var_find_axis_info (hb_face_t *face,
+ hb_tag_t axis_tag,
+ hb_ot_var_axis_info_t *axis_info);
+
+
+/*
+ * Named instances.
+ */
HB_EXTERN unsigned int
-hb_ot_var_get_axes (hb_face_t *face,
- unsigned int start_offset,
- unsigned int *axes_count /* IN/OUT */,
- hb_ot_var_axis_t *axes_array /* OUT */);
+hb_ot_var_get_named_instance_count (hb_face_t *face);
-HB_EXTERN hb_bool_t
-hb_ot_var_find_axis (hb_face_t *face,
- hb_tag_t axis_tag,
- unsigned int *axis_index,
- hb_ot_var_axis_t *axis_info);
+HB_EXTERN hb_ot_name_id_t
+hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face,
+ unsigned int instance_index);
+HB_EXTERN hb_ot_name_id_t
+hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face,
+ unsigned int instance_index);
+
+HB_EXTERN unsigned int
+hb_ot_var_named_instance_get_design_coords (hb_face_t *face,
+ unsigned int instance_index,
+ unsigned int *coords_length, /* IN/OUT */
+ float *coords /* OUT */);
+
+
+/*
+ * Conversions.
+ */
HB_EXTERN void
hb_ot_var_normalize_variations (hb_face_t *face,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot-vorg-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-vorg-table.hh
new file mode 100644
index 00000000000..a0480cbcb77
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot-vorg-table.hh
@@ -0,0 +1,181 @@
+/*
+ * Copyright © 2018 Adobe Systems Incorporated.
+ *
+ * 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.
+ *
+ * Adobe Author(s): Michiharu Ariza
+ */
+
+#ifndef HB_OT_VORG_TABLE_HH
+#define HB_OT_VORG_TABLE_HH
+
+#include "hb-open-type.hh"
+
+/*
+ * VORG -- Vertical Origin Table
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/vorg
+ */
+#define HB_OT_TAG_VORG HB_TAG('V','O','R','G')
+
+namespace OT {
+
+struct VertOriginMetric
+{
+ 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));
+ }
+
+ public:
+ GlyphID glyph;
+ FWORD vertOriginY;
+
+ public:
+ DEFINE_SIZE_STATIC (4);
+};
+
+struct VORG
+{
+ static const hb_tag_t tableTag = HB_OT_TAG_VORG;
+
+ inline bool has_data (void) const { return version.to_int (); }
+
+ inline int get_y_origin (hb_codepoint_t glyph) const
+ {
+ unsigned int i;
+ if (!vertYOrigins.bfind (glyph, &i))
+ return defaultVertOriginY;
+ return vertYOrigins[i].vertOriginY;
+ }
+
+ inline bool _subset (const hb_subset_plan_t *plan HB_UNUSED,
+ const VORG *vorg_table,
+ const hb_vector_t<VertOriginMetric> &subset_metrics,
+ unsigned int dest_sz,
+ void *dest) const
+ {
+ hb_serialize_context_t c (dest, dest_sz);
+
+ VORG *subset_table = c.start_serialize<VORG> ();
+ if (unlikely (!c.extend_min (*subset_table)))
+ return false;
+
+ subset_table->version.major.set (1);
+ subset_table->version.minor.set (0);
+
+ subset_table->defaultVertOriginY.set (vorg_table->defaultVertOriginY);
+ subset_table->vertYOrigins.len.set (subset_metrics.len);
+
+ bool success = true;
+ if (subset_metrics.len > 0)
+ {
+ unsigned int size = VertOriginMetric::static_size * subset_metrics.len;
+ VertOriginMetric *metrics = c.allocate_size<VertOriginMetric> (size);
+ if (likely (metrics != nullptr))
+ memcpy (metrics, &subset_metrics[0], size);
+ else
+ success = false;
+ }
+ c.end_serialize ();
+
+ return success;
+ }
+
+ inline bool subset (hb_subset_plan_t *plan) const
+ {
+ hb_blob_t *vorg_blob = hb_sanitize_context_t().reference_table<VORG> (plan->source);
+ const VORG *vorg_table = vorg_blob->as<VORG> ();
+
+ /* count the number of glyphs to be included in the subset table */
+ hb_vector_t<VertOriginMetric> subset_metrics;
+ subset_metrics.init ();
+ unsigned int glyph = 0;
+ unsigned int i = 0;
+ while ((glyph < plan->glyphs.len) && (i < vertYOrigins.len))
+ {
+ if (plan->glyphs[glyph] > vertYOrigins[i].glyph)
+ i++;
+ else if (plan->glyphs[glyph] < vertYOrigins[i].glyph)
+ glyph++;
+ else
+ {
+ VertOriginMetric *metrics = subset_metrics.push ();
+ metrics->glyph.set (glyph);
+ metrics->vertOriginY.set (vertYOrigins[i].vertOriginY);
+ glyph++;
+ i++;
+ }
+ }
+
+ /* alloc the new table */
+ unsigned int dest_sz = VORG::min_size + VertOriginMetric::static_size * subset_metrics.len;
+ void *dest = (void *) malloc (dest_sz);
+ if (unlikely (!dest))
+ {
+ subset_metrics.fini ();
+ hb_blob_destroy (vorg_blob);
+ return false;
+ }
+
+ /* serialize the new table */
+ if (!_subset (plan, vorg_table, subset_metrics, dest_sz, dest))
+ {
+ subset_metrics.fini ();
+ free (dest);
+ hb_blob_destroy (vorg_blob);
+ return false;
+ }
+
+ hb_blob_t *result = hb_blob_create ((const char *)dest,
+ dest_sz,
+ HB_MEMORY_MODE_READONLY,
+ dest,
+ free);
+ bool success = plan->add_table (HB_OT_TAG_VORG, result);
+ hb_blob_destroy (result);
+ subset_metrics.fini ();
+ hb_blob_destroy (vorg_blob);
+ return success;
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ version.major == 1 &&
+ vertYOrigins.sanitize (c));
+ }
+
+ protected:
+ FixedVersion<> version; /* Version of VORG table. Set to 0x00010000u. */
+ FWORD defaultVertOriginY; /* The default vertical origin. */
+ SortedArrayOf<VertOriginMetric>
+ vertYOrigins; /* The array of vertical origins. */
+
+ public:
+ DEFINE_SIZE_ARRAY(8, vertYOrigins);
+};
+} /* namespace OT */
+
+#endif /* HB_OT_VORG_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ot.h b/chromium/third_party/harfbuzz-ng/src/src/hb-ot.h
index 2120a3efa34..c168175ac35 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ot.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ot.h
@@ -30,10 +30,11 @@
#include "hb.h"
+#include "hb-ot-color.h"
#include "hb-ot-font.h"
#include "hb-ot-layout.h"
#include "hb-ot-math.h"
-#include "hb-ot-tag.h"
+#include "hb-ot-name.h"
#include "hb-ot-shape.h"
#include "hb-ot-var.h"
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-set-digest.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-set-digest.hh
index 0f9329f621c..4e99df0eb55 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-set-digest.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-set-digest.hh
@@ -48,8 +48,6 @@
template <typename mask_t, unsigned int shift>
struct hb_set_digest_lowest_bits_t
{
- ASSERT_POD ();
-
enum { mask_bytes = sizeof (mask_t) };
enum { mask_bits = sizeof (mask_t) * 8 };
static const unsigned int num_bits = 0
@@ -117,8 +115,6 @@ struct hb_set_digest_lowest_bits_t
template <typename head_t, typename tail_t>
struct hb_set_digest_combiner_t
{
- ASSERT_POD ();
-
inline void init (void) {
head.init ();
tail.init ();
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-set.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-set.cc
index 09dc4b483af..67ec5618028 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-set.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-set.cc
@@ -27,7 +27,16 @@
#include "hb-set.hh"
-/* Public API */
+/**
+ * SECTION:hb-set
+ * @title: hb-set
+ * @short_description: Object representing a set of integers
+ * @include: hb.h
+ *
+ * Set objects represent a mathematical set of integer values. They are
+ * used in non-shaping API to query certain set of characters or glyphs,
+ * or other integer values.
+ **/
/**
@@ -391,7 +400,7 @@ hb_set_symmetric_difference (hb_set_t *set,
* Deprecated: 1.6.1
**/
void
-hb_set_invert (hb_set_t *set)
+hb_set_invert (hb_set_t *set HB_UNUSED)
{
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-set.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-set.hh
index 353403e9297..8b7a0f3d0c6 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-set.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-set.hh
@@ -39,9 +39,13 @@
struct hb_set_t
{
+ HB_NO_COPY_ASSIGN (hb_set_t);
+ inline hb_set_t (void) { init (); }
+ inline ~hb_set_t (void) { fini (); }
+
struct page_map_t
{
- inline int cmp (const page_map_t *o) const { return (int) o->major - (int) major; }
+ inline int cmp (const page_map_t &o) const { return (int) o.major - (int) major; }
uint32_t major;
uint32_t index;
@@ -49,8 +53,8 @@ struct hb_set_t
struct page_t
{
- inline void init0 (void) { memset (&v, 0, sizeof (v)); }
- inline void init1 (void) { memset (&v, 0xff, sizeof (v)); }
+ inline void init0 (void) { v.clear (); }
+ inline void init1 (void) { v.clear (0xFF); }
inline unsigned int len (void) const
{ return ARRAY_LENGTH_CONST (v); }
@@ -86,7 +90,7 @@ struct hb_set_t
inline bool is_equal (const page_t *other) const
{
- return 0 == memcmp (&v, &other->v, sizeof (v));
+ return 0 == hb_memcmp (&v, &other->v, sizeof (v));
}
inline unsigned int get_population (void) const
@@ -199,6 +203,7 @@ struct hb_set_t
}
inline void fini_shallow (void)
{
+ population = 0;
page_map.fini ();
pages.fini ();
}
@@ -220,15 +225,17 @@ struct hb_set_t
return true;
}
- inline void clear (void) {
- if (unlikely (hb_object_is_inert (this)))
+ inline void clear (void)
+ {
+ if (unlikely (hb_object_is_immutable (this)))
return;
successful = true;
population = 0;
page_map.resize (0);
pages.resize (0);
}
- inline bool is_empty (void) const {
+ inline bool is_empty (void) const
+ {
unsigned int count = pages.len;
for (unsigned int i = 0; i < count; i++)
if (!pages[i].is_empty ())
@@ -334,11 +341,11 @@ struct hb_set_t
{
/* TODO perform op even if !successful. */
if (unlikely (!successful)) return;
- page_t *p = page_for (g);
- if (!p)
+ page_t *page = page_for (g);
+ if (!page)
return;
dirty ();
- p->del (g);
+ page->del (g);
}
inline void del_range (hb_codepoint_t a, hb_codepoint_t b)
{
@@ -350,10 +357,10 @@ struct hb_set_t
}
inline bool has (hb_codepoint_t g) const
{
- const page_t *p = page_for (g);
- if (!p)
+ const page_t *page = page_for (g);
+ if (!page)
return false;
- return p->has (g);
+ return page->has (g);
}
inline bool intersects (hb_codepoint_t first,
hb_codepoint_t last) const
@@ -368,8 +375,8 @@ struct hb_set_t
if (!resize (count))
return;
population = other->population;
- memcpy (pages.arrayZ, other->pages.arrayZ, count * sizeof (pages.arrayZ[0]));
- memcpy (page_map.arrayZ, other->page_map.arrayZ, count * sizeof (page_map.arrayZ[0]));
+ memcpy (pages, other->pages, count * pages.item_size);
+ memcpy (page_map, other->page_map, count * page_map.item_size);
}
inline bool is_equal (const hb_set_t *other) const
@@ -537,7 +544,7 @@ struct hb_set_t
page_map_t map = {get_major (*codepoint), 0};
unsigned int i;
- page_map.bfind (map, &i);
+ page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST);
if (i < page_map.len && page_map[i].major == map.major)
{
if (pages[page_map[i].index].next (codepoint))
@@ -568,7 +575,7 @@ struct hb_set_t
page_map_t map = {get_major (*codepoint), 0};
unsigned int i;
- page_map.bfind (map, &i);
+ page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST);
if (i < page_map.len && page_map[i].major == map.major)
{
if (pages[page_map[i].index].previous (codepoint))
@@ -663,13 +670,15 @@ struct hb_set_t
{
page_map_t map = {get_major (g), pages.len};
unsigned int i;
- if (!page_map.bfind (map, &i))
+ if (!page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST))
{
if (!resize (pages.len + 1))
return nullptr;
pages[map.index].init0 ();
- memmove (&page_map[i + 1], &page_map[i], (page_map.len - 1 - i) * sizeof (page_map[0]));
+ memmove (page_map + i + 1,
+ page_map + i,
+ (page_map.len - 1 - i) * sizeof (page_map[0]));
page_map[i] = map;
}
return &pages[page_map[i].index];
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.cc
index b0cf1e92d1d..bc3d81636b9 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.cc
@@ -31,88 +31,131 @@
#include "hb-buffer.hh"
-static void
-hb_shape_plan_plan (hb_shape_plan_t *shape_plan,
- const hb_feature_t *user_features,
- unsigned int num_user_features,
- const int *coords,
- unsigned int num_coords,
- const char * const *shaper_list)
+/**
+ * SECTION:hb-shape-plan
+ * @title: hb-shape-plan
+ * @short_description: Object representing a shaping plan
+ * @include: hb.h
+ *
+ * Shape plans are not used for shaping directly, but can be access to query
+ * certain information about how shaping will perform given a set of input
+ * parameters (script, language, direction, features, etc.)
+ * Most client would not need to deal with shape plans directly.
+ **/
+
+
+/*
+ * hb_shape_plan_key_t
+ */
+
+bool
+hb_shape_plan_key_t::init (bool copy,
+ hb_face_t *face,
+ const hb_segment_properties_t *props,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features,
+ const int *coords,
+ unsigned int num_coords,
+ const char * const *shaper_list)
{
- DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan,
- "num_features=%d num_coords=%d shaper_list=%p",
- num_user_features,
- num_coords,
- shaper_list);
+ hb_feature_t *features = nullptr;
+ if (copy && num_user_features && !(features = (hb_feature_t *) calloc (num_user_features, sizeof (hb_feature_t))))
+ goto bail;
- const hb_shaper_pair_t *shapers = _hb_shapers_get ();
+ this->props = *props;
+ this->num_user_features = num_user_features;
+ this->user_features = copy ? features : user_features;
+ if (copy && num_user_features)
+ {
+ memcpy (features, user_features, num_user_features * sizeof (hb_feature_t));
+ /* Make start/end uniform to easier catch bugs. */
+ for (unsigned int i = 0; i < num_user_features; i++)
+ {
+ if (features[0].start != HB_FEATURE_GLOBAL_START)
+ features[0].start = 1;
+ if (features[0].end != HB_FEATURE_GLOBAL_END)
+ features[0].end = 2;
+ }
+ }
+ this->shaper_func = nullptr;
+ this->shaper_name = nullptr;
+ this->ot.init (face, coords, num_coords);
+
+ /*
+ * Choose shaper.
+ */
#define HB_SHAPER_PLAN(shaper) \
HB_STMT_START { \
- if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) \
+ if (face->data.shaper) \
{ \
- /* XXX-MT-bug What happened to *ensure*ing this?!!!! */ \
- HB_SHAPER_DATA (shaper, shape_plan).set_relaxed ( \
- HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \
- user_features, num_user_features, \
- coords, num_coords)); \
- shape_plan->shaper_func = _hb_##shaper##_shape; \
- shape_plan->shaper_name = #shaper; \
- return; \
+ this->shaper_func = _hb_##shaper##_shape; \
+ this->shaper_name = #shaper; \
+ return true; \
} \
} HB_STMT_END
- if (likely (!shaper_list)) {
- for (unsigned int i = 0; i < HB_SHAPERS_COUNT; i++)
- if (0)
+ if (unlikely (shaper_list))
+ {
+ for (; *shaper_list; shaper_list++)
+ if (false)
;
#define HB_SHAPER_IMPLEMENT(shaper) \
- else if (shapers[i].func == _hb_##shaper##_shape) \
+ else if (0 == strcmp (*shaper_list, #shaper)) \
HB_SHAPER_PLAN (shaper);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
- } else {
- for (; *shaper_list; shaper_list++)
- if (0)
+ }
+ else
+ {
+ const hb_shaper_entry_t *shapers = _hb_shapers_get ();
+ for (unsigned int i = 0; i < HB_SHAPERS_COUNT; i++)
+ if (false)
;
#define HB_SHAPER_IMPLEMENT(shaper) \
- else if (0 == strcmp (*shaper_list, #shaper)) \
+ else if (shapers[i].func == _hb_##shaper##_shape) \
HB_SHAPER_PLAN (shaper);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
}
-
#undef HB_SHAPER_PLAN
-}
-
-/*
- * hb_shape_plan_t
- */
+bail:
+ ::free (features);
+ return false;
+}
-DEFINE_NULL_INSTANCE (hb_shape_plan_t) =
+bool
+hb_shape_plan_key_t::user_features_match (const hb_shape_plan_key_t *other)
{
- HB_OBJECT_HEADER_STATIC,
-
- true, /* default_shaper_list */
- nullptr, /* face */
- HB_SEGMENT_PROPERTIES_DEFAULT, /* props */
-
- nullptr, /* shaper_func */
- nullptr, /* shaper_name */
+ if (this->num_user_features != other->num_user_features)
+ return false;
+ for (unsigned int i = 0; i < num_user_features; i++)
+ {
+ if (this->user_features[i].tag != other->user_features[i].tag ||
+ this->user_features[i].value != other->user_features[i].value ||
+ (this->user_features[i].start == HB_FEATURE_GLOBAL_START &&
+ this->user_features[i].end == HB_FEATURE_GLOBAL_END) !=
+ (other->user_features[i].start == HB_FEATURE_GLOBAL_START &&
+ other->user_features[i].end == HB_FEATURE_GLOBAL_END))
+ return false;
+ }
+ return true;
+}
- nullptr, /* user_features */
- 0, /* num_user_featurs */
+bool
+hb_shape_plan_key_t::equal (const hb_shape_plan_key_t *other)
+{
+ return hb_segment_properties_equal (&this->props, &other->props) &&
+ this->user_features_match (other) &&
+ this->ot.equal (&other->ot) &&
+ this->shaper_func == other->shaper_func;
+}
- nullptr, /* coords */
- 0, /* num_coords */
- {
-#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID),
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
- },
-};
+/*
+ * hb_shape_plan_t
+ */
/**
@@ -147,7 +190,7 @@ hb_shape_plan_create2 (hb_face_t *face,
const hb_segment_properties_t *props,
const hb_feature_t *user_features,
unsigned int num_user_features,
- const int *orig_coords,
+ const int *coords,
unsigned int num_coords,
const char * const *shaper_list)
{
@@ -158,49 +201,40 @@ hb_shape_plan_create2 (hb_face_t *face,
num_coords,
shaper_list);
+ assert (props->direction != HB_DIRECTION_INVALID);
+
hb_shape_plan_t *shape_plan;
- hb_feature_t *features = nullptr;
- int *coords = nullptr;
- if (unlikely (!face))
- face = hb_face_get_empty ();
if (unlikely (!props))
- return hb_shape_plan_get_empty ();
- if (num_user_features && !(features = (hb_feature_t *) calloc (num_user_features, sizeof (hb_feature_t))))
- return hb_shape_plan_get_empty ();
- if (num_coords && !(coords = (int *) calloc (num_coords, sizeof (int))))
- {
- free (features);
- return hb_shape_plan_get_empty ();
- }
+ goto bail;
if (!(shape_plan = hb_object_create<hb_shape_plan_t> ()))
- {
- free (coords);
- free (features);
- return hb_shape_plan_get_empty ();
- }
-
- assert (props->direction != HB_DIRECTION_INVALID);
+ goto bail;
+ if (unlikely (!face))
+ face = hb_face_get_empty ();
hb_face_make_immutable (face);
- shape_plan->default_shaper_list = !shaper_list;
shape_plan->face_unsafe = face;
- shape_plan->props = *props;
- shape_plan->num_user_features = num_user_features;
- shape_plan->user_features = features;
- if (num_user_features)
- memcpy (features, user_features, num_user_features * sizeof (hb_feature_t));
- shape_plan->num_coords = num_coords;
- shape_plan->coords = coords;
- if (num_coords)
- memcpy (coords, orig_coords, num_coords * sizeof (int));
- hb_shape_plan_plan (shape_plan,
- user_features, num_user_features,
- coords, num_coords,
- shaper_list);
+ if (unlikely (!shape_plan->key.init (true,
+ face,
+ props,
+ user_features,
+ num_user_features,
+ coords,
+ num_coords,
+ shaper_list)))
+ goto bail2;
+ if (unlikely (!shape_plan->ot.init0 (face, &shape_plan->key)))
+ goto bail3;
return shape_plan;
+
+bail3:
+ shape_plan->key.free ();
+bail2:
+ free (shape_plan);
+bail:
+ return hb_shape_plan_get_empty ();
}
/**
@@ -247,13 +281,8 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
{
if (!hb_object_destroy (shape_plan)) return;
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, shape_plan);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-
- free (shape_plan->user_features);
- free (shape_plan->coords);
-
+ shape_plan->ot.fini ();
+ shape_plan->key.free ();
free (shape_plan);
}
@@ -299,6 +328,22 @@ hb_shape_plan_get_user_data (hb_shape_plan_t *shape_plan,
return hb_object_get_user_data (shape_plan, key);
}
+/**
+ * hb_shape_plan_get_shaper:
+ * @shape_plan: a shape plan.
+ *
+ *
+ *
+ * Return value: (transfer none):
+ *
+ * Since: 0.9.7
+ **/
+const char *
+hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan)
+{
+ return shape_plan->key.shaper_name;
+}
+
/**
* hb_shape_plan_execute:
@@ -324,32 +369,31 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan,
DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan,
"num_features=%d shaper_func=%p, shaper_name=%s",
num_features,
- shape_plan->shaper_func,
- shape_plan->shaper_name);
+ shape_plan->key.shaper_func,
+ shape_plan->key.shaper_name);
if (unlikely (!buffer->len))
return true;
- assert (!hb_object_is_inert (buffer));
+ assert (!hb_object_is_immutable (buffer));
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
if (unlikely (hb_object_is_inert (shape_plan)))
return false;
assert (shape_plan->face_unsafe == font->face);
- assert (hb_segment_properties_equal (&shape_plan->props, &buffer->props));
+ assert (hb_segment_properties_equal (&shape_plan->key.props, &buffer->props));
#define HB_SHAPER_EXECUTE(shaper) \
HB_STMT_START { \
- return HB_SHAPER_DATA (shaper, shape_plan).get () && \
- hb_##shaper##_shaper_font_data_ensure (font) && \
+ return font->data.shaper && \
_hb_##shaper##_shape (shape_plan, font, buffer, features, num_features); \
} HB_STMT_END
- if (0)
+ if (false)
;
#define HB_SHAPER_IMPLEMENT(shaper) \
- else if (shape_plan->shaper_func == _hb_##shaper##_shape) \
+ else if (shape_plan->key.shaper_func == _hb_##shaper##_shape) \
HB_SHAPER_EXECUTE (shaper);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
@@ -361,92 +405,9 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan,
/*
- * caching
+ * Caching
*/
-#if 0
-static unsigned int
-hb_shape_plan_hash (const hb_shape_plan_t *shape_plan)
-{
- return hb_segment_properties_hash (&shape_plan->props) +
- shape_plan->default_shaper_list ? 0 : (intptr_t) shape_plan->shaper_func;
-}
-#endif
-
-/* User-feature caching is currently somewhat dumb:
- * it only finds matches where the feature array is identical,
- * not cases where the feature lists would be compatible for plan purposes
- * but have different ranges, for example.
- */
-struct hb_shape_plan_proposal_t
-{
- const hb_segment_properties_t props;
- const char * const *shaper_list;
- const hb_feature_t *user_features;
- unsigned int num_user_features;
- const int *coords;
- unsigned int num_coords;
- hb_shape_func_t *shaper_func;
-};
-
-static inline hb_bool_t
-hb_shape_plan_user_features_match (const hb_shape_plan_t *shape_plan,
- const hb_shape_plan_proposal_t *proposal)
-{
- if (proposal->num_user_features != shape_plan->num_user_features)
- return false;
- for (unsigned int i = 0, n = proposal->num_user_features; i < n; i++)
- if (proposal->user_features[i].tag != shape_plan->user_features[i].tag ||
- proposal->user_features[i].value != shape_plan->user_features[i].value ||
- proposal->user_features[i].start != shape_plan->user_features[i].start ||
- proposal->user_features[i].end != shape_plan->user_features[i].end)
- return false;
- return true;
-}
-
-static inline hb_bool_t
-hb_shape_plan_coords_match (const hb_shape_plan_t *shape_plan,
- const hb_shape_plan_proposal_t *proposal)
-{
- if (proposal->num_coords != shape_plan->num_coords)
- return false;
- for (unsigned int i = 0, n = proposal->num_coords; i < n; i++)
- if (proposal->coords[i] != shape_plan->coords[i])
- return false;
- return true;
-}
-
-static hb_bool_t
-hb_shape_plan_matches (const hb_shape_plan_t *shape_plan,
- const hb_shape_plan_proposal_t *proposal)
-{
- return hb_segment_properties_equal (&shape_plan->props, &proposal->props) &&
- hb_shape_plan_user_features_match (shape_plan, proposal) &&
- hb_shape_plan_coords_match (shape_plan, proposal) &&
- ((shape_plan->default_shaper_list && !proposal->shaper_list) ||
- (shape_plan->shaper_func == proposal->shaper_func));
-}
-
-static inline hb_bool_t
-hb_non_global_user_features_present (const hb_feature_t *user_features,
- unsigned int num_user_features)
-{
- while (num_user_features) {
- if (user_features->start != 0 || user_features->end != (unsigned int) -1)
- return true;
- num_user_features--;
- user_features++;
- }
- return false;
-}
-
-static inline hb_bool_t
-hb_coords_present (const int *coords,
- unsigned int num_coords)
-{
- return num_coords != 0;
-}
-
/**
* hb_shape_plan_create_cached:
* @face:
@@ -489,62 +450,38 @@ hb_shape_plan_create_cached2 (hb_face_t *face,
num_user_features,
shaper_list);
- hb_shape_plan_proposal_t proposal = {
- *props,
- shaper_list,
- user_features,
- num_user_features,
- nullptr
- };
-
- if (shaper_list) {
- /* Choose shaper. Adapted from hb_shape_plan_plan().
- * Must choose shaper exactly the same way as that function. */
- for (const char * const *shaper_item = shaper_list; *shaper_item; shaper_item++)
- if (0)
- ;
-#define HB_SHAPER_IMPLEMENT(shaper) \
- else if (0 == strcmp (*shaper_item, #shaper) && \
- hb_##shaper##_shaper_face_data_ensure (face)) \
- { \
- proposal.shaper_func = _hb_##shaper##_shape; \
- break; \
- }
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-
- if (unlikely (!proposal.shaper_func))
- return hb_shape_plan_get_empty ();
- }
+retry:
+ hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans;
+ bool dont_cache = hb_object_is_inert (face);
-retry:
- hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans.get ();
+ if (likely (!dont_cache))
+ {
+ hb_shape_plan_key_t key;
+ if (!key.init (false,
+ face,
+ props,
+ user_features,
+ num_user_features,
+ coords,
+ num_coords,
+ shaper_list))
+ return hb_shape_plan_get_empty ();
- /* Don't look for plan in the cache if there were variation coordinates XXX Fix me. */
- if (!hb_coords_present (coords, num_coords))
for (hb_face_t::plan_node_t *node = cached_plan_nodes; node; node = node->next)
- if (hb_shape_plan_matches (node->shape_plan, &proposal))
+ if (node->shape_plan->key.equal (&key))
{
DEBUG_MSG_FUNC (SHAPE_PLAN, node->shape_plan, "fulfilled from cache");
return hb_shape_plan_reference (node->shape_plan);
}
+ }
- /* Not found. */
hb_shape_plan_t *shape_plan = hb_shape_plan_create2 (face, props,
user_features, num_user_features,
coords, num_coords,
shaper_list);
- /* Don't add to the cache if face is inert. */
- if (unlikely (hb_object_is_inert (face)))
- return shape_plan;
-
- /* Don't add the plan to the cache if there were user features with non-global ranges */
- if (hb_non_global_user_features_present (user_features, num_user_features))
- return shape_plan;
- /* Don't add the plan to the cache if there were variation coordinates XXX Fix me. */
- if (hb_coords_present (coords, num_coords))
+ if (unlikely (dont_cache))
return shape_plan;
hb_face_t::plan_node_t *node = (hb_face_t::plan_node_t *) calloc (1, sizeof (hb_face_t::plan_node_t));
@@ -564,19 +501,3 @@ retry:
return hb_shape_plan_reference (shape_plan);
}
-
-/**
- * hb_shape_plan_get_shaper:
- * @shape_plan: a shape plan.
- *
- *
- *
- * Return value: (transfer none):
- *
- * Since: 0.9.7
- **/
-const char *
-hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan)
-{
- return shape_plan->shaper_name;
-}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.hh
index bf82b912be0..d9aa3ee1ab4 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shape-plan.hh
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Google, Inc.
+ * Copyright © 2012,2018 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -29,39 +29,47 @@
#include "hb.hh"
#include "hb-shaper.hh"
+#include "hb-ot-shape.hh"
-struct hb_shape_plan_t
+struct hb_shape_plan_key_t
{
- hb_object_header_t header;
- ASSERT_POD ();
+ hb_segment_properties_t props;
- hb_bool_t default_shaper_list;
- hb_face_t *face_unsafe; /* We don't carry a reference to face. */
- hb_segment_properties_t props;
+ const hb_feature_t *user_features;
+ unsigned int num_user_features;
+
+ hb_ot_shape_plan_key_t ot;
+
+ hb_shape_func_t *shaper_func;
+ const char *shaper_name;
- hb_shape_func_t *shaper_func;
- const char *shaper_name;
+ HB_INTERNAL inline bool init (bool copy,
+ hb_face_t *face,
+ const hb_segment_properties_t *props,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features,
+ const int *coords,
+ unsigned int num_coords,
+ const char * const *shaper_list);
- hb_feature_t *user_features;
- unsigned int num_user_features;
+ HB_INTERNAL inline void free (void)
+ {
+ ::free ((void *) user_features);
+ }
- int *coords;
- unsigned int num_coords;
+ HB_INTERNAL bool user_features_match (const hb_shape_plan_key_t *other);
- struct hb_shaper_data_t shaper_data;
+ HB_INTERNAL bool equal (const hb_shape_plan_key_t *other);
};
-DECLARE_NULL_INSTANCE (hb_shape_plan_t);
-#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \
- , const hb_feature_t *user_features \
- , unsigned int num_user_features \
- , const int *coords \
- , unsigned int num_coords
-#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, shape_plan);
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
+struct hb_shape_plan_t
+{
+ hb_object_header_t header;
+ hb_face_t *face_unsafe; /* We don't carry a reference to face. */
+ hb_shape_plan_key_t key;
+ hb_ot_shape_plan_t ot;
+};
#endif /* HB_SHAPE_PLAN_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shape.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-shape.cc
index e8eeff5b354..45f3a6916e2 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shape.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shape.cc
@@ -34,19 +34,21 @@
#include "hb-font.hh"
#include "hb-machinery.hh"
+
/**
* SECTION:hb-shape
- * @title: Shaping
+ * @title: hb-shape
* @short_description: Conversion of text strings into positioned glyphs
* @include: hb.h
*
* Shaping is the central operation of HarfBuzz. Shaping operates on buffers,
* which are sequences of Unicode characters that use the same font and have
- * the same text direction, script and language. After shaping the buffer
+ * the same text direction, script, and language. After shaping the buffer
* contains the output glyphs and their positions.
**/
-#ifdef HB_USE_ATEXIT
+
+#if HB_USE_ATEXIT
static void free_static_shaper_list (void);
#endif
@@ -61,13 +63,13 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *,
if (unlikely (!shaper_list))
return nullptr;
- const hb_shaper_pair_t *shapers = _hb_shapers_get ();
+ const hb_shaper_entry_t *shapers = _hb_shapers_get ();
unsigned int i;
for (i = 0; i < HB_SHAPERS_COUNT; i++)
shaper_list[i] = shapers[i].name;
shaper_list[i] = nullptr;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_shaper_list);
#endif
@@ -83,7 +85,7 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *,
}
} static_shaper_list;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_shaper_list (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-impl.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-impl.hh
index d40cb085a23..b674fceb6af 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-impl.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-impl.hh
@@ -30,14 +30,9 @@
#include "hb.hh"
#include "hb-shaper.hh"
-#include "hb-shape-plan.hh"
+#include "hb-face.hh"
#include "hb-font.hh"
+#include "hb-shape-plan.hh"
#include "hb-buffer.hh"
-
-#ifdef HB_SHAPER
-#define HB_SHAPER_DATA_GET(object) HB_SHAPER_DATA (HB_SHAPER, object).get ()
-#endif
-
-
#endif /* HB_SHAPER_IMPL_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-list.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-list.hh
index b0835d31ab1..1fdb64810b3 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-list.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper-list.hh
@@ -39,9 +39,7 @@ HB_SHAPER_IMPLEMENT (graphite2)
HB_SHAPER_IMPLEMENT (coretext_aat)
#endif
-#ifdef HAVE_OT
HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */
-#endif
#ifdef HAVE_UNISCRIBE
HB_SHAPER_IMPLEMENT (uniscribe)
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.cc
index 52418c08234..b10927ecfcf 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.cc
@@ -29,26 +29,26 @@
#include "hb-machinery.hh"
-static const hb_shaper_pair_t all_shapers[] = {
+static const hb_shaper_entry_t all_shapers[] = {
#define HB_SHAPER_IMPLEMENT(name) {#name, _hb_##name##_shape},
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
};
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_shapers (void);
#endif
-static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_pair_t,
+static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_entry_t,
hb_shapers_lazy_loader_t>
{
- static inline hb_shaper_pair_t *create (void)
+ static inline hb_shaper_entry_t *create (void)
{
char *env = getenv ("HB_SHAPER_LIST");
if (!env || !*env)
return nullptr;
- hb_shaper_pair_t *shapers = (hb_shaper_pair_t *) calloc (1, sizeof (all_shapers));
+ hb_shaper_entry_t *shapers = (hb_shaper_entry_t *) calloc (1, sizeof (all_shapers));
if (unlikely (!shapers))
return nullptr;
@@ -68,7 +68,7 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_pair_t
0 == strncmp (shapers[j].name, p, end - p))
{
/* Reorder this shaper to position i */
- struct hb_shaper_pair_t t = shapers[j];
+ struct hb_shaper_entry_t t = shapers[j];
memmove (&shapers[i + 1], &shapers[i], sizeof (shapers[i]) * (j - i));
shapers[i] = t;
i++;
@@ -80,23 +80,23 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_pair_t
p = end + 1;
}
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_shapers);
#endif
return shapers;
}
- static inline void destroy (const hb_shaper_pair_t *p)
+ static inline void destroy (const hb_shaper_entry_t *p)
{
free ((void *) p);
}
- static inline const hb_shaper_pair_t *get_null (void)
+ static inline const hb_shaper_entry_t *get_null (void)
{
return all_shapers;
}
} static_shapers;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_shapers (void)
{
@@ -104,7 +104,7 @@ void free_static_shapers (void)
}
#endif
-const hb_shaper_pair_t *
+const hb_shaper_entry_t *
_hb_shapers_get (void)
{
return static_shapers.get_unconst ();
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.hh
index 361165e4f95..3fda27bc0ec 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-shaper.hh
@@ -28,6 +28,7 @@
#define HB_SHAPER_HH
#include "hb.hh"
+#include "hb-machinery.hh"
typedef hb_bool_t hb_shape_func_t (hb_shape_plan_t *shape_plan,
hb_font_t *font,
@@ -40,95 +41,94 @@ typedef hb_bool_t hb_shape_func_t (hb_shape_plan_t *shape_plan,
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
-struct hb_shaper_pair_t {
+struct hb_shaper_entry_t {
char name[16];
hb_shape_func_t *func;
};
-HB_INTERNAL const hb_shaper_pair_t *
+HB_INTERNAL const hb_shaper_entry_t *
_hb_shapers_get (void);
-/* Means: succeeded, but don't need to keep any data. */
-#define HB_SHAPER_DATA_SUCCEEDED ((void *) +1)
-/* Means: tried but failed to create. */
-#define HB_SHAPER_DATA_INVALID ((void *) -1)
+template <typename Data, unsigned int WheresData, typename T>
+struct hb_shaper_lazy_loader_t;
-#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_##object##_data_t
-#define HB_SHAPER_DATA_TYPE(shaper, object) struct HB_SHAPER_DATA_TYPE_NAME(shaper, object)
-#define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* reinterpret_cast<hb_atomic_ptr_t<HB_SHAPER_DATA_TYPE(shaper, object) *> *> (&(instance)->shaper_data.shaper))
-#define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE(shaper, object, object)
+#define HB_SHAPER_ORDER(Shaper) \
+ HB_PASTE (HB_SHAPER_ORDER_, Shaper)
+enum hb_shaper_order_t
+{
+ _HB_SHAPER_ORDER_ORDER_ZERO,
+#define HB_SHAPER_IMPLEMENT(Shaper) \
+ HB_SHAPER_ORDER (Shaper),
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+ _HB_SHAPERS_COUNT_PLUS_ONE,
+ HB_SHAPERS_COUNT = _HB_SHAPERS_COUNT_PLUS_ONE - 1,
+};
+
+template <enum hb_shaper_order_t order, typename Object> struct hb_shaper_object_data_type_t;
+
+#define HB_SHAPER_DATA_SUCCEEDED ((void *) +1)
+#define HB_SHAPER_DATA_TYPE(shaper, object) hb_##shaper##_##object##_data_t
#define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create
#define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy
-#define HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) hb_##shaper##_shaper_##object##_data_ensure
-#define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \
- HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \
+#define HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, object) \
+ \
+ struct HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \
extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \
- HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS); \
+ HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object); \
extern "C" HB_INTERNAL void \
- HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shaper, object) *data); \
- extern "C" HB_INTERNAL bool \
- HB_SHAPER_DATA_ENSURE_FUNC (shaper, object) (hb_##object##_t *object)
-
-#define HB_SHAPER_DATA_DESTROY(shaper, object) \
- if (HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object).get ()) \
- if (data != HB_SHAPER_DATA_INVALID && data != HB_SHAPER_DATA_SUCCEEDED) \
- HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data);
-
-#define HB_SHAPER_DATA_ENSURE_DEFINE(shaper, object) \
- HB_SHAPER_DATA_ENSURE_DEFINE_WITH_CONDITION(shaper, object, true)
-
-#define HB_SHAPER_DATA_ENSURE_DEFINE_WITH_CONDITION(shaper, object, condition) \
-bool \
-HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) (hb_##object##_t *object) \
-{\
- retry: \
- HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object).get (); \
- if (likely (data) && !(condition)) { \
- /* XXX-MT-bug \
- * Note that evaluating condition above can be dangerous if another thread \
- * got here first and destructed data. That's, as always, bad use pattern. \
- * If you modify the font (change font size), other threads must not be \
- * using it at the same time. However, since this check is delayed to \
- * when one actually tries to shape something, this is a XXX race condition \
- * (and the only know we have that I know of) right now. Ie. you modify the \
- * font size in one thread, then (supposedly safely) try to use it from two \
- * or more threads and BOOM! I'm not sure how to fix this. We want RCU. \
- * Maybe when it doesn't matter when we finally implement AAT shaping, as
- * this (condition) is currently only used by hb-coretext. */ \
- /* Drop and recreate. */ \
- /* If someone dropped it in the mean time, throw it away and don't touch it. \
- * Otherwise, destruct it. */ \
- if (likely (HB_SHAPER_DATA (shaper, object).cmpexch (data, nullptr))) \
- { \
- HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \
- } \
- goto retry; \
- } \
- if (unlikely (!data)) { \
- data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \
- if (unlikely (!data)) \
- data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \
- if (unlikely (!HB_SHAPER_DATA (shaper, object).cmpexch (nullptr, data))) { \
- if (data && \
- data != HB_SHAPER_DATA_INVALID && \
- data != HB_SHAPER_DATA_SUCCEEDED) \
- HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \
- goto retry; \
- } \
- } \
- return data != nullptr && (void *) data != HB_SHAPER_DATA_INVALID; \
-}
-
-
-/* For embedding in face / font / ... */
-struct hb_shaper_data_t {
-#define HB_SHAPER_IMPLEMENT(shaper) hb_atomic_ptr_t<void *> shaper;
+ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shaper, object) *shaper##_##object); \
+ \
+ template <> \
+ struct hb_shaper_object_data_type_t<HB_SHAPER_ORDER (shaper), hb_##object##_t> \
+ { \
+ typedef HB_SHAPER_DATA_TYPE(shaper, object) value; \
+ }; \
+ \
+ template <unsigned int WheresData> \
+ struct hb_shaper_lazy_loader_t<hb_##object##_t, WheresData, HB_SHAPER_DATA_TYPE(shaper, object)> \
+ : hb_lazy_loader_t<HB_SHAPER_DATA_TYPE(shaper, object), \
+ hb_shaper_lazy_loader_t<hb_##object##_t, \
+ WheresData, \
+ HB_SHAPER_DATA_TYPE(shaper, object)>, \
+ hb_##object##_t, WheresData> \
+ { \
+ typedef HB_SHAPER_DATA_TYPE(shaper, object) Type; \
+ static inline Type* create (hb_##object##_t *data) \
+ { return HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (data); } \
+ static inline Type *get_null (void) { return nullptr; } \
+ static inline void destroy (Type *p) { HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (p); } \
+ }; \
+ \
+ static_assert (true, "") /* Require semicolon. */
+
+
+template <typename Object>
+struct hb_shaper_object_dataset_t
+{
+ inline void init0 (Object *parent_data)
+ {
+ this->parent_data = parent_data;
+#define HB_SHAPER_IMPLEMENT(shaper) shaper.init0 ();
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
-};
-#define HB_SHAPERS_COUNT (sizeof (hb_shaper_data_t) / sizeof (void *))
+ }
+ inline void fini (void)
+ {
+#define HB_SHAPER_IMPLEMENT(shaper) shaper.fini ();
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+ }
+ Object *parent_data; /* MUST be JUST before the lazy loaders. */
+#define HB_SHAPER_IMPLEMENT(shaper) \
+ hb_shaper_lazy_loader_t<Object, HB_SHAPER_ORDER(shaper), \
+ typename hb_shaper_object_data_type_t<HB_SHAPER_ORDER(shaper), Object>::value \
+ > shaper;
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+};
#endif /* HB_SHAPER_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-static.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-static.cc
index 5112d77be0a..a22f729ef6e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-static.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-static.cc
@@ -27,9 +27,12 @@
#include "hb.hh"
#include "hb-open-type.hh"
-#include "hb-ot-layout-common.hh"
-
#include "hb-face.hh"
+
+#include "hb-aat-layout-common.hh"
+#include "hb-aat-layout-feat-table.hh"
+#include "hb-ot-layout-common.hh"
+#include "hb-ot-cmap-table.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
@@ -41,26 +44,32 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_
DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
+DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};
+DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF};
+/* Hand-coded because Lookup is a template. Sad. */
+const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF};
-void
+unsigned int
hb_face_t::load_num_glyphs (void) const
{
hb_sanitize_context_t c = hb_sanitize_context_t ();
c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */
hb_blob_t *maxp_blob = c.reference_table<OT::maxp> (this);
const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
- num_glyphs = maxp_table->get_num_glyphs ();
+
+ unsigned int ret = maxp_table->get_num_glyphs ();
+ num_glyphs.set_relaxed (ret);
hb_blob_destroy (maxp_blob);
+ return ret;
}
-void
+unsigned int
hb_face_t::load_upem (void) const
{
- hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table<OT::head> (this);
- const OT::head *head_table = head_blob->as<OT::head> ();
- upem = head_table->get_upem ();
- hb_blob_destroy (head_blob);
+ unsigned int ret = table.head->get_upem ();
+ upem.set_relaxed (ret);
+ return ret;
}
#endif
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.cc
index 499380a9773..2219d379c1e 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.cc
@@ -31,12 +31,12 @@
static bool
_calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
- hb_vector_t<hb_codepoint_t> &glyph_ids,
- hb_bool_t drop_hints,
- bool *use_short_loca /* OUT */,
- unsigned int *glyf_size /* OUT */,
- unsigned int *loca_size /* OUT */,
- hb_vector_t<unsigned int> *instruction_ranges /* OUT */)
+ hb_vector_t<hb_codepoint_t> &glyph_ids,
+ hb_bool_t drop_hints,
+ bool *use_short_loca /* OUT */,
+ unsigned int *glyf_size /* OUT */,
+ unsigned int *loca_size /* OUT */,
+ hb_vector_t<unsigned int> *instruction_ranges /* OUT */)
{
unsigned int total = 0;
for (unsigned int i = 0; i < glyph_ids.len; i++)
@@ -53,8 +53,8 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
*instruction_end = 0;
unsigned int start_offset, end_offset;
- if (unlikely (!(glyf.get_offsets(next_glyph, &start_offset, &end_offset)
- && glyf.remove_padding(start_offset, &end_offset))))
+ if (unlikely (!(glyf.get_offsets (next_glyph, &start_offset, &end_offset) &&
+ glyf.remove_padding (start_offset, &end_offset))))
{
DEBUG_MSG(SUBSET, nullptr, "Invalid gid %d", next_glyph);
continue;
@@ -64,11 +64,11 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
if (drop_hints)
{
- if (unlikely (!glyf.get_instruction_offsets(start_offset, end_offset,
- instruction_start, instruction_end)))
+ if (unlikely (!glyf.get_instruction_offsets (start_offset, end_offset,
+ instruction_start, instruction_end)))
{
- DEBUG_MSG(SUBSET, nullptr, "Unable to get instruction offsets for %d", next_glyph);
- return false;
+ DEBUG_MSG(SUBSET, nullptr, "Unable to get instruction offsets for %d", next_glyph);
+ return false;
}
}
@@ -80,21 +80,21 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
*glyf_size = total;
*use_short_loca = (total <= 131070);
*loca_size = (glyph_ids.len + 1)
- * (*use_short_loca ? sizeof(OT::HBUINT16) : sizeof(OT::HBUINT32));
+ * (*use_short_loca ? sizeof (OT::HBUINT16) : sizeof (OT::HBUINT32));
DEBUG_MSG(SUBSET, nullptr, "preparing to subset glyf: final size %d, loca size %d, using %s loca",
- total,
- *loca_size,
- *use_short_loca ? "short" : "long");
+ total,
+ *loca_size,
+ *use_short_loca ? "short" : "long");
return true;
}
static bool
_write_loca_entry (unsigned int id,
- unsigned int offset,
- bool is_short,
- void *loca_prime,
- unsigned int loca_size)
+ unsigned int offset,
+ bool is_short,
+ void *loca_prime,
+ unsigned int loca_size)
{
unsigned int entry_size = is_short ? sizeof (OT::HBUINT16) : sizeof (OT::HBUINT32);
if ((id + 1) * entry_size <= loca_size)
@@ -108,11 +108,11 @@ _write_loca_entry (unsigned int id,
}
// Offset was not written because the write is out of bounds.
- DEBUG_MSG (SUBSET,
- nullptr,
- "WARNING: Attempted to write an out of bounds loca entry at index %d. Loca size is %d.",
- id,
- loca_size);
+ DEBUG_MSG(SUBSET,
+ nullptr,
+ "WARNING: Attempted to write an out of bounds loca entry at index %d. Loca size is %d.",
+ id,
+ loca_size);
return false;
}
@@ -130,15 +130,15 @@ _update_components (hb_subset_plan_t * plan,
{
hb_codepoint_t new_gid;
if (!plan->new_gid_for_old_gid (iterator.current->glyphIndex,
- &new_gid))
+ &new_gid))
continue;
((OT::glyf::CompositeGlyphHeader *) iterator.current)->glyphIndex.set (new_gid);
- } while (iterator.move_to_next());
+ } while (iterator.move_to_next ());
}
}
-static bool _remove_composite_instruction_flag(char *glyf_prime, unsigned int length)
+static bool _remove_composite_instruction_flag (char *glyf_prime, unsigned int length)
{
/* remove WE_HAVE_INSTRUCTIONS from flags in dest */
OT::glyf::CompositeGlyphHeader::Iterator composite_it;
@@ -148,20 +148,20 @@ static bool _remove_composite_instruction_flag(char *glyf_prime, unsigned int le
glyph = composite_it.current;
OT::HBUINT16 *flags = const_cast<OT::HBUINT16 *> (&glyph->flags);
flags->set ( (uint16_t) *flags & ~OT::glyf::CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS);
- } while (composite_it.move_to_next());
+ } while (composite_it.move_to_next ());
return true;
}
static bool
_write_glyf_and_loca_prime (hb_subset_plan_t *plan,
const OT::glyf::accelerator_t &glyf,
- const char *glyf_data,
- bool use_short_loca,
- hb_vector_t<unsigned int> &instruction_ranges,
- unsigned int glyf_prime_size,
- char *glyf_prime_data /* OUT */,
- unsigned int loca_prime_size,
- char *loca_prime_data /* OUT */)
+ const char *glyf_data,
+ bool use_short_loca,
+ hb_vector_t<unsigned int> &instruction_ranges,
+ unsigned int glyf_prime_size,
+ char *glyf_prime_data /* OUT */,
+ unsigned int loca_prime_size,
+ char *loca_prime_data /* OUT */)
{
hb_vector_t<hb_codepoint_t> &glyph_ids = plan->glyphs;
char *glyf_prime_data_next = glyf_prime_data;
@@ -170,8 +170,8 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
for (unsigned int i = 0; i < glyph_ids.len; i++)
{
unsigned int start_offset, end_offset;
- if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset)
- && glyf.remove_padding(start_offset, &end_offset))))
+ if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset) &&
+ glyf.remove_padding (start_offset, &end_offset))))
end_offset = start_offset = 0;
unsigned int instruction_start = instruction_ranges[i * 2];
@@ -181,10 +181,10 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
if (glyf_prime_data_next + length > glyf_prime_data + glyf_prime_size)
{
- DEBUG_MSG (SUBSET,
- nullptr,
- "WARNING: Attempted to write an out of bounds glyph entry for gid %d (length %d)",
- i, length);
+ DEBUG_MSG(SUBSET,
+ nullptr,
+ "WARNING: Attempted to write an out of bounds glyph entry for gid %d (length %d)",
+ i, length);
return false;
}
@@ -197,18 +197,18 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
/* if the instructions end at the end this was a composite glyph, else simple */
if (instruction_end == end_offset)
{
- if (unlikely (!_remove_composite_instruction_flag (glyf_prime_data_next, length))) return false;
+ if (unlikely (!_remove_composite_instruction_flag (glyf_prime_data_next, length))) return false;
}
else
- /* zero instruction length, which is just before instruction_start */
- memset (glyf_prime_data_next + instruction_start - start_offset - 2, 0, 2);
+ /* zero instruction length, which is just before instruction_start */
+ memset (glyf_prime_data_next + instruction_start - start_offset - 2, 0, 2);
}
success = success && _write_loca_entry (i,
- glyf_prime_data_next - glyf_prime_data,
- use_short_loca,
- loca_prime_data,
- loca_prime_size);
+ glyf_prime_data_next - glyf_prime_data,
+ use_short_loca,
+ loca_prime_data,
+ loca_prime_size);
_update_components (plan, glyf_prime_data_next, length);
// TODO: don't align to two bytes if using long loca.
@@ -216,20 +216,20 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan,
}
success = success && _write_loca_entry (glyph_ids.len,
- glyf_prime_data_next - glyf_prime_data,
- use_short_loca,
- loca_prime_data,
- loca_prime_size);
+ glyf_prime_data_next - glyf_prime_data,
+ use_short_loca,
+ loca_prime_data,
+ loca_prime_size);
return success;
}
static bool
_hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
- const char *glyf_data,
- hb_subset_plan_t *plan,
- bool *use_short_loca,
- hb_blob_t **glyf_prime /* OUT */,
- hb_blob_t **loca_prime /* OUT */)
+ const char *glyf_data,
+ hb_subset_plan_t *plan,
+ bool *use_short_loca,
+ hb_blob_t **glyf_prime /* OUT */,
+ hb_blob_t **loca_prime /* OUT */)
{
// TODO(grieger): Sanity check allocation size for the new table.
hb_vector_t<hb_codepoint_t> &glyphs_to_retain = plan->glyphs;
@@ -237,43 +237,43 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
unsigned int glyf_prime_size;
unsigned int loca_prime_size;
hb_vector_t<unsigned int> instruction_ranges;
- instruction_ranges.init();
+ instruction_ranges.init ();
if (unlikely (!_calculate_glyf_and_loca_prime_size (glyf,
- glyphs_to_retain,
- plan->drop_hints,
- use_short_loca,
- &glyf_prime_size,
- &loca_prime_size,
- &instruction_ranges))) {
- instruction_ranges.fini();
+ glyphs_to_retain,
+ plan->drop_hints,
+ use_short_loca,
+ &glyf_prime_size,
+ &loca_prime_size,
+ &instruction_ranges))) {
+ instruction_ranges.fini ();
return false;
}
char *glyf_prime_data = (char *) calloc (1, glyf_prime_size);
char *loca_prime_data = (char *) calloc (1, loca_prime_size);
if (unlikely (!_write_glyf_and_loca_prime (plan, glyf, glyf_data,
- *use_short_loca,
- instruction_ranges,
- glyf_prime_size, glyf_prime_data,
- loca_prime_size, loca_prime_data))) {
+ *use_short_loca,
+ instruction_ranges,
+ glyf_prime_size, glyf_prime_data,
+ loca_prime_size, loca_prime_data))) {
free (glyf_prime_data);
free (loca_prime_data);
- instruction_ranges.fini();
+ instruction_ranges.fini ();
return false;
}
- instruction_ranges.fini();
+ instruction_ranges.fini ();
*glyf_prime = hb_blob_create (glyf_prime_data,
- glyf_prime_size,
- HB_MEMORY_MODE_READONLY,
- glyf_prime_data,
- free);
+ glyf_prime_size,
+ HB_MEMORY_MODE_READONLY,
+ glyf_prime_data,
+ free);
*loca_prime = hb_blob_create (loca_prime_data,
- loca_prime_size,
- HB_MEMORY_MODE_READONLY,
- loca_prime_data,
- free);
+ loca_prime_size,
+ HB_MEMORY_MODE_READONLY,
+ loca_prime_data,
+ free);
return true;
}
@@ -287,24 +287,24 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
**/
bool
hb_subset_glyf_and_loca (hb_subset_plan_t *plan,
- bool *use_short_loca, /* OUT */
- hb_blob_t **glyf_prime, /* OUT */
- hb_blob_t **loca_prime /* OUT */)
+ bool *use_short_loca, /* OUT */
+ hb_blob_t **glyf_prime, /* OUT */
+ hb_blob_t **loca_prime /* OUT */)
{
hb_blob_t *glyf_blob = hb_sanitize_context_t ().reference_table<OT::glyf> (plan->source);
- const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr);
+ const char *glyf_data = hb_blob_get_data (glyf_blob, nullptr);
OT::glyf::accelerator_t glyf;
- glyf.init(plan->source);
+ glyf.init (plan->source);
bool result = _hb_subset_glyf_and_loca (glyf,
- glyf_data,
- plan,
- use_short_loca,
- glyf_prime,
- loca_prime);
+ glyf_data,
+ plan,
+ use_short_loca,
+ glyf_prime,
+ loca_prime);
hb_blob_destroy (glyf_blob);
- glyf.fini();
+ glyf.fini ();
return result;
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.hh
index 3109ecb643a..99cf8f07112 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-glyf.hh
@@ -33,8 +33,8 @@
HB_INTERNAL bool
hb_subset_glyf_and_loca (hb_subset_plan_t *plan,
- bool *use_short_loca, /* OUT */
- hb_blob_t **glyf_prime /* OUT */,
- hb_blob_t **loca_prime /* OUT */);
+ bool *use_short_loca, /* OUT */
+ hb_blob_t **glyf_prime /* OUT */,
+ hb_blob_t **loca_prime /* OUT */);
#endif /* HB_SUBSET_GLYF_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.cc
index d59b5bae03c..aafd31b9d3f 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.cc
@@ -72,7 +72,7 @@ hb_subset_input_reference (hb_subset_input_t *subset_input)
* Since: 1.8.0
**/
void
-hb_subset_input_destroy(hb_subset_input_t *subset_input)
+hb_subset_input_destroy (hb_subset_input_t *subset_input)
{
if (!hb_object_destroy (subset_input)) return;
@@ -121,7 +121,7 @@ hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input)
HB_EXTERN void
hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input,
- hb_bool_t drop_layout)
+ hb_bool_t drop_layout)
{
subset_input->drop_layout = drop_layout;
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.hh
index 9fc86154e40..7f625f2e443 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-input.hh
@@ -37,7 +37,6 @@
struct hb_subset_input_t
{
hb_object_header_t header;
- ASSERT_POD ();
hb_set_t *unicodes;
hb_set_t *glyphs;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.cc
index 0570060399d..56a2bba522d 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.cc
@@ -55,26 +55,37 @@ _add_gid_and_children (const OT::glyf::accelerator_t &glyf,
static void
_gsub_closure (hb_face_t *face, hb_set_t *gids_to_retain)
{
- hb_auto_t<hb_set_t> lookup_indices;
+ hb_set_t lookup_indices;
hb_ot_layout_collect_lookups (face,
- HB_OT_TAG_GSUB,
- nullptr,
- nullptr,
- nullptr,
- &lookup_indices);
+ HB_OT_TAG_GSUB,
+ nullptr,
+ nullptr,
+ nullptr,
+ &lookup_indices);
hb_ot_layout_lookups_substitute_closure (face,
- &lookup_indices,
- gids_to_retain);
+ &lookup_indices,
+ gids_to_retain);
}
+static void
+_remove_invalid_gids (hb_set_t *glyphs,
+ unsigned int num_glyphs)
+{
+ hb_codepoint_t gid = HB_SET_VALUE_INVALID;
+ while (glyphs->next (&gid))
+ {
+ if (gid >= num_glyphs)
+ glyphs->del (gid);
+ }
+}
static hb_set_t *
_populate_gids_to_retain (hb_face_t *face,
- const hb_set_t *unicodes,
- bool close_over_gsub,
- hb_set_t *unicodes_to_retain,
- hb_map_t *codepoint_to_glyph,
- hb_vector_t<hb_codepoint_t> *glyphs)
+ const hb_set_t *unicodes,
+ bool close_over_gsub,
+ hb_set_t *unicodes_to_retain,
+ hb_map_t *codepoint_to_glyph,
+ hb_vector_t<hb_codepoint_t> *glyphs)
{
OT::cmap::accelerator_t cmap;
OT::glyf::accelerator_t glyf;
@@ -112,6 +123,8 @@ _populate_gids_to_retain (hb_face_t *face,
}
hb_set_destroy (initial_gids_to_retain);
+ _remove_invalid_gids (all_gids_to_retain, face->get_num_glyphs ());
+
glyphs->alloc (all_gids_to_retain->get_population ());
gid = HB_SET_VALUE_INVALID;
while (all_gids_to_retain->next (&gid))
@@ -125,7 +138,7 @@ _populate_gids_to_retain (hb_face_t *face,
static void
_create_old_gid_to_new_gid_map (const hb_vector_t<hb_codepoint_t> &glyphs,
- hb_map_t *glyph_map)
+ hb_map_t *glyph_map)
{
for (unsigned int i = 0; i < glyphs.len; i++) {
glyph_map->set (glyphs[i], i);
@@ -144,7 +157,7 @@ _create_old_gid_to_new_gid_map (const hb_vector_t<hb_codepoint_t> &glyphs,
**/
hb_subset_plan_t *
hb_subset_plan_create (hb_face_t *face,
- hb_subset_input_t *input)
+ hb_subset_input_t *input)
{
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
@@ -163,7 +176,7 @@ hb_subset_plan_create (hb_face_t *face,
plan->codepoint_to_glyph,
&plan->glyphs);
_create_old_gid_to_new_gid_map (plan->glyphs,
- plan->glyph_map);
+ plan->glyph_map);
return plan;
}
@@ -179,7 +192,7 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
if (!hb_object_destroy (plan)) return;
hb_set_destroy (plan->unicodes);
- plan->glyphs.fini();
+ plan->glyphs.fini ();
hb_face_destroy (plan->source);
hb_face_destroy (plan->dest);
hb_map_destroy (plan->codepoint_to_glyph);
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.hh
index c2c484a5bef..c574f8f810b 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset-plan.hh
@@ -37,7 +37,6 @@
struct hb_subset_plan_t
{
hb_object_header_t header;
- ASSERT_POD ();
bool drop_hints : 1;
bool drop_layout : 1;
@@ -57,7 +56,7 @@ struct hb_subset_plan_t
inline bool
new_gid_for_codepoint (hb_codepoint_t codepoint,
- hb_codepoint_t *new_gid) const
+ hb_codepoint_t *new_gid) const
{
hb_codepoint_t old_gid = codepoint_to_glyph->get (codepoint);
if (old_gid == HB_MAP_VALUE_INVALID)
@@ -68,7 +67,7 @@ struct hb_subset_plan_t
inline bool
new_gid_for_old_gid (hb_codepoint_t old_gid,
- hb_codepoint_t *new_gid) const
+ hb_codepoint_t *new_gid) const
{
hb_codepoint_t gid = glyph_map->get (old_gid);
if (gid == HB_MAP_VALUE_INVALID)
@@ -80,13 +79,13 @@ struct hb_subset_plan_t
inline bool
add_table (hb_tag_t tag,
- hb_blob_t *contents)
+ hb_blob_t *contents)
{
hb_blob_t *source_blob = source->reference_table (tag);
DEBUG_MSG(SUBSET, nullptr, "add table %c%c%c%c, dest %d bytes, source %d bytes",
- HB_UNTAG(tag),
- hb_blob_get_length (contents),
- hb_blob_get_length (source_blob));
+ HB_UNTAG(tag),
+ hb_blob_get_length (contents),
+ hb_blob_get_length (source_blob));
hb_blob_destroy (source_blob);
return hb_face_builder_add_table (dest, tag, contents);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.cc
index 2bed35868e9..a3917b8626b 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.cc
@@ -68,25 +68,25 @@ _subset2 (hb_subset_plan_t *plan)
hb_bool_t result = false;
if (source_blob->data)
{
- hb_auto_t<hb_vector_t<char> > buf;
+ hb_vector_t<char> buf;
unsigned int buf_size = _plan_estimate_subset_table_size (plan, source_blob->length);
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG(tag), buf_size);
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
if (unlikely (!buf.alloc (buf_size)))
{
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG(tag), buf_size);
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
return false;
}
retry:
- hb_serialize_context_t serializer (buf.arrayZ, buf_size);
+ hb_serialize_context_t serializer (buf, buf_size);
hb_subset_context_t c (plan, &serializer);
result = table->subset (&c);
if (serializer.ran_out_of_room)
{
buf_size += (buf_size >> 1) + 32;
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG(tag), buf_size);
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG (tag), buf_size);
if (unlikely (!buf.alloc (buf_size)))
{
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.", HB_UNTAG(tag), buf_size);
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.", HB_UNTAG (tag), buf_size);
return false;
}
goto retry;
@@ -94,21 +94,21 @@ _subset2 (hb_subset_plan_t *plan)
if (result)
{
hb_blob_t *dest_blob = serializer.copy_blob ();
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG(tag), dest_blob->length);
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c final subset table size: %u bytes.", HB_UNTAG (tag), dest_blob->length);
result = c.plan->add_table (tag, dest_blob);
hb_blob_destroy (dest_blob);
}
else
{
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG(tag));
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
result = true;
}
}
else
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG(tag));
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
hb_blob_destroy (source_blob);
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG(tag), result ? "success" : "FAILED!");
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG (tag), result ? "success" : "FAILED!");
return result;
}
@@ -124,19 +124,19 @@ _subset (hb_subset_plan_t *plan)
if (source_blob->data)
result = table->subset (plan);
else
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG(tag));
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
hb_blob_destroy (source_blob);
- DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG(tag), result ? "success" : "FAILED!");
+ DEBUG_MSG(SUBSET, nullptr, "OT::%c%c%c%c::subset %s", HB_UNTAG (tag), result ? "success" : "FAILED!");
return result;
}
static bool
_subset_table (hb_subset_plan_t *plan,
- hb_tag_t tag)
+ hb_tag_t tag)
{
- DEBUG_MSG(SUBSET, nullptr, "begin subset %c%c%c%c", HB_UNTAG(tag));
+ DEBUG_MSG(SUBSET, nullptr, "begin subset %c%c%c%c", HB_UNTAG (tag));
bool result = true;
switch (tag) {
case HB_OT_TAG_glyf:
@@ -171,8 +171,8 @@ _subset_table (hb_subset_plan_t *plan,
case HB_OT_TAG_cmap:
result = _subset<const OT::cmap> (plan);
break;
- case HB_OT_TAG_os2:
- result = _subset<const OT::os2> (plan);
+ case HB_OT_TAG_OS2:
+ result = _subset<const OT::OS2> (plan);
break;
case HB_OT_TAG_post:
result = _subset<const OT::post> (plan);
@@ -186,20 +186,20 @@ _subset_table (hb_subset_plan_t *plan,
break;
default:
- hb_blob_t *source_table = hb_face_reference_table(plan->source, tag);
+ hb_blob_t *source_table = hb_face_reference_table (plan->source, tag);
if (likely (source_table))
- result = plan->add_table(tag, source_table);
+ result = plan->add_table (tag, source_table);
else
- result = false;
+ result = false;
hb_blob_destroy (source_table);
break;
}
- DEBUG_MSG(SUBSET, nullptr, "subset %c%c%c%c %s", HB_UNTAG(tag), result ? "ok" : "FAILED");
+ DEBUG_MSG(SUBSET, nullptr, "subset %c%c%c%c %s", HB_UNTAG (tag), result ? "ok" : "FAILED");
return result;
}
static bool
-_should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag)
+_should_drop_table (hb_subset_plan_t *plan, hb_tag_t tag)
{
switch (tag) {
case HB_TAG ('c', 'v', 'a', 'r'): /* hint table, fallthrough */
@@ -248,9 +248,9 @@ _should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag)
**/
hb_face_t *
hb_subset (hb_face_t *source,
- hb_subset_input_t *input)
+ hb_subset_input_t *input)
{
- if (unlikely (!input || !source)) return hb_face_get_empty();
+ if (unlikely (!input || !source)) return hb_face_get_empty ();
hb_subset_plan_t *plan = hb_subset_plan_create (source, input);
@@ -263,17 +263,17 @@ hb_subset (hb_face_t *source,
for (unsigned int i = 0; i < count; i++)
{
hb_tag_t tag = table_tags[i];
- if (_should_drop_table(plan, tag))
+ if (_should_drop_table (plan, tag))
{
- DEBUG_MSG(SUBSET, nullptr, "drop %c%c%c%c", HB_UNTAG(tag));
- continue;
+ DEBUG_MSG(SUBSET, nullptr, "drop %c%c%c%c", HB_UNTAG (tag));
+ continue;
}
success = success && _subset_table (plan, tag);
}
offset += count;
} while (success && count == ARRAY_LENGTH (table_tags));
- hb_face_t *result = success ? hb_face_reference(plan->dest) : hb_face_get_empty();
+ hb_face_t *result = success ? hb_face_reference (plan->dest) : hb_face_get_empty ();
hb_subset_plan_destroy (plan);
return result;
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.h b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.h
index 8b07a45e923..3b306dd81f5 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.h
@@ -62,15 +62,14 @@ hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input);
HB_EXTERN void
hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input,
- hb_bool_t drop_layout);
+ hb_bool_t drop_layout);
HB_EXTERN hb_bool_t
hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input);
-/* hb_subset() */
+/* hb_subset () */
HB_EXTERN hb_face_t *
-hb_subset (hb_face_t *source,
- hb_subset_input_t *input);
+hb_subset (hb_face_t *source, hb_subset_input_t *input);
HB_END_DECLS
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.hh
index 9cdd388d780..e43c79f5ee6 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-subset.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-subset.hh
@@ -43,7 +43,7 @@ struct hb_subset_context_t :
template <typename T>
inline bool dispatch (const T &obj) { return obj.subset (this); }
static bool default_return_value (void) { return true; }
- bool stop_sublookup_iteration (bool r) const { return false; }
+ bool stop_sublookup_iteration (bool r HB_UNUSED) const { return false; }
hb_subset_plan_t *plan;
hb_serialize_context_t *serializer;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-ucdn.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-ucdn.cc
index 41be586c860..10608aff518 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-ucdn.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-ucdn.cc
@@ -16,7 +16,6 @@
#include "hb.hh"
-#include "hb-unicode.hh"
#include "hb-machinery.hh"
#include "ucdn.h"
@@ -182,15 +181,6 @@ hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs HB_UNUSED,
return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode);
}
-static unsigned int
-hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t unicode,
- void *user_data HB_UNUSED)
-{
- int w = ucdn_get_east_asian_width(unicode);
- return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1;
-}
-
static hb_unicode_general_category_t
hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode,
@@ -231,16 +221,8 @@ hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ucdn_decompose(ab, a, b);
}
-static unsigned int
-hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs HB_UNUSED,
- hb_codepoint_t u, hb_codepoint_t *decomposed,
- void *user_data HB_UNUSED)
-{
- return ucdn_compat_decompose(u, decomposed);
-}
-
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static void free_static_ucdn_funcs (void);
#endif
@@ -250,14 +232,16 @@ static struct hb_ucdn_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader
{
hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr);
-#define HB_UNICODE_FUNC_IMPLEMENT(name) \
- hb_unicode_funcs_set_##name##_func (funcs, hb_ucdn_##name, nullptr, nullptr);
- HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
-#undef HB_UNICODE_FUNC_IMPLEMENT
+ hb_unicode_funcs_set_combining_class_func (funcs, hb_ucdn_combining_class, nullptr, nullptr);
+ hb_unicode_funcs_set_general_category_func (funcs, hb_ucdn_general_category, nullptr, nullptr);
+ hb_unicode_funcs_set_mirroring_func (funcs, hb_ucdn_mirroring, nullptr, nullptr);
+ hb_unicode_funcs_set_script_func (funcs, hb_ucdn_script, nullptr, nullptr);
+ hb_unicode_funcs_set_compose_func (funcs, hb_ucdn_compose, nullptr, nullptr);
+ hb_unicode_funcs_set_decompose_func (funcs, hb_ucdn_decompose, nullptr, nullptr);
hb_unicode_funcs_make_immutable (funcs);
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_ucdn_funcs);
#endif
@@ -265,7 +249,7 @@ static struct hb_ucdn_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader
}
} static_ucdn_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_ucdn_funcs (void)
{
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode-emoji-table.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode-emoji-table.hh
index 41199de53c8..1dd0b3211e8 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode-emoji-table.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode-emoji-table.hh
@@ -47,38 +47,9 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t
{0x25FB, 0x25FE},
{0x2600, 0x2605},
{0x2607, 0x2612},
- {0x2614, 0x2615},
- {0x2616, 0x2617},
- {0x2618, 0x2618},
- {0x2619, 0x2619},
- {0x261A, 0x266F},
- {0x2670, 0x2671},
- {0x2672, 0x267D},
- {0x267E, 0x267F},
- {0x2680, 0x2685},
- {0x2690, 0x2691},
- {0x2692, 0x269C},
- {0x269D, 0x269D},
- {0x269E, 0x269F},
- {0x26A0, 0x26A1},
- {0x26A2, 0x26B1},
- {0x26B2, 0x26B2},
- {0x26B3, 0x26BC},
- {0x26BD, 0x26BF},
- {0x26C0, 0x26C3},
- {0x26C4, 0x26CD},
- {0x26CE, 0x26CE},
- {0x26CF, 0x26E1},
- {0x26E2, 0x26E2},
- {0x26E3, 0x26E3},
- {0x26E4, 0x26E7},
- {0x26E8, 0x26FF},
- {0x2700, 0x2700},
- {0x2701, 0x2704},
- {0x2705, 0x2705},
- {0x2708, 0x2709},
- {0x270A, 0x270B},
- {0x270C, 0x2712},
+ {0x2614, 0x2685},
+ {0x2690, 0x2705},
+ {0x2708, 0x2712},
{0x2714, 0x2714},
{0x2716, 0x2716},
{0x271D, 0x271D},
@@ -105,163 +76,33 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t
{0x303D, 0x303D},
{0x3297, 0x3297},
{0x3299, 0x3299},
- {0x1F000, 0x1F02B},
- {0x1F02C, 0x1F02F},
- {0x1F030, 0x1F093},
- {0x1F094, 0x1F09F},
- {0x1F0A0, 0x1F0AE},
- {0x1F0AF, 0x1F0B0},
- {0x1F0B1, 0x1F0BE},
- {0x1F0BF, 0x1F0BF},
- {0x1F0C0, 0x1F0C0},
- {0x1F0C1, 0x1F0CF},
- {0x1F0D0, 0x1F0D0},
- {0x1F0D1, 0x1F0DF},
- {0x1F0E0, 0x1F0F5},
- {0x1F0F6, 0x1F0FF},
+ {0x1F000, 0x1F0FF},
{0x1F10D, 0x1F10F},
{0x1F12F, 0x1F12F},
- {0x1F16C, 0x1F16F},
- {0x1F170, 0x1F171},
- {0x1F17E, 0x1F17E},
- {0x1F17F, 0x1F17F},
+ {0x1F16C, 0x1F171},
+ {0x1F17E, 0x1F17F},
{0x1F18E, 0x1F18E},
{0x1F191, 0x1F19A},
{0x1F1AD, 0x1F1E5},
- {0x1F201, 0x1F202},
- {0x1F203, 0x1F20F},
+ {0x1F201, 0x1F20F},
{0x1F21A, 0x1F21A},
{0x1F22F, 0x1F22F},
{0x1F232, 0x1F23A},
{0x1F23C, 0x1F23F},
- {0x1F249, 0x1F24F},
- {0x1F250, 0x1F251},
- {0x1F252, 0x1F25F},
- {0x1F260, 0x1F265},
- {0x1F266, 0x1F2FF},
- {0x1F300, 0x1F320},
- {0x1F321, 0x1F32C},
- {0x1F32D, 0x1F32F},
- {0x1F330, 0x1F335},
- {0x1F336, 0x1F336},
- {0x1F337, 0x1F37C},
- {0x1F37D, 0x1F37D},
- {0x1F37E, 0x1F37F},
- {0x1F380, 0x1F393},
- {0x1F394, 0x1F39F},
- {0x1F3A0, 0x1F3C4},
- {0x1F3C5, 0x1F3C5},
- {0x1F3C6, 0x1F3CA},
- {0x1F3CB, 0x1F3CE},
- {0x1F3CF, 0x1F3D3},
- {0x1F3D4, 0x1F3DF},
- {0x1F3E0, 0x1F3F0},
- {0x1F3F1, 0x1F3F7},
- {0x1F3F8, 0x1F3FA},
- {0x1F400, 0x1F43E},
- {0x1F43F, 0x1F43F},
- {0x1F440, 0x1F440},
- {0x1F441, 0x1F441},
- {0x1F442, 0x1F4F7},
- {0x1F4F8, 0x1F4F8},
- {0x1F4F9, 0x1F4FC},
- {0x1F4FD, 0x1F4FE},
- {0x1F4FF, 0x1F4FF},
- {0x1F500, 0x1F53D},
- {0x1F546, 0x1F54A},
- {0x1F54B, 0x1F54F},
- {0x1F550, 0x1F567},
- {0x1F568, 0x1F579},
- {0x1F57A, 0x1F57A},
- {0x1F57B, 0x1F5A3},
- {0x1F5A4, 0x1F5A4},
- {0x1F5A5, 0x1F5FA},
- {0x1F5FB, 0x1F5FF},
- {0x1F600, 0x1F600},
- {0x1F601, 0x1F610},
- {0x1F611, 0x1F611},
- {0x1F612, 0x1F614},
- {0x1F615, 0x1F615},
- {0x1F616, 0x1F616},
- {0x1F617, 0x1F617},
- {0x1F618, 0x1F618},
- {0x1F619, 0x1F619},
- {0x1F61A, 0x1F61A},
- {0x1F61B, 0x1F61B},
- {0x1F61C, 0x1F61E},
- {0x1F61F, 0x1F61F},
- {0x1F620, 0x1F625},
- {0x1F626, 0x1F627},
- {0x1F628, 0x1F62B},
- {0x1F62C, 0x1F62C},
- {0x1F62D, 0x1F62D},
- {0x1F62E, 0x1F62F},
- {0x1F630, 0x1F633},
- {0x1F634, 0x1F634},
- {0x1F635, 0x1F640},
- {0x1F641, 0x1F642},
- {0x1F643, 0x1F644},
- {0x1F645, 0x1F64F},
- {0x1F680, 0x1F6C5},
- {0x1F6C6, 0x1F6CF},
- {0x1F6D0, 0x1F6D0},
- {0x1F6D1, 0x1F6D2},
- {0x1F6D3, 0x1F6D4},
- {0x1F6D5, 0x1F6DF},
- {0x1F6E0, 0x1F6EC},
- {0x1F6ED, 0x1F6EF},
- {0x1F6F0, 0x1F6F3},
- {0x1F6F4, 0x1F6F6},
- {0x1F6F7, 0x1F6F8},
- {0x1F6F9, 0x1F6F9},
- {0x1F6FA, 0x1F6FF},
+ {0x1F249, 0x1F3FA},
+ {0x1F400, 0x1F53D},
+ {0x1F546, 0x1F64F},
+ {0x1F680, 0x1F6FF},
{0x1F774, 0x1F77F},
- {0x1F7D5, 0x1F7D8},
- {0x1F7D9, 0x1F7FF},
+ {0x1F7D5, 0x1F7FF},
{0x1F80C, 0x1F80F},
{0x1F848, 0x1F84F},
{0x1F85A, 0x1F85F},
{0x1F888, 0x1F88F},
{0x1F8AE, 0x1F8FF},
- {0x1F90C, 0x1F90F},
- {0x1F910, 0x1F918},
- {0x1F919, 0x1F91E},
- {0x1F91F, 0x1F91F},
- {0x1F920, 0x1F927},
- {0x1F928, 0x1F92F},
- {0x1F930, 0x1F930},
- {0x1F931, 0x1F932},
- {0x1F933, 0x1F93A},
- {0x1F93C, 0x1F93E},
- {0x1F93F, 0x1F93F},
- {0x1F940, 0x1F945},
- {0x1F947, 0x1F94B},
- {0x1F94C, 0x1F94C},
- {0x1F94D, 0x1F94F},
- {0x1F950, 0x1F95E},
- {0x1F95F, 0x1F96B},
- {0x1F96C, 0x1F970},
- {0x1F971, 0x1F972},
- {0x1F973, 0x1F976},
- {0x1F977, 0x1F979},
- {0x1F97A, 0x1F97A},
- {0x1F97B, 0x1F97B},
- {0x1F97C, 0x1F97F},
- {0x1F980, 0x1F984},
- {0x1F985, 0x1F991},
- {0x1F992, 0x1F997},
- {0x1F998, 0x1F9A2},
- {0x1F9A3, 0x1F9AF},
- {0x1F9B0, 0x1F9B9},
- {0x1F9BA, 0x1F9BF},
- {0x1F9C0, 0x1F9C0},
- {0x1F9C1, 0x1F9C2},
- {0x1F9C3, 0x1F9CF},
- {0x1F9D0, 0x1F9E6},
- {0x1F9E7, 0x1F9FF},
- {0x1FA00, 0x1FA5F},
- {0x1FA60, 0x1FA6D},
- {0x1FA6E, 0x1FFFD},
+ {0x1F90C, 0x1F93A},
+ {0x1F93C, 0x1F945},
+ {0x1F947, 0x1FFFD},
};
#endif /* HB_UNICODE_EMOJI_TABLE_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.cc
index 7b821b46d5e..5accf3643cd 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.cc
@@ -33,6 +33,20 @@
#include "hb-unicode.hh"
+/**
+ * SECTION: hb-unicode
+ * @title: hb-unicode
+ * @short_description: Unicode character property access
+ * @include: hb.h
+ *
+ * Unicode functions are used to access Unicode character properties.
+ * Client can pass its own Unicode functions to HarfBuzz, or access
+ * the built-in Unicode functions that come with HarfBuzz.
+ *
+ * With the Unicode functions, one can query variour Unicode character
+ * properties, such as General Category, Script, Combining Class, etc.
+ **/
+
/*
* hb_unicode_funcs_t
@@ -109,40 +123,23 @@ hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED
}
-#define HB_UNICODE_FUNCS_IMPLEMENT_SET \
- HB_UNICODE_FUNCS_IMPLEMENT (glib) \
- HB_UNICODE_FUNCS_IMPLEMENT (icu) \
- HB_UNICODE_FUNCS_IMPLEMENT (ucdn) \
- HB_UNICODE_FUNCS_IMPLEMENT (nil) \
- /* ^--- Add new callbacks before nil */
-
-#define hb_nil_get_unicode_funcs hb_unicode_funcs_get_empty
-
-/* Prototype them all */
-#define HB_UNICODE_FUNCS_IMPLEMENT(set) \
-extern "C" hb_unicode_funcs_t *hb_##set##_get_unicode_funcs (void);
-HB_UNICODE_FUNCS_IMPLEMENT_SET
-#undef HB_UNICODE_FUNCS_IMPLEMENT
-
+extern "C" hb_unicode_funcs_t *hb_glib_get_unicode_funcs (void);
+extern "C" hb_unicode_funcs_t *hb_icu_get_unicode_funcs (void);
+extern "C" hb_unicode_funcs_t *hb_ucdn_get_unicode_funcs (void);
hb_unicode_funcs_t *
hb_unicode_funcs_get_default (void)
{
-#define HB_UNICODE_FUNCS_IMPLEMENT(set) \
- return hb_##set##_get_unicode_funcs ();
-
#if defined(HAVE_UCDN)
- HB_UNICODE_FUNCS_IMPLEMENT(ucdn)
+ return hb_ucdn_get_unicode_funcs ();
#elif defined(HAVE_GLIB)
- HB_UNICODE_FUNCS_IMPLEMENT(glib)
+ return hb_glib_get_unicode_funcs ();
#elif defined(HAVE_ICU) && defined(HAVE_ICU_BUILTIN)
- HB_UNICODE_FUNCS_IMPLEMENT(icu)
+ return hb_icu_get_unicode_funcs ();
#else
#define HB_UNICODE_FUNCS_NIL 1
- HB_UNICODE_FUNCS_IMPLEMENT(nil)
+ return hb_unicode_funcs_get_empty ();
#endif
-
-#undef HB_UNICODE_FUNCS_IMPLEMENT
}
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HB_UNICODE_FUNCS_NIL)
@@ -190,7 +187,6 @@ DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) =
HB_OBJECT_HEADER_STATIC,
nullptr, /* parent */
- true, /* immutable */
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
@@ -306,12 +302,10 @@ hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
void
hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
{
- if (unlikely (hb_object_is_inert (ufuncs)))
- return;
- if (ufuncs->immutable)
+ if (hb_object_is_immutable (ufuncs))
return;
- ufuncs->immutable = true;
+ hb_object_make_immutable (ufuncs);
}
/**
@@ -327,7 +321,7 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
hb_bool_t
hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
{
- return ufuncs->immutable;
+ return hb_object_is_immutable (ufuncs);
}
/**
@@ -355,7 +349,7 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
void *user_data, \
hb_destroy_func_t destroy) \
{ \
- if (ufuncs->immutable) \
+ if (hb_object_is_immutable (ufuncs)) \
return; \
\
if (ufuncs->destroy.name) \
@@ -442,6 +436,7 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
* Return value:
*
* Since: 0.9.2
+ * Deprecated: 2.0.0
**/
unsigned int
hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
@@ -575,8 +570,8 @@ _hb_modified_combining_class[256] =
bool
_hb_unicode_is_emoji_Extended_Pictographic (hb_codepoint_t cp)
{
- return hb_bsearch_r (&cp, _hb_unicode_emoji_Extended_Pictographic_table,
- ARRAY_LENGTH (_hb_unicode_emoji_Extended_Pictographic_table),
- sizeof (hb_unicode_range_t),
- hb_unicode_range_t::cmp, nullptr);
+ return hb_bsearch (&cp, _hb_unicode_emoji_Extended_Pictographic_table,
+ ARRAY_LENGTH (_hb_unicode_emoji_Extended_Pictographic_table),
+ sizeof (hb_unicode_range_t),
+ hb_unicode_range_t::cmp);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.h b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.h
index c8d87e4d1d2..df0b91f0190 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.h
@@ -44,7 +44,7 @@ HB_BEGIN_DECLS
* HB_UNICODE_MAX
*
* Since: 1.9.0
- */
+ **/
#define HB_UNICODE_MAX 0x10FFFFu
@@ -230,9 +230,6 @@ hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs);
typedef hb_unicode_combining_class_t (*hb_unicode_combining_class_func_t) (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode,
void *user_data);
-typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs,
- hb_codepoint_t unicode,
- void *user_data);
typedef hb_unicode_general_category_t (*hb_unicode_general_category_func_t) (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode,
void *user_data);
@@ -254,32 +251,6 @@ typedef hb_bool_t (*hb_unicode_decompose_func_t) (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t *b,
void *user_data);
-/**
- * hb_unicode_decompose_compatibility_func_t:
- * @ufuncs: a Unicode function structure
- * @u: codepoint to decompose
- * @decomposed: address of codepoint array (of length %HB_UNICODE_MAX_DECOMPOSITION_LEN) to write decomposition into
- * @user_data: user data pointer as passed to hb_unicode_funcs_set_decompose_compatibility_func()
- *
- * Fully decompose @u to its Unicode compatibility decomposition. The codepoints of the decomposition will be written to @decomposed.
- * The complete length of the decomposition will be returned.
- *
- * If @u has no compatibility decomposition, zero should be returned.
- *
- * The Unicode standard guarantees that a buffer of length %HB_UNICODE_MAX_DECOMPOSITION_LEN codepoints will always be sufficient for any
- * compatibility decomposition plus an terminating value of 0. Consequently, @decompose must be allocated by the caller to be at least this length. Implementations
- * of this function type must ensure that they do not write past the provided array.
- *
- * Return value: number of codepoints in the full compatibility decomposition of @u, or 0 if no decomposition available.
- */
-typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_funcs_t *ufuncs,
- hb_codepoint_t u,
- hb_codepoint_t *decomposed,
- void *user_data);
-
-/* See Unicode 6.1 for details on the maximum decomposition length. */
-#define HB_UNICODE_MAX_DECOMPOSITION_LEN (18+1) /* codepoints */
-
/* setters */
/**
@@ -299,22 +270,6 @@ hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
void *user_data, hb_destroy_func_t destroy);
/**
- * hb_unicode_funcs_set_eastasian_width_func:
- * @ufuncs: a Unicode function structure
- * @func: (closure user_data) (destroy destroy) (scope notified):
- * @user_data:
- * @destroy:
- *
- *
- *
- * Since: 0.9.2
- **/
-HB_EXTERN void
-hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_eastasian_width_func_t func,
- void *user_data, hb_destroy_func_t destroy);
-
-/**
* hb_unicode_funcs_set_general_category_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
@@ -394,22 +349,6 @@ hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_decompose_func_t func,
void *user_data, hb_destroy_func_t destroy);
-/**
- * hb_unicode_funcs_set_decompose_compatibility_func:
- * @ufuncs: a Unicode function structure
- * @func: (closure user_data) (destroy destroy) (scope notified):
- * @user_data:
- * @destroy:
- *
- *
- *
- * Since: 0.9.2
- **/
-HB_EXTERN void
-hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_decompose_compatibility_func_t func,
- void *user_data, hb_destroy_func_t destroy);
-
/* accessors */
/**
@@ -422,15 +361,6 @@ hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode);
/**
- * hb_unicode_eastasian_width:
- *
- * Since: 0.9.2
- **/
-HB_EXTERN unsigned int
-hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs,
- hb_codepoint_t unicode);
-
-/**
* hb_unicode_general_category:
*
* Since: 0.9.2
@@ -469,11 +399,6 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t *a,
hb_codepoint_t *b);
-HB_EXTERN unsigned int
-hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
- hb_codepoint_t u,
- hb_codepoint_t *decomposed);
-
HB_END_DECLS
#endif /* HB_UNICODE_H */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.hh
index 6d6a4fa0ca1..d3fd5ea4bae 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-unicode.hh
@@ -63,12 +63,9 @@ extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256];
struct hb_unicode_funcs_t
{
hb_object_header_t header;
- ASSERT_POD ();
hb_unicode_funcs_t *parent;
- bool immutable;
-
#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
inline return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
@@ -369,7 +366,7 @@ DECLARE_NULL_INSTANCE (hb_unicode_funcs_t);
struct hb_unicode_range_t
{
static int
- cmp (const void *_key, const void *_item, void *_arg)
+ cmp (const void *_key, const void *_item)
{
hb_codepoint_t cp = *((hb_codepoint_t *) _key);
const hb_unicode_range_t *range = (hb_unicode_range_t *) _item;
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-uniscribe.cc b/chromium/third_party/harfbuzz-ng/src/src/hb-uniscribe.cc
index b77baa2fe4c..1fae6435b2c 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-uniscribe.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-uniscribe.cc
@@ -25,7 +25,6 @@
*/
#include "hb.hh"
-#define HB_SHAPER uniscribe
#include "hb-shaper-impl.hh"
#include <windows.h>
@@ -36,7 +35,17 @@
#include "hb-open-file.hh"
#include "hb-ot-name-table.hh"
-#include "hb-ot-tag.h"
+#include "hb-ot-layout.h"
+
+
+/**
+ * SECTION:hb-uniscribe
+ * @title: hb-uniscribe
+ * @short_description: Windows integration
+ * @include: hb-uniscribe.h
+ *
+ * Functions for using HarfBuzz with the Windows fonts.
+ **/
static inline uint16_t hb_uint16_swap (const uint16_t v)
@@ -236,7 +245,7 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis
funcs->init ();
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
atexit (free_static_uniscribe_shaper_funcs);
#endif
@@ -252,7 +261,7 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis
}
} static_uniscribe_shaper_funcs;
-#ifdef HB_USE_ATEXIT
+#if HB_USE_ATEXIT
static
void free_static_uniscribe_shaper_funcs (void)
{
@@ -304,9 +313,6 @@ struct range_record_t {
unsigned int index_last; /* == end - 1 */
};
-HB_SHAPER_DATA_ENSURE_DEFINE(uniscribe, face)
-HB_SHAPER_DATA_ENSURE_DEFINE(uniscribe, font)
-
/*
* shaper face data
@@ -493,11 +499,12 @@ _hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_face_data_t *data)
* shaper font data
*/
-struct hb_uniscribe_font_data_t {
+struct hb_uniscribe_font_data_t
+{
HDC hdc;
- LOGFONTW log_font;
+ mutable LOGFONTW log_font;
HFONT hfont;
- SCRIPT_CACHE script_cache;
+ mutable SCRIPT_CACHE script_cache;
double x_mult, y_mult; /* From LOGFONT space to HB space. */
};
@@ -510,10 +517,7 @@ populate_log_font (LOGFONTW *lf,
lf->lfHeight = - (int) font_size;
lf->lfCharSet = DEFAULT_CHARSET;
- hb_face_t *face = font->face;
- hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
-
- memcpy (lf->lfFaceName, face_data->face_name, sizeof (lf->lfFaceName));
+ memcpy (lf->lfFaceName, font->face->data.uniscribe->face_name, sizeof (lf->lfFaceName));
return true;
}
@@ -521,8 +525,6 @@ populate_log_font (LOGFONTW *lf,
hb_uniscribe_font_data_t *
_hb_uniscribe_shaper_font_data_create (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_face_data_ensure (font->face))) return nullptr;
-
hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) calloc (1, sizeof (hb_uniscribe_font_data_t));
if (unlikely (!data))
return nullptr;
@@ -576,39 +578,15 @@ _hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_font_data_t *data)
LOGFONTW *
hb_uniscribe_font_get_logfontw (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr;
- hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
- return &font_data->log_font;
+ const hb_uniscribe_font_data_t *data = font->data.uniscribe;
+ return data ? &data->log_font : nullptr;
}
HFONT
hb_uniscribe_font_get_hfont (hb_font_t *font)
{
- if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr;
- hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
- return font_data->hfont;
-}
-
-
-/*
- * shaper shape_plan data
- */
-
-struct hb_uniscribe_shape_plan_data_t {};
-
-hb_uniscribe_shape_plan_data_t *
-_hb_uniscribe_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
- const hb_feature_t *user_features HB_UNUSED,
- unsigned int num_user_features HB_UNUSED,
- const int *coords HB_UNUSED,
- unsigned int num_coords HB_UNUSED)
-{
- return (hb_uniscribe_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
-}
-
-void
-_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shape_plan_data_t *data HB_UNUSED)
-{
+ const hb_uniscribe_font_data_t *data = font->data.uniscribe;
+ return data ? data->hfont : nullptr;
}
@@ -625,19 +603,19 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
unsigned int num_features)
{
hb_face_t *face = font->face;
- hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
- hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
+ const hb_uniscribe_face_data_t *face_data = face->data.uniscribe;
+ const hb_uniscribe_font_data_t *font_data = font->data.uniscribe;
hb_uniscribe_shaper_funcs_t *funcs = face_data->funcs;
/*
* Set up features.
*/
- hb_auto_t<hb_vector_t<OPENTYPE_FEATURE_RECORD> > feature_records;
- hb_auto_t<hb_vector_t<range_record_t> > range_records;
+ hb_vector_t<OPENTYPE_FEATURE_RECORD> feature_records;
+ hb_vector_t<range_record_t> range_records;
if (num_features)
{
/* Sort features by start/end events. */
- hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
+ hb_vector_t<feature_event_t> feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
active_feature_t feature;
@@ -672,7 +650,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
}
/* Scan events and save features for each range. */
- hb_auto_t<hb_vector_t<active_feature_t> > active_features;
+ hb_vector_t<active_feature_t> active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
@@ -717,7 +695,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
{
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
- active_features.remove (feature - active_features.arrayZ);
+ active_features.remove (feature - active_features);
}
}
@@ -728,7 +706,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
for (unsigned int i = 0; i < range_records.len; i++)
{
range_record_t *range = &range_records[i];
- range->props.potfRecords = feature_records.arrayZ + reinterpret_cast<uintptr_t> (range->props.potfRecords);
+ range->props.potfRecords = feature_records + reinterpret_cast<uintptr_t> (range->props.potfRecords);
}
}
@@ -843,9 +821,15 @@ retry:
#undef MAX_ITEMS
- OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language));
- hb_auto_t<hb_vector_t<TEXTRANGE_PROPERTIES*> > range_properties;
- hb_auto_t<hb_vector_t<int> > range_char_counts;
+ hb_tag_t lang_tag;
+ unsigned int lang_count = 1;
+ hb_ot_tags_from_script_and_language (buffer->props.script,
+ buffer->props.language,
+ nullptr, nullptr,
+ &lang_count, &lang_tag);
+ OPENTYPE_TAG language_tag = hb_uint32_swap (lang_count ? lang_tag : HB_TAG_NONE);
+ hb_vector_t<TEXTRANGE_PROPERTIES*> range_properties;
+ hb_vector_t<int> range_char_counts;
unsigned int glyphs_offset = 0;
unsigned int glyphs_len;
@@ -902,8 +886,8 @@ retry:
&items[i].a,
script_tags[i],
language_tag,
- range_char_counts.arrayZ,
- range_properties.arrayZ,
+ range_char_counts,
+ range_properties,
range_properties.len,
pchars + chars_offset,
item_chars_len,
@@ -943,8 +927,8 @@ retry:
&items[i].a,
script_tags[i],
language_tag,
- range_char_counts.arrayZ,
- range_properties.arrayZ,
+ range_char_counts,
+ range_properties,
range_properties.len,
pchars + chars_offset,
log_clusters + chars_offset,
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-utf.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-utf.hh
index eccb632e489..54ede3c167a 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-utf.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-utf.hh
@@ -29,14 +29,16 @@
#include "hb.hh"
+#include "hb-open-type.hh"
+
struct hb_utf8_t
{
typedef uint8_t codepoint_t;
- static inline const uint8_t *
- next (const uint8_t *text,
- const uint8_t *end,
+ static inline const codepoint_t *
+ next (const codepoint_t *text,
+ const codepoint_t *end,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
@@ -103,13 +105,13 @@ struct hb_utf8_t
return text;
}
- static inline const uint8_t *
- prev (const uint8_t *text,
- const uint8_t *start,
+ static inline const codepoint_t *
+ prev (const codepoint_t *text,
+ const codepoint_t *start,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
- const uint8_t *end = text--;
+ const codepoint_t *end = text--;
while (start < text && (*text & 0xc0) == 0x80 && end - text < 4)
text--;
@@ -121,20 +123,71 @@ struct hb_utf8_t
}
static inline unsigned int
- strlen (const uint8_t *text)
+ strlen (const codepoint_t *text)
{
return ::strlen ((const char *) text);
}
+
+ static inline unsigned int
+ encode_len (hb_codepoint_t unicode)
+ {
+ if (unicode < 0x0080u) return 1;
+ if (unicode < 0x0800u) return 2;
+ if (unicode < 0x10000u) return 3;
+ if (unicode < 0x110000u) return 4;
+ return 3;
+ }
+
+ static inline codepoint_t *
+ encode (codepoint_t *text,
+ const codepoint_t *end,
+ hb_codepoint_t unicode)
+ {
+ if (unlikely (unicode >= 0xD800u && (unicode <= 0xDFFFu || unicode > 0x10FFFFu)))
+ unicode = 0xFFFDu;
+ if (unicode < 0x0080u)
+ *text++ = unicode;
+ else if (unicode < 0x0800u)
+ {
+ if (end - text >= 2)
+ {
+ *text++ = 0xC0u + (0x1Fu & (unicode >> 6));
+ *text++ = 0x80u + (0x3Fu & (unicode ));
+ }
+ }
+ else if (unicode < 0x10000u)
+ {
+ if (end - text >= 3)
+ {
+ *text++ = 0xE0u + (0x0Fu & (unicode >> 12));
+ *text++ = 0x80u + (0x3Fu & (unicode >> 6));
+ *text++ = 0x80u + (0x3Fu & (unicode ));
+ }
+ }
+ else
+ {
+ if (end - text >= 4)
+ {
+ *text++ = 0xF0u + (0x07u & (unicode >> 18));
+ *text++ = 0x80u + (0x3Fu & (unicode >> 12));
+ *text++ = 0x80u + (0x3Fu & (unicode >> 6));
+ *text++ = 0x80u + (0x3Fu & (unicode ));
+ }
+ }
+ return text;
+ }
};
-struct hb_utf16_t
+template <typename TCodepoint>
+struct hb_utf16_xe_t
{
- typedef uint16_t codepoint_t;
+ static_assert (sizeof (TCodepoint) == 2, "");
+ typedef TCodepoint codepoint_t;
- static inline const uint16_t *
- next (const uint16_t *text,
- const uint16_t *end,
+ static inline const codepoint_t *
+ next (const codepoint_t *text,
+ const codepoint_t *end,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
@@ -164,9 +217,9 @@ struct hb_utf16_t
return text;
}
- static inline const uint16_t *
- prev (const uint16_t *text,
- const uint16_t *start,
+ static inline const codepoint_t *
+ prev (const codepoint_t *text,
+ const codepoint_t *start,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
@@ -198,23 +251,51 @@ struct hb_utf16_t
static inline unsigned int
- strlen (const uint16_t *text)
+ strlen (const codepoint_t *text)
{
unsigned int l = 0;
while (*text++) l++;
return l;
}
+
+ static inline unsigned int
+ encode_len (hb_codepoint_t unicode)
+ {
+ return unicode < 0x10000 ? 1 : 2;
+ }
+
+ static inline codepoint_t *
+ encode (codepoint_t *text,
+ const codepoint_t *end,
+ hb_codepoint_t unicode)
+ {
+ if (unlikely (unicode >= 0xD800u && (unicode <= 0xDFFFu || unicode > 0x10FFFFu)))
+ unicode = 0xFFFDu;
+ if (unicode < 0x10000u)
+ *text++ = unicode;
+ else if (end - text >= 2)
+ {
+ unicode -= 0x10000u;
+ *text++ = 0xD800u + (unicode >> 10);
+ *text++ = 0xDC00u + (unicode & 0x03FFu);
+ }
+ return text;
+ }
};
+typedef hb_utf16_xe_t<uint16_t> hb_utf16_t;
+typedef hb_utf16_xe_t<OT::HBUINT16> hb_utf16_be_t;
-template <bool validate=true>
-struct hb_utf32_t
+
+template <typename TCodepoint, bool validate=true>
+struct hb_utf32_xe_t
{
- typedef uint32_t codepoint_t;
+ static_assert (sizeof (TCodepoint) == 4, "");
+ typedef TCodepoint codepoint_t;
- static inline const uint32_t *
- next (const uint32_t *text,
- const uint32_t *end HB_UNUSED,
+ static inline const TCodepoint *
+ next (const TCodepoint *text,
+ const TCodepoint *end HB_UNUSED,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
@@ -224,9 +305,9 @@ struct hb_utf32_t
return text;
}
- static inline const uint32_t *
- prev (const uint32_t *text,
- const uint32_t *start HB_UNUSED,
+ static inline const TCodepoint *
+ prev (const TCodepoint *text,
+ const TCodepoint *start HB_UNUSED,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
@@ -237,22 +318,42 @@ struct hb_utf32_t
}
static inline unsigned int
- strlen (const uint32_t *text)
+ strlen (const TCodepoint *text)
{
unsigned int l = 0;
while (*text++) l++;
return l;
}
+
+ static inline unsigned int
+ encode_len (hb_codepoint_t unicode HB_UNUSED)
+ {
+ return 1;
+ }
+
+ static inline codepoint_t *
+ encode (codepoint_t *text,
+ const codepoint_t *end HB_UNUSED,
+ hb_codepoint_t unicode)
+ {
+ if (validate && unlikely (unicode >= 0xD800u && (unicode <= 0xDFFFu || unicode > 0x10FFFFu)))
+ unicode = 0xFFFDu;
+ *text++ = unicode;
+ return text;
+ }
};
+typedef hb_utf32_xe_t<uint32_t> hb_utf32_t;
+typedef hb_utf32_xe_t<uint32_t, false> hb_utf32_novalidate_t;
+
struct hb_latin1_t
{
typedef uint8_t codepoint_t;
- static inline const uint8_t *
- next (const uint8_t *text,
- const uint8_t *end HB_UNUSED,
+ static inline const codepoint_t *
+ next (const codepoint_t *text,
+ const codepoint_t *end HB_UNUSED,
hb_codepoint_t *unicode,
hb_codepoint_t replacement HB_UNUSED)
{
@@ -260,23 +361,95 @@ struct hb_latin1_t
return text;
}
- static inline const uint8_t *
- prev (const uint8_t *text,
- const uint8_t *start HB_UNUSED,
+ static inline const codepoint_t *
+ prev (const codepoint_t *text,
+ const codepoint_t *start HB_UNUSED,
+ hb_codepoint_t *unicode,
+ hb_codepoint_t replacement HB_UNUSED)
+ {
+ *unicode = *--text;
+ return text;
+ }
+
+ static inline unsigned int
+ strlen (const codepoint_t *text)
+ {
+ unsigned int l = 0;
+ while (*text++) l++;
+ return l;
+ }
+
+ static inline unsigned int
+ encode_len (hb_codepoint_t unicode HB_UNUSED)
+ {
+ return 1;
+ }
+
+ static inline codepoint_t *
+ encode (codepoint_t *text,
+ const codepoint_t *end HB_UNUSED,
+ hb_codepoint_t unicode)
+ {
+ if (unlikely (unicode >= 0x0100u))
+ unicode = '?';
+ *text++ = unicode;
+ return text;
+ }
+};
+
+
+struct hb_ascii_t
+{
+ typedef uint8_t codepoint_t;
+
+ static inline const codepoint_t *
+ next (const codepoint_t *text,
+ const codepoint_t *end HB_UNUSED,
+ hb_codepoint_t *unicode,
+ hb_codepoint_t replacement HB_UNUSED)
+ {
+ *unicode = *text++;
+ if (*unicode >= 0x0080u)
+ *unicode = replacement;
+ return text;
+ }
+
+ static inline const codepoint_t *
+ prev (const codepoint_t *text,
+ const codepoint_t *start HB_UNUSED,
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
*unicode = *--text;
+ if (*unicode >= 0x0080u)
+ *unicode = replacement;
return text;
}
static inline unsigned int
- strlen (const uint8_t *text)
+ strlen (const codepoint_t *text)
{
unsigned int l = 0;
while (*text++) l++;
return l;
}
+
+ static inline unsigned int
+ encode_len (hb_codepoint_t unicode HB_UNUSED)
+ {
+ return 1;
+ }
+
+ static inline codepoint_t *
+ encode (codepoint_t *text,
+ const codepoint_t *end HB_UNUSED,
+ hb_codepoint_t unicode)
+ {
+ if (unlikely (unicode >= 0x0080u))
+ unicode = '?';
+ *text++ = unicode;
+ return text;
+ }
};
#endif /* HB_UTF_HH */
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-vector.hh b/chromium/third_party/harfbuzz-ng/src/src/hb-vector.hh
index da548cbb12f..787512f9221 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-vector.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-vector.hh
@@ -31,39 +31,87 @@
#include "hb.hh"
-template <typename Type, unsigned int StaticSize=8>
+template <typename Type, unsigned int PreallocedCount=8>
struct hb_vector_t
{
+ static_assert ((bool) (unsigned) hb_static_size (Type), "");
+
+ typedef Type ItemType;
+ enum { item_size = sizeof (Type) };
+
+ HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount);
+ inline hb_vector_t (void) { init (); }
+ inline ~hb_vector_t (void) { fini (); }
+
unsigned int len;
+ private:
unsigned int allocated; /* == 0 means allocation failed. */
- Type *arrayZ;
- Type static_array[StaticSize];
+ Type *arrayZ_;
+ Type static_array[PreallocedCount];
+ public:
void init (void)
{
len = 0;
allocated = ARRAY_LENGTH (static_array);
- arrayZ = static_array;
+ arrayZ_ = nullptr;
+ }
+
+ inline void fini (void)
+ {
+ if (arrayZ_)
+ free (arrayZ_);
+ arrayZ_ = nullptr;
+ allocated = len = 0;
+ }
+ inline void fini_deep (void)
+ {
+ Type *array = arrayZ();
+ unsigned int count = len;
+ for (unsigned int i = 0; i < count; i++)
+ array[i].fini ();
+ fini ();
}
+ inline Type * arrayZ (void)
+ { return arrayZ_ ? arrayZ_ : static_array; }
+ inline const Type * arrayZ (void) const
+ { return arrayZ_ ? arrayZ_ : static_array; }
+
inline Type& operator [] (unsigned int i)
{
if (unlikely (i >= len))
return Crap (Type);
- return arrayZ[i];
+ return arrayZ()[i];
}
inline const Type& operator [] (unsigned int i) const
{
if (unlikely (i >= len))
return Null(Type);
- return arrayZ[i];
+ return arrayZ()[i];
}
+ inline hb_array_t<Type> as_array (void)
+ { return hb_array (arrayZ(), len); }
+ inline hb_array_t<const Type> as_array (void) const
+ { return hb_array (arrayZ(), len); }
+
+ inline hb_sorted_array_t<Type> as_sorted_array (void)
+ { return hb_sorted_array (arrayZ(), len); }
+ inline hb_sorted_array_t<const Type> as_sorted_array (void) const
+ { return hb_sorted_array (arrayZ(), len); }
+
+ template <typename T> inline operator T * (void) { return arrayZ(); }
+ template <typename T> inline operator const T * (void) const { return arrayZ(); }
+
+ inline Type * operator + (unsigned int i) { return arrayZ() + i; }
+ inline const Type * operator + (unsigned int i) const { return arrayZ() + i; }
+
inline Type *push (void)
{
if (unlikely (!resize (len + 1)))
return &Crap(Type);
- return &arrayZ[len - 1];
+ return &arrayZ()[len - 1];
}
inline Type *push (const Type& v)
{
@@ -91,17 +139,17 @@ struct hb_vector_t
Type *new_array = nullptr;
- if (arrayZ == static_array)
+ if (!arrayZ_)
{
new_array = (Type *) calloc (new_allocated, sizeof (Type));
if (new_array)
- memcpy (new_array, arrayZ, len * sizeof (Type));
+ memcpy (new_array, static_array, len * sizeof (Type));
}
else
{
bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type));
if (likely (!overflows))
- new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type));
+ new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type));
}
if (unlikely (!new_array))
@@ -110,7 +158,7 @@ struct hb_vector_t
return false;
}
- arrayZ = new_array;
+ arrayZ_ = new_array;
allocated = new_allocated;
return true;
@@ -123,7 +171,7 @@ struct hb_vector_t
return false;
if (size > len)
- memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ));
+ memset (arrayZ() + len, 0, (size - len) * sizeof (*arrayZ()));
len = size;
return true;
@@ -137,12 +185,13 @@ struct hb_vector_t
inline void remove (unsigned int i)
{
- if (unlikely (i >= len))
- return;
- memmove (static_cast<void *> (&arrayZ[i]),
- static_cast<void *> (&arrayZ[i + 1]),
- (len - i - 1) * sizeof (Type));
- len--;
+ if (unlikely (i >= len))
+ return;
+ Type *array = arrayZ();
+ memmove (static_cast<void *> (&array[i]),
+ static_cast<void *> (&array[i + 1]),
+ (len - i - 1) * sizeof (Type));
+ len--;
}
inline void shrink (int size_)
@@ -153,87 +202,47 @@ struct hb_vector_t
}
template <typename T>
- inline Type *find (T v) {
+ inline Type *find (T v)
+ {
+ Type *array = arrayZ();
for (unsigned int i = 0; i < len; i++)
- if (arrayZ[i] == v)
- return &arrayZ[i];
+ if (array[i] == v)
+ return &array[i];
return nullptr;
}
template <typename T>
- inline const Type *find (T v) const {
+ inline const Type *find (T v) const
+ {
+ const Type *array = arrayZ();
for (unsigned int i = 0; i < len; i++)
- if (arrayZ[i] == v)
- return &arrayZ[i];
+ if (array[i] == v)
+ return &array[i];
return nullptr;
}
inline void qsort (int (*cmp)(const void*, const void*))
- {
- ::qsort (arrayZ, len, sizeof (Type), cmp);
- }
-
- inline void qsort (void)
- {
- ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
- }
-
- inline void qsort (unsigned int start, unsigned int end)
- {
- ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp);
- }
+ { as_array ().qsort (cmp); }
+ inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
+ { as_array ().qsort (start, end); }
template <typename T>
- inline Type *lsearch (const T &x)
- {
- for (unsigned int i = 0; i < len; i++)
- if (0 == this->arrayZ[i].cmp (&x))
- return &arrayZ[i];
- return nullptr;
- }
+ inline Type *lsearch (const T &x, Type *not_found = nullptr)
+ { return as_array ().lsearch (x, not_found); }
+ template <typename T>
+ inline const Type *lsearch (const T &x, const Type *not_found = nullptr) const
+ { return as_array ().lsearch (x, not_found); }
template <typename T>
- inline Type *bsearch (const T &x)
- {
- unsigned int i;
- return bfind (x, &i) ? &arrayZ[i] : nullptr;
- }
+ inline Type *bsearch (const T &x, Type *not_found = nullptr)
+ { return as_sorted_array ().bsearch (x, not_found); }
template <typename T>
- inline const Type *bsearch (const T &x) const
- {
- unsigned int i;
- return bfind (x, &i) ? &arrayZ[i] : nullptr;
- }
+ inline const Type *bsearch (const T &x, const Type *not_found = nullptr) const
+ { return as_sorted_array ().bsearch (x, not_found); }
template <typename T>
- inline bool bfind (const T &x, unsigned int *i) const
- {
- int min = 0, max = (int) this->len - 1;
- while (min <= max)
- {
- int mid = (min + max) / 2;
- int c = this->arrayZ[mid].cmp (&x);
- if (c < 0)
- max = mid - 1;
- else if (c > 0)
- min = mid + 1;
- else
- {
- *i = mid;
- return true;
- }
- }
- if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0))
- max++;
- *i = max;
- return false;
- }
-
- inline void fini (void)
- {
- if (arrayZ != static_array)
- free (arrayZ);
- arrayZ = nullptr;
- allocated = len = 0;
- }
+ inline bool bfind (const T &x, unsigned int *i = nullptr,
+ hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
+ unsigned int to_store = (unsigned int) -1) const
+ { return as_sorted_array ().bfind (x, i, not_found, to_store); }
};
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb-version.h b/chromium/third_party/harfbuzz-ng/src/src/hb-version.h
index 346495104be..fb9f8f30624 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb-version.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb-version.h
@@ -36,11 +36,11 @@
HB_BEGIN_DECLS
-#define HB_VERSION_MAJOR 1
-#define HB_VERSION_MINOR 9
-#define HB_VERSION_MICRO 0
+#define HB_VERSION_MAJOR 2
+#define HB_VERSION_MINOR 1
+#define HB_VERSION_MICRO 3
-#define HB_VERSION_STRING "1.9.0"
+#define HB_VERSION_STRING "2.1.3"
#define HB_VERSION_ATLEAST(major,minor,micro) \
((major)*10000+(minor)*100+(micro) <= \
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb.h b/chromium/third_party/harfbuzz-ng/src/src/hb.h
index fc75a69187c..c5e7072fbac 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb.h
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb.h
@@ -28,10 +28,6 @@
#define HB_H
#define HB_H_IN
-#ifndef HB_EXTERN
-#define HB_EXTERN extern
-#endif
-
#include "hb-blob.h"
#include "hb-buffer.h"
#include "hb-common.h"
diff --git a/chromium/third_party/harfbuzz-ng/src/src/hb.hh b/chromium/third_party/harfbuzz-ng/src/src/hb.hh
index cfe6d68fbe4..6df0a55b1bb 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/hb.hh
+++ b/chromium/third_party/harfbuzz-ng/src/src/hb.hh
@@ -39,12 +39,18 @@
#define _POSIX_C_SOURCE 200809L
#endif
+#if defined (_MSC_VER) && defined (HB_DLL_EXPORT)
+#define HB_EXTERN __declspec (dllexport) extern
+#endif
+
#include "hb.h"
#define HB_H_IN
-#ifdef HAVE_OT
#include "hb-ot.h"
#define HB_OT_H_IN
-#endif
+#include "hb-aat.h"
+#define HB_AAT_H_IN
+
+#include "hb-aat.h"
#include <math.h>
#include <stdlib.h>
@@ -178,8 +184,10 @@ struct _hb_alignof
# if !defined(HB_NO_VISIBILITY) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__SUNPRO_CC)
# define HB_INTERNAL __attribute__((__visibility__("hidden")))
# elif defined(__MINGW32__)
- /* We use -export-symbols on mingw32, since it does not support visibility
- * attribute. */
+ /* We use -export-symbols on mingw32, since it does not support visibility attributes. */
+# define HB_INTERNAL
+# elif defined (_MSC_VER) && defined (HB_DLL_EXPORT)
+ /* We do not try to export internal symbols on Visual Studio */
# define HB_INTERNAL
#else
# define HB_INTERNAL
@@ -233,7 +241,16 @@ struct _hb_alignof
# define HB_FALLTHROUGH /* FALLTHROUGH */
#endif
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(__clang__)
+/* Disable certain sanitizer errors. */
+/* https://github.com/harfbuzz/harfbuzz/issues/1247 */
+#define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow")))
+#else
+#define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW
+#endif
+
+
+#ifdef _WIN32
/* We need Windows Vista for both Uniscribe backend and for
* MemoryBarrier. We don't support compiling on Windows XP,
* though we run on it fine. */
@@ -268,7 +285,7 @@ static int errno = 0; /* Use something better? */
# endif
#endif
-#if HAVE_ATEXIT
+#if defined(HAVE_ATEXIT) && !defined(HB_USE_ATEXIT)
/* atexit() is only safe to be called from shared libraries on certain
* platforms. Whitelist.
* https://bugs.freedesktop.org/show_bug.cgi?id=82246 */
@@ -300,6 +317,9 @@ static int errno = 0; /* Use something better? */
#ifdef HB_NO_ATEXIT
# undef HB_USE_ATEXIT
#endif
+#ifndef HB_USE_ATEXIT
+# define HB_USE_ATEXIT 0
+#endif
#define HB_STMT_START do
#define HB_STMT_END while (0)
@@ -324,35 +344,40 @@ static_assert ((sizeof (hb_mask_t) == 4), "");
static_assert ((sizeof (hb_var_int_t) == 4), "");
-/* We like our types POD */
+#if __cplusplus >= 201103L
-#define _ASSERT_TYPE_POD1(_line, _type) union _type_##_type##_on_line_##_line##_is_not_POD { _type instance; }
-#define _ASSERT_TYPE_POD0(_line, _type) _ASSERT_TYPE_POD1 (_line, _type)
-#define ASSERT_TYPE_POD(_type) _ASSERT_TYPE_POD0 (__LINE__, _type)
+/* We only enable these with C++11 or later, since earlier language
+ * does not allow structs with constructors in unions, and we need
+ * those. */
-#ifdef __GNUC__
-# define _ASSERT_INSTANCE_POD1(_line, _instance) \
- HB_STMT_START { \
- typedef __typeof__(_instance) _type_##_line; \
- _ASSERT_TYPE_POD1 (_line, _type_##_line); \
- } HB_STMT_END
-#else
-# define _ASSERT_INSTANCE_POD1(_line, _instance) typedef int _assertion_on_line_##_line##_not_tested
-#endif
-# define _ASSERT_INSTANCE_POD0(_line, _instance) _ASSERT_INSTANCE_POD1 (_line, _instance)
-# define ASSERT_INSTANCE_POD(_instance) _ASSERT_INSTANCE_POD0 (__LINE__, _instance)
+#define HB_NO_COPY_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \
+ TypeName(const TypeName<T1, T2>&); \
+ void operator=(const TypeName<T1, T2>&)
+#define HB_NO_CREATE_COPY_ASSIGN(TypeName) \
+ TypeName(void); \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE(TypeName, T) \
+ TypeName(void); \
+ TypeName(const TypeName<T>&); \
+ void operator=(const TypeName<T>&)
+#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \
+ TypeName(void); \
+ TypeName(const TypeName<T1, T2>&); \
+ void operator=(const TypeName<T1, T2>&)
-/* Check _assertion in a method environment */
-#define _ASSERT_POD1(_line) \
- HB_UNUSED inline void _static_assertion_on_line_##_line (void) const \
- { _ASSERT_INSTANCE_POD1 (_line, *this); /* Make sure it's POD. */ }
-# define _ASSERT_POD0(_line) _ASSERT_POD1 (_line)
-# define ASSERT_POD() _ASSERT_POD0 (__LINE__)
+#else /* __cpluspplus >= 201103L */
+#define HB_NO_COPY_ASSIGN(TypeName)
+#define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) static_assert (true, "")
+#define HB_NO_CREATE_COPY_ASSIGN(TypeName) static_assert (true, "")
+#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE(TypeName, T) static_assert (true, "")
+#define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) static_assert (true, "")
-#define HB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
+#endif /* __cpluspplus >= 201103L */
/*
@@ -425,9 +450,11 @@ typedef uint64_t hb_vector_size_impl_t;
* For example, for testing "x ∈ {x1, x2, x3}" use:
* (FLAG_UNSAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3)))
*/
-#define FLAG(x) (ASSERT_STATIC_EXPR_ZERO ((unsigned int)(x) < 32) + (1U << (unsigned int)(x)))
-#define FLAG_UNSAFE(x) ((unsigned int)(x) < 32 ? (1U << (unsigned int)(x)) : 0)
+#define FLAG(x) (ASSERT_STATIC_EXPR_ZERO ((unsigned)(x) < 32) + (((uint32_t) 1U) << (unsigned)(x)))
+#define FLAG_UNSAFE(x) ((unsigned)(x) < 32 ? (((uint32_t) 1U) << (unsigned)(x)) : 0)
#define FLAG_RANGE(x,y) (ASSERT_STATIC_EXPR_ZERO ((x) < (y)) + FLAG(y+1) - FLAG(x))
+#define FLAG64(x) (ASSERT_STATIC_EXPR_ZERO ((unsigned)(x) < 64) + (((uint64_t) 1ULL) << (unsigned)(x)))
+#define FLAG64_UNSAFE(x) ((unsigned)(x) < 64 ? (((uint64_t) 1ULL) << (unsigned)(x)) : 0)
/* Size signifying variable-sized array */
@@ -474,6 +501,26 @@ _hb_memalign(void **memptr, size_t alignment, size_t size)
#endif
+/*
+ * For lack of a better place, put Zawgyi script hack here.
+ * https://github.com/harfbuzz/harfbuzz/issues/1162
+ */
+
+#define HB_SCRIPT_MYANMAR_ZAWGYI ((hb_script_t) HB_TAG ('Q','a','a','g'))
+
+
+/* Some really basic things everyone wants. */
+template <typename T> struct hb_remove_const { typedef T value; };
+template <typename T> struct hb_remove_const<const T> { typedef T value; };
+#define hb_remove_const(T) hb_remove_const<T>::value
+template <typename T> struct hb_remove_reference { typedef T value; };
+template <typename T> struct hb_remove_reference<T &> { typedef T value; };
+#define hb_remove_reference(T) hb_remove_reference<T>::value
+template <typename T> struct hb_remove_pointer { typedef T value; };
+template <typename T> struct hb_remove_pointer<T *> { typedef T value; };
+#define hb_remove_pointer(T) hb_remove_pointer<T>::value
+
+
/* Headers we include for everyone. Keep sorted. They express dependency amongst
* themselves, but no other file should include them.*/
#include "hb-atomic.hh"
diff --git a/chromium/third_party/harfbuzz-ng/src/src/test-name-table.cc b/chromium/third_party/harfbuzz-ng/src/src/test-name-table.cc
new file mode 100644
index 00000000000..58c98f07ab6
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/test-name-table.cc
@@ -0,0 +1,67 @@
+/*
+ * 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.h"
+#include "hb-ot.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ if (argc != 2) {
+ fprintf (stderr, "usage: %s font-file\n", argv[0]);
+ exit (1);
+ }
+
+ hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
+ hb_face_t *face = hb_face_create (blob, 0 /* first face */);
+ hb_blob_destroy (blob);
+ blob = NULL;
+
+ unsigned int count;
+ const hb_ot_name_entry_t *entries = hb_ot_name_list_names (face, &count);
+
+ for (unsigned int i = 0; i < count; i++)
+ {
+ printf ("%u %s ",
+ entries[i].name_id,
+ hb_language_to_string (entries[i].language));
+
+ char buf[64];
+ unsigned int buf_size = sizeof (buf);
+ hb_ot_name_get_utf8 (face,
+ entries[i].name_id,
+ entries[i].language,
+ &buf_size,
+ buf);
+
+ printf ("%s\n", buf);
+ }
+
+ return count ? 0 : 1;
+}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/test-ot-color.cc b/chromium/third_party/harfbuzz-ng/src/src/test-ot-color.cc
new file mode 100644
index 00000000000..4050a664d82
--- /dev/null
+++ b/chromium/third_party/harfbuzz-ng/src/src/test-ot-color.cc
@@ -0,0 +1,336 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ * Copyright © 2018 Khaled Hosny
+ *
+ * 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.
+ */
+
+#include "hb.h"
+#include "hb-ot.h"
+
+#include "hb-ft.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+
+#include <cairo.h>
+#include <cairo-ft.h>
+#include <cairo-svg.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+static void
+svg_dump (hb_face_t *face, unsigned int face_index)
+{
+ unsigned glyph_count = hb_face_get_glyph_count (face);
+
+ for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++)
+ {
+ hb_blob_t *blob = hb_ot_color_glyph_reference_svg (face, glyph_id);
+
+ if (hb_blob_get_length (blob) == 0) continue;
+
+ unsigned int length;
+ const char *data = hb_blob_get_data (blob, &length);
+
+ char output_path[255];
+ sprintf (output_path, "out/svg-%u-%u.svg%s",
+ glyph_id,
+ face_index,
+ // append "z" if the content is gzipped, https://stackoverflow.com/a/6059405
+ (length > 2 && (data[0] == '\x1F') && (data[1] == '\x8B')) ? "z" : "");
+
+ FILE *f = fopen (output_path, "wb");
+ fwrite (data, 1, length, f);
+ fclose (f);
+
+ hb_blob_destroy (blob);
+ }
+}
+
+/* _png API is so easy to use unlike the below code, don't get confused */
+static void
+png_dump (hb_face_t *face, unsigned int face_index)
+{
+ unsigned glyph_count = hb_face_get_glyph_count (face);
+ hb_font_t *font = hb_font_create (face);
+
+ /* scans the font for strikes */
+ unsigned int sample_glyph_id;
+ /* we don't care about different strikes for different glyphs at this point */
+ for (sample_glyph_id = 0; sample_glyph_id < glyph_count; sample_glyph_id++)
+ {
+ hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id);
+ unsigned int blob_length = hb_blob_get_length (blob);
+ hb_blob_destroy (blob);
+ if (blob_length != 0)
+ break;
+ }
+
+ unsigned int upem = hb_face_get_upem (face);
+ unsigned int blob_length = 0;
+ unsigned int strike = 0;
+ for (unsigned int ppem = 1; ppem < upem; ppem++)
+ {
+ hb_font_set_ppem (font, ppem, ppem);
+ hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id);
+ unsigned int new_blob_length = hb_blob_get_length (blob);
+ hb_blob_destroy (blob);
+ if (new_blob_length != blob_length)
+ {
+ for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++)
+ {
+ hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, glyph_id);
+
+ if (hb_blob_get_length (blob) == 0) continue;
+
+ unsigned int length;
+ const char *data = hb_blob_get_data (blob, &length);
+
+ char output_path[255];
+ sprintf (output_path, "out/png-%u-%u-%u.png", glyph_id, strike, face_index);
+
+ FILE *f = fopen (output_path, "wb");
+ fwrite (data, 1, length, f);
+ fclose (f);
+
+ hb_blob_destroy (blob);
+ }
+
+ strike++;
+ blob_length = new_blob_length;
+ }
+ }
+
+ hb_font_destroy (font);
+}
+
+static void
+layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int face_index)
+{
+ unsigned int upem = hb_face_get_upem (face);
+
+ unsigned glyph_count = hb_face_get_glyph_count (face);
+ for (hb_codepoint_t gid = 0; gid < glyph_count; ++gid)
+ {
+ unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, NULL, NULL);
+ if (!num_layers)
+ continue;
+
+ hb_ot_color_layer_t *layers = (hb_ot_color_layer_t*) malloc (num_layers * sizeof (hb_ot_color_layer_t));
+
+ hb_ot_color_glyph_get_layers (face, gid, 0, &num_layers, layers);
+ if (num_layers)
+ {
+ // Measure
+ cairo_text_extents_t extents;
+ {
+ cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ cairo_t *cr = cairo_create (surface);
+ cairo_set_font_face (cr, cairo_face);
+ cairo_set_font_size (cr, upem);
+
+ cairo_glyph_t *glyphs = (cairo_glyph_t *) calloc (num_layers, sizeof (cairo_glyph_t));
+ for (unsigned int j = 0; j < num_layers; ++j)
+ glyphs[j].index = layers[j].glyph;
+ cairo_glyph_extents (cr, glyphs, num_layers, &extents);
+ free (glyphs);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+ }
+
+ // Add a slight margin
+ extents.width += extents.width / 10;
+ extents.height += extents.height / 10;
+ extents.x_bearing -= extents.width / 20;
+ extents.y_bearing -= extents.height / 20;
+
+ // Render
+ unsigned int palette_count = hb_ot_color_palette_get_count (face);
+ for (unsigned int palette = 0; palette < palette_count; palette++)
+ {
+ unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, NULL, NULL);
+ if (!num_colors)
+ continue;
+
+ hb_color_t *colors = (hb_color_t*) calloc (num_colors, sizeof (hb_color_t));
+ hb_ot_color_palette_get_colors (face, palette, 0, &num_colors, colors);
+ if (num_colors)
+ {
+ char output_path[255];
+ sprintf (output_path, "out/colr-%u-%u-%u.svg", gid, palette, face_index);
+
+ cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
+ cairo_t *cr = cairo_create (surface);
+ cairo_set_font_face (cr, cairo_face);
+ cairo_set_font_size (cr, upem);
+
+ for (unsigned int layer = 0; layer < num_layers; ++layer)
+ {
+ hb_color_t color = 0x000000FF;
+ if (layers[layer].color_index != 0xFFFF)
+ color = colors[layers[layer].color_index];
+ cairo_set_source_rgba (cr,
+ hb_color_get_red (color) / 255.,
+ hb_color_get_green (color) / 255.,
+ hb_color_get_blue (color) / 255.,
+ hb_color_get_alpha (color) / 255.);
+
+ cairo_glyph_t glyph;
+ glyph.index = layers[layer].glyph;
+ glyph.x = -extents.x_bearing;
+ glyph.y = -extents.y_bearing;
+ cairo_show_glyphs (cr, &glyph, 1);
+ }
+
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+ }
+ free (colors);
+ }
+ }
+
+ free (layers);
+ }
+}
+
+static void
+dump_glyphs (cairo_font_face_t *cairo_face, unsigned int upem,
+ unsigned int num_glyphs, unsigned int face_index)
+{
+ for (unsigned int i = 0; i < num_glyphs; ++i)
+ {
+ cairo_text_extents_t extents;
+ cairo_glyph_t glyph = {0};
+ glyph.index = i;
+
+ // Measure
+ {
+ cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ cairo_t *cr = cairo_create (surface);
+ cairo_set_font_face (cr, cairo_face);
+ cairo_set_font_size (cr, upem);
+
+ cairo_glyph_extents (cr, &glyph, 1, &extents);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+ }
+
+ // Add a slight margin
+ extents.width += extents.width / 10;
+ extents.height += extents.height / 10;
+ extents.x_bearing -= extents.width / 20;
+ extents.y_bearing -= extents.height / 20;
+
+ // Render
+ {
+ char output_path[255];
+ sprintf (output_path, "out/%u-%u.svg", face_index, i);
+ cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
+ cairo_t *cr = cairo_create (surface);
+ cairo_set_font_face (cr, cairo_face);
+ cairo_set_font_size (cr, upem);
+ glyph.x = -extents.x_bearing;
+ glyph.y = -extents.y_bearing;
+ cairo_show_glyphs (cr, &glyph, 1);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+ }
+ }
+}
+
+int
+main (int argc, char **argv)
+{
+ if (argc != 2) {
+ fprintf (stderr, "usage: %s font-file.ttf\n"
+ "run it like `rm -rf out && mkdir out && %s font-file.ttf`\n",
+ argv[0], argv[0]);
+ exit (1);
+ }
+
+
+ FILE *font_name_file = fopen ("out/.dumped_font_name", "r");
+ if (font_name_file != NULL)
+ {
+ fprintf (stderr, "Purge or move ./out folder in order to run a new dump\n");
+ exit (1);
+ }
+
+ font_name_file = fopen ("out/.dumped_font_name", "w");
+ if (font_name_file == NULL)
+ {
+ fprintf (stderr, "./out is not accessible as a folder, create it please\n");
+ exit (1);
+ }
+ fwrite (argv[1], 1, strlen (argv[1]), font_name_file);
+ fclose (font_name_file);
+
+ hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
+ unsigned int num_faces = hb_face_count (blob);
+ if (num_faces == 0)
+ {
+ fprintf (stderr, "error: The file (%s) was corrupted, empty or not found", argv[1]);
+ exit (1);
+ }
+
+ for (unsigned int face_index = 0; face_index < hb_face_count (blob); face_index++)
+ {
+ hb_face_t *face = hb_face_create (blob, face_index);
+ hb_font_t *font = hb_font_create (face);
+
+ if (hb_ot_color_has_png (face)) printf ("Dumping png (cbdt/sbix)...\n");
+ png_dump (face, face_index);
+
+ if (hb_ot_color_has_svg (face)) printf ("Dumping svg...\n");
+ svg_dump (face, face_index);
+
+ cairo_font_face_t *cairo_face;
+ {
+ FT_Library library;
+ FT_Init_FreeType (&library);
+ FT_Face ft_face;
+ FT_New_Face (library, argv[1], 0, &ft_face);
+ cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+ }
+ if (hb_ot_color_has_layers (face) && hb_ot_color_has_palettes (face))
+ printf ("Dumping layered color glyphs...\n");
+ layered_glyph_dump (face, cairo_face, face_index);
+
+ unsigned int num_glyphs = hb_face_get_glyph_count (face);
+ unsigned int upem = hb_face_get_upem (face);
+
+ // disabled when color font as cairo rendering of NotoColorEmoji is soooo slow
+ if (!hb_ot_color_has_layers (face) &&
+ !hb_ot_color_has_png (face) &&
+ !hb_ot_color_has_svg (face))
+ dump_glyphs (cairo_face, upem, num_glyphs, face_index);
+
+ hb_font_destroy (font);
+ hb_face_destroy (face);
+ }
+
+ hb_blob_destroy (blob);
+
+ return 0;
+}
diff --git a/chromium/third_party/harfbuzz-ng/src/src/test-size-params.cc b/chromium/third_party/harfbuzz-ng/src/src/test-size-params.cc
index e53a47d8df6..12eec618838 100644
--- a/chromium/third_party/harfbuzz-ng/src/src/test-size-params.cc
+++ b/chromium/third_party/harfbuzz-ng/src/src/test-size-params.cc
@@ -46,7 +46,7 @@ main (int argc, char **argv)
blob = nullptr;
unsigned int p[5];
- bool ret = hb_ot_layout_get_size_params (face, p, p+1, p+2, p+3, p+4);
+ bool ret = hb_ot_layout_get_size_params (face, p, p+1, (p+2), p+3, p+4);
printf ("%g %u %u %g %g\n", p[0]/10., p[1], p[2], p[3]/10., p[4]/10.);
diff --git a/chromium/third_party/harfbuzz-ng/src/util/Makefile.am b/chromium/third_party/harfbuzz-ng/src/util/Makefile.am
index b8bf88418bc..85f9edaa01e 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/Makefile.am
+++ b/chromium/third_party/harfbuzz-ng/src/util/Makefile.am
@@ -52,14 +52,11 @@ hb_subset_LDADD = \
$(top_builddir)/src/libharfbuzz-subset.la
bin_PROGRAMS += hb-subset
-if HAVE_OT
hb_ot_shape_closure_SOURCES = $(HB_OT_SHAPE_CLOSURE_sources)
bin_PROGRAMS += hb-ot-shape-closure
-endif # HAVE_OT
endif # HAVE_GLIB
-#if HAVE_OT
#if HAVE_FONTCONFIG
#hb_fc_list_SOURCES = \
# hb-fc.cc \
@@ -72,6 +69,5 @@ endif # HAVE_GLIB
# $(NULL)
#bin_PROGRAMS += hb-fc-list
#endif # HAVE_FONTCONFIG
-#endif # HAVE_OT
-include $(top_srcdir)/git.mk
diff --git a/chromium/third_party/harfbuzz-ng/src/util/hb-shape.cc b/chromium/third_party/harfbuzz-ng/src/util/hb-shape.cc
index 337cd431908..1a671230d99 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/hb-shape.cc
+++ b/chromium/third_party/harfbuzz-ng/src/util/hb-shape.cc
@@ -160,6 +160,34 @@ struct output_buffer_t
int
main (int argc, char **argv)
{
+ if (argc == 2 && !strcmp (argv[1], "--batch"))
+ {
+ unsigned int ret = 0;
+ char buf[4092];
+ while (fgets (buf, sizeof (buf), stdin))
+ {
+ size_t l = strlen (buf);
+ if (l && buf[l - 1] == '\n') buf[l - 1] = '\0';
+ main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
+ char *args[32];
+ argc = 0;
+ char *p = buf, *e;
+ args[argc++] = p;
+ while ((e = strchr (p, ' ')) && argc < (int) (int) ARRAY_LENGTH (args))
+ {
+ *e++ = '\0';
+ while (*e == ' ')
+ e++;
+ args[argc++] = p = e;
+ }
+ ret |= driver.main (argc, args);
+ fflush (stdout);
+
+ if (ret)
+ break;
+ }
+ return ret;
+ }
main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
return driver.main (argc, argv);
}
diff --git a/chromium/third_party/harfbuzz-ng/src/util/hb-subset.cc b/chromium/third_party/harfbuzz-ng/src/util/hb-subset.cc
index 3f0963c3fac..c44f0af997e 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/hb-subset.cc
+++ b/chromium/third_party/harfbuzz-ng/src/util/hb-subset.cc
@@ -93,7 +93,7 @@ struct subset_consumer_t
hb_face_t *face = hb_font_get_face (font);
- hb_face_t *new_face = hb_subset(face, input);
+ hb_face_t *new_face = hb_subset (face, input);
hb_blob_t *result = hb_face_reference_blob (new_face);
failed = !hb_blob_get_length (result);
diff --git a/chromium/third_party/harfbuzz-ng/src/util/options.cc b/chromium/third_party/harfbuzz-ng/src/util/options.cc
index bfb11b457eb..3f8fa3d0479 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/options.cc
+++ b/chromium/third_party/harfbuzz-ng/src/util/options.cc
@@ -29,9 +29,7 @@
#ifdef HAVE_FREETYPE
#include <hb-ft.h>
#endif
-#ifdef HAVE_OT
#include <hb-ot.h>
-#endif
static struct supported_font_funcs_t {
char name[4];
@@ -41,9 +39,7 @@ static struct supported_font_funcs_t {
#ifdef HAVE_FREETYPE
{"ft", hb_ft_font_set_funcs},
#endif
-#ifdef HAVE_OT
{"ot", hb_ot_font_set_funcs},
-#endif
};
@@ -329,6 +325,7 @@ parse_text (const char *name G_GNUC_UNUSED,
return false;
}
+ text_opts->text_len = -1;
text_opts->text = g_strdup (arg);
return true;
}
@@ -374,6 +371,7 @@ parse_unicodes (const char *name G_GNUC_UNUSED,
s = p;
}
+ text_opts->text_len = gs->len;
text_opts->text = g_string_free (gs, FALSE);
return true;
}
@@ -415,6 +413,7 @@ shape_options_t::add_options (option_parser_t *parser)
{"eot", 0, 0, G_OPTION_ARG_NONE, &this->eot, "Treat text as end-of-paragraph", nullptr},
{"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", nullptr},
{"remove-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->remove_default_ignorables, "Remove Default-Ignorable characters", nullptr},
+ {"invisible-glyph", 0, 0, G_OPTION_ARG_INT, &this->invisible_glyph, "Glyph value to replace Default-Ignorables with", nullptr},
{"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", nullptr},
{"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2"},
{"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", nullptr},
@@ -663,7 +662,7 @@ font_options_t::get_font (void) const
blob = hb_blob_create_from_file (font_path);
if (blob == hb_blob_get_empty ())
- fail (false, "No such file or directory");
+ fail (false, "Couldn't read or find %s, or it was empty.", font_path);
/* Create the face */
hb_face_t *face = hb_face_create (blob, face_index);
@@ -730,7 +729,11 @@ const char *
text_options_t::get_line (unsigned int *len)
{
if (text) {
- if (!line) line = text;
+ if (!line)
+ {
+ line = text;
+ line_len = text_len;
+ }
if (line_len == (unsigned int) -1)
line_len = strlen (line);
diff --git a/chromium/third_party/harfbuzz-ng/src/util/options.hh b/chromium/third_party/harfbuzz-ng/src/util/options.hh
index 40e1ab89275..0137484ce80 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/options.hh
+++ b/chromium/third_party/harfbuzz-ng/src/util/options.hh
@@ -46,9 +46,7 @@
#endif
#include <hb.h>
-#ifdef HAVE_OT
#include <hb-ot.h>
-#endif
#include <glib.h>
#include <glib/gprintf.h>
@@ -155,6 +153,7 @@ struct shape_options_t : option_group_t
num_features = 0;
shapers = nullptr;
utf8_clusters = false;
+ invisible_glyph = 0;
cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT;
normalize_glyphs = false;
verify = false;
@@ -185,6 +184,7 @@ struct shape_options_t : option_group_t
(preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 0) |
(remove_default_ignorables ? HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES : 0) |
0));
+ hb_buffer_set_invisible_glyph (buffer, invisible_glyph);
hb_buffer_set_cluster_level (buffer, cluster_level);
hb_buffer_guess_segment_properties (buffer);
}
@@ -435,6 +435,7 @@ struct shape_options_t : option_group_t
unsigned int num_features;
char **shapers;
hb_bool_t utf8_clusters;
+ hb_codepoint_t invisible_glyph;
hb_buffer_cluster_level_t cluster_level;
hb_bool_t normalize_glyphs;
hb_bool_t verify;
@@ -505,6 +506,7 @@ struct text_options_t : option_group_t
text_before = nullptr;
text_after = nullptr;
+ text_len = -1;
text = nullptr;
text_file = nullptr;
@@ -523,7 +525,7 @@ struct text_options_t : option_group_t
g_free (text_file);
if (gs)
g_string_free (gs, true);
- if (fp)
+ if (fp && fp != stdin)
fclose (fp);
}
@@ -534,13 +536,14 @@ struct text_options_t : option_group_t
g_set_error (error,
G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
"Only one of text and text-file can be set");
- };
+ }
const char *get_line (unsigned int *len);
char *text_before;
char *text_after;
+ int text_len;
char *text;
char *text_file;
@@ -569,7 +572,7 @@ struct output_options_t : option_group_t
{
g_free (output_file);
g_free (output_format);
- if (fp)
+ if (fp && fp != stdout)
fclose (fp);
}
@@ -585,7 +588,7 @@ struct output_options_t : option_group_t
if (output_format)
{
output_format++; /* skip the dot */
- output_format = strdup (output_format);
+ output_format = g_strdup (output_format);
}
}
diff --git a/chromium/third_party/harfbuzz-ng/src/util/view-cairo.hh b/chromium/third_party/harfbuzz-ng/src/util/view-cairo.hh
index 677f74b3887..5be3523adc8 100644
--- a/chromium/third_party/harfbuzz-ng/src/util/view-cairo.hh
+++ b/chromium/third_party/harfbuzz-ng/src/util/view-cairo.hh
@@ -46,7 +46,7 @@ struct view_cairo_t
void init (hb_buffer_t *buffer, const font_options_t *font_opts)
{
lines = g_array_new (false, false, sizeof (helper_cairo_line_t));
- scale_bits = -font_opts->subpixel_bits;
+ scale_bits = - (int) font_opts->subpixel_bits;
}
void new_line (void)
{