diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-12-22 00:39:38 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-12-22 00:39:38 +0000 |
commit | aefa260469999e53f3b8ea263fda94cdddef8ce3 (patch) | |
tree | e1182a668216a25f19d5f18ffcfec27cc7925b96 /Build/source/libs/harfbuzz/harfbuzz-src/src | |
parent | 27205aecce351fee6bb1ad9a7c43d4b542e28a1a (diff) |
harfbuzz-2.3.0
git-svn-id: svn://tug.org/texlive/trunk@49473 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src')
146 files changed, 12742 insertions, 3756 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am index c726cf2a660..3618d03a2c7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am @@ -28,10 +28,6 @@ HBSOURCES = $(HB_BASE_sources) HBSOURCES += $(HB_BASE_RAGEL_GENERATED_sources) HBHEADERS = $(HB_BASE_headers) -HBSOURCES += $(HB_OT_sources) -HBSOURCES += $(HB_OT_RAGEL_GENERATED_sources) -HBHEADERS += $(HB_OT_headers) - if HAVE_FALLBACK HBSOURCES += $(HB_FALLBACK_sources) endif @@ -299,12 +295,10 @@ built-sources: $(BUILT_SOURCES) RAGEL_GENERATED = \ $(patsubst %,$(srcdir)/%,$(HB_BASE_RAGEL_GENERATED_sources)) \ - $(patsubst %,$(srcdir)/%,$(HB_OT_RAGEL_GENERATED_sources)) \ $(NULL) BUILT_SOURCES += $(RAGEL_GENERATED) EXTRA_DIST += \ $(HB_BASE_RAGEL_sources) \ - $(HB_OT_RAGEL_sources) \ $(NULL) # We decided to add ragel-generated files to git... #MAINTAINERCLEANFILES += $(RAGEL_GENERATED) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources index ba90ef022ef..98b62288978 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources @@ -1,196 +1,198 @@ # Base and default-included sources and headers HB_BASE_sources = \ + hb-aat-fdsc-table.hh \ + hb-aat-layout-ankr-table.hh \ + hb-aat-layout-bsln-table.hh \ + hb-aat-layout-common.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.cc \ + hb-aat-layout.hh \ + hb-aat-ltag-table.hh \ + hb-aat-map.cc \ + hb-aat-map.hh \ + hb-array.hh \ hb-atomic.hh \ - hb-blob.hh \ hb-blob.cc \ - hb-buffer.hh \ + hb-blob.hh \ hb-buffer-serialize.cc \ hb-buffer.cc \ + hb-buffer.hh \ hb-cache.hh \ + hb-cff-interp-common.hh \ + hb-cff-interp-cs-common.hh \ + hb-cff-interp-dict-common.hh \ + hb-cff1-interp-cs.hh \ + hb-cff2-interp-cs.hh \ hb-common.cc \ hb-debug.hh \ hb-dsalgs.hh \ - hb-face.hh \ hb-face.cc \ - hb-font.hh \ + hb-face.hh \ hb-font.cc \ - hb-iter.hh \ + hb-font.hh \ hb-kern.hh \ - hb-map.hh \ - hb-map.cc \ hb-machinery.hh \ + hb-map.cc \ + hb-map.hh \ hb-mutex.hh \ hb-null.hh \ hb-object.hh \ hb-open-file.hh \ hb-open-type.hh \ - hb-ot-color-cbdt-table.hh \ + hb-ot-cff-common.hh \ + hb-ot-cff1-table.cc \ + hb-ot-cff1-table.hh \ + hb-ot-cff2-table.cc \ + hb-ot-cff2-table.hh \ hb-ot-cmap-table.hh \ + hb-ot-color-cbdt-table.hh \ + hb-ot-color-colr-table.hh \ + hb-ot-color-cpal-table.hh \ + hb-ot-color-sbix-table.hh \ + hb-ot-color-svg-table.hh \ + hb-ot-color.cc \ + hb-ot-face.cc \ + hb-ot-face.hh \ + hb-ot-font.cc \ + hb-ot-gasp-table.hh \ hb-ot-glyf-table.hh \ hb-ot-hdmx-table.hh \ hb-ot-head-table.hh \ hb-ot-hhea-table.hh \ 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 \ - hb-set.hh \ - hb-set.cc \ - hb-shape.cc \ - hb-shape-plan.hh \ - hb-shape-plan.cc \ - hb-shaper-list.hh \ - hb-shaper-impl.hh \ - hb-shaper.hh \ - hb-shaper.cc \ - hb-static.cc \ - hb-string-array.hh \ - hb-unicode.hh \ - hb-unicode-emoji-table.hh \ - hb-unicode.cc \ - hb-vector.hh \ - hb-utf.hh \ - hb-warning.cc \ - $(NULL) - -HB_BASE_RAGEL_GENERATED_sources = \ - hb-buffer-deserialize-json.hh \ - hb-buffer-deserialize-text.hh \ - $(NULL) -HB_BASE_RAGEL_sources = \ - hb-buffer-deserialize-json.rl \ - hb-buffer-deserialize-text.rl \ - $(NULL) - -HB_BASE_headers = \ - hb.h \ - hb-blob.h \ - hb-buffer.h \ - hb-common.h \ - hb-deprecated.h \ - hb-face.h \ - hb-font.h \ - hb-map.h \ - hb-set.h \ - hb-shape.h \ - hb-shape-plan.h \ - hb-unicode.h \ - hb-version.h \ - $(NULL) - -HB_FALLBACK_sources = \ - hb-fallback-shape.cc \ - $(NULL) - -HB_OT_sources = \ - hb-aat-layout.cc \ - hb-aat-layout-common.hh \ - hb-aat-layout-ankr-table.hh \ - hb-aat-layout-bsln-table.hh \ - hb-aat-layout-feat-table.hh \ - hb-aat-layout-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 \ - hb-ot-layout.cc \ hb-ot-layout-base-table.hh \ hb-ot-layout-common.hh \ hb-ot-layout-gdef-table.hh \ hb-ot-layout-gpos-table.hh \ - hb-ot-layout-gsubgpos.hh \ hb-ot-layout-gsub-table.hh \ + hb-ot-layout-gsubgpos.hh \ hb-ot-layout-jstf-table.hh \ + hb-ot-layout.cc \ hb-ot-layout.hh \ - hb-ot-color.cc \ - hb-ot-color-colr-table.hh \ - hb-ot-color-cpal-table.hh \ - hb-ot-color-sbix-table.hh \ - hb-ot-color-svg-table.hh \ hb-ot-map.cc \ hb-ot-map.hh \ - hb-ot-math.cc \ hb-ot-math-table.hh \ - hb-ot-shape.cc \ - hb-ot-shape-complex-arabic.cc \ + hb-ot-math.cc \ + 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-shape-complex-arabic-fallback.hh \ - hb-ot-shape-complex-arabic.hh \ hb-ot-shape-complex-arabic-table.hh \ hb-ot-shape-complex-arabic-win1256.hh \ + hb-ot-shape-complex-arabic.cc \ + hb-ot-shape-complex-arabic.hh \ hb-ot-shape-complex-default.cc \ hb-ot-shape-complex-hangul.cc \ hb-ot-shape-complex-hebrew.cc \ + hb-ot-shape-complex-indic-table.cc \ hb-ot-shape-complex-indic.cc \ hb-ot-shape-complex-indic.hh \ - hb-ot-shape-complex-indic-table.cc \ - hb-ot-shape-complex-khmer.hh \ hb-ot-shape-complex-khmer.cc \ - hb-ot-shape-complex-myanmar.hh \ + hb-ot-shape-complex-khmer.hh \ hb-ot-shape-complex-myanmar.cc \ + hb-ot-shape-complex-myanmar.hh \ hb-ot-shape-complex-thai.cc \ + hb-ot-shape-complex-use-table.cc \ 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-fallback.hh \ + hb-ot-shape-normalize.cc \ + hb-ot-shape-normalize.hh \ + hb-ot-shape.cc \ hb-ot-shape.hh \ hb-ot-stat-table.hh \ - hb-ot-var.cc \ + hb-ot-tag-table.hh \ + hb-ot-tag.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-var.cc \ hb-ot-vorg-table.hh \ + hb-set-digest.hh \ + hb-set.cc \ + hb-set.hh \ + hb-shape-plan.cc \ + hb-shape-plan.hh \ + hb-shape.cc \ + hb-shaper-impl.hh \ + hb-shaper-list.hh \ + hb-shaper.cc \ + hb-shaper.hh \ + hb-static.cc \ + hb-string-array.hh \ + hb-unicode-emoji-table.hh \ + hb-unicode.cc \ + hb-unicode.hh \ + hb-utf.hh \ + hb-vector.hh \ + hb-warning.cc \ + hb.hh \ $(NULL) -HB_OT_RAGEL_GENERATED_sources = \ +HB_BASE_RAGEL_GENERATED_sources = \ + hb-buffer-deserialize-json.hh \ + hb-buffer-deserialize-text.hh \ hb-ot-shape-complex-indic-machine.hh \ hb-ot-shape-complex-khmer-machine.hh \ hb-ot-shape-complex-myanmar-machine.hh \ hb-ot-shape-complex-use-machine.hh \ $(NULL) -HB_OT_RAGEL_sources = \ +HB_BASE_RAGEL_sources = \ + hb-buffer-deserialize-json.rl \ + hb-buffer-deserialize-text.rl \ hb-ot-shape-complex-indic-machine.rl \ hb-ot-shape-complex-khmer-machine.rl \ hb-ot-shape-complex-myanmar-machine.rl \ hb-ot-shape-complex-use-machine.rl \ $(NULL) -HB_OT_headers = \ - hb-aat.h \ +HB_BASE_headers = \ hb-aat-layout.h \ - hb-ot.h \ + hb-aat.h \ + hb-blob.h \ + hb-buffer.h \ + hb-common.h \ + hb-deprecated.h \ + hb-face.h \ + hb-font.h \ + hb-map.h \ hb-ot-color.h \ + hb-ot-deprecated.h \ hb-ot-font.h \ hb-ot-layout.h \ hb-ot-math.h \ hb-ot-name.h \ hb-ot-shape.h \ hb-ot-var.h \ + hb-ot.h \ + hb-set.h \ + hb-shape-plan.h \ + hb-shape.h \ + hb-unicode.h \ + hb-version.h \ + hb.h \ + $(NULL) + +HB_FALLBACK_sources = \ + hb-fallback-shape.cc \ $(NULL) # Optional Sources and Headers with external deps @@ -224,15 +226,26 @@ HB_ICU_headers = hb-icu.h # Sources for libharfbuzz-subset HB_SUBSET_sources = \ + hb-ot-cff1-table.cc \ + hb-ot-cff2-table.cc \ hb-static.cc \ - hb-subset.cc \ - hb-subset.hh \ + hb-subset-cff-common.cc \ + hb-subset-cff-common.hh \ + hb-subset-cff1.cc \ + hb-subset-cff1.hh \ + hb-subset-cff2.cc \ + hb-subset-cff2.hh \ hb-subset-glyf.cc \ hb-subset-glyf.hh \ + hb-subset-glyf.hh \ hb-subset-input.cc \ hb-subset-input.hh \ hb-subset-plan.cc \ hb-subset-plan.hh \ + hb-subset-plan.hh \ + hb-subset.cc \ + hb-subset.hh \ + hb-subset.hh \ $(NULL) HB_SUBSET_headers = \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc index a506889810b..8ddc9d5a4ef 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-indic-data.cc @@ -27,7 +27,7 @@ #include "hb-ot-shape-complex-indic.hh" int -main (void) +main () { for (hb_codepoint_t u = 0; u <= 0x10FFFF; u++) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc index 1e79a976732..cffbb92df72 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-khmer-data.cc @@ -27,7 +27,7 @@ #include "hb-ot-shape-complex-khmer.hh" int -main (void) +main () { for (hb_codepoint_t u = 0; u <= 0x10FFFF; u++) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc index 9f8b12ed229..c1a303f8f1a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-myanmar-data.cc @@ -27,7 +27,7 @@ #include "hb-ot-shape-complex-myanmar.hh" int -main (void) +main () { for (hb_codepoint_t u = 0; u <= 0x10FFFF; u++) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc index 4a8b25842e1..d639426b733 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/dump-use-data.cc @@ -27,7 +27,7 @@ #include "hb-ot-shape-complex-use.hh" int -main (void) +main () { for (hb_codepoint_t u = 0; u <= 0x10FFFF; u++) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-fdsc-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-fdsc-table.hh new file mode 100644 index 00000000000..a1af595f9ff --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-fdsc-table.hh @@ -0,0 +1,126 @@ +/* + * 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_FDSC_TABLE_HH +#define HB_AAT_FDSC_TABLE_HH + +#include "hb-aat-layout-common.hh" +#include "hb-open-type.hh" + +/* + * fdsc -- Font descriptors + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fdsc.html + */ +#define HB_AAT_TAG_fdsc HB_TAG('f','d','s','c') + + +namespace AAT { + + +struct FontDescriptor +{ + bool has_data () const { return tag; } + + int cmp (hb_tag_t a) const { return tag.cmp (a); } + + float get_value () const { return u.value.to_float (); } + + enum non_alphabetic_value_t { + Alphabetic = 0, + Dingbats = 1, + PiCharacters = 2, + Fleurons = 3, + DecorativeBorders = 4, + InternationalSymbols= 5, + MathSymbols = 6 + }; + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + protected: + Tag tag; /* The 4-byte table tag name. */ + union { + Fixed value; /* The value for the descriptor tag. */ + HBUINT32 nalfType; /* If the tag is `nalf`, see non_alphabetic_value_t */ + } u; + public: + DEFINE_SIZE_STATIC (8); +}; + +struct fdsc +{ + enum { tableTag = HB_AAT_TAG_fdsc }; + + enum { + Weight = HB_TAG ('w','g','h','t'), + /* Percent weight relative to regular weight. + * (defaul value: 1.0) */ + Width = HB_TAG ('w','d','t','h'), + /* Percent width relative to regular width. + * (default value: 1.0) */ + Slant = HB_TAG ('s','l','n','t'), + /* Angle of slant in degrees, where positive + * is clockwise from straight up. + * (default value: 0.0) */ + OpticalSize = HB_TAG ('o','p','s','z'), + /* Point size the font was designed for. + * (default value: 12.0) */ + NonAlphabetic= HB_TAG ('n','a','l','f') + /* These values are treated as integers, + * not fixed32s. 0 means alphabetic, and greater + * integers mean the font is non-alphabetic (e.g. symbols). + * (default value: 0) */ + }; + + const FontDescriptor &get_descriptor (hb_tag_t style) const + { return descriptors.lsearch (style); } + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + descriptors.sanitize (c)); + } + + protected: + Fixed version; /* Version number of the font descriptors + * table (0x00010000 for the current version). */ + LArrayOf<FontDescriptor> + descriptors; /* List of tagged-coordinate pairs style descriptors + * that will be included to characterize this font. + * Each descriptor consists of a <tag, value> pair. + * These pairs are located in the gxFontDescriptor + * array that follows. */ + public: + DEFINE_SIZE_ARRAY (8, descriptors); +}; + +} /* namespace AAT */ + + +#endif /* HB_AAT_FDSC_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh index b793245a0c5..4235b363a1f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-ankr-table.hh @@ -41,7 +41,7 @@ using namespace OT; struct Anchor { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -58,12 +58,12 @@ typedef LArrayOf<Anchor> GlyphAnchors; struct ankr { - static const hb_tag_t tableTag = HB_AAT_TAG_ankr; + enum { 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 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) @@ -75,7 +75,7 @@ struct ankr return anchors[i]; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh index b86408626f2..5bc59cbb10a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-bsln-table.hh @@ -39,7 +39,7 @@ namespace AAT { struct BaselineTableFormat0Part { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -57,7 +57,7 @@ struct BaselineTableFormat0Part struct BaselineTableFormat1Part { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -75,7 +75,7 @@ struct BaselineTableFormat1Part struct BaselineTableFormat2Part { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -98,7 +98,7 @@ struct BaselineTableFormat2Part struct BaselineTableFormat3Part { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && lookupTable.sanitize (c)); @@ -116,15 +116,16 @@ struct BaselineTableFormat3Part struct bsln { - static const hb_tag_t tableTag = HB_AAT_TAG_bsln; + enum { tableTag = HB_AAT_TAG_bsln }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!(c->check_struct (this) && defaultBaseline < 32))) return_trace (false); - switch (format) { + switch (format) + { case 0: return_trace (parts.format0.sanitize (c)); case 1: return_trace (parts.format1.sanitize (c)); case 2: return_trace (parts.format2.sanitize (c)); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh index c0b0e3751f3..95d6b312ab5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh @@ -28,6 +28,7 @@ #define HB_AAT_LAYOUT_COMMON_HH #include "hb-aat-layout.hh" +#include "hb-open-type.hh" namespace AAT { @@ -47,18 +48,18 @@ struct LookupFormat0 friend struct Lookup<T>; private: - inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const { if (unlikely (glyph_id >= num_glyphs)) return nullptr; return &arrayZ[glyph_id]; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (arrayZ.sanitize (c, c->get_num_glyphs ())); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (arrayZ.sanitize (c, c->get_num_glyphs (), base)); @@ -78,16 +79,15 @@ struct LookupSegmentSingle { enum { TerminationWordCount = 2 }; - inline int cmp (hb_codepoint_t g) const { - return g < first ? -1 : g <= last ? 0 : +1 ; - } + int cmp (hb_codepoint_t g) const + { return g < first ? -1 : g <= last ? 0 : +1 ; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && value.sanitize (c)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && value.sanitize (c, base)); @@ -106,18 +106,18 @@ struct LookupFormat2 friend struct Lookup<T>; private: - inline const T* get_value (hb_codepoint_t glyph_id) const + const T* get_value (hb_codepoint_t glyph_id) const { const LookupSegmentSingle<T> *v = segments.bsearch (glyph_id); return v ? &v->value : nullptr; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (segments.sanitize (c)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (segments.sanitize (c, base)); @@ -138,16 +138,15 @@ struct LookupSegmentArray { enum { TerminationWordCount = 2 }; - inline const T* get_value (hb_codepoint_t glyph_id, const void *base) const + const T* get_value (hb_codepoint_t glyph_id, const void *base) const { return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr; } - inline int cmp (hb_codepoint_t g) const { - return g < first ? -1 : g <= last ? 0 : +1 ; - } + int cmp (hb_codepoint_t g) const + { return g < first ? -1 : g <= last ? 0 : +1; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -155,7 +154,7 @@ struct LookupSegmentArray 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 + bool sanitize (hb_sanitize_context_t *c, const void *base, T2 user_data) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -178,18 +177,18 @@ struct LookupFormat4 friend struct Lookup<T>; private: - inline const T* get_value (hb_codepoint_t glyph_id) const + const T* get_value (hb_codepoint_t glyph_id) const { const LookupSegmentArray<T> *v = segments.bsearch (glyph_id); return v ? v->get_value (glyph_id, this) : nullptr; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (segments.sanitize (c, this)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (segments.sanitize (c, this, base)); @@ -210,14 +209,14 @@ struct LookupSingle { enum { TerminationWordCount = 1 }; - inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } + int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && value.sanitize (c)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && value.sanitize (c, base)); @@ -235,18 +234,18 @@ struct LookupFormat6 friend struct Lookup<T>; private: - inline const T* get_value (hb_codepoint_t glyph_id) const + const T* get_value (hb_codepoint_t glyph_id) const { const LookupSingle<T> *v = entries.bsearch (glyph_id); return v ? &v->value : nullptr; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (entries.sanitize (c)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (entries.sanitize (c, base)); @@ -266,18 +265,18 @@ struct LookupFormat8 friend struct Lookup<T>; private: - inline const T* get_value (hb_codepoint_t glyph_id) const + const T* get_value (hb_codepoint_t glyph_id) const { return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? &valueArrayZ[glyph_id - firstGlyph] : nullptr; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { 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 + 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)); @@ -301,7 +300,7 @@ struct LookupFormat10 friend struct Lookup<T>; private: - inline const typename T::type get_value_or_null (hb_codepoint_t glyph_id) const + 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); @@ -316,7 +315,7 @@ struct LookupFormat10 return v; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -340,7 +339,7 @@ struct LookupFormat10 template <typename T> struct Lookup { - inline const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const { switch (u.format) { case 0: return u.format0.get_value (glyph_id, num_glyphs); @@ -352,7 +351,7 @@ struct Lookup } } - inline const typename T::type get_value_or_null (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + 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. */ @@ -363,15 +362,15 @@ struct Lookup } } - inline typename T::type get_class (hb_codepoint_t glyph_id, - unsigned int num_glyphs, - unsigned int outOfRange) const + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -385,7 +384,7 @@ struct Lookup default:return_trace (true); } } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -420,17 +419,14 @@ struct Lookup /* 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); -} +/*static*/ inline const AAT::Lookup<OT::HBUINT16>& Null<AAT::Lookup<OT::HBUINT16> > () +{ 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); -} +/*static*/ inline const AAT::Lookup<OT::HBUINT32>& Null<AAT::Lookup<OT::HBUINT32> > () +{ 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); -} +/*static*/ inline const AAT::Lookup<OT::Offset<OT::HBUINT16, false> >& Null<AAT::Lookup<OT::Offset<OT::HBUINT16, false> > > () +{ return *reinterpret_cast<const AAT::Lookup<OT::Offset<OT::HBUINT16, false> > *> (_hb_Null_AAT_Lookup); } namespace AAT { enum { DELETED_GLYPH = 0xFFFF }; @@ -442,7 +438,7 @@ enum { DELETED_GLYPH = 0xFFFF }; template <typename T> struct Entry { - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); /* Note, we don't recurse-sanitize data because we don't access it. @@ -470,7 +466,7 @@ struct Entry template <> struct Entry<void> { - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count /*XXX Unused?*/) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count /*XXX Unused?*/) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -503,21 +499,19 @@ struct StateTable CLASS_END_OF_LINE = 3, }; - inline int new_state (unsigned int newState) const - { return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / nClasses; } + int new_state (unsigned int newState) const + { return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / (int) nClasses; } - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const + unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const { 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 - { - return (this+entryTable).arrayZ; - } + const Entry<Extra> *get_entries () const + { return (this+entryTable).arrayZ; } - inline const Entry<Extra> *get_entryZ (int state, unsigned int klass) const + const Entry<Extra> *get_entryZ (int state, unsigned int klass) const { if (unlikely (klass >= nClasses)) return nullptr; @@ -530,8 +524,8 @@ struct StateTable return &entries[entry]; } - inline bool sanitize (hb_sanitize_context_t *c, - unsigned int *num_entries_out = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + unsigned int *num_entries_out = nullptr) const { TRACE_SANITIZE (this); if (unlikely (!(c->check_struct (this) && @@ -649,18 +643,18 @@ struct StateTable template <typename HBUCHAR> struct ClassTable { - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange) const + 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 + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && classArray.sanitize (c)); @@ -675,60 +669,60 @@ struct ClassTable struct ObsoleteTypes { - static const bool extended = false; + enum { 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) + static 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) + static 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) + static 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; + enum { 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) + static 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) + static 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) + static unsigned int wordOffsetToIndex (unsigned int offset, + const void *base, + const T *array) { return offset; } @@ -737,15 +731,15 @@ struct ExtendedTypes template <typename Types, typename EntryData> struct StateTableDriver { - inline StateTableDriver (const StateTable<Types, EntryData> &machine_, - hb_buffer_t *buffer_, - hb_face_t *face_) : + StateTableDriver (const StateTable<Types, EntryData> &machine_, + hb_buffer_t *buffer_, + hb_face_t *face_) : machine (machine_), buffer (buffer_), num_glyphs (face_->get_num_glyphs ()) {} template <typename context_t> - inline void drive (context_t *c) + void drive (context_t *c) { if (!c->in_place) buffer->clear_output (); @@ -819,10 +813,10 @@ struct ankr; struct hb_aat_apply_context_t : hb_dispatch_context_t<hb_aat_apply_context_t, bool, HB_DEBUG_APPLY> { - inline const char *get_name (void) { return "APPLY"; } + const char *get_name () { return "APPLY"; } template <typename T> - inline return_t dispatch (const T &obj) { return obj.apply (this); } - static return_t default_return_value (void) { return false; } + return_t dispatch (const T &obj) { return obj.apply (this); } + static return_t default_return_value () { return false; } bool stop_sublookup_iteration (return_t r) const { return r; } const hb_ot_shape_plan_t *plan; @@ -842,11 +836,11 @@ struct hb_aat_apply_context_t : hb_buffer_t *buffer_, hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t))); - HB_INTERNAL ~hb_aat_apply_context_t (void); + HB_INTERNAL ~hb_aat_apply_context_t (); 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; } + void set_lookup_index (unsigned int i) { lookup_index = i; } }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh index 4e63ec8e855..63c69a20f9f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-feat-table.hh @@ -44,10 +44,10 @@ struct SettingName 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 + hb_aat_layout_feature_selector_t get_selector () const { return (hb_aat_layout_feature_selector_t) (unsigned) setting; } - inline void get_info (hb_aat_layout_feature_selector_info_t *s, + void get_info (hb_aat_layout_feature_selector_info_t *s, hb_aat_layout_feature_selector_t default_selector) const { s->name_id = nameIndex; @@ -60,7 +60,7 @@ struct SettingName s->reserved = 0; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -95,11 +95,11 @@ struct FeatureName * 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 + 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); @@ -125,12 +125,12 @@ struct FeatureName return settings_table.len; } - inline hb_aat_layout_feature_type_t get_feature_type () const + 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; } + hb_ot_name_id_t get_feature_name_id () const { return nameIndex; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -155,13 +155,13 @@ struct FeatureName struct feat { - static const hb_tag_t tableTag = HB_AAT_TAG_feat; + enum { tableTag = HB_AAT_TAG_feat }; - inline bool has_data (void) const { return version.to_int (); } + bool has_data () 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 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) @@ -174,25 +174,25 @@ struct feat return featureNameCount; } - inline const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const + 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 + 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 + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-just-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-just-table.hh index 92ca6603e16..d39945abd6b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-just-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-just-table.hh @@ -45,7 +45,7 @@ using namespace OT; struct ActionSubrecordHeader { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -62,7 +62,7 @@ struct ActionSubrecordHeader struct DecompositionAction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -91,7 +91,7 @@ struct DecompositionAction struct UnconditionalAddGlyphAction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -109,7 +109,7 @@ struct UnconditionalAddGlyphAction struct ConditionalAddGlyphAction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -134,7 +134,7 @@ struct ConditionalAddGlyphAction struct DuctileGlyphAction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -160,7 +160,7 @@ struct DuctileGlyphAction struct RepeatedAddGlyphAction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -178,9 +178,9 @@ struct RepeatedAddGlyphAction struct ActionSubrecord { - inline unsigned int get_length (void) const { return u.header.actionLength; } + unsigned int get_length () const { return u.header.actionLength; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) @@ -215,7 +215,7 @@ struct ActionSubrecord struct PostcompensationActionChain { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) @@ -291,7 +291,7 @@ struct JustWidthDeltaEntry struct WidthDeltaPair { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -328,7 +328,7 @@ struct JustificationCategory * glyph if nonzero. */ }; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -347,7 +347,7 @@ struct JustificationCategory struct JustificationHeader { - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -382,9 +382,9 @@ struct JustificationHeader struct just { - static const hb_tag_t tableTag = HB_AAT_TAG_just; + enum { tableTag = HB_AAT_TAG_just }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh index 7caf45d5dd1..291f3e35b40 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-kerx-table.hh @@ -66,17 +66,16 @@ struct hb_glyph_pair_t struct KernPair { - inline int get_kerning (void) const - { return value; } + int get_kerning () const { return value; } - inline int cmp (const hb_glyph_pair_t &o) const + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -93,15 +92,15 @@ struct KernPair template <typename KernSubTableHeader> struct KerxSubTableFormat0 { - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, - hb_aat_apply_context_t *c = nullptr) const + 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 + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -123,16 +122,16 @@ struct KerxSubTableFormat0 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_) {} + 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 + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (pairs.sanitize (c))); @@ -171,10 +170,10 @@ struct Format1Entry<true> DEFINE_SIZE_STATIC (2); }; - static inline bool performAction (const Entry<EntryData> *entry) + static bool performAction (const Entry<EntryData> *entry) { return entry->data.kernActionIndex != 0xFFFF; } - static inline unsigned int kernActionIndex (const Entry<EntryData> *entry) + static unsigned int kernActionIndex (const Entry<EntryData> *entry) { return entry->data.kernActionIndex; } }; template <> @@ -193,10 +192,10 @@ struct Format1Entry<false> typedef void EntryData; - static inline bool performAction (const Entry<EntryData> *entry) + static bool performAction (const Entry<EntryData> *entry) { return entry->flags & Offset; } - static inline unsigned int kernActionIndex (const Entry<EntryData> *entry) + static unsigned int kernActionIndex (const Entry<EntryData> *entry) { return entry->flags & Offset; } }; @@ -211,14 +210,14 @@ struct KerxSubTableFormat1 struct driver_context_t { - static const bool in_place = true; + enum { in_place = true }; enum { DontAdvance = Format1EntryT::DontAdvance, }; - inline driver_context_t (const KerxSubTableFormat1 *table_, - hb_aat_apply_context_t *c_) : + 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, @@ -228,13 +227,13 @@ struct KerxSubTableFormat1 depth (0), crossStream (table->header.coverage & table->header.CrossStream) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, - const Entry<EntryData> *entry) + 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) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; unsigned int flags = entry->flags; @@ -348,7 +347,7 @@ struct KerxSubTableFormat1 bool crossStream; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -364,7 +363,7 @@ struct KerxSubTableFormat1 return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); /* The rest of array sanitizations are done at run-time. */ @@ -386,8 +385,8 @@ struct KerxSubTableFormat2 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 + 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); @@ -402,7 +401,7 @@ struct KerxSubTableFormat2 return kerxTupleKern (*v, header.tuple_count (), this, c); } - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -424,15 +423,15 @@ struct KerxSubTableFormat2 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_) {} + 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 + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -472,7 +471,7 @@ struct KerxSubTableFormat4 struct driver_context_t { - static const bool in_place = true; + enum { in_place = true }; enum Flags { Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */ @@ -490,7 +489,7 @@ struct KerxSubTableFormat4 * point table. */ }; - inline driver_context_t (const KerxSubTableFormat4 *table, + driver_context_t (const KerxSubTableFormat4 *table, hb_aat_apply_context_t *c_) : c (c_), action_type ((table->flags & ActionType) >> 30), @@ -498,13 +497,13 @@ struct KerxSubTableFormat4 mark_set (false), mark (0) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, - const Entry<EntryData> *entry) + 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) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -599,7 +598,7 @@ struct KerxSubTableFormat4 unsigned int mark; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -611,7 +610,7 @@ struct KerxSubTableFormat4 return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); /* The rest of array sanitizations are done at run-time. */ @@ -635,9 +634,9 @@ struct KerxSubTableFormat6 ValuesAreLong = 0x00000001, }; - inline bool is_long (void) const { return flags & ValuesAreLong; } + bool is_long () const { return flags & ValuesAreLong; } - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, + 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 (); @@ -665,7 +664,7 @@ struct KerxSubTableFormat6 } } - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -682,7 +681,7 @@ struct KerxSubTableFormat6 return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -705,11 +704,11 @@ struct KerxSubTableFormat6 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_) {} + 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 + int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const { return table.get_kerning (left, right, c); } }; @@ -743,8 +742,8 @@ struct KerxSubTableHeader { typedef ExtendedTypes Types; - inline unsigned int tuple_count (void) const { return tupleCount; } - inline bool is_horizontal (void) const { return !(coverage & Vertical); } + unsigned int tuple_count () const { return tupleCount; } + bool is_horizontal () const { return !(coverage & Vertical); } enum Coverage { @@ -760,7 +759,7 @@ struct KerxSubTableHeader SubtableType= 0x000000FFu, /* Subtable type. */ }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -778,11 +777,11 @@ struct KerxSubTable { 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; } + unsigned int get_size () const { return u.header.length; } + unsigned int get_type () const { return u.header.coverage & u.header.SubtableType; } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -796,7 +795,7 @@ struct KerxSubTable } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.header.sanitize (c) || @@ -829,9 +828,9 @@ template <typename T> struct KerxTable { /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ - inline const T* thiz (void) const { return static_cast<const T *> (this); } + const T* thiz () const { return static_cast<const T *> (this); } - inline bool has_state_machine (void) const + bool has_state_machine () const { typedef typename T::SubTable SubTable; @@ -846,7 +845,7 @@ struct KerxTable return false; } - inline bool has_cross_stream (void) const + bool has_cross_stream () const { typedef typename T::SubTable SubTable; @@ -861,7 +860,7 @@ struct KerxTable return false; } - inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const + int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const { typedef typename T::SubTable SubTable; @@ -879,7 +878,7 @@ struct KerxTable return v; } - inline bool apply (AAT::hb_aat_apply_context_t *c) const + bool apply (AAT::hb_aat_apply_context_t *c) const { typedef typename T::SubTable SubTable; @@ -943,11 +942,11 @@ struct KerxTable return ret; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!thiz()->version.sanitize (c) || - thiz()->version < T::minVersion || + (unsigned) thiz()->version < (unsigned) T::minVersion || !thiz()->tableCount.sanitize (c))) return_trace (false); @@ -982,14 +981,14 @@ struct kerx : KerxTable<kerx> { friend struct KerxTable<kerx>; - static const hb_tag_t tableTag = HB_AAT_TAG_kerx; - static const uint16_t minVersion = 2; + enum { tableTag = HB_AAT_TAG_kerx }; + enum { minVersion = 2u }; typedef KerxSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; typedef KerxSubTable SubTable; - inline bool has_data (void) const { return version; } + bool has_data () const { return version; } protected: HBUINT16 version; /* The version number of the extended kerning table diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-lcar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-lcar-table.hh index 40d34f59bf0..cac96971721 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-lcar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-lcar-table.hh @@ -40,14 +40,14 @@ typedef ArrayOf<HBINT16> LigCaretClassEntry; struct lcar { - static const hb_tag_t tableTag = HB_AAT_TAG_lcar; + enum { 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 + 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 ()); @@ -70,7 +70,7 @@ struct lcar return array.len; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh index 171ee4a10b2..c7600aa25dc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-morx-table.hh @@ -54,7 +54,7 @@ struct RearrangementSubtable struct driver_context_t { - static const bool in_place = true; + enum { in_place = true }; enum Flags { MarkFirst = 0x8000, /* If set, make the current glyph the first @@ -69,17 +69,17 @@ struct RearrangementSubtable Verb = 0x000F, /* The type of rearrangement specified. */ }; - inline driver_context_t (const RearrangementSubtable *table HB_UNUSED) : + driver_context_t (const RearrangementSubtable *table HB_UNUSED) : ret (false), start (0), end (0) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, - const Entry<EntryData> *entry) + bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, + const Entry<EntryData> *entry) { return (entry->flags & Verb) && start < end; } - inline bool transition (StateTableDriver<Types, EntryData> *driver, - const Entry<EntryData> *entry) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; unsigned int flags = entry->flags; @@ -163,7 +163,7 @@ struct RearrangementSubtable unsigned int end; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -175,7 +175,7 @@ struct RearrangementSubtable return_trace (dc.ret); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (machine.sanitize (c)); @@ -204,7 +204,7 @@ struct ContextualSubtable struct driver_context_t { - static const bool in_place = true; + enum { in_place = true }; enum Flags { SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ @@ -213,7 +213,7 @@ struct ContextualSubtable Reserved = 0x3FFF, /* These bits are reserved and should be set to 0. */ }; - inline driver_context_t (const ContextualSubtable *table_, + driver_context_t (const ContextualSubtable *table_, hb_aat_apply_context_t *c_) : ret (false), c (c_), @@ -222,8 +222,8 @@ struct ContextualSubtable table (table_), subs (table+table->substitutionTables) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver, - const Entry<EntryData> *entry) + bool is_actionable (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -232,8 +232,8 @@ struct ContextualSubtable return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF; } - inline bool transition (StateTableDriver<Types, EntryData> *driver, - const Entry<EntryData> *entry) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -311,7 +311,7 @@ struct ContextualSubtable const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false> &subs; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -323,7 +323,7 @@ struct ContextualSubtable return_trace (dc.ret); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -384,10 +384,10 @@ struct LigatureEntry<true> DEFINE_SIZE_STATIC (2); }; - static inline bool performAction (const Entry<EntryData> *entry) + static bool performAction (const Entry<EntryData> *entry) { return entry->flags & PerformAction; } - static inline unsigned int ligActionIndex (const Entry<EntryData> *entry) + static unsigned int ligActionIndex (const Entry<EntryData> *entry) { return entry->data.ligActionIndex; } }; template <> @@ -406,10 +406,10 @@ struct LigatureEntry<false> typedef void EntryData; - static inline bool performAction (const Entry<EntryData> *entry) + static bool performAction (const Entry<EntryData> *entry) { return entry->flags & Offset; } - static inline unsigned int ligActionIndex (const Entry<EntryData> *entry) + static unsigned int ligActionIndex (const Entry<EntryData> *entry) { return entry->flags & Offset; } }; @@ -424,7 +424,7 @@ struct LigatureSubtable struct driver_context_t { - static const bool in_place = false; + enum { in_place = false }; enum { DontAdvance = LigatureEntryT::DontAdvance, @@ -441,8 +441,8 @@ struct LigatureSubtable * into the component table. */ }; - inline driver_context_t (const LigatureSubtable *table_, - hb_aat_apply_context_t *c_) : + driver_context_t (const LigatureSubtable *table_, + hb_aat_apply_context_t *c_) : ret (false), c (c_), table (table_), @@ -451,13 +451,13 @@ struct LigatureSubtable ligature (table+table->ligature), match_length (0) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, - const Entry<EntryData> *entry) + bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, + const Entry<EntryData> *entry) { return LigatureEntryT::performAction (entry); } - inline bool transition (StateTableDriver<Types, EntryData> *driver, - const Entry<EntryData> *entry) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; @@ -567,7 +567,7 @@ struct LigatureSubtable unsigned int match_positions[HB_MAX_CONTEXT_LENGTH]; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -579,7 +579,7 @@ struct LigatureSubtable return_trace (dc.ret); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); /* The rest of array sanitizations are done at run-time. */ @@ -603,7 +603,7 @@ struct LigatureSubtable template <typename Types> struct NoncontextualSubtable { - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -625,7 +625,7 @@ struct NoncontextualSubtable return_trace (ret); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (substitute.sanitize (c)); @@ -660,7 +660,7 @@ struct InsertionSubtable struct driver_context_t { - static const bool in_place = false; + enum { in_place = false }; enum Flags { SetMark = 0x8000, /* If set, mark the current glyph. */ @@ -709,22 +709,22 @@ struct InsertionSubtable * marked location is 31 glyphs. */ }; - inline driver_context_t (const InsertionSubtable *table, - hb_aat_apply_context_t *c_) : + driver_context_t (const InsertionSubtable *table, + hb_aat_apply_context_t *c_) : ret (false), c (c_), mark_set (false), mark (0), insertionAction (table+table->insertionAction) {} - inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, - const Entry<EntryData> *entry) + 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<Types, EntryData> *driver, - const Entry<EntryData> *entry) + bool transition (StateTableDriver<Types, EntryData> *driver, + const Entry<EntryData> *entry) { hb_buffer_t *buffer = driver->buffer; unsigned int flags = entry->flags; @@ -809,7 +809,7 @@ struct InsertionSubtable const UnsizedArrayOf<GlyphID> &insertionAction; }; - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -821,7 +821,7 @@ struct InsertionSubtable return_trace (dc.ret); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); /* The rest of array sanitizations are done at run-time. */ @@ -842,7 +842,7 @@ struct InsertionSubtable struct Feature { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -868,9 +868,9 @@ struct ChainSubtable template <typename T> friend struct Chain; - inline unsigned int get_size (void) const { return length; } - inline unsigned int get_type (void) const { return coverage & 0xFF; } - inline unsigned int get_coverage (void) const { return coverage >> (sizeof (HBUINT) * 8 - 8); } + unsigned int get_size () const { return length; } + unsigned int get_type () const { return coverage & 0xFF; } + unsigned int get_coverage () const { return coverage >> (sizeof (HBUINT) * 8 - 8); } enum Coverage { @@ -897,7 +897,7 @@ struct ChainSubtable }; template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -911,14 +911,14 @@ struct ChainSubtable } } - inline bool apply (hb_aat_apply_context_t *c) const + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!length.sanitize (c) || @@ -950,7 +950,7 @@ struct Chain { typedef typename Types::HBUINT HBUINT; - inline hb_mask_t compile_flags (const hb_aat_map_builder_t *map) const + hb_mask_t compile_flags (const hb_aat_map_builder_t *map) const { hb_mask_t flags = defaultFlags; { @@ -979,7 +979,7 @@ struct Chain return flags; } - inline void apply (hb_aat_apply_context_t *c, + void apply (hb_aat_apply_context_t *c, hb_mask_t flags) const { const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount)); @@ -1049,9 +1049,9 @@ struct Chain } } - inline unsigned int get_size (void) const { return length; } + unsigned int get_size () const { return length; } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int version HB_UNUSED) const + bool sanitize (hb_sanitize_context_t *c, unsigned int version HB_UNUSED) const { TRACE_SANITIZE (this); if (!length.sanitize (c) || @@ -1096,12 +1096,12 @@ struct Chain template <typename Types> struct mortmorx { - static const hb_tag_t tableTag = HB_AAT_TAG_morx; + enum { tableTag = HB_AAT_TAG_morx }; - inline bool has_data (void) const { return version != 0; } + bool has_data () const { return version != 0; } - inline void compile_flags (const hb_aat_map_builder_t *mapper, - hb_aat_map_t *map) const + 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; @@ -1112,7 +1112,7 @@ struct mortmorx } } - inline void apply (hb_aat_apply_context_t *c) const + void apply (hb_aat_apply_context_t *c) const { if (unlikely (!c->buffer->successful)) return; c->set_lookup_index (0); @@ -1126,7 +1126,7 @@ struct mortmorx } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!version.sanitize (c) || !version || !chainCount.sanitize (c)) @@ -1158,11 +1158,11 @@ struct mortmorx struct morx : mortmorx<ExtendedTypes> { - static const hb_tag_t tableTag = HB_AAT_TAG_morx; + enum { tableTag = HB_AAT_TAG_morx }; }; struct mort : mortmorx<ObsoleteTypes> { - static const hb_tag_t tableTag = HB_AAT_TAG_mort; + enum { tableTag = HB_AAT_TAG_mort }; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh index 5474d1d11b8..0648f6175f7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-trak-table.hh @@ -46,25 +46,19 @@ struct TrackTableEntry { friend struct TrackData; - inline float get_track_value () const - { - return track.to_float (); - } + float get_track_value () const { return track.to_float (); } - inline int get_value (const void *base, - unsigned int index, - unsigned int nSizes) const - { - return (base+valuesZ).as_array (nSizes)[index]; - } + int get_value (const void *base, unsigned int index, + unsigned int table_size) const + { return (base+valuesZ).as_array (table_size)[index]; } public: - inline bool sanitize (hb_sanitize_context_t *c, const void *base, - unsigned int nSizes) const + bool sanitize (hb_sanitize_context_t *c, const void *base, + unsigned int table_size) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && - (valuesZ.sanitize (c, base, nSizes)))); + (valuesZ.sanitize (c, base, table_size)))); } protected: @@ -82,10 +76,10 @@ struct TrackTableEntry struct TrackData { - inline float interpolate_at (unsigned int idx, - float target_size, - const TrackTableEntry &trackTableEntry, - const void *base) const + float interpolate_at (unsigned int idx, + float target_size, + const TrackTableEntry &trackTableEntry, + const void *base) const { unsigned int sizes = nSizes; hb_array_t<const Fixed> size_table ((base+sizeTable).arrayZ, sizes); @@ -97,7 +91,7 @@ struct TrackData (1.f - t) * trackTableEntry.get_value (base, idx, sizes); } - inline int get_tracking (const void *base, float ptem) const + int get_tracking (const void *base, float ptem) const { /* CoreText points are CSS pixels (96 per inch), * NOT typographic points (72 per inch). @@ -143,7 +137,7 @@ struct TrackData *trackTableEntry, base)); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -166,11 +160,11 @@ struct TrackData struct trak { - static const hb_tag_t tableTag = HB_AAT_TAG_trak; + enum { tableTag = HB_AAT_TAG_trak }; - inline bool has_data (void) const { return version.to_int (); } + bool has_data () const { return version.to_int (); } - inline bool apply (hb_aat_apply_context_t *c) const + bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -211,7 +205,7 @@ struct trak return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc index fae67800c00..8de8205f574 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.cc @@ -29,6 +29,7 @@ #include "hb-ot-face.hh" #include "hb-aat-layout.hh" +#include "hb-aat-fdsc-table.hh" // Just so we compile it; unused otherwise. #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" @@ -166,10 +167,8 @@ AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *p sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX); } -AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t (void) -{ - sanitizer.end_processing (); -} +AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t () +{ sanitizer.end_processing (); } void AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_, @@ -205,7 +204,14 @@ hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper, } -bool +/* + * hb_aat_layout_has_substitution: + * @face: + * + * Returns: + * Since: 2.3.0 + */ +hb_bool_t hb_aat_layout_has_substitution (hb_face_t *face) { return face->table.morx->has_data () || @@ -259,9 +265,14 @@ 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: + * @face: + * + * Returns: + * Since: 2.3.0 + */ +hb_bool_t hb_aat_layout_has_positioning (hb_face_t *face) { return face->table.kerx->has_data (); @@ -284,7 +295,14 @@ hb_aat_layout_position (const hb_ot_shape_plan_t *plan, } -bool +/* + * hb_aat_layout_has_tracking: + * @face: + * + * Returns: + * Since: 2.3.0 + */ +hb_bool_t hb_aat_layout_has_tracking (hb_face_t *face) { return face->table.trak->has_data (); @@ -341,7 +359,9 @@ hb_aat_layout_get_feature_types (hb_face_t *face, 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); } +{ + return face->table.feat->get_feature_name_id (feature_type); +} /** * hb_aat_layout_feature_type_get_selectors: diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.h index 696e9033409..760aaae40a6 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.h @@ -457,6 +457,30 @@ hb_aat_layout_feature_type_get_selector_infos (hb_face_t unsigned int *default_index /* OUT. May be NULL. */); +/* + * morx/mort + */ + +HB_EXTERN hb_bool_t +hb_aat_layout_has_substitution (hb_face_t *face); + + +/* + * kerx + */ + +HB_EXTERN hb_bool_t +hb_aat_layout_has_positioning (hb_face_t *face); + + +/* + * trak + */ + +HB_EXTERN hb_bool_t +hb_aat_layout_has_tracking (hb_face_t *face); + + HB_END_DECLS #endif /* HB_AAT_LAYOUT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh index 5fd47ed62ad..8346d9f00b5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout.hh @@ -39,7 +39,7 @@ struct hb_aat_feature_mapping_t hb_aat_layout_feature_selector_t selectorToEnable; hb_aat_layout_feature_selector_t selectorToDisable; - static inline int cmp (const void *key_, const void *entry_) + static 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_; @@ -56,9 +56,6 @@ 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, @@ -70,17 +67,11 @@ hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer); HB_INTERNAL void 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, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh index 8a42b3510bf..3b00b55914e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh @@ -43,7 +43,7 @@ struct FTStringRange { friend struct ltag; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && (base+tag).sanitize (c, length)); @@ -60,16 +60,16 @@ struct FTStringRange struct ltag { - static const hb_tag_t tableTag = HB_AAT_TAG_ltag; + enum { tableTag = HB_AAT_TAG_ltag }; - inline hb_language_t get_language (unsigned int i) const + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh index b033e336872..fa312dbec39 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh @@ -36,15 +36,12 @@ struct hb_aat_map_t public: - inline void init (void) + void init () { memset (this, 0, sizeof (*this)); chain_flags.init (); } - inline void fini (void) - { - chain_flags.fini (); - } + void fini () { chain_flags.fini (); } public: hb_vector_t<hb_mask_t, 1> chain_flags; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh new file mode 100644 index 00000000000..d4df16546cd --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh @@ -0,0 +1,274 @@ +/* + * 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_ARRAY_HH +#define HB_ARRAY_HH + +#include "hb.hh" + + +template <typename Type> +struct hb_sorted_array_t; + +template <typename Type> +struct hb_array_t +{ + typedef Type ItemType; + enum { item_size = hb_static_size (Type) }; + + /* + * Constructors. + */ + hb_array_t () : arrayZ (nullptr), len (0) {} + hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), len (o.len) {} + hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} + template <unsigned int len_> hb_array_t (Type (&array_)[len_]) : arrayZ (array_), len (len_) {} + + /* + * Operators. + */ + + Type& operator [] (int i_) const + { + unsigned int i = (unsigned int) i_; + if (unlikely (i >= len)) return CrapOrNull(Type); + return arrayZ[i]; + } + + explicit_operator bool () const { return len; } + Type * operator & () const { return arrayZ; } + Type & operator * () { return (this->operator [])[0]; } + operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, len); } + template <typename T> operator T * () const { return arrayZ; } + + hb_array_t<Type> & operator += (unsigned int count) + { + if (unlikely (count > len)) + count = len; + len -= count; + arrayZ += count; + return *this; + } + hb_array_t<Type> & operator -= (unsigned int count) + { + if (unlikely (count > len)) + count = len; + len -= count; + return *this; + } + hb_array_t<Type> & operator ++ () { *this += 1; } + hb_array_t<Type> & operator -- () { *this -= 1; } + hb_array_t<Type> operator + (unsigned int count) + { hb_array_t<Type> copy (*this); *this += count; return copy; } + hb_array_t<Type> operator - (unsigned int count) + { hb_array_t<Type> copy (*this); *this -= count; return copy; } + hb_array_t<Type> operator ++ (int) + { hb_array_t<Type> copy (*this); ++*this; return copy; } + hb_array_t<Type> operator -- (int) + { hb_array_t<Type> copy (*this); --*this; return copy; } + + /* + * Compare, Sort, and Search. + */ + + /* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */ + int cmp (const hb_array_t<Type> &a) const + { + if (len != a.len) + return (int) a.len - (int) len; + return hb_memcmp (a.arrayZ, arrayZ, get_size ()); + } + static int cmp (const void *pa, const void *pb) + { + hb_array_t<Type> *a = (hb_array_t<Type> *) pa; + hb_array_t<Type> *b = (hb_array_t<Type> *) pb; + return b->cmp (*a); + } + + template <typename T> + 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> + 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; + } + + hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*)) + { + ::qsort (arrayZ, len, item_size, cmp_); + return hb_sorted_array_t<Type> (*this); + } + hb_sorted_array_t<Type> qsort () + { + ::qsort (arrayZ, len, item_size, Type::cmp); + return hb_sorted_array_t<Type> (*this); + } + void qsort (unsigned int start, unsigned int end) + { + end = MIN (end, len); + assert (start <= end); + ::qsort (arrayZ + start, end - start, item_size, Type::cmp); + } + + /* + * Other methods. + */ + + unsigned int get_size () const { return len * item_size; } + + hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const + { + if (!start_offset && !seg_count) + return *this; + + unsigned int count = len; + if (unlikely (start_offset > count)) + count = 0; + else + count -= start_offset; + if (seg_count) + count = *seg_count = MIN (count, *seg_count); + return hb_array_t<Type> (arrayZ + start_offset, count); + } + hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const + { return sub_array (start_offset, &seg_count); } + + /* Only call if you allocated the underlying array using malloc() or similar. */ + void free () + { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } + + template <typename hb_sanitize_context_t> + bool sanitize (hb_sanitize_context_t *c) const + { return c->check_array (arrayZ, len); } + + /* + * Members + */ + + 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> +{ + hb_sorted_array_t () : hb_array_t<Type> () {} + hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {} + hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t<Type> (array_, len_) {} + + 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)); } + 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> + Type *bsearch (const T &x, Type *not_found = nullptr) + { + unsigned int i; + return bfind (x, &i) ? &this->arrayZ[i] : not_found; + } + template <typename T> + 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> + 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); } + + +typedef hb_array_t<const char> hb_bytes_t; +typedef hb_array_t<const unsigned char> hb_ubytes_t; + + +#endif /* HB_ARRAY_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh index 265de1267ac..9321932e06f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-atomic.hh @@ -104,7 +104,7 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) #include <windows.h> -static inline void _hb_memory_barrier (void) +static inline void _hb_memory_barrier () { #if !defined(MemoryBarrier) /* MinGW has a convoluted history of supporting MemoryBarrier. */ @@ -143,7 +143,7 @@ static_assert ((sizeof (LONG) == sizeof (int)), ""); static inline int _hb_fetch_and_add (int *AI, int V) { _hb_memory_w_barrier (); - int result = atomic_add_int_nv ((uint_t *) AI, V); + int result = atomic_add_int_nv ((uint_t *) AI, V) - V; _hb_memory_r_barrier (); return result; } @@ -267,12 +267,12 @@ inline void *hb_atomic_ptr_impl_get (void ** const P) { void *v = *P; _hb_memory #define HB_ATOMIC_INT_INIT(V) {V} struct hb_atomic_int_t { - 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); } + void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); } + void set (int v_) { hb_atomic_int_impl_set (&v, v_); } + int get_relaxed () const { return hb_atomic_int_impl_get_relaxed (&v); } + int get () const { return hb_atomic_int_impl_get (&v); } + int inc () { return hb_atomic_int_impl_add (&v, 1); } + int dec () { return hb_atomic_int_impl_add (&v, -1); } int v; }; @@ -284,14 +284,14 @@ struct hb_atomic_ptr_t { typedef typename hb_remove_pointer (P) T; - inline void init (T* v_ = nullptr) { set_relaxed (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_); } + void init (T* v_ = nullptr) { set_relaxed (v_); } + void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); } + T *get_relaxed () const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); } + T *get () const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } + bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); } - inline T * operator -> (void) const { return get (); } - template <typename C> inline operator C * (void) const { return get (); } + T * operator -> () const { return get (); } + template <typename C> operator C * () const { return get (); } T *v; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc index 8ebedca7887..b53b20bd147 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc @@ -188,7 +188,7 @@ hb_blob_copy_writable_or_fail (hb_blob_t *blob) * Since: 0.9.2 **/ hb_blob_t * -hb_blob_get_empty (void) +hb_blob_get_empty () { return const_cast<hb_blob_t *> (&Null(hb_blob_t)); } @@ -378,7 +378,7 @@ hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) bool -hb_blob_t::try_make_writable_inplace_unix (void) +hb_blob_t::try_make_writable_inplace_unix () { #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT) uintptr_t pagesize = -1, mask, length; @@ -421,7 +421,7 @@ hb_blob_t::try_make_writable_inplace_unix (void) } bool -hb_blob_t::try_make_writable_inplace (void) +hb_blob_t::try_make_writable_inplace () { DEBUG_MSG_FUNC (BLOB, this, "making writable inplace\n"); @@ -436,7 +436,7 @@ hb_blob_t::try_make_writable_inplace (void) } bool -hb_blob_t::try_make_writable (void) +hb_blob_t::try_make_writable () { if (hb_object_is_immutable (this)) return false; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh index bf2132bda99..4ea13f81370 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.hh @@ -38,12 +38,9 @@ struct hb_blob_t { - inline void fini_shallow (void) - { - destroy_user_data (); - } + void fini_shallow () { destroy_user_data (); } - inline void destroy_user_data (void) + void destroy_user_data () { if (destroy) { @@ -53,19 +50,17 @@ struct hb_blob_t } } - HB_INTERNAL bool try_make_writable (void); - HB_INTERNAL bool try_make_writable_inplace (void); - HB_INTERNAL bool try_make_writable_inplace_unix (void); + HB_INTERNAL bool try_make_writable (); + HB_INTERNAL bool try_make_writable_inplace (); + HB_INTERNAL bool try_make_writable_inplace_unix (); template <typename Type> - inline const Type* as (void) const + const Type* as () const { return length < hb_null_size (Type) ? &Null(Type) : reinterpret_cast<const Type *> (data); } - inline hb_bytes_t as_bytes (void) const - { - return hb_bytes_t (data, length); - } + hb_bytes_t as_bytes () const + { return hb_bytes_t (data, length); } public: hb_object_header_t header; @@ -88,16 +83,16 @@ 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_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {} + hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; } + const T * operator -> () const { return get (); } + const T & operator * () const { return *get (); } + template <typename C> operator const C * () const { return get (); } + operator const char * () const { return (const char *) get (); } + const T * get () const { return b->as<T> (); } + hb_blob_t * get_blob () const { return b.get_raw (); } + unsigned int get_length () const { return b.get ()->length; } + void destroy () { hb_blob_destroy (b.get ()); b = nullptr; } hb_nonnull_ptr_t<hb_blob_t> b; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc index 1bd603d4474..6e265e84c6c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-serialize.cc @@ -44,7 +44,7 @@ static const char *serialize_formats[] = { * Since: 0.9.7 **/ const char ** -hb_buffer_serialize_list_formats (void) +hb_buffer_serialize_list_formats () { return serialize_formats; } @@ -246,7 +246,7 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer, if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS) { - if (info[i].mask &HB_GLYPH_FLAG_DEFINED) + if (info[i].mask & HB_GLYPH_FLAG_DEFINED) p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc index 1a5547b35f3..2dc02e9d657 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc @@ -215,7 +215,7 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size) /* HarfBuzz-Internal API */ void -hb_buffer_t::reset (void) +hb_buffer_t::reset () { if (unlikely (hb_object_is_immutable (this))) return; @@ -230,7 +230,7 @@ hb_buffer_t::reset (void) } void -hb_buffer_t::clear (void) +hb_buffer_t::clear () { if (unlikely (hb_object_is_immutable (this))) return; @@ -287,7 +287,7 @@ hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) void -hb_buffer_t::remove_output (void) +hb_buffer_t::remove_output () { if (unlikely (hb_object_is_immutable (this))) return; @@ -300,7 +300,7 @@ hb_buffer_t::remove_output (void) } void -hb_buffer_t::clear_output (void) +hb_buffer_t::clear_output () { if (unlikely (hb_object_is_immutable (this))) return; @@ -313,7 +313,7 @@ hb_buffer_t::clear_output (void) } void -hb_buffer_t::clear_positions (void) +hb_buffer_t::clear_positions () { if (unlikely (hb_object_is_immutable (this))) return; @@ -328,7 +328,7 @@ hb_buffer_t::clear_positions (void) } void -hb_buffer_t::swap_buffers (void) +hb_buffer_t::swap_buffers () { if (unlikely (!successful)) return; @@ -480,7 +480,7 @@ hb_buffer_t::reverse_range (unsigned int start, } void -hb_buffer_t::reverse (void) +hb_buffer_t::reverse () { if (unlikely (!len)) return; @@ -489,7 +489,7 @@ hb_buffer_t::reverse (void) } void -hb_buffer_t::reverse_clusters (void) +hb_buffer_t::reverse_clusters () { unsigned int i, start, count, last_cluster; @@ -636,7 +636,7 @@ hb_buffer_t::unsafe_to_break_from_outbuffer (unsigned int start, unsigned int en } void -hb_buffer_t::guess_segment_properties (void) +hb_buffer_t::guess_segment_properties () { assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); @@ -709,7 +709,7 @@ DEFINE_NULL_INSTANCE (hb_buffer_t) = * Since: 0.9.2 **/ hb_buffer_t * -hb_buffer_create (void) +hb_buffer_create () { hb_buffer_t *buffer; @@ -727,14 +727,14 @@ hb_buffer_create (void) /** * hb_buffer_get_empty: * - * + * * * Return value: (transfer full): * * Since: 0.9.2 **/ hb_buffer_t * -hb_buffer_get_empty (void) +hb_buffer_get_empty () { return const_cast<hb_buffer_t *> (&Null(hb_buffer_t)); } @@ -785,14 +785,14 @@ hb_buffer_destroy (hb_buffer_t *buffer) /** * hb_buffer_set_user_data: (skip) * @buffer: an #hb_buffer_t. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -809,11 +809,11 @@ hb_buffer_set_user_data (hb_buffer_t *buffer, /** * hb_buffer_get_user_data: (skip) * @buffer: an #hb_buffer_t. - * @key: + * @key: * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -863,9 +863,9 @@ hb_buffer_get_content_type (hb_buffer_t *buffer) /** * hb_buffer_set_unicode_funcs: * @buffer: an #hb_buffer_t. - * @unicode_funcs: + * @unicode_funcs: + * * - * * * Since: 0.9.2 **/ @@ -888,9 +888,9 @@ hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, * hb_buffer_get_unicode_funcs: * @buffer: an #hb_buffer_t. * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -1094,7 +1094,7 @@ hb_buffer_set_flags (hb_buffer_t *buffer, * * See hb_buffer_set_flags(). * - * Return value: + * Return value: * The @buffer flags. * * Since: 0.9.7 @@ -1108,9 +1108,9 @@ hb_buffer_get_flags (hb_buffer_t *buffer) /** * hb_buffer_set_cluster_level: * @buffer: an #hb_buffer_t. - * @cluster_level: + * @cluster_level: + * * - * * * Since: 0.9.42 **/ @@ -1128,9 +1128,9 @@ hb_buffer_set_cluster_level (hb_buffer_t *buffer, * hb_buffer_get_cluster_level: * @buffer: an #hb_buffer_t. * - * * - * Return value: + * + * Return value: * * Since: 0.9.42 **/ @@ -1169,7 +1169,7 @@ hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, * * See hb_buffer_set_replacement_codepoint(). * - * Return value: + * Return value: * The @buffer replacement #hb_codepoint_t. * * Since: 0.9.31 @@ -1209,7 +1209,7 @@ hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, * * See hb_buffer_set_invisible_glyph(). * - * Return value: + * Return value: * The @buffer invisible #hb_codepoint_t. * * Since: 2.0.0 @@ -1320,7 +1320,7 @@ hb_buffer_add (hb_buffer_t *buffer, * Similar to hb_buffer_pre_allocate(), but clears any new items added at the * end. * - * Return value: + * Return value: * %true if @buffer memory allocation succeeded, %false otherwise. * * Since: 0.9.2 @@ -2000,7 +2000,7 @@ hb_buffer_diff (hb_buffer_t *buffer, * @user_data: * @destroy: * - * + * * * Since: 1.1.3 **/ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh index 37adeb083bf..8a3170ca9a5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh @@ -137,7 +137,9 @@ struct hb_buffer_t /* Methods */ - inline void allocate_var (unsigned int start, unsigned int count) + bool in_error () const { return !successful; } + + void allocate_var (unsigned int start, unsigned int count) { #ifndef HB_NDEBUG unsigned int end = start + count; @@ -147,7 +149,7 @@ struct hb_buffer_t allocated_var_bits |= bits; #endif } - inline void deallocate_var (unsigned int start, unsigned int count) + void deallocate_var (unsigned int start, unsigned int count) { #ifndef HB_NDEBUG unsigned int end = start + count; @@ -157,7 +159,7 @@ struct hb_buffer_t allocated_var_bits &= ~bits; #endif } - inline void assert_var (unsigned int start, unsigned int count) + void assert_var (unsigned int start, unsigned int count) { #ifndef HB_NDEBUG unsigned int end = start + count; @@ -166,53 +168,51 @@ struct hb_buffer_t assert (bits == (allocated_var_bits & bits)); #endif } - inline void deallocate_var_all (void) + void deallocate_var_all () { #ifndef HB_NDEBUG allocated_var_bits = 0; #endif } - inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; } - inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; } + hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; } + hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; } - inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } - inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } + hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } + hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } - inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 : 0]; } - inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len - 1 : 0]; } + hb_glyph_info_t &prev () { return out_info[out_len ? out_len - 1 : 0]; } + hb_glyph_info_t prev () const { return out_info[out_len ? out_len - 1 : 0]; } - inline bool has_separate_output (void) const { return info != out_info; } + bool has_separate_output () const { return info != out_info; } - HB_INTERNAL void reset (void); - HB_INTERNAL void clear (void); + HB_INTERNAL void reset (); + HB_INTERNAL void clear (); - inline unsigned int backtrack_len (void) const - { return have_output? out_len : idx; } - inline unsigned int lookahead_len (void) const - { return len - idx; } - inline unsigned int next_serial (void) { return serial++; } + unsigned int backtrack_len () const { return have_output? out_len : idx; } + unsigned int lookahead_len () const { return len - idx; } + unsigned int next_serial () { return serial++; } HB_INTERNAL void add (hb_codepoint_t codepoint, unsigned int cluster); HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); - HB_INTERNAL void reverse (void); - HB_INTERNAL void reverse_clusters (void); - HB_INTERNAL void guess_segment_properties (void); + HB_INTERNAL void reverse (); + HB_INTERNAL void reverse_clusters (); + HB_INTERNAL void guess_segment_properties (); - HB_INTERNAL void swap_buffers (void); - HB_INTERNAL void remove_output (void); - HB_INTERNAL void clear_output (void); - HB_INTERNAL void clear_positions (void); + HB_INTERNAL void swap_buffers (); + HB_INTERNAL void remove_output (); + HB_INTERNAL void clear_output (); + HB_INTERNAL void clear_positions (); HB_INTERNAL void replace_glyphs (unsigned int num_in, unsigned int num_out, const hb_codepoint_t *glyph_data); - inline void replace_glyph (hb_codepoint_t glyph_index) + void replace_glyph (hb_codepoint_t glyph_index) { if (unlikely (out_info != info || out_len != idx)) { if (unlikely (!make_room_for (1, 1))) return; @@ -224,7 +224,7 @@ struct hb_buffer_t out_len++; } /* Makes a copy of the glyph at idx to output and replace glyph_index */ - inline hb_glyph_info_t & output_glyph (hb_codepoint_t glyph_index) + hb_glyph_info_t & output_glyph (hb_codepoint_t glyph_index) { if (unlikely (!make_room_for (0, 1))) return Crap(hb_glyph_info_t); @@ -238,7 +238,7 @@ struct hb_buffer_t return out_info[out_len - 1]; } - inline void output_info (const hb_glyph_info_t &glyph_info) + void output_info (const hb_glyph_info_t &glyph_info) { if (unlikely (!make_room_for (0, 1))) return; @@ -247,7 +247,7 @@ struct hb_buffer_t out_len++; } /* Copies glyph at idx to output but doesn't advance idx */ - inline void copy_glyph (void) + void copy_glyph () { if (unlikely (!make_room_for (0, 1))) return; @@ -257,8 +257,8 @@ struct hb_buffer_t } /* Copies glyph at idx to output and advance idx. * If there's no output, just advance idx. */ - inline void - next_glyph (void) + void + next_glyph () { if (have_output) { @@ -274,7 +274,7 @@ struct hb_buffer_t } /* Copies n glyphs at idx to output and advance idx. * If there's no output, just advance idx. */ - inline void + void next_glyphs (unsigned int n) { if (have_output) @@ -290,16 +290,13 @@ struct hb_buffer_t idx += n; } /* Advance idx without copying to output. */ - inline void skip_glyph (void) - { - idx++; - } - inline void reset_masks (hb_mask_t mask) + void skip_glyph () { idx++; } + void reset_masks (hb_mask_t mask) { for (unsigned int j = 0; j < len; j++) info[j].mask = mask; } - inline void add_masks (hb_mask_t mask) + void add_masks (hb_mask_t mask) { for (unsigned int j = 0; j < len; j++) info[j].mask |= mask; @@ -307,7 +304,7 @@ struct hb_buffer_t HB_INTERNAL void set_masks (hb_mask_t value, hb_mask_t mask, unsigned int cluster_start, unsigned int cluster_end); - inline void merge_clusters (unsigned int start, unsigned int end) + void merge_clusters (unsigned int start, unsigned int end) { if (end - start < 2) return; @@ -316,9 +313,9 @@ struct hb_buffer_t HB_INTERNAL void merge_clusters_impl (unsigned int start, unsigned int end); HB_INTERNAL void merge_out_clusters (unsigned int start, unsigned int end); /* Merge clusters for deleting current glyph, and skip it. */ - HB_INTERNAL void delete_glyph (void); + HB_INTERNAL void delete_glyph (); - inline void unsafe_to_break (unsigned int start, + void unsafe_to_break (unsigned int start, unsigned int end) { if (end - start < 2) @@ -334,10 +331,10 @@ struct hb_buffer_t HB_INTERNAL bool enlarge (unsigned int size); - inline bool ensure (unsigned int size) + bool ensure (unsigned int size) { return likely (!size || size < allocated) ? true : enlarge (size); } - inline bool ensure_inplace (unsigned int size) + bool ensure_inplace (unsigned int size) { return likely (!size || size < allocated); } HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); @@ -346,12 +343,12 @@ struct hb_buffer_t typedef long scratch_buffer_t; HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size); - inline void clear_context (unsigned int side) { context_len[side] = 0; } + void clear_context (unsigned int side) { context_len[side] = 0; } HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *)); - inline bool messaging (void) { return unlikely (message_func); } - inline bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4) + bool messaging () { return unlikely (message_func); } + bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4) { if (!messaging ()) return true; @@ -363,7 +360,7 @@ struct hb_buffer_t } HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) HB_PRINTF_FUNC(3, 0); - static inline void + static void set_cluster (hb_glyph_info_t &inf, unsigned int cluster, unsigned int mask = 0) { if (inf.cluster != cluster) @@ -376,7 +373,7 @@ struct hb_buffer_t inf.cluster = cluster; } - inline int + int _unsafe_to_break_find_min_cluster (const hb_glyph_info_t *infos, unsigned int start, unsigned int end, unsigned int cluster) const @@ -385,7 +382,7 @@ struct hb_buffer_t cluster = MIN<unsigned int> (cluster, infos[i].cluster); return cluster; } - inline void + void _unsafe_to_break_set_mask (hb_glyph_info_t *infos, unsigned int start, unsigned int end, unsigned int cluster) @@ -398,13 +395,9 @@ struct hb_buffer_t } } - inline void - unsafe_to_break_all (void) - { - unsafe_to_break_impl (0, len); - } - inline void - safe_to_break_all (void) + void unsafe_to_break_all () + { unsafe_to_break_impl (0, len); } + void safe_to_break_all () { for (unsigned int i = 0; i < len; i++) info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cache.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cache.hh index eb48f18cf94..bf26d96be46 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cache.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cache.hh @@ -39,16 +39,16 @@ struct hb_cache_t static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (hb_atomic_int_t)), ""); static_assert (sizeof (hb_atomic_int_t) == sizeof (unsigned int), ""); - inline void init (void) { clear (); } - inline void fini (void) {} + void init () { clear (); } + void fini () {} - inline void clear (void) + void clear () { for (unsigned i = 0; i < ARRAY_LENGTH (values); i++) values[i].set_relaxed (-1); } - inline bool get (unsigned int key, unsigned int *value) const + bool get (unsigned int key, unsigned int *value) const { unsigned int k = key & ((1u<<cache_bits)-1); unsigned int v = values[k].get_relaxed (); @@ -59,7 +59,7 @@ struct hb_cache_t return true; } - inline bool set (unsigned int key, unsigned int value) + bool set (unsigned int key, unsigned int value) { if (unlikely ((key >> key_bits) || (value >> value_bits))) return false; /* Overflows */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh new file mode 100644 index 00000000000..c2be034a1ce --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh @@ -0,0 +1,744 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_CFF_INTERP_COMMON_HH +#define HB_CFF_INTERP_COMMON_HH + +namespace CFF { + +using namespace OT; + +typedef unsigned int OpCode; + + +/* === Dict operators === */ + +/* One byte operators (0-31) */ +#define OpCode_version 0 /* CFF Top */ +#define OpCode_Notice 1 /* CFF Top */ +#define OpCode_FullName 2 /* CFF Top */ +#define OpCode_FamilyName 3 /* CFF Top */ +#define OpCode_Weight 4 /* CFF Top */ +#define OpCode_FontBBox 5 /* CFF Top */ +#define OpCode_BlueValues 6 /* CFF Private, CFF2 Private */ +#define OpCode_OtherBlues 7 /* CFF Private, CFF2 Private */ +#define OpCode_FamilyBlues 8 /* CFF Private, CFF2 Private */ +#define OpCode_FamilyOtherBlues 9 /* CFF Private, CFF2 Private */ +#define OpCode_StdHW 10 /* CFF Private, CFF2 Private */ +#define OpCode_StdVW 11 /* CFF Private, CFF2 Private */ +#define OpCode_escape 12 /* All. Shared with CS */ +#define OpCode_UniqueID 13 /* CFF Top */ +#define OpCode_XUID 14 /* CFF Top */ +#define OpCode_charset 15 /* CFF Top (0) */ +#define OpCode_Encoding 16 /* CFF Top (0) */ +#define OpCode_CharStrings 17 /* CFF Top, CFF2 Top */ +#define OpCode_Private 18 /* CFF Top, CFF2 FD */ +#define OpCode_Subrs 19 /* CFF Private, CFF2 Private */ +#define OpCode_defaultWidthX 20 /* CFF Private (0) */ +#define OpCode_nominalWidthX 21 /* CFF Private (0) */ +#define OpCode_vsindexdict 22 /* CFF2 Private/CS */ +#define OpCode_blenddict 23 /* CFF2 Private/CS */ +#define OpCode_vstore 24 /* CFF2 Top */ +#define OpCode_reserved25 25 +#define OpCode_reserved26 26 +#define OpCode_reserved27 27 + +/* Numbers */ +#define OpCode_shortint 28 /* 16-bit integer, All */ +#define OpCode_longintdict 29 /* 32-bit integer, All */ +#define OpCode_BCD 30 /* Real number, CFF2 Top/FD */ +#define OpCode_reserved31 31 + +/* 1-byte integers */ +#define OpCode_OneByteIntFirst 32 /* All. beginning of the range of first byte ints */ +#define OpCode_OneByteIntLast 246 /* All. ending of the range of first byte int */ + +/* 2-byte integers */ +#define OpCode_TwoBytePosInt0 247 /* All. first byte of two byte positive int (+108 to +1131) */ +#define OpCode_TwoBytePosInt1 248 +#define OpCode_TwoBytePosInt2 249 +#define OpCode_TwoBytePosInt3 250 + +#define OpCode_TwoByteNegInt0 251 /* All. first byte of two byte negative int (-1131 to -108) */ +#define OpCode_TwoByteNegInt1 252 +#define OpCode_TwoByteNegInt2 253 +#define OpCode_TwoByteNegInt3 254 + +/* Two byte escape operators 12, (0-41) */ +#define OpCode_ESC_Base 256 +#define Make_OpCode_ESC(byte2) ((OpCode)(OpCode_ESC_Base + (byte2))) + +inline OpCode Unmake_OpCode_ESC (OpCode op) { return (OpCode)(op - OpCode_ESC_Base); } +inline bool Is_OpCode_ESC (OpCode op) { return op >= OpCode_ESC_Base; } +inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1; } + +#define OpCode_Copyright Make_OpCode_ESC(0) /* CFF Top */ +#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */ +#define OpCode_ItalicAngle Make_OpCode_ESC(2) /* CFF Top (0) */ +#define OpCode_UnderlinePosition Make_OpCode_ESC(3) /* CFF Top (-100) */ +#define OpCode_UnderlineThickness Make_OpCode_ESC(4) /* CFF Top (50) */ +#define OpCode_PaintType Make_OpCode_ESC(5) /* CFF Top (0) */ +#define OpCode_CharstringType Make_OpCode_ESC(6) /* CFF Top (2) */ +#define OpCode_FontMatrix Make_OpCode_ESC(7) /* CFF Top, CFF2 Top (.001 0 0 .001 0 0)*/ +#define OpCode_StrokeWidth Make_OpCode_ESC(8) /* CFF Top (0) */ +#define OpCode_BlueScale Make_OpCode_ESC(9) /* CFF Private, CFF2 Private (0.039625) */ +#define OpCode_BlueShift Make_OpCode_ESC(10) /* CFF Private, CFF2 Private (7) */ +#define OpCode_BlueFuzz Make_OpCode_ESC(11) /* CFF Private, CFF2 Private (1) */ +#define OpCode_StemSnapH Make_OpCode_ESC(12) /* CFF Private, CFF2 Private */ +#define OpCode_StemSnapV Make_OpCode_ESC(13) /* CFF Private, CFF2 Private */ +#define OpCode_ForceBold Make_OpCode_ESC(14) /* CFF Private (false) */ +#define OpCode_reservedESC15 Make_OpCode_ESC(15) +#define OpCode_reservedESC16 Make_OpCode_ESC(16) +#define OpCode_LanguageGroup Make_OpCode_ESC(17) /* CFF Private, CFF2 Private (0) */ +#define OpCode_ExpansionFactor Make_OpCode_ESC(18) /* CFF Private, CFF2 Private (0.06) */ +#define OpCode_initialRandomSeed Make_OpCode_ESC(19) /* CFF Private (0) */ +#define OpCode_SyntheticBase Make_OpCode_ESC(20) /* CFF Top */ +#define OpCode_PostScript Make_OpCode_ESC(21) /* CFF Top */ +#define OpCode_BaseFontName Make_OpCode_ESC(22) /* CFF Top */ +#define OpCode_BaseFontBlend Make_OpCode_ESC(23) /* CFF Top */ +#define OpCode_reservedESC24 Make_OpCode_ESC(24) +#define OpCode_reservedESC25 Make_OpCode_ESC(25) +#define OpCode_reservedESC26 Make_OpCode_ESC(26) +#define OpCode_reservedESC27 Make_OpCode_ESC(27) +#define OpCode_reservedESC28 Make_OpCode_ESC(28) +#define OpCode_reservedESC29 Make_OpCode_ESC(29) +#define OpCode_ROS Make_OpCode_ESC(30) /* CFF Top_CID */ +#define OpCode_CIDFontVersion Make_OpCode_ESC(31) /* CFF Top_CID (0) */ +#define OpCode_CIDFontRevision Make_OpCode_ESC(32) /* CFF Top_CID (0) */ +#define OpCode_CIDFontType Make_OpCode_ESC(33) /* CFF Top_CID (0) */ +#define OpCode_CIDCount Make_OpCode_ESC(34) /* CFF Top_CID (8720) */ +#define OpCode_UIDBase Make_OpCode_ESC(35) /* CFF Top_CID */ +#define OpCode_FDArray Make_OpCode_ESC(36) /* CFF Top_CID, CFF2 Top */ +#define OpCode_FDSelect Make_OpCode_ESC(37) /* CFF Top_CID, CFF2 Top */ +#define OpCode_FontName Make_OpCode_ESC(38) /* CFF Top_CID */ + + +/* === CharString operators === */ + +#define OpCode_hstem 1 /* CFF, CFF2 */ +#define OpCode_Reserved2 2 +#define OpCode_vstem 3 /* CFF, CFF2 */ +#define OpCode_vmoveto 4 /* CFF, CFF2 */ +#define OpCode_rlineto 5 /* CFF, CFF2 */ +#define OpCode_hlineto 6 /* CFF, CFF2 */ +#define OpCode_vlineto 7 /* CFF, CFF2 */ +#define OpCode_rrcurveto 8 /* CFF, CFF2 */ +#define OpCode_Reserved9 9 +#define OpCode_callsubr 10 /* CFF, CFF2 */ +#define OpCode_return 11 /* CFF */ +//#define OpCode_escape 12 /* CFF, CFF2 */ +#define OpCode_Reserved13 13 +#define OpCode_endchar 14 /* CFF */ +#define OpCode_vsindexcs 15 /* CFF2 */ +#define OpCode_blendcs 16 /* CFF2 */ +#define OpCode_Reserved17 17 +#define OpCode_hstemhm 18 /* CFF, CFF2 */ +#define OpCode_hintmask 19 /* CFF, CFF2 */ +#define OpCode_cntrmask 20 /* CFF, CFF2 */ +#define OpCode_rmoveto 21 /* CFF, CFF2 */ +#define OpCode_hmoveto 22 /* CFF, CFF2 */ +#define OpCode_vstemhm 23 /* CFF, CFF2 */ +#define OpCode_rcurveline 24 /* CFF, CFF2 */ +#define OpCode_rlinecurve 25 /* CFF, CFF2 */ +#define OpCode_vvcurveto 26 /* CFF, CFF2 */ +#define OpCode_hhcurveto 27 /* CFF, CFF2 */ +//#define OpCode_shortint 28 /* CFF, CFF2 */ +#define OpCode_callgsubr 29 /* CFF, CFF2 */ +#define OpCode_vhcurveto 30 /* CFF, CFF2 */ +#define OpCode_hvcurveto 31 /* CFF, CFF2 */ + +#define OpCode_fixedcs 255 /* 32-bit fixed */ + +/* Two byte escape operators 12, (0-41) */ +#define OpCode_dotsection Make_OpCode_ESC(0) /* CFF (obsoleted) */ +#define OpCode_ReservedESC1 Make_OpCode_ESC(1) +#define OpCode_ReservedESC2 Make_OpCode_ESC(2) +#define OpCode_and Make_OpCode_ESC(3) /* CFF */ +#define OpCode_or Make_OpCode_ESC(4) /* CFF */ +#define OpCode_not Make_OpCode_ESC(5) /* CFF */ +#define OpCode_ReservedESC6 Make_OpCode_ESC(6) +#define OpCode_ReservedESC7 Make_OpCode_ESC(7) +#define OpCode_ReservedESC8 Make_OpCode_ESC(8) +#define OpCode_abs Make_OpCode_ESC(9) /* CFF */ +#define OpCode_add Make_OpCode_ESC(10) /* CFF */ +#define OpCode_sub Make_OpCode_ESC(11) /* CFF */ +#define OpCode_div Make_OpCode_ESC(12) /* CFF */ +#define OpCode_ReservedESC13 Make_OpCode_ESC(13) +#define OpCode_neg Make_OpCode_ESC(14) /* CFF */ +#define OpCode_eq Make_OpCode_ESC(15) /* CFF */ +#define OpCode_ReservedESC16 Make_OpCode_ESC(16) +#define OpCode_ReservedESC17 Make_OpCode_ESC(17) +#define OpCode_drop Make_OpCode_ESC(18) /* CFF */ +#define OpCode_ReservedESC19 Make_OpCode_ESC(19) +#define OpCode_put Make_OpCode_ESC(20) /* CFF */ +#define OpCode_get Make_OpCode_ESC(21) /* CFF */ +#define OpCode_ifelse Make_OpCode_ESC(22) /* CFF */ +#define OpCode_random Make_OpCode_ESC(23) /* CFF */ +#define OpCode_mul Make_OpCode_ESC(24) /* CFF */ +//#define OpCode_reservedESC25 Make_OpCode_ESC(25) +#define OpCode_sqrt Make_OpCode_ESC(26) /* CFF */ +#define OpCode_dup Make_OpCode_ESC(27) /* CFF */ +#define OpCode_exch Make_OpCode_ESC(28) /* CFF */ +#define OpCode_index Make_OpCode_ESC(29) /* CFF */ +#define OpCode_roll Make_OpCode_ESC(30) /* CFF */ +#define OpCode_reservedESC31 Make_OpCode_ESC(31) +#define OpCode_reservedESC32 Make_OpCode_ESC(32) +#define OpCode_reservedESC33 Make_OpCode_ESC(33) +#define OpCode_hflex Make_OpCode_ESC(34) /* CFF, CFF2 */ +#define OpCode_flex Make_OpCode_ESC(35) /* CFF, CFF2 */ +#define OpCode_hflex1 Make_OpCode_ESC(36) /* CFF, CFF2 */ +#define OpCode_flex1 Make_OpCode_ESC(37) /* CFF, CFF2 */ + + +#define OpCode_Invalid 0xFFFFu + + +struct Number +{ + void init () { set_real (0.0); } + void fini () {} + + void set_int (int v) { value = (double) v; } + int to_int () const { return (int) value; } + + void set_fixed (int32_t v) { value = v / 65536.0; } + int32_t to_fixed () const { return (int32_t) (value * 65536.0); } + + void set_real (double v) { value = v; } + double to_real () const { return value; } + + int ceil () const { return (int) ::ceil (value); } + int floor () const { return (int) ::floor (value); } + + bool in_int_range () const + { return ((double) (int16_t) to_int () == value); } + + bool operator > (const Number &n) const + { return value > n.to_real (); } + + bool operator < (const Number &n) const + { return n > *this; } + + bool operator >= (const Number &n) const + { return !(*this < n); } + + bool operator <= (const Number &n) const + { return !(*this > n); } + + const Number &operator += (const Number &n) + { + set_real (to_real () + n.to_real ()); + + return *this; + } + + protected: + double value; +}; + +/* byte string */ +struct UnsizedByteStr : UnsizedArrayOf <HBUINT8> +{ + // encode 2-byte int (Dict/CharString) or 4-byte int (Dict) + template <typename INTTYPE, int minVal, int maxVal> + static bool serialize_int (hb_serialize_context_t *c, OpCode intOp, int value) + { + TRACE_SERIALIZE (this); + + if (unlikely ((value < minVal || value > maxVal))) + return_trace (false); + + HBUINT8 *p = c->allocate_size<HBUINT8> (1); + if (unlikely (p == nullptr)) return_trace (false); + p->set (intOp); + + INTTYPE *ip = c->allocate_size<INTTYPE> (INTTYPE::static_size); + if (unlikely (ip == nullptr)) return_trace (false); + ip->set ((unsigned int)value); + + return_trace (true); + } + + static bool serialize_int4 (hb_serialize_context_t *c, int value) + { return serialize_int<HBUINT32, 0, 0x7FFFFFFF> (c, OpCode_longintdict, value); } + + static bool serialize_int2 (hb_serialize_context_t *c, int value) + { return serialize_int<HBUINT16, 0, 0x7FFF> (c, OpCode_shortint, value); } + + /* Defining null_size allows a Null object may be created. Should be safe because: + * A descendent struct Dict uses a Null pointer to indicate a missing table, + * checked before access. + * ByteStr, a wrapper struct pairing a byte pointer along with its length, always + * checks the length before access. A Null pointer is used as the initial pointer + * along with zero length by the default ctor. + */ + DEFINE_SIZE_MIN(0); +}; + +struct ByteStr +{ + ByteStr () + : str (&Null(UnsizedByteStr)), len (0) {} + ByteStr (const UnsizedByteStr& s, unsigned int l) + : str (&s), len (l) {} + ByteStr (const char *s, unsigned int l=0) + : str ((const UnsizedByteStr *)s), len (l) {} + /* sub-string */ + ByteStr (const ByteStr &bs, unsigned int offset, unsigned int len_) + { + str = (const UnsizedByteStr *)&bs.str[offset]; + len = len_; + } + + bool sanitize (hb_sanitize_context_t *c) const { return str->sanitize (c, len); } + + const HBUINT8& operator [] (unsigned int i) const + { + if (likely (str && (i < len))) + return (*str)[i]; + else + return Null(HBUINT8); + } + + bool serialize (hb_serialize_context_t *c, const ByteStr &src) + { + TRACE_SERIALIZE (this); + HBUINT8 *dest = c->allocate_size<HBUINT8> (src.len); + if (unlikely (dest == nullptr)) + return_trace (false); + memcpy (dest, src.str, src.len); + return_trace (true); + } + + unsigned int get_size () const { return len; } + + bool check_limit (unsigned int offset, unsigned int count) const + { return (offset + count <= len); } + + const UnsizedByteStr *str; + unsigned int len; +}; + +struct SubByteStr +{ + SubByteStr () + { init (); } + + void init () + { + str = ByteStr (0); + offset = 0; + error = false; + } + + void fini () {} + + SubByteStr (const ByteStr &str_, unsigned int offset_ = 0) + : str (str_), offset (offset_), error (false) {} + + void reset (const ByteStr &str_, unsigned int offset_ = 0) + { + str = str_; + offset = offset_; + error = false; + } + + const HBUINT8& operator [] (int i) { + if (unlikely ((unsigned int)(offset + i) >= str.len)) + { + set_error (); + return Null(HBUINT8); + } + else + return str[offset + i]; + } + + operator ByteStr () const { return ByteStr (str, offset, str.len - offset); } + + bool avail (unsigned int count=1) const + { + return (!in_error () && str.check_limit (offset, count)); + } + void inc (unsigned int count=1) + { + if (likely (!in_error () && (offset <= str.len) && (offset + count <= str.len))) + { + offset += count; + } + else + { + offset = str.len; + set_error (); + } + } + + void set_error () { error = true; } + bool in_error () const { return error; } + + ByteStr str; + unsigned int offset; /* beginning of the sub-string within str */ + + protected: + bool error; +}; + +typedef hb_vector_t<ByteStr> ByteStrArray; + +/* stack */ +template <typename ELEM, int LIMIT> +struct Stack +{ + void init () + { + error = false; + count = 0; + elements.init (); + elements.resize (kSizeLimit); + for (unsigned int i = 0; i < elements.len; i++) + elements[i].init (); + } + + void fini () + { + elements.fini_deep (); + } + + ELEM& operator [] (unsigned int i) + { + if (unlikely (i >= count)) set_error (); + return elements[i]; + } + + void push (const ELEM &v) + { + if (likely (count < elements.len)) + elements[count++] = v; + else + set_error (); + } + + ELEM &push () + { + if (likely (count < elements.len)) + return elements[count++]; + else + { + set_error (); + return Crap(ELEM); + } + } + + ELEM& pop () + { + if (likely (count > 0)) + return elements[--count]; + else + { + set_error (); + return Crap(ELEM); + } + } + + void pop (unsigned int n) + { + if (likely (count >= n)) + count -= n; + else + set_error (); + } + + const ELEM& peek () + { + if (likely (count > 0)) + return elements[count-1]; + else + { + set_error (); + return Null(ELEM); + } + } + + void unpop () + { + if (likely (count < elements.len)) + count++; + else + set_error (); + } + + void clear () { count = 0; } + + bool in_error () const { return (error || elements.in_error ()); } + void set_error () { error = true; } + + unsigned int get_count () const { return count; } + bool is_empty () const { return count == 0; } + + static const unsigned int kSizeLimit = LIMIT; + + protected: + bool error; + unsigned int count; + hb_vector_t<ELEM, kSizeLimit> elements; +}; + +/* argument stack */ +template <typename ARG=Number> +struct ArgStack : Stack<ARG, 513> +{ + void push_int (int v) + { + ARG &n = S::push (); + n.set_int (v); + } + + void push_fixed (int32_t v) + { + ARG &n = S::push (); + n.set_fixed (v); + } + + void push_real (double v) + { + ARG &n = S::push (); + n.set_real (v); + } + + ARG& pop_num () { return this->pop (); } + + int pop_int () { return this->pop ().to_int (); } + + unsigned int pop_uint () + { + int i = pop_int (); + if (unlikely (i < 0)) + { + i = 0; + S::set_error (); + } + return (unsigned)i; + } + + void push_longint_from_substr (SubByteStr& substr) + { + push_int ((substr[0] << 24) | (substr[1] << 16) | (substr[2] << 8) | (substr[3])); + substr.inc (4); + } + + bool push_fixed_from_substr (SubByteStr& substr) + { + if (unlikely (!substr.avail (4))) + return false; + push_fixed ((int32_t)*(const HBUINT32*)&substr[0]); + substr.inc (4); + return true; + } + + hb_array_t<const ARG> get_subarray (unsigned int start) const + { + return S::elements.sub_array (start); + } + + private: + typedef Stack<ARG, 513> S; +}; + +/* an operator prefixed by its operands in a byte string */ +struct OpStr +{ + void init () {} + void fini () {} + + OpCode op; + ByteStr str; +}; + +/* base of OP_SERIALIZER */ +struct OpSerializer +{ + protected: + bool copy_opstr (hb_serialize_context_t *c, const OpStr& opstr) const + { + TRACE_SERIALIZE (this); + + HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len); + if (unlikely (d == nullptr)) return_trace (false); + memcpy (d, &opstr.str.str[0], opstr.str.len); + return_trace (true); + } +}; + +template <typename VAL> +struct ParsedValues +{ + void init () + { + opStart = 0; + values.init (); + } + void fini () { values.fini_deep (); } + + void add_op (OpCode op, const SubByteStr& substr = SubByteStr ()) + { + VAL *val = values.push (); + val->op = op; + val->str = ByteStr (substr.str, opStart, substr.offset - opStart); + opStart = substr.offset; + } + + void add_op (OpCode op, const SubByteStr& substr, const VAL &v) + { + VAL *val = values.push (v); + val->op = op; + val->str = ByteStr (substr.str, opStart, substr.offset - opStart); + opStart = substr.offset; + } + + bool has_op (OpCode op) const + { + for (unsigned int i = 0; i < get_count (); i++) + if (get_value (i).op == op) return true; + return false; + } + + unsigned get_count () const { return values.len; } + const VAL &get_value (unsigned int i) const { return values[i]; } + const VAL &operator [] (unsigned int i) const { return get_value (i); } + + unsigned int opStart; + hb_vector_t<VAL> values; +}; + +template <typename ARG=Number> +struct InterpEnv +{ + void init (const ByteStr &str_) + { + substr.reset (str_); + argStack.init (); + error = false; + } + void fini () { argStack.fini (); } + + bool in_error () const + { return error || substr.in_error () || argStack.in_error (); } + + void set_error () { error = true; } + + OpCode fetch_op () + { + OpCode op = OpCode_Invalid; + if (unlikely (!substr.avail ())) + return OpCode_Invalid; + op = (OpCode)(unsigned char)substr[0]; + if (op == OpCode_escape) { + if (unlikely (!substr.avail ())) + return OpCode_Invalid; + op = Make_OpCode_ESC(substr[1]); + substr.inc (); + } + substr.inc (); + return op; + } + + const ARG& eval_arg (unsigned int i) + { + return argStack[i]; + } + + ARG& pop_arg () + { + return argStack.pop (); + } + + void pop_n_args (unsigned int n) + { + argStack.pop (n); + } + + void clear_args () + { + pop_n_args (argStack.get_count ()); + } + + SubByteStr substr; + ArgStack<ARG> argStack; + protected: + bool error; +}; + +typedef InterpEnv<> NumInterpEnv; + +template <typename ARG=Number> +struct OpSet +{ + static void process_op (OpCode op, InterpEnv<ARG>& env) + { + switch (op) { + case OpCode_shortint: + env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1])); + env.substr.inc (2); + break; + + case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1: + case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: + env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108)); + env.substr.inc (); + break; + + case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: + case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: + env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108)); + env.substr.inc (); + break; + + default: + /* 1-byte integer */ + if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast))) + { + env.argStack.push_int ((int)op - 139); + } else { + /* invalid unknown operator */ + env.clear_args (); + env.set_error (); + } + break; + } + } +}; + +template <typename ENV> +struct Interpreter { + + ~Interpreter() { fini (); } + + void fini () { env.fini (); } + + ENV env; +}; + +} /* namespace CFF */ + +#endif /* HB_CFF_INTERP_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-cs-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-cs-common.hh new file mode 100644 index 00000000000..e78d5571c94 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-cs-common.hh @@ -0,0 +1,904 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_CFF_INTERP_CS_COMMON_HH +#define HB_CFF_INTERP_CS_COMMON_HH + +#include "hb.hh" +#include "hb-cff-interp-common.hh" + +namespace CFF { + +using namespace OT; + +enum CSType { + CSType_CharString, + CSType_GlobalSubr, + CSType_LocalSubr +}; + +struct CallContext +{ + void init (const SubByteStr substr_=SubByteStr (), CSType type_=CSType_CharString, unsigned int subr_num_=0) + { + substr = substr_; + type = type_; + subr_num = subr_num_; + } + + void fini () {} + + SubByteStr substr; + CSType type; + unsigned int subr_num; +}; + +/* call stack */ +const unsigned int kMaxCallLimit = 10; +struct CallStack : Stack<CallContext, kMaxCallLimit> {}; + +template <typename SUBRS> +struct BiasedSubrs +{ + void init (const SUBRS &subrs_) + { + subrs = &subrs_; + unsigned int nSubrs = get_count (); + if (nSubrs < 1240) + bias = 107; + else if (nSubrs < 33900) + bias = 1131; + else + bias = 32768; + } + + void fini () {} + + unsigned int get_count () const { return (subrs == nullptr)? 0: subrs->count; } + unsigned int get_bias () const { return bias; } + + ByteStr operator [] (unsigned int index) const + { + if (unlikely ((subrs == nullptr) || index >= subrs->count)) + return Null(ByteStr); + else + return (*subrs)[index]; + } + + protected: + unsigned int bias; + const SUBRS *subrs; +}; + +struct Point +{ + void init () + { + x.init (); + y.init (); + } + + void set_int (int _x, int _y) + { + x.set_int (_x); + y.set_int (_y); + } + + void move_x (const Number &dx) { x += dx; } + void move_y (const Number &dy) { y += dy; } + void move (const Number &dx, const Number &dy) { move_x (dx); move_y (dy); } + void move (const Point &d) { move_x (d.x); move_y (d.y); } + + Number x; + Number y; +}; + +template <typename ARG, typename SUBRS> +struct CSInterpEnv : InterpEnv<ARG> +{ + void init (const ByteStr &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_) + { + InterpEnv<ARG>::init (str); + + context.init (str, CSType_CharString); + seen_moveto = true; + seen_hintmask = false; + hstem_count = 0; + vstem_count = 0; + pt.init (); + callStack.init (); + globalSubrs.init (globalSubrs_); + localSubrs.init (localSubrs_); + } + void fini () + { + InterpEnv<ARG>::fini (); + + callStack.fini (); + globalSubrs.fini (); + localSubrs.fini (); + } + + bool in_error () const + { + return callStack.in_error () || SUPER::in_error (); + } + + bool popSubrNum (const BiasedSubrs<SUBRS>& biasedSubrs, unsigned int &subr_num) + { + int n = SUPER::argStack.pop_int (); + n += biasedSubrs.get_bias (); + if (unlikely ((n < 0) || ((unsigned int)n >= biasedSubrs.get_count ()))) + return false; + + subr_num = (unsigned int)n; + return true; + } + + void callSubr (const BiasedSubrs<SUBRS>& biasedSubrs, CSType type) + { + unsigned int subr_num; + + if (unlikely (!popSubrNum (biasedSubrs, subr_num) + || callStack.get_count () >= kMaxCallLimit)) + { + SUPER::set_error (); + return; + } + context.substr = SUPER::substr; + callStack.push (context); + + context.init ( biasedSubrs[subr_num], type, subr_num); + SUPER::substr = context.substr; + } + + void returnFromSubr () + { + if (unlikely (SUPER::substr.in_error ())) + SUPER::set_error (); + context = callStack.pop (); + SUPER::substr = context.substr; + } + + void determine_hintmask_size () + { + if (!seen_hintmask) + { + vstem_count += SUPER::argStack.get_count() / 2; + hintmask_size = (hstem_count + vstem_count + 7) >> 3; + seen_hintmask = true; + } + } + + void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; } + bool is_endchar () const { return endchar_flag; } + + const Number &get_x () const { return pt.x; } + const Number &get_y () const { return pt.y; } + const Point &get_pt () const { return pt; } + + void moveto (const Point &pt_ ) { pt = pt_; } + + public: + CallContext context; + bool endchar_flag; + bool seen_moveto; + bool seen_hintmask; + + unsigned int hstem_count; + unsigned int vstem_count; + unsigned int hintmask_size; + CallStack callStack; + BiasedSubrs<SUBRS> globalSubrs; + BiasedSubrs<SUBRS> localSubrs; + + private: + Point pt; + + typedef InterpEnv<ARG> SUPER; +}; + +template <typename ENV, typename PARAM> +struct PathProcsNull +{ + static void rmoveto (ENV &env, PARAM& param) {} + static void hmoveto (ENV &env, PARAM& param) {} + static void vmoveto (ENV &env, PARAM& param) {} + static void rlineto (ENV &env, PARAM& param) {} + static void hlineto (ENV &env, PARAM& param) {} + static void vlineto (ENV &env, PARAM& param) {} + static void rrcurveto (ENV &env, PARAM& param) {} + static void rcurveline (ENV &env, PARAM& param) {} + static void rlinecurve (ENV &env, PARAM& param) {} + static void vvcurveto (ENV &env, PARAM& param) {} + static void hhcurveto (ENV &env, PARAM& param) {} + static void vhcurveto (ENV &env, PARAM& param) {} + static void hvcurveto (ENV &env, PARAM& param) {} + static void moveto (ENV &env, PARAM& param, const Point &pt) {} + static void line (ENV &env, PARAM& param, const Point &pt1) {} + static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3) {} + static void hflex (ENV &env, PARAM& param) {} + static void flex (ENV &env, PARAM& param) {} + static void hflex1 (ENV &env, PARAM& param) {} + static void flex1 (ENV &env, PARAM& param) {} +}; + +template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=PathProcsNull<ENV, PARAM> > +struct CSOpSet : OpSet<ARG> +{ + static void process_op (OpCode op, ENV &env, PARAM& param) + { + switch (op) { + + case OpCode_return: + env.returnFromSubr (); + break; + case OpCode_endchar: + OPSET::check_width (op, env, param); + env.set_endchar (true); + OPSET::flush_args_and_op (op, env, param); + break; + + case OpCode_fixedcs: + env.argStack.push_fixed_from_substr (env.substr); + break; + + case OpCode_callsubr: + env.callSubr (env.localSubrs, CSType_LocalSubr); + break; + + case OpCode_callgsubr: + env.callSubr (env.globalSubrs, CSType_GlobalSubr); + break; + + case OpCode_hstem: + case OpCode_hstemhm: + OPSET::check_width (op, env, param); + OPSET::process_hstem (op, env, param); + break; + case OpCode_vstem: + case OpCode_vstemhm: + OPSET::check_width (op, env, param); + OPSET::process_vstem (op, env, param); + break; + case OpCode_hintmask: + case OpCode_cntrmask: + OPSET::check_width (op, env, param); + OPSET::process_hintmask (op, env, param); + break; + case OpCode_rmoveto: + OPSET::check_width (op, env, param); + PATH::rmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; + case OpCode_hmoveto: + OPSET::check_width (op, env, param); + PATH::hmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; + case OpCode_vmoveto: + OPSET::check_width (op, env, param); + PATH::vmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; + case OpCode_rlineto: + PATH::rlineto (env, param); + process_post_path (op, env, param); + break; + case OpCode_hlineto: + PATH::hlineto (env, param); + process_post_path (op, env, param); + break; + case OpCode_vlineto: + PATH::vlineto (env, param); + process_post_path (op, env, param); + break; + case OpCode_rrcurveto: + PATH::rrcurveto (env, param); + process_post_path (op, env, param); + break; + case OpCode_rcurveline: + PATH::rcurveline (env, param); + process_post_path (op, env, param); + break; + case OpCode_rlinecurve: + PATH::rlinecurve (env, param); + process_post_path (op, env, param); + break; + case OpCode_vvcurveto: + PATH::vvcurveto (env, param); + process_post_path (op, env, param); + break; + case OpCode_hhcurveto: + PATH::hhcurveto (env, param); + process_post_path (op, env, param); + break; + case OpCode_vhcurveto: + PATH::vhcurveto (env, param); + process_post_path (op, env, param); + break; + case OpCode_hvcurveto: + PATH::hvcurveto (env, param); + process_post_path (op, env, param); + break; + + case OpCode_hflex: + PATH::hflex (env, param); + OPSET::process_post_flex (op, env, param); + break; + + case OpCode_flex: + PATH::flex (env, param); + OPSET::process_post_flex (op, env, param); + break; + + case OpCode_hflex1: + PATH::hflex1 (env, param); + OPSET::process_post_flex (op, env, param); + break; + + case OpCode_flex1: + PATH::flex1 (env, param); + OPSET::process_post_flex (op, env, param); + break; + + default: + SUPER::process_op (op, env); + break; + } + } + + static void process_hstem (OpCode op, ENV &env, PARAM& param) + { + env.hstem_count += env.argStack.get_count () / 2; + OPSET::flush_args_and_op (op, env, param); + } + + static void process_vstem (OpCode op, ENV &env, PARAM& param) + { + env.vstem_count += env.argStack.get_count () / 2; + OPSET::flush_args_and_op (op, env, param); + } + + static void process_hintmask (OpCode op, ENV &env, PARAM& param) + { + env.determine_hintmask_size (); + if (likely (env.substr.avail (env.hintmask_size))) + { + OPSET::flush_hintmask (op, env, param); + env.substr.inc (env.hintmask_size); + } + } + + static void process_post_flex (OpCode op, ENV &env, PARAM& param) + { + OPSET::flush_args_and_op (op, env, param); + } + + static void check_width (OpCode op, ENV &env, PARAM& param) + {} + + static void process_post_move (OpCode op, ENV &env, PARAM& param) + { + if (!env.seen_moveto) + { + env.determine_hintmask_size (); + env.seen_moveto = true; + } + OPSET::flush_args_and_op (op, env, param); + } + + static void process_post_path (OpCode op, ENV &env, PARAM& param) + { + OPSET::flush_args_and_op (op, env, param); + } + + static void flush_args_and_op (OpCode op, ENV &env, PARAM& param) + { + OPSET::flush_args (env, param); + OPSET::flush_op (op, env, param); + } + + static void flush_args (ENV &env, PARAM& param) + { + env.pop_n_args (env.argStack.get_count ()); + } + + static void flush_op (OpCode op, ENV &env, PARAM& param) + { + } + + static void flush_hintmask (OpCode op, ENV &env, PARAM& param) + { + OPSET::flush_args_and_op (op, env, param); + } + + static bool is_number_op (OpCode op) + { + switch (op) + { + case OpCode_shortint: + case OpCode_fixedcs: + case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1: + case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: + case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: + case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: + return true; + + default: + /* 1-byte integer */ + return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast); + } + } + + protected: + typedef OpSet<ARG> SUPER; +}; + +template <typename PATH, typename ENV, typename PARAM> +struct PathProcs +{ + static void rmoveto (ENV &env, PARAM& param) + { + Point pt1 = env.get_pt (); + const Number &dy = env.pop_arg (); + const Number &dx = env.pop_arg (); + pt1.move (dx, dy); + PATH::moveto (env, param, pt1); + } + + static void hmoveto (ENV &env, PARAM& param) + { + Point pt1 = env.get_pt (); + pt1.move_x (env.pop_arg ()); + PATH::moveto (env, param, pt1); + } + + static void vmoveto (ENV &env, PARAM& param) + { + Point pt1 = env.get_pt (); + pt1.move_y (env.pop_arg ()); + PATH::moveto (env, param, pt1); + } + + static void rlineto (ENV &env, PARAM& param) + { + for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + PATH::line (env, param, pt1); + } + } + + static void hlineto (ENV &env, PARAM& param) + { + Point pt1; + unsigned int i = 0; + for (; i + 2 <= env.argStack.get_count (); i += 2) + { + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + PATH::line (env, param, pt1); + pt1.move_y (env.eval_arg (i+1)); + PATH::line (env, param, pt1); + } + if (i < env.argStack.get_count ()) + { + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + PATH::line (env, param, pt1); + } + } + + static void vlineto (ENV &env, PARAM& param) + { + Point pt1; + unsigned int i = 0; + for (; i + 2 <= env.argStack.get_count (); i += 2) + { + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + PATH::line (env, param, pt1); + pt1.move_x (env.eval_arg (i+1)); + PATH::line (env, param, pt1); + } + if (i < env.argStack.get_count ()) + { + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + PATH::line (env, param, pt1); + } + } + + static void rrcurveto (ENV &env, PARAM& param) + { + for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); + Point pt3 = pt2; + pt3.move (env.eval_arg (i+4), env.eval_arg (i+5)); + PATH::curve (env, param, pt1, pt2, pt3); + } + } + + static void rcurveline (ENV &env, PARAM& param) + { + unsigned int i = 0; + for (; i + 6 <= env.argStack.get_count (); i += 6) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); + Point pt3 = pt2; + pt3.move (env.eval_arg (i+4), env.eval_arg (i+5)); + PATH::curve (env, param, pt1, pt2, pt3); + } + for (; i + 2 <= env.argStack.get_count (); i += 2) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + PATH::line (env, param, pt1); + } + } + + static void rlinecurve (ENV &env, PARAM& param) + { + unsigned int i = 0; + unsigned int line_limit = (env.argStack.get_count () % 6); + for (; i + 2 <= line_limit; i += 2) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + PATH::line (env, param, pt1); + } + for (; i + 6 <= env.argStack.get_count (); i += 6) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (i), env.eval_arg (i+1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); + Point pt3 = pt2; + pt3.move (env.eval_arg (i+4), env.eval_arg (i+5)); + PATH::curve (env, param, pt1, pt2, pt3); + } + } + + static void vvcurveto (ENV &env, PARAM& param) + { + unsigned int i = 0; + Point pt1 = env.get_pt (); + if ((env.argStack.get_count () & 1) != 0) + pt1.move_x (env.eval_arg (i++)); + for (; i + 4 <= env.argStack.get_count (); i += 4) + { + pt1.move_y (env.eval_arg (i)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + Point pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + } + } + + static void hhcurveto (ENV &env, PARAM& param) + { + unsigned int i = 0; + Point pt1 = env.get_pt (); + if ((env.argStack.get_count () & 1) != 0) + pt1.move_y (env.eval_arg (i++)); + for (; i + 4 <= env.argStack.get_count (); i += 4) + { + pt1.move_x (env.eval_arg (i)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + Point pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + } + } + + static void vhcurveto (ENV &env, PARAM& param) + { + Point pt1, pt2, pt3; + unsigned int i = 0; + if ((env.argStack.get_count () % 8) >= 4) + { + Point pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + Point pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + i += 4; + + for (; i + 8 <= env.argStack.get_count (); i += 8) + { + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + + pt1 = pt3; + pt1.move_y (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+7)); + } + if (i < env.argStack.get_count ()) + pt3.move_y (env.eval_arg (i)); + PATH::curve (env, param, pt1, pt2, pt3); + } + else + { + for (; i + 8 <= env.argStack.get_count (); i += 8) + { + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + + pt1 = pt3; + pt1.move_x (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+7)); + if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) + pt3.move_x (env.eval_arg (i+8)); + PATH::curve (env, param, pt1, pt2, pt3); + } + } + } + + static void hvcurveto (ENV &env, PARAM& param) + { + Point pt1, pt2, pt3; + unsigned int i = 0; + if ((env.argStack.get_count () % 8) >= 4) + { + Point pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + Point pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + Point pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + i += 4; + + for (; i + 8 <= env.argStack.get_count (); i += 8) + { + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + + pt1 = pt3; + pt1.move_x (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+7)); + } + if (i < env.argStack.get_count ()) + pt3.move_x (env.eval_arg (i)); + PATH::curve (env, param, pt1, pt2, pt3); + } + else + { + for (; i + 8 <= env.argStack.get_count (); i += 8) + { + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); + + pt1 = pt3; + pt1.move_y (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+7)); + if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) + pt3.move_y (env.eval_arg (i+8)); + PATH::curve (env, param, pt1, pt2, pt3); + } + } + } + + /* default actions to be overridden */ + static void moveto (ENV &env, PARAM& param, const Point &pt) + { env.moveto (pt); } + + static void line (ENV &env, PARAM& param, const Point &pt1) + { PATH::moveto (env, param, pt1); } + + static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3) + { PATH::moveto (env, param, pt3); } + + static void hflex (ENV &env, PARAM& param) + { + if (likely (env.argStack.get_count () == 7)) + { + Point pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (0)); + Point pt2 = pt1; + pt2.move (env.eval_arg (1), env.eval_arg (2)); + Point pt3 = pt2; + pt3.move_x (env.eval_arg (3)); + Point pt4 = pt3; + pt4.move_x (env.eval_arg (4)); + Point pt5 = pt4; + pt5.move_x (env.eval_arg (5)); + pt5.y = pt1.y; + Point pt6 = pt5; + pt6.move_x (env.eval_arg (6)); + + curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); + } + else + env.set_error (); + } + + static void flex (ENV &env, PARAM& param) + { + if (likely (env.argStack.get_count () == 13)) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (0), env.eval_arg (1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (2), env.eval_arg (3)); + Point pt3 = pt2; + pt3.move (env.eval_arg (4), env.eval_arg (5)); + Point pt4 = pt3; + pt4.move (env.eval_arg (6), env.eval_arg (7)); + Point pt5 = pt4; + pt5.move (env.eval_arg (8), env.eval_arg (9)); + Point pt6 = pt5; + pt6.move (env.eval_arg (10), env.eval_arg (11)); + + curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); + } + else + env.set_error (); + } + + static void hflex1 (ENV &env, PARAM& param) + { + if (likely (env.argStack.get_count () == 9)) + { + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (0), env.eval_arg (1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (2), env.eval_arg (3)); + Point pt3 = pt2; + pt3.move_x (env.eval_arg (4)); + Point pt4 = pt3; + pt4.move_x (env.eval_arg (5)); + Point pt5 = pt4; + pt5.move (env.eval_arg (6), env.eval_arg (7)); + Point pt6 = pt5; + pt6.move_x (env.eval_arg (8)); + pt6.y = env.get_pt ().y; + + curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); + } + else + env.set_error (); + } + + static void flex1 (ENV &env, PARAM& param) + { + if (likely (env.argStack.get_count () == 11)) + { + Point d; + d.init (); + for (unsigned int i = 0; i < 10; i += 2) + d.move (env.eval_arg (i), env.eval_arg (i+1)); + + Point pt1 = env.get_pt (); + pt1.move (env.eval_arg (0), env.eval_arg (1)); + Point pt2 = pt1; + pt2.move (env.eval_arg (2), env.eval_arg (3)); + Point pt3 = pt2; + pt3.move (env.eval_arg (4), env.eval_arg (5)); + Point pt4 = pt3; + pt4.move (env.eval_arg (6), env.eval_arg (7)); + Point pt5 = pt4; + pt5.move (env.eval_arg (8), env.eval_arg (9)); + Point pt6 = pt5; + + if (fabs (d.x.to_real ()) > fabs (d.y.to_real ())) + { + pt6.move_x (env.eval_arg (10)); + pt6.y = env.get_pt ().y; + } + else + { + pt6.x = env.get_pt ().x; + pt6.move_y (env.eval_arg (10)); + } + + curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); + } + else + env.set_error (); + } + + protected: + static void curve2 (ENV &env, PARAM& param, + const Point &pt1, const Point &pt2, const Point &pt3, + const Point &pt4, const Point &pt5, const Point &pt6) + { + PATH::curve (env, param, pt1, pt2, pt3); + PATH::curve (env, param, pt4, pt5, pt6); + } +}; + +template <typename ENV, typename OPSET, typename PARAM> +struct CSInterpreter : Interpreter<ENV> +{ + bool interpret (PARAM& param) + { + SUPER::env.set_endchar (false); + + for (;;) { + OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); + if (unlikely (SUPER::env.in_error ())) + return false; + if (SUPER::env.is_endchar ()) + break; + } + + return true; + } + + private: + typedef Interpreter<ENV> SUPER; +}; + +} /* namespace CFF */ + +#endif /* HB_CFF_INTERP_CS_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-dict-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-dict-common.hh new file mode 100644 index 00000000000..8000d76b8bd --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-dict-common.hh @@ -0,0 +1,294 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_CFF_INTERP_DICT_COMMON_HH +#define HB_CFF_INTERP_DICT_COMMON_HH + +#include "hb-cff-interp-common.hh" +#include <math.h> +#include <float.h> + +namespace CFF { + +using namespace OT; + +/* an opstr and the parsed out dict value(s) */ +struct DictVal : OpStr +{ + void init () { single_val.set_int (0); } + void fini () {} + + Number single_val; +}; + +typedef DictVal NumDictVal; + +template <typename VAL> struct DictValues : ParsedValues<VAL> {}; + +template <typename OPSTR=OpStr> +struct TopDictValues : DictValues<OPSTR> +{ + void init () + { + DictValues<OPSTR>::init (); + charStringsOffset = 0; + FDArrayOffset = 0; + } + void fini () { DictValues<OPSTR>::fini (); } + + unsigned int calculate_serialized_op_size (const OPSTR& opstr) const + { + switch (opstr.op) + { + case OpCode_CharStrings: + case OpCode_FDArray: + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + + default: + return opstr.str.len; + } + } + + unsigned int charStringsOffset; + unsigned int FDArrayOffset; +}; + +struct DictOpSet : OpSet<Number> +{ + static void process_op (OpCode op, InterpEnv<Number>& env) + { + switch (op) { + case OpCode_longintdict: /* 5-byte integer */ + env.argStack.push_longint_from_substr (env.substr); + break; + + case OpCode_BCD: /* real number */ + env.argStack.push_real (parse_bcd (env.substr)); + break; + + default: + OpSet<Number>::process_op (op, env); + break; + } + } + + static double parse_bcd (SubByteStr& substr) + { + bool neg = false; + double int_part = 0; + uint64_t frac_part = 0; + uint32_t frac_count = 0; + bool exp_neg = false; + uint32_t exp_part = 0; + bool exp_overflow = false; + enum Part { INT_PART=0, FRAC_PART, EXP_PART } part = INT_PART; + enum Nibble { DECIMAL=10, EXP_POS, EXP_NEG, RESERVED, NEG, END }; + const uint64_t MAX_FRACT = 0xFFFFFFFFFFFFFull; /* 1^52-1 */ + const uint32_t MAX_EXP = 0x7FFu; /* 1^11-1 */ + + double value = 0.0; + unsigned char byte = 0; + for (uint32_t i = 0;; i++) + { + char d; + if ((i & 1) == 0) + { + if (!substr.avail ()) + { + substr.set_error (); + return 0.0; + } + byte = substr[0]; + substr.inc (); + d = byte >> 4; + } + else + d = byte & 0x0F; + + switch (d) + { + case RESERVED: + substr.set_error (); + return value; + + case END: + value = (double)(neg? -int_part: int_part); + if (frac_count > 0) + { + double frac = (frac_part / pow (10.0, (double)frac_count)); + if (neg) frac = -frac; + value += frac; + } + if (unlikely (exp_overflow)) + { + if (value == 0.0) + return value; + if (exp_neg) + return neg? -DBL_MIN: DBL_MIN; + else + return neg? -DBL_MAX: DBL_MAX; + } + if (exp_part != 0) + { + if (exp_neg) + value /= pow (10.0, (double)exp_part); + else + value *= pow (10.0, (double)exp_part); + } + return value; + + case NEG: + if (i != 0) + { + substr.set_error (); + return 0.0; + } + neg = true; + break; + + case DECIMAL: + if (part != INT_PART) + { + substr.set_error (); + return value; + } + part = FRAC_PART; + break; + + case EXP_NEG: + exp_neg = true; + HB_FALLTHROUGH; + + case EXP_POS: + if (part == EXP_PART) + { + substr.set_error (); + return value; + } + part = EXP_PART; + break; + + default: + switch (part) { + default: + case INT_PART: + int_part = (int_part * 10) + d; + break; + + case FRAC_PART: + if (likely (frac_part <= MAX_FRACT / 10)) + { + frac_part = (frac_part * 10) + (unsigned)d; + frac_count++; + } + break; + + case EXP_PART: + if (likely (exp_part * 10 + d <= MAX_EXP)) + { + exp_part = (exp_part * 10) + d; + } + else + exp_overflow = true; + break; + } + } + } + + return value; + } + + static bool is_hint_op (OpCode op) + { + switch (op) + { + case OpCode_BlueValues: + case OpCode_OtherBlues: + case OpCode_FamilyBlues: + case OpCode_FamilyOtherBlues: + case OpCode_StemSnapH: + case OpCode_StemSnapV: + case OpCode_StdHW: + case OpCode_StdVW: + case OpCode_BlueScale: + case OpCode_BlueShift: + case OpCode_BlueFuzz: + case OpCode_ForceBold: + case OpCode_LanguageGroup: + case OpCode_ExpansionFactor: + return true; + default: + return false; + } + } +}; + +template <typename VAL=OpStr> +struct TopDictOpSet : DictOpSet +{ + static void process_op (OpCode op, InterpEnv<Number>& env, TopDictValues<VAL> & dictval) + { + switch (op) { + case OpCode_CharStrings: + dictval.charStringsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_FDArray: + dictval.FDArrayOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_FontMatrix: + env.clear_args (); + break; + default: + DictOpSet::process_op (op, env); + break; + } + } +}; + +template <typename OPSET, typename PARAM, typename ENV=NumInterpEnv> +struct DictInterpreter : Interpreter<ENV> +{ + bool interpret (PARAM& param) + { + param.init (); + while (SUPER::env.substr.avail ()) + { + OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); + if (unlikely (SUPER::env.in_error ())) + return false; + } + + return true; + } + + private: + typedef Interpreter<ENV> SUPER; +}; + +} /* namespace CFF */ + +#endif /* HB_CFF_INTERP_DICT_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff1-interp-cs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff1-interp-cs.hh new file mode 100644 index 00000000000..68e1d81d762 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff1-interp-cs.hh @@ -0,0 +1,161 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_CFF1_INTERP_CS_HH +#define HB_CFF1_INTERP_CS_HH + +#include "hb.hh" +#include "hb-cff-interp-cs-common.hh" + +namespace CFF { + +using namespace OT; + +typedef BiasedSubrs<CFF1Subrs> CFF1BiasedSubrs; + +struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs> +{ + template <typename ACC> + void init (const ByteStr &str, ACC &acc, unsigned int fd) + { + SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); + processed_width = false; + has_width = false; + arg_start = 0; + in_seac = false; + } + + void fini () { SUPER::fini (); } + + void set_width (bool has_width_) + { + if (likely (!processed_width && (SUPER::argStack.get_count () > 0))) + { + if (has_width_) + { + width = SUPER::argStack[0]; + has_width = true; + arg_start = 1; + } + } + processed_width = true; + } + + void clear_args () + { + arg_start = 0; + SUPER::clear_args (); + } + + void set_in_seac (bool _in_seac) { in_seac = _in_seac; } + + bool processed_width; + bool has_width; + unsigned int arg_start; + Number width; + bool in_seac; + + private: + typedef CSInterpEnv<Number, CFF1Subrs> SUPER; +}; + +template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF1CSInterpEnv, PARAM> > +struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH> +{ + /* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */ + /* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */ + + static void process_op (OpCode op, CFF1CSInterpEnv &env, PARAM& param) + { + switch (op) { + case OpCode_dotsection: + SUPER::flush_args_and_op (op, env, param); + break; + + case OpCode_endchar: + OPSET::check_width (op, env, param); + if (env.argStack.get_count () >= 4) + { + OPSET::process_seac (env, param); + } + OPSET::flush_args_and_op (op, env, param); + env.set_endchar (true); + break; + + default: + SUPER::process_op (op, env, param); + } + } + + static void check_width (OpCode op, CFF1CSInterpEnv &env, PARAM& param) + { + if (!env.processed_width) + { + bool has_width = false; + switch (op) + { + case OpCode_endchar: + case OpCode_hstem: + case OpCode_hstemhm: + case OpCode_vstem: + case OpCode_vstemhm: + case OpCode_hintmask: + case OpCode_cntrmask: + has_width = ((env.argStack.get_count () & 1) != 0); + break; + case OpCode_hmoveto: + case OpCode_vmoveto: + has_width = (env.argStack.get_count () > 1); + break; + case OpCode_rmoveto: + has_width = (env.argStack.get_count () > 2); + break; + default: + return; + } + env.set_width (has_width); + } + } + + static void process_seac (CFF1CSInterpEnv &env, PARAM& param) + { + } + + static void flush_args (CFF1CSInterpEnv &env, PARAM& param) + { + SUPER::flush_args (env, param); + env.clear_args (); /* pop off width */ + } + + private: + typedef CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH> SUPER; +}; + +template <typename OPSET, typename PARAM> +struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {}; + +} /* namespace CFF */ + +#endif /* HB_CFF1_INTERP_CS_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff2-interp-cs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff2-interp-cs.hh new file mode 100644 index 00000000000..709bdefa1dc --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff2-interp-cs.hh @@ -0,0 +1,271 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_CFF2_INTERP_CS_HH +#define HB_CFF2_INTERP_CS_HH + +#include "hb.hh" +#include "hb-cff-interp-cs-common.hh" + +namespace CFF { + +using namespace OT; + +struct BlendArg : Number +{ + void init () + { + Number::init (); + deltas.init (); + } + + void fini () + { + Number::fini (); + deltas.fini_deep (); + } + + void set_int (int v) { reset_blends (); Number::set_int (v); } + void set_fixed (int32_t v) { reset_blends (); Number::set_fixed (v); } + void set_real (double v) { reset_blends (); Number::set_real (v); } + + void set_blends (unsigned int numValues_, unsigned int valueIndex_, + unsigned int numBlends, hb_array_t<const BlendArg> blends_) + { + numValues = numValues_; + valueIndex = valueIndex_; + deltas.resize (numBlends); + for (unsigned int i = 0; i < numBlends; i++) + deltas[i] = blends_[i]; + } + + bool blending () const { return deltas.len > 0; } + void reset_blends () + { + numValues = valueIndex = 0; + deltas.resize (0); + } + + unsigned int numValues; + unsigned int valueIndex; + hb_vector_t<Number> deltas; +}; + +typedef InterpEnv<BlendArg> BlendInterpEnv; +typedef BiasedSubrs<CFF2Subrs> CFF2BiasedSubrs; + +struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs> +{ + template <typename ACC> + void init (const ByteStr &str, ACC &acc, unsigned int fd, + const int *coords_=nullptr, unsigned int num_coords_=0) + { + SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); + + coords = coords_; + num_coords = num_coords_; + varStore = acc.varStore; + seen_blend = false; + seen_vsindex_ = false; + scalars.init (); + do_blend = (coords != nullptr) && num_coords && (varStore != &Null(CFF2VariationStore)); + set_ivs (acc.privateDicts[fd].ivs); + } + + void fini () + { + scalars.fini (); + SUPER::fini (); + } + + OpCode fetch_op () + { + if (this->substr.avail ()) + return SUPER::fetch_op (); + + /* make up return or endchar op */ + if (this->callStack.is_empty ()) + return OpCode_endchar; + else + return OpCode_return; + } + + const BlendArg& eval_arg (unsigned int i) + { + BlendArg &arg = argStack[i]; + blend_arg (arg); + return arg; + } + + const BlendArg& pop_arg () + { + BlendArg &arg = argStack.pop (); + blend_arg (arg); + return arg; + } + + void process_blend () + { + if (!seen_blend) + { + region_count = varStore->varStore.get_region_index_count (get_ivs ()); + if (do_blend) + { + scalars.resize (region_count); + varStore->varStore.get_scalars (get_ivs (), + (int *)coords, num_coords, + &scalars[0], region_count); + } + seen_blend = true; + } + } + + void process_vsindex () + { + unsigned int index = argStack.pop_uint (); + if (unlikely (seen_vsindex () || seen_blend)) + { + set_error (); + } + else + { + set_ivs (index); + } + seen_vsindex_ = true; + } + + unsigned int get_region_count () const { return region_count; } + void set_region_count (unsigned int region_count_) { region_count = region_count_; } + unsigned int get_ivs () const { return ivs; } + void set_ivs (unsigned int ivs_) { ivs = ivs_; } + bool seen_vsindex () const { return seen_vsindex_; } + + protected: + void blend_arg (BlendArg &arg) + { + if (do_blend && arg.blending ()) + { + if (likely (scalars.len == arg.deltas.len)) + { + double v = arg.to_real (); + for (unsigned int i = 0; i < scalars.len; i++) + { + v += (double)scalars[i] * arg.deltas[i].to_real (); + } + arg.set_real (v); + arg.deltas.resize (0); + } + } + } + + protected: + const int *coords; + unsigned int num_coords; + const CFF2VariationStore *varStore; + unsigned int region_count; + unsigned int ivs; + hb_vector_t<float> scalars; + bool do_blend; + bool seen_vsindex_; + bool seen_blend; + + typedef CSInterpEnv<BlendArg, CFF2Subrs> SUPER; +}; +template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF2CSInterpEnv, PARAM> > +struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH> +{ + static void process_op (OpCode op, CFF2CSInterpEnv &env, PARAM& param) + { + switch (op) { + case OpCode_callsubr: + case OpCode_callgsubr: + /* a subroutine number shoudln't be a blended value */ + if (unlikely (env.argStack.peek ().blending ())) + { + env.set_error (); + break; + } + SUPER::process_op (op, env, param); + break; + + case OpCode_blendcs: + OPSET::process_blend (env, param); + break; + + case OpCode_vsindexcs: + if (unlikely (env.argStack.peek ().blending ())) + { + env.set_error (); + break; + } + OPSET::process_vsindex (env, param); + break; + + default: + SUPER::process_op (op, env, param); + } + } + + static void process_blend (CFF2CSInterpEnv &env, PARAM& param) + { + unsigned int n, k; + + env.process_blend (); + k = env.get_region_count (); + n = env.argStack.pop_uint (); + /* copy the blend values into blend array of the default values */ + unsigned int start = env.argStack.get_count () - ((k+1) * n); + /* let an obvious error case fail, but note CFF2 spec doesn't forbid n==0 */ + if (unlikely (start > env.argStack.get_count ())) + { + env.set_error (); + return; + } + for (unsigned int i = 0; i < n; i++) + { + const hb_array_t<const BlendArg> blends = env.argStack.get_subarray (start + n + (i * k)); + env.argStack[start + i].set_blends (n, i, k, blends); + } + + /* pop off blend values leaving default values now adorned with blend values */ + env.argStack.pop (k * n); + } + + static void process_vsindex (CFF2CSInterpEnv &env, PARAM& param) + { + env.process_vsindex (); + env.clear_args (); + } + + private: + typedef CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH> SUPER; +}; + +template <typename OPSET, typename PARAM> +struct CFF2CSInterpreter : CSInterpreter<CFF2CSInterpEnv, OPSET, PARAM> {}; + +} /* namespace CFF */ + +#endif /* HB_CFF2_INTERP_CS_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc index c3cffccb189..93f5b7939ca 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.cc @@ -51,7 +51,7 @@ hb_atomic_int_t _hb_options; void -_hb_options_init (void) +_hb_options_init () { hb_options_union_t u; u.i = 0; @@ -247,11 +247,10 @@ struct hb_language_item_t { struct hb_language_item_t *next; hb_language_t lang; - inline bool operator == (const char *s) const { - return lang_equal (lang, s); - } + bool operator == (const char *s) const + { return lang_equal (lang, s); } - inline hb_language_item_t & operator = (const char *s) { + hb_language_item_t & operator = (const char *s) { /* If a custom allocated is used calling strdup() pairs badly with a call to the custom free() in fini() below. Therefore don't call strdup(), implement its behavior. @@ -268,7 +267,7 @@ struct hb_language_item_t { return *this; } - void fini (void) { free ((void *) lang); } + void fini () { free ((void *) lang); } }; @@ -278,7 +277,7 @@ static hb_atomic_ptr_t <hb_language_item_t> langs; #if HB_USE_ATEXIT static void -free_langs (void) +free_langs () { retry: hb_language_item_t *first_lang = langs; @@ -404,7 +403,7 @@ hb_language_to_string (hb_language_t language) * Since: 0.9.2 **/ hb_language_t -hb_language_get_default (void) +hb_language_get_default () { static hb_atomic_ptr_t <hb_language_t> default_language; @@ -668,7 +667,7 @@ hb_version (unsigned int *major, * Since: 0.9.2 **/ const char * -hb_version_string (void) +hb_version_string () { return HB_VERSION_STRING; } @@ -781,13 +780,13 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv) #ifdef USE_XLOCALE #if HB_USE_ATEXIT -static void free_static_C_locale (void); +static void free_static_C_locale (); #endif 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) + static HB_LOCALE_T create () { HB_LOCALE_T C_locale = HB_CREATE_LOCALE ("C"); @@ -797,11 +796,11 @@ static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (HB return C_locale; } - static inline void destroy (HB_LOCALE_T p) + static void destroy (HB_LOCALE_T p) { HB_FREE_LOCALE (p); } - static inline HB_LOCALE_T get_null (void) + static HB_LOCALE_T get_null () { return nullptr; } @@ -809,14 +808,14 @@ static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer (HB #if HB_USE_ATEXIT static -void free_static_C_locale (void) +void free_static_C_locale () { static_C_locale.free_instance (); } #endif static HB_LOCALE_T -get_C_locale (void) +get_C_locale () { return static_C_locale.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc index 918f649da6c..c181950d21d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc @@ -100,7 +100,7 @@ _hb_cg_font_release (void *data) static CTFontDescriptorRef -get_last_resort_font_desc (void) +get_last_resort_font_desc () { // TODO Handle allocation failures? CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize (CFSTR("LastResort"), 0); @@ -598,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); + active_features.remove (feature - active_features.arrayZ ()); } } } @@ -1163,20 +1163,8 @@ struct hb_coretext_aat_face_data_t {}; hb_coretext_aat_face_data_t * _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) { - static const hb_tag_t tags[] = {HB_CORETEXT_TAG_MORX, HB_CORETEXT_TAG_MORT, HB_CORETEXT_TAG_KERX}; - - for (unsigned int i = 0; i < ARRAY_LENGTH (tags); i++) - { - hb_blob_t *blob = face->reference_table (tags[i]); - if (hb_blob_get_length (blob)) - { - hb_blob_destroy (blob); - return face->data.coretext ? (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; - } - hb_blob_destroy (blob); - } - - return nullptr; + return hb_aat_layout_has_substitution (face) || hb_aat_layout_has_positioning (face) ? + (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } void diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh index f13cfddb9c5..41a85b58c10 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh @@ -56,12 +56,12 @@ union hb_options_union_t { static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)), ""); HB_INTERNAL void -_hb_options_init (void); +_hb_options_init (); extern HB_INTERNAL hb_atomic_int_t _hb_options; static inline hb_options_t -hb_options (void) +hb_options () { /* Make a local copy, so we can access bitfield threadsafely. */ hb_options_union_t u; @@ -284,7 +284,7 @@ struct hb_auto_trace_t _hb_debug_msg_va<max_level> (what, obj, func, true, plevel ? *plevel : 0, +1, message, ap); va_end (ap); } - inline ~hb_auto_trace_t (void) + ~hb_auto_trace_t () { _hb_warn_no_return<ret_t> (returned); if (!returned) { @@ -293,9 +293,9 @@ struct hb_auto_trace_t if (plevel) --*plevel; } - inline ret_t ret (ret_t v, - const char *func = "", - unsigned int line = 0) + 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"); @@ -327,18 +327,18 @@ struct hb_auto_trace_t<0, ret_t> const char *message, ...) HB_PRINTF_FUNC(6, 7) {} - inline ret_t ret (ret_t v, - const char *func HB_UNUSED = 0, - unsigned int line HB_UNUSED = 0) { return v; } + ret_t ret (ret_t v, + const char *func HB_UNUSED = nullptr, + 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, - const char *func HB_UNUSED = "", - unsigned int line HB_UNUSED = 0) { return v; } + 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, HB_FUNC, __LINE__) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h index 9ceb264816c..4a5e702ffca 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h @@ -52,6 +52,7 @@ HB_BEGIN_DECLS #ifndef HB_DISABLE_DEPRECATED + #define HB_SCRIPT_CANADIAN_ABORIGINAL HB_SCRIPT_CANADIAN_SYLLABICS #define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT @@ -217,66 +218,6 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font, 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: 2.2.0 - */ -#define HB_OT_VAR_NO_AXIS_INDEX 0xFFFFFFFFu - -/** - * hb_ot_var_axis_t: - * - * Since: 1.4.2 - * Deprecated: 2.2.0 - */ -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 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc index f9b2d261a99..e93cf90a30f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc @@ -35,9 +35,9 @@ * to override malloc/free, we will redefine new/delete so users * won't need to do that by their own. */ -void* operator new (size_t size) { return malloc (size); } -void* operator new [] (size_t size) { return malloc (size); } -void operator delete (void* pointer) { free (pointer); } +void* operator new (size_t size) { return malloc (size); } +void* operator new [] (size_t size) { return malloc (size); } +void operator delete (void* pointer) { free (pointer); } void operator delete [] (void* pointer) { free (pointer); } @@ -54,19 +54,19 @@ private: IDWriteFontFileStream *mFontFileStream; public: DWriteFontFileLoader (IDWriteFontFileStream *fontFileStream) - { - mFontFileStream = fontFileStream; - } + { mFontFileStream = fontFileStream; } // IUnknown interface - IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) { return S_OK; } - IFACEMETHOD_ (ULONG, AddRef) () { return 1; } + IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) + { return S_OK; } + IFACEMETHOD_ (ULONG, AddRef) () { return 1; } IFACEMETHOD_ (ULONG, Release) () { return 1; } // IDWriteFontFileLoader methods - virtual HRESULT STDMETHODCALLTYPE CreateStreamFromKey (void const* fontFileReferenceKey, - uint32_t fontFileReferenceKeySize, - OUT IDWriteFontFileStream** fontFileStream) + virtual HRESULT STDMETHODCALLTYPE + CreateStreamFromKey (void const* fontFileReferenceKey, + uint32_t fontFileReferenceKeySize, + OUT IDWriteFontFileStream** fontFileStream) { *fontFileStream = mFontFileStream; return S_OK; @@ -86,19 +86,20 @@ public: } // IUnknown interface - IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) { return S_OK; } - IFACEMETHOD_ (ULONG, AddRef) () { return 1; } + IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) + { return S_OK; } + IFACEMETHOD_ (ULONG, AddRef) () { return 1; } IFACEMETHOD_ (ULONG, Release) () { return 1; } // IDWriteFontFileStream methods - virtual HRESULT STDMETHODCALLTYPE ReadFileFragment (void const** fragmentStart, - UINT64 fileOffset, - UINT64 fragmentSize, - OUT void** fragmentContext) + virtual HRESULT STDMETHODCALLTYPE + ReadFileFragment (void const** fragmentStart, + UINT64 fileOffset, + UINT64 fragmentSize, + OUT void** fragmentContext) { // We are required to do bounds checking. - if (fileOffset + fragmentSize > mSize) - return E_FAIL; + if (fileOffset + fragmentSize > mSize) return E_FAIL; // truncate the 64 bit fileOffset to size_t sized index into mData size_t index = static_cast<size_t> (fileOffset); @@ -109,18 +110,18 @@ public: return S_OK; } - virtual void STDMETHODCALLTYPE ReleaseFileFragment (void* fragmentContext) { } + virtual void STDMETHODCALLTYPE + ReleaseFileFragment (void* fragmentContext) {} - virtual HRESULT STDMETHODCALLTYPE GetFileSize (OUT UINT64* fileSize) + virtual HRESULT STDMETHODCALLTYPE + GetFileSize (OUT UINT64* fileSize) { *fileSize = mSize; return S_OK; } - virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime (OUT UINT64* lastWriteTime) - { - return E_NOTIMPL; - } + virtual HRESULT STDMETHODCALLTYPE + GetLastWriteTime (OUT UINT64* lastWriteTime) { return E_NOTIMPL; } }; @@ -147,17 +148,14 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face) // TODO: factory and fontFileLoader should be cached separately IDWriteFactory* dwriteFactory; - DWriteCreateFactory ( - DWRITE_FACTORY_TYPE_SHARED, - __uuidof (IDWriteFactory), - (IUnknown**) &dwriteFactory - ); + DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), + (IUnknown**) &dwriteFactory); HRESULT hr; hb_blob_t *blob = hb_face_reference_blob (face); - DWriteFontFileStream *fontFileStream = new DWriteFontFileStream ( - (uint8_t *) hb_blob_get_data (blob, nullptr), - hb_blob_get_length (blob)); + DWriteFontFileStream *fontFileStream; + fontFileStream = new DWriteFontFileStream ((uint8_t *) hb_blob_get_data (blob, nullptr), + hb_blob_get_length (blob)); DWriteFontFileLoader *fontFileLoader = new DWriteFontFileLoader (fontFileStream); dwriteFactory->RegisterFontFileLoader (fontFileLoader); @@ -165,7 +163,7 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face) IDWriteFontFile *fontFile; uint64_t fontFileKey = 0; hr = dwriteFactory->CreateCustomFontFileReference (&fontFileKey, sizeof (fontFileKey), - fontFileLoader, &fontFile); + fontFileLoader, &fontFile); #define FAIL(...) \ HB_STMT_START { \ @@ -188,7 +186,7 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face) IDWriteFontFace *fontFace; dwriteFactory->CreateFontFace (faceType, 1, &fontFile, 0, - DWRITE_FONT_SIMULATIONS_NONE, &fontFace); + DWRITE_FONT_SIMULATIONS_NONE, &fontFace); data->dwriteFactory = dwriteFactory; data->fontFile = fontFile; @@ -228,9 +226,7 @@ _hb_directwrite_shaper_face_data_destroy (hb_directwrite_face_data_t *data) * shaper font data */ -struct hb_directwrite_font_data_t -{ -}; +struct hb_directwrite_font_data_t {}; hb_directwrite_font_data_t * _hb_directwrite_shaper_font_data_create (hb_font_t *font) @@ -251,12 +247,12 @@ _hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data) // Most of TextAnalysis is originally written by Bas Schouten for Mozilla project // but now is relicensed to MIT for HarfBuzz use -class TextAnalysis - : public IDWriteTextAnalysisSource, public IDWriteTextAnalysisSink +class TextAnalysis : public IDWriteTextAnalysisSource, public IDWriteTextAnalysisSink { public: - IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) { return S_OK; } + IFACEMETHOD (QueryInterface) (IID const& iid, OUT void** ppObject) + { return S_OK; } IFACEMETHOD_ (ULONG, AddRef) () { return 1; } IFACEMETHOD_ (ULONG, Release) () { return 1; } @@ -273,7 +269,7 @@ public: uint8_t mBidiLevel; bool mIsSideways; - inline bool ContainsTextPosition (uint32_t aTextPosition) const + bool ContainsTextPosition (uint32_t aTextPosition) const { return aTextPosition >= mTextStart && aTextPosition < mTextStart + mTextLength; @@ -283,16 +279,10 @@ public: }; public: - TextAnalysis (const wchar_t* text, - uint32_t textLength, - const wchar_t* localeName, - DWRITE_READING_DIRECTION readingDirection) - : mText (text) - , mTextLength (textLength) - , mLocaleName (localeName) - , mReadingDirection (readingDirection) - , mCurrentRun (nullptr) { }; - + TextAnalysis (const wchar_t* text, uint32_t textLength, + const wchar_t* localeName, DWRITE_READING_DIRECTION readingDirection) + : mText (text), mTextLength (textLength), mLocaleName (localeName), + mReadingDirection (readingDirection), mCurrentRun (nullptr) {} ~TextAnalysis () { // delete runs, except mRunHead which is part of the TextAnalysis object @@ -304,8 +294,8 @@ public: } } - STDMETHODIMP GenerateResults (IDWriteTextAnalyzer* textAnalyzer, - Run **runHead) + STDMETHODIMP + GenerateResults (IDWriteTextAnalyzer* textAnalyzer, Run **runHead) { // Analyzes the text using the script analyzer and returns // the result as a series of runs. @@ -330,9 +320,10 @@ public: // IDWriteTextAnalysisSource implementation - IFACEMETHODIMP GetTextAtPosition (uint32_t textPosition, - OUT wchar_t const** textString, - OUT uint32_t* textLength) + IFACEMETHODIMP + GetTextAtPosition (uint32_t textPosition, + OUT wchar_t const** textString, + OUT uint32_t* textLength) { if (textPosition >= mTextLength) { @@ -348,9 +339,10 @@ public: return S_OK; } - IFACEMETHODIMP GetTextBeforePosition (uint32_t textPosition, - OUT wchar_t const** textString, - OUT uint32_t* textLength) + IFACEMETHODIMP + GetTextBeforePosition (uint32_t textPosition, + OUT wchar_t const** textString, + OUT uint32_t* textLength) { if (textPosition == 0 || textPosition > mTextLength) { @@ -368,19 +360,16 @@ public: } IFACEMETHODIMP_ (DWRITE_READING_DIRECTION) - GetParagraphReadingDirection () { return mReadingDirection; } + GetParagraphReadingDirection () { return mReadingDirection; } - IFACEMETHODIMP GetLocaleName (uint32_t textPosition, - uint32_t* textLength, - wchar_t const** localeName) - { - return S_OK; - } + IFACEMETHODIMP GetLocaleName (uint32_t textPosition, uint32_t* textLength, + wchar_t const** localeName) + { return S_OK; } IFACEMETHODIMP - GetNumberSubstitution (uint32_t textPosition, - OUT uint32_t* textLength, - OUT IDWriteNumberSubstitution** numberSubstitution) + GetNumberSubstitution (uint32_t textPosition, + OUT uint32_t* textLength, + OUT IDWriteNumberSubstitution** numberSubstitution) { // We do not support number substitution. *numberSubstitution = nullptr; @@ -392,9 +381,8 @@ public: // IDWriteTextAnalysisSink implementation IFACEMETHODIMP - SetScriptAnalysis (uint32_t textPosition, - uint32_t textLength, - DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis) + SetScriptAnalysis (uint32_t textPosition, uint32_t textLength, + DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis) { SetCurrentRun (textPosition); SplitCurrentRun (textPosition); @@ -408,19 +396,19 @@ public: } IFACEMETHODIMP - SetLineBreakpoints (uint32_t textPosition, - uint32_t textLength, - const DWRITE_LINE_BREAKPOINT* lineBreakpoints) { return S_OK; } + SetLineBreakpoints (uint32_t textPosition, + uint32_t textLength, + const DWRITE_LINE_BREAKPOINT* lineBreakpoints) + { return S_OK; } - IFACEMETHODIMP SetBidiLevel (uint32_t textPosition, - uint32_t textLength, - uint8_t explicitLevel, - uint8_t resolvedLevel) { return S_OK; } + IFACEMETHODIMP SetBidiLevel (uint32_t textPosition, uint32_t textLength, + uint8_t explicitLevel, uint8_t resolvedLevel) + { return S_OK; } IFACEMETHODIMP - SetNumberSubstitution (uint32_t textPosition, - uint32_t textLength, - IDWriteNumberSubstitution* numberSubstitution) { return S_OK; } + SetNumberSubstitution (uint32_t textPosition, uint32_t textLength, + IDWriteNumberSubstitution* numberSubstitution) + { return S_OK; } protected: Run *FetchNextRun (IN OUT uint32_t* textLength) @@ -520,11 +508,11 @@ static inline uint32_t hb_uint32_swap (const uint32_t v) static hb_bool_t _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features, - float lineWidth) + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features, + float lineWidth) { hb_face_t *face = font->face; const hb_directwrite_face_data_t *face_data = face->data.directwrite; @@ -580,9 +568,10 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, // TODO: Handle TEST_DISABLE_OPTIONAL_LIGATURES - DWRITE_READING_DIRECTION readingDirection = buffer->props.direction ? - DWRITE_READING_DIRECTION_RIGHT_TO_LEFT : - DWRITE_READING_DIRECTION_LEFT_TO_RIGHT; + DWRITE_READING_DIRECTION readingDirection; + readingDirection = buffer->props.direction ? + DWRITE_READING_DIRECTION_RIGHT_TO_LEFT : + DWRITE_READING_DIRECTION_LEFT_TO_RIGHT; /* * There's an internal 16-bit limit on some things inside the analyzer, @@ -611,10 +600,8 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, const wchar_t localeName[20] = {0}; if (buffer->props.language != nullptr) - { mbstowcs ((wchar_t*) localeName, - hb_language_to_string (buffer->props.language), 20); - } + hb_language_to_string (buffer->props.language), 20); // TODO: it does work but doesn't care about ranges DWRITE_TYPOGRAPHIC_FEATURES typographic_features; @@ -625,27 +612,29 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, for (unsigned int i = 0; i < num_features; ++i) { typographic_features.features[i].nameTag = (DWRITE_FONT_FEATURE_TAG) - hb_uint32_swap (features[i].tag); + hb_uint32_swap (features[i].tag); typographic_features.features[i].parameter = features[i].value; } } - const DWRITE_TYPOGRAPHIC_FEATURES* dwFeatures = - (const DWRITE_TYPOGRAPHIC_FEATURES*) &typographic_features; + const DWRITE_TYPOGRAPHIC_FEATURES* dwFeatures; + dwFeatures = (const DWRITE_TYPOGRAPHIC_FEATURES*) &typographic_features; const uint32_t featureRangeLengths[] = { textLength }; // - uint16_t* clusterMap = new uint16_t[textLength]; - DWRITE_SHAPING_TEXT_PROPERTIES* textProperties = - new DWRITE_SHAPING_TEXT_PROPERTIES[textLength]; + uint16_t* clusterMap; + clusterMap = new uint16_t[textLength]; + DWRITE_SHAPING_TEXT_PROPERTIES* textProperties; + textProperties = new DWRITE_SHAPING_TEXT_PROPERTIES[textLength]; retry_getglyphs: uint16_t* glyphIndices = new uint16_t[maxGlyphCount]; - DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProperties = - new DWRITE_SHAPING_GLYPH_PROPERTIES[maxGlyphCount]; + DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProperties; + glyphProperties = new DWRITE_SHAPING_GLYPH_PROPERTIES[maxGlyphCount]; hr = analyzer->GetGlyphs (textString, textLength, fontFace, false, - isRightToLeft, &runHead->mScript, localeName, nullptr, &dwFeatures, - featureRangeLengths, 1, maxGlyphCount, clusterMap, textProperties, glyphIndices, - glyphProperties, &glyphCount); + isRightToLeft, &runHead->mScript, localeName, + nullptr, &dwFeatures, featureRangeLengths, 1, + maxGlyphCount, clusterMap, textProperties, + glyphIndices, glyphProperties, &glyphCount); if (unlikely (hr == HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER))) { @@ -665,30 +654,28 @@ retry_getglyphs: /* The -2 in the following is to compensate for possible * alignment needed after the WORD array. sizeof (WORD) == 2. */ unsigned int glyphs_size = (scratch_size * sizeof (int) - 2) - / (sizeof (WORD) + - sizeof (DWRITE_SHAPING_GLYPH_PROPERTIES) + - sizeof (int) + - sizeof (DWRITE_GLYPH_OFFSET) + - sizeof (uint32_t)); + / (sizeof (WORD) + + sizeof (DWRITE_SHAPING_GLYPH_PROPERTIES) + + sizeof (int) + + sizeof (DWRITE_GLYPH_OFFSET) + + sizeof (uint32_t)); ALLOCATE_ARRAY (uint32_t, vis_clusters, glyphs_size); #undef ALLOCATE_ARRAY int fontEmSize = font->face->get_upem (); - if (fontEmSize < 0) - fontEmSize = -fontEmSize; + if (fontEmSize < 0) fontEmSize = -fontEmSize; - if (fontEmSize < 0) - fontEmSize = -fontEmSize; + if (fontEmSize < 0) fontEmSize = -fontEmSize; double x_mult = (double) font->x_scale / fontEmSize; double y_mult = (double) font->y_scale / fontEmSize; - hr = analyzer->GetGlyphPlacements (textString, - clusterMap, textProperties, textLength, glyphIndices, - glyphProperties, glyphCount, fontFace, fontEmSize, - false, isRightToLeft, &runHead->mScript, localeName, - &dwFeatures, featureRangeLengths, 1, - glyphAdvances, glyphOffsets); + hr = analyzer->GetGlyphPlacements (textString, clusterMap, textProperties, + textLength, glyphIndices, glyphProperties, + glyphCount, fontFace, fontEmSize, + false, isRightToLeft, &runHead->mScript, localeName, + &dwFeatures, featureRangeLengths, 1, + glyphAdvances, glyphOffsets); if (FAILED (hr)) FAIL ("Analyzer failed to get glyph placements."); @@ -698,12 +685,12 @@ retry_getglyphs: if (analyzer1 && lineWidth) { - DWRITE_JUSTIFICATION_OPPORTUNITY* justificationOpportunities = new DWRITE_JUSTIFICATION_OPPORTUNITY[maxGlyphCount]; - hr = analyzer1->GetJustificationOpportunities (fontFace, fontEmSize, - runHead->mScript, textLength, glyphCount, textString, clusterMap, - glyphProperties, justificationOpportunities); + hr = analyzer1->GetJustificationOpportunities (fontFace, fontEmSize, runHead->mScript, + textLength, glyphCount, textString, + clusterMap, glyphProperties, + justificationOpportunities); if (FAILED (hr)) FAIL ("Analyzer failed to get justification opportunities."); @@ -711,15 +698,14 @@ retry_getglyphs: float* justifiedGlyphAdvances = new float[maxGlyphCount]; DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets = new DWRITE_GLYPH_OFFSET[glyphCount]; hr = analyzer1->JustifyGlyphAdvances (lineWidth, glyphCount, justificationOpportunities, - glyphAdvances, glyphOffsets, justifiedGlyphAdvances, justifiedGlyphOffsets); + glyphAdvances, glyphOffsets, justifiedGlyphAdvances, + justifiedGlyphOffsets); - if (FAILED (hr)) - FAIL ("Analyzer failed to get justified glyph advances."); + if (FAILED (hr)) FAIL ("Analyzer failed to get justify glyph advances."); DWRITE_SCRIPT_PROPERTIES scriptProperties; hr = analyzer1->GetScriptProperties (runHead->mScript, &scriptProperties); - if (FAILED (hr)) - FAIL ("Analyzer failed to get script properties."); + if (FAILED (hr)) FAIL ("Analyzer failed to get script properties."); uint32_t justificationCharacter = scriptProperties.justificationCharacter; // if a script justificationCharacter is not space, it can have GetJustifiedGlyphs @@ -729,14 +715,15 @@ retry_getglyphs: retry_getjustifiedglyphs: uint16_t* modifiedGlyphIndices = new uint16_t[maxGlyphCount]; float* modifiedGlyphAdvances = new float[maxGlyphCount]; - DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets = - new DWRITE_GLYPH_OFFSET[maxGlyphCount]; + DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets = new DWRITE_GLYPH_OFFSET[maxGlyphCount]; uint32_t actualGlyphsCount; hr = analyzer1->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript, - textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices, - glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets, - glyphProperties, &actualGlyphsCount, modifiedClusterMap, modifiedGlyphIndices, - modifiedGlyphAdvances, modifiedGlyphOffsets); + textLength, glyphCount, maxGlyphCount, + clusterMap, glyphIndices, glyphAdvances, + justifiedGlyphAdvances, justifiedGlyphOffsets, + glyphProperties, &actualGlyphsCount, + modifiedClusterMap, modifiedGlyphIndices, + modifiedGlyphAdvances, modifiedGlyphOffsets); if (hr == HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER)) { @@ -776,7 +763,6 @@ retry_getglyphs: } delete [] justificationOpportunities; - } /* Ok, we've got everything we need, now compose output buffer, @@ -826,13 +812,11 @@ retry_getglyphs: /* TODO vertical */ pos->x_advance = x_mult * (int32_t) info->mask; - pos->x_offset = - x_mult * (isRightToLeft ? -info->var1.i32 : info->var1.i32); + pos->x_offset = x_mult * (isRightToLeft ? -info->var1.i32 : info->var1.i32); pos->y_offset = y_mult * info->var2.i32; } - if (isRightToLeft) - hb_buffer_reverse (buffer); + if (isRightToLeft) hb_buffer_reverse (buffer); delete [] clusterMap; delete [] glyphIndices; @@ -850,13 +834,13 @@ retry_getglyphs: hb_bool_t _hb_directwrite_shape (hb_shape_plan_t *shape_plan, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features) + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features) { return _hb_directwrite_shape_full (shape_plan, font, buffer, - features, num_features, 0); + features, num_features, 0); } /* @@ -865,16 +849,17 @@ _hb_directwrite_shape (hb_shape_plan_t *shape_plan, hb_bool_t hb_directwrite_shape_experimental_width (hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features, - float width) + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features, + float width) { static const char *shapers = "directwrite"; - hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, - &buffer->props, features, num_features, &shapers); + hb_shape_plan_t *shape_plan; + shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, + features, num_features, &shapers); hb_bool_t res = _hb_directwrite_shape_full (shape_plan, font, buffer, - features, num_features, width); + features, num_features, width); buffer->unsafe_to_break_all (); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh index 5773596019d..48ce9897d5e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh @@ -46,7 +46,7 @@ template <typename T> static inline HB_CONST_FUNC unsigned int hb_popcount (T v) { -#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && defined(__OPTIMIZE__) +#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) if (sizeof (T) <= sizeof (unsigned int)) return __builtin_popcount (v); @@ -89,7 +89,7 @@ hb_bit_storage (T v) { if (unlikely (!v)) return 0; -#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) +#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) if (sizeof (T) <= sizeof (unsigned int)) return sizeof (unsigned int) * 8 - __builtin_clz (v); @@ -163,7 +163,7 @@ hb_ctz (T v) { if (unlikely (!v)) return 0; -#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) +#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) if (sizeof (T) <= sizeof (unsigned int)) return __builtin_ctz (v); @@ -234,6 +234,15 @@ hb_ctz (T v) * Tiny stuff. */ +template <typename T> +static inline T* hb_addressof (T& arg) +{ + /* https://en.cppreference.com/w/cpp/memory/addressof */ + return reinterpret_cast<T*>( + &const_cast<char&>( + reinterpret_cast<const volatile char&>(arg))); +} + /* ASCII tag/character handling */ static inline bool ISALPHA (unsigned char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } @@ -287,11 +296,25 @@ hb_ceil_to_4 (unsigned int v) return ((v - 1) | 3) + 1; } -template <typename T> class hb_assert_unsigned_t; -template <> class hb_assert_unsigned_t<unsigned char> {}; -template <> class hb_assert_unsigned_t<unsigned short> {}; -template <> class hb_assert_unsigned_t<unsigned int> {}; -template <> class hb_assert_unsigned_t<unsigned long> {}; +template <typename T> struct hb_is_signed; +template <> struct hb_is_signed<signed char> { enum { value = true }; }; +template <> struct hb_is_signed<signed short> { enum { value = true }; }; +template <> struct hb_is_signed<signed int> { enum { value = true }; }; +template <> struct hb_is_signed<signed long> { enum { value = true }; }; +template <> struct hb_is_signed<unsigned char> { enum { value = false }; }; +template <> struct hb_is_signed<unsigned short> { enum { value = false }; }; +template <> struct hb_is_signed<unsigned int> { enum { value = false }; }; +template <> struct hb_is_signed<unsigned long> { enum { value = false }; }; +/* We need to define hb_is_signed for the typedefs we use on pre-Visual + * Studio 2010 for the int8_t type, since __int8/__int64 is not considered + * the same as char/long. The previous lines will suffice for the other + * types, though. Note that somehow, unsigned __int8 is considered same + * as unsigned char. + * https://github.com/harfbuzz/harfbuzz/pull/1499 + */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +template <> struct hb_is_signed<__int8> { enum { value = true }; }; +#endif template <typename T> static inline bool hb_in_range (T u, T lo, T hi) @@ -301,7 +324,7 @@ hb_in_range (T u, T lo, T hi) * one right now. Declaring a variable won't work as HB_UNUSED * is unusable on some platforms and unused types are less likely * to generate a warning than unused variables. */ - static_assert ((sizeof (hb_assert_unsigned_t<T>) >= 0), ""); + static_assert (!hb_is_signed<T>::value, ""); /* The casts below are important as if T is smaller than int, * the subtract results will become a signed int! */ @@ -529,232 +552,28 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o } -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 * 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; } - - inline int cmp (const hb_bytes_t &a) const - { - if (len != a.len) - return (int) a.len - (int) len; - return hb_memcmp (a.arrayZ, arrayZ, len); - } - static inline int cmp (const void *pa, const void *pb) - { - hb_bytes_t *a = (hb_bytes_t *) pa; - hb_bytes_t *b = (hb_bytes_t *) pb; - return b->cmp (*a); - } - - const char *arrayZ; - 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 { - static const bool passthru_left = true; - static const bool passthru_right = true; + enum { passthru_left = true }; + enum { passthru_right = true }; template <typename T> static void process (T &o, const T &a, const T &b) { o = a | b; } }; struct HbOpAnd { - static const bool passthru_left = false; - static const bool passthru_right = false; + enum { passthru_left = false }; + enum { passthru_right = false }; template <typename T> static void process (T &o, const T &a, const T &b) { o = a & b; } }; struct HbOpMinus { - static const bool passthru_left = true; - static const bool passthru_right = false; + enum { passthru_left = true }; + enum { passthru_right = false }; template <typename T> static void process (T &o, const T &a, const T &b) { o = a & ~b; } }; struct HbOpXor { - static const bool passthru_left = true; - static const bool passthru_right = true; + enum { passthru_left = true }; + enum { passthru_right = true }; template <typename T> static void process (T &o, const T &a, const T &b) { o = a ^ b; } }; @@ -767,13 +586,13 @@ struct HbOpXor template <typename elt_t, unsigned int byte_size> struct hb_vector_size_t { - inline elt_t& operator [] (unsigned int i) { return u.v[i]; } - inline const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + elt_t& operator [] (unsigned int i) { return u.v[i]; } + const elt_t& operator [] (unsigned int i) const { return u.v[i]; } - inline void clear (unsigned char v = 0) { memset (this, v, sizeof (*this)); } + 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 + hb_vector_size_t process (const hb_vector_size_t &o) const { hb_vector_size_t r; #if HB_VECTOR_SIZE @@ -786,13 +605,13 @@ struct hb_vector_size_t Op::process (r.u.v[i], u.v[i], o.u.v[i]); return r; } - inline hb_vector_size_t operator | (const hb_vector_size_t &o) const + hb_vector_size_t operator | (const hb_vector_size_t &o) const { return process<HbOpOr> (o); } - inline hb_vector_size_t operator & (const hb_vector_size_t &o) const + hb_vector_size_t operator & (const hb_vector_size_t &o) const { return process<HbOpAnd> (o); } - inline hb_vector_size_t operator ^ (const hb_vector_size_t &o) const + hb_vector_size_t operator ^ (const hb_vector_size_t &o) const { return process<HbOpXor> (o); } - inline hb_vector_size_t operator ~ () const + hb_vector_size_t operator ~ () const { hb_vector_size_t r; #if HB_VECTOR_SIZE && 0 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc index 5b33784f45c..8bb8c512106 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc @@ -224,7 +224,7 @@ hb_face_create (hb_blob_t *blob, * Since: 0.9.2 **/ hb_face_t * -hb_face_get_empty (void) +hb_face_get_empty () { return const_cast<hb_face_t *> (&Null(hb_face_t)); } @@ -588,7 +588,7 @@ struct hb_face_builder_data_t { struct table_entry_t { - inline int cmp (hb_tag_t t) const + int cmp (hb_tag_t t) const { if (t < tag) return -1; if (t > tag) return -1; @@ -603,7 +603,7 @@ struct hb_face_builder_data_t }; static hb_face_builder_data_t * -_hb_face_builder_data_create (void) +_hb_face_builder_data_create () { hb_face_builder_data_t *data = (hb_face_builder_data_t *) calloc (1, sizeof (hb_face_builder_data_t)); if (unlikely (!data)) @@ -642,18 +642,13 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) return nullptr; hb_serialize_context_t c (buf, face_length); + c.propagate_error (data->tables); OT::OpenTypeFontFile *f = c.start_serialize<OT::OpenTypeFontFile> (); bool is_cff = data->tables.lsearch (HB_TAG ('C','F','F',' ')) || data->tables.lsearch (HB_TAG ('C','F','F','2')); hb_tag_t sfnt_tag = is_cff ? OT::OpenTypeFontFile::CFFTag : OT::OpenTypeFontFile::TrueTypeTag; - Supplier<hb_tag_t> tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); - Supplier<hb_blob_t *> blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); - bool ret = f->serialize_single (&c, - sfnt_tag, - tags_supplier, - blobs_supplier, - table_count); + bool ret = f->serialize_single (&c, sfnt_tag, data->tables.as_array ()); c.end_serialize (); @@ -694,7 +689,7 @@ _hb_face_builder_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void * Since: 1.9.0 **/ hb_face_t * -hb_face_builder_create (void) +hb_face_builder_create () { hb_face_builder_data_t *data = _hb_face_builder_data_create (); if (unlikely (!data)) return hb_face_get_empty (); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh index 0b672336f3e..68834baeb83 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.hh @@ -67,7 +67,7 @@ struct hb_face_t }; hb_atomic_ptr_t<plan_node_t> shape_plans; - inline hb_blob_t *reference_table (hb_tag_t tag) const + hb_blob_t *reference_table (hb_tag_t tag) const { hb_blob_t *blob; @@ -81,7 +81,7 @@ struct hb_face_t return blob; } - inline HB_PURE_FUNC unsigned int get_upem (void) const + HB_PURE_FUNC unsigned int get_upem () const { unsigned int ret = upem.get_relaxed (); if (unlikely (!ret)) @@ -91,7 +91,7 @@ struct hb_face_t return ret; } - inline unsigned int get_num_glyphs (void) const + unsigned int get_num_glyphs () const { unsigned int ret = num_glyphs.get_relaxed (); if (unlikely (ret == (unsigned int) -1)) @@ -100,8 +100,8 @@ struct hb_face_t } private: - HB_INTERNAL unsigned int load_upem (void) const; - HB_INTERNAL unsigned int load_num_glyphs (void) const; + HB_INTERNAL unsigned int load_upem () const; + HB_INTERNAL unsigned int load_num_glyphs () const; }; DECLARE_NULL_INSTANCE (hb_face_t); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc index 237b2a50929..0f0bcadc1b5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -523,7 +523,7 @@ static const hb_font_funcs_t _hb_font_funcs_default = { * Since: 0.9.2 **/ hb_font_funcs_t * -hb_font_funcs_create (void) +hb_font_funcs_create () { hb_font_funcs_t *ffuncs; @@ -545,7 +545,7 @@ hb_font_funcs_create (void) * Since: 0.9.2 **/ hb_font_funcs_t * -hb_font_funcs_get_empty (void) +hb_font_funcs_get_empty () { return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_default); } @@ -1408,7 +1408,7 @@ hb_font_create_sub_font (hb_font_t *parent) * Since: 0.9.2 **/ hb_font_t * -hb_font_get_empty (void) +hb_font_get_empty () { return const_cast<hb_font_t *> (&Null(hb_font_t)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh index 73733b34bb3..aaa0fd91cac 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.hh @@ -86,7 +86,7 @@ struct hb_font_funcs_t #define HB_FONT_FUNC_IMPLEMENT(name) +1 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT - ]) (void); + ]) (); } get; }; DECLARE_NULL_INSTANCE (hb_font_funcs_t); @@ -127,40 +127,42 @@ struct hb_font_t /* Convert from font-space to user-space */ - inline int dir_scale (hb_direction_t direction) + int dir_scale (hb_direction_t direction) { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; } - inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); } - inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); } - inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); } - inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); } - inline float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); } - inline float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); } - inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction) + hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); } + hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); } + hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); } + hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); } + float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); } + float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); } + hb_position_t em_scale_dir (int16_t v, hb_direction_t direction) { return em_scale (v, dir_scale (direction)); } /* Convert from parent-font user-space to our user-space */ - inline hb_position_t parent_scale_x_distance (hb_position_t v) { + hb_position_t parent_scale_x_distance (hb_position_t v) + { if (unlikely (parent && parent->x_scale != x_scale)) return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale); return v; } - inline hb_position_t parent_scale_y_distance (hb_position_t v) { + hb_position_t parent_scale_y_distance (hb_position_t v) + { if (unlikely (parent && parent->y_scale != y_scale)) return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale); return v; } - inline hb_position_t parent_scale_x_position (hb_position_t v) { - return parent_scale_x_distance (v); - } - inline hb_position_t parent_scale_y_position (hb_position_t v) { - return parent_scale_y_distance (v); - } + hb_position_t parent_scale_x_position (hb_position_t v) + { return parent_scale_x_distance (v); } + hb_position_t parent_scale_y_position (hb_position_t v) + { return parent_scale_y_distance (v); } - inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { + void parent_scale_distance (hb_position_t *x, hb_position_t *y) + { *x = parent_scale_x_distance (*x); *y = parent_scale_y_distance (*y); } - inline void parent_scale_position (hb_position_t *x, hb_position_t *y) { + void parent_scale_position (hb_position_t *x, hb_position_t *y) + { *x = parent_scale_x_position (*x); *y = parent_scale_y_position (*y); } @@ -174,14 +176,14 @@ struct hb_font_t /* has_* ... */ #define HB_FONT_FUNC_IMPLEMENT(name) \ bool \ - has_##name##_func (void) \ + has_##name##_func () \ { \ 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) \ + has_##name##_func_set () \ { \ 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]); \ @@ -190,14 +192,14 @@ struct hb_font_t HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT - inline hb_bool_t get_font_h_extents (hb_font_extents_t *extents) + hb_bool_t get_font_h_extents (hb_font_extents_t *extents) { memset (extents, 0, sizeof (*extents)); return klass->get.f.font_h_extents (this, user_data, extents, klass->user_data.font_h_extents); } - inline hb_bool_t get_font_v_extents (hb_font_extents_t *extents) + hb_bool_t get_font_v_extents (hb_font_extents_t *extents) { memset (extents, 0, sizeof (*extents)); return klass->get.f.font_v_extents (this, user_data, @@ -205,13 +207,13 @@ struct hb_font_t klass->user_data.font_v_extents); } - inline bool has_glyph (hb_codepoint_t unicode) + bool has_glyph (hb_codepoint_t unicode) { hb_codepoint_t glyph; return get_nominal_glyph (unicode, &glyph); } - inline hb_bool_t get_nominal_glyph (hb_codepoint_t unicode, + hb_bool_t get_nominal_glyph (hb_codepoint_t unicode, hb_codepoint_t *glyph) { *glyph = 0; @@ -219,11 +221,11 @@ 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) + 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, @@ -232,8 +234,8 @@ struct hb_font_t 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) + hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) { *glyph = 0; return klass->get.f.variation_glyph (this, user_data, @@ -241,25 +243,25 @@ struct hb_font_t klass->user_data.variation_glyph); } - inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) + hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) { return klass->get.f.glyph_h_advance (this, user_data, glyph, klass->user_data.glyph_h_advance); } - inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) + hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) { return klass->get.f.glyph_v_advance (this, user_data, glyph, klass->user_data.glyph_v_advance); } - inline void get_glyph_h_advances (unsigned int count, - const hb_codepoint_t *first_glyph, - unsigned int glyph_stride, - hb_position_t *first_advance, - unsigned int advance_stride) + void get_glyph_h_advances (unsigned int count, + const hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) { return klass->get.f.glyph_h_advances (this, user_data, count, @@ -268,11 +270,11 @@ struct hb_font_t klass->user_data.glyph_h_advances); } - inline void get_glyph_v_advances (unsigned int count, - const hb_codepoint_t *first_glyph, - unsigned int glyph_stride, - hb_position_t *first_advance, - unsigned int advance_stride) + void get_glyph_v_advances (unsigned int count, + const hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) { return klass->get.f.glyph_v_advances (this, user_data, count, @@ -281,7 +283,7 @@ struct hb_font_t klass->user_data.glyph_v_advances); } - inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, + hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) { *x = *y = 0; @@ -290,8 +292,8 @@ struct hb_font_t klass->user_data.glyph_h_origin); } - inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { *x = *y = 0; return klass->get.f.glyph_v_origin (this, user_data, @@ -299,21 +301,23 @@ struct hb_font_t klass->user_data.glyph_v_origin); } - inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) + hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph) { return klass->get.f.glyph_h_kerning (this, user_data, left_glyph, right_glyph, klass->user_data.glyph_h_kerning); } - inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph) + hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, + hb_codepoint_t bottom_glyph) { return klass->get.f.glyph_v_kerning (this, user_data, top_glyph, bottom_glyph, klass->user_data.glyph_v_kerning); } - inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph, + hb_bool_t get_glyph_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) { memset (extents, 0, sizeof (*extents)); @@ -323,7 +327,7 @@ struct hb_font_t klass->user_data.glyph_extents); } - inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, + hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, hb_position_t *x, hb_position_t *y) { *x = *y = 0; @@ -333,8 +337,8 @@ struct hb_font_t klass->user_data.glyph_contour_point); } - inline hb_bool_t get_glyph_name (hb_codepoint_t glyph, - char *name, unsigned int size) + hb_bool_t get_glyph_name (hb_codepoint_t glyph, + char *name, unsigned int size) { if (size) *name = '\0'; return klass->get.f.glyph_name (this, user_data, @@ -343,8 +347,8 @@ struct hb_font_t klass->user_data.glyph_name); } - inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) + hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) { *glyph = 0; if (len == -1) len = strlen (name); @@ -357,7 +361,7 @@ struct hb_font_t /* A bit higher-level, and with fallback */ - inline void get_h_extents_with_fallback (hb_font_extents_t *extents) + void get_h_extents_with_fallback (hb_font_extents_t *extents) { if (!get_font_h_extents (extents)) { @@ -366,7 +370,7 @@ struct hb_font_t extents->line_gap = 0; } } - inline void get_v_extents_with_fallback (hb_font_extents_t *extents) + void get_v_extents_with_fallback (hb_font_extents_t *extents) { if (!get_font_v_extents (extents)) { @@ -376,8 +380,8 @@ struct hb_font_t } } - inline void get_extents_for_direction (hb_direction_t direction, - hb_font_extents_t *extents) + void get_extents_for_direction (hb_direction_t direction, + hb_font_extents_t *extents) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) get_h_extents_with_fallback (extents); @@ -385,9 +389,9 @@ struct hb_font_t get_v_extents_with_fallback (extents); } - inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + void get_glyph_advance_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { *x = *y = 0; if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) @@ -395,12 +399,12 @@ struct hb_font_t else *y = get_glyph_v_advance (glyph); } - inline void get_glyph_advances_for_direction (hb_direction_t direction, - unsigned int count, - const hb_codepoint_t *first_glyph, - unsigned glyph_stride, - hb_position_t *first_advance, - unsigned advance_stride) + void get_glyph_advances_for_direction (hb_direction_t direction, + unsigned int count, + const hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); @@ -408,8 +412,8 @@ struct hb_font_t get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); } - inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { *x = get_glyph_h_advance (glyph) / 2; @@ -419,8 +423,8 @@ struct hb_font_t *y = extents.ascender; } - inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { if (!get_glyph_h_origin (glyph, x, y) && get_glyph_v_origin (glyph, x, y)) @@ -430,8 +434,8 @@ struct hb_font_t *x -= dx; *y -= dy; } } - inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { if (!get_glyph_v_origin (glyph, x, y) && get_glyph_h_origin (glyph, x, y)) @@ -442,9 +446,9 @@ struct hb_font_t } } - inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + void get_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) get_glyph_h_origin_with_fallback (glyph, x, y); @@ -452,8 +456,8 @@ struct hb_font_t get_glyph_v_origin_with_fallback (glyph, x, y); } - inline void add_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void add_glyph_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -462,8 +466,8 @@ struct hb_font_t *x += origin_x; *y += origin_y; } - inline void add_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void add_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -472,9 +476,9 @@ struct hb_font_t *x += origin_x; *y += origin_y; } - inline void add_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + void add_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -484,8 +488,8 @@ struct hb_font_t *y += origin_y; } - inline void subtract_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void subtract_glyph_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -494,8 +498,8 @@ struct hb_font_t *x -= origin_x; *y -= origin_y; } - inline void subtract_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) + void subtract_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -504,9 +508,9 @@ struct hb_font_t *x -= origin_x; *y -= origin_y; } - inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { hb_position_t origin_x, origin_y; @@ -516,9 +520,9 @@ struct hb_font_t *y -= origin_y; } - inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { *y = 0; @@ -529,9 +533,9 @@ struct hb_font_t } } - inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, - hb_direction_t direction, - hb_glyph_extents_t *extents) + hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, + hb_direction_t direction, + hb_glyph_extents_t *extents) { hb_bool_t ret = get_glyph_extents (glyph, extents); @@ -541,9 +545,9 @@ struct hb_font_t return ret; } - inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) + hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) { hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y); @@ -554,7 +558,7 @@ struct hb_font_t } /* Generates gidDDD if glyph has no name. */ - inline void + void glyph_to_string (hb_codepoint_t glyph, char *s, unsigned int size) { @@ -565,7 +569,7 @@ struct hb_font_t } /* Parses gidDDD and uniUUUU strings automatically. */ - inline hb_bool_t + hb_bool_t glyph_from_string (const char *s, int len, /* -1 means nul-terminated */ hb_codepoint_t *glyph) { @@ -595,21 +599,17 @@ struct hb_font_t return false; } - inline hb_position_t em_scale (int16_t v, int scale) + hb_position_t em_scale (int16_t v, int scale) { int upem = face->get_upem (); int64_t scaled = v * (int64_t) scale; scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */ return (hb_position_t) (scaled / upem); } - inline hb_position_t em_scalef (float v, int scale) - { - return (hb_position_t) round (v * scale / face->get_upem ()); - } - inline float em_fscale (int16_t v, int scale) - { - return (float) v * scale / face->get_upem (); - } + hb_position_t em_scalef (float v, int scale) + { return (hb_position_t) round (v * scale / face->get_upem ()); } + float em_fscale (int16_t v, int scale) + { return (float) v * scale / face->get_upem (); } }; DECLARE_NULL_INSTANCE (hb_font_t); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc index 633e0ecd2c8..5f6e3808756 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -479,12 +479,12 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED, } #if HB_USE_ATEXIT -static void free_static_ft_funcs (void); +static void free_static_ft_funcs (); #endif static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ft_font_funcs_lazy_loader_t> { - static inline hb_font_funcs_t *create (void) + static hb_font_funcs_t *create () { hb_font_funcs_t *funcs = hb_font_funcs_create (); @@ -514,14 +514,14 @@ static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ft #if HB_USE_ATEXIT static -void free_static_ft_funcs (void) +void free_static_ft_funcs () { static_ft_funcs.free_instance (); } #endif static hb_font_funcs_t * -_hb_ft_get_font_funcs (void) +_hb_ft_get_font_funcs () { return static_ft_funcs.get_unconst (); } @@ -745,13 +745,13 @@ hb_ft_font_create_referenced (FT_Face ft_face) } #if HB_USE_ATEXIT -static void free_static_ft_library (void); +static void free_static_ft_library (); #endif 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) + static FT_Library create () { FT_Library l; if (FT_Init_FreeType (&l)) @@ -763,11 +763,11 @@ static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer ( return l; } - static inline void destroy (FT_Library l) + static void destroy (FT_Library l) { FT_Done_FreeType (l); } - static inline FT_Library get_null (void) + static FT_Library get_null () { return nullptr; } @@ -775,14 +775,14 @@ static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer ( #if HB_USE_ATEXIT static -void free_static_ft_library (void) +void free_static_ft_library () { static_ft_library.free_instance (); } #endif static FT_Library -get_ft_library (void) +get_ft_library () { return static_ft_library.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc index cb7e7096e34..576375460bc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-glib.cc @@ -337,12 +337,12 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, #if HB_USE_ATEXIT -static void free_static_glib_funcs (void); +static void free_static_glib_funcs (); #endif static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t<hb_glib_unicode_funcs_lazy_loader_t> { - static inline hb_unicode_funcs_t *create (void) + static hb_unicode_funcs_t *create () { hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr); @@ -365,14 +365,14 @@ static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader #if HB_USE_ATEXIT static -void free_static_glib_funcs (void) +void free_static_glib_funcs () { static_glib_funcs.free_instance (); } #endif hb_unicode_funcs_t * -hb_glib_get_unicode_funcs (void) +hb_glib_get_unicode_funcs () { return static_glib_funcs.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl index e056df47891..e3a9a6b3fc0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.cc.tmpl @@ -46,7 +46,7 @@ /*** BEGIN value-header ***/ GType -@enum_name@_get_type (void) +@enum_name@_get_type () { static gsize type_id = 0; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.h.tmpl b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.h.tmpl index 606727cd32d..7ef9dfc0295 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.h.tmpl +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-enums.h.tmpl @@ -43,7 +43,7 @@ HB_BEGIN_DECLS /*** BEGIN value-header ***/ HB_EXTERN GType -@enum_name@_get_type (void) G_GNUC_CONST; +@enum_name@_get_type () G_GNUC_CONST; #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) /*** END value-header ***/ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc index 23ca43656d0..846240e9322 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-gobject-structs.cc @@ -51,7 +51,7 @@ #define HB_DEFINE_BOXED_TYPE(name,copy_func,free_func) \ GType \ -hb_gobject_##name##_get_type (void) \ +hb_gobject_##name##_get_type () \ { \ static gsize type_id = 0; \ if (g_once_init_enter (&type_id)) { \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc index 287f863404d..c26c91d484a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-icu.cc @@ -302,12 +302,12 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, #if HB_USE_ATEXIT -static void free_static_icu_funcs (void); +static void free_static_icu_funcs (); #endif static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t<hb_icu_unicode_funcs_lazy_loader_t> { - static inline hb_unicode_funcs_t *create (void) + static hb_unicode_funcs_t *create () { void *user_data = nullptr; #if U_ICU_VERSION_MAJOR_NUM >= 49 @@ -337,14 +337,14 @@ static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_ #if HB_USE_ATEXIT static -void free_static_icu_funcs (void) +void free_static_icu_funcs () { static_icu_funcs.free_instance (); } #endif hb_unicode_funcs_t * -hb_icu_get_unicode_funcs (void) +hb_icu_get_unicode_funcs () { return static_icu_funcs.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh deleted file mode 100644 index 6fd6aed79a7..00000000000 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright © 2018 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_ITER_HH -#define HB_ITER_HH - -#include "hb.hh" - - -/* Unified iterator object. - * - * The goal of this template is to make the same iterator interface - * available to all types, and make it very easy and compact to use. - * Iterator objects are small, light-weight, objects that can be - * copied by value. If the collection / object being iterated on - * is writable, then the iterator points to lvalues, otherwise it - * returns rvalues. - * - * The way to declare, initialize, and use iterators, eg.: - * - * Iter<const int *> s (src); - * Iter<int *> t (dst); - * for (; s && t; s++, t++) - * *s = *t; - */ - -template <typename T> -struct Iter; - -#if 0 -template <typename T> -struct Iter -{ - explicit inline Iter (const T &c); -}; -#endif - -template <typename T> -struct Iter<T *> -{ - /* Type of items. */ - typedef T Value; - - /* Constructors. */ - inline Iter (T *array_, int length_) : - array (array_), length (MAX (length_, 0)) {} - template <unsigned int length_> - explicit inline Iter (T (&array_)[length_]) : - array (array_), length (length_) {} - - /* Emptiness. */ - explicit_operator inline operator bool (void) const { return bool (length); } - - /* Current item. */ - inline T &operator * (void) - { - if (unlikely (!length)) return CrapOrNull(T); - return *array; - } - inline T &operator -> (void) - { - return (operator *); - } - - /* Next. */ - inline Iter<T *> & operator ++ (void) - { - if (unlikely (!length)) return *this; - array++; - length--; - return *this; - } - /* Might return void, or a copy of pre-increment iterator. */ - inline void operator ++ (int) - { - if (unlikely (!length)) return; - array++; - length--; - } - - /* Some iterators might implement len(). */ - inline unsigned int len (void) const { return length; } - - /* Some iterators might implement fast-forward. - * Only implement it if it's constant-time. */ - inline void operator += (unsigned int n) - { - n = MIN (n, length); - array += n; - length -= n; - } - - /* Some iterators might implement random-access. - * Only implement it if it's constant-time. */ - inline Iter<T *> & operator [] (unsigned int i) - { - if (unlikely (i >= length)) return CrapOrNull(T); - return array[i]; - } - - private: - T *array; - unsigned int length; -}; - -/* XXX Remove - * Just to test these compile. */ -static inline void -m (void) -{ - const int src[10] = {}; - int dst[20]; - - Iter<const int *> s (src); - Iter<const int *> s2 (src, 5); - Iter<int *> t (dst); - - s2 = s; - - for (; s && t; ++s, ++t) - { - *t = *s; - } -} - -#endif /* HB_ITER_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-kern.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-kern.hh index aa01b470f29..fd5bb9e45ef 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-kern.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-kern.hh @@ -44,10 +44,10 @@ struct hb_kern_machine_t 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 + 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); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh index 39e962936db..9d2ae95556b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh @@ -32,7 +32,7 @@ #include "hb.hh" #include "hb-blob.hh" -#include "hb-iter.hh" +#include "hb-array.hh" #include "hb-vector.hh" @@ -81,14 +81,14 @@ 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 \ + void _instance_assertion_on_line_##_line () const \ { static_assert ((_assertion), ""); } # define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) # define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion) /* Check that _code compiles in a method environment */ #define _DEFINE_COMPILES_ASSERTION1(_line, _code) \ - inline void _compiles_assertion_on_line_##_line (void) const \ + void _compiles_assertion_on_line_##_line () const \ { _code; } # define _DEFINE_COMPILES_ASSERTION0(_line, _code) _DEFINE_COMPILES_ASSERTION1 (_line, _code) # define DEFINE_COMPILES_ASSERTION(_code) _DEFINE_COMPILES_ASSERTION0 (__LINE__, _code) @@ -96,7 +96,7 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_STATIC(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \ - inline unsigned int get_size (void) const { return (size); } \ + unsigned int get_size () const { return (size); } \ enum { null_size = (size) }; \ enum { min_size = (size) }; \ enum { static_size = (size) } @@ -123,7 +123,7 @@ static inline Type& StructAfter(TObject &X) enum { min_size = (size) } #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ - inline unsigned int get_size (void) const { return (size - (array).min_size + (array).get_size ()); } \ + unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \ DEFINE_SIZE_ARRAY(size, array) @@ -137,8 +137,9 @@ 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 HB_UNUSED, const F *format HB_UNUSED) { return true; } - static return_t no_dispatch_return_value (void) { return Context::default_return_value (); } + bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; } + static return_t no_dispatch_return_value () { return Context::default_return_value (); } + static bool stop_sublookup_iteration (const return_t r HB_UNUSED) { return false; } }; @@ -225,7 +226,7 @@ struct hb_dispatch_context_t struct hb_sanitize_context_t : hb_dispatch_context_t<hb_sanitize_context_t, bool, HB_DEBUG_SANITIZE> { - inline hb_sanitize_context_t (void) : + hb_sanitize_context_t () : debug_depth (0), start (nullptr), end (nullptr), max_ops (0), @@ -234,33 +235,33 @@ struct hb_sanitize_context_t : num_glyphs (65536), num_glyphs_set (false) {} - inline const char *get_name (void) { return "SANITIZE"; } + const char *get_name () { return "SANITIZE"; } template <typename T, typename F> - inline bool may_dispatch (const T *obj HB_UNUSED, const F *format) + 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); } - static return_t default_return_value (void) { return true; } - static return_t no_dispatch_return_value (void) { return false; } + return_t dispatch (const T &obj) { return obj.sanitize (this); } + static return_t default_return_value () { return true; } + static return_t no_dispatch_return_value () { return false; } bool stop_sublookup_iteration (const return_t r) const { return !r; } - inline void init (hb_blob_t *b) + void init (hb_blob_t *b) { this->blob = hb_blob_reference (b); this->writable = false; } - inline void set_num_glyphs (unsigned int num_glyphs_) + void set_num_glyphs (unsigned int num_glyphs_) { num_glyphs = num_glyphs_; num_glyphs_set = true; } - inline unsigned int get_num_glyphs (void) { return num_glyphs; } + unsigned int get_num_glyphs () { return num_glyphs; } - inline void set_max_ops (int max_ops_) { max_ops = max_ops_; } + void set_max_ops (int max_ops_) { max_ops = max_ops_; } template <typename T> - inline void set_object (const T *obj) + void set_object (const T *obj) { reset_object (); @@ -279,14 +280,14 @@ struct hb_sanitize_context_t : } } - inline void reset_object (void) + void reset_object () { 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) + void start_processing () { reset_object (); this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR, @@ -300,7 +301,7 @@ struct hb_sanitize_context_t : (unsigned long) (this->end - this->start)); } - inline void end_processing (void) + void end_processing () { DEBUG_MSG_LEVEL (SANITIZE, this->start, 0, -1, "end [%p..%p] %u edit requests", @@ -311,7 +312,7 @@ struct hb_sanitize_context_t : this->start = this->end = nullptr; } - inline bool check_range (const void *base, + bool check_range (const void *base, unsigned int len) const { const char *p = (const char *) base; @@ -330,7 +331,7 @@ struct hb_sanitize_context_t : } template <typename T> - inline bool check_range (const T *base, + bool check_range (const T *base, unsigned int a, unsigned int b) const { @@ -339,7 +340,7 @@ struct hb_sanitize_context_t : } template <typename T> - inline bool check_range (const T *base, + bool check_range (const T *base, unsigned int a, unsigned int b, unsigned int c) const @@ -349,27 +350,24 @@ struct hb_sanitize_context_t : } template <typename T> - inline bool check_array (const T *base, - unsigned int len) const + bool check_array (const T *base, unsigned int len) const { - return this->check_range (base, len, T::static_size); + return this->check_range (base, len, hb_static_size (T)); } template <typename T> - inline bool check_array (const T *base, - unsigned int a, - unsigned int b) const + bool check_array (const T *base, + unsigned int a, + unsigned int b) const { - return this->check_range (base, a, b, T::static_size); + return this->check_range (base, a, b, hb_static_size (T)); } template <typename Type> - inline bool check_struct (const Type *obj) const - { - return likely (this->check_range (obj, obj->min_size)); - } + bool check_struct (const Type *obj) const + { return likely (this->check_range (obj, obj->min_size)); } - inline bool may_edit (const void *base, unsigned int len) + bool may_edit (const void *base, unsigned int len) { if (this->edit_count >= HB_SANITIZE_MAX_EDITS) return false; @@ -388,16 +386,18 @@ struct hb_sanitize_context_t : } template <typename Type, typename ValueType> - inline bool try_set (const Type *obj, const ValueType &v) { - if (this->may_edit (obj, obj->static_size)) { - const_cast<Type *> (obj)->set (v); + bool try_set (const Type *obj, const ValueType &v) + { + if (this->may_edit (obj, hb_static_size (Type))) + { + hb_assign (* const_cast<Type *> (obj), v); return true; } return false; } template <typename Type> - inline hb_blob_t *sanitize_blob (hb_blob_t *blob) + hb_blob_t *sanitize_blob (hb_blob_t *blob) { bool sane; @@ -464,7 +464,7 @@ struct hb_sanitize_context_t : } template <typename Type> - inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) + hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) { if (!num_glyphs_set) set_num_glyphs (hb_face_get_glyph_count (face)); @@ -485,15 +485,11 @@ struct hb_sanitize_context_t : struct hb_sanitize_with_object_t { template <typename T> - inline hb_sanitize_with_object_t (hb_sanitize_context_t *c, + 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 (); - } + { c->set_object (obj); } + ~hb_sanitize_with_object_t () + { c->reset_object (); } private: hb_sanitize_context_t *c; @@ -506,25 +502,42 @@ struct hb_sanitize_with_object_t struct hb_serialize_context_t { - inline hb_serialize_context_t (void *start_, unsigned int size) + hb_serialize_context_t (void *start_, unsigned int size) { this->start = (char *) start_; this->end = this->start + size; reset (); } - inline void reset (void) + bool in_error () const { return !this->successful; } + + void reset () { - this->ran_out_of_room = false; + this->successful = true; this->head = this->start; this->debug_depth = 0; } - inline bool err (bool e) { return this->ran_out_of_room = this->ran_out_of_room || e; } + bool propagate_error (bool e) + { return this->successful = this->successful && e; } + template <typename T> bool propagate_error (const T &obj) + { return this->successful = this->successful && !obj.in_error (); } + template <typename T> bool propagate_error (const T *obj) + { return this->successful = this->successful && !obj->in_error (); } + template <typename T1, typename T2> bool propagate_error (T1 &o1, T2 &o2) + { return propagate_error (o1) && propagate_error (o2); } + template <typename T1, typename T2> bool propagate_error (T1 *o1, T2 *o2) + { return propagate_error (o1) && propagate_error (o2); } + template <typename T1, typename T2, typename T3> + bool propagate_error (T1 &o1, T2 &o2, T3 &o3) + { return propagate_error (o1) && propagate_error (o2, o3); } + template <typename T1, typename T2, typename T3> + bool propagate_error (T1 *o1, T2 *o2, T3 *o3) + { return propagate_error (o1) && propagate_error (o2, o3); } /* To be called around main operation. */ template <typename Type> - inline Type *start_serialize (void) + Type *start_serialize () { DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, +1, "start [%p..%p] (%lu bytes)", @@ -533,18 +546,18 @@ struct hb_serialize_context_t return start_embed<Type> (); } - inline void end_serialize (void) + void end_serialize () { DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1, "end [%p..%p] serialized %d bytes; %s", this->start, this->end, (int) (this->head - this->start), - this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room"); + this->successful ? "successful" : "UNSUCCESSFUL"); } - inline unsigned int length (void) const { return this->head - this->start; } + unsigned int length () const { return this->head - this->start; } - inline void align (unsigned int alignment) + void align (unsigned int alignment) { unsigned int l = length () % alignment; if (l) @@ -552,17 +565,17 @@ struct hb_serialize_context_t } template <typename Type> - inline Type *start_embed (void) const + Type *start_embed (const Type *_ HB_UNUSED = nullptr) const { Type *ret = reinterpret_cast<Type *> (this->head); return ret; } template <typename Type> - inline Type *allocate_size (unsigned int size) + Type *allocate_size (unsigned int size) { - if (unlikely (this->ran_out_of_room || this->end - this->head < ptrdiff_t (size))) { - this->ran_out_of_room = true; + if (unlikely (!this->successful || this->end - this->head < ptrdiff_t (size))) { + this->successful = false; return nullptr; } memset (this->head, 0, size); @@ -572,13 +585,13 @@ struct hb_serialize_context_t } template <typename Type> - inline Type *allocate_min (void) + Type *allocate_min () { return this->allocate_size<Type> (Type::min_size); } template <typename Type> - inline Type *embed (const Type &obj) + Type *embed (const Type &obj) { unsigned int size = obj.get_size (); Type *ret = this->allocate_size<Type> (size); @@ -586,50 +599,50 @@ struct hb_serialize_context_t memcpy (ret, &obj, size); return ret; } + template <typename Type> + hb_serialize_context_t &operator << (const Type &obj) { embed (obj); return *this; } template <typename Type> - inline Type *extend_min (Type &obj) + Type *extend_size (Type &obj, unsigned int size) { - unsigned int size = obj.min_size; - assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); + assert (this->start <= (char *) &obj); + assert ((char *) &obj <= this->head); + assert ((char *) &obj + size >= this->head); if (unlikely (!this->allocate_size<Type> (((char *) &obj) + size - this->head))) return nullptr; return reinterpret_cast<Type *> (&obj); } template <typename Type> - inline Type *extend (Type &obj) - { - unsigned int size = obj.get_size (); - assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size<Type> (((char *) &obj) + size - this->head))) return nullptr; - return reinterpret_cast<Type *> (&obj); - } + Type *extend_min (Type &obj) { return extend_size (obj, obj.min_size); } + + template <typename Type> + Type *extend (Type &obj) { return extend_size (obj, obj.get_size ()); } /* Output routines. */ template <typename Type> - inline Type *copy (void) const + Type *copy () const { - assert (!this->ran_out_of_room); + assert (this->successful); unsigned int len = this->head - this->start; void *p = malloc (len); if (p) memcpy (p, this->start, len); return reinterpret_cast<Type *> (p); } - inline hb_bytes_t copy_bytes (void) const + hb_bytes_t copy_bytes () const { - assert (!this->ran_out_of_room); + assert (this->successful); unsigned int len = this->head - this->start; void *p = malloc (len); if (p) memcpy (p, this->start, len); else return hb_bytes_t (); - return hb_bytes_t (p, len); + return hb_bytes_t ((char *) p, len); } - inline hb_blob_t *copy_blob (void) const + hb_blob_t *copy_blob () const { - assert (!this->ran_out_of_room); + assert (this->successful); return hb_blob_create (this->start, this->head - this->start, HB_MEMORY_MODE_DUPLICATE, @@ -639,54 +652,10 @@ struct hb_serialize_context_t public: unsigned int debug_depth; char *start, *end, *head; - bool ran_out_of_room; + bool successful; }; -/* - * Supplier - */ - -template <typename Type> -struct Supplier -{ - inline Supplier (const Type *array, unsigned int len_, unsigned int stride_=sizeof (Type)) - { - head = array; - len = len_; - stride = stride_; - } - inline Supplier (const hb_vector_t<Type> *v) - { - head = *v; - len = v->len; - stride = sizeof (Type); - } - - inline const Type operator [] (unsigned int i) const - { - if (unlikely (i >= len)) return Type (); - return * (const Type *) (const void *) ((const char *) head + stride * i); - } - - inline Supplier<Type> & operator += (unsigned int count) - { - if (unlikely (count > len)) - count = len; - len -= count; - head = (const Type *) (const void *) ((const char *) head + stride * count); - return *this; - } - - private: - inline Supplier (const Supplier<Type> &); /* Disallow copy */ - inline Supplier<Type>& operator= (const Supplier<Type> &); /* Disallow copy */ - - unsigned int len; - unsigned int stride; - const Type *head; -}; - /* * Big-endian integers. @@ -699,14 +668,8 @@ struct BEInt<Type, 1> { public: typedef Type type; - inline void set (Type V) - { - v = V; - } - inline operator Type (void) const - { - return v; - } + void set (Type V) { v = V; } + operator Type () const { return v; } private: uint8_t v; }; template <typename Type> @@ -714,18 +677,24 @@ struct BEInt<Type, 2> { public: typedef Type type; - inline void set (Type V) + void set (Type V) { v[0] = (V >> 8) & 0xFF; v[1] = (V ) & 0xFF; } - inline operator Type (void) const + operator Type () const { -#if defined(__GNUC__) || defined(__clang__) +#if ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) && \ + defined(__BYTE_ORDER) && \ + (__BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __BIG_ENDIAN) /* 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; }; +#if __BYTE_ORDER == __LITTLE_ENDIAN return __builtin_bswap16 (((packed_uint16_t *) this)->v); +#else /* __BYTE_ORDER == __BIG_ENDIAN */ + return ((packed_uint16_t *) this)->v; +#endif #endif return (v[0] << 8) + (v[1] ); @@ -737,13 +706,13 @@ struct BEInt<Type, 3> { public: typedef Type type; - inline void set (Type V) + void set (Type V) { v[0] = (V >> 16) & 0xFF; v[1] = (V >> 8) & 0xFF; v[2] = (V ) & 0xFF; } - inline operator Type (void) const + operator Type () const { return (v[0] << 16) + (v[1] << 8) @@ -756,14 +725,14 @@ struct BEInt<Type, 4> { public: typedef Type type; - inline void set (Type V) + void set (Type V) { v[0] = (V >> 24) & 0xFF; v[1] = (V >> 16) & 0xFF; v[2] = (V >> 8) & 0xFF; v[3] = (V ) & 0xFF; } - inline operator Type (void) const + operator Type () const { return (v[0] << 24) + (v[1] << 16) @@ -783,23 +752,21 @@ struct hb_data_wrapper_t { static_assert (WheresData > 0, ""); - inline Data * get_data (void) const - { - return *(((Data **) (void *) this) - WheresData); - } + Data * get_data () const + { return *(((Data **) (void *) this) - WheresData); } - inline bool is_inert (void) const { return !get_data (); } + bool is_inert () const { return !get_data (); } template <typename Stored, typename Subclass> - inline Stored * call_create (void) const { return Subclass::create (get_data ()); } + Stored * call_create () const { return Subclass::create (get_data ()); } }; template <> struct hb_data_wrapper_t<void, 0> { - inline bool is_inert (void) const { return false; } + bool is_inert () const { return false; } template <typename Stored, typename Funcs> - inline Stored * call_create (void) const { return Funcs::create (); } + Stored * call_create () const { return Funcs::create (); } }; template <typename T1, typename T2> struct hb_non_void_t { typedef T1 value; }; @@ -816,13 +783,11 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData> hb_lazy_loader_t<Returned,Subclass,Data,WheresData,Stored> >::value Funcs; - inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ - inline void init (void) { instance.set_relaxed (nullptr); } - inline void fini (void) - { - do_destroy (instance.get ()); - } - inline void free_instance (void) + void init0 () {} /* Init, when memory is already set to 0. No-op for us. */ + void init () { instance.set_relaxed (nullptr); } + void fini () { do_destroy (instance.get ()); } + + void free_instance () { retry: Stored *p = instance.get (); @@ -831,19 +796,19 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData> do_destroy (p); } - static inline void do_destroy (Stored *p) + static void do_destroy (Stored *p) { 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 (); } - explicit_operator inline operator bool (void) const + const Returned * operator -> () const { return get (); } + const Returned & operator * () const { return *get (); } + explicit_operator bool () const { return get_stored () != Funcs::get_null (); } - template <typename C> inline operator const C * (void) const { return get (); } + template <typename C> operator const C * () const { return get (); } - inline Stored * get_stored (void) const + Stored * get_stored () const { retry: Stored *p = this->instance.get (); @@ -864,41 +829,41 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData> } return p; } - inline Stored * get_stored_relaxed (void) const + Stored * get_stored_relaxed () const { return this->instance.get_relaxed (); } - inline bool cmpexch (Stored *current, Stored *value) const + bool cmpexch (Stored *current, Stored *value) const { /* 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 ()); } - inline const Returned * get_relaxed (void) const { return Funcs::convert (get_stored_relaxed ()); } - inline Returned * get_unconst (void) const { return const_cast<Returned *> (Funcs::convert (get_stored ())); } + const Returned * get () const { return Funcs::convert (get_stored ()); } + const Returned * get_relaxed () const { return Funcs::convert (get_stored_relaxed ()); } + Returned * get_unconst () const { return const_cast<Returned *> (Funcs::convert (get_stored ())); } /* To be possibly overloaded by subclasses. */ - static inline Returned* convert (Stored *p) { return p; } + static Returned* convert (Stored *p) { return p; } /* By default null/init/fini the object. */ - static inline const Stored* get_null (void) { return &Null(Stored); } - static inline Stored *create (Data *data) + static const Stored* get_null () { return &Null(Stored); } + static Stored *create (Data *data) { Stored *p = (Stored *) calloc (1, sizeof (Stored)); if (likely (p)) p->init (data); return p; } - static inline Stored *create (void) + static Stored *create () { Stored *p = (Stored *) calloc (1, sizeof (Stored)); if (likely (p)) p->init (); return p; } - static inline void destroy (Stored *p) + static void destroy (Stored *p) { p->fini (); free (p); @@ -922,52 +887,34 @@ struct hb_table_lazy_loader_t : hb_lazy_loader_t<T, hb_face_t, WheresFace, hb_blob_t> { - static inline hb_blob_t *create (hb_face_t *face) - { - return hb_sanitize_context_t ().reference_table<T> (face); - } - static inline void destroy (hb_blob_t *p) - { - hb_blob_destroy (p); - } - static inline const hb_blob_t *get_null (void) - { - return hb_blob_get_empty (); - } - static inline const T* convert (const hb_blob_t *blob) - { - return blob->as<T> (); - } + static hb_blob_t *create (hb_face_t *face) + { return hb_sanitize_context_t ().reference_table<T> (face); } + static void destroy (hb_blob_t *p) { hb_blob_destroy (p); } - inline hb_blob_t* get_blob (void) const - { - return this->get_stored (); - } + static const hb_blob_t *get_null () + { return hb_blob_get_empty (); } + + static const T* convert (const hb_blob_t *blob) + { return blob->as<T> (); } + + hb_blob_t* get_blob () const { return this->get_stored (); } }; template <typename Subclass> struct hb_font_funcs_lazy_loader_t : hb_lazy_loader_t<hb_font_funcs_t, Subclass> { - static inline void destroy (hb_font_funcs_t *p) - { - hb_font_funcs_destroy (p); - } - static inline const hb_font_funcs_t *get_null (void) - { - return hb_font_funcs_get_empty (); - } + static void destroy (hb_font_funcs_t *p) + { hb_font_funcs_destroy (p); } + static const hb_font_funcs_t *get_null () + { return hb_font_funcs_get_empty (); } }; template <typename Subclass> struct hb_unicode_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unicode_funcs_t, Subclass> { - static inline void destroy (hb_unicode_funcs_t *p) - { - hb_unicode_funcs_destroy (p); - } - static inline const hb_unicode_funcs_t *get_null (void) - { - return hb_unicode_funcs_get_empty (); - } + static void destroy (hb_unicode_funcs_t *p) + { hb_unicode_funcs_destroy (p); } + static const hb_unicode_funcs_t *get_null () + { return hb_unicode_funcs_get_empty (); } }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc index 067a2b37169..a2c770c586d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.cc @@ -47,7 +47,7 @@ * Since: 1.7.7 **/ hb_map_t * -hb_map_create (void) +hb_map_create () { hb_map_t *map; @@ -67,7 +67,7 @@ hb_map_create (void) * Since: 1.7.7 **/ hb_map_t * -hb_map_get_empty (void) +hb_map_get_empty () { return const_cast<hb_map_t *> (&Null(hb_map_t)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh index c54c9d7b640..3b119daa8e2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh @@ -45,16 +45,16 @@ 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 (); } + hb_map_t () { init (); } + ~hb_map_t () { fini (); } struct item_t { hb_codepoint_t key; hb_codepoint_t value; - inline bool is_unused (void) const { return key == INVALID; } - inline bool is_tombstone (void) const { return key != INVALID && value == INVALID; } + bool is_unused () const { return key == INVALID; } + bool is_tombstone () const { return key != INVALID && value == INVALID; } }; hb_object_header_t header; @@ -65,7 +65,7 @@ struct hb_map_t unsigned int prime; item_t *items; - inline void init_shallow (void) + void init_shallow () { successful = true; population = occupancy = 0; @@ -73,24 +73,26 @@ struct hb_map_t prime = 0; items = nullptr; } - inline void init (void) + void init () { hb_object_init (this); init_shallow (); } - inline void fini_shallow (void) + void fini_shallow () { free (items); items = nullptr; } - inline void fini (void) + void fini () { population = occupancy = 0; hb_object_fini (this); fini_shallow (); } - inline bool resize (void) + bool in_error () const { return !successful; } + + bool resize () { if (unlikely (!successful)) return false; @@ -124,7 +126,7 @@ struct hb_map_t return true; } - inline void set (hb_codepoint_t key, hb_codepoint_t value) + void set (hb_codepoint_t key, hb_codepoint_t value) { if (unlikely (!successful)) return; if (unlikely (key == INVALID)) return; @@ -149,46 +151,36 @@ struct hb_map_t population++; } - inline hb_codepoint_t get (hb_codepoint_t key) const + hb_codepoint_t get (hb_codepoint_t key) const { if (unlikely (!items)) return INVALID; unsigned int i = bucket_for (key); return items[i].key == key ? items[i].value : INVALID; } - inline void del (hb_codepoint_t key) - { - set (key, INVALID); - } - inline bool has (hb_codepoint_t key) const - { - return get (key) != INVALID; - } + void del (hb_codepoint_t key) { set (key, INVALID); } - inline hb_codepoint_t operator [] (unsigned int key) const + bool has (hb_codepoint_t key) const + { return get (key) != INVALID; } + + hb_codepoint_t operator [] (unsigned int key) const { return get (key); } - static const hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID; + enum { INVALID = HB_MAP_VALUE_INVALID }; - inline void clear (void) + void clear () { memset (items, 0xFF, ((size_t) mask + 1) * sizeof (item_t)); population = occupancy = 0; } - inline bool is_empty (void) const - { - return population == 0; - } + bool is_empty () const { return population == 0; } - inline unsigned int get_population () const - { - return population; - } + unsigned int get_population () const { return population; } protected: - inline unsigned int bucket_for (hb_codepoint_t key) const + unsigned int bucket_for (hb_codepoint_t key) const { unsigned int i = Hash (key) % prime; unsigned int step = 0; @@ -204,7 +196,7 @@ struct hb_map_t return tombstone == INVALID ? i : tombstone; } - static inline unsigned int prime_for (unsigned int shift) + static unsigned int prime_for (unsigned int shift) { /* Following comment and table copied from glib. */ /* Each table size has an associated prime modulo (the first prime diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh index b529091d44a..35f1fded1ef 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-mutex.hh @@ -131,16 +131,16 @@ struct hb_mutex_t hb_mutex_impl_t m; - inline void init (void) { hb_mutex_impl_init (&m); } - inline void lock (void) { hb_mutex_impl_lock (&m); } - inline void unlock (void) { hb_mutex_impl_unlock (&m); } - inline void fini (void) { hb_mutex_impl_finish (&m); } + void init () { hb_mutex_impl_init (&m); } + void lock () { hb_mutex_impl_lock (&m); } + void unlock () { hb_mutex_impl_unlock (&m); } + void fini () { 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 (); } + hb_lock_t (hb_mutex_t &mutex_) : mutex (mutex_) { mutex.lock (); } + ~hb_lock_t () { mutex.unlock (); } private: hb_mutex_t &mutex; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh index 1583d5b90e0..8a3e0d4056e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -36,7 +36,7 @@ /* Global nul-content Null pool. Enlarge as necessary. */ -#define HB_NULL_POOL_SIZE 1024 +#define HB_NULL_POOL_SIZE 9880 /* Use SFINAE to sniff whether T has min_size; in which case return T::null_size, * otherwise return sizeof(T). */ @@ -59,7 +59,10 @@ 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. */ +/* These doesn't belong here, but since is copy/paste from above, put it here. */ + +/* hb_static_size (T) + * Returns T::static_size if T::min_size is defined, or sizeof (T) otherwise. */ template <typename T, typename B> struct _hb_static_size @@ -74,26 +77,52 @@ struct hb_static_size #define hb_static_size(T) hb_static_size<T>::value +/* hb_assign (obj, value) + * Calls obj.set (value) if obj.min_size is defined and value has different type + * from obj, or obj = v otherwise. */ + +template <typename T, typename V, typename B> +struct _hb_assign +{ static inline void value (T &o, const V v) { o = v; } }; +template <typename T, typename V> +struct _hb_assign<T, V, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> > +{ static inline void value (T &o, const V v) { o.set (v); } }; +template <typename T> +struct _hb_assign<T, T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> > +{ static inline void value (T &o, const T v) { o = v; } }; + +template <typename T, typename V> +static inline void hb_assign (T &o, const V v) +{ _hb_assign<T, V, _hb_bool_type<true> >::value (o, v); }; + + /* * 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 inline Type const & Null () { 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<typename hb_remove_const (typename hb_remove_reference (Type))> () +template <typename QType> +struct NullHelper +{ + typedef typename hb_remove_const (typename hb_remove_reference (QType)) Type; + static const Type & get_null () { return Null<Type> (); } +}; +#define Null(Type) NullHelper<Type>::get_null () /* 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::null_size]; \ template <> \ - /*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \ + /*static*/ inline const Namespace::Type& Null<Namespace::Type> () { \ return *reinterpret_cast<const Namespace::Type *> (_hb_Null_##Namespace##_##Type); \ } \ namespace Namespace { \ @@ -105,7 +134,7 @@ static inline Type const & Null (void) { #define DECLARE_NULL_INSTANCE(Type) \ extern HB_INTERNAL const Type _hb_Null_##Type; \ template <> \ - /*static*/ inline const Type& Null<Type> (void) { \ + /*static*/ inline const Type& Null<Type> () { \ return _hb_Null_##Type; \ } \ static_assert (true, "Just so we take semicolon after.") @@ -123,23 +152,29 @@ extern HB_INTERNAL /* CRAP pool: Common Region for Access Protection. */ template <typename Type> -static inline Type& Crap (void) { +static inline Type& Crap () { static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); Type *obj = reinterpret_cast<Type *> (_hb_CrapPool); memcpy (obj, &Null(Type), sizeof (*obj)); return *obj; } -#define Crap(Type) Crap<typename hb_remove_const (typename hb_remove_reference (Type))> () +template <typename QType> +struct CrapHelper +{ + typedef typename hb_remove_const (typename hb_remove_reference (QType)) Type; + static Type & get_crap () { return Crap<Type> (); } +}; +#define Crap(Type) CrapHelper<Type>::get_crap () template <typename Type> -struct CrapOrNull { - static inline Type & get (void) { return Crap(Type); } +struct CrapOrNullHelper { + static Type & get () { return Crap(Type); } }; template <typename Type> -struct CrapOrNull<const Type> { - static inline Type const & get (void) { return Null(Type); } +struct CrapOrNullHelper<const Type> { + static const Type & get () { return Null(Type); } }; -#define CrapOrNull(Type) CrapOrNull<Type>::get () +#define CrapOrNull(Type) CrapOrNullHelper<Type>::get () /* @@ -151,16 +186,16 @@ 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; } + hb_nonnull_ptr_t (T *v_ = nullptr) : v (v_) {} + T * operator = (T *v_) { return v = v_; } + T * operator -> () const { return get (); } + T & operator * () const { return *get (); } + T ** operator & () 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; } + template <typename C> operator const C * () const { return get (); } + operator const char * () const { return (const char *) get (); } + T * get () const { return v ? v : const_cast<T *> (&Null(T)); } + T * get_raw () const { return v; } T *v; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh index cdacf49f4c1..6eb1173d82f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh @@ -47,10 +47,10 @@ struct hb_lockable_set_t { hb_vector_t <item_t, 1> items; - inline void init (void) { items.init (); } + void init () { items.init (); } template <typename T> - inline item_t *replace_or_insert (T v, lock_t &l, bool replace) + item_t *replace_or_insert (T v, lock_t &l, bool replace) { l.lock (); item_t *item = items.find (v); @@ -73,7 +73,7 @@ struct hb_lockable_set_t } template <typename T> - inline void remove (T v, lock_t &l) + void remove (T v, lock_t &l) { l.lock (); item_t *item = items.find (v); @@ -89,7 +89,7 @@ struct hb_lockable_set_t } template <typename T> - inline bool find (T v, item_t *i, lock_t &l) + bool find (T v, item_t *i, lock_t &l) { l.lock (); item_t *item = items.find (v); @@ -100,7 +100,7 @@ struct hb_lockable_set_t } template <typename T> - inline item_t *find_or_insert (T v, lock_t &l) + item_t *find_or_insert (T v, lock_t &l) { l.lock (); item_t *item = items.find (v); @@ -111,7 +111,7 @@ struct hb_lockable_set_t return item; } - inline void fini (lock_t &l) + void fini (lock_t &l) { if (!items.len) { /* No need for locking. */ @@ -145,14 +145,14 @@ struct hb_reference_count_t { mutable hb_atomic_int_t ref_count; - inline void init (int v = 1) { ref_count.set_relaxed (v); } - inline int get_relaxed (void) const { return ref_count.get_relaxed (); } - inline int inc (void) const { return ref_count.inc (); } - inline int dec (void) const { return ref_count.dec (); } - inline void fini (void) { ref_count.set_relaxed (HB_REFERENCE_COUNT_POISON_VALUE); } + void init (int v = 1) { ref_count.set_relaxed (v); } + int get_relaxed () const { return ref_count.get_relaxed (); } + int inc () const { return ref_count.inc (); } + int dec () const { return ref_count.dec (); } + void fini () { ref_count.set_relaxed (HB_REFERENCE_COUNT_POISON_VALUE); } - inline bool is_inert (void) const { return ref_count.get_relaxed () == HB_REFERENCE_COUNT_INERT_VALUE; } - inline bool is_valid (void) const { return ref_count.get_relaxed () > 0; } + bool is_inert () const { return ref_count.get_relaxed () == HB_REFERENCE_COUNT_INERT_VALUE; } + bool is_valid () const { return ref_count.get_relaxed () > 0; } }; @@ -165,16 +165,16 @@ struct hb_user_data_array_t void *data; hb_destroy_func_t destroy; - inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } - inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; } + bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } + bool operator == (hb_user_data_item_t &other) const { return key == other.key; } - void fini (void) { if (destroy) destroy (data); } + void fini () { if (destroy) destroy (data); } }; hb_mutex_t lock; hb_lockable_set_t<hb_user_data_item_t, hb_mutex_t> items; - inline void init (void) { lock.init (); items.init (); } + void init () { lock.init (); items.init (); } HB_INTERNAL bool set (hb_user_data_key_t *key, void * data, @@ -183,7 +183,7 @@ struct hb_user_data_array_t HB_INTERNAL void *get (hb_user_data_key_t *key); - inline void fini (void) { items.fini (lock); lock.fini (); } + void fini () { items.fini (lock); lock.fini (); } }; @@ -219,7 +219,7 @@ static inline void hb_object_trace (const Type *obj, const char *function) } template <typename Type> -static inline Type *hb_object_create (void) +static inline Type *hb_object_create () { Type *obj = (Type *) calloc (1, sizeof (Type)); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh index af68892ab11..822a92d3946 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh @@ -54,8 +54,7 @@ struct TTCHeader; typedef struct TableRecord { - int cmp (Tag t) const - { return -t.cmp (tag); } + int cmp (Tag t) const { return -t.cmp (tag); } static int cmp (const void *pa, const void *pb) { @@ -64,7 +63,7 @@ typedef struct TableRecord return b->cmp (a->tag); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -83,13 +82,10 @@ typedef struct OffsetTable { friend struct OpenTypeFontFile; - inline unsigned int get_table_count (void) const - { return tables.len; } - inline const TableRecord& get_table (unsigned int i) const - { - return tables[i]; - } - inline unsigned int get_table_tags (unsigned int start_offset, + unsigned int get_table_count () const { return tables.len; } + const TableRecord& get_table (unsigned int i) const + { return tables[i]; } + unsigned int get_table_tags (unsigned int start_offset, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */) const { @@ -107,13 +103,13 @@ typedef struct OffsetTable } return tables.len; } - inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const + bool find_table_index (hb_tag_t tag, unsigned int *table_index) const { Tag t; t.set (tag); 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 + const TableRecord& get_table_by_tag (hb_tag_t tag) const { unsigned int table_index; find_table_index (tag, &table_index); @@ -122,11 +118,10 @@ typedef struct OffsetTable public: - inline bool serialize (hb_serialize_context_t *c, - hb_tag_t sfnt_tag, - Supplier<hb_tag_t> &tags, - Supplier<hb_blob_t *> &blobs, - unsigned int table_count) + template <typename item_t> + bool serialize (hb_serialize_context_t *c, + hb_tag_t sfnt_tag, + hb_array_t<item_t> items) { TRACE_SERIALIZE (this); /* Alloc 12 for the OTHeader. */ @@ -135,17 +130,17 @@ typedef struct OffsetTable sfnt_version.set (sfnt_tag); /* Take space for numTables, searchRange, entrySelector, RangeShift * and the TableRecords themselves. */ - if (unlikely (!tables.serialize (c, table_count))) return_trace (false); + if (unlikely (!tables.serialize (c, items.len))) return_trace (false); const char *dir_end = (const char *) c->head; HBUINT32 *checksum_adjustment = nullptr; /* Write OffsetTables, alloc for and write actual table blobs. */ - for (unsigned int i = 0; i < table_count; i++) + for (unsigned int i = 0; i < tables.len; i++) { TableRecord &rec = tables.arrayZ[i]; - hb_blob_t *blob = blobs[i]; - rec.tag.set (tags[i]); + hb_blob_t *blob = items[i].blob; + rec.tag.set (items[i].tag); rec.length.set (hb_blob_get_length (blob)); rec.offset.serialize (c, this); @@ -159,7 +154,7 @@ typedef struct OffsetTable c->align (4); const char *end = (const char *) c->head; - if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size) + if (items[i].tag == HB_OT_TAG_head && end - start >= head::static_size) { head *h = (head *) start; checksum_adjustment = &h->checkSumAdjustment; @@ -168,8 +163,6 @@ typedef struct OffsetTable rec.checkSum.set_for_data (start, end - start); } - tags += table_count; - blobs += table_count; tables.qsort (); @@ -180,7 +173,7 @@ typedef struct OffsetTable /* The following line is a slower version of the following block. */ //checksum.set_for_data (this, (const char *) c->head - (const char *) this); checksum.set_for_data (this, dir_end - (const char *) this); - for (unsigned int i = 0; i < table_count; i++) + for (unsigned int i = 0; i < items.len; i++) { TableRecord &rec = tables.arrayZ[i]; checksum.set (checksum + rec.checkSum); @@ -192,7 +185,7 @@ typedef struct OffsetTable return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && tables.sanitize (c)); @@ -215,10 +208,10 @@ struct TTCHeaderVersion1 { friend struct TTCHeader; - inline unsigned int get_face_count (void) const { return table.len; } - inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } + unsigned int get_face_count () const { return table.len; } + const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (table.sanitize (c, this)); @@ -241,7 +234,7 @@ struct TTCHeader private: - inline unsigned int get_face_count (void) const + unsigned int get_face_count () const { switch (u.header.version.major) { case 2: /* version 2 is compatible with version 1 */ @@ -249,7 +242,7 @@ struct TTCHeader default:return 0; } } - inline const OpenTypeFontFace& get_face (unsigned int i) const + const OpenTypeFontFace& get_face (unsigned int i) const { switch (u.header.version.major) { case 2: /* version 2 is compatible with version 1 */ @@ -258,7 +251,7 @@ struct TTCHeader } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!u.header.version.sanitize (c))) return_trace (false); @@ -288,10 +281,10 @@ struct TTCHeader struct ResourceRecord { - inline const OpenTypeFontFace & get_face (const void *data_base) const + const OpenTypeFontFace & get_face (const void *data_base) const { return CastR<OpenTypeFontFace> ((data_base+offset).arrayZ); } - inline bool sanitize (hb_sanitize_context_t *c, + bool sanitize (hb_sanitize_context_t *c, const void *data_base) const { TRACE_SANITIZE (this); @@ -317,20 +310,18 @@ struct ResourceRecord struct ResourceTypeRecord { - inline unsigned int get_resource_count (void) const + unsigned int get_resource_count () const { return tag == HB_TAG_sfnt ? resCountM1 + 1 : 0; } - inline bool is_sfnt (void) const { return tag == HB_TAG_sfnt; } + bool is_sfnt () const { return tag == HB_TAG_sfnt; } - inline const ResourceRecord& get_resource_record (unsigned int i, - const void *type_base) const - { - return (type_base+resourcesZ).as_array (get_resource_count ())[i]; - } + const ResourceRecord& get_resource_record (unsigned int i, + const void *type_base) const + { return (type_base+resourcesZ).as_array (get_resource_count ())[i]; } - inline bool sanitize (hb_sanitize_context_t *c, - const void *type_base, - const void *data_base) const + bool sanitize (hb_sanitize_context_t *c, + const void *type_base, + const void *data_base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -351,7 +342,7 @@ struct ResourceTypeRecord struct ResourceMap { - inline unsigned int get_face_count (void) const + unsigned int get_face_count () const { unsigned int count = get_type_count (); for (unsigned int i = 0; i < count; i++) @@ -363,8 +354,8 @@ struct ResourceMap return 0; } - inline const OpenTypeFontFace& get_face (unsigned int idx, - const void *data_base) const + const OpenTypeFontFace& get_face (unsigned int idx, + const void *data_base) const { unsigned int count = get_type_count (); for (unsigned int i = 0; i < count; i++) @@ -378,7 +369,7 @@ struct ResourceMap return Null (OpenTypeFontFace); } - inline bool sanitize (hb_sanitize_context_t *c, const void *data_base) const + bool sanitize (hb_sanitize_context_t *c, const void *data_base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -388,9 +379,9 @@ struct ResourceMap } private: - inline unsigned int get_type_count (void) const { return (this+typeList).lenM1 + 1; } + unsigned int get_type_count () const { return (this+typeList).lenM1 + 1; } - inline const ResourceTypeRecord& get_type_record (unsigned int i) const + const ResourceTypeRecord& get_type_record (unsigned int i) const { return (this+typeList)[i]; } protected: @@ -409,11 +400,11 @@ struct ResourceMap struct ResourceForkHeader { - inline unsigned int get_face_count (void) const + unsigned int get_face_count () const { return (this+map).get_face_count (); } - inline const OpenTypeFontFace& get_face (unsigned int idx, - unsigned int *base_offset = nullptr) const + const OpenTypeFontFace& get_face (unsigned int idx, + unsigned int *base_offset = nullptr) const { const OpenTypeFontFace &face = (this+map).get_face (idx, &(this+data)); if (base_offset) @@ -421,7 +412,7 @@ struct ResourceForkHeader return face; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -457,9 +448,9 @@ struct OpenTypeFontFile Typ1Tag = HB_TAG ('t','y','p','1') /* Obsolete Apple Type1 font in SFNT container */ }; - inline hb_tag_t get_tag (void) const { return u.tag; } + hb_tag_t get_tag () const { return u.tag; } - inline unsigned int get_face_count (void) const + unsigned int get_face_count () const { switch (u.tag) { case CFFTag: /* All the non-collection tags */ @@ -471,7 +462,7 @@ struct OpenTypeFontFile default: return 0; } } - inline const OpenTypeFontFace& get_face (unsigned int i, unsigned int *base_offset = nullptr) const + const OpenTypeFontFace& get_face (unsigned int i, unsigned int *base_offset = nullptr) const { if (base_offset) *base_offset = 0; @@ -489,19 +480,18 @@ struct OpenTypeFontFile } } - inline bool serialize_single (hb_serialize_context_t *c, - hb_tag_t sfnt_tag, - Supplier<hb_tag_t> &tags, - Supplier<hb_blob_t *> &blobs, - unsigned int table_count) + template <typename item_t> + bool serialize_single (hb_serialize_context_t *c, + hb_tag_t sfnt_tag, + hb_array_t<item_t> items) { TRACE_SERIALIZE (this); assert (sfnt_tag != TTCTag); if (unlikely (!c->extend_min (*this))) return_trace (false); - return_trace (u.fontFace.serialize (c, sfnt_tag, tags, blobs, table_count)); + return_trace (u.fontFace.serialize (c, sfnt_tag, items)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!u.tag.sanitize (c))) return_trace (false); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh index f4d0238ea07..7f88279a792 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh @@ -52,18 +52,24 @@ namespace OT { * Int types */ +template <bool is_signed> struct hb_signedness_int; +template <> struct hb_signedness_int<false> { typedef unsigned int value; }; +template <> struct hb_signedness_int<true> { typedef signed int value; }; + /* Integer types in big-endian order and no alignment requirement */ 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 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); } + typedef typename hb_signedness_int<hb_is_signed<Type>::value>::value wide_type; + + void set (wide_type i) { v.set (i); } + operator wide_type () const { return v; } + bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; } + bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); } + static int cmp (const IntType<Type,Size> *a, const IntType<Type,Size> *b) { return b->cmp (*a); } template <typename Type2> - inline int cmp (Type2 a) const + int cmp (Type2 a) const { Type b = v; if (sizeof (Type) < sizeof (int) && sizeof (Type2) < sizeof (int)) @@ -71,7 +77,7 @@ struct IntType else return a < b ? -1 : a == b ? 0 : +1; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -88,6 +94,8 @@ typedef IntType<uint16_t, 2> HBUINT16; /* 16-bit unsigned integer. */ typedef IntType<int16_t, 2> HBINT16; /* 16-bit signed integer. */ typedef IntType<uint32_t, 4> HBUINT32; /* 32-bit unsigned integer. */ typedef IntType<int32_t, 4> HBINT32; /* 32-bit signed integer. */ +/* Note: we cannot defined a signed HBINT24 because there's no corresponding C type. + * Works for unsigned, but not signed, since we rely on compiler for sign-extension. */ typedef IntType<uint32_t, 3> HBUINT24; /* 24-bit unsigned integer. */ /* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */ @@ -103,8 +111,8 @@ typedef HBUINT16 UFWORD; struct F2DOT14 : HBINT16 { // 16384 means 1<<14 - inline float to_float (void) const { return ((int32_t) v) / 16384.f; } - inline void set_float (float f) { v.set (round (f * 16384.f)); } + float to_float () const { return ((int32_t) v) / 16384.f; } + void set_float (float f) { v.set (round (f * 16384.f)); } public: DEFINE_SIZE_STATIC (2); }; @@ -113,8 +121,8 @@ struct F2DOT14 : HBINT16 struct Fixed : HBINT32 { // 65536 means 1<<16 - inline float to_float (void) const { return ((int32_t) v) / 65536.f; } - inline void set_float (float f) { v.set (round (f * 65536.f)); } + float to_float () const { return ((int32_t) v) / 65536.f; } + void set_float (float f) { v.set (round (f * 65536.f)); } public: DEFINE_SIZE_STATIC (4); }; @@ -123,7 +131,7 @@ struct Fixed : HBINT32 * 1904. The value is represented as a signed 64-bit integer. */ struct LONGDATETIME { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -140,8 +148,8 @@ struct LONGDATETIME struct Tag : HBUINT32 { /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ - inline operator const char* (void) const { return reinterpret_cast<const char *> (&this->v); } - inline operator char* (void) { return reinterpret_cast<char *> (&this->v); } + operator const char* () const { return reinterpret_cast<const char *> (&this->v); } + operator char* () { return reinterpret_cast<char *> (&this->v); } public: DEFINE_SIZE_STATIC (4); }; @@ -163,9 +171,9 @@ struct Offset : Type { typedef Type type; - inline bool is_null (void) const { return has_null && 0 == *this; } + bool is_null () const { return has_null && 0 == *this; } - inline void *serialize (hb_serialize_context_t *c, const void *base) + void *serialize (hb_serialize_context_t *c, const void *base) { void *t = c->start_embed<void> (); this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ @@ -184,7 +192,7 @@ typedef Offset<HBUINT32> Offset32; struct CheckSum : HBUINT32 { /* This is reference implementation from the spec. */ - static inline uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length) + static uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length) { uint32_t Sum = 0L; assert (0 == (Length & 3)); @@ -196,7 +204,7 @@ struct CheckSum : HBUINT32 } /* Note: data should be 4byte aligned and have 4byte padding at the end. */ - inline void set_for_data (const void *data, unsigned int length) + void set_for_data (const void *data, unsigned int length) { set (CalcTableChecksum ((const HBUINT32 *) data, length)); } public: @@ -211,9 +219,9 @@ struct CheckSum : HBUINT32 template <typename FixedType=HBUINT16> struct FixedVersion { - inline uint32_t to_int (void) const { return (major << (sizeof (FixedType) * 8)) + minor; } + uint32_t to_int () const { return (major << (sizeof (FixedType) * 8)) + minor; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -234,38 +242,37 @@ struct FixedVersion 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; } + static const Type *get_null () { return nullptr; } + static Type *get_crap () { 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); } + static const Type *get_null () { return &Null(Type); } + static Type *get_crap () { return &Crap(Type); } }; template <typename Type, typename OffsetType=HBUINT16, bool has_null=true> struct OffsetTo : Offset<OffsetType, has_null> { - inline const Type& operator () (const void *base) const + const Type& operator () (const void *base) const { 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 + Type& operator () (void *base) const { - 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); } - inline Type& serialize (hb_serialize_context_t *c, const void *base) + Type& serialize (hb_serialize_context_t *c, const void *base) { return * (Type *) Offset<OffsetType>::serialize (c, base); } template <typename T> - inline void serialize_subset (hb_subset_context_t *c, const T &src, const void *base) + void serialize_subset (hb_subset_context_t *c, const T &src, const void *base) { if (&src == &Null (T)) { @@ -277,7 +284,7 @@ struct OffsetTo : Offset<OffsetType, has_null> this->set (0); } - inline bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const + bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) return_trace (false); @@ -286,7 +293,7 @@ struct OffsetTo : Offset<OffsetType, has_null> return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (sanitize_shallow (c, base) && @@ -295,7 +302,7 @@ struct OffsetTo : Offset<OffsetType, has_null> neuter (c))); } template <typename T1> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1) const + bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1) const { TRACE_SANITIZE (this); return_trace (sanitize_shallow (c, base) && @@ -304,7 +311,7 @@ struct OffsetTo : Offset<OffsetType, has_null> neuter (c))); } template <typename T1, typename T2> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1, T2 d2) const + bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1, T2 d2) const { TRACE_SANITIZE (this); return_trace (sanitize_shallow (c, base) && @@ -313,7 +320,7 @@ struct OffsetTo : Offset<OffsetType, has_null> neuter (c))); } template <typename T1, typename T2, typename T3> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1, T2 d2, T3 d3) const + bool sanitize (hb_sanitize_context_t *c, const void *base, T1 d1, T2 d2, T3 d3) const { TRACE_SANITIZE (this); return_trace (sanitize_shallow (c, base) && @@ -323,7 +330,7 @@ struct OffsetTo : Offset<OffsetType, has_null> } /* Set the offset to Null */ - inline bool neuter (hb_sanitize_context_t *c) const + bool neuter (hb_sanitize_context_t *c) const { if (!has_null) return false; return c->try_set (this, 0); @@ -345,47 +352,49 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null> template <typename Type> struct UnsizedArrayOf { - static_assert ((bool) (unsigned) hb_static_size (Type), ""); - - enum { item_size = Type::static_size }; + typedef Type ItemType; + enum { item_size = hb_static_size (Type) }; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; const Type *p = &arrayZ[i]; if (unlikely (p < arrayZ)) return Null (Type); /* Overflowed. */ return *p; } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (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 + unsigned int get_size (unsigned int len) const { return len * Type::static_size; } - inline hb_array_t<Type> as_array (unsigned int len) + template <typename T> operator T * () { return arrayZ; } + template <typename T> operator const T * () const { return arrayZ; } + 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 + hb_array_t<const Type> as_array (unsigned int len) const { return hb_array (arrayZ, len); } + operator hb_array_t<Type> () { return as_array (); } + operator hb_array_t<const Type> () const { return as_array (); } template <typename T> - inline Type &lsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) + Type &lsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) { return *as_array (len).lsearch (x, ¬_found); } template <typename T> - inline const Type &lsearch (unsigned int len, const T &x, const Type ¬_found = Null (Type)) const + const Type &lsearch (unsigned int len, const T &x, const Type ¬_found = Null (Type)) const { return *as_array (len).lsearch (x, ¬_found); } - inline void qsort (unsigned int len, unsigned int start = 0, unsigned int end = (unsigned int) -1) + 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 + bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c, count))) return_trace (false); @@ -401,7 +410,7 @@ struct UnsizedArrayOf return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c, count))) return_trace (false); @@ -411,7 +420,7 @@ struct UnsizedArrayOf return_trace (true); } template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c, count))) return_trace (false); @@ -421,7 +430,7 @@ struct UnsizedArrayOf return_trace (true); } - inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const + bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); return_trace (c->check_array (arrayZ, count)); @@ -441,27 +450,29 @@ struct UnsizedOffsetArrayOf : UnsizedArrayOf<OffsetTo<Type, OffsetType, has_null template <typename Type, typename OffsetType, bool has_null=true> struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null> { - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) 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) + Type& operator [] (int i_) { + unsigned int i = (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 + bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (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 + bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const { TRACE_SANITIZE (this); return_trace ((UnsizedOffsetArrayOf<Type, OffsetType, has_null>::sanitize (c, count, this, user_data))); @@ -472,19 +483,21 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null> template <typename Type> struct SortedUnsizedArrayOf : UnsizedArrayOf<Type> { - inline hb_sorted_array_t<Type> as_array (unsigned int len) + 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 + hb_sorted_array_t<const Type> as_array (unsigned int len) const { return hb_sorted_array (this->arrayZ, len); } + operator hb_sorted_array_t<Type> () { return as_array (); } + operator hb_sorted_array_t<const Type> () const { return as_array (); } template <typename T> - inline Type &bsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) + Type &bsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) { return *as_array (len).bsearch (x, ¬_found); } template <typename T> - inline const Type &bsearch (unsigned int len, const T &x, const Type ¬_found = Null (Type)) const + const Type &bsearch (unsigned int len, const T &x, const Type ¬_found = Null (Type)) const { return *as_array (len).bsearch (x, ¬_found); } template <typename T> - inline bool bfind (unsigned int len, const T &x, unsigned int *i = nullptr, + 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); } @@ -495,42 +508,44 @@ struct SortedUnsizedArrayOf : UnsizedArrayOf<Type> template <typename Type, typename LenType=HBUINT16> struct ArrayOf { - static_assert ((bool) (unsigned) hb_static_size (Type), ""); - - enum { item_size = Type::static_size }; + typedef Type ItemType; + enum { item_size = hb_static_size (Type) }; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i >= len)) return Null (Type); return arrayZ[i]; } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (unsigned int) i_; if (unlikely (i >= len)) return Crap (Type); return arrayZ[i]; } - inline unsigned int get_size (void) const + unsigned int get_size () const { return len.static_size + len * Type::static_size; } - inline hb_array_t<Type> as_array (void) + hb_array_t<Type> as_array () { return hb_array (arrayZ, len); } - inline hb_array_t<const Type> as_array (void) const + hb_array_t<const Type> as_array () const { return hb_array (arrayZ, len); } + operator hb_array_t<Type> (void) { return as_array (); } + operator hb_array_t<const Type> (void) const { return as_array (); } - inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int count) const + 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 + hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* 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) + 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 */) + hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) { return as_array ().sub_array (start_offset, count);} - inline bool serialize (hb_serialize_context_t *c, - unsigned int items_len) + bool serialize (hb_serialize_context_t *c, unsigned int items_len) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -538,19 +553,17 @@ struct ArrayOf if (unlikely (!c->extend (*this))) return_trace (false); return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<Type> &items, - unsigned int items_len) + template <typename T> + bool serialize (hb_serialize_context_t *c, hb_array_t<const T> items) { TRACE_SERIALIZE (this); - if (unlikely (!serialize (c, items_len))) return_trace (false); - for (unsigned int i = 0; i < items_len; i++) - arrayZ[i] = items[i]; - items += items_len; + if (unlikely (!serialize (c, items.len))) return_trace (false); + for (unsigned int i = 0; i < items.len; i++) + hb_assign (arrayZ[i], items[i]); return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); @@ -566,7 +579,7 @@ struct ArrayOf return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); @@ -577,7 +590,7 @@ struct ArrayOf return_trace (true); } template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const + 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); @@ -589,16 +602,16 @@ struct ArrayOf } template <typename T> - inline Type &lsearch (const T &x, Type ¬_found = Crap (Type)) + Type &lsearch (const T &x, Type ¬_found = Crap (Type)) { return *as_array ().lsearch (x, ¬_found); } template <typename T> - inline const Type &lsearch (const T &x, const Type ¬_found = Null (Type)) const + const Type &lsearch (const T &x, const Type ¬_found = Null (Type)) const { return *as_array ().lsearch (x, ¬_found); } - inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) + void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) { as_array ().qsort (start, end); } - inline bool sanitize_shallow (hb_sanitize_context_t *c) const + bool sanitize_shallow (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (len.sanitize (c) && c->check_array (arrayZ, len)); @@ -625,18 +638,20 @@ struct LOffsetLArrayOf : ArrayOf<OffsetTo<Type, HBUINT32>, HBUINT32> {}; template <typename Type> struct OffsetListOf : OffsetArrayOf<Type> { - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i >= this->len)) return Null (Type); return this+this->arrayZ[i]; } - inline const Type& operator [] (unsigned int i) + const Type& operator [] (int i_) { + unsigned int i = (unsigned int) i_; if (unlikely (i >= this->len)) return Crap (Type); return this+this->arrayZ[i]; } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct OffsetListOf<Type> *out = c->serializer->embed (*this); @@ -647,13 +662,13 @@ struct OffsetListOf : OffsetArrayOf<Type> return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (OffsetArrayOf<Type>::sanitize (c, this)); } template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, T user_data) const + bool sanitize (hb_sanitize_context_t *c, T user_data) const { TRACE_SANITIZE (this); return_trace (OffsetArrayOf<Type>::sanitize (c, this, user_data)); @@ -668,35 +683,34 @@ struct HeadlessArrayOf HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType); - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i >= lenP1 || !i)) return Null (Type); return arrayZ[i-1]; } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (unsigned int) i_; if (unlikely (i >= lenP1 || !i)) return Crap (Type); return arrayZ[i-1]; } - inline unsigned int get_size (void) const + unsigned int get_size () const { return lenP1.static_size + (lenP1 ? lenP1 - 1 : 0) * Type::static_size; } - inline bool serialize (hb_serialize_context_t *c, - Supplier<Type> &items, - unsigned int items_len) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const Type> items) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - lenP1.set (items_len); /* TODO(serialize) Overflow? */ - if (unlikely (!items_len)) return_trace (true); + lenP1.set (items.len + 1); /* TODO(serialize) Overflow? */ if (unlikely (!c->extend (*this))) return_trace (false); - for (unsigned int i = 0; i < items_len - 1; i++) + for (unsigned int i = 0; i < items.len; i++) arrayZ[i] = items[i]; - items += items_len - 1; return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); @@ -714,7 +728,7 @@ struct HeadlessArrayOf } private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const + bool sanitize_shallow (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (lenP1.sanitize (c) && @@ -734,21 +748,23 @@ struct ArrayOfM1 { HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOfM1, Type, LenType); - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i > lenM1)) return Null (Type); return arrayZ[i]; } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (unsigned int) i_; if (unlikely (i > lenM1)) return Crap (Type); return arrayZ[i]; } - inline unsigned int get_size (void) const + unsigned int get_size () const { return lenM1.static_size + (lenM1 + 1) * Type::static_size; } template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const + 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); @@ -760,7 +776,7 @@ struct ArrayOfM1 } private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const + bool sanitize_shallow (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (lenM1.sanitize (c) && @@ -778,28 +794,30 @@ struct ArrayOfM1 template <typename Type, typename LenType=HBUINT16> struct SortedArrayOf : ArrayOf<Type, LenType> { - inline hb_sorted_array_t<Type> as_array (void) + hb_sorted_array_t<Type> as_array () { return hb_sorted_array (this->arrayZ, this->len); } - inline hb_sorted_array_t<const Type> as_array (void) const + hb_sorted_array_t<const Type> as_array () const { return hb_sorted_array (this->arrayZ, this->len); } + operator hb_sorted_array_t<Type> () { return as_array (); } + operator hb_sorted_array_t<const Type> () const { return as_array (); } - inline hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int count) const + 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 + hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* 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) + 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 */) + hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) { return as_array ().sub_array (start_offset, count);} template <typename T> - inline Type &bsearch (const T &x, Type ¬_found = Crap (Type)) + Type &bsearch (const T &x, Type ¬_found = Crap (Type)) { return *as_array ().bsearch (x, ¬_found); } template <typename T> - inline const Type &bsearch (const T &x, const Type ¬_found = Null (Type)) const + const Type &bsearch (const T &x, const Type ¬_found = Null (Type)) const { return *as_array ().bsearch (x, ¬_found); } template <typename T> - inline bool bfind (const T &x, unsigned int *i = nullptr, + 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); } @@ -812,15 +830,15 @@ struct SortedArrayOf : ArrayOf<Type, LenType> template <typename LenType=HBUINT16> struct BinSearchHeader { - inline operator uint32_t (void) const { return len; } + operator uint32_t () const { return len; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } - inline void set (unsigned int v) + void set (unsigned int v) { len.set (v); assert (len == v); @@ -848,7 +866,7 @@ struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader<LenType> > {}; struct VarSizedBinSearchHeader { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -874,7 +892,7 @@ struct VarSizedBinSearchArrayOf HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type); - inline bool last_is_terminator (void) const + bool last_is_terminator () const { if (unlikely (!header.nUnits)) return false; @@ -890,24 +908,24 @@ struct VarSizedBinSearchArrayOf return true; } - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i >= get_length ())) return Null (Type); return StructAtOffset<Type> (&bytesZ, i * header.unitSize); } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (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 + unsigned int get_length () const + { return header.nUnits - last_is_terminator (); } + unsigned int get_size () const { return header.static_size + header.nUnits * header.unitSize; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); @@ -923,7 +941,7 @@ struct VarSizedBinSearchArrayOf return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); @@ -934,7 +952,7 @@ struct VarSizedBinSearchArrayOf return_trace (true); } template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const + 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); @@ -946,7 +964,7 @@ struct VarSizedBinSearchArrayOf } template <typename T> - inline const Type *bsearch (const T &key) const + const Type *bsearch (const T &key) const { unsigned int size = header.unitSize; int min = 0, max = (int) get_length () - 1; @@ -963,7 +981,7 @@ struct VarSizedBinSearchArrayOf } private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const + bool sanitize_shallow (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (header.sanitize (c) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh new file mode 100644 index 00000000000..db04b3eb239 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh @@ -0,0 +1,711 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ +#ifndef HB_OT_CFF_COMMON_HH +#define HB_OT_CFF_COMMON_HH + +#include "hb-open-type.hh" +#include "hb-ot-layout-common.hh" +#include "hb-cff-interp-dict-common.hh" +#include "hb-subset-plan.hh" + +namespace CFF { + +using namespace OT; + +#define CFF_UNDEF_CODE 0xFFFFFFFF + +/* utility macro */ +template<typename Type> +static inline const Type& StructAtOffsetOrNull(const void *P, unsigned int offset) +{ return offset? (* reinterpret_cast<const Type*> ((const char *) P + offset)): Null(Type); } + +inline unsigned int calcOffSize(unsigned int dataSize) +{ + unsigned int size = 1; + unsigned int offset = dataSize + 1; + while ((offset & ~0xFF) != 0) + { + size++; + offset >>= 8; + } + /* format does not support size > 4; caller should handle it as an error */ + return size; +} + +struct code_pair +{ + hb_codepoint_t code; + hb_codepoint_t glyph; +}; + +typedef hb_vector_t<char, 1> StrBuff; +struct StrBuffArray : hb_vector_t<StrBuff> +{ + void fini () { SUPER::fini_deep (); } + + unsigned int total_size () const + { + unsigned int size = 0; + for (unsigned int i = 0; i < len; i++) + size += (*this)[i].len; + return size; + } + + private: + typedef hb_vector_t<StrBuff> SUPER; +}; + +/* CFF INDEX */ +template <typename COUNT> +struct CFFIndex +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely ((count.sanitize (c) && count == 0) || /* empty INDEX */ + (c->check_struct (this) && offSize >= 1 && offSize <= 4 && + c->check_array (offsets, offSize, count + 1) && + c->check_array ((const HBUINT8*)data_base (), 1, max_offset () - 1)))); + } + + static unsigned int calculate_offset_array_size (unsigned int offSize, unsigned int count) + { return offSize * (count + 1); } + + unsigned int offset_array_size () const + { return calculate_offset_array_size (offSize, count); } + + static unsigned int calculate_serialized_size (unsigned int offSize, unsigned int count, unsigned int dataSize) + { + if (count == 0) + return COUNT::static_size; + else + return min_size + calculate_offset_array_size (offSize, count) + dataSize; + } + + bool serialize (hb_serialize_context_t *c, const CFFIndex &src) + { + TRACE_SERIALIZE (this); + unsigned int size = src.get_size (); + CFFIndex *dest = c->allocate_size<CFFIndex> (size); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &src, size); + return_trace (true); + } + + bool serialize (hb_serialize_context_t *c, + unsigned int offSize_, + const ByteStrArray &byteArray) + { + TRACE_SERIALIZE (this); + if (byteArray.len == 0) + { + COUNT *dest = c->allocate_min<COUNT> (); + if (unlikely (dest == nullptr)) return_trace (false); + dest->set (0); + } + else + { + /* serialize CFFIndex header */ + if (unlikely (!c->extend_min (*this))) return_trace (false); + this->count.set (byteArray.len); + this->offSize.set (offSize_); + if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.len + 1)))) + return_trace (false); + + /* serialize indices */ + unsigned int offset = 1; + unsigned int i = 0; + for (; i < byteArray.len; i++) + { + set_offset_at (i, offset); + offset += byteArray[i].get_size (); + } + set_offset_at (i, offset); + + /* serialize data */ + for (unsigned int i = 0; i < byteArray.len; i++) + { + ByteStr *dest = c->start_embed<ByteStr> (); + if (unlikely (dest == nullptr || + !dest->serialize (c, byteArray[i]))) + return_trace (false); + } + } + return_trace (true); + } + + bool serialize (hb_serialize_context_t *c, + unsigned int offSize_, + const StrBuffArray &buffArray) + { + ByteStrArray byteArray; + byteArray.init (); + byteArray.resize (buffArray.len); + for (unsigned int i = 0; i < byteArray.len; i++) + { + byteArray[i] = ByteStr (buffArray[i].arrayZ (), buffArray[i].len); + } + bool result = this->serialize (c, offSize_, byteArray); + byteArray.fini (); + return result; + } + + void set_offset_at (unsigned int index, unsigned int offset) + { + HBUINT8 *p = offsets + offSize * index + offSize; + unsigned int size = offSize; + for (; size; size--) + { + --p; + p->set (offset & 0xFF); + offset >>= 8; + } + } + + unsigned int offset_at (unsigned int index) const + { + assert (index <= count); + const HBUINT8 *p = offsets + offSize * index; + unsigned int size = offSize; + unsigned int offset = 0; + for (; size; size--) + offset = (offset << 8) + *p++; + return offset; + } + + unsigned int length_at (unsigned int index) const + { + if (likely ((offset_at (index + 1) >= offset_at (index)) && + (offset_at (index + 1) <= offset_at (count)))) + return offset_at (index + 1) - offset_at (index); + else + return 0; + } + + const char *data_base () const + { return (const char *)this + min_size + offset_array_size (); } + + unsigned int data_size () const { return HBINT8::static_size; } + + ByteStr operator [] (unsigned int index) const + { + if (likely (index < count)) + return ByteStr (data_base () + offset_at (index) - 1, length_at (index)); + else + return Null(ByteStr); + } + + unsigned int get_size () const + { + if (this != &Null(CFFIndex)) + { + if (count > 0) + return min_size + offset_array_size () + (offset_at (count) - 1); + else + return count.static_size; /* empty CFFIndex contains count only */ + } + else + return 0; + } + + protected: + unsigned int max_offset () const + { + unsigned int max = 0; + for (unsigned int i = 0; i < count + 1u; i++) + { + unsigned int off = offset_at (i); + if (off > max) max = off; + } + return max; + } + + public: + COUNT count; /* Number of object data. Note there are (count+1) offsets */ + HBUINT8 offSize; /* The byte size of each offset in the offsets array. */ + HBUINT8 offsets[VAR]; /* The array of (count + 1) offsets into objects array (1-base). */ + /* HBUINT8 data[VAR]; Object data */ + public: + DEFINE_SIZE_ARRAY (COUNT::static_size + HBUINT8::static_size, offsets); +}; + +template <typename COUNT, typename TYPE> +struct CFFIndexOf : CFFIndex<COUNT> +{ + const ByteStr operator [] (unsigned int index) const + { + if (likely (index < CFFIndex<COUNT>::count)) + return ByteStr (CFFIndex<COUNT>::data_base () + CFFIndex<COUNT>::offset_at (index) - 1, CFFIndex<COUNT>::length_at (index)); + return Null(ByteStr); + } + + template <typename DATA, typename PARAM1, typename PARAM2> + bool serialize (hb_serialize_context_t *c, + unsigned int offSize_, + const DATA *dataArray, + unsigned int dataArrayLen, + const hb_vector_t<unsigned int> &dataSizeArray, + const PARAM1 ¶m1, + const PARAM2 ¶m2) + { + TRACE_SERIALIZE (this); + /* serialize CFFIndex header */ + if (unlikely (!c->extend_min (*this))) return_trace (false); + this->count.set (dataArrayLen); + this->offSize.set (offSize_); + if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (dataArrayLen + 1)))) + return_trace (false); + + /* serialize indices */ + unsigned int offset = 1; + unsigned int i = 0; + for (; i < dataArrayLen; i++) + { + CFFIndex<COUNT>::set_offset_at (i, offset); + offset += dataSizeArray[i]; + } + CFFIndex<COUNT>::set_offset_at (i, offset); + + /* serialize data */ + for (unsigned int i = 0; i < dataArrayLen; i++) + { + TYPE *dest = c->start_embed<TYPE> (); + if (unlikely (dest == nullptr || + !dest->serialize (c, dataArray[i], param1, param2))) + return_trace (false); + } + return_trace (true); + } + + /* in parallel to above */ + template <typename DATA, typename PARAM> + static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, + const DATA *dataArray, + unsigned int dataArrayLen, + hb_vector_t<unsigned int> &dataSizeArray, /* OUT */ + const PARAM ¶m) + { + /* determine offset size */ + unsigned int totalDataSize = 0; + for (unsigned int i = 0; i < dataArrayLen; i++) + { + unsigned int dataSize = TYPE::calculate_serialized_size (dataArray[i], param); + dataSizeArray[i] = dataSize; + totalDataSize += dataSize; + } + offSize_ = calcOffSize (totalDataSize); + + return CFFIndex<COUNT>::calculate_serialized_size (offSize_, dataArrayLen, totalDataSize); + } +}; + +/* Top Dict, Font Dict, Private Dict */ +struct Dict : UnsizedByteStr +{ + template <typename DICTVAL, typename OP_SERIALIZER, typename PARAM> + bool serialize (hb_serialize_context_t *c, + const DICTVAL &dictval, + OP_SERIALIZER& opszr, + PARAM& param) + { + TRACE_SERIALIZE (this); + for (unsigned int i = 0; i < dictval.get_count (); i++) + { + if (unlikely (!opszr.serialize (c, dictval[i], param))) + return_trace (false); + } + return_trace (true); + } + + /* in parallel to above */ + template <typename DICTVAL, typename OP_SERIALIZER, typename PARAM> + static unsigned int calculate_serialized_size (const DICTVAL &dictval, + OP_SERIALIZER& opszr, + PARAM& param) + { + unsigned int size = 0; + for (unsigned int i = 0; i < dictval.get_count (); i++) + size += opszr.calculate_serialized_size (dictval[i], param); + return size; + } + + template <typename DICTVAL, typename OP_SERIALIZER> + static unsigned int calculate_serialized_size (const DICTVAL &dictval, + OP_SERIALIZER& opszr) + { + unsigned int size = 0; + for (unsigned int i = 0; i < dictval.get_count (); i++) + size += opszr.calculate_serialized_size (dictval[i]); + return size; + } + + template <typename INTTYPE, int minVal, int maxVal> + static bool serialize_int_op (hb_serialize_context_t *c, OpCode op, int value, OpCode intOp) + { + // XXX: not sure why but LLVM fails to compile the following 'unlikely' macro invocation + if (/*unlikely*/ (!serialize_int<INTTYPE, minVal, maxVal> (c, intOp, value))) + return false; + + TRACE_SERIALIZE (this); + /* serialize the opcode */ + HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op)); + if (unlikely (p == nullptr)) return_trace (false); + if (Is_OpCode_ESC (op)) + { + p->set (OpCode_escape); + op = Unmake_OpCode_ESC (op); + p++; + } + p->set (op); + return_trace (true); + } + + static bool serialize_uint4_op (hb_serialize_context_t *c, OpCode op, int value) + { return serialize_int_op<HBUINT32, 0, 0x7FFFFFFF> (c, op, value, OpCode_longintdict); } + + static bool serialize_uint2_op (hb_serialize_context_t *c, OpCode op, int value) + { return serialize_int_op<HBUINT16, 0, 0x7FFF> (c, op, value, OpCode_shortint); } + + static bool serialize_offset4_op (hb_serialize_context_t *c, OpCode op, int value) + { + return serialize_uint4_op (c, op, value); + } + + static bool serialize_offset2_op (hb_serialize_context_t *c, OpCode op, int value) + { + return serialize_uint2_op (c, op, value); + } +}; + +struct TopDict : Dict {}; +struct FontDict : Dict {}; +struct PrivateDict : Dict {}; + +struct TableInfo +{ + void init () { offSize = offset = size = 0; } + + unsigned int offset; + unsigned int size; + unsigned int offSize; +}; + +/* used to remap font index or SID from fullset to subset. + * set to CFF_UNDEF_CODE if excluded from subset */ +struct Remap : hb_vector_t<hb_codepoint_t> +{ + void init () { SUPER::init (); } + + void fini () { SUPER::fini (); } + + bool reset (unsigned int size) + { + if (unlikely (!SUPER::resize (size))) + return false; + for (unsigned int i = 0; i < len; i++) + (*this)[i] = CFF_UNDEF_CODE; + count = 0; + return true; + } + + bool identity (unsigned int size) + { + if (unlikely (!SUPER::resize (size))) + return false; + unsigned int i; + for (i = 0; i < len; i++) + (*this)[i] = i; + count = i; + return true; + } + + bool excludes (hb_codepoint_t id) const + { return (id < len) && ((*this)[id] == CFF_UNDEF_CODE); } + + bool includes (hb_codepoint_t id) const + { return !excludes (id); } + + unsigned int add (unsigned int i) + { + if ((*this)[i] == CFF_UNDEF_CODE) + (*this)[i] = count++; + return (*this)[i]; + } + + hb_codepoint_t get_count () const { return count; } + + protected: + hb_codepoint_t count; + + private: + typedef hb_vector_t<hb_codepoint_t> SUPER; +}; + +template <typename COUNT> +struct FDArray : CFFIndexOf<COUNT, FontDict> +{ + /* used by CFF1 */ + template <typename DICTVAL, typename OP_SERIALIZER> + bool serialize (hb_serialize_context_t *c, + unsigned int offSize_, + const hb_vector_t<DICTVAL> &fontDicts, + OP_SERIALIZER& opszr) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + this->count.set (fontDicts.len); + this->offSize.set (offSize_); + if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.len + 1)))) + return_trace (false); + + /* serialize font dict offsets */ + unsigned int offset = 1; + unsigned int fid = 0; + for (; fid < fontDicts.len; fid++) + { + CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); + offset += FontDict::calculate_serialized_size (fontDicts[fid], opszr); + } + CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); + + /* serialize font dicts */ + for (unsigned int i = 0; i < fontDicts.len; i++) + { + FontDict *dict = c->start_embed<FontDict> (); + if (unlikely (!dict->serialize (c, fontDicts[i], opszr, fontDicts[i]))) + return_trace (false); + } + return_trace (true); + } + + /* used by CFF2 */ + template <typename DICTVAL, typename OP_SERIALIZER> + bool serialize (hb_serialize_context_t *c, + unsigned int offSize_, + const hb_vector_t<DICTVAL> &fontDicts, + unsigned int fdCount, + const Remap &fdmap, + OP_SERIALIZER& opszr, + const hb_vector_t<TableInfo> &privateInfos) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + this->count.set (fdCount); + this->offSize.set (offSize_); + if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fdCount + 1)))) + return_trace (false); + + /* serialize font dict offsets */ + unsigned int offset = 1; + unsigned int fid = 0; + for (unsigned i = 0; i < fontDicts.len; i++) + if (fdmap.includes (i)) + { + CFFIndexOf<COUNT, FontDict>::set_offset_at (fid++, offset); + offset += FontDict::calculate_serialized_size (fontDicts[i], opszr); + } + CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); + + /* serialize font dicts */ + for (unsigned int i = 0; i < fontDicts.len; i++) + if (fdmap.includes (i)) + { + FontDict *dict = c->start_embed<FontDict> (); + if (unlikely (!dict->serialize (c, fontDicts[i], opszr, privateInfos[fdmap[i]]))) + return_trace (false); + } + return_trace (true); + } + + /* in parallel to above */ + template <typename OP_SERIALIZER, typename DICTVAL> + static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, + const hb_vector_t<DICTVAL> &fontDicts, + unsigned int fdCount, + const Remap &fdmap, + OP_SERIALIZER& opszr) + { + unsigned int dictsSize = 0; + for (unsigned int i = 0; i < fontDicts.len; i++) + if (fdmap.includes (i)) + dictsSize += FontDict::calculate_serialized_size (fontDicts[i], opszr); + + offSize_ = calcOffSize (dictsSize); + return CFFIndex<COUNT>::calculate_serialized_size (offSize_, fdCount, dictsSize); + } +}; + +/* FDSelect */ +struct FDSelect0 { + bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + { + TRACE_SANITIZE (this); + if (unlikely (!(c->check_struct (this)))) + return_trace (false); + for (unsigned int i = 0; i < c->get_num_glyphs (); i++) + if (unlikely (!fds[i].sanitize (c))) + return_trace (false); + + return_trace (true); + } + + hb_codepoint_t get_fd (hb_codepoint_t glyph) const + { + return (hb_codepoint_t)fds[glyph]; + } + + unsigned int get_size (unsigned int num_glyphs) const + { return HBUINT8::static_size * num_glyphs; } + + HBUINT8 fds[VAR]; + + DEFINE_SIZE_MIN (1); +}; + +template <typename GID_TYPE, typename FD_TYPE> +struct FDSelect3_4_Range { + bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && (first < c->get_num_glyphs ()) && (fd < fdcount))); + } + + GID_TYPE first; + FD_TYPE fd; + + DEFINE_SIZE_STATIC (GID_TYPE::static_size + FD_TYPE::static_size); +}; + +template <typename GID_TYPE, typename FD_TYPE> +struct FDSelect3_4 { + unsigned int get_size () const + { return GID_TYPE::static_size * 2 + FDSelect3_4_Range<GID_TYPE, FD_TYPE>::static_size * nRanges; } + + bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + { + TRACE_SANITIZE (this); + if (unlikely (!(c->check_struct (this) && (nRanges > 0) && (ranges[0].first == 0)))) + return_trace (false); + + for (unsigned int i = 0; i < nRanges; i++) + { + if (unlikely (!ranges[i].sanitize (c, fdcount))) + return_trace (false); + if ((0 < i) && unlikely (ranges[i - 1].first >= ranges[i].first)) + return_trace (false); + } + if (unlikely (!sentinel().sanitize (c) || (sentinel() != c->get_num_glyphs ()))) + return_trace (false); + + return_trace (true); + } + + hb_codepoint_t get_fd (hb_codepoint_t glyph) const + { + unsigned int i; + for (i = 1; i < nRanges; i++) + if (glyph < ranges[i].first) + break; + + return (hb_codepoint_t)ranges[i - 1].fd; + } + + GID_TYPE &sentinel () { return StructAfter<GID_TYPE> (ranges[nRanges - 1]); } + const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges - 1]); } + + GID_TYPE nRanges; + FDSelect3_4_Range<GID_TYPE, FD_TYPE> ranges[VAR]; + /* GID_TYPE sentinel */ + + DEFINE_SIZE_ARRAY (GID_TYPE::static_size, ranges); +}; + +typedef FDSelect3_4<HBUINT16, HBUINT8> FDSelect3; +typedef FDSelect3_4_Range<HBUINT16, HBUINT8> FDSelect3_Range; + +struct FDSelect { + bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + { + TRACE_SANITIZE (this); + + return_trace (likely (c->check_struct (this) && (format == 0 || format == 3) && + (format == 0)? + u.format0.sanitize (c, fdcount): + u.format3.sanitize (c, fdcount))); + } + + bool serialize (hb_serialize_context_t *c, const FDSelect &src, unsigned int num_glyphs) + { + TRACE_SERIALIZE (this); + unsigned int size = src.get_size (num_glyphs); + FDSelect *dest = c->allocate_size<FDSelect> (size); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &src, size); + return_trace (true); + } + + unsigned int calculate_serialized_size (unsigned int num_glyphs) const + { return get_size (num_glyphs); } + + unsigned int get_size (unsigned int num_glyphs) const + { + unsigned int size = format.static_size; + if (format == 0) + size += u.format0.get_size (num_glyphs); + else + size += u.format3.get_size (); + return size; + } + + hb_codepoint_t get_fd (hb_codepoint_t glyph) const + { + if (this == &Null(FDSelect)) + return 0; + if (format == 0) + return u.format0.get_fd (glyph); + else + return u.format3.get_fd (glyph); + } + + HBUINT8 format; + union { + FDSelect0 format0; + FDSelect3 format3; + } u; + + DEFINE_SIZE_MIN (1); +}; + +template <typename COUNT> +struct Subrs : CFFIndex<COUNT> +{ + typedef COUNT count_type; + typedef CFFIndex<COUNT> SUPER; +}; + +} /* namespace CFF */ + +#endif /* HB_OT_CFF_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.cc new file mode 100644 index 00000000000..51cecb6f5b4 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.cc @@ -0,0 +1,385 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#include "hb-ot-cff1-table.hh" +#include "hb-cff1-interp-cs.hh" + +using namespace CFF; + +/* SID to code */ +static const uint8_t standard_encoding_to_code [] = +{ + 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 177, + 178, 179, 180, 182, 183, 184, 185, 186, 187, 188, 189, 191, 193, 194, 195, 196, + 197, 198, 199, 200, 202, 203, 205, 206, 207, 208, 225, 227, 232, 233, 234, 235, + 241, 245, 248, 249, 250, 251 +}; + +/* SID to code */ +static const uint8_t expert_encoding_to_code [] = +{ + 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 45, 46, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 59, 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, 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, 0, 0, 0, + 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 88, 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, 0, + 0, 0, 0, 0, 0, 0, 201, 0, 0, 0, 0, 189, 0, 0, 188, 0, + 0, 0, 0, 190, 202, 0, 0, 0, 0, 203, 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, 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, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 60, 61, 62, 63, 65, 66, 67, + 68, 69, 73, 76, 77, 78, 79, 82, 83, 84, 86, 89, 90, 91, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 161, 162, 163, 166, 167, 168, 169, 170, 172, 175, 178, 179, 182, 183, 184, 191, + 192, 193, 194, 195, 196, 197, 200, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 +}; + +/* glyph ID to SID */ +static const uint16_t expert_charset_to_sid [] = +{ + 0, 1, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 13, 14, 15, 99, + 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 252, + 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 109, 110, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, + 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 158, 155, 163, 319, 320, 321, 322, 323, 324, 325, 326, 150, + 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, + 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + 373, 374, 375, 376, 377, 378 +}; + +/* glyph ID to SID */ +static const uint16_t expert_subset_charset_to_sid [] = +{ + 0, 1, 231, 232, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 253, 254, 255, 256, 257, + 258, 259, 260, 261, 262, 263, 264, 265, 266, 109, 110, 267, 268, 269, 270, 272, + 300, 301, 302, 305, 314, 315, 158, 155, 163, 320, 321, 322, 323, 324, 325, 326, + 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, + 340, 341, 342, 343, 344, 345, 346 +}; + +/* code to SID */ +static const uint8_t standard_encoding_to_sid [] = +{ + 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, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 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, 0, + 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 0, 111, 112, 113, 114, 0, 115, 116, 117, 118, 119, 120, 121, 122, 0, 123, + 0, 124, 125, 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, 134, 135, 136, + 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 138, 0, 139, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, + 0, 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0 +}; + +hb_codepoint_t OT::cff1::lookup_standard_encoding_for_code (hb_codepoint_t sid) +{ + if (sid < ARRAY_LENGTH (standard_encoding_to_code)) + return (hb_codepoint_t)standard_encoding_to_code[sid]; + else + return 0; +} + +hb_codepoint_t OT::cff1::lookup_expert_encoding_for_code (hb_codepoint_t sid) +{ + if (sid < ARRAY_LENGTH (expert_encoding_to_code)) + return (hb_codepoint_t)expert_encoding_to_code[sid]; + else + return 0; +} + +hb_codepoint_t OT::cff1::lookup_expert_charset_for_sid (hb_codepoint_t glyph) +{ + if (glyph < ARRAY_LENGTH (expert_charset_to_sid)) + return (hb_codepoint_t)expert_charset_to_sid[glyph]; + else + return 0; +} + +hb_codepoint_t OT::cff1::lookup_expert_subset_charset_for_sid (hb_codepoint_t glyph) +{ + if (glyph < ARRAY_LENGTH (expert_subset_charset_to_sid)) + return (hb_codepoint_t)expert_subset_charset_to_sid[glyph]; + else + return 0; +} + +hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code) +{ + if (code < ARRAY_LENGTH (standard_encoding_to_sid)) + return (hb_codepoint_t)standard_encoding_to_sid[code]; + else + return CFF_UNDEF_SID; +} + +struct Bounds +{ + void init () + { + min.set_int (0x7FFFFFFF, 0x7FFFFFFF); + max.set_int (-0x80000000, -0x80000000); + } + + void update (const Point &pt) + { + if (pt.x < min.x) min.x = pt.x; + if (pt.x > max.x) max.x = pt.x; + if (pt.y < min.y) min.y = pt.y; + if (pt.y > max.y) max.y = pt.y; + } + + void merge (const Bounds &b) + { + if (empty ()) + *this = b; + else if (!b.empty ()) + { + if (b.min.x < min.x) min.x = b.min.x; + if (b.max.x > max.x) max.x = b.max.x; + if (b.min.y < min.y) min.y = b.min.y; + if (b.max.y > max.y) max.y = b.max.y; + } + } + + void offset (const Point &delta) + { + if (!empty ()) + { + min.move (delta); + max.move (delta); + } + } + + bool empty () const + { return (min.x >= max.x) || (min.y >= max.y); } + + Point min; + Point max; +}; + +struct ExtentsParam +{ + void init (const OT::cff1::accelerator_t *_cff) + { + path_open = false; + cff = _cff; + bounds.init (); + } + + void start_path () { path_open = true; } + void end_path () { path_open = false; } + bool is_path_open () const { return path_open; } + + bool path_open; + Bounds bounds; + + const OT::cff1::accelerator_t *cff; +}; + +struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv, ExtentsParam> +{ + static void moveto (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt) + { + param.end_path (); + env.moveto (pt); + } + + static void line (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1) + { + if (!param.is_path_open ()) + { + param.start_path (); + param.bounds.update (env.get_pt ()); + } + env.moveto (pt1); + param.bounds.update (env.get_pt ()); + } + + static void curve (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3) + { + if (!param.is_path_open ()) + { + param.start_path (); + param.bounds.update (env.get_pt ()); + } + /* include control points */ + param.bounds.update (pt1); + param.bounds.update (pt2); + env.moveto (pt3); + param.bounds.update (env.get_pt ()); + } +}; + +static bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac=false); + +struct CFF1CSOpSet_Extents : CFF1CSOpSet<CFF1CSOpSet_Extents, ExtentsParam, CFF1PathProcs_Extents> +{ + static void process_seac (CFF1CSInterpEnv &env, ExtentsParam& param) + { + unsigned int n = env.argStack.get_count (); + Point delta; + delta.x = env.argStack[n-4]; + delta.y = env.argStack[n-3]; + hb_codepoint_t base = param.cff->std_code_to_glyph (env.argStack[n-2].to_int ()); + hb_codepoint_t accent = param.cff->std_code_to_glyph (env.argStack[n-1].to_int ()); + + Bounds base_bounds, accent_bounds; + if (likely (!env.in_seac && base && accent + && _get_bounds (param.cff, base, base_bounds, true) + && _get_bounds (param.cff, accent, accent_bounds, true))) + { + param.bounds.merge (base_bounds); + accent_bounds.offset (delta); + param.bounds.merge (accent_bounds); + } + else + env.set_error (); + } +}; + +bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac) +{ + bounds.init (); + if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false; + + unsigned int fd = cff->fdSelect->get_fd (glyph); + CFF1CSInterpreter<CFF1CSOpSet_Extents, ExtentsParam> interp; + const ByteStr str = (*cff->charStrings)[glyph]; + interp.env.init (str, *cff, fd); + interp.env.set_in_seac (in_seac); + ExtentsParam param; + param.init (cff); + if (unlikely (!interp.interpret (param))) return false; + bounds = param.bounds; + return true; +} + +bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const +{ + Bounds bounds; + + if (!_get_bounds (this, glyph, bounds)) + return false; + + if (bounds.min.x >= bounds.max.x) + { + extents->width = 0; + extents->x_bearing = 0; + } + else + { + extents->x_bearing = (int32_t)bounds.min.x.floor (); + extents->width = (int32_t)bounds.max.x.ceil () - extents->x_bearing; + } + if (bounds.min.y >= bounds.max.y) + { + extents->height = 0; + extents->y_bearing = 0; + } + else + { + extents->y_bearing = (int32_t)bounds.max.y.ceil (); + extents->height = (int32_t)bounds.min.y.floor () - extents->y_bearing; + } + + return true; +} + +struct GetSeacParam +{ + void init (const OT::cff1::accelerator_t *_cff) + { + cff = _cff; + base = 0; + accent = 0; + } + + bool has_seac () const { return base && accent; } + + const OT::cff1::accelerator_t *cff; + hb_codepoint_t base; + hb_codepoint_t accent; +}; + +struct CFF1CSOpSet_Seac : CFF1CSOpSet<CFF1CSOpSet_Seac, GetSeacParam> +{ + static void process_seac (CFF1CSInterpEnv &env, GetSeacParam& param) + { + unsigned int n = env.argStack.get_count (); + hb_codepoint_t base_char = (hb_codepoint_t)env.argStack[n-2].to_int (); + hb_codepoint_t accent_char = (hb_codepoint_t)env.argStack[n-1].to_int (); + + param.base = param.cff->std_code_to_glyph (base_char); + param.accent = param.cff->std_code_to_glyph (accent_char); + } +}; + +bool OT::cff1::accelerator_t::get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const +{ + if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false; + + unsigned int fd = fdSelect->get_fd (glyph); + CFF1CSInterpreter<CFF1CSOpSet_Seac, GetSeacParam> interp; + const ByteStr str = (*charStrings)[glyph]; + interp.env.init (str, *this, fd); + GetSeacParam param; + param.init (this); + if (unlikely (!interp.interpret (param))) return false; + + if (param.has_seac ()) + { + *base = param.base; + *accent = param.accent; + return true; + } + return false; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.hh new file mode 100644 index 00000000000..72dc0ef3e01 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.hh @@ -0,0 +1,1300 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#ifndef HB_OT_CFF1_TABLE_HH +#define HB_OT_CFF1_TABLE_HH + +#include "hb-ot-head-table.hh" +#include "hb-ot-cff-common.hh" +#include "hb-subset-cff1.hh" + +namespace CFF { + +/* + * CFF -- Compact Font Format (CFF) + * http://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5176.CFF.pdf + */ +#define HB_OT_TAG_cff1 HB_TAG('C','F','F',' ') + +#define CFF_UNDEF_SID CFF_UNDEF_CODE + +enum EncodingID { StandardEncoding = 0, ExpertEncoding = 1 }; +enum CharsetID { ISOAdobeCharset = 0, ExpertCharset = 1, ExpertSubsetCharset = 2 }; + +typedef CFFIndex<HBUINT16> CFF1Index; +template <typename Type> struct CFF1IndexOf : CFFIndexOf<HBUINT16, Type> {}; + +typedef CFFIndex<HBUINT16> CFF1Index; +typedef CFF1Index CFF1CharStrings; +typedef FDArray<HBUINT16> CFF1FDArray; +typedef Subrs<HBUINT16> CFF1Subrs; + +struct CFF1FDSelect : FDSelect {}; + +/* Encoding */ +struct Encoding0 { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && codes[nCodes - 1].sanitize (c)); + } + + hb_codepoint_t get_code (hb_codepoint_t glyph) const + { + assert (glyph > 0); + glyph--; + if (glyph < nCodes) + { + return (hb_codepoint_t)codes[glyph]; + } + else + return CFF_UNDEF_CODE; + } + + unsigned int get_size () const + { return HBUINT8::static_size * (nCodes + 1); } + + HBUINT8 nCodes; + HBUINT8 codes[VAR]; + + DEFINE_SIZE_ARRAY(1, codes); +}; + +struct Encoding1_Range { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + HBUINT8 first; + HBUINT8 nLeft; + + DEFINE_SIZE_STATIC (2); +}; + +struct Encoding1 { + unsigned int get_size () const + { return HBUINT8::static_size + Encoding1_Range::static_size * nRanges; } + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && ((nRanges == 0) || (ranges[nRanges - 1]).sanitize (c))); + } + + hb_codepoint_t get_code (hb_codepoint_t glyph) const + { + assert (glyph > 0); + glyph--; + for (unsigned int i = 0; i < nRanges; i++) + { + if (glyph <= ranges[i].nLeft) + { + return (hb_codepoint_t)ranges[i].first + glyph; + } + glyph -= (ranges[i].nLeft + 1); + } + return CFF_UNDEF_CODE; + } + + HBUINT8 nRanges; + Encoding1_Range ranges[VAR]; + + DEFINE_SIZE_ARRAY (1, ranges); +}; + +struct SuppEncoding { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + HBUINT8 code; + HBUINT16 glyph; + + DEFINE_SIZE_STATIC (3); +}; + +struct CFF1SuppEncData { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && ((nSups == 0) || (supps[nSups - 1]).sanitize (c))); + } + + void get_codes (hb_codepoint_t sid, hb_vector_t<hb_codepoint_t> &codes) const + { + for (unsigned int i = 0; i < nSups; i++) + if (sid == supps[i].glyph) + codes.push (supps[i].code); + } + + unsigned int get_size () const + { return HBUINT8::static_size + SuppEncoding::static_size * nSups; } + + HBUINT8 nSups; + SuppEncoding supps[VAR]; + + DEFINE_SIZE_ARRAY (1, supps); +}; + +struct Encoding { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + + if (unlikely (!c->check_struct (this))) + return_trace (false); + unsigned int fmt = format & 0x7F; + if (unlikely (fmt > 1)) + return_trace (false); + if (unlikely (!((fmt == 0)? u.format0.sanitize (c): u.format1.sanitize (c)))) + return_trace (false); + return_trace (((format & 0x80) == 0) || suppEncData ().sanitize (c)); + } + + /* serialize a fullset Encoding */ + bool serialize (hb_serialize_context_t *c, const Encoding &src) + { + TRACE_SERIALIZE (this); + unsigned int size = src.get_size (); + Encoding *dest = c->allocate_size<Encoding> (size); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &src, size); + return_trace (true); + } + + /* serialize a subset Encoding */ + bool serialize (hb_serialize_context_t *c, + uint8_t format, + unsigned int enc_count, + const hb_vector_t<code_pair>& code_ranges, + const hb_vector_t<code_pair>& supp_codes) + { + TRACE_SERIALIZE (this); + Encoding *dest = c->extend_min (*this); + if (unlikely (dest == nullptr)) return_trace (false); + dest->format.set (format | ((supp_codes.len > 0)? 0x80: 0)); + if (format == 0) + { + Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count); + if (unlikely (fmt0 == nullptr)) return_trace (false); + fmt0->nCodes.set (enc_count); + unsigned int glyph = 0; + for (unsigned int i = 0; i < code_ranges.len; i++) + { + hb_codepoint_t code = code_ranges[i].code; + for (int left = (int)code_ranges[i].glyph; left >= 0; left--) + fmt0->codes[glyph++].set (code++); + if (unlikely (!((glyph <= 0x100) && (code <= 0x100)))) + return_trace (false); + } + } + else + { + Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.len); + if (unlikely (fmt1 == nullptr)) return_trace (false); + fmt1->nRanges.set (code_ranges.len); + for (unsigned int i = 0; i < code_ranges.len; i++) + { + if (unlikely (!((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF)))) + return_trace (false); + fmt1->ranges[i].first.set (code_ranges[i].code); + fmt1->ranges[i].nLeft.set (code_ranges[i].glyph); + } + } + if (supp_codes.len > 0) + { + CFF1SuppEncData *suppData = c->allocate_size<CFF1SuppEncData> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.len); + if (unlikely (suppData == nullptr)) return_trace (false); + suppData->nSups.set (supp_codes.len); + for (unsigned int i = 0; i < supp_codes.len; i++) + { + suppData->supps[i].code.set (supp_codes[i].code); + suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */ + } + } + return_trace (true); + } + + /* parallel to above: calculate the size of a subset Encoding */ + static unsigned int calculate_serialized_size (uint8_t format, + unsigned int enc_count, + unsigned int supp_count) + { + unsigned int size = min_size; + if (format == 0) + size += Encoding0::min_size + HBUINT8::static_size * enc_count; + else + size += Encoding1::min_size + Encoding1_Range::static_size * enc_count; + if (supp_count > 0) + size += CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_count; + return size; + } + + unsigned int get_size () const + { + unsigned int size = min_size; + if (table_format () == 0) + size += u.format0.get_size (); + else + size += u.format1.get_size (); + if (has_supplement ()) + size += suppEncData ().get_size (); + return size; + } + + hb_codepoint_t get_code (hb_codepoint_t glyph) const + { + if (table_format () == 0) + return u.format0.get_code (glyph); + else + return u.format1.get_code (glyph); + } + + uint8_t table_format () const { return (format & 0x7F); } + bool has_supplement () const { return (format & 0x80) != 0; } + + void get_supplement_codes (hb_codepoint_t sid, hb_vector_t<hb_codepoint_t> &codes) const + { + codes.resize (0); + if (has_supplement ()) + suppEncData().get_codes (sid, codes); + } + + protected: + const CFF1SuppEncData &suppEncData () const + { + if ((format & 0x7F) == 0) + return StructAfter<CFF1SuppEncData> (u.format0.codes[u.format0.nCodes-1]); + else + return StructAfter<CFF1SuppEncData> (u.format1.ranges[u.format1.nRanges-1]); + } + + public: + HBUINT8 format; + + union { + Encoding0 format0; + Encoding1 format1; + } u; + /* CFF1SuppEncData suppEncData; */ + + DEFINE_SIZE_MIN (1); +}; + +/* Charset */ +struct Charset0 { + bool sanitize (hb_sanitize_context_t *c, unsigned int num_glyphs) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && sids[num_glyphs - 1].sanitize (c)); + } + + hb_codepoint_t get_sid (hb_codepoint_t glyph) const + { + if (glyph == 0) + return 0; + else + return sids[glyph - 1]; + } + + hb_codepoint_t get_glyph (hb_codepoint_t sid, unsigned int num_glyphs) const + { + if (sid == 0) + return 0; + + for (unsigned int glyph = 1; glyph < num_glyphs; glyph++) + { + if (sids[glyph-1] == sid) + return glyph; + } + return 0; + } + + unsigned int get_size (unsigned int num_glyphs) const + { + assert (num_glyphs > 0); + return HBUINT16::static_size * (num_glyphs - 1); + } + + HBUINT16 sids[VAR]; + + DEFINE_SIZE_ARRAY(0, sids); +}; + +template <typename TYPE> +struct Charset_Range { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + HBUINT16 first; + TYPE nLeft; + + DEFINE_SIZE_STATIC (HBUINT16::static_size + TYPE::static_size); +}; + +template <typename TYPE> +struct Charset1_2 { + bool sanitize (hb_sanitize_context_t *c, unsigned int num_glyphs) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) + return_trace (false); + num_glyphs--; + for (unsigned int i = 0; num_glyphs > 0; i++) + { + if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1))) + return_trace (false); + num_glyphs -= (ranges[i].nLeft + 1); + } + return_trace (true); + } + + hb_codepoint_t get_sid (hb_codepoint_t glyph) const + { + if (glyph == 0) return 0; + glyph--; + for (unsigned int i = 0;; i++) + { + if (glyph <= ranges[i].nLeft) + return (hb_codepoint_t)ranges[i].first + glyph; + glyph -= (ranges[i].nLeft + 1); + } + + return 0; + } + + hb_codepoint_t get_glyph (hb_codepoint_t sid, unsigned int num_glyphs) const + { + if (sid == 0) return 0; + hb_codepoint_t glyph = 1; + for (unsigned int i = 0;; i++) + { + if (glyph >= num_glyphs) + return 0; + if ((ranges[i].first <= sid) && (sid <= ranges[i].first + ranges[i].nLeft)) + return glyph + (sid - ranges[i].first); + glyph += (ranges[i].nLeft + 1); + } + + return 0; + } + + unsigned int get_size (unsigned int num_glyphs) const + { + unsigned int size = HBUINT8::static_size; + int glyph = (int)num_glyphs; + + assert (glyph > 0); + glyph--; + for (unsigned int i = 0; glyph > 0; i++) + { + glyph -= (ranges[i].nLeft + 1); + size += Charset_Range<TYPE>::static_size; + } + + return size; + } + + Charset_Range<TYPE> ranges[VAR]; + + DEFINE_SIZE_ARRAY (0, ranges); +}; + +typedef Charset1_2<HBUINT8> Charset1; +typedef Charset1_2<HBUINT16> Charset2; +typedef Charset_Range<HBUINT8> Charset1_Range; +typedef Charset_Range<HBUINT16> Charset2_Range; + +struct Charset { + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + + if (unlikely (!c->check_struct (this))) + return_trace (false); + if (format == 0) + return_trace (u.format0.sanitize (c, c->get_num_glyphs ())); + else if (format == 1) + return_trace (u.format1.sanitize (c, c->get_num_glyphs ())); + else if (likely (format == 2)) + return_trace (u.format2.sanitize (c, c->get_num_glyphs ())); + else + return_trace (false); + } + + /* serialize a fullset Charset */ + bool serialize (hb_serialize_context_t *c, const Charset &src, unsigned int num_glyphs) + { + TRACE_SERIALIZE (this); + unsigned int size = src.get_size (num_glyphs); + Charset *dest = c->allocate_size<Charset> (size); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &src, size); + return_trace (true); + } + + /* serialize a subset Charset */ + bool serialize (hb_serialize_context_t *c, + uint8_t format, + unsigned int num_glyphs, + const hb_vector_t<code_pair>& sid_ranges) + { + TRACE_SERIALIZE (this); + Charset *dest = c->extend_min (*this); + if (unlikely (dest == nullptr)) return_trace (false); + dest->format.set (format); + if (format == 0) + { + Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1)); + if (unlikely (fmt0 == nullptr)) return_trace (false); + unsigned int glyph = 0; + for (unsigned int i = 0; i < sid_ranges.len; i++) + { + hb_codepoint_t sid = sid_ranges[i].code; + for (int left = (int)sid_ranges[i].glyph; left >= 0; left--) + fmt0->sids[glyph++].set (sid++); + } + } + else if (format == 1) + { + Charset1 *fmt1 = c->allocate_size<Charset1> (Charset1::min_size + Charset1_Range::static_size * sid_ranges.len); + if (unlikely (fmt1 == nullptr)) return_trace (false); + for (unsigned int i = 0; i < sid_ranges.len; i++) + { + if (unlikely (!(sid_ranges[i].glyph <= 0xFF))) + return_trace (false); + fmt1->ranges[i].first.set (sid_ranges[i].code); + fmt1->ranges[i].nLeft.set (sid_ranges[i].glyph); + } + } + else /* format 2 */ + { + Charset2 *fmt2 = c->allocate_size<Charset2> (Charset2::min_size + Charset2_Range::static_size * sid_ranges.len); + if (unlikely (fmt2 == nullptr)) return_trace (false); + for (unsigned int i = 0; i < sid_ranges.len; i++) + { + if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF))) + return_trace (false); + fmt2->ranges[i].first.set (sid_ranges[i].code); + fmt2->ranges[i].nLeft.set (sid_ranges[i].glyph); + } + } + return_trace (true); + } + + /* parallel to above: calculate the size of a subset Charset */ + static unsigned int calculate_serialized_size ( + uint8_t format, + unsigned int count) + { + unsigned int size = min_size; + if (format == 0) + size += Charset0::min_size + HBUINT16::static_size * (count - 1); + else if (format == 1) + size += Charset1::min_size + Charset1_Range::static_size * count; + else + size += Charset2::min_size + Charset2_Range::static_size * count; + + return size; + } + + unsigned int get_size (unsigned int num_glyphs) const + { + unsigned int size = min_size; + if (format == 0) + size += u.format0.get_size (num_glyphs); + else if (format == 1) + size += u.format1.get_size (num_glyphs); + else + size += u.format2.get_size (num_glyphs); + return size; + } + + hb_codepoint_t get_sid (hb_codepoint_t glyph) const + { + if (format == 0) + return u.format0.get_sid (glyph); + else if (format == 1) + return u.format1.get_sid (glyph); + else + return u.format2.get_sid (glyph); + } + + hb_codepoint_t get_glyph (hb_codepoint_t sid, unsigned int num_glyphs) const + { + if (format == 0) + return u.format0.get_glyph (sid, num_glyphs); + else if (format == 1) + return u.format1.get_glyph (sid, num_glyphs); + else + return u.format2.get_glyph (sid, num_glyphs); + } + + HBUINT8 format; + union { + Charset0 format0; + Charset1 format1; + Charset2 format2; + } u; + + DEFINE_SIZE_MIN (1); +}; + +struct CFF1StringIndex : CFF1Index +{ + bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings, + unsigned int offSize_, const Remap &sidmap) + { + TRACE_SERIALIZE (this); + if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0))) + { + if (!unlikely (c->extend_min (this->count))) + return_trace (false); + count.set (0); + return_trace (true); + } + + ByteStrArray bytesArray; + bytesArray.init (); + if (!bytesArray.resize (sidmap.get_count ())) + return_trace (false); + for (unsigned int i = 0; i < strings.count; i++) + { + hb_codepoint_t j = sidmap[i]; + if (j != CFF_UNDEF_CODE) + bytesArray[j] = strings[i]; + } + + bool result = CFF1Index::serialize (c, offSize_, bytesArray); + bytesArray.fini (); + return_trace (result); + } + + /* in parallel to above */ + unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const + { + offSize = 0; + if ((count == 0) || (sidmap.get_count () == 0)) + return count.static_size; + + unsigned int dataSize = 0; + for (unsigned int i = 0; i < count; i++) + if (sidmap[i] != CFF_UNDEF_CODE) + dataSize += length_at (i); + + offSize = calcOffSize(dataSize); + return CFF1Index::calculate_serialized_size (offSize, sidmap.get_count (), dataSize); + } +}; + +struct CFF1TopDictInterpEnv : NumInterpEnv +{ + CFF1TopDictInterpEnv () + : NumInterpEnv(), prev_offset(0), last_offset(0) {} + + unsigned int prev_offset; + unsigned int last_offset; +}; + +struct NameDictValues +{ + enum NameDictValIndex + { + version, + notice, + copyright, + fullName, + familyName, + weight, + postscript, + fontName, + baseFontName, + registry, + ordering, + + ValCount + }; + + void init () + { + for (unsigned int i = 0; i < ValCount; i++) + values[i] = CFF_UNDEF_SID; + } + + unsigned int& operator[] (unsigned int i) + { assert (i < ValCount); return values[i]; } + + unsigned int operator[] (unsigned int i) const + { assert (i < ValCount); return values[i]; } + + static enum NameDictValIndex name_op_to_index (OpCode op) + { + switch (op) { + default: // can't happen - just make some compiler happy + case OpCode_version: + return version; + case OpCode_Notice: + return notice; + case OpCode_Copyright: + return copyright; + case OpCode_FullName: + return fullName; + case OpCode_FamilyName: + return familyName; + case OpCode_Weight: + return weight; + case OpCode_PostScript: + return postscript; + case OpCode_FontName: + return fontName; + case OpCode_BaseFontName: + return baseFontName; + } + } + + unsigned int values[ValCount]; +}; + +struct CFF1TopDictVal : OpStr +{ + unsigned int last_arg_offset; +}; + +struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal> +{ + void init () + { + TopDictValues<CFF1TopDictVal>::init (); + + nameSIDs.init (); + ros_supplement = 0; + cidCount = 8720; + EncodingOffset = 0; + CharsetOffset = 0; + FDSelectOffset = 0; + privateDictInfo.init (); + } + void fini () { TopDictValues<CFF1TopDictVal>::fini (); } + + bool is_CID () const + { return nameSIDs[NameDictValues::registry] != CFF_UNDEF_SID; } + + NameDictValues nameSIDs; + unsigned int ros_supplement_offset; + unsigned int ros_supplement; + unsigned int cidCount; + + unsigned int EncodingOffset; + unsigned int CharsetOffset; + unsigned int FDSelectOffset; + TableInfo privateDictInfo; +}; + +struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal> +{ + static void process_op (OpCode op, CFF1TopDictInterpEnv& env, CFF1TopDictValues& dictval) + { + CFF1TopDictVal val; + val.last_arg_offset = (env.last_offset-1) - dictval.opStart; /* offset to the last argument */ + + switch (op) { + case OpCode_version: + case OpCode_Notice: + case OpCode_Copyright: + case OpCode_FullName: + case OpCode_FamilyName: + case OpCode_Weight: + case OpCode_PostScript: + case OpCode_BaseFontName: + dictval.nameSIDs[NameDictValues::name_op_to_index (op)] = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_isFixedPitch: + case OpCode_ItalicAngle: + case OpCode_UnderlinePosition: + case OpCode_UnderlineThickness: + case OpCode_PaintType: + case OpCode_CharstringType: + case OpCode_UniqueID: + case OpCode_StrokeWidth: + case OpCode_SyntheticBase: + case OpCode_CIDFontVersion: + case OpCode_CIDFontRevision: + case OpCode_CIDFontType: + case OpCode_UIDBase: + case OpCode_FontBBox: + case OpCode_XUID: + case OpCode_BaseFontBlend: + env.clear_args (); + break; + + case OpCode_CIDCount: + dictval.cidCount = env.argStack.pop_uint (); + env.clear_args (); + break; + + case OpCode_ROS: + dictval.ros_supplement = env.argStack.pop_uint (); + dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint (); + dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint (); + env.clear_args (); + break; + + case OpCode_Encoding: + dictval.EncodingOffset = env.argStack.pop_uint (); + env.clear_args (); + if (unlikely (dictval.EncodingOffset == 0)) return; + break; + + case OpCode_charset: + dictval.CharsetOffset = env.argStack.pop_uint (); + env.clear_args (); + if (unlikely (dictval.CharsetOffset == 0)) return; + break; + + case OpCode_FDSelect: + dictval.FDSelectOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + + case OpCode_Private: + dictval.privateDictInfo.offset = env.argStack.pop_uint (); + dictval.privateDictInfo.size = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + env.last_offset = env.substr.offset; + TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval); + /* Record this operand below if stack is empty, otherwise done */ + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr, val); + } +}; + +struct CFF1FontDictValues : DictValues<OpStr> +{ + void init () + { + DictValues<OpStr>::init (); + privateDictInfo.init (); + fontName = CFF_UNDEF_SID; + } + void fini () { DictValues<OpStr>::fini (); } + + TableInfo privateDictInfo; + unsigned int fontName; +}; + +struct CFF1FontDictOpSet : DictOpSet +{ + static void process_op (OpCode op, NumInterpEnv& env, CFF1FontDictValues& dictval) + { + switch (op) { + case OpCode_FontName: + dictval.fontName = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_FontMatrix: + case OpCode_PaintType: + env.clear_args (); + break; + case OpCode_Private: + dictval.privateDictInfo.offset = env.argStack.pop_uint (); + dictval.privateDictInfo.size = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr); + } +}; + +template <typename VAL> +struct CFF1PrivateDictValues_Base : DictValues<VAL> +{ + void init () + { + DictValues<VAL>::init (); + subrsOffset = 0; + localSubrs = &Null(CFF1Subrs); + } + void fini () { DictValues<VAL>::fini (); } + + unsigned int calculate_serialized_size () const + { + unsigned int size = 0; + for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++) + if (DictValues<VAL>::get_value (i).op == OpCode_Subrs) + size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); + else + size += DictValues<VAL>::get_value (i).str.len; + return size; + } + + unsigned int subrsOffset; + const CFF1Subrs *localSubrs; +}; + +typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset; +typedef CFF1PrivateDictValues_Base<NumDictVal> CFF1PrivateDictValues; + +struct CFF1PrivateDictOpSet : DictOpSet +{ + static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues& dictval) + { + NumDictVal val; + val.init (); + + switch (op) { + case OpCode_BlueValues: + case OpCode_OtherBlues: + case OpCode_FamilyBlues: + case OpCode_FamilyOtherBlues: + case OpCode_StemSnapH: + case OpCode_StemSnapV: + env.clear_args (); + break; + case OpCode_StdHW: + case OpCode_StdVW: + case OpCode_BlueScale: + case OpCode_BlueShift: + case OpCode_BlueFuzz: + case OpCode_ForceBold: + case OpCode_LanguageGroup: + case OpCode_ExpansionFactor: + case OpCode_initialRandomSeed: + case OpCode_defaultWidthX: + case OpCode_nominalWidthX: + val.single_val = env.argStack.pop_num (); + env.clear_args (); + break; + case OpCode_Subrs: + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr, val); + } +}; + +struct CFF1PrivateDictOpSet_Subset : DictOpSet +{ + static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues_Subset& dictval) + { + switch (op) { + case OpCode_BlueValues: + case OpCode_OtherBlues: + case OpCode_FamilyBlues: + case OpCode_FamilyOtherBlues: + case OpCode_StemSnapH: + case OpCode_StemSnapV: + case OpCode_StdHW: + case OpCode_StdVW: + case OpCode_BlueScale: + case OpCode_BlueShift: + case OpCode_BlueFuzz: + case OpCode_ForceBold: + case OpCode_LanguageGroup: + case OpCode_ExpansionFactor: + case OpCode_initialRandomSeed: + case OpCode_defaultWidthX: + case OpCode_nominalWidthX: + env.clear_args (); + break; + + case OpCode_Subrs: + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr); + } +}; + +typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues, CFF1TopDictInterpEnv> CFF1TopDict_Interpreter; +typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter; +typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_Interpreter; + +typedef CFF1Index CFF1NameIndex; +typedef CFF1IndexOf<TopDict> CFF1TopDictIndex; + +}; /* namespace CFF */ + +namespace OT { + +using namespace CFF; + +struct cff1 +{ + static const hb_tag_t tableTag = HB_OT_TAG_cff1; + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + likely (version.major == 1)); + } + + template <typename PRIVOPSET, typename PRIVDICTVAL> + struct accelerator_templ_t + { + void init (hb_face_t *face) + { + topDict.init (); + fontDicts.init (); + privateDicts.init (); + + this->blob = sc.reference_table<cff1> (face); + + /* setup for run-time santization */ + sc.init (this->blob); + sc.start_processing (); + + const OT::cff1 *cff = this->blob->template as<OT::cff1> (); + + if (cff == &Null(OT::cff1)) + { fini (); return; } + + nameIndex = &cff->nameIndex (cff); + if ((nameIndex == &Null (CFF1NameIndex)) || !nameIndex->sanitize (&sc)) + { fini (); return; } + + topDictIndex = &StructAtOffset<CFF1TopDictIndex> (nameIndex, nameIndex->get_size ()); + if ((topDictIndex == &Null (CFF1TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0)) + { fini (); return; } + + { /* parse top dict */ + const ByteStr topDictStr = (*topDictIndex)[0]; + if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } + CFF1TopDict_Interpreter top_interp; + top_interp.env.init (topDictStr); + topDict.init (); + if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } + } + + if (is_predef_charset ()) + charset = &Null(Charset); + else + { + charset = &StructAtOffsetOrNull<Charset> (cff, topDict.CharsetOffset); + if (unlikely ((charset == &Null (Charset)) || !charset->sanitize (&sc))) { fini (); return; } + } + + fdCount = 1; + if (is_CID ()) + { + fdArray = &StructAtOffsetOrNull<CFF1FDArray> (cff, topDict.FDArrayOffset); + fdSelect = &StructAtOffsetOrNull<CFF1FDSelect> (cff, topDict.FDSelectOffset); + if (unlikely ((fdArray == &Null(CFF1FDArray)) || !fdArray->sanitize (&sc) || + (fdSelect == &Null(CFF1FDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) + { fini (); return; } + + fdCount = fdArray->count; + } + else + { + fdArray = &Null(CFF1FDArray); + fdSelect = &Null(CFF1FDSelect); + } + + stringIndex = &StructAtOffset<CFF1StringIndex> (topDictIndex, topDictIndex->get_size ()); + if ((stringIndex == &Null (CFF1StringIndex)) || !stringIndex->sanitize (&sc)) + { fini (); return; } + + globalSubrs = &StructAtOffset<CFF1Subrs> (stringIndex, stringIndex->get_size ()); + if ((globalSubrs != &Null (CFF1Subrs)) && !globalSubrs->sanitize (&sc)) + { fini (); return; } + + charStrings = &StructAtOffsetOrNull<CFF1CharStrings> (cff, topDict.charStringsOffset); + + if ((charStrings == &Null(CFF1CharStrings)) || unlikely (!charStrings->sanitize (&sc))) + { fini (); return; } + + num_glyphs = charStrings->count; + if (num_glyphs != sc.get_num_glyphs ()) + { fini (); return; } + + privateDicts.resize (fdCount); + for (unsigned int i = 0; i < fdCount; i++) + privateDicts[i].init (); + + // parse CID font dicts and gather private dicts + if (is_CID ()) + { + for (unsigned int i = 0; i < fdCount; i++) + { + ByteStr fontDictStr = (*fdArray)[i]; + if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } + CFF1FontDictValues *font; + CFF1FontDict_Interpreter font_interp; + font_interp.env.init (fontDictStr); + font = fontDicts.push (); + if (unlikely (font == &Crap(CFF1FontDictValues))) { fini (); return; } + font->init (); + if (unlikely (!font_interp.interpret (*font))) { fini (); return; } + PRIVDICTVAL *priv = &privateDicts[i]; + const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp; + priv_interp.env.init (privDictStr); + priv->init (); + if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } + + priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && + unlikely (!priv->localSubrs->sanitize (&sc))) + { fini (); return; } + } + } + else /* non-CID */ + { + CFF1TopDictValues *font = &topDict; + PRIVDICTVAL *priv = &privateDicts[0]; + + const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp; + priv_interp.env.init (privDictStr); + priv->init (); + if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } + + priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && + unlikely (!priv->localSubrs->sanitize (&sc))) + { fini (); return; } + } + } + + void fini () + { + sc.end_processing (); + topDict.fini (); + fontDicts.fini_deep (); + privateDicts.fini_deep (); + hb_blob_destroy (blob); + blob = nullptr; + } + + bool is_valid () const { return blob != nullptr; } + bool is_CID () const { return topDict.is_CID (); } + + bool is_predef_charset () const { return topDict.CharsetOffset <= ExpertSubsetCharset; } + + unsigned int std_code_to_glyph (hb_codepoint_t code) const + { + hb_codepoint_t sid = lookup_standard_encoding_for_sid (code); + if (unlikely (sid == CFF_UNDEF_SID)) + return 0; + + if (charset != &Null(Charset)) + return charset->get_glyph (sid, num_glyphs); + else if ((topDict.CharsetOffset == ISOAdobeCharset) + && (code <= 228 /*zcaron*/)) return sid; + return 0; + } + + protected: + hb_blob_t *blob; + hb_sanitize_context_t sc; + + public: + const Charset *charset; + const CFF1NameIndex *nameIndex; + const CFF1TopDictIndex *topDictIndex; + const CFF1StringIndex *stringIndex; + const CFF1Subrs *globalSubrs; + const CFF1CharStrings *charStrings; + const CFF1FDArray *fdArray; + const CFF1FDSelect *fdSelect; + unsigned int fdCount; + + CFF1TopDictValues topDict; + hb_vector_t<CFF1FontDictValues> fontDicts; + hb_vector_t<PRIVDICTVAL> privateDicts; + + unsigned int num_glyphs; + }; + + struct accelerator_t : accelerator_templ_t<CFF1PrivateDictOpSet, CFF1PrivateDictValues> + { + HB_INTERNAL bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const; + HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const; + }; + + struct accelerator_subset_t : accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> + { + void init (hb_face_t *face) + { + SUPER::init (face); + if (blob == nullptr) return; + + const OT::cff1 *cff = this->blob->as<OT::cff1> (); + encoding = &Null(Encoding); + if (is_CID ()) + { + if (unlikely (charset == &Null(Charset))) { fini (); return; } + } + else + { + if (!is_predef_encoding ()) + { + encoding = &StructAtOffsetOrNull<Encoding> (cff, topDict.EncodingOffset); + if (unlikely ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc))) { fini (); return; } + } + } + } + + bool is_predef_encoding () const { return topDict.EncodingOffset <= ExpertEncoding; } + + hb_codepoint_t glyph_to_code (hb_codepoint_t glyph) const + { + if (encoding != &Null(Encoding)) + return encoding->get_code (glyph); + else + { + hb_codepoint_t sid = glyph_to_sid (glyph); + if (sid == 0) return 0; + hb_codepoint_t code = 0; + switch (topDict.EncodingOffset) + { + case StandardEncoding: + code = lookup_standard_encoding_for_code (sid); + break; + case ExpertEncoding: + code = lookup_expert_encoding_for_code (sid); + break; + default: + break; + } + return code; + } + } + + hb_codepoint_t glyph_to_sid (hb_codepoint_t glyph) const + { + if (charset != &Null(Charset)) + return charset->get_sid (glyph); + else + { + hb_codepoint_t sid = 0; + switch (topDict.CharsetOffset) + { + case ISOAdobeCharset: + if (glyph <= 228 /*zcaron*/) sid = glyph; + break; + case ExpertCharset: + sid = lookup_expert_charset_for_sid (glyph); + break; + case ExpertSubsetCharset: + sid = lookup_expert_subset_charset_for_sid (glyph); + break; + default: + break; + } + return sid; + } + } + + const Encoding *encoding; + + private: + typedef accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> SUPER; + }; + + bool subset (hb_subset_plan_t *plan) const + { + hb_blob_t *cff_prime = nullptr; + + bool success = true; + if (hb_subset_cff1 (plan, &cff_prime)) { + success = success && plan->add_table (HB_OT_TAG_cff1, cff_prime); + hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (plan->source); + success = success && head_blob && plan->add_table (HB_OT_TAG_head, head_blob); + hb_blob_destroy (head_blob); + } else { + success = false; + } + hb_blob_destroy (cff_prime); + + return success; + } + + protected: + HB_INTERNAL static hb_codepoint_t lookup_standard_encoding_for_code (hb_codepoint_t sid); + HB_INTERNAL static hb_codepoint_t lookup_expert_encoding_for_code (hb_codepoint_t sid); + HB_INTERNAL static hb_codepoint_t lookup_expert_charset_for_sid (hb_codepoint_t glyph); + HB_INTERNAL static hb_codepoint_t lookup_expert_subset_charset_for_sid (hb_codepoint_t glyph); + HB_INTERNAL static hb_codepoint_t lookup_standard_encoding_for_sid (hb_codepoint_t code); + + public: + FixedVersion<HBUINT8> version; /* Version of CFF table. set to 0x0100u */ + OffsetTo<CFF1NameIndex, HBUINT8> nameIndex; /* headerSize = Offset to Name INDEX. */ + HBUINT8 offSize; /* offset size (unused?) */ + + public: + DEFINE_SIZE_STATIC (4); +}; + +struct cff1_accelerator_t : cff1::accelerator_t {}; +} /* namespace OT */ + +#endif /* HB_OT_CFF1_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.cc new file mode 100644 index 00000000000..7188a3bfe86 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.cc @@ -0,0 +1,136 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#include "hb-ot-cff2-table.hh" +#include "hb-cff2-interp-cs.hh" + +using namespace CFF; + +struct ExtentsParam +{ + void init () + { + path_open = false; + min_x.set_int (0x7FFFFFFF); + min_y.set_int (0x7FFFFFFF); + max_x.set_int (-0x80000000); + max_y.set_int (-0x80000000); + } + + void start_path () { path_open = true; } + void end_path () { path_open = false; } + bool is_path_open () const { return path_open; } + + void update_bounds (const Point &pt) + { + if (pt.x < min_x) min_x = pt.x; + if (pt.x > max_x) max_x = pt.x; + if (pt.y < min_y) min_y = pt.y; + if (pt.y > max_y) max_y = pt.y; + } + + bool path_open; + Number min_x; + Number min_y; + Number max_x; + Number max_y; +}; + +struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv, ExtentsParam> +{ + static void moveto (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt) + { + param.end_path (); + env.moveto (pt); + } + + static void line (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1) + { + if (!param.is_path_open ()) + { + param.start_path (); + param.update_bounds (env.get_pt ()); + } + env.moveto (pt1); + param.update_bounds (env.get_pt ()); + } + + static void curve (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3) + { + if (!param.is_path_open ()) + { + param.start_path (); + param.update_bounds (env.get_pt ()); + } + /* include control points */ + param.update_bounds (pt1); + param.update_bounds (pt2); + env.moveto (pt3); + param.update_bounds (env.get_pt ()); + } +}; + +struct CFF2CSOpSet_Extents : CFF2CSOpSet<CFF2CSOpSet_Extents, ExtentsParam, CFF2PathProcs_Extents> {}; + +bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents) const +{ + if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false; + + unsigned int num_coords; + const int *coords = hb_font_get_var_coords_normalized (font, &num_coords); + unsigned int fd = fdSelect->get_fd (glyph); + CFF2CSInterpreter<CFF2CSOpSet_Extents, ExtentsParam> interp; + const ByteStr str = (*charStrings)[glyph]; + interp.env.init (str, *this, fd, coords, num_coords); + ExtentsParam param; + param.init (); + if (unlikely (!interp.interpret (param))) return false; + + if (param.min_x >= param.max_x) + { + extents->width = 0; + extents->x_bearing = 0; + } + else + { + extents->x_bearing = (int32_t)param.min_x.floor (); + extents->width = (int32_t)param.max_x.ceil () - extents->x_bearing; + } + if (param.min_y >= param.max_y) + { + extents->height = 0; + extents->y_bearing = 0; + } + else + { + extents->y_bearing = (int32_t)param.max_y.ceil (); + extents->height = (int32_t)param.min_y.floor () - extents->y_bearing; + } + + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.hh new file mode 100644 index 00000000000..25c41ef8cc1 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.hh @@ -0,0 +1,565 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#ifndef HB_OT_CFF2_TABLE_HH +#define HB_OT_CFF2_TABLE_HH + +#include "hb-ot-head-table.hh" +#include "hb-ot-cff-common.hh" +#include "hb-subset-cff2.hh" + +namespace CFF { + +/* + * CFF2 -- Compact Font Format (CFF) Version 2 + * https://docs.microsoft.com/en-us/typography/opentype/spec/cff2 + */ +#define HB_OT_TAG_cff2 HB_TAG('C','F','F','2') + +typedef CFFIndex<HBUINT32> CFF2Index; +template <typename Type> struct CFF2IndexOf : CFFIndexOf<HBUINT32, Type> {}; + +typedef CFF2Index CFF2CharStrings; +typedef FDArray<HBUINT32> CFF2FDArray; +typedef Subrs<HBUINT32> CFF2Subrs; + +typedef FDSelect3_4<HBUINT32, HBUINT16> FDSelect4; +typedef FDSelect3_4_Range<HBUINT32, HBUINT16> FDSelect4_Range; + +struct CFF2FDSelect +{ + bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + { + TRACE_SANITIZE (this); + + return_trace (likely (c->check_struct (this) && (format == 0 || format == 3 || format == 4) && + (format == 0)? + u.format0.sanitize (c, fdcount): + ((format == 3)? + u.format3.sanitize (c, fdcount): + u.format4.sanitize (c, fdcount)))); + } + + bool serialize (hb_serialize_context_t *c, const CFF2FDSelect &src, unsigned int num_glyphs) + { + TRACE_SERIALIZE (this); + unsigned int size = src.get_size (num_glyphs); + CFF2FDSelect *dest = c->allocate_size<CFF2FDSelect> (size); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &src, size); + return_trace (true); + } + + unsigned int calculate_serialized_size (unsigned int num_glyphs) const + { return get_size (num_glyphs); } + + unsigned int get_size (unsigned int num_glyphs) const + { + unsigned int size = format.static_size; + if (format == 0) + size += u.format0.get_size (num_glyphs); + else if (format == 3) + size += u.format3.get_size (); + else + size += u.format4.get_size (); + return size; + } + + hb_codepoint_t get_fd (hb_codepoint_t glyph) const + { + if (this == &Null(CFF2FDSelect)) + return 0; + if (format == 0) + return u.format0.get_fd (glyph); + else if (format == 3) + return u.format3.get_fd (glyph); + else + return u.format4.get_fd (glyph); + } + + HBUINT8 format; + union { + FDSelect0 format0; + FDSelect3 format3; + FDSelect4 format4; + } u; + + DEFINE_SIZE_MIN (2); +}; + +struct CFF2VariationStore +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this)) && c->check_range (&varStore, size) && varStore.sanitize (c)); + } + + bool serialize (hb_serialize_context_t *c, const CFF2VariationStore *varStore) + { + TRACE_SERIALIZE (this); + unsigned int size_ = varStore->get_size (); + CFF2VariationStore *dest = c->allocate_size<CFF2VariationStore> (size_); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, varStore, size_); + return_trace (true); + } + + unsigned int get_size () const { return HBUINT16::static_size + size; } + + HBUINT16 size; + VariationStore varStore; + + DEFINE_SIZE_MIN (2 + VariationStore::min_size); +}; + +struct CFF2TopDictValues : TopDictValues<> +{ + void init () + { + TopDictValues<>::init (); + vstoreOffset = 0; + FDSelectOffset = 0; + } + void fini () { TopDictValues<>::fini (); } + + unsigned int calculate_serialized_size () const + { + unsigned int size = 0; + for (unsigned int i = 0; i < get_count (); i++) + { + OpCode op = get_value (i).op; + switch (op) + { + case OpCode_vstore: + case OpCode_FDSelect: + size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); + break; + default: + size += TopDictValues<>::calculate_serialized_op_size (get_value (i)); + break; + } + } + return size; + } + + unsigned int vstoreOffset; + unsigned int FDSelectOffset; +}; + +struct CFF2TopDictOpSet : TopDictOpSet<> +{ + static void process_op (OpCode op, NumInterpEnv& env, CFF2TopDictValues& dictval) + { + switch (op) { + case OpCode_FontMatrix: + { + DictVal val; + val.init (); + dictval.add_op (op, env.substr); + env.clear_args (); + } + break; + + case OpCode_vstore: + dictval.vstoreOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_FDSelect: + dictval.FDSelectOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + SUPER::process_op (op, env, dictval); + /* Record this operand below if stack is empty, otherwise done */ + if (!env.argStack.is_empty ()) return; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr); + } + + typedef TopDictOpSet<> SUPER; +}; + +struct CFF2FontDictValues : DictValues<OpStr> +{ + void init () + { + DictValues<OpStr>::init (); + privateDictInfo.init (); + } + void fini () { DictValues<OpStr>::fini (); } + + TableInfo privateDictInfo; +}; + +struct CFF2FontDictOpSet : DictOpSet +{ + static void process_op (OpCode op, NumInterpEnv& env, CFF2FontDictValues& dictval) + { + switch (op) { + case OpCode_Private: + dictval.privateDictInfo.offset = env.argStack.pop_uint (); + dictval.privateDictInfo.size = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + SUPER::process_op (op, env); + if (!env.argStack.is_empty ()) + return; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr); + } + + private: + typedef DictOpSet SUPER; +}; + +template <typename VAL> +struct CFF2PrivateDictValues_Base : DictValues<VAL> +{ + void init () + { + DictValues<VAL>::init (); + subrsOffset = 0; + localSubrs = &Null(CFF2Subrs); + ivs = 0; + } + void fini () { DictValues<VAL>::fini (); } + + unsigned int calculate_serialized_size () const + { + unsigned int size = 0; + for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++) + if (DictValues<VAL>::get_value (i).op == OpCode_Subrs) + size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); + else + size += DictValues<VAL>::get_value (i).str.len; + return size; + } + + unsigned int subrsOffset; + const CFF2Subrs *localSubrs; + unsigned int ivs; +}; + +typedef CFF2PrivateDictValues_Base<OpStr> CFF2PrivateDictValues_Subset; +typedef CFF2PrivateDictValues_Base<NumDictVal> CFF2PrivateDictValues; + +struct CFF2PrivDictInterpEnv : NumInterpEnv +{ + void init (const ByteStr &str) + { + NumInterpEnv::init (str); + ivs = 0; + seen_vsindex = false; + } + + void process_vsindex () + { + if (likely (!seen_vsindex)) + { + set_ivs (argStack.pop_uint ()); + } + seen_vsindex = true; + } + + unsigned int get_ivs () const { return ivs; } + void set_ivs (unsigned int ivs_) { ivs = ivs_; } + + protected: + unsigned int ivs; + bool seen_vsindex; +}; + +struct CFF2PrivateDictOpSet : DictOpSet +{ + static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues& dictval) + { + NumDictVal val; + val.init (); + + switch (op) { + case OpCode_StdHW: + case OpCode_StdVW: + case OpCode_BlueScale: + case OpCode_BlueShift: + case OpCode_BlueFuzz: + case OpCode_ExpansionFactor: + case OpCode_LanguageGroup: + val.single_val = env.argStack.pop_num (); + env.clear_args (); + break; + case OpCode_BlueValues: + case OpCode_OtherBlues: + case OpCode_FamilyBlues: + case OpCode_FamilyOtherBlues: + case OpCode_StemSnapH: + case OpCode_StemSnapV: + env.clear_args (); + break; + case OpCode_Subrs: + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + case OpCode_vsindexdict: + env.process_vsindex (); + dictval.ivs = env.get_ivs (); + env.clear_args (); + break; + case OpCode_blenddict: + break; + + default: + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr, val); + } +}; + +struct CFF2PrivateDictOpSet_Subset : DictOpSet +{ + static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues_Subset& dictval) + { + switch (op) { + case OpCode_BlueValues: + case OpCode_OtherBlues: + case OpCode_FamilyBlues: + case OpCode_FamilyOtherBlues: + case OpCode_StdHW: + case OpCode_StdVW: + case OpCode_BlueScale: + case OpCode_BlueShift: + case OpCode_BlueFuzz: + case OpCode_StemSnapH: + case OpCode_StemSnapV: + case OpCode_LanguageGroup: + case OpCode_ExpansionFactor: + env.clear_args (); + break; + + case OpCode_blenddict: + env.clear_args (); + return; + + case OpCode_Subrs: + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; + + default: + SUPER::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; + } + + if (unlikely (env.in_error ())) return; + + dictval.add_op (op, env.substr); + } + + private: + typedef DictOpSet SUPER; +}; + +typedef DictInterpreter<CFF2TopDictOpSet, CFF2TopDictValues> CFF2TopDict_Interpreter; +typedef DictInterpreter<CFF2FontDictOpSet, CFF2FontDictValues> CFF2FontDict_Interpreter; + +}; /* namespace CFF */ + +namespace OT { + +using namespace CFF; + +struct cff2 +{ + static const hb_tag_t tableTag = HB_OT_TAG_cff2; + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + likely (version.major == 2)); + } + + template <typename PRIVOPSET, typename PRIVDICTVAL> + struct accelerator_templ_t + { + void init (hb_face_t *face) + { + topDict.init (); + fontDicts.init (); + privateDicts.init (); + + this->blob = sc.reference_table<cff2> (face); + + /* setup for run-time santization */ + sc.init (this->blob); + sc.start_processing (); + + const OT::cff2 *cff2 = this->blob->template as<OT::cff2> (); + + if (cff2 == &Null(OT::cff2)) + { fini (); return; } + + { /* parse top dict */ + ByteStr topDictStr (cff2 + cff2->topDict, cff2->topDictSize); + if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } + CFF2TopDict_Interpreter top_interp; + top_interp.env.init (topDictStr); + topDict.init (); + if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } + } + + globalSubrs = &StructAtOffset<CFF2Subrs> (cff2, cff2->topDict + cff2->topDictSize); + varStore = &StructAtOffsetOrNull<CFF2VariationStore> (cff2, topDict.vstoreOffset); + charStrings = &StructAtOffsetOrNull<CFF2CharStrings> (cff2, topDict.charStringsOffset); + fdArray = &StructAtOffsetOrNull<CFF2FDArray> (cff2, topDict.FDArrayOffset); + fdSelect = &StructAtOffsetOrNull<CFF2FDSelect> (cff2, topDict.FDSelectOffset); + + if (((varStore != &Null(CFF2VariationStore)) && unlikely (!varStore->sanitize (&sc))) || + (charStrings == &Null(CFF2CharStrings)) || unlikely (!charStrings->sanitize (&sc)) || + (globalSubrs == &Null(CFF2Subrs)) || unlikely (!globalSubrs->sanitize (&sc)) || + (fdArray == &Null(CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) || + (((fdSelect != &Null(CFF2FDSelect)) && unlikely (!fdSelect->sanitize (&sc, fdArray->count))))) + { fini (); return; } + + num_glyphs = charStrings->count; + if (num_glyphs != sc.get_num_glyphs ()) + { fini (); return; } + + fdCount = fdArray->count; + privateDicts.resize (fdCount); + + /* parse font dicts and gather private dicts */ + for (unsigned int i = 0; i < fdCount; i++) + { + const ByteStr fontDictStr = (*fdArray)[i]; + if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } + CFF2FontDictValues *font; + CFF2FontDict_Interpreter font_interp; + font_interp.env.init (fontDictStr); + font = fontDicts.push (); + if (unlikely (font == &Crap(CFF2FontDictValues))) { fini (); return; } + font->init (); + if (unlikely (!font_interp.interpret (*font))) { fini (); return; } + + const ByteStr privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter<PRIVOPSET, PRIVDICTVAL, CFF2PrivDictInterpEnv> priv_interp; + priv_interp.env.init(privDictStr); + privateDicts[i].init (); + if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; } + + privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (privDictStr.str, privateDicts[i].subrsOffset); + if (privateDicts[i].localSubrs != &Null(CFF2Subrs) && + unlikely (!privateDicts[i].localSubrs->sanitize (&sc))) + { fini (); return; } + } + } + + void fini () + { + sc.end_processing (); + fontDicts.fini_deep (); + privateDicts.fini_deep (); + hb_blob_destroy (blob); + blob = nullptr; + } + + bool is_valid () const { return blob != nullptr; } + + protected: + hb_blob_t *blob; + hb_sanitize_context_t sc; + + public: + CFF2TopDictValues topDict; + const CFF2Subrs *globalSubrs; + const CFF2VariationStore *varStore; + const CFF2CharStrings *charStrings; + const CFF2FDArray *fdArray; + const CFF2FDSelect *fdSelect; + unsigned int fdCount; + + hb_vector_t<CFF2FontDictValues> fontDicts; + hb_vector_t<PRIVDICTVAL> privateDicts; + + unsigned int num_glyphs; + }; + + struct accelerator_t : accelerator_templ_t<CFF2PrivateDictOpSet, CFF2PrivateDictValues> + { + HB_INTERNAL bool get_extents (hb_font_t *font, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents) const; + }; + + typedef accelerator_templ_t<CFF2PrivateDictOpSet_Subset, CFF2PrivateDictValues_Subset> accelerator_subset_t; + + bool subset (hb_subset_plan_t *plan) const + { + hb_blob_t *cff2_prime = nullptr; + + bool success = true; + if (hb_subset_cff2 (plan, &cff2_prime)) { + success = success && plan->add_table (HB_OT_TAG_cff2, cff2_prime); + hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (plan->source); + success = success && head_blob && plan->add_table (HB_OT_TAG_head, head_blob); + hb_blob_destroy (head_blob); + } else { + success = false; + } + hb_blob_destroy (cff2_prime); + + return success; + } + + public: + FixedVersion<HBUINT8> version; /* Version of CFF2 table. set to 0x0200u */ + OffsetTo<TopDict, HBUINT8, false> topDict; /* headerSize = Offset to Top DICT. */ + HBUINT16 topDictSize; /* Top DICT size */ + + public: + DEFINE_SIZE_STATIC (5); +}; + +struct cff2_accelerator_t : cff2::accelerator_t {}; +} /* namespace OT */ + +#endif /* HB_OT_CFF2_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh index cdc610be3ea..7567e52cf1e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh @@ -41,7 +41,7 @@ namespace OT { struct CmapSubtableFormat0 { - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { hb_codepoint_t gid = codepoint < 256 ? glyphIdArray[codepoint] : 0; if (!gid) @@ -49,14 +49,14 @@ struct CmapSubtableFormat0 *glyph = gid; return true; } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { for (unsigned int i = 0; i < 256; i++) if (glyphIdArray[i]) out->add (i); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -154,7 +154,7 @@ struct CmapSubtableFormat4 return_trace (true); } - static inline size_t get_sub_table_size (const hb_vector_t<segment_plan> &segments) + static size_t get_sub_table_size (const hb_vector_t<segment_plan> &segments) { size_t segment_size = 0; for (unsigned int i = 0; i < segments.len; i++) @@ -176,8 +176,8 @@ struct CmapSubtableFormat4 + segment_size; } - static inline bool create_sub_table_plan (const hb_subset_plan_t *plan, - hb_vector_t<segment_plan> *segments) + static bool create_sub_table_plan (const hb_subset_plan_t *plan, + hb_vector_t<segment_plan> *segments) { segment_plan *segment = nullptr; hb_codepoint_t last_gid = 0; @@ -226,11 +226,11 @@ struct CmapSubtableFormat4 struct accelerator_t { - inline accelerator_t (void) {} - inline accelerator_t (const CmapSubtableFormat4 *subtable) { init (subtable); } - inline ~accelerator_t (void) { fini (); } + accelerator_t () {} + accelerator_t (const CmapSubtableFormat4 *subtable) { init (subtable); } + ~accelerator_t () { fini (); } - inline void init (const CmapSubtableFormat4 *subtable) + void init (const CmapSubtableFormat4 *subtable) { segCount = subtable->segCountX2 / 2; endCount = subtable->values.arrayZ; @@ -240,9 +240,9 @@ struct CmapSubtableFormat4 glyphIdArray = idRangeOffset + segCount; glyphIdArrayLength = (subtable->length - 16 - 8 * segCount) / 2; } - inline void fini (void) {} + void fini () {} - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { /* Custom two-array bsearch. */ int min = 0, max = (int) this->segCount - 1; @@ -286,11 +286,11 @@ struct CmapSubtableFormat4 *glyph = gid; return true; } - static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) + static bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) { return ((const accelerator_t *) obj)->get_glyph (codepoint, glyph); } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { unsigned int count = this->segCount; if (count && this->startCount[count - 1] == 0xFFFFu) @@ -327,18 +327,18 @@ struct CmapSubtableFormat4 unsigned int glyphIdArrayLength; }; - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { accelerator_t accel (this); return accel.get_glyph_func (&accel, codepoint, glyph); } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { accelerator_t accel (this); accel.collect_unicodes (out); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) @@ -403,7 +403,7 @@ struct CmapSubtableLongGroup return 0; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -422,7 +422,7 @@ DECLARE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup); template <typename UINT> struct CmapSubtableTrimmed { - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { /* Rely on our implicit array bound-checking. */ hb_codepoint_t gid = glyphIdArray[codepoint - startCharCode]; @@ -431,7 +431,7 @@ struct CmapSubtableTrimmed *glyph = gid; return true; } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { hb_codepoint_t start = startCharCode; unsigned int count = glyphIdArray.len; @@ -440,7 +440,7 @@ struct CmapSubtableTrimmed out->add (start + i); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && glyphIdArray.sanitize (c)); @@ -466,7 +466,7 @@ struct CmapSubtableLongSegmented { friend struct cmap; - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const { hb_codepoint_t gid = T::group_get_glyph (groups.bsearch (codepoint), codepoint); if (!gid) @@ -475,7 +475,7 @@ struct CmapSubtableLongSegmented return true; } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { for (unsigned int i = 0; i < this->groups.len; i++) { out->add_range (this->groups[i].startCharCode, @@ -484,19 +484,18 @@ struct CmapSubtableLongSegmented } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && groups.sanitize (c)); } - inline bool serialize (hb_serialize_context_t *c, - const hb_vector_t<CmapSubtableLongGroup> &group_data) + bool serialize (hb_serialize_context_t *c, + const hb_vector_t<CmapSubtableLongGroup> &group_data) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - Supplier<CmapSubtableLongGroup> supplier (group_data, group_data.len); - if (unlikely (!groups.serialize (c, supplier, group_data.len))) return_trace (false); + if (unlikely (!groups.serialize (c, group_data.as_array ()))) return_trace (false); return true; } @@ -513,8 +512,8 @@ struct CmapSubtableLongSegmented struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> { - static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, - hb_codepoint_t u) + static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, + hb_codepoint_t u) { return likely (group.startCharCode <= group.endCharCode) ? group.glyphID + (u - group.startCharCode) : 0; } @@ -531,13 +530,13 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> return CmapSubtableLongSegmented<CmapSubtableFormat12>::serialize (c, groups); } - static inline size_t get_sub_table_size (const hb_vector_t<CmapSubtableLongGroup> &groups) + static size_t get_sub_table_size (const hb_vector_t<CmapSubtableLongGroup> &groups) { return 16 + 12 * groups.len; } - static inline bool create_sub_table_plan (const hb_subset_plan_t *plan, - hb_vector_t<CmapSubtableLongGroup> *groups) + static bool create_sub_table_plan (const hb_subset_plan_t *plan, + hb_vector_t<CmapSubtableLongGroup> *groups) { CmapSubtableLongGroup *group = nullptr; @@ -570,9 +569,9 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> } private: - static inline bool _is_gid_consecutive (CmapSubtableLongGroup *group, - hb_codepoint_t cp, - hb_codepoint_t new_gid) + static bool _is_gid_consecutive (CmapSubtableLongGroup *group, + hb_codepoint_t cp, + hb_codepoint_t new_gid) { return (cp - 1 == group->endCharCode) && new_gid == group->glyphID + (cp - group->startCharCode); @@ -582,8 +581,8 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> struct CmapSubtableFormat13 : CmapSubtableLongSegmented<CmapSubtableFormat13> { - static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, - hb_codepoint_t u HB_UNUSED) + static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, + hb_codepoint_t u HB_UNUSED) { return group.glyphID; } }; @@ -596,14 +595,14 @@ typedef enum struct UnicodeValueRange { - inline int cmp (const hb_codepoint_t &codepoint) const + int cmp (const hb_codepoint_t &codepoint) const { if (codepoint < startUnicodeValue) return -1; if (codepoint > startUnicodeValue + additionalCount) return +1; return 0; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -618,7 +617,7 @@ struct UnicodeValueRange struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32> { - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { unsigned int count = len; for (unsigned int i = 0; i < count; i++) @@ -636,12 +635,12 @@ struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32> struct UVSMapping { - inline int cmp (const hb_codepoint_t &codepoint) const + int cmp (const hb_codepoint_t &codepoint) const { return unicodeValue.cmp (codepoint); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -655,7 +654,7 @@ struct UVSMapping struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32> { - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { unsigned int count = len; for (unsigned int i = 0; i < count; i++) @@ -668,9 +667,9 @@ struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32> struct VariationSelectorRecord { - inline glyph_variant_t get_glyph (hb_codepoint_t codepoint, - hb_codepoint_t *glyph, - const void *base) const + glyph_variant_t get_glyph (hb_codepoint_t codepoint, + hb_codepoint_t *glyph, + const void *base) const { if ((base+defaultUVS).bfind (codepoint)) return GLYPH_VARIANT_USE_DEFAULT; @@ -683,18 +682,18 @@ struct VariationSelectorRecord return GLYPH_VARIANT_NOT_FOUND; } - inline void collect_unicodes (hb_set_t *out, const void *base) const + void collect_unicodes (hb_set_t *out, const void *base) const { (base+defaultUVS).collect_unicodes (out); (base+nonDefaultUVS).collect_unicodes (out); } - inline int cmp (const hb_codepoint_t &variation_selector) const + int cmp (const hb_codepoint_t &variation_selector) const { return varSelector.cmp (variation_selector); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -713,26 +712,26 @@ struct VariationSelectorRecord struct CmapSubtableFormat14 { - inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const + glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) const { return record.bsearch (variation_selector).get_glyph (codepoint, glyph, this); } - inline void collect_variation_selectors (hb_set_t *out) const + void collect_variation_selectors (hb_set_t *out) const { unsigned int count = record.len; for (unsigned int i = 0; i < count; i++) out->add (record.arrayZ[i].varSelector); } - inline void collect_variation_unicodes (hb_codepoint_t variation_selector, - hb_set_t *out) const + void collect_variation_unicodes (hb_codepoint_t variation_selector, + hb_set_t *out) const { record.bsearch (variation_selector).collect_unicodes (out, this); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -753,8 +752,8 @@ struct CmapSubtable { /* Note: We intentionally do NOT implement subtable formats 2 and 8. */ - inline bool get_glyph (hb_codepoint_t codepoint, - hb_codepoint_t *glyph) const + bool get_glyph (hb_codepoint_t codepoint, + hb_codepoint_t *glyph) const { switch (u.format) { case 0: return u.format0 .get_glyph (codepoint, glyph); @@ -767,7 +766,7 @@ struct CmapSubtable default: return false; } } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { switch (u.format) { case 0: u.format0 .collect_unicodes (out); return; @@ -781,7 +780,7 @@ struct CmapSubtable } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -815,7 +814,7 @@ struct CmapSubtable struct EncodingRecord { - inline int cmp (const EncodingRecord &other) const + int cmp (const EncodingRecord &other) const { int ret; ret = platformID.cmp (other.platformID); @@ -825,7 +824,7 @@ struct EncodingRecord return 0; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -842,11 +841,11 @@ struct EncodingRecord struct cmap { - static const hb_tag_t tableTag = HB_OT_TAG_cmap; + enum { tableTag = HB_OT_TAG_cmap }; struct subset_plan { - inline size_t final_size () const + size_t final_size () const { return 4 // header + 8 * 3 // 3 EncodingRecord @@ -858,8 +857,8 @@ struct cmap hb_vector_t<CmapSubtableLongGroup> format12_groups; }; - inline bool _create_plan (const hb_subset_plan_t *plan, - subset_plan *cmap_plan) const + bool _create_plan (const hb_subset_plan_t *plan, + subset_plan *cmap_plan) const { if (unlikely (!CmapSubtableFormat4::create_sub_table_plan (plan, &cmap_plan->format4_segments))) return false; @@ -867,10 +866,10 @@ struct cmap 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, - size_t dest_sz, - void *dest) const + bool _subset (const hb_subset_plan_t *plan, + const subset_plan &cmap_subset_plan, + size_t dest_sz, + void *dest) const { hb_serialize_context_t c (dest, dest_sz); @@ -928,7 +927,7 @@ struct cmap return true; } - inline bool subset (hb_subset_plan_t *plan) const + bool subset (hb_subset_plan_t *plan) const { subset_plan cmap_subset_plan; @@ -995,7 +994,7 @@ struct cmap struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { this->table = hb_sanitize_context_t ().reference_table<cmap> (face); bool symbol; @@ -1031,22 +1030,19 @@ struct cmap } } - inline void fini (void) - { - this->table.destroy (); - } + void fini () { this->table.destroy (); } - inline bool get_nominal_glyph (hb_codepoint_t unicode, + bool get_nominal_glyph (hb_codepoint_t unicode, hb_codepoint_t *glyph) const { 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 + 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; @@ -1064,9 +1060,9 @@ struct cmap return done; } - inline bool get_variation_glyph (hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const + bool get_variation_glyph (hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) const { switch (this->subtable_uvs->get_glyph_variant (unicode, variation_selector, @@ -1080,16 +1076,16 @@ struct cmap return get_nominal_glyph (unicode, glyph); } - inline void collect_unicodes (hb_set_t *out) const + void collect_unicodes (hb_set_t *out) const { subtable->collect_unicodes (out); } - inline void collect_variation_selectors (hb_set_t *out) const + void collect_variation_selectors (hb_set_t *out) const { subtable_uvs->collect_variation_selectors (out); } - inline void collect_variation_unicodes (hb_codepoint_t variation_selector, - hb_set_t *out) const + void collect_variation_unicodes (hb_codepoint_t variation_selector, + hb_set_t *out) const { subtable_uvs->collect_variation_unicodes (variation_selector, out); } @@ -1100,16 +1096,16 @@ struct cmap hb_codepoint_t *glyph); template <typename Type> - static inline bool get_glyph_from (const void *obj, - hb_codepoint_t codepoint, - hb_codepoint_t *glyph) + static bool get_glyph_from (const void *obj, + hb_codepoint_t codepoint, + hb_codepoint_t *glyph) { const Type *typed_obj = (const Type *) obj; return typed_obj->get_glyph (codepoint, glyph); } template <typename Type> - static inline bool get_glyph_from_symbol (const void *obj, + static bool get_glyph_from_symbol (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) { @@ -1144,8 +1140,8 @@ struct cmap protected: - inline const CmapSubtable *find_subtable (unsigned int platform_id, - unsigned int encoding_id) const + const CmapSubtable *find_subtable (unsigned int platform_id, + unsigned int encoding_id) const { EncodingRecord key; key.platformID.set (platform_id); @@ -1160,7 +1156,7 @@ struct cmap public: - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh index 47774fd8f0a..b1971a7615b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh @@ -45,13 +45,13 @@ namespace OT { struct SmallGlyphMetrics { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } - inline void get_extents (hb_glyph_extents_t *extents) const + void get_extents (hb_glyph_extents_t *extents) const { extents->x_bearing = bearingX; extents->y_bearing = bearingY; @@ -79,7 +79,7 @@ struct BigGlyphMetrics : SmallGlyphMetrics struct SBitLineMetrics { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -108,7 +108,7 @@ struct SBitLineMetrics struct IndexSubtableHeader { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -124,7 +124,7 @@ struct IndexSubtableHeader template <typename OffsetType> struct IndexSubtableFormat1Or3 { - inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const + bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -155,7 +155,7 @@ struct IndexSubtableFormat3 : IndexSubtableFormat1Or3<HBUINT16> {}; struct IndexSubtable { - inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const + bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const { TRACE_SANITIZE (this); if (!u.header.sanitize (c)) return_trace (false); @@ -166,7 +166,7 @@ struct IndexSubtable } } - inline bool get_extents (hb_glyph_extents_t *extents HB_UNUSED) const + bool get_extents (hb_glyph_extents_t *extents HB_UNUSED) const { switch (u.header.indexFormat) { case 2: case 5: /* TODO */ @@ -201,7 +201,7 @@ struct IndexSubtable struct IndexSubtableRecord { - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -209,8 +209,8 @@ struct IndexSubtableRecord offsetToSubtable.sanitize (c, base, lastGlyphIndex - firstGlyphIndex + 1)); } - inline bool get_extents (hb_glyph_extents_t *extents, - const void *base) const + bool get_extents (hb_glyph_extents_t *extents, + const void *base) const { return (base+offsetToSubtable).get_extents (extents); } @@ -237,7 +237,7 @@ struct IndexSubtableArray { friend struct CBDT; - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); return_trace (indexSubtablesZ.sanitize (c, count, this)); @@ -265,7 +265,7 @@ struct BitmapSizeTable friend struct CBLC; friend struct CBDT; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -332,9 +332,9 @@ struct CBLC { friend struct CBDT; - static const hb_tag_t tableTag = HB_OT_TAG_CBLC; + enum { tableTag = HB_OT_TAG_CBLC }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -378,11 +378,11 @@ struct CBLC struct CBDT { - static const hb_tag_t tableTag = HB_OT_TAG_CBDT; + enum { tableTag = HB_OT_TAG_CBDT }; struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { cblc = hb_sanitize_context_t().reference_table<CBLC> (face); cbdt = hb_sanitize_context_t().reference_table<CBDT> (face); @@ -390,14 +390,14 @@ struct CBDT upem = hb_face_get_upem (face); } - inline void fini (void) + void fini () { this->cblc.destroy (); this->cbdt.destroy (); } - inline bool get_extents (hb_font_t *font, hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const + bool get_extents (hb_font_t *font, hb_codepoint_t glyph, + hb_glyph_extents_t *extents) const { const void *base; const BitmapSizeTable &strike = this->cblc->choose_strike (font); @@ -452,7 +452,7 @@ struct CBDT return true; } - inline hb_blob_t* reference_png (hb_font_t *font, + hb_blob_t* reference_png (hb_font_t *font, hb_codepoint_t glyph) const { const void *base; @@ -505,7 +505,7 @@ struct CBDT return hb_blob_get_empty (); } - inline bool has_data () const { return cbdt.get_length (); } + bool has_data () const { return cbdt.get_length (); } private: hb_blob_ptr_t<CBLC> cblc; @@ -514,7 +514,7 @@ struct CBDT unsigned int upem; }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh index 84c34332556..3883604a535 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-colr-table.hh @@ -39,7 +39,7 @@ namespace OT { struct LayerRecord { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -63,10 +63,10 @@ struct LayerRecord struct BaseGlyphRecord { - inline int cmp (hb_codepoint_t g) const + int cmp (hb_codepoint_t g) const { return g < glyphId ? -1 : g > glyphId ? 1 : 0; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -87,14 +87,14 @@ struct BaseGlyphRecord struct COLR { - static const hb_tag_t tableTag = HB_OT_TAG_COLR; + enum { tableTag = HB_OT_TAG_COLR }; - inline bool has_data (void) const { return numBaseGlyphs; } + bool has_data () 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 + 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); @@ -114,7 +114,7 @@ struct COLR return glyph_layers.len; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh index 332f0dd7452..bd57d8a3591 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh @@ -48,39 +48,36 @@ struct CPALV1Tail friend struct CPAL; private: - inline hb_ot_color_palette_flags_t - get_palette_flags (const void *base, - unsigned int palette_index, - unsigned int palette_count) const + hb_ot_color_palette_flags_t get_palette_flags (const void *base, + unsigned int palette_index, + unsigned int palette_count) const { 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]; } - inline hb_ot_name_id_t - get_palette_name_id (const void *base, - unsigned int palette_index, - unsigned int palette_count) const + hb_ot_name_id_t get_palette_name_id (const void *base, + unsigned int palette_index, + unsigned int palette_count) const { if (!paletteLabelsZ) return HB_OT_NAME_ID_INVALID; return (base+paletteLabelsZ).as_array (palette_count)[palette_index]; } - inline hb_ot_name_id_t - get_color_name_id (const void *base, - unsigned int color_index, - unsigned int color_count) const + hb_ot_name_id_t get_color_name_id (const void *base, + unsigned int color_index, + unsigned int color_count) const { 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 + 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) && @@ -110,29 +107,29 @@ typedef HBUINT32 BGRAColor; struct CPAL { - static const hb_tag_t tableTag = HB_OT_TAG_CPAL; + enum { tableTag = HB_OT_TAG_CPAL }; - inline bool has_data (void) const { return numPalettes; } + bool has_data () const { return numPalettes; } - inline unsigned int get_size (void) const + unsigned int get_size () const { return min_size + numPalettes * sizeof (colorRecordIndicesZ[0]); } - inline unsigned int get_palette_count () const { return numPalettes; } - inline unsigned int get_color_count () const { return numColors; } + unsigned int get_palette_count () const { return numPalettes; } + unsigned int get_color_count () const { return numColors; } - inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const + hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const { return v1 ().get_palette_flags (this, palette_index, numPalettes); } - inline hb_ot_name_id_t get_palette_name_id (unsigned int palette_index) const + hb_ot_name_id_t get_palette_name_id (unsigned int palette_index) const { return v1 ().get_palette_name_id (this, palette_index, numPalettes); } - inline hb_ot_name_id_t get_color_name_id (unsigned int color_index) const + 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_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 + 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 { if (unlikely (palette_index >= numPalettes)) { @@ -156,14 +153,14 @@ struct CPAL } private: - inline const CPALV1Tail& v1 (void) const + const CPALV1Tail& v1 () const { if (version == 0) return Null(CPALV1Tail); return StructAfter<CPALV1Tail> (*this); } public: - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh index 08dee2a0c67..ed93d6526b5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-sbix-table.hh @@ -62,20 +62,20 @@ struct SBIXGlyph struct SBIXStrike { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && imageOffsetsZ.sanitize_shallow (c, c->get_num_glyphs () + 1)); } - 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 + 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. */ @@ -130,43 +130,36 @@ struct SBIXStrike struct sbix { - static const hb_tag_t tableTag = HB_OT_TAG_sbix; + enum { tableTag = HB_OT_TAG_sbix }; - inline bool has_data (void) const { return version; } + bool has_data () const { return version; } - inline const SBIXStrike &get_strike (unsigned int i) const { return this+strikes[i]; } + const SBIXStrike &get_strike (unsigned int i) const { return this+strikes[i]; } struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { table = hb_sanitize_context_t().reference_table<sbix> (face); num_glyphs = face->get_num_glyphs (); } + void fini () { table.destroy (); } - inline void fini (void) - { - table.destroy (); - } - - inline bool has_data () const - { - return table->has_data (); - } + 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 + 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 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 + 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 { return choose_strike (font).get_glyph_blob (glyph_id, table.get_blob (), HB_TAG ('p','n','g',' '), @@ -176,7 +169,7 @@ struct sbix private: - inline const SBIXStrike &choose_strike (hb_font_t *font) const + const SBIXStrike &choose_strike (hb_font_t *font) const { unsigned count = table->strikes.len; if (unlikely (!count)) @@ -226,9 +219,9 @@ struct sbix DEFINE_SIZE_STATIC (29); }; - inline bool get_png_extents (hb_font_t *font, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const + 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. */ @@ -267,7 +260,7 @@ struct sbix unsigned int num_glyphs; }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh index ad3551035c8..554453f7594 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-svg-table.hh @@ -40,17 +40,17 @@ namespace OT { struct SVGDocumentIndexEntry { - inline int cmp (hb_codepoint_t g) const + int cmp (hb_codepoint_t g) const { return g < startGlyphID ? -1 : g > endGlyphID ? 1 : 0; } - inline hb_blob_t *reference_blob (hb_blob_t *svg_blob, unsigned int index_offset) const + 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 + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -73,40 +73,32 @@ struct SVGDocumentIndexEntry struct SVG { - static const hb_tag_t tableTag = HB_OT_TAG_SVG; + enum { tableTag = HB_OT_TAG_SVG }; - inline bool has_data (void) const { return svgDocEntries; } + bool has_data () const { return svgDocEntries; } struct accelerator_t { - inline void init (hb_face_t *face) - { - table = hb_sanitize_context_t().reference_table<SVG> (face); - } + void init (hb_face_t *face) + { table = hb_sanitize_context_t().reference_table<SVG> (face); } + void fini () { table.destroy (); } - inline void fini (void) - { - table.destroy (); - } - - inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const + hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const { return table->get_glyph_entry (glyph_id).reference_blob (table.get_blob (), table->svgDocEntries); } - inline bool has_data () const { return table->has_data (); } + bool has_data () const { return table->has_data (); } 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); - } + 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.h index a4f2053291e..49646bf3ac2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color.h @@ -71,7 +71,7 @@ hb_ot_color_palette_color_get_name_id (hb_face_t *face, 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_FLAG_USABLE_WITH_DARK_BACKGROUND = 0x00000002u } hb_ot_color_palette_flags_t; HB_EXTERN hb_ot_color_palette_flags_t diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-deprecated.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-deprecated.h new file mode 100644 index 00000000000..bce51b71e78 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-deprecated.h @@ -0,0 +1,107 @@ +/* + * 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_H_IN +#error "Include <hb-ot.h> instead." +#endif + +#ifndef HB_OT_DEPRECATED_H +#define HB_OT_DEPRECATED_H + +#include "hb.h" +#include "hb-ot-name.h" + + +HB_BEGIN_DECLS + +#ifndef HB_DISABLE_DEPRECATED + + +/* 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); + + +/** + * HB_OT_VAR_NO_AXIS_INDEX: + * + * Since: 1.4.2 + * Deprecated: 2.2.0 + */ +#define HB_OT_VAR_NO_AXIS_INDEX 0xFFFFFFFFu + +/** + * hb_ot_var_axis_t: + * + * Since: 1.4.2 + * Deprecated: 2.2.0 + */ +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 + +#endif /* HB_OT_DEPRECATED_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc index c7dafdd4ab9..9b17526b7e4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.cc @@ -28,6 +28,8 @@ #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" +#include "hb-ot-cff1-table.hh" +#include "hb-ot-cff2-table.hh" #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" #include "hb-ot-name-table.hh" @@ -49,7 +51,7 @@ void hb_ot_face_t::init0 (hb_face_t *face) #undef HB_OT_ACCELERATOR #undef HB_OT_TABLE } -void hb_ot_face_t::fini (void) +void hb_ot_face_t::fini () { #define HB_OT_TABLE(Namespace, Type) Type.fini (); #define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh index 4a3260626c2..7f47ba6cb8e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-face.hh @@ -47,6 +47,8 @@ HB_OT_ACCELERATOR(OT, post) \ HB_OT_TABLE(OT, kern) \ HB_OT_ACCELERATOR(OT, glyf) \ + HB_OT_ACCELERATOR(OT, cff1) \ + HB_OT_ACCELERATOR(OT, cff2) \ HB_OT_TABLE(OT, VORG) \ HB_OT_ACCELERATOR(OT, name) \ HB_OT_TABLE(OT, OS2) \ @@ -90,7 +92,7 @@ HB_OT_TABLES struct hb_ot_face_t { HB_INTERNAL void init0 (hb_face_t *face); - HB_INTERNAL void fini (void); + HB_INTERNAL void fini (); #define HB_OT_TABLE_ORDER(Namespace, Type) \ HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc index 7c91362509c..c080f0fd937 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc @@ -34,6 +34,8 @@ #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" +#include "hb-ot-cff1-table.hh" +#include "hb-ot-cff2-table.hh" #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" #include "hb-ot-os2-table.hh" @@ -182,6 +184,10 @@ hb_ot_get_glyph_extents (hb_font_t *font, if (!ret) ret = ot_face->glyf->get_extents (glyph, extents); if (!ret) + ret = ot_face->cff1->get_extents (glyph, extents); + if (!ret) + ret = ot_face->cff2->get_extents (font, 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); @@ -244,12 +250,12 @@ hb_ot_get_font_v_extents (hb_font_t *font, } #if HB_USE_ATEXIT -static void free_static_ot_funcs (void); +static void free_static_ot_funcs (); #endif 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) + static hb_font_funcs_t *create () { hb_font_funcs_t *funcs = hb_font_funcs_create (); @@ -279,14 +285,14 @@ static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot #if HB_USE_ATEXIT static -void free_static_ot_funcs (void) +void free_static_ot_funcs () { static_ot_funcs.free_instance (); } #endif static hb_font_funcs_t * -_hb_ot_get_font_funcs (void) +_hb_ot_get_font_funcs () { return static_ot_funcs.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-gasp-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-gasp-table.hh new file mode 100644 index 00000000000..d328fd22243 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-gasp-table.hh @@ -0,0 +1,84 @@ +/* + * 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_GASP_TABLE_HH +#define HB_OT_GASP_TABLE_HH + +#include "hb-open-type.hh" +#include "hb-ot-hhea-table.hh" +#include "hb-ot-os2-table.hh" +#include "hb-ot-var-hvar-table.hh" + +/* + * gasp -- Grid-fitting and Scan-conversion Procedure + * https://docs.microsoft.com/en-us/typography/opentype/spec/gasp + */ +#define HB_OT_TAG_gasp HB_TAG('g','a','s','p') + + +namespace OT { + +struct GaspRange +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + public: + HBUINT16 rangeMaxPPEM; /* Upper limit of range, in PPEM */ + HBUINT16 rangeGaspBehavior; + /* Flags describing desired rasterizer behavior. */ + public: + DEFINE_SIZE_STATIC (4); +}; + +struct gasp +{ + enum { tableTag = HB_OT_TAG_gasp }; + + const GaspRange &get_gasp_range (unsigned int i) const + { return gaspRanges[i]; } + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + gaspRanges.sanitize (c)); + } + + protected: + HBUINT16 version; /* Version number (set to 1) */ + ArrayOf<GaspRange> + gaspRanges; /* Number of records to follow + * Sorted by ppem */ + public: + DEFINE_SIZE_ARRAY (4, gaspRanges); +}; + +} /* namespace OT */ + + +#endif /* HB_OT_GASP_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh index c88f43385b4..a6dec40d240 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh @@ -45,9 +45,9 @@ struct loca { friend struct glyf; - static const hb_tag_t tableTag = HB_OT_TAG_loca; + enum { tableTag = HB_OT_TAG_loca }; - inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const + bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const { TRACE_SANITIZE (this); return_trace (true); @@ -71,9 +71,9 @@ struct loca struct glyf { - static const hb_tag_t tableTag = HB_OT_TAG_glyf; + enum { tableTag = HB_OT_TAG_glyf }; - inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const + 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 @@ -81,7 +81,7 @@ struct glyf return_trace (true); } - inline bool subset (hb_subset_plan_t *plan) const + bool subset (hb_subset_plan_t *plan) const { hb_blob_t *glyf_prime = nullptr; hb_blob_t *loca_prime = nullptr; @@ -153,7 +153,7 @@ struct glyf HBUINT16 flags; GlyphID glyphIndex; - inline unsigned int get_size (void) const + unsigned int get_size () const { unsigned int size = min_size; // arg1 and 2 are int16 @@ -177,7 +177,7 @@ struct glyf const char *glyph_end; const CompositeGlyphHeader *current; - inline bool move_to_next () + bool move_to_next () { if (current->flags & CompositeGlyphHeader::MORE_COMPONENTS) { @@ -191,7 +191,7 @@ struct glyf return false; } - inline bool in_range (const CompositeGlyphHeader *composite) const + bool in_range (const CompositeGlyphHeader *composite) const { return (const char *) composite >= glyph_start && ((const char *) composite + CompositeGlyphHeader::min_size) <= glyph_end @@ -199,7 +199,7 @@ struct glyf } }; - static inline bool get_iterator (const char * glyph_data, + static bool get_iterator (const char * glyph_data, unsigned int length, CompositeGlyphHeader::Iterator *iterator /* OUT */) { @@ -228,7 +228,7 @@ struct glyf struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { memset (this, 0, sizeof (accelerator_t)); @@ -244,7 +244,7 @@ struct glyf num_glyphs = MAX (1u, loca_table.get_length () / (short_offset ? 2 : 4)) - 1; } - inline void fini (void) + void fini () { loca_table.destroy (); glyf_table.destroy (); @@ -255,8 +255,8 @@ struct glyf * If true is returned a pointer to the composite glyph will be written into * composite. */ - inline bool get_composite (hb_codepoint_t glyph, - CompositeGlyphHeader::Iterator *composite /* OUT */) const + bool get_composite (hb_codepoint_t glyph, + CompositeGlyphHeader::Iterator *composite /* OUT */) const { if (unlikely (!num_glyphs)) return false; @@ -271,15 +271,18 @@ struct glyf } enum simple_glyph_flag_t { + FLAG_ON_CURVE = 0x01, FLAG_X_SHORT = 0x02, FLAG_Y_SHORT = 0x04, FLAG_REPEAT = 0x08, FLAG_X_SAME = 0x10, - FLAG_Y_SAME = 0x20 + FLAG_Y_SAME = 0x20, + FLAG_RESERVED1 = 0x40, + FLAG_RESERVED2 = 0x80 }; /* based on FontTools _g_l_y_f.py::trim */ - inline bool remove_padding (unsigned int start_offset, + bool remove_padding (unsigned int start_offset, unsigned int *end_offset) const { if (*end_offset - start_offset < GlyphHeader::static_size) return true; @@ -351,7 +354,7 @@ struct glyf return true; } - inline bool get_offsets (hb_codepoint_t glyph, + bool get_offsets (hb_codepoint_t glyph, unsigned int *start_offset /* OUT */, unsigned int *end_offset /* OUT */) const { @@ -378,10 +381,10 @@ struct glyf 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 + 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) { @@ -437,8 +440,7 @@ struct glyf return true; } - inline bool get_extents (hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const + bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const { unsigned int start_offset, end_offset; if (!get_offsets (glyph, &start_offset, &end_offset)) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh index 0fea24bca24..48421ee2cbb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh @@ -47,21 +47,19 @@ struct DeviceRecord unsigned int sizeDeviceRecord; hb_subset_plan_t *subset_plan; - inline void init (const DeviceRecord *source_device_record, - unsigned int sizeDeviceRecord, - hb_subset_plan_t *subset_plan) + void init (const DeviceRecord *source_device_record, + unsigned int sizeDeviceRecord, + hb_subset_plan_t *subset_plan) { this->source_device_record = source_device_record; this->sizeDeviceRecord = sizeDeviceRecord; this->subset_plan = subset_plan; } - inline unsigned int len () const - { - return this->subset_plan->glyphs.len; - } + unsigned int len () const + { return this->subset_plan->glyphs.len; } - inline const HBUINT8* operator [] (unsigned int i) const + const HBUINT8* operator [] (unsigned int i) const { if (unlikely (i >= len ())) return nullptr; hb_codepoint_t gid = this->subset_plan->glyphs [i]; @@ -72,12 +70,10 @@ struct DeviceRecord } }; - static inline unsigned int get_size (unsigned int count) - { - return hb_ceil_to_4 (min_size + count * HBUINT8::static_size); - } + static unsigned int get_size (unsigned int count) + { return hb_ceil_to_4 (min_size + count * HBUINT8::static_size); } - inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view) + bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view) { TRACE_SERIALIZE (this); @@ -106,7 +102,7 @@ struct DeviceRecord return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int sizeDeviceRecord) const + bool sanitize (hb_sanitize_context_t *c, unsigned int sizeDeviceRecord) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -123,14 +119,12 @@ struct DeviceRecord struct hdmx { - static const hb_tag_t tableTag = HB_OT_TAG_hdmx; + enum { tableTag = HB_OT_TAG_hdmx }; - inline unsigned int get_size (void) const - { - return min_size + numRecords * sizeDeviceRecord; - } + unsigned int get_size () const + { return min_size + numRecords * sizeDeviceRecord; } - inline const DeviceRecord& operator [] (unsigned int i) const + const DeviceRecord& operator [] (unsigned int i) const { /* XXX Null(DeviceRecord) is NOT safe as it's num-glyphs lengthed. * https://github.com/harfbuzz/harfbuzz/issues/1300 */ @@ -138,7 +132,7 @@ struct hdmx return StructAtOffset<DeviceRecord> (&this->firstDeviceRecord, i * sizeDeviceRecord); } - inline bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan) + bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan) { TRACE_SERIALIZE (this); @@ -160,12 +154,12 @@ struct hdmx return_trace (true); } - static inline size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan) + static size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan) { return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->glyphs.len); } - inline bool subset (hb_subset_plan_t *plan) const + bool subset (hb_subset_plan_t *plan) const { size_t dest_size = get_subsetted_size (this, plan); hdmx *dest = (hdmx *) malloc (dest_size); @@ -196,7 +190,7 @@ struct hdmx return result; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh index 602e365ce5d..41062ca326a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh @@ -45,16 +45,29 @@ struct head { friend struct OffsetTable; - static const hb_tag_t tableTag = HB_OT_TAG_head; + enum { tableTag = HB_OT_TAG_head }; - inline unsigned int get_upem (void) const + unsigned int get_upem () const { unsigned int upem = unitsPerEm; /* If no valid head table found, assume 1000, which matches typical Type1 usage. */ return 16 <= upem && upem <= 16384 ? upem : 1000; } - inline bool sanitize (hb_sanitize_context_t *c) const + enum mac_style_flag_t { + BOLD = 1u<<0, + ITALIC = 1u<<1, + UNDERLINE = 1u<<2, + OUTLINE = 1u<<3, + SHADOW = 1u<<4, + CONDENSED = 1u<<5 + }; + + bool is_bold () const { return macStyle & BOLD; } + bool is_italic () const { return macStyle & ITALIC; } + bool is_condensed () const { return macStyle & CONDENSED; } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh index 3336cadd472..7bc1817eefe 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh @@ -45,7 +45,7 @@ namespace OT { template <typename T> struct _hea { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && likely (version.major == 1)); @@ -86,10 +86,10 @@ struct _hea }; struct hhea : _hea<hhea> { - static const hb_tag_t tableTag = HB_OT_TAG_hhea; + enum { tableTag = HB_OT_TAG_hhea }; }; struct vhea : _hea<vhea> { - static const hb_tag_t tableTag = HB_OT_TAG_vhea; + enum { tableTag = HB_OT_TAG_vhea }; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh index 091b601173f..fa74a0e3858 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh @@ -56,7 +56,7 @@ struct LongMetric template <typename T, typename H> struct hmtxvmtx { - inline bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const + 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 @@ -65,7 +65,7 @@ struct hmtxvmtx } - inline bool subset_update_header (hb_subset_plan_t *plan, + bool subset_update_header (hb_subset_plan_t *plan, unsigned int num_hmetrics) const { hb_blob_t *src_blob = hb_sanitize_context_t ().reference_table<H> (plan->source, H::tableTag); @@ -86,7 +86,7 @@ struct hmtxvmtx return result; } - inline bool subset (hb_subset_plan_t *plan) const + bool subset (hb_subset_plan_t *plan) const { typename T::accelerator_t _mtx; _mtx.init (plan->source); @@ -186,22 +186,18 @@ struct hmtxvmtx { friend struct hmtxvmtx; - inline void init (hb_face_t *face, + void init (hb_face_t *face, unsigned int default_advance_ = 0) { default_advance = default_advance_ ? default_advance_ : hb_face_get_upem (face); bool got_font_extents = false; - if (T::os2Tag) + if (T::os2Tag != HB_TAG_NONE && face->table.OS2->is_typo_metrics ()) { -#define USE_TYPO_METRICS (1u<<7) - if (0 != (face->table.OS2->fsSelection & USE_TYPO_METRICS)) - { - ascender = abs (face->table.OS2->sTypoAscender); - descender = -abs (face->table.OS2->sTypoDescender); - line_gap = face->table.OS2->sTypoLineGap; - got_font_extents = (ascender | descender) != 0; - } + 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_t *_hea_blob = hb_sanitize_context_t().reference_table<H> (face); @@ -238,14 +234,14 @@ struct hmtxvmtx var_table = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag); } - inline void fini (void) + void fini () { table.destroy (); var_table.destroy (); } /* TODO Add variations version. */ - inline unsigned int get_side_bearing (hb_codepoint_t glyph) const + unsigned int get_side_bearing (hb_codepoint_t glyph) const { if (glyph < num_advances) return table->longMetricZ[glyph].sb; @@ -257,7 +253,7 @@ struct hmtxvmtx return bearings[glyph - num_advances]; } - inline unsigned int get_advance (hb_codepoint_t glyph) const + unsigned int get_advance (hb_codepoint_t glyph) const { if (unlikely (glyph >= num_metrics)) { @@ -273,8 +269,8 @@ struct hmtxvmtx return table->longMetricZ[MIN (glyph, (uint32_t) num_advances - 1)].advance; } - inline unsigned int get_advance (hb_codepoint_t glyph, - hb_font_t *font) const + unsigned int get_advance (hb_codepoint_t glyph, + hb_font_t *font) const { unsigned int advance = get_advance (glyph); if (likely (glyph < num_metrics)) @@ -327,14 +323,14 @@ 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; + enum { tableTag = HB_OT_TAG_hmtx }; + enum { variationsTag = HB_OT_TAG_HVAR }; + enum { os2Tag = HB_OT_TAG_OS2 }; }; struct vmtx : hmtxvmtx<vmtx, vhea> { - static const hb_tag_t tableTag = HB_OT_TAG_vmtx; - static const hb_tag_t variationsTag = HB_OT_TAG_VVAR; - static const hb_tag_t os2Tag = HB_TAG_NONE; + enum { tableTag = HB_OT_TAG_vmtx }; + enum { variationsTag = HB_OT_TAG_VVAR }; + enum { os2Tag = HB_TAG_NONE }; }; struct hmtx_accelerator_t : hmtx::accelerator_t {}; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh index b57ebaea8dc..5e75d083b76 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh @@ -44,7 +44,7 @@ namespace OT { template <typename KernSubTableHeader> struct KernSubTableFormat3 { - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const + int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const { hb_array_t<const FWORD> kernValue = kernValueZ.as_array (kernValueCount); hb_array_t<const HBUINT8> leftClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (kernValue).as_array (glyphCount); @@ -59,7 +59,7 @@ struct KernSubTableFormat3 return kernValue[kernIndex[i]]; } - inline bool apply (AAT::hb_aat_apply_context_t *c) const + bool apply (AAT::hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -75,7 +75,7 @@ struct KernSubTableFormat3 return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -109,10 +109,10 @@ struct KernSubTableFormat3 template <typename KernSubTableHeader> struct KernSubTable { - inline unsigned int get_size (void) const { return u.header.length; } - inline unsigned int get_type (void) const { return u.header.format; } + unsigned int get_size () const { return u.header.length; } + unsigned int get_type () const { return u.header.format; } - inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const + int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const { switch (get_type ()) { /* This method hooks up to hb_font_t's get_h_kerning. Only support Format0. */ @@ -122,7 +122,7 @@ struct KernSubTable } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -135,7 +135,7 @@ struct KernSubTable } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!u.header.sanitize (c) || @@ -160,11 +160,11 @@ struct KernSubTable struct KernOTSubTableHeader { - static const bool apple = false; + enum { apple = false }; typedef AAT::ObsoleteTypes Types; - inline unsigned int tuple_count (void) const { return 0; } - inline bool is_horizontal (void) const { return (coverage & Horizontal); } + unsigned int tuple_count () const { return 0; } + bool is_horizontal () const { return (coverage & Horizontal); } enum Coverage { @@ -178,7 +178,7 @@ struct KernOTSubTableHeader Variation = 0x00u, }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -197,8 +197,8 @@ struct KernOT : AAT::KerxTable<KernOT> { friend struct AAT::KerxTable<KernOT>; - static const hb_tag_t tableTag = HB_OT_TAG_kern; - static const uint16_t minVersion = 0; + enum { tableTag = HB_OT_TAG_kern }; + enum { minVersion = 0u }; typedef KernOTSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; @@ -215,11 +215,11 @@ struct KernOT : AAT::KerxTable<KernOT> struct KernAATSubTableHeader { - static const bool apple = true; + enum { apple = true }; typedef AAT::ObsoleteTypes Types; - inline unsigned int tuple_count (void) const { return 0; } - inline bool is_horizontal (void) const { return !(coverage & Vertical); } + unsigned int tuple_count () const { return 0; } + bool is_horizontal () const { return !(coverage & Vertical); } enum Coverage { @@ -231,7 +231,7 @@ struct KernAATSubTableHeader Backwards = 0x00u, }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -252,8 +252,8 @@ struct KernAAT : AAT::KerxTable<KernAAT> { friend struct AAT::KerxTable<KernAAT>; - static const hb_tag_t tableTag = HB_OT_TAG_kern; - static const uint32_t minVersion = 0x00010000u; + enum { tableTag = HB_OT_TAG_kern }; + enum { minVersion = 0x00010000u }; typedef KernAATSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; @@ -269,12 +269,12 @@ struct KernAAT : AAT::KerxTable<KernAAT> struct kern { - static const hb_tag_t tableTag = HB_OT_TAG_kern; + enum { tableTag = HB_OT_TAG_kern }; - inline bool has_data (void) const { return u.version32; } - inline unsigned int get_type (void) const { return u.major; } + bool has_data () const { return u.version32; } + unsigned int get_type () const { return u.major; } - inline bool has_state_machine (void) const + bool has_state_machine () const { switch (get_type ()) { case 0: return u.ot.has_state_machine (); @@ -283,7 +283,7 @@ struct kern } } - inline bool has_cross_stream (void) const + bool has_cross_stream () const { switch (get_type ()) { case 0: return u.ot.has_cross_stream (); @@ -292,7 +292,7 @@ struct kern } } - inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const + int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const { switch (get_type ()) { case 0: return u.ot.get_h_kerning (left, right); @@ -301,11 +301,11 @@ struct kern } } - inline bool apply (AAT::hb_aat_apply_context_t *c) const + bool apply (AAT::hb_aat_apply_context_t *c) const { return dispatch (c); } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { unsigned int subtable_type = get_type (); TRACE_DISPATCH (this, subtable_type); @@ -316,7 +316,7 @@ struct kern } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.version32.sanitize (c)) return_trace (false); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh index fb57e76242e..6c39932670f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-base-table.hh @@ -44,9 +44,9 @@ namespace OT { struct BaseCoordFormat1 { - inline hb_position_t get_coord () const { return coordinate; } + hb_position_t get_coord () const { return coordinate; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -61,13 +61,13 @@ struct BaseCoordFormat1 struct BaseCoordFormat2 { - inline hb_position_t get_coord () const + hb_position_t get_coord () const { /* TODO */ return coordinate; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -85,9 +85,9 @@ struct BaseCoordFormat2 struct BaseCoordFormat3 { - inline hb_position_t get_coord (hb_font_t *font, - const VariationStore &var_store, - hb_direction_t direction) const + hb_position_t get_coord (hb_font_t *font, + const VariationStore &var_store, + hb_direction_t direction) const { const Device &device = this+deviceTable; return coordinate + (HB_DIRECTION_IS_VERTICAL (direction) ? @@ -96,7 +96,7 @@ struct BaseCoordFormat3 } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -116,9 +116,9 @@ struct BaseCoordFormat3 struct BaseCoord { - inline hb_position_t get_coord (hb_font_t *font, - const VariationStore &var_store, - hb_direction_t direction) const + hb_position_t get_coord (hb_font_t *font, + const VariationStore &var_store, + hb_direction_t direction) const { switch (u.format) { case 1: return u.format1.get_coord (); @@ -128,7 +128,7 @@ struct BaseCoord } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!u.format.sanitize (c))) return_trace (false); @@ -162,13 +162,13 @@ struct FeatMinMaxRecord 0; } - inline void get_min_max (const BaseCoord **min, const BaseCoord **max) const + 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 + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -194,7 +194,7 @@ struct FeatMinMaxRecord struct MinMax { - inline void get_min_max (hb_tag_t feature_tag, + void get_min_max (hb_tag_t feature_tag, const BaseCoord **min, const BaseCoord **max) const { @@ -213,7 +213,7 @@ struct MinMax } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -241,13 +241,13 @@ struct MinMax struct BaseValues { - inline const BaseCoord &get_base_coord (int baseline_tag_index) const + const BaseCoord &get_base_coord (int baseline_tag_index) const { if (baseline_tag_index == -1) baseline_tag_index = defaultIndex; return this+baseCoords[baseline_tag_index]; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -280,10 +280,10 @@ struct BaseLangSysRecord 0; } - inline const MinMax &get_min_max () const + const MinMax &get_min_max () const { return this+minMax; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -301,7 +301,7 @@ struct BaseLangSysRecord struct BaseScript { - inline const MinMax &get_min_max (hb_tag_t language_tag) const + const MinMax &get_min_max (hb_tag_t language_tag) const { /* TODO Replace hb_bsearch() with .bsearch(). */ const BaseLangSysRecord* record = (const BaseLangSysRecord *) @@ -312,13 +312,12 @@ struct BaseScript return record ? record->get_min_max () : this+defaultMinMax; } - inline const BaseCoord &get_base_coord (int baseline_tag_index) const + const BaseCoord &get_base_coord (int baseline_tag_index) const { return (this+baseValues).get_base_coord (baseline_tag_index); } - inline bool is_empty () const - { return !baseValues; } + bool is_empty () const { return !baseValues; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -355,10 +354,10 @@ struct BaseScriptRecord 0; } - inline const BaseScript &get_base_script (const BaseScriptList *list) const + const BaseScript &get_base_script (const BaseScriptList *list) const { return list+baseScript; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -377,7 +376,7 @@ struct BaseScriptRecord struct BaseScriptList { - inline const BaseScriptRecord *find_record (hb_tag_t script) const + const BaseScriptRecord *find_record (hb_tag_t script) const { /* TODO Replace hb_bsearch() with .bsearch(). */ return (const BaseScriptRecord *) hb_bsearch (&script, baseScriptRecords.arrayZ, @@ -387,7 +386,7 @@ struct BaseScriptList } /* TODO: Or client should handle fallback? */ - inline const BaseScript &get_base_script (hb_tag_t script) const + const BaseScript &get_base_script (hb_tag_t script) const { const BaseScriptRecord *record = find_record (script); if (!record) record = find_record ((hb_script_t) HB_TAG ('D','F','L','T')); @@ -395,7 +394,7 @@ struct BaseScriptList return record ? record->get_base_script (this) : Null (BaseScript); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -412,7 +411,7 @@ struct BaseScriptList struct Axis { - inline bool get_baseline (hb_ot_layout_baseline_t baseline, + bool get_baseline (hb_ot_layout_baseline_t baseline, hb_tag_t script_tag, hb_tag_t language_tag, const BaseCoord **coord) const @@ -425,11 +424,11 @@ struct Axis return true; } - 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 + 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 { const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag); if (base_script.is_empty ()) return false; @@ -439,7 +438,7 @@ struct Axis return true; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && @@ -465,20 +464,20 @@ struct Axis struct BASE { - static const hb_tag_t tableTag = HB_OT_TAG_BASE; + enum { tableTag = HB_OT_TAG_BASE }; - inline const Axis &get_axis (hb_direction_t direction) const + const Axis &get_axis (hb_direction_t direction) const { return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; } - inline const VariationStore &get_var_store () const + const VariationStore &get_var_store () const { return version.to_int () < 0x00010001u ? Null (VariationStore) : this+varStore; } - 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 + 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 { const BaseCoord *base_coord; if (!get_axis (direction).get_baseline (baseline, script_tag, language_tag, &base_coord)) @@ -491,13 +490,13 @@ struct BASE } /* 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) + 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) { const BaseCoord *min_coord, *max_coord; if (!get_axis (direction).get_min_max (script_tag, language_tag, feature_tag, @@ -510,7 +509,7 @@ struct BASE return true; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common.hh index b5af73af64a..d9f5728b65c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-common.hh @@ -86,11 +86,9 @@ struct Record_sanitize_closure_t { template <typename Type> struct Record { - inline int cmp (hb_tag_t a) const { - return tag.cmp (a); - } + int cmp (hb_tag_t a) const { return tag.cmp (a); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); const Record_sanitize_closure_t closure = {tag, base}; @@ -108,15 +106,15 @@ struct Record template <typename Type> struct RecordArrayOf : SortedArrayOf<Record<Type> > { - inline const OffsetTo<Type>& get_offset (unsigned int i) const + const OffsetTo<Type>& get_offset (unsigned int i) const { return (*this)[i].offset; } - inline OffsetTo<Type>& get_offset (unsigned int i) + OffsetTo<Type>& get_offset (unsigned int i) { return (*this)[i].offset; } - inline const Tag& get_tag (unsigned int i) const + const Tag& get_tag (unsigned int i) const { return (*this)[i].tag; } - inline unsigned int get_tags (unsigned int start_offset, - unsigned int *record_count /* IN/OUT */, - hb_tag_t *record_tags /* OUT */) const + unsigned int get_tags (unsigned int start_offset, + unsigned int *record_count /* IN/OUT */, + hb_tag_t *record_tags /* OUT */) const { if (record_count) { const Record<Type> *arr = this->sub_array (start_offset, record_count); @@ -126,7 +124,7 @@ struct RecordArrayOf : SortedArrayOf<Record<Type> > } return this->len; } - inline bool find_index (hb_tag_t tag, unsigned int *index) const + bool find_index (hb_tag_t tag, unsigned int *index) const { return this->bfind (tag, index, HB_BFIND_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX); } @@ -135,10 +133,10 @@ struct RecordArrayOf : SortedArrayOf<Record<Type> > template <typename Type> struct RecordListOf : RecordArrayOf<Type> { - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (unsigned int i) const { return this+this->get_offset (i); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct RecordListOf<Type> *out = c->serializer->embed (*this); @@ -149,7 +147,7 @@ struct RecordListOf : RecordArrayOf<Type> return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (RecordArrayOf<Type>::sanitize (c, this)); @@ -159,23 +157,21 @@ struct RecordListOf : RecordArrayOf<Type> struct RangeRecord { - inline int cmp (hb_codepoint_t g) const { - return g < start ? -1 : g <= end ? 0 : +1 ; - } + int cmp (hb_codepoint_t g) const + { return g < start ? -1 : g <= end ? 0 : +1; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return glyphs->intersects (start, end); } template <typename set_t> - inline bool add_coverage (set_t *glyphs) const { - return glyphs->add_range (start, end); - } + bool add_coverage (set_t *glyphs) const + { return glyphs->add_range (start, end); } GlyphID start; /* First GlyphID in the range */ GlyphID end; /* Last GlyphID in the range */ @@ -188,9 +184,9 @@ DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord); struct IndexArray : ArrayOf<Index> { - inline unsigned int get_indexes (unsigned int start_offset, - unsigned int *_count /* IN/OUT */, - unsigned int *_indexes /* OUT */) const + unsigned int get_indexes (unsigned int start_offset, + unsigned int *_count /* IN/OUT */, + unsigned int *_indexes /* OUT */) const { if (_count) { const HBUINT16 *arr = this->sub_array (start_offset, _count); @@ -201,7 +197,7 @@ struct IndexArray : ArrayOf<Index> return this->len; } - inline void add_indexes_to (hb_set_t* output /* OUT */) const + void add_indexes_to (hb_set_t* output /* OUT */) const { output->add_array (arrayZ, len); } @@ -215,33 +211,33 @@ struct Feature; struct LangSys { - inline unsigned int get_feature_count (void) const + unsigned int get_feature_count () const { return featureIndex.len; } - inline hb_tag_t get_feature_index (unsigned int i) const + hb_tag_t get_feature_index (unsigned int i) const { return featureIndex[i]; } - inline unsigned int get_feature_indexes (unsigned int start_offset, - unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */) const + unsigned int get_feature_indexes (unsigned int start_offset, + unsigned int *feature_count /* IN/OUT */, + unsigned int *feature_indexes /* OUT */) const { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); } - inline void add_feature_indexes_to (hb_set_t *feature_indexes) const + void add_feature_indexes_to (hb_set_t *feature_indexes) const { featureIndex.add_indexes_to (feature_indexes); } - inline bool has_required_feature (void) const { return reqFeatureIndex != 0xFFFFu; } - inline unsigned int get_required_feature_index (void) const + bool has_required_feature () const { return reqFeatureIndex != 0xFFFFu; } + unsigned int get_required_feature_index () const { if (reqFeatureIndex == 0xFFFFu) return Index::NOT_FOUND_INDEX; return reqFeatureIndex;; } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); return_trace (c->serializer->embed (*this)); } - inline bool sanitize (hb_sanitize_context_t *c, - const Record_sanitize_closure_t * = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + const Record_sanitize_closure_t * = nullptr) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && featureIndex.sanitize (c)); @@ -260,26 +256,26 @@ DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys); struct Script { - inline unsigned int get_lang_sys_count (void) const + unsigned int get_lang_sys_count () const { return langSys.len; } - inline const Tag& get_lang_sys_tag (unsigned int i) const + const Tag& get_lang_sys_tag (unsigned int i) const { return langSys.get_tag (i); } - inline unsigned int get_lang_sys_tags (unsigned int start_offset, - unsigned int *lang_sys_count /* IN/OUT */, - hb_tag_t *lang_sys_tags /* OUT */) const + unsigned int get_lang_sys_tags (unsigned int start_offset, + unsigned int *lang_sys_count /* IN/OUT */, + hb_tag_t *lang_sys_tags /* OUT */) const { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } - inline const LangSys& get_lang_sys (unsigned int i) const + const LangSys& get_lang_sys (unsigned int i) const { if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); return this+langSys[i].offset; } - inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const + bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const { return langSys.find_index (tag, index); } - inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } - inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } + bool has_default_lang_sys () const { return defaultLangSys != 0; } + const LangSys& get_default_lang_sys () const { return this+defaultLangSys; } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct Script *out = c->serializer->embed (*this); @@ -291,8 +287,8 @@ struct Script return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, - const Record_sanitize_closure_t * = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + const Record_sanitize_closure_t * = nullptr) const { TRACE_SANITIZE (this); return_trace (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this)); @@ -315,7 +311,7 @@ typedef RecordListOf<Script> ScriptList; /* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */ struct FeatureParamsSize { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) return_trace (false); @@ -427,7 +423,7 @@ struct FeatureParamsSize /* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#ssxx */ struct FeatureParamsStylisticSet { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); /* Right now minorVersion is at zero. Which means, any table supports @@ -461,7 +457,7 @@ struct FeatureParamsStylisticSet /* https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#cv01-cv99 */ struct FeatureParamsCharacterVariants { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -502,7 +498,7 @@ struct FeatureParamsCharacterVariants struct FeatureParams { - inline bool sanitize (hb_sanitize_context_t *c, hb_tag_t tag) const + bool sanitize (hb_sanitize_context_t *c, hb_tag_t tag) const { TRACE_SANITIZE (this); if (tag == HB_TAG ('s','i','z','e')) @@ -514,21 +510,21 @@ struct FeatureParams return_trace (true); } - inline const FeatureParamsSize& get_size_params (hb_tag_t tag) const + const FeatureParamsSize& get_size_params (hb_tag_t tag) const { if (tag == HB_TAG ('s','i','z','e')) return u.size; return Null (FeatureParamsSize); } - inline const FeatureParamsStylisticSet& get_stylistic_set_params (hb_tag_t tag) const + 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 + const FeatureParamsCharacterVariants& get_character_variants_params (hb_tag_t tag) const { if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */ return u.characterVariants; @@ -547,21 +543,21 @@ struct FeatureParams struct Feature { - inline unsigned int get_lookup_count (void) const + unsigned int get_lookup_count () const { return lookupIndex.len; } - inline hb_tag_t get_lookup_index (unsigned int i) const + hb_tag_t get_lookup_index (unsigned int i) const { return lookupIndex[i]; } - inline unsigned int get_lookup_indexes (unsigned int start_index, - unsigned int *lookup_count /* IN/OUT */, - unsigned int *lookup_tags /* OUT */) const + unsigned int get_lookup_indexes (unsigned int start_index, + 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 + 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 + const FeatureParams &get_feature_params () const { return this+featureParams; } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct Feature *out = c->serializer->embed (*this); @@ -570,8 +566,8 @@ struct Feature return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c, - const Record_sanitize_closure_t *closure = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + const Record_sanitize_closure_t *closure = nullptr) const { TRACE_SANITIZE (this); if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c)))) @@ -650,20 +646,20 @@ namespace OT { struct Lookup { - inline unsigned int get_subtable_count (void) const { return subTable.len; } + unsigned int get_subtable_count () const { return subTable.len; } template <typename TSubTable> - inline const TSubTable& get_subtable (unsigned int i) const + const TSubTable& get_subtable (unsigned int i) const { return this+CastR<OffsetArrayOf<TSubTable> > (subTable)[i]; } template <typename TSubTable> - inline const OffsetArrayOf<TSubTable>& get_subtables (void) const + const OffsetArrayOf<TSubTable>& get_subtables () const { return CastR<OffsetArrayOf<TSubTable> > (subTable); } template <typename TSubTable> - inline OffsetArrayOf<TSubTable>& get_subtables (void) + OffsetArrayOf<TSubTable>& get_subtables () { return CastR<OffsetArrayOf<TSubTable> > (subTable); } - inline unsigned int get_size (void) const + unsigned int get_size () const { const HBUINT16 &markFilteringSet = StructAfter<const HBUINT16> (subTable); if (lookupFlag & LookupFlag::UseMarkFilteringSet) @@ -671,12 +667,12 @@ struct Lookup return (const char *) &markFilteringSet - (const char *) this; } - inline unsigned int get_type (void) const { return lookupType; } + unsigned int get_type () const { return lookupType; } /* lookup_props is a 32-bit integer where the lower 16-bit is LookupFlag and * higher 16-bit is mark-filtering-set if the lookup uses one. * Not to be confused with glyph_props which is very similar. */ - inline uint32_t get_props (void) const + uint32_t get_props () const { unsigned int flag = lookupFlag; if (unlikely (flag & LookupFlag::UseMarkFilteringSet)) @@ -688,7 +684,7 @@ struct Lookup } template <typename TSubTable, typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { unsigned int lookup_type = get_type (); TRACE_DISPATCH (this, lookup_type); @@ -701,10 +697,10 @@ struct Lookup return_trace (c->default_return_value ()); } - inline bool serialize (hb_serialize_context_t *c, - unsigned int lookup_type, - uint32_t lookup_props, - unsigned int num_subtables) + bool serialize (hb_serialize_context_t *c, + unsigned int lookup_type, + uint32_t lookup_props, + unsigned int num_subtables) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -724,12 +720,12 @@ struct Lookup template <typename TSubTable> struct SubTableSubsetWrapper { - inline SubTableSubsetWrapper (const TSubTable &subtable_, - unsigned int lookup_type_) : - subtable (subtable_), - lookup_type (lookup_type_) {} + SubTableSubsetWrapper (const TSubTable &subtable_, + unsigned int lookup_type_) : + subtable (subtable_), + lookup_type (lookup_type_) {} - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { return subtable.dispatch (c, lookup_type); } private: @@ -738,7 +734,7 @@ struct Lookup }; template <typename TSubTable> - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct Lookup *out = c->serializer->embed (*this); @@ -760,8 +756,16 @@ struct Lookup return_trace (true); } + /* Older compilers need this to NOT be locally defined in a function. */ + template <typename TSubTable> + struct SubTableSanitizeWrapper : TSubTable + { + bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) const + { return this->dispatch (c, lookup_type); } + }; + template <typename TSubTable> - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!(c->check_struct (this) && subTable.sanitize (c))) return_trace (false); @@ -771,7 +775,9 @@ struct Lookup if (!markFilteringSet.sanitize (c)) return_trace (false); } - if (unlikely (!dispatch<TSubTable> (c))) return_trace (false); + if (unlikely (!CastR<OffsetArrayOf<SubTableSanitizeWrapper<TSubTable> > > (subTable) + .sanitize (c, this, get_type ()))) + return_trace (false); if (unlikely (get_type () == TSubTable::Extension)) { @@ -813,34 +819,27 @@ struct CoverageFormat1 friend struct Coverage; private: - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const + unsigned int get_coverage (hb_codepoint_t glyph_id) const { unsigned int i; glyphArray.bfind (glyph_id, &i, HB_BFIND_NOT_FOUND_STORE, NOT_COVERED); return i; } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs) { TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - glyphArray.len.set (num_glyphs); - if (unlikely (!c->extend (glyphArray))) return_trace (false); - for (unsigned int i = 0; i < num_glyphs; i++) - glyphArray[i] = glyphs[i]; - glyphs += num_glyphs; - return_trace (true); + return_trace (glyphArray.serialize (c, glyphs)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (glyphArray.sanitize (c)); } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { /* TODO Speed up, using hb_set_next() and bsearch()? */ unsigned int count = glyphArray.len; @@ -849,23 +848,24 @@ struct CoverageFormat1 return true; return false; } - inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const + bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { return glyphs->has (glyphArray[index]); } template <typename set_t> - inline bool add_coverage (set_t *glyphs) const { + bool add_coverage (set_t *glyphs) const + { return glyphs->add_sorted_array (glyphArray.arrayZ, glyphArray.len); } 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 bool more (void) { return i < c->glyphArray.len; } - inline void next (void) { i++; } - inline hb_codepoint_t get_glyph (void) { return c->glyphArray[i]; } - inline unsigned int get_coverage (void) { return i; } + void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; } + void fini () {} + bool more () { return i < c->glyphArray.len; } + void next () { i++; } + hb_codepoint_t get_glyph () { return c->glyphArray[i]; } + unsigned int get_coverage () { return i; } private: const struct CoverageFormat1 *c; @@ -886,7 +886,7 @@ struct CoverageFormat2 friend struct Coverage; private: - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const + unsigned int get_coverage (hb_codepoint_t glyph_id) const { const RangeRecord &range = rangeRecord.bsearch (glyph_id); return likely (range.start <= range.end) ? @@ -894,21 +894,20 @@ struct CoverageFormat2 NOT_COVERED; } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!num_glyphs)) + if (unlikely (!glyphs.len)) { rangeRecord.len.set (0); return_trace (true); } unsigned int num_ranges = 1; - for (unsigned int i = 1; i < num_glyphs; i++) + for (unsigned int i = 1; i < glyphs.len; i++) if (glyphs[i - 1] + 1 != glyphs[i]) num_ranges++; rangeRecord.len.set (num_ranges); @@ -917,26 +916,26 @@ struct CoverageFormat2 unsigned int range = 0; rangeRecord[range].start = glyphs[0]; rangeRecord[range].value.set (0); - for (unsigned int i = 1; i < num_glyphs; i++) - if (glyphs[i - 1] + 1 != glyphs[i]) { + for (unsigned int i = 1; i < glyphs.len; i++) + { + if (glyphs[i - 1] + 1 != glyphs[i]) + { range++; rangeRecord[range].start = glyphs[i]; rangeRecord[range].value.set (i); - rangeRecord[range].end = glyphs[i]; - } else { - rangeRecord[range].end = glyphs[i]; } - glyphs += num_glyphs; + rangeRecord[range].end = glyphs[i]; + } return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (rangeRecord.sanitize (c)); } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { /* TODO Speed up, using hb_set_next() and bsearch()? */ unsigned int count = rangeRecord.len; @@ -945,7 +944,7 @@ struct CoverageFormat2 return true; return false; } - inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const + bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { unsigned int i; unsigned int count = rangeRecord.len; @@ -962,7 +961,8 @@ struct CoverageFormat2 } template <typename set_t> - inline bool add_coverage (set_t *glyphs) const { + bool add_coverage (set_t *glyphs) const + { unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) if (unlikely (!rangeRecord[i].add_coverage (glyphs))) @@ -974,7 +974,7 @@ struct CoverageFormat2 /* Older compilers need this to be public. */ struct Iter { - inline void init (const CoverageFormat2 &c_) + void init (const CoverageFormat2 &c_) { c = &c_; coverage = 0; @@ -986,9 +986,9 @@ struct CoverageFormat2 i = c->rangeRecord.len; } } - inline void fini (void) {} - inline bool more (void) { return i < c->rangeRecord.len; } - inline void next (void) + void fini () {} + bool more () { return i < c->rangeRecord.len; } + void next () { if (j >= c->rangeRecord[i].end) { @@ -1010,8 +1010,8 @@ struct CoverageFormat2 coverage++; j++; } - inline hb_codepoint_t get_glyph (void) { return j; } - inline unsigned int get_coverage (void) { return coverage; } + hb_codepoint_t get_glyph () { return j; } + unsigned int get_coverage () { return coverage; } private: const struct CoverageFormat2 *c; @@ -1032,7 +1032,7 @@ struct CoverageFormat2 struct Coverage { - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const + unsigned int get_coverage (hb_codepoint_t glyph_id) const { switch (u.format) { case 1: return u.format1.get_coverage (glyph_id); @@ -1041,26 +1041,27 @@ struct Coverage } } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); + unsigned int num_ranges = 1; - for (unsigned int i = 1; i < num_glyphs; i++) + for (unsigned int i = 1; i < glyphs.len; i++) if (glyphs[i - 1] + 1 != glyphs[i]) num_ranges++; - u.format.set (num_glyphs * 2 < num_ranges * 3 ? 1 : 2); + u.format.set (glyphs.len * 2 < num_ranges * 3 ? 1 : 2); + switch (u.format) { - case 1: return_trace (u.format1.serialize (c, glyphs, num_glyphs)); - case 2: return_trace (u.format2.serialize (c, glyphs, num_glyphs)); + case 1: return_trace (u.format1.serialize (c, glyphs)); + case 2: return_trace (u.format2.serialize (c, glyphs)); default:return_trace (false); } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -1072,7 +1073,7 @@ struct Coverage } } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { switch (u.format) { @@ -1081,7 +1082,7 @@ struct Coverage default:return false; } } - inline bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const + bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { switch (u.format) { @@ -1094,7 +1095,7 @@ struct Coverage /* Might return false if array looks unsorted. * Used for faster rejection of corrupt data. */ template <typename set_t> - inline bool add_coverage (set_t *glyphs) const + bool add_coverage (set_t *glyphs) const { switch (u.format) { @@ -1106,7 +1107,7 @@ struct Coverage struct Iter { - inline Iter (const Coverage &c_) + Iter (const Coverage &c_) { memset (this, 0, sizeof (*this)); format = c_.u.format; @@ -1117,7 +1118,7 @@ struct Coverage default: return; } } - inline bool more (void) + bool more () { switch (format) { @@ -1126,7 +1127,7 @@ struct Coverage default:return false; } } - inline void next (void) + void next () { switch (format) { @@ -1135,7 +1136,7 @@ struct Coverage default: break; } } - inline hb_codepoint_t get_glyph (void) + hb_codepoint_t get_glyph () { switch (format) { @@ -1144,7 +1145,7 @@ struct Coverage default:return 0; } } - inline unsigned int get_coverage (void) + unsigned int get_coverage () { switch (format) { @@ -1177,24 +1178,79 @@ struct Coverage * Class Definition Table */ +static inline void ClassDef_serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const HBUINT16> klasses); + struct ClassDefFormat1 { friend struct ClassDef; private: - inline unsigned int get_class (hb_codepoint_t glyph_id) const + unsigned int get_class (hb_codepoint_t glyph_id) const { return classValue[(unsigned int) (glyph_id - startGlyph)]; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool serialize (hb_serialize_context_t *c, + hb_array_t<const HBUINT16> glyphs, + hb_array_t<const HBUINT16> klasses) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + + if (unlikely (!glyphs.len)) + { + startGlyph.set (0); + classValue.len.set (0); + return_trace (true); + } + + hb_codepoint_t glyph_min = glyphs[0]; + hb_codepoint_t glyph_max = glyphs[glyphs.len - 1]; + + startGlyph.set (glyph_min); + classValue.len.set (glyph_max - glyph_min + 1); + if (unlikely (!c->extend (classValue))) return_trace (false); + + for (unsigned int i = 0; i < glyphs.len; i++) + classValue[glyphs[i] - glyph_min] = klasses[i]; + + return_trace (true); + } + + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + const hb_set_t &glyphset = *c->plan->glyphset; + const hb_map_t &glyph_map = *c->plan->glyph_map; + hb_vector_t<GlyphID> glyphs; + hb_vector_t<HBUINT16> klasses; + + hb_codepoint_t start = startGlyph; + hb_codepoint_t end = start + classValue.len; + for (hb_codepoint_t g = start; g < end; g++) + { + unsigned int value = classValue[g - start]; + if (!value) continue; + if (!glyphset.has (g)) continue; + glyphs.push()->set (glyph_map[g]); + klasses.push()->set (value); + } + c->serializer->propagate_error (glyphs, klasses); + ClassDef_serialize (c->serializer, glyphs, klasses); + return_trace (glyphs.len); + } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && classValue.sanitize (c)); } template <typename set_t> - inline bool add_coverage (set_t *glyphs) const { + bool add_coverage (set_t *glyphs) const + { unsigned int start = 0; unsigned int count = classValue.len; for (unsigned int i = 0; i < count; i++) @@ -1216,14 +1272,15 @@ struct ClassDefFormat1 } template <typename set_t> - inline bool add_class (set_t *glyphs, unsigned int klass) const { + 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); return true; } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { /* TODO Speed up, using hb_set_next()? */ hb_codepoint_t start = startGlyph; @@ -1233,7 +1290,8 @@ struct ClassDefFormat1 if (classValue[iter - start]) return true; return false; } - inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { + bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const + { unsigned int count = classValue.len; if (klass == 0) { @@ -1265,19 +1323,84 @@ struct ClassDefFormat2 friend struct ClassDef; private: - inline unsigned int get_class (hb_codepoint_t glyph_id) const + unsigned int get_class (hb_codepoint_t glyph_id) const { return rangeRecord.bsearch (glyph_id).value; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool serialize (hb_serialize_context_t *c, + hb_array_t<const HBUINT16> glyphs, + hb_array_t<const HBUINT16> klasses) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + + if (unlikely (!glyphs.len)) + { + rangeRecord.len.set (0); + return_trace (true); + } + + unsigned int num_ranges = 1; + for (unsigned int i = 1; i < glyphs.len; i++) + if (glyphs[i - 1] + 1 != glyphs[i] || + klasses[i - 1] != klasses[i]) + num_ranges++; + rangeRecord.len.set (num_ranges); + if (unlikely (!c->extend (rangeRecord))) return_trace (false); + + unsigned int range = 0; + rangeRecord[range].start = glyphs[0]; + rangeRecord[range].value.set (klasses[0]); + for (unsigned int i = 1; i < glyphs.len; i++) + { + if (glyphs[i - 1] + 1 != glyphs[i] || + klasses[i - 1] != klasses[i]) + { + range++; + rangeRecord[range].start = glyphs[i]; + rangeRecord[range].value = klasses[i]; + } + rangeRecord[range].end = glyphs[i]; + } + return_trace (true); + } + + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + const hb_set_t &glyphset = *c->plan->glyphset; + const hb_map_t &glyph_map = *c->plan->glyph_map; + hb_vector_t<GlyphID> glyphs; + hb_vector_t<HBUINT16> klasses; + + unsigned int count = rangeRecord.len; + for (unsigned int i = 0; i < count; i++) + { + unsigned int value = rangeRecord[i].value; + if (!value) continue; + hb_codepoint_t start = rangeRecord[i].start; + hb_codepoint_t end = rangeRecord[i].end + 1; + for (hb_codepoint_t g = start; g < end; g++) + { + if (!glyphset.has (g)) continue; + glyphs.push ()->set (glyph_map[g]); + klasses.push ()->set (value); + } + } + c->serializer->propagate_error (glyphs, klasses); + ClassDef_serialize (c->serializer, glyphs, klasses); + return_trace (glyphs.len); + } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (rangeRecord.sanitize (c)); } template <typename set_t> - inline bool add_coverage (set_t *glyphs) const + bool add_coverage (set_t *glyphs) const { unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) @@ -1288,7 +1411,7 @@ struct ClassDefFormat2 } template <typename set_t> - inline bool add_class (set_t *glyphs, unsigned int klass) const + bool add_class (set_t *glyphs, unsigned int klass) const { unsigned int count = rangeRecord.len; for (unsigned int i = 0; i < count; i++) @@ -1300,7 +1423,7 @@ struct ClassDefFormat2 return true; } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { /* TODO Speed up, using hb_set_next() and bsearch()? */ unsigned int count = rangeRecord.len; @@ -1309,7 +1432,7 @@ struct ClassDefFormat2 return true; return false; } - inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const + bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { unsigned int count = rangeRecord.len; if (klass == 0) @@ -1345,7 +1468,7 @@ struct ClassDefFormat2 struct ClassDef { - inline unsigned int get_class (hb_codepoint_t glyph_id) const + unsigned int get_class (hb_codepoint_t glyph_id) const { switch (u.format) { case 1: return u.format1.get_class (glyph_id); @@ -1354,7 +1477,49 @@ struct ClassDef } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const HBUINT16> klasses) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return_trace (false); + + unsigned int format = 2; + if (glyphs.len) + { + hb_codepoint_t glyph_min = glyphs[0]; + hb_codepoint_t glyph_max = glyphs[glyphs.len - 1]; + + unsigned int num_ranges = 1; + for (unsigned int i = 1; i < glyphs.len; i++) + if (glyphs[i - 1] + 1 != glyphs[i] || + klasses[i - 1] != klasses[i]) + num_ranges++; + + if (1 + (glyph_max - glyph_min + 1) < num_ranges * 3) + format = 1; + } + u.format.set (format); + + switch (u.format) + { + case 1: return_trace (u.format1.serialize (c, glyphs, klasses)); + case 2: return_trace (u.format2.serialize (c, glyphs, klasses)); + default:return_trace (false); + } + } + + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + switch (u.format) { + case 1: return_trace (u.format1.subset (c)); + case 2: return_trace (u.format2.subset (c)); + default:return_trace (false); + } + } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -1368,7 +1533,8 @@ struct ClassDef /* Might return false if array looks unsorted. * Used for faster rejection of corrupt data. */ template <typename set_t> - inline bool add_coverage (set_t *glyphs) const { + bool add_coverage (set_t *glyphs) const + { switch (u.format) { case 1: return u.format1.add_coverage (glyphs); case 2: return u.format2.add_coverage (glyphs); @@ -1379,7 +1545,8 @@ struct ClassDef /* Might return false if array looks unsorted. * Used for faster rejection of corrupt data. */ template <typename set_t> - inline bool add_class (set_t *glyphs, unsigned int klass) const { + bool add_class (set_t *glyphs, unsigned int klass) const + { switch (u.format) { case 1: return u.format1.add_class (glyphs, klass); case 2: return u.format2.add_class (glyphs, klass); @@ -1387,14 +1554,16 @@ struct ClassDef } } - inline bool intersects (const hb_set_t *glyphs) const { + bool intersects (const hb_set_t *glyphs) const + { switch (u.format) { case 1: return u.format1.intersects (glyphs); case 2: return u.format2.intersects (glyphs); default:return false; } } - inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { + bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const + { switch (u.format) { case 1: return u.format1.intersects_class (glyphs, klass); case 2: return u.format2.intersects_class (glyphs, klass); @@ -1412,6 +1581,11 @@ struct ClassDef DEFINE_SIZE_UNION (2, format); }; +static inline void ClassDef_serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const HBUINT16> klasses) +{ c->start_embed<ClassDef> ()->serialize (c, glyphs, klasses); } + /* * Item Variation Store @@ -1419,7 +1593,7 @@ struct ClassDef struct VarRegionAxis { - inline float evaluate (int coord) const + float evaluate (int coord) const { int start = startCoord, peak = peakCoord, end = endCoord; @@ -1442,7 +1616,7 @@ struct VarRegionAxis return float (end - coord) / (end - peak); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -1460,7 +1634,7 @@ struct VarRegionAxis struct VarRegionList { - inline float evaluate (unsigned int region_index, + float evaluate (unsigned int region_index, const int *coords, unsigned int coord_len) const { if (unlikely (region_index >= regionCount)) @@ -1481,13 +1655,15 @@ struct VarRegionList return v; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && axesZ.sanitize (c, (unsigned int) axisCount * (unsigned int) regionCount)); } + unsigned int get_region_count () const { return regionCount; } + protected: HBUINT16 axisCount; HBUINT16 regionCount; @@ -1499,13 +1675,16 @@ struct VarRegionList struct VarData { - inline unsigned int get_row_size (void) const + unsigned int get_region_index_count () const + { return regionIndices.len; } + + unsigned int get_row_size () const { return shortCount + regionIndices.len; } - inline unsigned int get_size (void) const + unsigned int get_size () const { return itemCount * get_row_size (); } - inline float get_delta (unsigned int inner, + float get_delta (unsigned int inner, const int *coords, unsigned int coord_count, const VarRegionList ®ions) const { @@ -1537,7 +1716,19 @@ struct VarData return delta; } - inline bool sanitize (hb_sanitize_context_t *c) const + void get_scalars (int *coords, unsigned int coord_count, + const VarRegionList ®ions, + float *scalars /*OUT */, + unsigned int num_scalars) const + { + assert (num_scalars == regionIndices.len); + for (unsigned int i = 0; i < num_scalars; i++) + { + scalars[i] = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count); + } + } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -1559,8 +1750,8 @@ struct VarData struct VariationStore { - inline float get_delta (unsigned int outer, unsigned int inner, - const int *coords, unsigned int coord_count) const + float get_delta (unsigned int outer, unsigned int inner, + const int *coords, unsigned int coord_count) const { if (unlikely (outer >= dataSets.len)) return 0.; @@ -1570,15 +1761,15 @@ struct VariationStore this+regions); } - inline float get_delta (unsigned int index, - const int *coords, unsigned int coord_count) const + float get_delta (unsigned int index, + const int *coords, unsigned int coord_count) const { unsigned int outer = index >> 16; unsigned int inner = index & 0xFFFF; return get_delta (outer, inner, coords, coord_count); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -1587,6 +1778,18 @@ struct VariationStore dataSets.sanitize (c, this)); } + unsigned int get_region_index_count (unsigned int ivs) const + { return (this+dataSets[ivs]).get_region_index_count (); } + + void get_scalars (unsigned int ivs, + int *coords, unsigned int coord_count, + float *scalars /*OUT*/, + unsigned int num_scalars) const + { + (this+dataSets[ivs]).get_scalars (coords, coord_count, this+regions, + &scalars[0], num_scalars); + } + protected: HBUINT16 format; LOffsetTo<VarRegionList> regions; @@ -1604,13 +1807,13 @@ struct ConditionFormat1 friend struct Condition; private: - inline bool evaluate (const int *coords, unsigned int coord_len) const + bool evaluate (const int *coords, unsigned int coord_len) const { int coord = axisIndex < coord_len ? coords[axisIndex] : 0; return filterRangeMinValue <= coord && coord <= filterRangeMaxValue; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -1627,7 +1830,7 @@ struct ConditionFormat1 struct Condition { - inline bool evaluate (const int *coords, unsigned int coord_len) const + bool evaluate (const int *coords, unsigned int coord_len) const { switch (u.format) { case 1: return u.format1.evaluate (coords, coord_len); @@ -1635,7 +1838,7 @@ struct Condition } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -1656,7 +1859,7 @@ struct Condition struct ConditionSet { - inline bool evaluate (const int *coords, unsigned int coord_len) const + bool evaluate (const int *coords, unsigned int coord_len) const { unsigned int count = conditions.len; for (unsigned int i = 0; i < count; i++) @@ -1665,7 +1868,7 @@ struct ConditionSet return true; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (conditions.sanitize (c, this)); @@ -1681,7 +1884,7 @@ struct FeatureTableSubstitutionRecord { friend struct FeatureTableSubstitution; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && feature.sanitize (c, base)); @@ -1696,7 +1899,7 @@ struct FeatureTableSubstitutionRecord struct FeatureTableSubstitution { - inline const Feature *find_substitute (unsigned int feature_index) const + const Feature *find_substitute (unsigned int feature_index) const { unsigned int count = substitutions.len; for (unsigned int i = 0; i < count; i++) @@ -1708,7 +1911,7 @@ struct FeatureTableSubstitution return nullptr; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -1728,7 +1931,7 @@ struct FeatureVariationRecord { friend struct FeatureVariations; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (conditions.sanitize (c, base) && @@ -1748,7 +1951,7 @@ struct FeatureVariations { enum { NOT_FOUND_INDEX = 0xFFFFFFFFu }; - inline bool find_index (const int *coords, unsigned int coord_len, + bool find_index (const int *coords, unsigned int coord_len, unsigned int *index) const { unsigned int count = varRecords.len; @@ -1765,20 +1968,20 @@ struct FeatureVariations return false; } - inline const Feature *find_substitute (unsigned int variations_index, - unsigned int feature_index) const + const Feature *find_substitute (unsigned int variations_index, + unsigned int feature_index) const { const FeatureVariationRecord &record = varRecords[variations_index]; return (this+record.substitutions).find_substitute (feature_index); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); return_trace (c->serializer->embed (*this)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -1805,20 +2008,20 @@ struct HintingDevice private: - inline hb_position_t get_x_delta (hb_font_t *font) const + hb_position_t get_x_delta (hb_font_t *font) const { return get_delta (font->x_ppem, font->x_scale); } - inline hb_position_t get_y_delta (hb_font_t *font) const + hb_position_t get_y_delta (hb_font_t *font) const { return get_delta (font->y_ppem, font->y_scale); } - inline unsigned int get_size (void) const + unsigned int get_size () const { unsigned int f = deltaFormat; if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * HBUINT16::static_size; return HBUINT16::static_size * (4 + ((endSize - startSize) >> (4 - f))); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && c->check_range (this, this->get_size ())); @@ -1826,7 +2029,7 @@ struct HintingDevice private: - inline int get_delta (unsigned int ppem, int scale) const + int get_delta (unsigned int ppem, int scale) const { if (!ppem) return 0; @@ -1836,7 +2039,7 @@ struct HintingDevice return (int) (pixels * (int64_t) scale / ppem); } - inline int get_delta_pixels (unsigned int ppem_size) const + int get_delta_pixels (unsigned int ppem_size) const { unsigned int f = deltaFormat; if (unlikely (f < 1 || f > 3)) @@ -1879,13 +2082,13 @@ struct VariationDevice private: - inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store) const + hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store) const { return font->em_scalef_x (get_delta (font, store)); } - inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store) const + hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store) const { return font->em_scalef_y (get_delta (font, store)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -1893,7 +2096,7 @@ struct VariationDevice private: - inline float get_delta (hb_font_t *font, const VariationStore &store) const + float get_delta (hb_font_t *font, const VariationStore &store) const { return store.get_delta (outerIndex, innerIndex, font->coords, font->num_coords); } @@ -1919,7 +2122,7 @@ struct DeviceHeader struct Device { - inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const + hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const { switch (u.b.format) { @@ -1931,7 +2134,7 @@ struct Device return 0; } } - inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const + hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null (VariationStore)) const { switch (u.b.format) { @@ -1944,7 +2147,7 @@ struct Device } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.b.format.sanitize (c)) return_trace (false); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh index a0ae27e75cb..3099fb96a80 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gdef-table.hh @@ -46,10 +46,10 @@ typedef ArrayOf<HBUINT16> AttachPoint; /* Array of contour point indices--in struct AttachList { - inline unsigned int get_attach_points (hb_codepoint_t glyph_id, - unsigned int start_offset, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */) const + unsigned int get_attach_points (hb_codepoint_t glyph_id, + unsigned int start_offset, + unsigned int *point_count /* IN/OUT */, + unsigned int *point_array /* OUT */) const { unsigned int index = (this+coverage).get_coverage (glyph_id); if (index == NOT_COVERED) @@ -72,7 +72,7 @@ struct AttachList return points.len; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && attachPoint.sanitize (c, this)); @@ -98,12 +98,12 @@ struct CaretValueFormat1 friend struct CaretValue; private: - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction) const + hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction) const { return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -121,14 +121,14 @@ struct CaretValueFormat2 friend struct CaretValue; private: - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const + 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; 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -145,14 +145,15 @@ struct CaretValueFormat3 { friend struct CaretValue; - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, const VariationStore &var_store) const + hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, + const VariationStore &var_store) const { return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font, var_store) : font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font, var_store); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && deviceTable.sanitize (c, this)); @@ -171,7 +172,7 @@ struct CaretValueFormat3 struct CaretValue { - inline hb_position_t get_caret_value (hb_font_t *font, + hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id, const VariationStore &var_store) const @@ -184,7 +185,7 @@ struct CaretValue } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -209,13 +210,13 @@ struct CaretValue struct LigGlyph { - inline unsigned int get_lig_carets (hb_font_t *font, - hb_direction_t direction, - hb_codepoint_t glyph_id, - const VariationStore &var_store, - unsigned int start_offset, - unsigned int *caret_count /* IN/OUT */, - hb_position_t *caret_array /* OUT */) const + unsigned int get_lig_carets (hb_font_t *font, + hb_direction_t direction, + hb_codepoint_t glyph_id, + const VariationStore &var_store, + unsigned int start_offset, + unsigned int *caret_count /* IN/OUT */, + hb_position_t *caret_array /* OUT */) const { if (caret_count) { @@ -228,7 +229,7 @@ struct LigGlyph return carets.len; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (carets.sanitize (c, this)); @@ -245,13 +246,13 @@ struct LigGlyph struct LigCaretList { - inline unsigned int get_lig_carets (hb_font_t *font, - hb_direction_t direction, - hb_codepoint_t glyph_id, - const VariationStore &var_store, - unsigned int start_offset, - unsigned int *caret_count /* IN/OUT */, - hb_position_t *caret_array /* OUT */) const + unsigned int get_lig_carets (hb_font_t *font, + hb_direction_t direction, + hb_codepoint_t glyph_id, + const VariationStore &var_store, + unsigned int start_offset, + unsigned int *caret_count /* IN/OUT */, + hb_position_t *caret_array /* OUT */) const { unsigned int index = (this+coverage).get_coverage (glyph_id); if (index == NOT_COVERED) @@ -264,7 +265,7 @@ struct LigCaretList return lig_glyph.get_lig_carets (font, direction, glyph_id, var_store, start_offset, caret_count, caret_array); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this)); @@ -284,10 +285,10 @@ struct LigCaretList struct MarkGlyphSetsFormat1 { - inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const + bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this)); @@ -304,7 +305,7 @@ struct MarkGlyphSetsFormat1 struct MarkGlyphSets { - inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const + bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const { switch (u.format) { case 1: return u.format1.covers (set_index, glyph_id); @@ -312,7 +313,7 @@ struct MarkGlyphSets } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -340,7 +341,7 @@ struct MarkGlyphSets struct GDEF { - static const hb_tag_t tableTag = HB_OT_TAG_GDEF; + enum { tableTag = HB_OT_TAG_GDEF }; enum GlyphClasses { UnclassifiedGlyph = 0, @@ -350,47 +351,47 @@ struct GDEF ComponentGlyph = 4 }; - 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 + bool has_data () const { return version.to_int (); } + bool has_glyph_classes () const { return glyphClassDef != 0; } + unsigned int get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); } - inline void get_glyphs_in_class (unsigned int klass, hb_set_t *glyphs) const + void get_glyphs_in_class (unsigned int klass, hb_set_t *glyphs) const { (this+glyphClassDef).add_class (glyphs, klass); } - inline bool has_mark_attachment_types (void) const { return markAttachClassDef != 0; } - inline unsigned int get_mark_attachment_type (hb_codepoint_t glyph) const + bool has_mark_attachment_types () const { return markAttachClassDef != 0; } + unsigned int get_mark_attachment_type (hb_codepoint_t glyph) const { return (this+markAttachClassDef).get_class (glyph); } - inline bool has_attach_points (void) const { return attachList != 0; } - inline unsigned int get_attach_points (hb_codepoint_t glyph_id, - unsigned int start_offset, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */) const + bool has_attach_points () const { return attachList != 0; } + unsigned int get_attach_points (hb_codepoint_t glyph_id, + unsigned int start_offset, + unsigned int *point_count /* IN/OUT */, + unsigned int *point_array /* OUT */) const { return (this+attachList).get_attach_points (glyph_id, start_offset, point_count, point_array); } - inline bool has_lig_carets (void) const { return ligCaretList != 0; } - inline unsigned int get_lig_carets (hb_font_t *font, - hb_direction_t direction, - hb_codepoint_t glyph_id, - unsigned int start_offset, - unsigned int *caret_count /* IN/OUT */, - hb_position_t *caret_array /* OUT */) const + bool has_lig_carets () const { return ligCaretList != 0; } + unsigned int get_lig_carets (hb_font_t *font, + hb_direction_t direction, + hb_codepoint_t glyph_id, + unsigned int start_offset, + unsigned int *caret_count /* IN/OUT */, + hb_position_t *caret_array /* OUT */) const { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, get_var_store(), start_offset, caret_count, caret_array); } - inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef != 0; } - inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const + bool has_mark_sets () const { return version.to_int () >= 0x00010002u && markGlyphSetsDef != 0; } + bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef).covers (set_index, glyph_id); } - inline bool has_var_store (void) const { return version.to_int () >= 0x00010003u && varStore != 0; } - inline const VariationStore &get_var_store (void) const + bool has_var_store () const { return version.to_int () >= 0x00010003u && varStore != 0; } + const VariationStore &get_var_store () const { 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 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 + unsigned int get_glyph_props (hb_codepoint_t glyph) const { unsigned int klass = get_glyph_class (glyph); @@ -413,7 +414,7 @@ struct GDEF struct accelerator_t { - inline void init (hb_face_t *face) + 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))) @@ -423,22 +424,39 @@ struct GDEF } } - inline void fini (void) - { - this->table.destroy (); - } + void fini () { this->table.destroy (); } hb_blob_ptr_t<GDEF> table; }; - inline unsigned int get_size (void) const + unsigned int get_size () const { return min_size + (version.to_int () >= 0x00010002u ? markGlyphSetsDef.static_size : 0) + (version.to_int () >= 0x00010003u ? varStore.static_size : 0); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool subset (hb_subset_context_t *c) const + { + TRACE_SUBSET (this); + struct GDEF *out = c->serializer->embed (*this); + if (unlikely (!out)) return_trace (false); + + out->glyphClassDef.serialize_subset (c, this+glyphClassDef, out); + out->attachList.set (0);//TODO(subset) serialize_subset (c, this+attachList, out); + out->ligCaretList.set (0);//TODO(subset) serialize_subset (c, this+ligCaretList, out); + out->markAttachClassDef.serialize_subset (c, this+markAttachClassDef, out); + + if (version.to_int () >= 0x00010002u) + out->markGlyphSetsDef.set (0);// TODO(subset) serialize_subset (c, this+markGlyphSetsDef, out); + + if (version.to_int () >= 0x00010003u) + out->varStore.set (0);// TODO(subset) serialize_subset (c, this+varStore, out); + + return_trace (true); + } + + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh index 2589218de78..b123336109b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh @@ -98,10 +98,8 @@ struct ValueFormat : HBUINT16 * PosTable (may be NULL) */ #endif - inline unsigned int get_len (void) const - { return hb_popcount ((unsigned int) *this); } - inline unsigned int get_size (void) const - { return get_len () * Value::static_size; } + unsigned int get_len () const { return hb_popcount ((unsigned int) *this); } + unsigned int get_size () const { return get_len () * Value::static_size; } bool apply_value (hb_ot_apply_context_t *c, const void *base, @@ -158,7 +156,7 @@ struct ValueFormat : HBUINT16 } private: - inline bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const + bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const { unsigned int format = *this; @@ -175,15 +173,15 @@ struct ValueFormat : HBUINT16 return true; } - static inline OffsetTo<Device>& get_device (Value* value) + static OffsetTo<Device>& get_device (Value* value) { return *CastP<OffsetTo<Device> > (value); } - static inline const OffsetTo<Device>& get_device (const Value* value, bool *worked=nullptr) + static 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, bool *worked=nullptr) + static const HBINT16& get_short (const Value* value, bool *worked=nullptr) { if (worked) *worked |= *value; return *CastP<HBINT16> (value); @@ -191,18 +189,19 @@ struct ValueFormat : HBUINT16 public: - inline bool has_device (void) const { + bool has_device () const + { unsigned int format = *this; return (format & devices) != 0; } - inline bool sanitize_value (hb_sanitize_context_t *c, const void *base, const Value *values) const + bool sanitize_value (hb_sanitize_context_t *c, const void *base, const Value *values) const { TRACE_SANITIZE (this); return_trace (c->check_range (values, get_size ()) && (!has_device () || sanitize_value_devices (c, base, values))); } - inline bool sanitize_values (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count) const + bool sanitize_values (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count) const { TRACE_SANITIZE (this); unsigned int len = get_len (); @@ -221,7 +220,7 @@ struct ValueFormat : HBUINT16 } /* Just sanitize referenced Device tables. Doesn't check the values themselves. */ - inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count, unsigned int stride) const + bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count, unsigned int stride) const { TRACE_SANITIZE (this); @@ -240,15 +239,15 @@ struct ValueFormat : HBUINT16 struct AnchorFormat1 { - inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, - float *x, float *y) const + void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, + float *x, float *y) const { hb_font_t *font = c->font; *x = font->em_fscale_x (xCoordinate); *y = font->em_fscale_y (yCoordinate); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -264,8 +263,8 @@ struct AnchorFormat1 struct AnchorFormat2 { - inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id, - float *x, float *y) const + void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id, + float *x, float *y) const { hb_font_t *font = c->font; unsigned int x_ppem = font->x_ppem; @@ -279,7 +278,7 @@ struct AnchorFormat2 *y = ret && y_ppem ? cy : font->em_fscale_y (yCoordinate); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -296,8 +295,8 @@ struct AnchorFormat2 struct AnchorFormat3 { - inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, - float *x, float *y) const + void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, + float *x, float *y) const { hb_font_t *font = c->font; *x = font->em_fscale_x (xCoordinate); @@ -309,7 +308,7 @@ struct AnchorFormat3 *y += (this+yDeviceTable).get_y_delta (font, c->var_store); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this)); @@ -333,8 +332,8 @@ struct AnchorFormat3 struct Anchor { - inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id, - float *x, float *y) const + void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id, + float *x, float *y) const { *x = *y = 0; switch (u.format) { @@ -345,7 +344,7 @@ struct Anchor } } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!u.format.sanitize (c)) return_trace (false); @@ -371,14 +370,16 @@ struct Anchor struct AnchorMatrix { - inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols, bool *found) const { + const Anchor& get_anchor (unsigned int row, unsigned int col, + unsigned int cols, bool *found) const + { *found = false; if (unlikely (row >= rows || col >= cols)) return Null(Anchor); *found = !matrixZ[row * cols + col].is_null (); return this+matrixZ[row * cols + col]; } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const + bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const { TRACE_SANITIZE (this); if (!c->check_struct (this)) return_trace (false); @@ -404,7 +405,7 @@ struct MarkRecord { friend struct MarkArray; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && markAnchor.sanitize (c, base)); @@ -421,10 +422,10 @@ struct MarkRecord struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage order */ { - inline bool apply (hb_ot_apply_context_t *c, - unsigned int mark_index, unsigned int glyph_index, - const AnchorMatrix &anchors, unsigned int class_count, - unsigned int glyph_pos) const + bool apply (hb_ot_apply_context_t *c, + unsigned int mark_index, unsigned int glyph_index, + const AnchorMatrix &anchors, unsigned int class_count, + unsigned int glyph_pos) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -455,7 +456,7 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (ArrayOf<MarkRecord>::sanitize (c, this)); @@ -467,19 +468,18 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde struct SinglePosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -492,14 +492,14 @@ struct SinglePosFormat1 return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -523,19 +523,18 @@ struct SinglePosFormat1 struct SinglePosFormat2 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -552,14 +551,14 @@ struct SinglePosFormat2 return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -584,7 +583,7 @@ struct SinglePosFormat2 struct SinglePos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -622,7 +621,7 @@ struct PairSet { friend struct PairPosFormat1; - inline bool intersects (const hb_set_t *glyphs, + bool intersects (const hb_set_t *glyphs, const ValueFormat *valueFormats) const { unsigned int len1 = valueFormats[0].get_len (); @@ -640,7 +639,7 @@ struct PairSet return false; } - inline void collect_glyphs (hb_collect_glyphs_context_t *c, + void collect_glyphs (hb_collect_glyphs_context_t *c, const ValueFormat *valueFormats) const { TRACE_COLLECT_GLYPHS (this); @@ -652,7 +651,7 @@ struct PairSet c->input->add_array (&record->secondGlyph, len, record_size); } - inline bool apply (hb_ot_apply_context_t *c, + bool apply (hb_ot_apply_context_t *c, const ValueFormat *valueFormats, unsigned int pos) const { @@ -702,7 +701,7 @@ struct PairSet unsigned int stride; /* 1 + len1 + len2 */ }; - inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) const + bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) const { TRACE_SANITIZE (this); if (!(c->check_struct (this) @@ -728,7 +727,7 @@ struct PairSet struct PairPosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { unsigned int count = pairSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -742,7 +741,7 @@ struct PairPosFormat1 return false; } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -751,10 +750,9 @@ struct PairPosFormat1 (this+pairSet[i]).collect_glyphs (c, valueFormat); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -768,14 +766,14 @@ struct PairPosFormat1 return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -814,23 +812,22 @@ struct PairPosFormat1 struct PairPosFormat2 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs) && (this+classDef2).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; if (unlikely (!(this+classDef2).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -862,14 +859,14 @@ struct PairPosFormat2 return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!(c->check_struct (this) @@ -922,7 +919,7 @@ struct PairPosFormat2 struct PairPos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -946,7 +943,7 @@ struct EntryExitRecord { friend struct CursivePosFormat1; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base)); @@ -970,19 +967,18 @@ reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direc struct CursivePosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -1083,14 +1079,14 @@ struct CursivePosFormat1 return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this)); @@ -1111,7 +1107,7 @@ struct CursivePosFormat1 struct CursivePos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1136,21 +1132,20 @@ typedef AnchorMatrix BaseArray; /* base-major-- struct MarkBasePosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+markCoverage).intersects (glyphs) && (this+baseCoverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+markCoverage).add_coverage (c->input))) return; if (unlikely (!(this+baseCoverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+markCoverage; } + const Coverage &get_coverage () const { return this+markCoverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -1190,14 +1185,14 @@ struct MarkBasePosFormat1 return_trace ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -1229,7 +1224,7 @@ struct MarkBasePosFormat1 struct MarkBasePos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1259,21 +1254,20 @@ typedef OffsetListOf<LigatureAttach> LigatureArray; struct MarkLigPosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+markCoverage).intersects (glyphs) && (this+ligatureCoverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+markCoverage).add_coverage (c->input))) return; if (unlikely (!(this+ligatureCoverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+markCoverage; } + const Coverage &get_coverage () const { return this+markCoverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -1316,14 +1310,14 @@ struct MarkLigPosFormat1 return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -1356,7 +1350,7 @@ struct MarkLigPosFormat1 struct MarkLigPos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1381,21 +1375,20 @@ typedef AnchorMatrix Mark2Array; /* mark2-major-- struct MarkMarkPosFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+mark1Coverage).intersects (glyphs) && (this+mark2Coverage).intersects (glyphs); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+mark1Coverage).add_coverage (c->input))) return; if (unlikely (!(this+mark2Coverage).add_coverage (c->input))) return; } - inline const Coverage &get_coverage (void) const - { return this+mark1Coverage; } + const Coverage &get_coverage () const { return this+mark1Coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_buffer_t *buffer = c->buffer; @@ -1439,14 +1432,14 @@ struct MarkMarkPosFormat1 return_trace ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -1480,7 +1473,7 @@ struct MarkMarkPosFormat1 struct MarkMarkPos { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1532,10 +1525,9 @@ struct PosLookupSubTable }; template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const + typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); - if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_dispatch_return_value ()); switch (lookup_type) { case Single: return_trace (u.single.dispatch (c)); case Pair: return_trace (u.pair.dispatch (c)); @@ -1552,7 +1544,6 @@ struct PosLookupSubTable protected: union { - HBUINT16 sub_format; SinglePos single; PairPos pair; CursivePos cursive; @@ -1564,7 +1555,7 @@ struct PosLookupSubTable ExtensionPos extension; } u; public: - DEFINE_SIZE_UNION (2, sub_format); + DEFINE_SIZE_MIN (0); }; @@ -1572,34 +1563,34 @@ struct PosLookup : Lookup { typedef struct PosLookupSubTable SubTable; - inline const SubTable& get_subtable (unsigned int i) const + const SubTable& get_subtable (unsigned int i) const { return Lookup::get_subtable<SubTable> (i); } - inline bool is_reverse (void) const + bool is_reverse () const { return false; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); return_trace (dispatch (c)); } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { hb_intersects_context_t c (glyphs); return dispatch (&c); } - inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const + hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); return_trace (dispatch (c)); } template <typename set_t> - inline void add_coverage (set_t *glyphs) const + void add_coverage (set_t *glyphs) const { hb_add_coverage_context_t<set_t> c (glyphs); dispatch (&c); @@ -1608,16 +1599,16 @@ struct PosLookup : Lookup static bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index); template <typename context_t> - static inline typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index); + static typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index); template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { return Lookup::dispatch<SubTable> (c); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { return Lookup::subset<SubTable> (c); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { return Lookup::sanitize<SubTable> (c); } }; @@ -1628,19 +1619,19 @@ struct PosLookup : Lookup struct GPOS : GSUBGPOS { - static const hb_tag_t tableTag = HB_OT_TAG_GPOS; + enum { tableTag = HB_OT_TAG_GPOS }; - inline const PosLookup& get_lookup (unsigned int i) const + const PosLookup& get_lookup (unsigned int i) const { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); } static inline void position_start (hb_font_t *font, hb_buffer_t *buffer); static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer); static inline void position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer); - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { return GSUBGPOS::subset<PosLookup> (c); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { return GSUBGPOS::sanitize<PosLookup> (c); } HB_INTERNAL bool is_blacklisted (hb_blob_t *blob, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh index 27bd440dabf..180e7f2decd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsub-table.hh @@ -36,16 +36,15 @@ namespace OT { static inline void SingleSubst_serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<GlyphID> &substitutes, - unsigned int num_glyphs); + hb_array_t<const GlyphID> glyphs, + hb_array_t<const GlyphID> substitutes); struct SingleSubstFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -58,7 +57,7 @@ struct SingleSubstFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -71,16 +70,15 @@ struct SingleSubstFormat1 } } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); hb_codepoint_t glyph_id = c->buffer->cur().codepoint; @@ -95,43 +93,37 @@ struct SingleSubstFormat1 return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs, - int delta) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + int delta) { 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); + if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs))) return_trace (false); deltaGlyphID.set (delta); /* TODO(serialize) overflow? */ return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); + const hb_set_t &glyphset = *c->plan->glyphset; + const hb_map_t &glyph_map = *c->plan->glyph_map; hb_vector_t<GlyphID> from; hb_vector_t<GlyphID> to; hb_codepoint_t delta = deltaGlyphID; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { - if (!c->plan->glyphset->has (iter.get_glyph ())) - continue; - from.push ()->set (iter.get_glyph ()); - to.push ()->set ((iter.get_glyph () + delta) & 0xFFFF); + if (!glyphset.has (iter.get_glyph ())) continue; + from.push ()->set (glyph_map[iter.get_glyph ()]); + to.push ()->set (glyph_map[(iter.get_glyph () + delta) & 0xFFFF]); } - c->serializer->err (from.in_error () || to.in_error ()); - - Supplier<GlyphID> from_supplier (&from); - Supplier<GlyphID> to_supplier (&to); - SingleSubst_serialize (c->serializer, - from_supplier, - to_supplier, - from.len); + c->serializer->propagate_error (from, to); + SingleSubst_serialize (c->serializer, from, to); return_trace (from.len); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c)); @@ -150,10 +142,10 @@ struct SingleSubstFormat1 struct SingleSubstFormat2 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = substitute.len; @@ -166,7 +158,7 @@ struct SingleSubstFormat2 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -179,16 +171,15 @@ struct SingleSubstFormat2 } } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); @@ -201,42 +192,36 @@ struct SingleSubstFormat2 return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<GlyphID> &substitutes, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const GlyphID> substitutes) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return_trace (false); - if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false); + if (unlikely (!substitute.serialize (c, substitutes))) return_trace (false); + if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs))) return_trace (false); return_trace (true); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); + const hb_set_t &glyphset = *c->plan->glyphset; + const hb_map_t &glyph_map = *c->plan->glyph_map; 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; - from.push ()->set (iter.get_glyph ()); - to.push ()->set (substitute[iter.get_coverage ()]); + if (!glyphset.has (iter.get_glyph ())) continue; + from.push ()->set (glyph_map[iter.get_glyph ()]); + to.push ()->set (glyph_map[substitute[iter.get_coverage ()]]); } - c->serializer->err (from.in_error () || to.in_error ()); - - Supplier<GlyphID> from_supplier (&from); - Supplier<GlyphID> to_supplier (&to); - SingleSubst_serialize (c->serializer, - from_supplier, - to_supplier, - from.len); + c->serializer->propagate_error (from, to); + SingleSubst_serialize (c->serializer, from, to); return_trace (from.len); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && substitute.sanitize (c)); @@ -256,35 +241,35 @@ struct SingleSubstFormat2 struct SingleSubst { - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<GlyphID> &substitutes, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const GlyphID> substitutes) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned int format = 2; int delta = 0; - if (num_glyphs) { + if (glyphs.len) + { format = 1; /* TODO(serialize) check for wrap-around */ delta = substitutes[0] - glyphs[0]; - for (unsigned int i = 1; i < num_glyphs; i++) - if (delta != substitutes[i] - glyphs[i]) { + for (unsigned int i = 1; i < glyphs.len; i++) + if (delta != (int) (substitutes[i] - glyphs[i])) { format = 2; break; } } u.format.set (format); switch (u.format) { - case 1: return_trace (u.format1.serialize (c, glyphs, num_glyphs, delta)); - case 2: return_trace (u.format2.serialize (c, glyphs, substitutes, num_glyphs)); + case 1: return_trace (u.format1.serialize (c, glyphs, delta)); + case 2: return_trace (u.format2.serialize (c, glyphs, substitutes)); default:return_trace (false); } } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -305,19 +290,13 @@ struct SingleSubst static inline void SingleSubst_serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<GlyphID> &substitutes, - unsigned int num_glyphs) -{ - c->start_embed<SingleSubst> ()->serialize (c, - glyphs, - substitutes, - num_glyphs); -} + hb_array_t<const GlyphID> glyphs, + hb_array_t<const GlyphID> substitutes) +{ c->start_embed<SingleSubst> ()->serialize (c, glyphs, substitutes); } struct Sequence { - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = substitute.len; @@ -325,13 +304,13 @@ struct Sequence c->out->add (substitute[i]); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); c->output->add_array (substitute.arrayZ, substitute.len); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int count = substitute.len; @@ -363,17 +342,14 @@ struct Sequence return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs) { TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return_trace (false); - return_trace (true); + return_trace (substitute.serialize (c, glyphs)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (substitute.sanitize (c)); @@ -388,10 +364,10 @@ struct Sequence struct MultipleSubstFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = sequence.len; @@ -404,7 +380,7 @@ struct MultipleSubstFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -413,16 +389,15 @@ struct MultipleSubstFormat1 (this+sequence[i]).collect_glyphs (c); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); @@ -432,32 +407,33 @@ struct MultipleSubstFormat1 return_trace ((this+sequence[index]).apply (c)); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &substitute_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &substitute_glyphs_list) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> substitute_len_list, + hb_array_t<const GlyphID> substitute_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!sequence.serialize (c, num_glyphs))) return_trace (false); - for (unsigned int i = 0; i < num_glyphs; i++) - if (unlikely (!sequence[i].serialize (c, this).serialize (c, - substitute_glyphs_list, - substitute_len_list[i]))) return_trace (false); - substitute_len_list += num_glyphs; - if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false); - return_trace (true); + if (unlikely (!sequence.serialize (c, glyphs.len))) return_trace (false); + for (unsigned int i = 0; i < glyphs.len; i++) + { + unsigned int substitute_len = substitute_len_list[i]; + if (unlikely (!sequence[i].serialize (c, this) + .serialize (c, substitute_glyphs_list.sub_array (0, substitute_len)))) + return_trace (false); + substitute_glyphs_list += substitute_len; + } + return_trace (coverage.serialize (c, this).serialize (c, glyphs)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && sequence.sanitize (c, this)); @@ -477,24 +453,23 @@ struct MultipleSubstFormat1 struct MultipleSubst { - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &substitute_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &substitute_glyphs_list) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> substitute_len_list, + hb_array_t<const GlyphID> substitute_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned int format = 1; u.format.set (format); switch (u.format) { - case 1: return_trace (u.format1.serialize (c, glyphs, substitute_len_list, num_glyphs, substitute_glyphs_list)); + case 1: return_trace (u.format1.serialize (c, glyphs, substitute_len_list, substitute_glyphs_list)); default:return_trace (false); } } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -513,7 +488,7 @@ struct MultipleSubst struct AlternateSet { - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = alternates.len; @@ -521,13 +496,13 @@ struct AlternateSet c->out->add (alternates[i]); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); c->output->add_array (alternates.arrayZ, alternates.len); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int count = alternates.len; @@ -552,17 +527,14 @@ struct AlternateSet return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - unsigned int num_glyphs) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs) { TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!alternates.serialize (c, glyphs, num_glyphs))) return_trace (false); - return_trace (true); + return_trace (alternates.serialize (c, glyphs)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (alternates.sanitize (c)); @@ -578,10 +550,10 @@ struct AlternateSet struct AlternateSubstFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { return (this+coverage).intersects (glyphs); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = alternateSet.len; @@ -594,7 +566,7 @@ struct AlternateSubstFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -607,16 +579,15 @@ struct AlternateSubstFormat1 } } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); @@ -626,32 +597,33 @@ struct AlternateSubstFormat1 return_trace ((this+alternateSet[index]).apply (c)); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &alternate_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &alternate_glyphs_list) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> alternate_len_list, + hb_array_t<const GlyphID> alternate_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!alternateSet.serialize (c, num_glyphs))) return_trace (false); - for (unsigned int i = 0; i < num_glyphs; i++) - if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, - alternate_glyphs_list, - alternate_len_list[i]))) return_trace (false); - alternate_len_list += num_glyphs; - if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false); - return_trace (true); + if (unlikely (!alternateSet.serialize (c, glyphs.len))) return_trace (false); + for (unsigned int i = 0; i < glyphs.len; i++) + { + unsigned int alternate_len = alternate_len_list[i]; + if (unlikely (!alternateSet[i].serialize (c, this) + .serialize (c, alternate_glyphs_list.sub_array (0, alternate_len)))) + return_trace (false); + alternate_glyphs_list += alternate_len; + } + return_trace (coverage.serialize (c, this).serialize (c, glyphs)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && alternateSet.sanitize (c, this)); @@ -671,24 +643,23 @@ struct AlternateSubstFormat1 struct AlternateSubst { - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &alternate_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &alternate_glyphs_list) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> alternate_len_list, + hb_array_t<const GlyphID> alternate_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned int format = 1; u.format.set (format); switch (u.format) { - case 1: return_trace (u.format1.serialize (c, glyphs, alternate_len_list, num_glyphs, alternate_glyphs_list)); + case 1: return_trace (u.format1.serialize (c, glyphs, alternate_len_list, alternate_glyphs_list)); default:return_trace (false); } } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -708,7 +679,7 @@ struct AlternateSubst struct Ligature { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { unsigned int count = component.lenP1; for (unsigned int i = 1; i < count; i++) @@ -717,7 +688,7 @@ struct Ligature return true; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = component.lenP1; @@ -727,14 +698,14 @@ struct Ligature c->out->add (ligGlyph); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); c->input->add_array (component.arrayZ, component.lenP1 ? component.lenP1 - 1 : 0); c->output->add (ligGlyph); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); if (c->len != component.lenP1) @@ -747,7 +718,7 @@ struct Ligature return_trace (true); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int count = component.lenP1; @@ -786,20 +757,19 @@ struct Ligature return_trace (true); } - inline bool serialize (hb_serialize_context_t *c, - GlyphID ligature, - Supplier<GlyphID> &components, /* Starting from second */ - unsigned int num_components /* Including first component */) + bool serialize (hb_serialize_context_t *c, + GlyphID ligature, + hb_array_t<const GlyphID> components /* Starting from second */) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); ligGlyph = ligature; - if (unlikely (!component.serialize (c, components, num_components))) return_trace (false); + if (unlikely (!component.serialize (c, components))) return_trace (false); return_trace (true); } public: - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (ligGlyph.sanitize (c) && component.sanitize (c)); @@ -817,7 +787,7 @@ struct Ligature struct LigatureSet { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { unsigned int num_ligs = ligature.len; for (unsigned int i = 0; i < num_ligs; i++) @@ -826,7 +796,7 @@ struct LigatureSet return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int num_ligs = ligature.len; @@ -834,7 +804,7 @@ struct LigatureSet (this+ligature[i]).closure (c); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); unsigned int num_ligs = ligature.len; @@ -842,7 +812,7 @@ struct LigatureSet (this+ligature[i]).collect_glyphs (c); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); unsigned int num_ligs = ligature.len; @@ -855,7 +825,7 @@ struct LigatureSet return_trace (false); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int num_ligs = ligature.len; @@ -868,26 +838,28 @@ struct LigatureSet return_trace (false); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &ligatures, - Supplier<unsigned int> &component_count_list, - unsigned int num_ligatures, - Supplier<GlyphID> &component_list /* Starting from second for each ligature */) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> ligatures, + hb_array_t<const unsigned int> component_count_list, + hb_array_t<const GlyphID> component_list /* Starting from second for each ligature */) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!ligature.serialize (c, num_ligatures))) return_trace (false); - for (unsigned int i = 0; i < num_ligatures; i++) - if (unlikely (!ligature[i].serialize (c, this).serialize (c, - ligatures[i], - component_list, - component_count_list[i]))) return_trace (false); - ligatures += num_ligatures; - component_count_list += num_ligatures; + if (unlikely (!ligature.serialize (c, ligatures.len))) return_trace (false); + for (unsigned int i = 0; i < ligatures.len; i++) + { + unsigned int component_count = MAX<int> (component_count_list[i] - 1, 0); + if (unlikely (!ligature[i].serialize (c, this) + .serialize (c, + ligatures[i], + component_list.sub_array (0, component_count)))) + return_trace (false); + component_list += component_count; + } return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (ligature.sanitize (c, this)); @@ -903,7 +875,7 @@ struct LigatureSet struct LigatureSubstFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { unsigned int count = ligatureSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -917,7 +889,7 @@ struct LigatureSubstFormat1 return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); unsigned int count = ligatureSet.len; @@ -930,7 +902,7 @@ struct LigatureSubstFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -943,10 +915,9 @@ struct LigatureSubstFormat1 } } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->glyphs[0]); @@ -956,7 +927,7 @@ struct LigatureSubstFormat1 return_trace (lig_set.would_apply (c)); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); @@ -967,36 +938,40 @@ struct LigatureSubstFormat1 return_trace (lig_set.apply (c)); } - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &first_glyphs, - Supplier<unsigned int> &ligature_per_first_glyph_count_list, - unsigned int num_first_glyphs, - Supplier<GlyphID> &ligatures_list, - Supplier<unsigned int> &component_count_list, - Supplier<GlyphID> &component_list /* Starting from second for each ligature */) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> first_glyphs, + hb_array_t<const unsigned int> ligature_per_first_glyph_count_list, + hb_array_t<const GlyphID> ligatures_list, + hb_array_t<const unsigned int> component_count_list, + hb_array_t<const GlyphID> component_list /* Starting from second for each ligature */) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!ligatureSet.serialize (c, num_first_glyphs))) return_trace (false); - for (unsigned int i = 0; i < num_first_glyphs; i++) - if (unlikely (!ligatureSet[i].serialize (c, this).serialize (c, - ligatures_list, - component_count_list, - ligature_per_first_glyph_count_list[i], - component_list))) return_trace (false); - ligature_per_first_glyph_count_list += num_first_glyphs; - if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_first_glyphs))) return_trace (false); - return_trace (true); + if (unlikely (!ligatureSet.serialize (c, first_glyphs.len))) return_trace (false); + for (unsigned int i = 0; i < first_glyphs.len; i++) + { + unsigned int ligature_count = ligature_per_first_glyph_count_list[i]; + if (unlikely (!ligatureSet[i].serialize (c, this) + .serialize (c, + ligatures_list.sub_array (0, ligature_count), + component_count_list.sub_array (0, ligature_count), + component_list))) return_trace (false); + ligatures_list += ligature_count; + component_count_list += ligature_count; + for (unsigned int i = 0; i < ligature_count; i++) + component_list += MAX<int> (component_count_list[i] - 1, 0); + } + return_trace (coverage.serialize (c, this).serialize (c, first_glyphs)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && ligatureSet.sanitize (c, this)); @@ -1016,13 +991,12 @@ struct LigatureSubstFormat1 struct LigatureSubst { - inline bool serialize (hb_serialize_context_t *c, - Supplier<GlyphID> &first_glyphs, - Supplier<unsigned int> &ligature_per_first_glyph_count_list, - unsigned int num_first_glyphs, - Supplier<GlyphID> &ligatures_list, - Supplier<unsigned int> &component_count_list, - Supplier<GlyphID> &component_list /* Starting from second for each ligature */) + bool serialize (hb_serialize_context_t *c, + hb_array_t<const GlyphID> first_glyphs, + hb_array_t<const unsigned int> ligature_per_first_glyph_count_list, + hb_array_t<const GlyphID> ligatures_list, + hb_array_t<const unsigned int> component_count_list, + hb_array_t<const GlyphID> component_list /* Starting from second for each ligature */) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (u.format))) return_trace (false); @@ -1032,7 +1006,6 @@ struct LigatureSubst case 1: return_trace (u.format1.serialize (c, first_glyphs, ligature_per_first_glyph_count_list, - num_first_glyphs, ligatures_list, component_count_list, component_list)); @@ -1041,7 +1014,7 @@ struct LigatureSubst } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1067,13 +1040,13 @@ struct ExtensionSubst : Extension<ExtensionSubst> { typedef struct SubstLookupSubTable SubTable; - inline bool is_reverse (void) const; + bool is_reverse () const; }; struct ReverseChainSingleSubstFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { if (!(this+coverage).intersects (glyphs)) return false; @@ -1095,7 +1068,7 @@ struct ReverseChainSingleSubstFormat1 return true; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack); @@ -1123,7 +1096,7 @@ struct ReverseChainSingleSubstFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; @@ -1144,16 +1117,15 @@ struct ReverseChainSingleSubstFormat1 c->output->add_array (substitute.arrayZ, substitute.len); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); if (unlikely (c->nesting_level_left != HB_MAX_NESTING_LEVEL)) @@ -1186,14 +1158,14 @@ struct ReverseChainSingleSubstFormat1 return_trace (false); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this))) @@ -1228,7 +1200,7 @@ struct ReverseChainSingleSubstFormat1 struct ReverseChainSingleSubst { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1268,10 +1240,9 @@ struct SubstLookupSubTable }; template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const + typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const { TRACE_DISPATCH (this, lookup_type); - if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_dispatch_return_value ()); switch (lookup_type) { case Single: return_trace (u.single.dispatch (c)); case Multiple: return_trace (u.multiple.dispatch (c)); @@ -1287,7 +1258,6 @@ struct SubstLookupSubTable protected: union { - HBUINT16 sub_format; SingleSubst single; MultipleSubst multiple; AlternateSubst alternate; @@ -1298,7 +1268,7 @@ struct SubstLookupSubTable ReverseChainSingleSubst reverseChainContextSingle; } u; public: - DEFINE_SIZE_UNION (2, sub_format); + DEFINE_SIZE_MIN (0); }; @@ -1306,13 +1276,13 @@ struct SubstLookup : Lookup { typedef SubstLookupSubTable SubTable; - inline const SubTable& get_subtable (unsigned int i) const + const SubTable& get_subtable (unsigned int i) const { return Lookup::get_subtable<SubTable> (i); } - inline static bool lookup_type_is_reverse (unsigned int lookup_type) + static bool lookup_type_is_reverse (unsigned int lookup_type) { return lookup_type == SubTable::ReverseChainSingle; } - inline bool is_reverse (void) const + bool is_reverse () const { unsigned int type = get_type (); if (unlikely (type == SubTable::Extension)) @@ -1320,19 +1290,19 @@ struct SubstLookup : Lookup return lookup_type_is_reverse (type); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); return_trace (dispatch (c)); } - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { hb_intersects_context_t c (glyphs); return dispatch (&c); } - inline hb_closure_context_t::return_t closure (hb_closure_context_t *c, unsigned int this_index) const + hb_closure_context_t::return_t closure (hb_closure_context_t *c, unsigned int this_index) const { TRACE_CLOSURE (this); if (!c->should_visit_lookup (this_index)) @@ -1347,7 +1317,7 @@ struct SubstLookup : Lookup return_trace (ret); } - inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const + hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); @@ -1355,14 +1325,14 @@ struct SubstLookup : Lookup } template <typename set_t> - inline void add_coverage (set_t *glyphs) const + void add_coverage (set_t *glyphs) const { hb_add_coverage_context_t<set_t> c (glyphs); dispatch (&c); } - inline bool would_apply (hb_would_apply_context_t *c, - const hb_ot_layout_lookup_accelerator_t *accel) const + bool would_apply (hb_would_apply_context_t *c, + const hb_ot_layout_lookup_accelerator_t *accel) const { TRACE_WOULD_APPLY (this); if (unlikely (!c->len)) return_trace (false); @@ -1372,77 +1342,70 @@ struct SubstLookup : Lookup static bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index); - inline SubTable& serialize_subtable (hb_serialize_context_t *c, + SubTable& serialize_subtable (hb_serialize_context_t *c, unsigned int i) { return get_subtables<SubTable> ()[i].serialize (c, this); } - inline bool serialize_single (hb_serialize_context_t *c, - uint32_t lookup_props, - Supplier<GlyphID> &glyphs, - Supplier<GlyphID> &substitutes, - unsigned int num_glyphs) + bool serialize_single (hb_serialize_context_t *c, + uint32_t lookup_props, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const GlyphID> substitutes) { TRACE_SERIALIZE (this); if (unlikely (!Lookup::serialize (c, SubTable::Single, lookup_props, 1))) return_trace (false); - return_trace (serialize_subtable (c, 0).u.single.serialize (c, glyphs, substitutes, num_glyphs)); + return_trace (serialize_subtable (c, 0).u.single.serialize (c, glyphs, substitutes)); } - inline bool serialize_multiple (hb_serialize_context_t *c, - uint32_t lookup_props, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &substitute_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &substitute_glyphs_list) + bool serialize_multiple (hb_serialize_context_t *c, + uint32_t lookup_props, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> substitute_len_list, + hb_array_t<const GlyphID> substitute_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!Lookup::serialize (c, SubTable::Multiple, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.multiple.serialize (c, glyphs, substitute_len_list, - num_glyphs, substitute_glyphs_list)); } - inline bool serialize_alternate (hb_serialize_context_t *c, - uint32_t lookup_props, - Supplier<GlyphID> &glyphs, - Supplier<unsigned int> &alternate_len_list, - unsigned int num_glyphs, - Supplier<GlyphID> &alternate_glyphs_list) + bool serialize_alternate (hb_serialize_context_t *c, + uint32_t lookup_props, + hb_array_t<const GlyphID> glyphs, + hb_array_t<const unsigned int> alternate_len_list, + hb_array_t<const GlyphID> alternate_glyphs_list) { TRACE_SERIALIZE (this); if (unlikely (!Lookup::serialize (c, SubTable::Alternate, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.alternate.serialize (c, glyphs, alternate_len_list, - num_glyphs, alternate_glyphs_list)); } - inline bool serialize_ligature (hb_serialize_context_t *c, - uint32_t lookup_props, - Supplier<GlyphID> &first_glyphs, - Supplier<unsigned int> &ligature_per_first_glyph_count_list, - unsigned int num_first_glyphs, - Supplier<GlyphID> &ligatures_list, - Supplier<unsigned int> &component_count_list, - Supplier<GlyphID> &component_list /* Starting from second for each ligature */) + bool serialize_ligature (hb_serialize_context_t *c, + uint32_t lookup_props, + hb_array_t<const GlyphID> first_glyphs, + hb_array_t<const unsigned int> ligature_per_first_glyph_count_list, + hb_array_t<const GlyphID> ligatures_list, + hb_array_t<const unsigned int> component_count_list, + hb_array_t<const GlyphID> component_list /* Starting from second for each ligature */) { TRACE_SERIALIZE (this); if (unlikely (!Lookup::serialize (c, SubTable::Ligature, lookup_props, 1))) return_trace (false); return_trace (serialize_subtable (c, 0).u.ligature.serialize (c, first_glyphs, ligature_per_first_glyph_count_list, - num_first_glyphs, ligatures_list, component_count_list, component_list)); } template <typename context_t> - static inline typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index); + static typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index); - static inline hb_closure_context_t::return_t dispatch_closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index) + static hb_closure_context_t::return_t dispatch_closure_recurse_func (hb_closure_context_t *c, unsigned int lookup_index) { if (!c->should_visit_lookup (lookup_index)) return HB_VOID; @@ -1458,13 +1421,13 @@ struct SubstLookup : Lookup } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { return Lookup::dispatch<SubTable> (c); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { return Lookup::subset<SubTable> (c); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { return Lookup::sanitize<SubTable> (c); } }; @@ -1475,15 +1438,15 @@ struct SubstLookup : Lookup struct GSUB : GSUBGPOS { - static const hb_tag_t tableTag = HB_OT_TAG_GSUB; + enum { tableTag = HB_OT_TAG_GSUB }; - inline const SubstLookup& get_lookup (unsigned int i) const + const SubstLookup& get_lookup (unsigned int i) const { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { return GSUBGPOS::subset<SubstLookup> (c); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { return GSUBGPOS::sanitize<SubstLookup> (c); } HB_INTERNAL bool is_blacklisted (hb_blob_t *blob, @@ -1498,7 +1461,7 @@ struct GSUB_accelerator_t : GSUB::accelerator_t {}; /* Out-of-class implementation for methods recursing */ -/*static*/ inline bool ExtensionSubst::is_reverse (void) const +/*static*/ inline bool ExtensionSubst::is_reverse () const { unsigned int type = get_type (); if (unlikely (type == SubTable::Extension)) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh index a9bfee155d8..ac6e646384f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gsubgpos.hh @@ -44,10 +44,10 @@ namespace OT { struct hb_intersects_context_t : hb_dispatch_context_t<hb_intersects_context_t, bool, 0> { - inline const char *get_name (void) { return "INTERSECTS"; } + const char *get_name () { return "INTERSECTS"; } template <typename T> - inline return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); } - static return_t default_return_value (void) { return false; } + return_t dispatch (const T &obj) { return obj.intersects (this->glyphs); } + static return_t default_return_value () { return false; } bool stop_sublookup_iteration (return_t r) const { return r; } const hb_set_t *glyphs; @@ -61,12 +61,11 @@ struct hb_intersects_context_t : struct hb_closure_context_t : hb_dispatch_context_t<hb_closure_context_t, hb_void_t, HB_DEBUG_CLOSURE> { - inline const char *get_name (void) { return "CLOSURE"; } + const char *get_name () { return "CLOSURE"; } typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); template <typename T> - inline return_t dispatch (const T &obj) { obj.closure (this); 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; } + return_t dispatch (const T &obj) { obj.closure (this); return HB_VOID; } + static return_t default_return_value () { return HB_VOID; } void recurse (unsigned int lookup_index) { if (unlikely (nesting_level_left == 0 || !recurse_func)) @@ -109,14 +108,11 @@ struct hb_closure_context_t : debug_depth (0), done_lookups (done_lookups_) {} - ~hb_closure_context_t (void) - { - flush (); - } + ~hb_closure_context_t () { flush (); } void set_recurse_func (recurse_func_t func) { recurse_func = func; } - void flush (void) + void flush () { hb_set_union (glyphs, out); hb_set_clear (out); @@ -130,10 +126,10 @@ struct hb_closure_context_t : struct hb_would_apply_context_t : hb_dispatch_context_t<hb_would_apply_context_t, bool, HB_DEBUG_WOULD_APPLY> { - inline const char *get_name (void) { return "WOULD_APPLY"; } + const char *get_name () { return "WOULD_APPLY"; } template <typename T> - inline return_t dispatch (const T &obj) { return obj.would_apply (this); } - static return_t default_return_value (void) { return false; } + return_t dispatch (const T &obj) { return obj.would_apply (this); } + static return_t default_return_value () { return false; } bool stop_sublookup_iteration (return_t r) const { return r; } hb_face_t *face; @@ -157,12 +153,11 @@ struct hb_would_apply_context_t : struct hb_collect_glyphs_context_t : hb_dispatch_context_t<hb_collect_glyphs_context_t, hb_void_t, HB_DEBUG_COLLECT_GLYPHS> { - inline const char *get_name (void) { return "COLLECT_GLYPHS"; } + const char *get_name () { return "COLLECT_GLYPHS"; } typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); template <typename T> - inline return_t dispatch (const T &obj) { obj.collect_glyphs (this); 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; } + return_t dispatch (const T &obj) { obj.collect_glyphs (this); return HB_VOID; } + static return_t default_return_value () { return HB_VOID; } void recurse (unsigned int lookup_index) { if (unlikely (nesting_level_left == 0 || !recurse_func)) @@ -226,7 +221,7 @@ struct hb_collect_glyphs_context_t : recursed_lookups (hb_set_create ()), nesting_level_left (nesting_level_left_), debug_depth (0) {} - ~hb_collect_glyphs_context_t (void) { hb_set_destroy (recursed_lookups); } + ~hb_collect_glyphs_context_t () { hb_set_destroy (recursed_lookups); } void set_recurse_func (recurse_func_t func) { recurse_func = func; } }; @@ -237,11 +232,11 @@ template <typename set_t> struct hb_add_coverage_context_t : hb_dispatch_context_t<hb_add_coverage_context_t<set_t>, const Coverage &, HB_DEBUG_GET_COVERAGE> { - inline const char *get_name (void) { return "GET_COVERAGE"; } + const char *get_name () { return "GET_COVERAGE"; } typedef const Coverage &return_t; template <typename T> - inline return_t dispatch (const T &obj) { return obj.get_coverage (); } - static return_t default_return_value (void) { return Null(Coverage); } + return_t dispatch (const T &obj) { return obj.get_coverage (); } + static return_t default_return_value () { return Null(Coverage); } bool stop_sublookup_iteration (return_t r) const { r.add_coverage (set); @@ -262,7 +257,7 @@ struct hb_ot_apply_context_t : { struct matcher_t { - inline matcher_t (void) : + matcher_t () : lookup_props (0), ignore_zwnj (false), ignore_zwj (false), @@ -275,12 +270,12 @@ struct hb_ot_apply_context_t : typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const HBUINT16 &value, const void *data); - inline void set_ignore_zwnj (bool ignore_zwnj_) { ignore_zwnj = ignore_zwnj_; } - inline void set_ignore_zwj (bool ignore_zwj_) { ignore_zwj = ignore_zwj_; } - inline void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } - inline void set_mask (hb_mask_t mask_) { mask = mask_; } - inline void set_syllable (uint8_t syllable_) { syllable = syllable_; } - inline void set_match_func (match_func_t match_func_, + void set_ignore_zwnj (bool ignore_zwnj_) { ignore_zwnj = ignore_zwnj_; } + void set_ignore_zwj (bool ignore_zwj_) { ignore_zwj = ignore_zwj_; } + void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; } + void set_mask (hb_mask_t mask_) { mask = mask_; } + void set_syllable (uint8_t syllable_) { syllable = syllable_; } + void set_match_func (match_func_t match_func_, const void *match_data_) { match_func = match_func_; match_data = match_data_; } @@ -290,7 +285,7 @@ struct hb_ot_apply_context_t : MATCH_MAYBE }; - inline may_match_t may_match (const hb_glyph_info_t &info, + may_match_t may_match (const hb_glyph_info_t &info, const HBUINT16 *glyph_data) const { if (!(info.mask & mask) || @@ -309,9 +304,8 @@ struct hb_ot_apply_context_t : SKIP_MAYBE }; - inline may_skip_t - may_skip (const hb_ot_apply_context_t *c, - const hb_glyph_info_t &info) const + may_skip_t may_skip (const hb_ot_apply_context_t *c, + const hb_glyph_info_t &info) const { if (!c->check_glyph_property (&info, lookup_props)) return SKIP_YES; @@ -336,7 +330,7 @@ struct hb_ot_apply_context_t : struct skipping_iterator_t { - inline void init (hb_ot_apply_context_t *c_, bool context_match = false) + void init (hb_ot_apply_context_t *c_, bool context_match = false) { c = c_; match_glyph_data = nullptr; @@ -348,19 +342,19 @@ struct hb_ot_apply_context_t : matcher.set_ignore_zwj (context_match || c->auto_zwj); matcher.set_mask (context_match ? -1 : c->lookup_mask); } - inline void set_lookup_props (unsigned int lookup_props) + void set_lookup_props (unsigned int lookup_props) { matcher.set_lookup_props (lookup_props); } - inline void set_match_func (matcher_t::match_func_t match_func_, - const void *match_data_, - const HBUINT16 glyph_data[]) + void set_match_func (matcher_t::match_func_t match_func_, + const void *match_data_, + const HBUINT16 glyph_data[]) { matcher.set_match_func (match_func_, match_data_); match_glyph_data = glyph_data; } - inline void reset (unsigned int start_index_, + void reset (unsigned int start_index_, unsigned int num_items_) { idx = start_index_; @@ -369,15 +363,13 @@ struct hb_ot_apply_context_t : matcher.set_syllable (start_index_ == c->buffer->idx ? c->buffer->cur().syllable () : 0); } - inline void reject (void) { num_items++; match_glyph_data--; } + void reject () { num_items++; match_glyph_data--; } - inline matcher_t::may_skip_t - may_skip (const hb_glyph_info_t &info) const - { - return matcher.may_skip (c, info); - } + matcher_t::may_skip_t + may_skip (const hb_glyph_info_t &info) const + { return matcher.may_skip (c, info); } - inline bool next (void) + bool next () { assert (num_items > 0); while (idx + num_items < end) @@ -404,7 +396,7 @@ struct hb_ot_apply_context_t : } return false; } - inline bool prev (void) + bool prev () { assert (num_items > 0); while (idx > num_items - 1) @@ -443,11 +435,11 @@ struct hb_ot_apply_context_t : }; - inline const char *get_name (void) { return "APPLY"; } + const char *get_name () { return "APPLY"; } typedef return_t (*recurse_func_t) (hb_ot_apply_context_t *c, unsigned int lookup_index); template <typename T> - inline return_t dispatch (const T &obj) { return obj.apply (this); } - static return_t default_return_value (void) { return false; } + return_t dispatch (const T &obj) { return obj.apply (this); } + static return_t default_return_value () { return false; } bool stop_sublookup_iteration (return_t r) const { return r; } return_t recurse (unsigned int sub_lookup_index) { @@ -506,31 +498,30 @@ struct hb_ot_apply_context_t : random (false), random_state (1) { init_iters (); } - inline void init_iters (void) + void init_iters () { iter_input.init (this, false); iter_context.init (this, true); } - inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; init_iters (); } - inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; init_iters (); } - inline void set_auto_zwnj (bool auto_zwnj_) { auto_zwnj = auto_zwnj_; init_iters (); } - inline void set_random (bool random_) { random = random_; } - inline void set_recurse_func (recurse_func_t func) { recurse_func = func; } - inline void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } - inline void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; init_iters (); } + void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; init_iters (); } + void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; init_iters (); } + void set_auto_zwnj (bool auto_zwnj_) { auto_zwnj = auto_zwnj_; init_iters (); } + void set_random (bool random_) { random = random_; } + void set_recurse_func (recurse_func_t func) { recurse_func = func; } + void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } + void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; init_iters (); } - inline uint32_t random_number (void) + uint32_t random_number () { /* http://www.cplusplus.com/reference/random/minstd_rand/ */ random_state = random_state * 48271 % 2147483647; return random_state; } - inline bool - match_properties_mark (hb_codepoint_t glyph, - unsigned int glyph_props, - unsigned int match_props) const + bool match_properties_mark (hb_codepoint_t glyph, + unsigned int glyph_props, + unsigned int match_props) const { /* If using mark filtering sets, the high short of * match_props has the set index. @@ -548,9 +539,8 @@ struct hb_ot_apply_context_t : return true; } - inline bool - check_glyph_property (const hb_glyph_info_t *info, - unsigned int match_props) const + bool check_glyph_property (const hb_glyph_info_t *info, + unsigned int match_props) const { hb_codepoint_t glyph = info->codepoint; unsigned int glyph_props = _hb_glyph_info_get_glyph_props (info); @@ -567,7 +557,7 @@ struct hb_ot_apply_context_t : return true; } - inline void _set_glyph_props (hb_codepoint_t glyph_index, + void _set_glyph_props (hb_codepoint_t glyph_index, unsigned int class_guess = 0, bool ligature = false, bool component = false) const @@ -594,23 +584,23 @@ struct hb_ot_apply_context_t : _hb_glyph_info_set_glyph_props (&buffer->cur(), add_in | class_guess); } - inline void replace_glyph (hb_codepoint_t glyph_index) const + void replace_glyph (hb_codepoint_t glyph_index) const { _set_glyph_props (glyph_index); buffer->replace_glyph (glyph_index); } - inline void replace_glyph_inplace (hb_codepoint_t glyph_index) const + void replace_glyph_inplace (hb_codepoint_t glyph_index) const { _set_glyph_props (glyph_index); buffer->cur().codepoint = glyph_index; } - inline void replace_glyph_with_ligature (hb_codepoint_t glyph_index, + void replace_glyph_with_ligature (hb_codepoint_t glyph_index, unsigned int class_guess) const { _set_glyph_props (glyph_index, class_guess, true); buffer->replace_glyph (glyph_index); } - inline void output_glyph_for_component (hb_codepoint_t glyph_index, + void output_glyph_for_component (hb_codepoint_t glyph_index, unsigned int class_guess) const { _set_glyph_props (glyph_index, class_guess, false, true); @@ -623,7 +613,7 @@ 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) + static 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); @@ -634,7 +624,7 @@ struct hb_get_subtables_context_t : struct hb_applicable_t { template <typename T> - inline void init (const T &obj_, hb_apply_func_t apply_func_) + void init (const T &obj_, hb_apply_func_t apply_func_) { obj = &obj_; apply_func = apply_func_; @@ -642,7 +632,7 @@ struct hb_get_subtables_context_t : obj_.get_coverage ().add_coverage (&digest); } - inline bool apply (OT::hb_ot_apply_context_t *c) const + bool apply (OT::hb_ot_apply_context_t *c) const { return digest.may_have (c->buffer->cur().codepoint) && apply_func (obj, c); } @@ -656,16 +646,15 @@ struct hb_get_subtables_context_t : typedef hb_vector_t<hb_applicable_t, 2> array_t; /* Dispatch interface. */ - inline const char *get_name (void) { return "GET_SUBTABLES"; } + const char *get_name () { return "GET_SUBTABLES"; } template <typename T> - inline return_t dispatch (const T &obj) + 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; } + static return_t default_return_value () { return HB_VOID; } hb_get_subtables_context_t (array_t &array_) : array (array_), @@ -1061,7 +1050,7 @@ static inline bool match_lookahead (hb_ot_apply_context_t *c, struct LookupRecord { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -1298,14 +1287,14 @@ static inline bool context_apply_lookup (hb_ot_apply_context_t *c, struct Rule { - inline bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const + bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const { return context_intersects (glyphs, inputCount, inputZ.arrayZ, lookup_context); } - inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const + void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > @@ -1316,7 +1305,8 @@ struct Rule lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const + void collect_glyphs (hb_collect_glyphs_context_t *c, + ContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > @@ -1327,7 +1317,8 @@ struct Rule lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const + bool would_apply (hb_would_apply_context_t *c, + ContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > @@ -1335,7 +1326,8 @@ struct Rule 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 + bool apply (hb_ot_apply_context_t *c, + ContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > @@ -1344,13 +1336,13 @@ struct Rule } public: - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (inputCount.sanitize (c) && lookupCount.sanitize (c) && c->check_range (inputZ.arrayZ, - inputZ[0].static_size * (inputCount ? inputCount - 1 : 0) + + inputZ.item_size * (inputCount ? inputCount - 1 : 0) + LookupRecord::static_size * lookupCount)); } @@ -1371,7 +1363,8 @@ struct Rule struct RuleSet { - inline bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const + bool intersects (const hb_set_t *glyphs, + ContextClosureLookupContext &lookup_context) const { unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) @@ -1380,7 +1373,8 @@ struct RuleSet return false; } - inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const + void closure (hb_closure_context_t *c, + ContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); unsigned int num_rules = rule.len; @@ -1388,7 +1382,8 @@ struct RuleSet (this+rule[i]).closure (c, lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const + void collect_glyphs (hb_collect_glyphs_context_t *c, + ContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); unsigned int num_rules = rule.len; @@ -1396,7 +1391,8 @@ struct RuleSet (this+rule[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const + bool would_apply (hb_would_apply_context_t *c, + ContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); unsigned int num_rules = rule.len; @@ -1408,7 +1404,8 @@ struct RuleSet return_trace (false); } - inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const + bool apply (hb_ot_apply_context_t *c, + ContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); unsigned int num_rules = rule.len; @@ -1420,7 +1417,7 @@ struct RuleSet return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (rule.sanitize (c, this)); @@ -1437,7 +1434,7 @@ struct RuleSet struct ContextFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { struct ContextClosureLookupContext lookup_context = { {intersects_glyph}, @@ -1456,7 +1453,7 @@ struct ContextFormat1 return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); @@ -1475,7 +1472,7 @@ struct ContextFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); @@ -1490,7 +1487,7 @@ struct ContextFormat1 (this+ruleSet[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -1502,10 +1499,9 @@ struct ContextFormat1 return_trace (rule_set.would_apply (c, lookup_context)); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); @@ -1520,14 +1516,14 @@ struct ContextFormat1 return_trace (rule_set.apply (c, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); @@ -1548,7 +1544,7 @@ struct ContextFormat1 struct ContextFormat2 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { if (!(this+coverage).intersects (glyphs)) return false; @@ -1569,7 +1565,7 @@ struct ContextFormat2 return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); if (!(this+coverage).intersects (c->glyphs)) @@ -1590,7 +1586,7 @@ struct ContextFormat2 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); @@ -1606,7 +1602,7 @@ struct ContextFormat2 (this+ruleSet[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -1620,10 +1616,9 @@ struct ContextFormat2 return_trace (rule_set.would_apply (c, lookup_context)); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); @@ -1639,14 +1634,14 @@ struct ContextFormat2 return_trace (rule_set.apply (c, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && classDef.sanitize (c, this) && ruleSet.sanitize (c, this)); @@ -1670,7 +1665,7 @@ struct ContextFormat2 struct ContextFormat3 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { if (!(this+coverageZ[0]).intersects (glyphs)) return false; @@ -1684,7 +1679,7 @@ struct ContextFormat3 lookup_context); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); if (!(this+coverageZ[0]).intersects (c->glyphs)) @@ -1701,7 +1696,7 @@ struct ContextFormat3 lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); (this+coverageZ[0]).add_coverage (c->input); @@ -1718,7 +1713,7 @@ struct ContextFormat3 lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -1730,10 +1725,9 @@ struct ContextFormat3 return_trace (context_would_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context)); } - inline const Coverage &get_coverage (void) const - { return this+coverageZ[0]; } + const Coverage &get_coverage () const { return this+coverageZ[0]; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint); @@ -1747,14 +1741,14 @@ struct ContextFormat3 return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!c->check_struct (this)) return_trace (false); @@ -1785,7 +1779,7 @@ struct ContextFormat3 struct Context { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -1942,7 +1936,7 @@ static inline bool chain_context_apply_lookup (hb_ot_apply_context_t *c, struct ChainRule { - inline bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const + bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const { const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); @@ -1953,7 +1947,8 @@ struct ChainRule lookup_context); } - inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const + void closure (hb_closure_context_t *c, + ChainContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); @@ -1967,7 +1962,8 @@ struct ChainRule lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const + void collect_glyphs (hb_collect_glyphs_context_t *c, + ChainContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); @@ -1981,7 +1977,8 @@ struct ChainRule lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const + bool would_apply (hb_would_apply_context_t *c, + ChainContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); @@ -1994,7 +1991,7 @@ struct ChainRule lookup.arrayZ, lookup_context)); } - inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const + bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); @@ -2007,7 +2004,7 @@ struct ChainRule lookup.arrayZ, lookup_context)); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!backtrack.sanitize (c)) return_trace (false); @@ -2039,7 +2036,7 @@ struct ChainRule struct ChainRuleSet { - inline bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const + bool intersects (const hb_set_t *glyphs, ChainContextClosureLookupContext &lookup_context) const { unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) @@ -2047,7 +2044,7 @@ struct ChainRuleSet return true; return false; } - inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const + void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); unsigned int num_rules = rule.len; @@ -2055,7 +2052,7 @@ struct ChainRuleSet (this+rule[i]).closure (c, lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const + void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); unsigned int num_rules = rule.len; @@ -2063,7 +2060,7 @@ struct ChainRuleSet (this+rule[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const + bool would_apply (hb_would_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); unsigned int num_rules = rule.len; @@ -2074,7 +2071,7 @@ struct ChainRuleSet return_trace (false); } - inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const + bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); unsigned int num_rules = rule.len; @@ -2085,7 +2082,7 @@ struct ChainRuleSet return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (rule.sanitize (c, this)); @@ -2101,7 +2098,7 @@ struct ChainRuleSet struct ChainContextFormat1 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { struct ChainContextClosureLookupContext lookup_context = { {intersects_glyph}, @@ -2120,7 +2117,7 @@ struct ChainContextFormat1 return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); @@ -2139,7 +2136,7 @@ struct ChainContextFormat1 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); @@ -2154,7 +2151,7 @@ struct ChainContextFormat1 (this+ruleSet[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -2166,10 +2163,9 @@ struct ChainContextFormat1 return_trace (rule_set.would_apply (c, lookup_context)); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); @@ -2183,14 +2179,14 @@ struct ChainContextFormat1 return_trace (rule_set.apply (c, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && ruleSet.sanitize (c, this)); @@ -2210,7 +2206,7 @@ struct ChainContextFormat1 struct ChainContextFormat2 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { if (!(this+coverage).intersects (glyphs)) return false; @@ -2234,7 +2230,7 @@ struct ChainContextFormat2 return false; } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); if (!(this+coverage).intersects (c->glyphs)) @@ -2259,7 +2255,7 @@ struct ChainContextFormat2 } } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); @@ -2280,7 +2276,7 @@ struct ChainContextFormat2 (this+ruleSet[i]).collect_glyphs (c, lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -2299,10 +2295,9 @@ struct ChainContextFormat2 return_trace (rule_set.would_apply (c, lookup_context)); } - inline const Coverage &get_coverage (void) const - { return this+coverage; } + const Coverage &get_coverage () const { return this+coverage; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint); @@ -2323,14 +2318,14 @@ struct ChainContextFormat2 return_trace (rule_set.apply (c, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (coverage.sanitize (c, this) && @@ -2366,7 +2361,7 @@ struct ChainContextFormat2 struct ChainContextFormat3 { - inline bool intersects (const hb_set_t *glyphs) const + bool intersects (const hb_set_t *glyphs) const { const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); @@ -2385,7 +2380,7 @@ struct ChainContextFormat3 lookup_context); } - inline void closure (hb_closure_context_t *c) const + void closure (hb_closure_context_t *c) const { TRACE_CLOSURE (this); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); @@ -2407,7 +2402,7 @@ struct ChainContextFormat3 lookup_context); } - inline void collect_glyphs (hb_collect_glyphs_context_t *c) const + void collect_glyphs (hb_collect_glyphs_context_t *c) const { TRACE_COLLECT_GLYPHS (this); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); @@ -2428,7 +2423,7 @@ struct ChainContextFormat3 lookup_context); } - inline bool would_apply (hb_would_apply_context_t *c) const + bool would_apply (hb_would_apply_context_t *c) const { TRACE_WOULD_APPLY (this); @@ -2446,13 +2441,13 @@ struct ChainContextFormat3 lookup.len, lookup.arrayZ, lookup_context)); } - inline const Coverage &get_coverage (void) const + const Coverage &get_coverage () const { const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); return this+input[0]; } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { TRACE_APPLY (this); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); @@ -2473,14 +2468,14 @@ struct ChainContextFormat3 lookup.len, lookup.arrayZ, lookup_context)); } - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); // TODO(subset) return_trace (false); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (!backtrack.sanitize (c, this)) return_trace (false); @@ -2517,7 +2512,7 @@ struct ChainContextFormat3 struct ChainContext { template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -2542,10 +2537,10 @@ struct ChainContext template <typename T> struct ExtensionFormat1 { - inline unsigned int get_type (void) const { return extensionLookupType; } + unsigned int get_type () const { return extensionLookupType; } template <typename X> - inline const X& get_subtable (void) const + const X& get_subtable () const { unsigned int offset = extensionOffset; if (unlikely (!offset)) return Null(typename T::SubTable); @@ -2553,7 +2548,7 @@ struct ExtensionFormat1 } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, format); if (unlikely (!c->may_dispatch (this, this))) return_trace (c->no_dispatch_return_value ()); @@ -2561,7 +2556,7 @@ struct ExtensionFormat1 } /* This is called from may_dispatch() above with hb_sanitize_context_t. */ - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -2583,7 +2578,7 @@ struct ExtensionFormat1 template <typename T> struct Extension { - inline unsigned int get_type (void) const + unsigned int get_type () const { switch (u.format) { case 1: return u.format1.get_type (); @@ -2591,7 +2586,7 @@ struct Extension } } template <typename X> - inline const X& get_subtable (void) const + const X& get_subtable () const { switch (u.format) { case 1: return u.format1.template get_subtable<typename T::SubTable> (); @@ -2600,7 +2595,7 @@ struct Extension } template <typename context_t> - inline typename context_t::return_t dispatch (context_t *c) const + typename context_t::return_t dispatch (context_t *c) const { TRACE_DISPATCH (this, u.format); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); @@ -2625,7 +2620,7 @@ struct Extension struct hb_ot_layout_lookup_accelerator_t { template <typename TLookup> - inline void init (const TLookup &lookup) + void init (const TLookup &lookup) { digest.init (); lookup.add_coverage (&digest); @@ -2634,15 +2629,12 @@ struct hb_ot_layout_lookup_accelerator_t OT::hb_get_subtables_context_t c_get_subtables (subtables); lookup.dispatch (&c_get_subtables); } - inline void fini (void) - { - subtables.fini (); - } + void fini () { subtables.fini (); } - inline bool may_have (hb_codepoint_t g) const + bool may_have (hb_codepoint_t g) const { return digest.may_have (g); } - inline bool apply (hb_ot_apply_context_t *c) const + bool apply (hb_ot_apply_context_t *c) const { for (unsigned int i = 0; i < subtables.len; i++) if (subtables[i].apply (c)) @@ -2657,43 +2649,43 @@ struct hb_ot_layout_lookup_accelerator_t struct GSUBGPOS { - inline bool has_data (void) const { return version.to_int (); } - inline unsigned int get_script_count (void) const + bool has_data () const { return version.to_int (); } + unsigned int get_script_count () const { return (this+scriptList).len; } - inline const Tag& get_script_tag (unsigned int i) const + const Tag& get_script_tag (unsigned int i) const { return (this+scriptList).get_tag (i); } - inline unsigned int get_script_tags (unsigned int start_offset, - unsigned int *script_count /* IN/OUT */, - hb_tag_t *script_tags /* OUT */) const + unsigned int get_script_tags (unsigned int start_offset, + unsigned int *script_count /* IN/OUT */, + hb_tag_t *script_tags /* OUT */) const { return (this+scriptList).get_tags (start_offset, script_count, script_tags); } - inline const Script& get_script (unsigned int i) const + const Script& get_script (unsigned int i) const { return (this+scriptList)[i]; } - inline bool find_script_index (hb_tag_t tag, unsigned int *index) const + bool find_script_index (hb_tag_t tag, unsigned int *index) const { return (this+scriptList).find_index (tag, index); } - inline unsigned int get_feature_count (void) const + unsigned int get_feature_count () const { return (this+featureList).len; } - inline hb_tag_t get_feature_tag (unsigned int i) const + hb_tag_t get_feature_tag (unsigned int i) const { return i == Index::NOT_FOUND_INDEX ? HB_TAG_NONE : (this+featureList).get_tag (i); } - inline unsigned int get_feature_tags (unsigned int start_offset, - unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */) const + unsigned int get_feature_tags (unsigned int start_offset, + unsigned int *feature_count /* IN/OUT */, + hb_tag_t *feature_tags /* OUT */) const { return (this+featureList).get_tags (start_offset, feature_count, feature_tags); } - inline const Feature& get_feature (unsigned int i) const + const Feature& get_feature (unsigned int i) const { return (this+featureList)[i]; } - inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const + bool find_feature_index (hb_tag_t tag, unsigned int *index) const { return (this+featureList).find_index (tag, index); } - inline unsigned int get_lookup_count (void) const + unsigned int get_lookup_count () const { return (this+lookupList).len; } - inline const Lookup& get_lookup (unsigned int i) const + const Lookup& get_lookup (unsigned int i) const { return (this+lookupList)[i]; } - inline bool find_variations_index (const int *coords, unsigned int num_coords, - unsigned int *index) const + bool find_variations_index (const int *coords, unsigned int num_coords, + unsigned int *index) const { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) .find_index (coords, num_coords, index); } - inline const Feature& get_feature_variation (unsigned int feature_index, + const Feature& get_feature_variation (unsigned int feature_index, unsigned int variations_index) const { if (FeatureVariations::NOT_FOUND_INDEX != variations_index && @@ -2708,11 +2700,12 @@ struct GSUBGPOS } template <typename TLookup> - inline bool subset (hb_subset_context_t *c) const + bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); struct GSUBGPOS *out = c->serializer->embed (*this); if (unlikely (!out)) return_trace (false); + out->scriptList.serialize_subset (c, this+scriptList, out); out->featureList.serialize_subset (c, this+featureList, out); @@ -2725,17 +2718,18 @@ struct GSUBGPOS if (version.to_int () >= 0x00010001u) out->featureVars.serialize_subset (c, this+featureVars, out); + return_trace (true); } - inline unsigned int get_size (void) const + unsigned int get_size () const { return min_size + (version.to_int () >= 0x00010001u ? featureVars.static_size : 0); } template <typename TLookup> - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); typedef OffsetListOf<TLookup> TLookupList; @@ -2750,7 +2744,7 @@ struct GSUBGPOS template <typename T> struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { this->table = hb_sanitize_context_t().reference_table<T> (face); if (unlikely (this->table->is_blacklisted (this->table.get_blob (), face))) @@ -2769,7 +2763,7 @@ struct GSUBGPOS this->accels[i].init (table->get_lookup (i)); } - inline void fini (void) + void fini () { for (unsigned int i = 0; i < this->lookup_count; i++) this->accels[i].fini (); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-jstf-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-jstf-table.hh index 2fb23cbc32d..3beedc49b40 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-jstf-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-jstf-table.hh @@ -54,7 +54,7 @@ typedef OffsetListOf<PosLookup> JstfMax; struct JstfPriority { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -123,8 +123,8 @@ struct JstfPriority struct JstfLangSys : OffsetListOf<JstfPriority> { - inline bool sanitize (hb_sanitize_context_t *c, - const Record_sanitize_closure_t * = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + const Record_sanitize_closure_t * = nullptr) const { TRACE_SANITIZE (this); return_trace (OffsetListOf<JstfPriority>::sanitize (c)); @@ -145,27 +145,27 @@ typedef SortedArrayOf<GlyphID> ExtenderGlyphs; struct JstfScript { - inline unsigned int get_lang_sys_count (void) const + unsigned int get_lang_sys_count () const { return langSys.len; } - inline const Tag& get_lang_sys_tag (unsigned int i) const + const Tag& get_lang_sys_tag (unsigned int i) const { return langSys.get_tag (i); } - inline unsigned int get_lang_sys_tags (unsigned int start_offset, - unsigned int *lang_sys_count /* IN/OUT */, - hb_tag_t *lang_sys_tags /* OUT */) const + unsigned int get_lang_sys_tags (unsigned int start_offset, + unsigned int *lang_sys_count /* IN/OUT */, + hb_tag_t *lang_sys_tags /* OUT */) const { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } - inline const JstfLangSys& get_lang_sys (unsigned int i) const + const JstfLangSys& get_lang_sys (unsigned int i) const { if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); return this+langSys[i].offset; } - inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const + bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const { return langSys.find_index (tag, index); } - inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } - inline const JstfLangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } + bool has_default_lang_sys () const { return defaultLangSys != 0; } + const JstfLangSys& get_default_lang_sys () const { return this+defaultLangSys; } - inline bool sanitize (hb_sanitize_context_t *c, - const Record_sanitize_closure_t * = nullptr) const + bool sanitize (hb_sanitize_context_t *c, + const Record_sanitize_closure_t * = nullptr) const { TRACE_SANITIZE (this); return_trace (extenderGlyphs.sanitize (c, this) && @@ -195,22 +195,22 @@ struct JstfScript struct JSTF { - static const hb_tag_t tableTag = HB_OT_TAG_JSTF; + enum { tableTag = HB_OT_TAG_JSTF }; - inline unsigned int get_script_count (void) const + unsigned int get_script_count () const { return scriptList.len; } - inline const Tag& get_script_tag (unsigned int i) const + const Tag& get_script_tag (unsigned int i) const { return scriptList.get_tag (i); } - inline unsigned int get_script_tags (unsigned int start_offset, - unsigned int *script_count /* IN/OUT */, - hb_tag_t *script_tags /* OUT */) const + unsigned int get_script_tags (unsigned int start_offset, + unsigned int *script_count /* IN/OUT */, + hb_tag_t *script_tags /* OUT */) const { return scriptList.get_tags (start_offset, script_count, script_tags); } - inline const JstfScript& get_script (unsigned int i) const + const JstfScript& get_script (unsigned int i) const { return this+scriptList[i].offset; } - inline bool find_script_index (hb_tag_t tag, unsigned int *index) const + bool find_script_index (hb_tag_t tag, unsigned int *index) const { return scriptList.find_index (tag, index); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc index d0b22efe312..67ce9235349 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc @@ -35,11 +35,12 @@ #include "hb-map.hh" #include "hb-ot-kern-table.hh" +#include "hb-ot-gasp-table.hh" // Just so we compile it; unused otherwise. #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-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-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" @@ -1299,7 +1300,7 @@ hb_ot_layout_feature_get_characters (hb_face_t *face, struct GSUBProxy { enum { table_index = 0 }; - static const bool inplace = false; + enum { inplace = false }; typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : @@ -1313,7 +1314,7 @@ struct GSUBProxy struct GPOSProxy { enum { table_index = 1 }; - static const bool inplace = true; + enum { inplace = true }; typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc index 95f794ab4a2..884202cb1e2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc @@ -68,7 +68,7 @@ hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_, } } -hb_ot_map_builder_t::~hb_ot_map_builder_t (void) +hb_ot_map_builder_t::~hb_ot_map_builder_t () { feature_infos.fini (); for (unsigned int table_index = 0; table_index < 2; table_index++) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh index 0a5a4fbcb70..35e94934019 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh @@ -57,7 +57,7 @@ struct hb_ot_map_t unsigned int auto_zwj : 1; unsigned int random : 1; - inline int cmp (const hb_tag_t tag_) const + int cmp (const hb_tag_t tag_) const { return tag_ < tag ? -1 : tag_ > tag ? 1 : 0; } }; @@ -83,7 +83,7 @@ struct hb_ot_map_t pause_func_t pause_func; }; - inline void init (void) + void init () { memset (this, 0, sizeof (*this)); @@ -94,7 +94,7 @@ struct hb_ot_map_t stages[table_index].init (); } } - inline void fini (void) + void fini () { features.fini (); for (unsigned int table_index = 0; table_index < 2; table_index++) @@ -104,36 +104,42 @@ struct hb_ot_map_t } } - inline hb_mask_t get_global_mask (void) const { return global_mask; } + hb_mask_t get_global_mask () const { return global_mask; } - inline hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = nullptr) const { + hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = nullptr) const + { const feature_map_t *map = features.bsearch (feature_tag); if (shift) *shift = map ? map->shift : 0; return map ? map->mask : 0; } - inline bool needs_fallback (hb_tag_t feature_tag) const { + bool needs_fallback (hb_tag_t feature_tag) const + { const feature_map_t *map = features.bsearch (feature_tag); return map ? map->needs_fallback : false; } - inline hb_mask_t get_1_mask (hb_tag_t feature_tag) const { + hb_mask_t get_1_mask (hb_tag_t feature_tag) const + { const feature_map_t *map = features.bsearch (feature_tag); return map ? map->_1_mask : 0; } - inline unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const { + unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const + { const feature_map_t *map = features.bsearch (feature_tag); return map ? map->index[table_index] : HB_OT_LAYOUT_NO_FEATURE_INDEX; } - inline unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const { + unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const + { const feature_map_t *map = features.bsearch (feature_tag); return map ? map->stage[table_index] : (unsigned int) -1; } - inline void get_stage_lookups (unsigned int table_index, unsigned int stage, - const struct lookup_map_t **plookups, unsigned int *lookup_count) const { + void get_stage_lookups (unsigned int table_index, unsigned int stage, + const struct lookup_map_t **plookups, unsigned int *lookup_count) const + { if (unlikely (stage == (unsigned int) -1)) { *plookups = nullptr; *lookup_count = 0; @@ -197,26 +203,26 @@ struct hb_ot_map_builder_t HB_INTERNAL hb_ot_map_builder_t (hb_face_t *face_, const hb_segment_properties_t *props_); - HB_INTERNAL ~hb_ot_map_builder_t (void); + HB_INTERNAL ~hb_ot_map_builder_t (); HB_INTERNAL void add_feature (hb_tag_t tag, hb_ot_map_feature_flags_t flags=F_NONE, unsigned int value=1); - inline void add_feature (const hb_ot_map_feature_t &feat) + void add_feature (const hb_ot_map_feature_t &feat) { add_feature (feat.tag, feat.flags); } - inline void enable_feature (hb_tag_t tag, + void enable_feature (hb_tag_t tag, hb_ot_map_feature_flags_t flags=F_NONE, unsigned int value=1) { add_feature (tag, F_GLOBAL | flags, value); } - inline void disable_feature (hb_tag_t tag) + void disable_feature (hb_tag_t tag) { add_feature (tag, F_GLOBAL, 0); } - inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func) + void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func) { add_pause (0, pause_func); } - inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func) + 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, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh index 153a417959d..120ab065465 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh @@ -36,12 +36,12 @@ namespace OT { struct MathValueRecord { - inline hb_position_t get_x_value (hb_font_t *font, const void *base) const + hb_position_t get_x_value (hb_font_t *font, const void *base) const { return font->em_scale_x (value) + (base+deviceTable).get_x_delta (font); } - inline hb_position_t get_y_value (hb_font_t *font, const void *base) const + hb_position_t get_y_value (hb_font_t *font, const void *base) const { return font->em_scale_y (value) + (base+deviceTable).get_y_delta (font); } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && deviceTable.sanitize (c, base)); @@ -59,7 +59,7 @@ struct MathValueRecord struct MathConstants { - inline bool sanitize_math_value_records (hb_sanitize_context_t *c) const + bool sanitize_math_value_records (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -71,13 +71,13 @@ struct MathConstants return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && sanitize_math_value_records (c)); } - inline hb_position_t get_value (hb_ot_math_constant_t constant, + hb_position_t get_value (hb_ot_math_constant_t constant, hb_font_t *font) const { switch (constant) { @@ -165,7 +165,7 @@ struct MathConstants struct MathItalicsCorrectionInfo { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -173,8 +173,8 @@ struct MathItalicsCorrectionInfo italicsCorrection.sanitize (c, this)); } - inline hb_position_t get_value (hb_codepoint_t glyph, - hb_font_t *font) const + hb_position_t get_value (hb_codepoint_t glyph, + hb_font_t *font) const { unsigned int index = (this+coverage).get_coverage (glyph); return italicsCorrection[index].get_x_value (font, this); @@ -196,7 +196,7 @@ struct MathItalicsCorrectionInfo struct MathTopAccentAttachment { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -204,8 +204,8 @@ struct MathTopAccentAttachment topAccentAttachment.sanitize (c, this)); } - inline hb_position_t get_value (hb_codepoint_t glyph, - hb_font_t *font) const + hb_position_t get_value (hb_codepoint_t glyph, + hb_font_t *font) const { unsigned int index = (this+topAccentCoverage).get_coverage (glyph); if (index == NOT_COVERED) @@ -229,7 +229,7 @@ struct MathTopAccentAttachment struct MathKern { - inline bool sanitize_math_value_records (hb_sanitize_context_t *c) const + bool sanitize_math_value_records (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); unsigned int count = 2 * heightCount + 1; @@ -238,7 +238,7 @@ struct MathKern return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -246,7 +246,7 @@ struct MathKern sanitize_math_value_records (c)); } - inline hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const + hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const { const MathValueRecord* correctionHeight = mathValueRecordsZ.arrayZ; const MathValueRecord* kernValue = mathValueRecordsZ.arrayZ + heightCount; @@ -294,7 +294,7 @@ struct MathKern struct MathKernInfoRecord { - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); @@ -306,10 +306,10 @@ struct MathKernInfoRecord return_trace (true); } - inline hb_position_t get_kerning (hb_ot_math_kern_t kern, - hb_position_t correction_height, - hb_font_t *font, - const void *base) const + hb_position_t get_kerning (hb_ot_math_kern_t kern, + hb_position_t correction_height, + hb_font_t *font, + const void *base) const { unsigned int idx = kern; if (unlikely (idx >= ARRAY_LENGTH (mathKern))) return 0; @@ -327,7 +327,7 @@ struct MathKernInfoRecord struct MathKernInfo { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -335,10 +335,10 @@ struct MathKernInfo mathKernInfoRecords.sanitize (c, this)); } - inline hb_position_t get_kerning (hb_codepoint_t glyph, - hb_ot_math_kern_t kern, - hb_position_t correction_height, - hb_font_t *font) const + hb_position_t get_kerning (hb_codepoint_t glyph, + hb_ot_math_kern_t kern, + hb_position_t correction_height, + hb_font_t *font) const { unsigned int index = (this+mathKernCoverage).get_coverage (glyph); return mathKernInfoRecords[index].get_kerning (kern, correction_height, font, this); @@ -361,7 +361,7 @@ struct MathKernInfo struct MathGlyphInfo { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -371,21 +371,21 @@ struct MathGlyphInfo mathKernInfo.sanitize (c, this)); } - inline hb_position_t + hb_position_t get_italics_correction (hb_codepoint_t glyph, hb_font_t *font) const { return (this+mathItalicsCorrectionInfo).get_value (glyph, font); } - inline hb_position_t + hb_position_t get_top_accent_attachment (hb_codepoint_t glyph, hb_font_t *font) const { return (this+mathTopAccentAttachment).get_value (glyph, font); } - inline bool is_extended_shape (hb_codepoint_t glyph) const + bool is_extended_shape (hb_codepoint_t glyph) const { return (this+extendedShapeCoverage).get_coverage (glyph) != NOT_COVERED; } - inline hb_position_t get_kerning (hb_codepoint_t glyph, - hb_ot_math_kern_t kern, - hb_position_t correction_height, - hb_font_t *font) const + hb_position_t get_kerning (hb_codepoint_t glyph, + hb_ot_math_kern_t kern, + hb_position_t correction_height, + hb_font_t *font) const { return (this+mathKernInfo).get_kerning (glyph, kern, correction_height, font); } protected: @@ -416,7 +416,7 @@ struct MathGlyphVariantRecord { friend struct MathGlyphConstruction; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -446,15 +446,15 @@ struct PartFlags : HBUINT16 struct MathGlyphPartRecord { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } - inline void extract (hb_ot_math_glyph_part_t &out, - int scale, - hb_font_t *font) const + void extract (hb_ot_math_glyph_part_t &out, + int scale, + hb_font_t *font) const { out.glyph = glyph; @@ -491,7 +491,7 @@ struct MathGlyphPartRecord struct MathGlyphAssembly { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -499,12 +499,12 @@ struct MathGlyphAssembly partRecords.sanitize (c)); } - inline unsigned int get_parts (hb_direction_t direction, - hb_font_t *font, - unsigned int start_offset, - unsigned int *parts_count, /* IN/OUT */ - hb_ot_math_glyph_part_t *parts /* OUT */, - hb_position_t *italics_correction /* OUT */) const + unsigned int get_parts (hb_direction_t direction, + hb_font_t *font, + unsigned int start_offset, + unsigned int *parts_count, /* IN/OUT */ + hb_ot_math_glyph_part_t *parts /* OUT */, + hb_position_t *italics_correction /* OUT */) const { if (parts_count) { @@ -535,7 +535,7 @@ struct MathGlyphAssembly struct MathGlyphConstruction { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -543,14 +543,13 @@ struct MathGlyphConstruction mathGlyphVariantRecord.sanitize (c)); } - inline const MathGlyphAssembly &get_assembly (void) const - { return this+glyphAssembly; } + const MathGlyphAssembly &get_assembly () const { return this+glyphAssembly; } - inline unsigned int get_variants (hb_direction_t direction, - hb_font_t *font, - unsigned int start_offset, - unsigned int *variants_count, /* IN/OUT */ - hb_ot_math_glyph_variant_t *variants /* OUT */) const + unsigned int get_variants (hb_direction_t direction, + hb_font_t *font, + unsigned int start_offset, + unsigned int *variants_count, /* IN/OUT */ + hb_ot_math_glyph_variant_t *variants /* OUT */) const { if (variants_count) { @@ -580,7 +579,7 @@ struct MathGlyphConstruction struct MathVariants { - inline bool sanitize_offsets (hb_sanitize_context_t *c) const + bool sanitize_offsets (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); unsigned int count = vertGlyphCount + horizGlyphCount; @@ -589,7 +588,7 @@ struct MathVariants return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -599,20 +598,20 @@ struct MathVariants sanitize_offsets (c)); } - inline hb_position_t get_min_connector_overlap (hb_direction_t direction, + hb_position_t get_min_connector_overlap (hb_direction_t direction, hb_font_t *font) const { return font->em_scale_dir (minConnectorOverlap, direction); } - inline unsigned int get_glyph_variants (hb_codepoint_t glyph, - hb_direction_t direction, - hb_font_t *font, - unsigned int start_offset, - unsigned int *variants_count, /* IN/OUT */ - hb_ot_math_glyph_variant_t *variants /* OUT */) const + unsigned int get_glyph_variants (hb_codepoint_t glyph, + hb_direction_t direction, + hb_font_t *font, + unsigned int start_offset, + unsigned int *variants_count, /* IN/OUT */ + hb_ot_math_glyph_variant_t *variants /* OUT */) const { return get_glyph_construction (glyph, direction, font) .get_variants (direction, font, start_offset, variants_count, variants); } - inline unsigned int get_glyph_parts (hb_codepoint_t glyph, + unsigned int get_glyph_parts (hb_codepoint_t glyph, hb_direction_t direction, hb_font_t *font, unsigned int start_offset, @@ -626,10 +625,10 @@ struct MathVariants italics_correction); } private: - inline const MathGlyphConstruction & - get_glyph_construction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_font_t *font HB_UNUSED) const + const MathGlyphConstruction & + get_glyph_construction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_font_t *font HB_UNUSED) const { bool vertical = HB_DIRECTION_IS_VERTICAL (direction); unsigned int count = vertical ? vertGlyphCount : horizGlyphCount; @@ -680,11 +679,11 @@ struct MathVariants struct MATH { - static const hb_tag_t tableTag = HB_OT_TAG_MATH; + enum { tableTag = HB_OT_TAG_MATH }; - inline bool has_data (void) const { return version.to_int (); } + bool has_data () const { return version.to_int (); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -694,15 +693,13 @@ struct MATH mathVariants.sanitize (c, this)); } - inline hb_position_t get_constant (hb_ot_math_constant_t constant, + hb_position_t get_constant (hb_ot_math_constant_t constant, hb_font_t *font) const { return (this+mathConstants).get_value (constant, font); } - inline const MathGlyphInfo &get_glyph_info (void) const - { return this+mathGlyphInfo; } + const MathGlyphInfo &get_glyph_info () const { return this+mathGlyphInfo; } - inline const MathVariants &get_variants (void) const - { return this+mathVariants; } + const MathVariants &get_variants () const { return this+mathVariants; } protected: FixedVersion<>version; /* Version of the MATH table diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh index 198dd2518c3..ba474fd585d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh @@ -41,7 +41,7 @@ namespace OT { struct maxpV1Tail { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -71,19 +71,16 @@ struct maxpV1Tail struct maxp { - static const hb_tag_t tableTag = HB_OT_TAG_maxp; + enum { tableTag = HB_OT_TAG_maxp }; - inline unsigned int get_num_glyphs (void) const - { - return numGlyphs; - } + unsigned int get_num_glyphs () const { return numGlyphs; } - inline void set_num_glyphs (unsigned int count) + void set_num_glyphs (unsigned int count) { numGlyphs.set (count); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) @@ -97,7 +94,7 @@ struct maxp return_trace (likely (version.major == 0 && version.minor == 0x5000u)); } - inline bool subset (hb_subset_plan_t *plan) const + bool subset (hb_subset_plan_t *plan) const { hb_blob_t *maxp_blob = hb_sanitize_context_t().reference_table<maxp> (plan->source); hb_blob_t *maxp_prime_blob = hb_blob_copy_writable_or_fail (maxp_blob); @@ -117,7 +114,7 @@ struct maxp return result; } - static inline void drop_hint_fields (hb_subset_plan_t *plan HB_UNUSED, maxp *maxp_prime) + static void drop_hint_fields (hb_subset_plan_t *plan HB_UNUSED, maxp *maxp_prime) { if (maxp_prime->version.major == 1) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh index ab07b7196ad..705ae0e9215 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh @@ -49,7 +49,7 @@ namespace OT { struct NameRecord { - inline hb_language_t language (hb_face_t *face) const + hb_language_t language (hb_face_t *face) const { unsigned int p = platformID; unsigned int l = languageID; @@ -66,7 +66,7 @@ struct NameRecord return HB_LANGUAGE_INVALID; } - inline uint16_t score (void) const + uint16_t score () const { /* Same order as in cmap::find_best_subtable(). */ unsigned int p = platformID; @@ -93,7 +93,7 @@ struct NameRecord return UNSUPPORTED; } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); /* We can check from base all the way up to the end of string... */ @@ -151,12 +151,13 @@ _hb_ot_name_entry_cmp (const void *pa, const void *pb) struct name { - static const hb_tag_t tableTag = HB_OT_TAG_name; + enum { tableTag = HB_OT_TAG_name }; - inline unsigned int get_size (void) const - { return min_size + count * nameRecordZ[0].min_size; } + unsigned int get_size () const + { return min_size + count * nameRecordZ.item_size; } - inline bool sanitize_records (hb_sanitize_context_t *c) const { + bool sanitize_records (hb_sanitize_context_t *c) const + { TRACE_SANITIZE (this); const void *string_pool = (this+stringOffset).arrayZ; unsigned int _count = count; @@ -166,7 +167,7 @@ struct name return_trace (true); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -177,11 +178,11 @@ struct name struct accelerator_t { - inline void init (hb_face_t *face) + 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 = (const char *) (const void *) (this->table+this->table->stringOffset); 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); @@ -189,7 +190,7 @@ struct name this->names.init (); this->names.alloc (all_names.len); - for (uint16_t i = 0; i < all_names.len; i++) + for (unsigned int i = 0; i < all_names.len; i++) { hb_ot_name_entry_t *entry = this->names.push (); @@ -217,13 +218,13 @@ struct name this->names.resize (j); } - inline void fini (void) + void fini () { this->names.fini (); this->table.destroy (); } - inline int get_index (hb_ot_name_id_t name_id, + int get_index (hb_ot_name_id_t name_id, hb_language_t language, unsigned int *width=nullptr) const { @@ -243,16 +244,16 @@ struct name return entry->entry_index; } - inline hb_bytes_t get_name (unsigned int idx) const + 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 (); + const hb_bytes_t string_pool (pool, pool_len); + return string_pool.sub_array (record.offset, record.length); } private: - const void *pool; + const char *pool; unsigned int pool_len; public: hb_blob_ptr_t<name> table; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc index 4c886609688..b2eda293137 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc @@ -66,12 +66,12 @@ hb_ot_name_list_names (hb_face_t *face, template <typename in_utf_t, typename out_utf_t> static inline unsigned int -hb_ot_name_convert_utf (const hb_bytes_t *bytes, +hb_ot_name_convert_utf (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; + 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; @@ -129,10 +129,10 @@ hb_ot_name_get_utf (hb_face_t *face, 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); + 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); + return hb_ot_name_convert_utf<hb_ascii_t, utf_t> (bytes, text_size, text); } if (text_size) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.h index 8b831688427..3b4ad581c7e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-name.h @@ -73,7 +73,7 @@ enum HB_OT_NAME_ID_DARK_BACKGROUND = 24, HB_OT_NAME_ID_VARIATIONS_PS_PREFIX = 25, - HB_OT_NAME_ID_INVALID = 0xFFFF, + HB_OT_NAME_ID_INVALID = 0xFFFF }; typedef unsigned int hb_ot_name_id_t; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh index a5a9c07eadb..4c1812c3229 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh @@ -1,5 +1,6 @@ /* * Copyright © 2011,2012 Google, Inc. + * Copyright © 2018 Ebrahim Byagowi * * This is part of HarfBuzz, a text shaping library. * @@ -30,7 +31,7 @@ #include "hb-open-type.hh" #include "hb-ot-os2-unicode-ranges.hh" -namespace OT { +#include "hb-set.hh" /* * OS/2 and Windows Metrics @@ -38,17 +39,113 @@ namespace OT { */ #define HB_OT_TAG_OS2 HB_TAG('O','S','/','2') -struct OS2 + +namespace OT { + +struct OS2V1Tail { - static const hb_tag_t tableTag = HB_OT_TAG_OS2; + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + public: + HBUINT32 ulCodePageRange1; + HBUINT32 ulCodePageRange2; + public: + DEFINE_SIZE_STATIC (8); +}; - inline bool sanitize (hb_sanitize_context_t *c) const +struct OS2V2Tail +{ + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); } - inline bool subset (hb_subset_plan_t *plan) const + public: + HBINT16 sxHeight; + HBINT16 sCapHeight; + HBUINT16 usDefaultChar; + HBUINT16 usBreakChar; + HBUINT16 usMaxContext; + public: + DEFINE_SIZE_STATIC (10); +}; + +struct OS2V5Tail +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + public: + HBUINT16 usLowerOpticalPointSize; + HBUINT16 usUpperOpticalPointSize; + public: + DEFINE_SIZE_STATIC (4); +}; + +struct OS2 +{ + enum { tableTag = HB_OT_TAG_OS2 }; + + bool has_data () const { return this != &Null (OS2); } + + const OS2V1Tail &v1 () const { return version >= 1 ? v1X : Null (OS2V1Tail); } + const OS2V2Tail &v2 () const { return version >= 2 ? v2X : Null (OS2V2Tail); } + const OS2V5Tail &v5 () const { return version >= 5 ? v5X : Null (OS2V5Tail); } + + enum selection_flag_t { + ITALIC = 1u<<0, + UNDERSCORE = 1u<<1, + NEGATIVE = 1u<<2, + OUTLINED = 1u<<3, + STRIKEOUT = 1u<<4, + BOLD = 1u<<5, + REGULAR = 1u<<6, + USE_TYPO_METRICS = 1u<<7, + WWS = 1u<<8, + OBLIQUE = 1u<<9 + }; + + bool is_italic () const { return fsSelection & ITALIC; } + bool is_oblique () const { return fsSelection & OBLIQUE; } + bool is_typo_metrics () const { return fsSelection & USE_TYPO_METRICS; } + + enum width_class_t { + FWIDTH_ULTRA_CONDENSED = 1, /* 50% */ + FWIDTH_EXTRA_CONDENSED = 2, /* 62.5% */ + FWIDTH_CONDENSED = 3, /* 75% */ + FWIDTH_SEMI_CONDENSED = 4, /* 87.5% */ + FWIDTH_NORMAL = 5, /* 100% */ + FWIDTH_SEMI_EXPANDED = 6, /* 112.5% */ + FWIDTH_EXPANDED = 7, /* 125% */ + FWIDTH_EXTRA_EXPANDED = 8, /* 150% */ + FWIDTH_ULTRA_EXPANDED = 9 /* 200% */ + }; + + float get_width () const + { + switch (usWidthClass) { + case FWIDTH_ULTRA_CONDENSED:return 50.f; + case FWIDTH_EXTRA_CONDENSED:return 62.5f; + case FWIDTH_CONDENSED: return 75.f; + case FWIDTH_SEMI_CONDENSED: return 87.5f; + default: + case FWIDTH_NORMAL: return 100.f; + case FWIDTH_SEMI_EXPANDED: return 112.5f; + case FWIDTH_EXPANDED: return 125.f; + case FWIDTH_EXTRA_EXPANDED: return 150.f; + case FWIDTH_ULTRA_EXPANDED: return 200.f; + } + } + + 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_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1); @@ -73,8 +170,8 @@ struct OS2 return result; } - inline void _update_unicode_ranges (const hb_set_t *codepoints, - HBUINT32 ulUnicodeRange[4]) const + void _update_unicode_ranges (const hb_set_t *codepoints, + HBUINT32 ulUnicodeRange[4]) const { for (unsigned int i = 0; i < 4; i++) ulUnicodeRange[i].set (0); @@ -99,7 +196,7 @@ struct OS2 } } - static inline void find_min_and_max_codepoint (const hb_set_t *codepoints, + static void find_min_and_max_codepoint (const hb_set_t *codepoints, uint16_t *min_cp, /* OUT */ uint16_t *max_cp /* OUT */) { @@ -118,17 +215,21 @@ struct OS2 }; // https://github.com/Microsoft/Font-Validator/blob/520aaae/OTFontFileVal/val_OS2.cs#L644-L681 - inline font_page_t get_font_page () const + font_page_t get_font_page () const + { return (font_page_t) (version == 0 ? fsSelection & 0xFF00 : 0); } + + bool sanitize (hb_sanitize_context_t *c) const { - if (version != 0) - return (font_page_t) 0; - return (font_page_t) (fsSelection & 0xFF00); + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) return_trace (false); + if (unlikely (version >= 1 && !v1X.sanitize (c))) return_trace (false); + if (unlikely (version >= 2 && !v2X.sanitize (c))) return_trace (false); + if (unlikely (version >= 5 && !v5X.sanitize (c))) return_trace (false); + return_trace (true); } public: HBUINT16 version; - - /* Version 0 */ HBINT16 xAvgCharWidth; HBUINT16 usWeightClass; HBUINT16 usWidthClass; @@ -155,24 +256,11 @@ struct OS2 HBINT16 sTypoLineGap; HBUINT16 usWinAscent; HBUINT16 usWinDescent; - - /* Version 1 */ - //HBUINT32 ulCodePageRange1; - //HBUINT32 ulCodePageRange2; - - /* Version 2 */ - //HBINT16 sxHeight; - //HBINT16 sCapHeight; - //HBUINT16 usDefaultChar; - //HBUINT16 usBreakChar; - //HBUINT16 usMaxContext; - - /* Version 5 */ - //HBUINT16 usLowerOpticalPointSize; - //HBUINT16 usUpperOpticalPointSize; - + OS2V1Tail v1X; + OS2V2Tail v2X; + OS2V5Tail v5X; public: - DEFINE_SIZE_STATIC (78); + DEFINE_SIZE_MIN (78); }; } /* namespace OT */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh index 98df3e7801c..33b7070ee08 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh @@ -51,7 +51,7 @@ struct postV2Tail { friend struct post; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (glyphNameIndex.sanitize (c)); @@ -71,9 +71,9 @@ struct postV2Tail struct post { - static const hb_tag_t tableTag = HB_OT_TAG_post; + enum { tableTag = HB_OT_TAG_post }; - inline bool subset (hb_subset_plan_t *plan) const + 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); @@ -97,7 +97,7 @@ struct post struct accelerator_t { - inline void init (hb_face_t *face) + void init (hb_face_t *face) { index_to_offset.init (); @@ -107,7 +107,7 @@ struct post version = table->version.to_int (); if (version != 0x00020000) return; - const postV2Tail &v2 = table->v2; + const postV2Tail &v2 = table->v2X; glyphNameIndex = &v2.glyphNameIndex; pool = &StructAfter<uint8_t> (v2.glyphNameIndex); @@ -118,15 +118,15 @@ struct post data += 1 + *data) index_to_offset.push (data - pool); } - inline void fini (void) + void fini () { index_to_offset.fini (); free (gids_sorted_by_name.get ()); table.destroy (); } - inline bool get_glyph_name (hb_codepoint_t glyph, - char *buf, unsigned int buf_len) const + 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; @@ -137,8 +137,8 @@ struct post return true; } - inline bool get_glyph_from_name (const char *name, int len, - hb_codepoint_t *glyph) const + bool get_glyph_from_name (const char *name, int len, + hb_codepoint_t *glyph) const { unsigned int count = get_glyph_count (); if (unlikely (!count)) return false; @@ -168,7 +168,8 @@ struct post } hb_bytes_t st (name, len); - const uint16_t *gid = (const uint16_t *) hb_bsearch_r (&st, gids, count, sizeof (gids[0]), cmp_key, (void *) this); + const uint16_t *gid = (const uint16_t *) hb_bsearch_r (hb_addressof (st), gids, count, + sizeof (gids[0]), cmp_key, (void *) this); if (gid) { *glyph = *gid; @@ -180,7 +181,7 @@ struct post protected: - inline unsigned int get_glyph_count (void) const + unsigned int get_glyph_count () const { if (version == 0x00010000) return NUM_FORMAT1_NAMES; @@ -191,7 +192,7 @@ struct post return 0; } - static inline int cmp_gids (const void *pa, const void *pb, void *arg) + static int cmp_gids (const void *pa, const void *pb, void *arg) { const accelerator_t *thiz = (const accelerator_t *) arg; uint16_t a = * (const uint16_t *) pa; @@ -199,7 +200,7 @@ struct post return thiz->find_glyph_name (b).cmp (thiz->find_glyph_name (a)); } - static inline int cmp_key (const void *pk, const void *po, void *arg) + static int cmp_key (const void *pk, const void *po, void *arg) { const accelerator_t *thiz = (const accelerator_t *) arg; const hb_bytes_t *key = (const hb_bytes_t *) pk; @@ -207,7 +208,7 @@ struct post return thiz->find_glyph_name (o).cmp (*key); } - inline hb_bytes_t find_glyph_name (hb_codepoint_t glyph) const + hb_bytes_t find_glyph_name (hb_codepoint_t glyph) const { if (version == 0x00010000) { @@ -245,12 +246,12 @@ struct post hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name; }; - inline bool sanitize (hb_sanitize_context_t *c) const + 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 () == 0x00020000 && v2X.sanitize (c)) || version.to_int () == 0x00030000))); } @@ -286,7 +287,7 @@ 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; + postV2Tail v2X; DEFINE_SIZE_MIN (32); }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh index 5be6f8d69e9..2a1f2f8458c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-arabic-fallback.hh @@ -79,8 +79,6 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS * May not be good-enough for presidential candidate interviews, but good-enough for us... */ hb_stable_sort (&glyphs[0], num_glyphs, (int(*)(const OT::GlyphID*, const OT::GlyphID *)) OT::GlyphID::cmp, &substitutes[0]); - Supplier<OT::GlyphID> glyphs_supplier (glyphs, num_glyphs); - Supplier<OT::GlyphID> substitutes_supplier (substitutes, num_glyphs); /* Each glyph takes four bytes max, and there's some overhead. */ char buf[(SHAPING_TABLE_LAST - SHAPING_TABLE_FIRST + 1) * 4 + 128]; @@ -88,9 +86,8 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); bool ret = lookup->serialize_single (&c, OT::LookupFlag::IgnoreMarks, - glyphs_supplier, - substitutes_supplier, - num_glyphs); + hb_array (glyphs, num_glyphs), + hb_array (substitutes, num_glyphs)); c.end_serialize (); /* TODO sanitize the results? */ @@ -155,11 +152,6 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN if (!num_ligatures) return nullptr; - Supplier<OT::GlyphID> first_glyphs_supplier (first_glyphs, num_first_glyphs); - Supplier<unsigned int > ligature_per_first_glyph_count_supplier (ligature_per_first_glyph_count_list, num_first_glyphs); - Supplier<OT::GlyphID> ligatures_supplier (ligature_list, num_ligatures); - Supplier<unsigned int > component_count_supplier (component_count_list, num_ligatures); - Supplier<OT::GlyphID> component_supplier (component_list, num_ligatures); /* 16 bytes per ligature ought to be enough... */ char buf[ARRAY_LENGTH_CONST (ligature_list) * 16 + 128]; @@ -167,12 +159,11 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> (); bool ret = lookup->serialize_ligature (&c, OT::LookupFlag::IgnoreMarks, - first_glyphs_supplier, - ligature_per_first_glyph_count_supplier, - num_first_glyphs, - ligatures_supplier, - component_count_supplier, - component_supplier); + hb_array (first_glyphs, num_first_glyphs), + hb_array (ligature_per_first_glyph_count_list, num_first_glyphs), + hb_array (ligature_list, num_ligatures), + hb_array (component_count_list, num_ligatures), + hb_array (component_list, num_ligatures)); c.end_serialize (); /* TODO sanitize the results? */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc index 8933c1822a8..d2d0a5a34a6 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc @@ -226,7 +226,7 @@ override_features_indic (hb_ot_shape_planner_t *plan) struct would_substitute_feature_t { - inline void init (const hb_ot_map_t *map, hb_tag_t feature_tag, bool zero_context_) + void init (const hb_ot_map_t *map, hb_tag_t feature_tag, bool zero_context_) { zero_context = zero_context_; map->get_stage_lookups (0/*GSUB*/, @@ -234,9 +234,9 @@ struct would_substitute_feature_t &lookups, &count); } - inline bool would_substitute (const hb_codepoint_t *glyphs, - unsigned int glyphs_count, - hb_face_t *face) const + bool would_substitute (const hb_codepoint_t *glyphs, + unsigned int glyphs_count, + hb_face_t *face) const { for (unsigned int i = 0; i < count; i++) if (hb_ot_layout_lookup_would_substitute_fast (face, lookups[i].index, glyphs, glyphs_count, zero_context)) @@ -252,7 +252,7 @@ struct would_substitute_feature_t struct indic_shape_plan_t { - inline bool load_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const + bool load_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const { hb_codepoint_t glyph = virama_glyph.get_relaxed (); if (unlikely (glyph == (hb_codepoint_t) -1)) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc index 497891ea045..4475ceb7c91 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-khmer.cc @@ -127,28 +127,31 @@ collect_features_khmer (hb_ot_shape_planner_t *plan) for (; i < KHMER_NUM_FEATURES; i++) map->add_feature (khmer_features[i]); - - map->enable_feature (HB_TAG('c','a','l','t')); - map->enable_feature (HB_TAG('c','l','i','g')); - } static void override_features_khmer (hb_ot_shape_planner_t *plan) { + hb_ot_map_builder_t *map = &plan->map; + + /* Khmer spec has 'clig' as part of required shaping features: + * "Apply feature 'clig' to form ligatures that are desired for + * typographical correctness.", hence in overrides... */ + map->enable_feature (HB_TAG('c','l','i','g')); + /* Uniscribe does not apply 'kern' in Khmer. */ if (hb_options ().uniscribe_bug_compatible) { - plan->map.disable_feature (HB_TAG('k','e','r','n')); + map->disable_feature (HB_TAG('k','e','r','n')); } - plan->map.disable_feature (HB_TAG('l','i','g','a')); + map->disable_feature (HB_TAG('l','i','g','a')); } struct would_substitute_feature_t { - inline void init (const hb_ot_map_t *map, hb_tag_t feature_tag, bool zero_context_) + void init (const hb_ot_map_t *map, hb_tag_t feature_tag, bool zero_context_) { zero_context = zero_context_; map->get_stage_lookups (0/*GSUB*/, @@ -156,9 +159,9 @@ struct would_substitute_feature_t &lookups, &count); } - inline bool would_substitute (const hb_codepoint_t *glyphs, - unsigned int glyphs_count, - hb_face_t *face) const + bool would_substitute (const hb_codepoint_t *glyphs, + unsigned int glyphs_count, + hb_face_t *face) const { for (unsigned int i = 0; i < count; i++) if (hb_ot_layout_lookup_would_substitute_fast (face, lookups[i].index, glyphs, glyphs_count, zero_context)) @@ -174,7 +177,7 @@ struct would_substitute_feature_t struct khmer_shape_plan_t { - inline bool get_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const + bool get_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const { hb_codepoint_t glyph = virama_glyph; if (unlikely (virama_glyph == (hb_codepoint_t) -1)) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc index ef97435782c..6e5ce1523a3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc @@ -189,7 +189,7 @@ hb_ot_shape_plan_t::init0 (hb_face_t *face, } void -hb_ot_shape_plan_t::fini (void) +hb_ot_shape_plan_t::fini () { if (shaper->data_destroy) shaper->data_destroy (const_cast<void *> (data)); @@ -309,9 +309,6 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->enable_feature (HB_TAG ('v','e','r','t'), F_GLOBAL_SEARCH); } - if (planner->shaper->override_features) - planner->shaper->override_features (planner); - for (unsigned int i = 0; i < num_user_features; i++) { const hb_feature_t *feature = &user_features[i]; @@ -330,6 +327,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, aat_map->add_feature (feature->tag, feature->value); } } + + if (planner->shaper->override_features) + planner->shaper->override_features (planner); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh index 6e1478d0085..73a11e1af5b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.hh @@ -37,7 +37,7 @@ struct hb_ot_shape_plan_key_t { unsigned int variations_index[2]; - inline void init (hb_face_t *face, + void init (hb_face_t *face, const int *coords, unsigned int num_coords) { @@ -49,7 +49,7 @@ struct hb_ot_shape_plan_key_t &variations_index[table_index]); } - inline bool equal (const hb_ot_shape_plan_key_t *other) + bool equal (const hb_ot_shape_plan_key_t *other) { return 0 == memcmp (this, other, sizeof (*this)); } @@ -85,7 +85,7 @@ struct hb_ot_shape_plan_t bool apply_morx : 1; bool apply_trak : 1; - inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const + void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { unsigned int table_index; switch (table_tag) { @@ -98,7 +98,7 @@ struct hb_ot_shape_plan_t HB_INTERNAL bool init0 (hb_face_t *face, const hb_shape_plan_key_t *key); - HB_INTERNAL void fini (void); + HB_INTERNAL void fini (); 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; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh index 02c376e5de2..ffab28c8b10 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh @@ -57,28 +57,9 @@ enum // 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 + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -101,7 +82,7 @@ struct AxisValueFormat1 struct AxisValueFormat2 { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -128,7 +109,7 @@ struct AxisValueFormat2 struct AxisValueFormat3 { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -153,7 +134,7 @@ struct AxisValueFormat3 struct AxisValueRecord { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -170,7 +151,7 @@ struct AxisValueRecord struct AxisValueFormat4 { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this))); @@ -194,7 +175,7 @@ struct AxisValueFormat4 struct AxisValue { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (c->check_struct (this))) @@ -223,11 +204,30 @@ struct AxisValue DEFINE_SIZE_UNION (2, format); }; +struct StatAxisRecord +{ + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this))); + } + + protected: + Tag tag; /* A tag identifying the axis of design variation. */ + NameID nameID; /* The name ID for entries in the 'name' table that + * provide a display string for this axis. */ + HBUINT16 ordering; /* 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 STAT { - static const hb_tag_t tableTag = HB_OT_TAG_STAT; + enum { tableTag = HB_OT_TAG_STAT }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-tag.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-tag.cc index a569b8c22a2..d04e5329a04 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-tag.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-tag.cc @@ -503,7 +503,7 @@ hb_ot_tags_to_script_and_language (hb_tag_t script_tag, #ifdef MAIN static inline void -test_langs_sorted (void) +test_langs_sorted () { for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages); i++) { @@ -518,7 +518,7 @@ test_langs_sorted (void) } int -main (void) +main () { test_langs_sorted (); return 0; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-avar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-avar-table.hh index c2b110a2199..67a60f5e0c5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-avar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-avar-table.hh @@ -42,7 +42,7 @@ namespace OT { struct AxisValueMap { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -59,7 +59,7 @@ struct AxisValueMap struct SegmentMaps : ArrayOf<AxisValueMap> { - inline int map (int value) const + int map (int value) const { /* The following special-cases are not part of OpenType, which requires * that at least -1, 0, and +1 must be mapped. But we include these as @@ -99,9 +99,9 @@ struct SegmentMaps : ArrayOf<AxisValueMap> struct avar { - static const hb_tag_t tableTag = HB_OT_TAG_avar; + enum { tableTag = HB_OT_TAG_avar }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); if (unlikely (!(version.sanitize (c) && @@ -121,7 +121,7 @@ struct avar return_trace (true); } - inline void map_coords (int *coords, unsigned int coords_length) const + void map_coords (int *coords, unsigned int coords_length) const { unsigned int count = MIN<unsigned int> (coords_length, axisCount); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh index fed334e8a61..76c9eb2cc44 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-fvar-table.hh @@ -44,10 +44,10 @@ struct InstanceRecord { friend struct fvar; - inline hb_array_t<const Fixed> get_coordinates (unsigned int axis_count) const + 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 + bool sanitize (hb_sanitize_context_t *c, unsigned int axis_count) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -75,7 +75,7 @@ struct AxisRecord AXIS_FLAG_HIDDEN = 0x0001, }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -96,11 +96,11 @@ struct AxisRecord struct fvar { - static const hb_tag_t tableTag = HB_OT_TAG_fvar; + enum { tableTag = HB_OT_TAG_fvar }; - inline bool has_data (void) const { return version.to_int (); } + bool has_data () const { return version.to_int (); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -112,10 +112,9 @@ struct fvar c->check_range (get_instance (0), instanceCount, instanceSize)); } - inline unsigned int get_axis_count (void) const - { return axisCount; } + unsigned int get_axis_count () const { return axisCount; } - inline void get_axis_deprecated (unsigned int axis_index, + void get_axis_deprecated (unsigned int axis_index, hb_ot_var_axis_t *info) const { const AxisRecord &axis = get_axes ()[axis_index]; @@ -127,8 +126,8 @@ struct fvar info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.); } - inline void get_axis_info (unsigned int axis_index, - hb_ot_var_axis_info_t *info) const + 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; @@ -142,9 +141,9 @@ struct fvar 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 + 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) { @@ -164,9 +163,9 @@ struct fvar return axisCount; } - 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 + 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) { @@ -186,9 +185,9 @@ struct fvar return axisCount; } - inline bool find_axis_deprecated (hb_tag_t tag, - unsigned int *axis_index, - hb_ot_var_axis_t *info) const + 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 (); @@ -205,8 +204,8 @@ struct fvar return false; } - inline bool find_axis_info (hb_tag_t tag, - hb_ot_var_axis_info_t *info) const + 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 (); @@ -219,7 +218,7 @@ struct fvar return false; } - inline int normalize_axis_value (unsigned int axis_index, float v) const + int normalize_axis_value (unsigned int axis_index, float v) const { hb_ot_var_axis_info_t axis; get_axis_info (axis_index, &axis); @@ -235,17 +234,16 @@ struct fvar return (int) (v * 16384.f + (v >= 0.f ? .5f : -.5f)); } - inline unsigned int get_instance_count (void) const - { return instanceCount; } + unsigned int get_instance_count () const { return instanceCount; } - inline hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int instance_index) const + 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 + 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; @@ -254,7 +252,7 @@ struct fvar return HB_OT_NAME_ID_INVALID; } - inline unsigned int get_instance_coords (unsigned int instance_index, + unsigned int get_instance_coords (unsigned int instance_index, unsigned int *coords_length, /* IN/OUT */ float *coords /* OUT */) const { @@ -277,10 +275,10 @@ struct fvar } protected: - inline hb_array_t<const AxisRecord> get_axes (void) const + hb_array_t<const AxisRecord> get_axes () const { return hb_array (&(this+firstAxis), axisCount); } - inline const InstanceRecord *get_instance (unsigned int i) const + const InstanceRecord *get_instance (unsigned int i) const { if (unlikely (i >= instanceCount)) return nullptr; return &StructAtOffset<InstanceRecord> (&StructAfter<InstanceRecord> (get_axes ()), diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-hvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-hvar-table.hh index 62a6547b50c..2640f07ee19 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-hvar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-hvar-table.hh @@ -35,7 +35,7 @@ namespace OT { struct DeltaSetIndexMap { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && @@ -73,11 +73,9 @@ struct DeltaSetIndexMap } protected: - inline unsigned int get_width (void) const - { return ((format >> 4) & 3) + 1; } + unsigned int get_width () const { return ((format >> 4) & 3) + 1; } - inline unsigned int get_inner_bitcount (void) const - { return (format & 0xF) + 1; } + unsigned int get_inner_bitcount () const { return (format & 0xF) + 1; } protected: HBUINT16 format; /* A packed field that describes the compressed @@ -102,10 +100,10 @@ struct DeltaSetIndexMap struct HVARVVAR { - static const hb_tag_t HVARTag = HB_OT_TAG_HVAR; - static const hb_tag_t VVARTag = HB_OT_TAG_VVAR; + enum { HVARTag = HB_OT_TAG_HVAR }; + enum { VVARTag = HB_OT_TAG_VVAR }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -116,15 +114,14 @@ struct HVARVVAR rsbMap.sanitize (c, this)); } - inline float get_advance_var (hb_codepoint_t glyph, - const int *coords, unsigned int coord_count) const + float get_advance_var (hb_codepoint_t glyph, + const int *coords, unsigned int coord_count) const { unsigned int varidx = (this+advMap).map (glyph); return (this+varStore).get_delta (varidx, coords, coord_count); } - inline bool has_sidebearing_deltas (void) const - { return lsbMap && rsbMap; } + bool has_sidebearing_deltas () const { return lsbMap && rsbMap; } protected: FixedVersion<>version; /* Version of the metrics variation table @@ -143,12 +140,12 @@ struct HVARVVAR }; struct HVAR : HVARVVAR { - static const hb_tag_t tableTag = HB_OT_TAG_HVAR; + enum { tableTag = HB_OT_TAG_HVAR }; }; struct VVAR : HVARVVAR { - static const hb_tag_t tableTag = HB_OT_TAG_VVAR; + enum { tableTag = HB_OT_TAG_VVAR }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (static_cast<const HVARVVAR *> (this)->sanitize (c) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-mvar-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-mvar-table.hh index b16a09b3d14..a5eeddc5427 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-mvar-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var-mvar-table.hh @@ -35,7 +35,7 @@ namespace OT { struct VariationValueRecord { - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -58,9 +58,9 @@ struct VariationValueRecord struct MVAR { - static const hb_tag_t tableTag = HB_OT_TAG_MVAR; + enum { tableTag = HB_OT_TAG_MVAR }; - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && @@ -73,8 +73,8 @@ struct MVAR valueRecordSize)); } - inline float get_var (hb_tag_t tag, - const int *coords, unsigned int coord_count) const + float get_var (hb_tag_t tag, + const int *coords, unsigned int coord_count) const { const VariationValueRecord *record; record = (VariationValueRecord *) bsearch (&tag, valuesZ.arrayZ, @@ -87,7 +87,7 @@ struct MVAR } protected: - static inline int tag_compare (const void *pa, const void *pb) + static int tag_compare (const void *pa, const void *pb) { const hb_tag_t *a = (const hb_tag_t *) pa; const Tag *b = (const Tag *) pb; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.h index b9d5e408df0..cf6f0c9503f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-var.h @@ -68,7 +68,7 @@ hb_ot_var_get_axis_count (hb_face_t *face); typedef enum { /*< flags >*/ HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x00000001u, - _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/ + _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu /*< skip >*/ } hb_ot_var_axis_flags_t; /** diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-vorg-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-vorg-table.hh index a0480cbcb77..884d04312ff 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-vorg-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-vorg-table.hh @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Adobe Systems Incorporated. + * Copyright © 2018 Adobe Inc. * * This is part of HarfBuzz, a text shaping library. * @@ -39,9 +39,9 @@ namespace OT { struct VertOriginMetric { - inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } + int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this)); @@ -57,11 +57,11 @@ struct VertOriginMetric struct VORG { - static const hb_tag_t tableTag = HB_OT_TAG_VORG; + enum { tableTag = HB_OT_TAG_VORG }; - inline bool has_data (void) const { return version.to_int (); } + bool has_data () const { return version.to_int (); } - inline int get_y_origin (hb_codepoint_t glyph) const + int get_y_origin (hb_codepoint_t glyph) const { unsigned int i; if (!vertYOrigins.bfind (glyph, &i)) @@ -69,11 +69,11 @@ struct VORG 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 + 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); @@ -102,7 +102,7 @@ struct VORG return success; } - inline bool subset (hb_subset_plan_t *plan) const + 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> (); @@ -159,7 +159,7 @@ struct VORG return success; } - inline bool sanitize (hb_sanitize_context_t *c) const + bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot.h index c168175ac35..db784694c6a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot.h @@ -31,6 +31,7 @@ #include "hb.h" #include "hb-ot-color.h" +#include "hb-ot-deprecated.h" #include "hb-ot-font.h" #include "hb-ot-layout.h" #include "hb-ot-math.h" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest.hh index 4e99df0eb55..9f49af17810 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-digest.hh @@ -50,26 +50,23 @@ struct hb_set_digest_lowest_bits_t { enum { mask_bytes = sizeof (mask_t) }; enum { mask_bits = sizeof (mask_t) * 8 }; - static const unsigned int num_bits = 0 - + (mask_bytes >= 1 ? 3 : 0) - + (mask_bytes >= 2 ? 1 : 0) - + (mask_bytes >= 4 ? 1 : 0) - + (mask_bytes >= 8 ? 1 : 0) - + (mask_bytes >= 16? 1 : 0) - + 0; + enum { num_bits = 0 + + (mask_bytes >= 1 ? 3 : 0) + + (mask_bytes >= 2 ? 1 : 0) + + (mask_bytes >= 4 ? 1 : 0) + + (mask_bytes >= 8 ? 1 : 0) + + (mask_bytes >= 16? 1 : 0) + + 0 }; static_assert ((shift < sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), ""); - inline void init (void) { - mask = 0; - } + void init () { mask = 0; } - inline void add (hb_codepoint_t g) { - mask |= mask_for (g); - } + void add (hb_codepoint_t g) { mask |= mask_for (g); } - inline bool add_range (hb_codepoint_t a, hb_codepoint_t b) { + bool add_range (hb_codepoint_t a, hb_codepoint_t b) + { if ((b >> shift) - (a >> shift) >= mask_bits - 1) mask = (mask_t) -1; else { @@ -81,7 +78,7 @@ struct hb_set_digest_lowest_bits_t } template <typename T> - inline void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { for (unsigned int i = 0; i < count; i++) { @@ -90,7 +87,7 @@ struct hb_set_digest_lowest_bits_t } } template <typename T> - inline bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { for (unsigned int i = 0; i < count; i++) { @@ -100,51 +97,53 @@ struct hb_set_digest_lowest_bits_t return true; } - inline bool may_have (hb_codepoint_t g) const { - return !!(mask & mask_for (g)); - } + bool may_have (hb_codepoint_t g) const + { return !!(mask & mask_for (g)); } private: - static inline mask_t mask_for (hb_codepoint_t g) { - return ((mask_t) 1) << ((g >> shift) & (mask_bits - 1)); - } + static mask_t mask_for (hb_codepoint_t g) + { return ((mask_t) 1) << ((g >> shift) & (mask_bits - 1)); } mask_t mask; }; template <typename head_t, typename tail_t> struct hb_set_digest_combiner_t { - inline void init (void) { + void init () + { head.init (); tail.init (); } - inline void add (hb_codepoint_t g) { + void add (hb_codepoint_t g) + { head.add (g); tail.add (g); } - inline bool add_range (hb_codepoint_t a, hb_codepoint_t b) { + bool add_range (hb_codepoint_t a, hb_codepoint_t b) + { head.add_range (a, b); tail.add_range (a, b); return true; } template <typename T> - inline void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { head.add_array (array, count, stride); tail.add_array (array, count, stride); } template <typename T> - inline bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { head.add_sorted_array (array, count, stride); tail.add_sorted_array (array, count, stride); return true; } - inline bool may_have (hb_codepoint_t g) const { + bool may_have (hb_codepoint_t g) const + { return head.may_have (g) && tail.may_have (g); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.cc index 67ec5618028..06823626452 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.cc @@ -47,7 +47,7 @@ * Since: 0.9.2 **/ hb_set_t * -hb_set_create (void) +hb_set_create () { hb_set_t *set; @@ -67,7 +67,7 @@ hb_set_create (void) * Since: 0.9.2 **/ hb_set_t * -hb_set_get_empty (void) +hb_set_get_empty () { return const_cast<hb_set_t *> (&Null(hb_set_t)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh index 8b7a0f3d0c6..19596880e61 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh @@ -40,12 +40,12 @@ struct hb_set_t { HB_NO_COPY_ASSIGN (hb_set_t); - inline hb_set_t (void) { init (); } - inline ~hb_set_t (void) { fini (); } + hb_set_t () { init (); } + ~hb_set_t () { fini (); } struct page_map_t { - inline int cmp (const page_map_t &o) const { return (int) o.major - (int) major; } + int cmp (const page_map_t &o) const { return (int) o.major - (int) major; } uint32_t major; uint32_t index; @@ -53,13 +53,13 @@ struct hb_set_t struct page_t { - inline void init0 (void) { v.clear (); } - inline void init1 (void) { v.clear (0xFF); } + void init0 () { v.clear (); } + void init1 () { v.clear (0xFF); } - inline unsigned int len (void) const + unsigned int len () const { return ARRAY_LENGTH_CONST (v); } - inline bool is_empty (void) const + bool is_empty () const { for (unsigned int i = 0; i < len (); i++) if (v[i]) @@ -67,11 +67,11 @@ struct hb_set_t return true; } - inline void add (hb_codepoint_t g) { elt (g) |= mask (g); } - inline void del (hb_codepoint_t g) { elt (g) &= ~mask (g); } - inline bool has (hb_codepoint_t g) const { return !!(elt (g) & mask (g)); } + void add (hb_codepoint_t g) { elt (g) |= mask (g); } + void del (hb_codepoint_t g) { elt (g) &= ~mask (g); } + bool has (hb_codepoint_t g) const { return !!(elt (g) & mask (g)); } - inline void add_range (hb_codepoint_t a, hb_codepoint_t b) + void add_range (hb_codepoint_t a, hb_codepoint_t b) { elt_t *la = &elt (a); elt_t *lb = &elt (b); @@ -88,12 +88,12 @@ struct hb_set_t } } - inline bool is_equal (const page_t *other) const + bool is_equal (const page_t *other) const { return 0 == hb_memcmp (&v, &other->v, sizeof (v)); } - inline unsigned int get_population (void) const + unsigned int get_population () const { unsigned int pop = 0; for (unsigned int i = 0; i < len (); i++) @@ -101,7 +101,7 @@ struct hb_set_t return pop; } - inline bool next (hb_codepoint_t *codepoint) const + bool next (hb_codepoint_t *codepoint) const { unsigned int m = (*codepoint + 1) & MASK; if (!m) @@ -123,7 +123,7 @@ struct hb_set_t *codepoint = INVALID; return false; } - inline bool previous (hb_codepoint_t *codepoint) const + bool previous (hb_codepoint_t *codepoint) const { unsigned int m = (*codepoint - 1) & MASK; if (m == MASK) @@ -145,14 +145,14 @@ struct hb_set_t *codepoint = INVALID; return false; } - inline hb_codepoint_t get_min (void) const + hb_codepoint_t get_min () const { for (unsigned int i = 0; i < len (); i++) if (v[i]) return i * ELT_BITS + elt_get_min (v[i]); return INVALID; } - inline hb_codepoint_t get_max (void) const + hb_codepoint_t get_max () const { for (int i = len () - 1; i >= 0; i--) if (v[i]) @@ -164,8 +164,8 @@ struct hb_set_t enum { PAGE_BITS = 512 }; static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); - static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } - static inline unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; } + static unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } + static unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; } typedef hb_vector_size_t<elt_t, PAGE_BITS / 8> vector_t; @@ -189,31 +189,33 @@ struct hb_set_t hb_vector_t<page_map_t, 1> page_map; hb_vector_t<page_t, 1> pages; - inline void init_shallow (void) + void init_shallow () { successful = true; population = 0; page_map.init (); pages.init (); } - inline void init (void) + void init () { hb_object_init (this); init_shallow (); } - inline void fini_shallow (void) + void fini_shallow () { population = 0; page_map.fini (); pages.fini (); } - inline void fini (void) + void fini () { hb_object_fini (this); fini_shallow (); } - inline bool resize (unsigned int count) + bool in_error () const { return !successful; } + + bool resize (unsigned int count) { if (unlikely (!successful)) return false; if (!pages.resize (count) || !page_map.resize (count)) @@ -225,7 +227,7 @@ struct hb_set_t return true; } - inline void clear (void) + void clear () { if (unlikely (hb_object_is_immutable (this))) return; @@ -234,7 +236,7 @@ struct hb_set_t page_map.resize (0); pages.resize (0); } - inline bool is_empty (void) const + bool is_empty () const { unsigned int count = pages.len; for (unsigned int i = 0; i < count; i++) @@ -243,9 +245,9 @@ struct hb_set_t return true; } - inline void dirty (void) { population = (unsigned int) -1; } + void dirty () { population = (unsigned int) -1; } - inline void add (hb_codepoint_t g) + void add (hb_codepoint_t g) { if (unlikely (!successful)) return; if (unlikely (g == INVALID)) return; @@ -253,7 +255,7 @@ struct hb_set_t page_t *page = page_for_insert (g); if (unlikely (!page)) return; page->add (g); } - inline bool add_range (hb_codepoint_t a, hb_codepoint_t b) + bool add_range (hb_codepoint_t a, hb_codepoint_t b) { if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */ if (unlikely (a > b || a == INVALID || b == INVALID)) return false; @@ -283,7 +285,7 @@ struct hb_set_t } template <typename T> - inline void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { if (unlikely (!successful)) return; if (!count) return; @@ -309,7 +311,7 @@ struct hb_set_t /* Might return false if array looks unsorted. * Used for faster rejection of corrupt data. */ template <typename T> - inline bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) + bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) { if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */ if (!count) return true; @@ -337,7 +339,7 @@ struct hb_set_t return true; } - inline void del (hb_codepoint_t g) + void del (hb_codepoint_t g) { /* TODO perform op even if !successful. */ if (unlikely (!successful)) return; @@ -347,7 +349,7 @@ struct hb_set_t dirty (); page->del (g); } - inline void del_range (hb_codepoint_t a, hb_codepoint_t b) + void del_range (hb_codepoint_t a, hb_codepoint_t b) { /* TODO perform op even if !successful. */ /* TODO Optimize, like add_range(). */ @@ -355,31 +357,31 @@ struct hb_set_t for (unsigned int i = a; i < b + 1; i++) del (i); } - inline bool has (hb_codepoint_t g) const + bool has (hb_codepoint_t g) const { const page_t *page = page_for (g); if (!page) return false; return page->has (g); } - inline bool intersects (hb_codepoint_t first, + bool intersects (hb_codepoint_t first, hb_codepoint_t last) const { hb_codepoint_t c = first - 1; return next (&c) && c <= last; } - inline void set (const hb_set_t *other) + void set (const hb_set_t *other) { if (unlikely (!successful)) return; unsigned int count = other->pages.len; if (!resize (count)) return; population = other->population; - memcpy (pages, other->pages, count * pages.item_size); - memcpy (page_map, other->page_map, count * page_map.item_size); + memcpy ((void *) pages, (const void *) other->pages, count * pages.item_size); + memcpy ((void *) page_map, (const void *) other->page_map, count * page_map.item_size); } - inline bool is_equal (const hb_set_t *other) const + bool is_equal (const hb_set_t *other) const { if (get_population () != other->get_population ()) return false; @@ -406,7 +408,7 @@ struct hb_set_t return true; } - inline bool is_subset (const hb_set_t *larger_set) const + bool is_subset (const hb_set_t *larger_set) const { if (get_population () > larger_set->get_population ()) return false; @@ -421,7 +423,7 @@ struct hb_set_t } template <class Op> - inline void process (const hb_set_t *other) + void process (const hb_set_t *other) { if (unlikely (!successful)) return; @@ -519,23 +521,23 @@ struct hb_set_t resize (newCount); } - inline void union_ (const hb_set_t *other) + void union_ (const hb_set_t *other) { process<HbOpOr> (other); } - inline void intersect (const hb_set_t *other) + void intersect (const hb_set_t *other) { process<HbOpAnd> (other); } - inline void subtract (const hb_set_t *other) + void subtract (const hb_set_t *other) { process<HbOpMinus> (other); } - inline void symmetric_difference (const hb_set_t *other) + void symmetric_difference (const hb_set_t *other) { process<HbOpXor> (other); } - inline bool next (hb_codepoint_t *codepoint) const + bool next (hb_codepoint_t *codepoint) const { if (unlikely (*codepoint == INVALID)) { *codepoint = get_min (); @@ -566,7 +568,7 @@ struct hb_set_t *codepoint = INVALID; return false; } - inline bool previous (hb_codepoint_t *codepoint) const + bool previous (hb_codepoint_t *codepoint) const { if (unlikely (*codepoint == INVALID)) { *codepoint = get_max (); @@ -597,7 +599,7 @@ struct hb_set_t *codepoint = INVALID; return false; } - inline bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const + bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const { hb_codepoint_t i; @@ -615,7 +617,7 @@ struct hb_set_t return true; } - inline bool previous_range (hb_codepoint_t *first, hb_codepoint_t *last) const + bool previous_range (hb_codepoint_t *first, hb_codepoint_t *last) const { hb_codepoint_t i; @@ -634,7 +636,7 @@ struct hb_set_t return true; } - inline unsigned int get_population (void) const + unsigned int get_population () const { if (population != (unsigned int) -1) return population; @@ -647,7 +649,7 @@ struct hb_set_t population = pop; return pop; } - inline hb_codepoint_t get_min (void) const + hb_codepoint_t get_min () const { unsigned int count = pages.len; for (unsigned int i = 0; i < count; i++) @@ -655,18 +657,18 @@ struct hb_set_t return page_map[i].major * page_t::PAGE_BITS + page_at (i).get_min (); return INVALID; } - inline hb_codepoint_t get_max (void) const + hb_codepoint_t get_max () const { unsigned int count = pages.len; for (int i = count - 1; i >= 0; i++) if (!page_at (i).is_empty ()) - return page_map[i].major * page_t::PAGE_BITS + page_at (i).get_max (); + return page_map[(unsigned) i].major * page_t::PAGE_BITS + page_at (i).get_max (); return INVALID; } static const hb_codepoint_t INVALID = HB_SET_VALUE_INVALID; - inline page_t *page_for_insert (hb_codepoint_t g) + page_t *page_for_insert (hb_codepoint_t g) { page_map_t map = {get_major (g), pages.len}; unsigned int i; @@ -678,12 +680,12 @@ struct hb_set_t pages[map.index].init0 (); memmove (page_map + i + 1, page_map + i, - (page_map.len - 1 - i) * sizeof (page_map[0])); + (page_map.len - 1 - i) * page_map.item_size); page_map[i] = map; } return &pages[page_map[i].index]; } - inline page_t *page_for (hb_codepoint_t g) + page_t *page_for (hb_codepoint_t g) { page_map_t key = {get_major (g)}; const page_map_t *found = page_map.bsearch (key); @@ -691,7 +693,7 @@ struct hb_set_t return &pages[found->index]; return nullptr; } - inline const page_t *page_for (hb_codepoint_t g) const + const page_t *page_for (hb_codepoint_t g) const { page_map_t key = {get_major (g)}; const page_map_t *found = page_map.bsearch (key); @@ -699,10 +701,10 @@ struct hb_set_t return &pages[found->index]; return nullptr; } - inline page_t &page_at (unsigned int i) { return pages[page_map[i].index]; } - inline const page_t &page_at (unsigned int i) const { return pages[page_map[i].index]; } - inline unsigned int get_major (hb_codepoint_t g) const { return g / page_t::PAGE_BITS; } - inline hb_codepoint_t major_start (unsigned int major) const { return major * page_t::PAGE_BITS; } + page_t &page_at (unsigned int i) { return pages[page_map[i].index]; } + const page_t &page_at (unsigned int i) const { return pages[page_map[i].index]; } + unsigned int get_major (hb_codepoint_t g) const { return g / page_t::PAGE_BITS; } + hb_codepoint_t major_start (unsigned int major) const { return major * page_t::PAGE_BITS; } }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc index bc3d81636b9..61ea8d0e522 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.cc @@ -247,7 +247,7 @@ bail: * Since: 0.9.7 **/ hb_shape_plan_t * -hb_shape_plan_get_empty (void) +hb_shape_plan_get_empty () { return const_cast<hb_shape_plan_t *> (&Null(hb_shape_plan_t)); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.hh index d9aa3ee1ab4..3a057fd22d1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape-plan.hh @@ -53,10 +53,7 @@ struct hb_shape_plan_key_t unsigned int num_coords, const char * const *shaper_list); - HB_INTERNAL inline void free (void) - { - ::free ((void *) user_features); - } + HB_INTERNAL inline void free () { ::free ((void *) user_features); } HB_INTERNAL bool user_features_match (const hb_shape_plan_key_t *other); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc index 45f3a6916e2..deff77bedcd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shape.cc @@ -49,7 +49,7 @@ #if HB_USE_ATEXIT -static void free_static_shaper_list (void); +static void free_static_shaper_list (); #endif static const char *nil_shaper_list[] = {nullptr}; @@ -57,7 +57,7 @@ static const char *nil_shaper_list[] = {nullptr}; static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *, hb_shaper_list_lazy_loader_t> { - static inline const char ** create (void) + static const char ** create () { const char **shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *)); if (unlikely (!shaper_list)) @@ -75,19 +75,15 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *, return shaper_list; } - static inline void destroy (const char **l) - { - free (l); - } - static inline const char ** get_null (void) - { - return nil_shaper_list; - } + static void destroy (const char **l) + { free (l); } + static const char ** get_null () + { return nil_shaper_list; } } static_shaper_list; #if HB_USE_ATEXIT static -void free_static_shaper_list (void) +void free_static_shaper_list () { static_shaper_list.free_instance (); } @@ -105,7 +101,7 @@ void free_static_shaper_list (void) * Since: 0.9.2 **/ const char ** -hb_shape_list_shapers (void) +hb_shape_list_shapers () { return static_shaper_list.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh index 1fdb64810b3..36d8fc7f660 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper-list.hh @@ -34,10 +34,6 @@ /* Only picks up fonts that have a "Silf" table. */ HB_SHAPER_IMPLEMENT (graphite2) #endif -#ifdef HAVE_CORETEXT -/* Only picks up fonts that have a "mort" or "morx" table. */ -HB_SHAPER_IMPLEMENT (coretext_aat) -#endif HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */ @@ -49,6 +45,10 @@ HB_SHAPER_IMPLEMENT (directwrite) #endif #ifdef HAVE_CORETEXT HB_SHAPER_IMPLEMENT (coretext) + +/* Only picks up fonts that have a "mort" or "morx" table. + Probably going to be removed https://github.com/harfbuzz/harfbuzz/issues/1478 */ +HB_SHAPER_IMPLEMENT (coretext_aat) #endif #ifdef HAVE_FALLBACK diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.cc index b10927ecfcf..575ab1f7dd7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.cc @@ -36,13 +36,13 @@ static const hb_shaper_entry_t all_shapers[] = { }; #if HB_USE_ATEXIT -static void free_static_shapers (void); +static void free_static_shapers (); #endif 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_entry_t *create (void) + static hb_shaper_entry_t *create () { char *env = getenv ("HB_SHAPER_LIST"); if (!env || !*env) @@ -86,26 +86,20 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t<const hb_shaper_entry_ return shapers; } - static inline void destroy (const hb_shaper_entry_t *p) - { - free ((void *) p); - } - static inline const hb_shaper_entry_t *get_null (void) - { - return all_shapers; - } + static void destroy (const hb_shaper_entry_t *p) { free ((void *) p); } + static const hb_shaper_entry_t *get_null () { return all_shapers; } } static_shapers; #if HB_USE_ATEXIT static -void free_static_shapers (void) +void free_static_shapers () { static_shapers.free_instance (); } #endif const hb_shaper_entry_t * -_hb_shapers_get (void) +_hb_shapers_get () { return static_shapers.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh index 3fda27bc0ec..79dc5d07e09 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-shaper.hh @@ -47,7 +47,7 @@ struct hb_shaper_entry_t { }; HB_INTERNAL const hb_shaper_entry_t * -_hb_shapers_get (void); +_hb_shapers_get (); template <typename Data, unsigned int WheresData, typename T> @@ -96,10 +96,10 @@ template <enum hb_shaper_order_t order, typename Object> struct hb_shaper_object hb_##object##_t, WheresData> \ { \ typedef HB_SHAPER_DATA_TYPE(shaper, object) Type; \ - static inline Type* create (hb_##object##_t *data) \ + static 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 Type *get_null () { return nullptr; } \ + static void destroy (Type *p) { HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (p); } \ }; \ \ static_assert (true, "") /* Require semicolon. */ @@ -108,14 +108,14 @@ template <enum hb_shaper_order_t order, typename Object> struct hb_shaper_object template <typename Object> struct hb_shaper_object_dataset_t { - inline void init0 (Object *parent_data) + 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 } - inline void fini (void) + void fini () { #define HB_SHAPER_IMPLEMENT(shaper) shaper.fini (); #include "hb-shaper-list.hh" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc index a22f729ef6e..4c515886024 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-static.cc @@ -51,7 +51,7 @@ const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF}; unsigned int -hb_face_t::load_num_glyphs (void) const +hb_face_t::load_num_glyphs () const { hb_sanitize_context_t c = hb_sanitize_context_t (); c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */ @@ -65,7 +65,7 @@ hb_face_t::load_num_glyphs (void) const } unsigned int -hb_face_t::load_upem (void) const +hb_face_t::load_upem () const { unsigned int ret = table.head->get_upem (); upem.set_relaxed (ret); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.cc new file mode 100644 index 00000000000..b6127a9aba1 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.cc @@ -0,0 +1,226 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#include "hb-ot-cff-common.hh" +#include "hb-ot-cff2-table.hh" +#include "hb-subset-cff-common.hh" + +/* Disable FDSelect format 0 for compatibility with fonttools which doesn't seem choose it. + * Rarely any/much smaller than format 3 anyway. */ +#define CFF_SERIALIZE_FDSELECT_0 0 + +using namespace CFF; + +/** + * hb_plan_subset_cff_fdselect + * Determine an optimal FDSelect format according to a provided plan. + * + * Return value: FDSelect format, size, and ranges for the most compact subset FDSelect + * along with a font index remapping table + **/ + +bool +hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs, + unsigned int fdCount, + const FDSelect &src, /* IN */ + unsigned int &subset_fd_count /* OUT */, + unsigned int &subset_fdselect_size /* OUT */, + unsigned int &subset_fdselect_format /* OUT */, + hb_vector_t<code_pair> &fdselect_ranges /* OUT */, + Remap &fdmap /* OUT */) +{ + subset_fd_count = 0; + subset_fdselect_size = 0; + subset_fdselect_format = 0; + unsigned int num_ranges = 0; + + unsigned int subset_num_glyphs = glyphs.len; + if (subset_num_glyphs == 0) + return true; + + { + /* use hb_set to determine the subset of font dicts */ + hb_set_t *set = hb_set_create (); + if (set == &Null (hb_set_t)) + return false; + hb_codepoint_t prev_fd = CFF_UNDEF_CODE; + for (hb_codepoint_t i = 0; i < subset_num_glyphs; i++) + { + hb_codepoint_t fd = src.get_fd (glyphs[i]); + set->add (fd); + + if (fd != prev_fd) + { + num_ranges++; + prev_fd = fd; + code_pair pair = { fd, i }; + fdselect_ranges.push (pair); + } + } + + subset_fd_count = set->get_population (); + if (subset_fd_count == fdCount) + { + /* all font dicts belong to the subset. no need to subset FDSelect & FDArray */ + fdmap.identity (fdCount); + hb_set_destroy (set); + } + else + { + /* create a fdmap */ + if (!fdmap.reset (fdCount)) + { + hb_set_destroy (set); + return false; + } + + hb_codepoint_t fd = CFF_UNDEF_CODE; + while (set->next (&fd)) + fdmap.add (fd); + hb_set_destroy (set); + if (unlikely (fdmap.get_count () != subset_fd_count)) + return false; + } + + /* update each font dict index stored as "code" in fdselect_ranges */ + for (unsigned int i = 0; i < fdselect_ranges.len; i++) + fdselect_ranges[i].code = fdmap[fdselect_ranges[i].code]; + } + + /* determine which FDSelect format is most compact */ + if (subset_fd_count > 0xFF) + { + if (unlikely (src.format != 4)) + return false; + subset_fdselect_format = 4; + subset_fdselect_size = FDSelect::min_size + FDSelect4::min_size + FDSelect4_Range::static_size * num_ranges + HBUINT32::static_size; + } + else + { +#if CFF_SERIALIZE_FDSELECT_0 + unsigned int format0_size = FDSelect::min_size + FDSelect0::min_size + HBUINT8::static_size * subset_num_glyphs; +#endif + unsigned int format3_size = FDSelect::min_size + FDSelect3::min_size + FDSelect3_Range::static_size * num_ranges + HBUINT16::static_size; + +#if CFF_SERIALIZE_FDSELECT_0 + if (format0_size <= format3_size) + { + // subset_fdselect_format = 0; + subset_fdselect_size = format0_size; + } + else +#endif + { + subset_fdselect_format = 3; + subset_fdselect_size = format3_size; + } + } + + return true; +} + +template <typename FDSELECT3_4> +static inline bool +serialize_fdselect_3_4 (hb_serialize_context_t *c, + const unsigned int num_glyphs, + const FDSelect &src, + unsigned int size, + const hb_vector_t<code_pair> &fdselect_ranges) +{ + TRACE_SERIALIZE (this); + FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size); + if (unlikely (p == nullptr)) return_trace (false); + p->nRanges.set (fdselect_ranges.len); + for (unsigned int i = 0; i < fdselect_ranges.len; i++) + { + p->ranges[i].first.set (fdselect_ranges[i].glyph); + p->ranges[i].fd.set (fdselect_ranges[i].code); + } + p->sentinel().set (num_glyphs); + return_trace (true); +} + +/** + * hb_serialize_cff_fdselect + * Serialize a subset FDSelect format planned above. + **/ +bool +hb_serialize_cff_fdselect (hb_serialize_context_t *c, + const unsigned int num_glyphs, + const FDSelect &src, + unsigned int fd_count, + unsigned int fdselect_format, + unsigned int size, + const hb_vector_t<code_pair> &fdselect_ranges) +{ + TRACE_SERIALIZE (this); + FDSelect *p = c->allocate_min<FDSelect> (); + if (unlikely (p == nullptr)) return_trace (false); + p->format.set (fdselect_format); + size -= FDSelect::min_size; + + switch (fdselect_format) + { +#if CFF_SERIALIZE_FDSELECT_0 + case 0: + { + FDSelect0 *p = c->allocate_size<FDSelect0> (size); + if (unlikely (p == nullptr)) return_trace (false); + unsigned int range_index = 0; + unsigned int fd = fdselect_ranges[range_index++].code; + for (unsigned int i = 0; i < num_glyphs; i++) + { + if ((range_index < fdselect_ranges.len) && + (i >= fdselect_ranges[range_index].glyph)) + { + fd = fdselect_ranges[range_index++].code; + } + p->fds[i].set (fd); + } + break; + } +#endif /* CFF_SERIALIZE_FDSELECT_0 */ + + case 3: + return serialize_fdselect_3_4<FDSelect3> (c, + num_glyphs, + src, + size, + fdselect_ranges); + + case 4: + return serialize_fdselect_3_4<FDSelect4> (c, + num_glyphs, + src, + size, + fdselect_ranges); + + default: + assert(false); + } + + return_trace (true); +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.hh new file mode 100644 index 00000000000..820a0908509 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff-common.hh @@ -0,0 +1,992 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#ifndef HB_SUBSET_CFF_COMMON_HH +#define HB_SUBSET_CFF_COMMON_HH + +#include "hb.hh" + +#include "hb-subset-plan.hh" +#include "hb-cff-interp-cs-common.hh" + +namespace CFF { + +/* Used for writing a temporary charstring */ +struct StrEncoder +{ + StrEncoder (StrBuff &buff_) + : buff (buff_), error (false) {} + + void reset () { buff.resize (0); } + + void encode_byte (unsigned char b) + { + if (unlikely (buff.push ((const char)b) == &Crap(char))) + set_error (); + } + + void encode_int (int v) + { + if ((-1131 <= v) && (v <= 1131)) + { + if ((-107 <= v) && (v <= 107)) + encode_byte (v + 139); + else if (v > 0) + { + v -= 108; + encode_byte ((v >> 8) + OpCode_TwoBytePosInt0); + encode_byte (v & 0xFF); + } + else + { + v = -v - 108; + encode_byte ((v >> 8) + OpCode_TwoByteNegInt0); + encode_byte (v & 0xFF); + } + } + else + { + if (unlikely (v < -32768)) + v = -32768; + else if (unlikely (v > 32767)) + v = 32767; + encode_byte (OpCode_shortint); + encode_byte ((v >> 8) & 0xFF); + encode_byte (v & 0xFF); + } + } + + void encode_num (const Number& n) + { + if (n.in_int_range ()) + { + encode_int (n.to_int ()); + } + else + { + int32_t v = n.to_fixed (); + encode_byte (OpCode_fixedcs); + encode_byte ((v >> 24) & 0xFF); + encode_byte ((v >> 16) & 0xFF); + encode_byte ((v >> 8) & 0xFF); + encode_byte (v & 0xFF); + } + } + + void encode_op (OpCode op) + { + if (Is_OpCode_ESC (op)) + { + encode_byte (OpCode_escape); + encode_byte (Unmake_OpCode_ESC (op)); + } + else + encode_byte (op); + } + + void copy_str (const ByteStr &str) + { + unsigned int offset = buff.len; + buff.resize (offset + str.len); + if (unlikely (buff.len < offset + str.len)) + { + set_error (); + return; + } + memcpy (&buff[offset], &str.str[0], str.len); + } + + bool is_error () const { return error; } + + protected: + void set_error () { error = true; } + + StrBuff &buff; + bool error; +}; + +struct CFFSubTableOffsets { + CFFSubTableOffsets () : privateDictsOffset (0) + { + topDictInfo.init (); + FDSelectInfo.init (); + FDArrayInfo.init (); + charStringsInfo.init (); + globalSubrsInfo.init (); + localSubrsInfos.init (); + } + + ~CFFSubTableOffsets () { localSubrsInfos.fini (); } + + TableInfo topDictInfo; + TableInfo FDSelectInfo; + TableInfo FDArrayInfo; + TableInfo charStringsInfo; + unsigned int privateDictsOffset; + TableInfo globalSubrsInfo; + hb_vector_t<TableInfo> localSubrsInfos; +}; + +template <typename OPSTR=OpStr> +struct CFFTopDict_OpSerializer : OpSerializer +{ + bool serialize (hb_serialize_context_t *c, + const OPSTR &opstr, + const CFFSubTableOffsets &offsets) const + { + TRACE_SERIALIZE (this); + + switch (opstr.op) + { + case OpCode_CharStrings: + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.charStringsInfo.offset)); + + case OpCode_FDArray: + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDArrayInfo.offset)); + + case OpCode_FDSelect: + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDSelectInfo.offset)); + + default: + return_trace (copy_opstr (c, opstr)); + } + return_trace (true); + } + + unsigned int calculate_serialized_size (const OPSTR &opstr) const + { + switch (opstr.op) + { + case OpCode_CharStrings: + case OpCode_FDArray: + case OpCode_FDSelect: + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + + default: + return opstr.str.len; + } + } +}; + +struct CFFFontDict_OpSerializer : OpSerializer +{ + bool serialize (hb_serialize_context_t *c, + const OpStr &opstr, + const TableInfo &privateDictInfo) const + { + TRACE_SERIALIZE (this); + + if (opstr.op == OpCode_Private) + { + /* serialize the private dict size & offset as 2-byte & 4-byte integers */ + if (unlikely (!UnsizedByteStr::serialize_int2 (c, privateDictInfo.size) || + !UnsizedByteStr::serialize_int4 (c, privateDictInfo.offset))) + return_trace (false); + + /* serialize the opcode */ + HBUINT8 *p = c->allocate_size<HBUINT8> (1); + if (unlikely (p == nullptr)) return_trace (false); + p->set (OpCode_Private); + + return_trace (true); + } + else + { + HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len); + if (unlikely (d == nullptr)) return_trace (false); + memcpy (d, &opstr.str.str[0], opstr.str.len); + } + return_trace (true); + } + + unsigned int calculate_serialized_size (const OpStr &opstr) const + { + if (opstr.op == OpCode_Private) + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private); + else + return opstr.str.len; + } +}; + +struct CFFPrivateDict_OpSerializer : OpSerializer +{ + CFFPrivateDict_OpSerializer (bool desubroutinize_, bool drop_hints_) + : desubroutinize (desubroutinize_), drop_hints (drop_hints_) {} + + bool serialize (hb_serialize_context_t *c, + const OpStr &opstr, + const unsigned int subrsOffset) const + { + TRACE_SERIALIZE (this); + + if (drop_hints && DictOpSet::is_hint_op (opstr.op)) + return true; + if (opstr.op == OpCode_Subrs) + { + if (desubroutinize || (subrsOffset == 0)) + return_trace (true); + else + return_trace (FontDict::serialize_offset2_op (c, opstr.op, subrsOffset)); + } + else + return_trace (copy_opstr (c, opstr)); + } + + unsigned int calculate_serialized_size (const OpStr &opstr, + bool has_localsubr=true) const + { + if (drop_hints && DictOpSet::is_hint_op (opstr.op)) + return 0; + if (opstr.op == OpCode_Subrs) + { + if (desubroutinize || !has_localsubr) + return 0; + else + return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op); + } + else + return opstr.str.len; + } + + protected: + const bool desubroutinize; + const bool drop_hints; +}; + +struct FlattenParam +{ + StrBuff &flatStr; + bool drop_hints; +}; + +template <typename ACC, typename ENV, typename OPSET> +struct SubrFlattener +{ + SubrFlattener (const ACC &acc_, + const hb_vector_t<hb_codepoint_t> &glyphs_, + bool drop_hints_) + : acc (acc_), + glyphs (glyphs_), + drop_hints (drop_hints_) + {} + + bool flatten (StrBuffArray &flat_charstrings) + { + if (!flat_charstrings.resize (glyphs.len)) + return false; + for (unsigned int i = 0; i < glyphs.len; i++) + flat_charstrings[i].init (); + for (unsigned int i = 0; i < glyphs.len; i++) + { + hb_codepoint_t glyph = glyphs[i]; + const ByteStr str = (*acc.charStrings)[glyph]; + unsigned int fd = acc.fdSelect->get_fd (glyph); + if (unlikely (fd >= acc.fdCount)) + return false; + CSInterpreter<ENV, OPSET, FlattenParam> interp; + interp.env.init (str, acc, fd); + FlattenParam param = { flat_charstrings[i], drop_hints }; + if (unlikely (!interp.interpret (param))) + return false; + } + return true; + } + + const ACC &acc; + const hb_vector_t<hb_codepoint_t> &glyphs; + bool drop_hints; +}; + +struct SubrClosures +{ + SubrClosures () : valid (false), global_closure (nullptr) + { local_closures.init (); } + + void init (unsigned int fd_count) + { + valid = true; + global_closure = hb_set_create (); + if (global_closure == hb_set_get_empty ()) + valid = false; + if (!local_closures.resize (fd_count)) + valid = false; + + for (unsigned int i = 0; i < local_closures.len; i++) + { + local_closures[i] = hb_set_create (); + if (local_closures[i] == hb_set_get_empty ()) + valid = false; + } + } + + void fini () + { + hb_set_destroy (global_closure); + for (unsigned int i = 0; i < local_closures.len; i++) + hb_set_destroy (local_closures[i]); + local_closures.fini (); + } + + void reset () + { + hb_set_clear (global_closure); + for (unsigned int i = 0; i < local_closures.len; i++) + hb_set_clear (local_closures[i]); + } + + bool is_valid () const { return valid; } + bool valid; + hb_set_t *global_closure; + hb_vector_t<hb_set_t *> local_closures; +}; + +struct ParsedCSOp : OpStr +{ + void init (unsigned int subr_num_ = 0) + { + OpStr::init (); + subr_num = subr_num_; + drop_flag = false; + keep_flag = false; + skip_flag = false; + } + + void fini () { OpStr::fini (); } + + bool for_drop () const { return drop_flag; } + void set_drop () { if (!for_keep ()) drop_flag = true; } + + bool for_keep () const { return keep_flag; } + void set_keep () { keep_flag = true; } + + bool for_skip () const { return skip_flag; } + void set_skip () { skip_flag = true; } + + unsigned int subr_num; + + protected: + bool drop_flag : 1; + bool keep_flag : 1; + bool skip_flag : 1; +}; + +struct ParsedCStr : ParsedValues<ParsedCSOp> +{ + void init () + { + SUPER::init (); + parsed = false; + hint_dropped = false; + has_prefix_ = false; + } + + void add_op (OpCode op, const SubByteStr& substr) + { + if (!is_parsed ()) + SUPER::add_op (op, substr); + } + + void add_call_op (OpCode op, const SubByteStr& substr, unsigned int subr_num) + { + if (!is_parsed ()) + { + unsigned int parsed_len = get_count (); + if (likely (parsed_len > 0)) + values[parsed_len-1].set_skip (); + + ParsedCSOp val; + val.init (subr_num); + SUPER::add_op (op, substr, val); + } + } + + void set_prefix (const Number &num, OpCode op = OpCode_Invalid) + { + has_prefix_ = true; + prefix_op_ = op; + prefix_num_ = num; + } + + bool at_end (unsigned int pos) const + { + return ((pos + 1 >= values.len) /* CFF2 */ + || (values[pos + 1].op == OpCode_return)); + } + + bool is_parsed () const { return parsed; } + void set_parsed () { parsed = true; } + + bool is_hint_dropped () const { return hint_dropped; } + void set_hint_dropped () { hint_dropped = true; } + + bool is_vsindex_dropped () const { return vsindex_dropped; } + void set_vsindex_dropped () { vsindex_dropped = true; } + + bool has_prefix () const { return has_prefix_; } + OpCode prefix_op () const { return prefix_op_; } + const Number &prefix_num () const { return prefix_num_; } + + protected: + bool parsed; + bool hint_dropped; + bool vsindex_dropped; + bool has_prefix_; + OpCode prefix_op_; + Number prefix_num_; + + private: + typedef ParsedValues<ParsedCSOp> SUPER; +}; + +struct ParsedCStrs : hb_vector_t<ParsedCStr> +{ + void init (unsigned int len_ = 0) + { + SUPER::init (); + resize (len_); + for (unsigned int i = 0; i < len; i++) + (*this)[i].init (); + } + void fini () { SUPER::fini_deep (); } + + private: + typedef hb_vector_t<ParsedCStr> SUPER; +}; + +struct SubrSubsetParam +{ + void init (ParsedCStr *parsed_charstring_, + ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_, + hb_set_t *global_closure_, hb_set_t *local_closure_, + bool drop_hints_) + { + parsed_charstring = parsed_charstring_; + current_parsed_str = parsed_charstring; + parsed_global_subrs = parsed_global_subrs_; + parsed_local_subrs = parsed_local_subrs_; + global_closure = global_closure_; + local_closure = local_closure_; + drop_hints = drop_hints_; + } + + ParsedCStr *get_parsed_str_for_context (CallContext &context) + { + switch (context.type) + { + case CSType_CharString: + return parsed_charstring; + + case CSType_LocalSubr: + if (likely (context.subr_num < parsed_local_subrs->len)) + return &(*parsed_local_subrs)[context.subr_num]; + break; + + case CSType_GlobalSubr: + if (likely (context.subr_num < parsed_global_subrs->len)) + return &(*parsed_global_subrs)[context.subr_num]; + break; + } + return nullptr; + } + + template <typename ENV> + void set_current_str (ENV &env, bool calling) + { + ParsedCStr *parsed_str = get_parsed_str_for_context (env.context); + if (likely (parsed_str != nullptr)) + { + /* If the called subroutine is parsed partially but not completely yet, + * it must be because we are calling it recursively. + * Handle it as an error. */ + if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.len > 0))) + env.set_error (); + else + current_parsed_str = parsed_str; + } + else + env.set_error (); + } + + ParsedCStr *current_parsed_str; + + ParsedCStr *parsed_charstring; + ParsedCStrs *parsed_global_subrs; + ParsedCStrs *parsed_local_subrs; + hb_set_t *global_closure; + hb_set_t *local_closure; + bool drop_hints; +}; + +struct SubrRemap : Remap +{ + void create (hb_set_t *closure) + { + /* create a remapping of subroutine numbers from old to new. + * no optimization based on usage counts. fonttools doesn't appear doing that either. + */ + reset (closure->get_max () + 1); + for (hb_codepoint_t old_num = 0; old_num < len; old_num++) + { + if (hb_set_has (closure, old_num)) + add (old_num); + } + + if (get_count () < 1240) + bias = 107; + else if (get_count () < 33900) + bias = 1131; + else + bias = 32768; + } + + hb_codepoint_t operator[] (unsigned int old_num) const + { + if (old_num >= len) + return CFF_UNDEF_CODE; + else + return Remap::operator[] (old_num); + } + + int biased_num (unsigned int old_num) const + { + hb_codepoint_t new_num = (*this)[old_num]; + return (int)new_num - bias; + } + + protected: + int bias; +}; + +struct SubrRemaps +{ + SubrRemaps () + { + global_remap.init (); + local_remaps.init (); + } + + ~SubrRemaps () { fini (); } + + void init (unsigned int fdCount) + { + local_remaps.resize (fdCount); + for (unsigned int i = 0; i < fdCount; i++) + local_remaps[i].init (); + } + + void create (SubrClosures& closures) + { + global_remap.create (closures.global_closure); + for (unsigned int i = 0; i < local_remaps.len; i++) + local_remaps[i].create (closures.local_closures[i]); + } + + void fini () + { + global_remap.fini (); + local_remaps.fini_deep (); + } + + SubrRemap global_remap; + hb_vector_t<SubrRemap> local_remaps; +}; + +template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typename OPSET> +struct SubrSubsetter +{ + SubrSubsetter () + { + parsed_charstrings.init (); + parsed_global_subrs.init (); + parsed_local_subrs.init (); + } + + ~SubrSubsetter () + { + closures.fini (); + remaps.fini (); + parsed_charstrings.fini_deep (); + parsed_global_subrs.fini_deep (); + parsed_local_subrs.fini_deep (); + } + + /* Subroutine subsetting with --no-desubroutinize runs in phases: + * + * 1. execute charstrings/subroutines to determine subroutine closures + * 2. parse out all operators and numbers + * 3. mark hint operators and operands for removal if --no-hinting + * 4. re-encode all charstrings and subroutines with new subroutine numbers + * + * Phases #1 and #2 are done at the same time in collect_subrs (). + * Phase #3 walks charstrings/subroutines forward then backward (hence parsing required), + * because we can't tell if a number belongs to a hint op until we see the first moveto. + * + * Assumption: a callsubr/callgsubr operator must immediately follow a (biased) subroutine number + * within the same charstring/subroutine, e.g., not split across a charstring and a subroutine. + */ + bool subset (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, bool drop_hints) + { + closures.init (acc.fdCount); + remaps.init (acc.fdCount); + + parsed_charstrings.init (glyphs.len); + parsed_global_subrs.init (acc.globalSubrs->count); + parsed_local_subrs.resize (acc.fdCount); + for (unsigned int i = 0; i < acc.fdCount; i++) + { + parsed_local_subrs[i].init (acc.privateDicts[i].localSubrs->count); + } + if (unlikely (!closures.valid)) + return false; + + /* phase 1 & 2 */ + for (unsigned int i = 0; i < glyphs.len; i++) + { + hb_codepoint_t glyph = glyphs[i]; + const ByteStr str = (*acc.charStrings)[glyph]; + unsigned int fd = acc.fdSelect->get_fd (glyph); + if (unlikely (fd >= acc.fdCount)) + return false; + + CSInterpreter<ENV, OPSET, SubrSubsetParam> interp; + interp.env.init (str, acc, fd); + + SubrSubsetParam param; + param.init (&parsed_charstrings[i], + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); + + if (unlikely (!interp.interpret (param))) + return false; + + /* finalize parsed string esp. copy CFF1 width or CFF2 vsindex to the parsed charstring for encoding */ + SUBSETTER::finalize_parsed_str (interp.env, param, parsed_charstrings[i]); + } + + if (drop_hints) + { + /* mark hint ops and arguments for drop */ + for (unsigned int i = 0; i < glyphs.len; i++) + { + unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); + if (unlikely (fd >= acc.fdCount)) + return false; + SubrSubsetParam param; + param.init (&parsed_charstrings[i], + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); + + DropHintsParam drop; + if (drop_hints_in_str (parsed_charstrings[i], param, drop)) + { + parsed_charstrings[i].set_hint_dropped (); + if (drop.vsindex_dropped) + parsed_charstrings[i].set_vsindex_dropped (); + } + } + + /* after dropping hints recreate closures of actually used subrs */ + closures.reset (); + for (unsigned int i = 0; i < glyphs.len; i++) + { + unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); + if (unlikely (fd >= acc.fdCount)) + return false; + SubrSubsetParam param; + param.init (&parsed_charstrings[i], + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); + collect_subr_refs_in_str (parsed_charstrings[i], param); + } + } + + remaps.create (closures); + + return true; + } + + bool encode_charstrings (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, StrBuffArray &buffArray) const + { + if (unlikely (!buffArray.resize (glyphs.len))) + return false; + for (unsigned int i = 0; i < glyphs.len; i++) + { + unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); + if (unlikely (fd >= acc.fdCount)) + return false; + if (unlikely (!encode_str (parsed_charstrings[i], fd, buffArray[i]))) + return false; + } + return true; + } + + bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const + { + unsigned int count = remap.get_count (); + + if (unlikely (!buffArray.resize (count))) + return false; + for (unsigned int old_num = 0; old_num < subrs.len; old_num++) + { + hb_codepoint_t new_num = remap[old_num]; + if (new_num != CFF_UNDEF_CODE) + { + if (unlikely (!encode_str (subrs[old_num], fd, buffArray[new_num]))) + return false; + } + } + return true; + } + + bool encode_globalsubrs (StrBuffArray &buffArray) + { + return encode_subrs (parsed_global_subrs, remaps.global_remap, 0, buffArray); + } + + bool encode_localsubrs (unsigned int fd, StrBuffArray &buffArray) const + { + return encode_subrs (parsed_local_subrs[fd], remaps.local_remaps[fd], fd, buffArray); + } + + protected: + struct DropHintsParam + { + DropHintsParam () + : seen_moveto (false), + ends_in_hint (false), + vsindex_dropped (false) {} + + bool seen_moveto; + bool ends_in_hint; + bool vsindex_dropped; + }; + + bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos, + ParsedCStrs &subrs, unsigned int subr_num, + const SubrSubsetParam ¶m, DropHintsParam &drop) + { + drop.ends_in_hint = false; + bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop); + + /* if this subr ends with a stem hint (i.e., not a number a potential argument for moveto), + * then this entire subroutine must be a hint. drop its call. */ + if (drop.ends_in_hint) + { + str.values[pos].set_drop (); + /* if this subr call is at the end of the parent subr, propagate the flag + * otherwise reset the flag */ + if (!str.at_end (pos)) + drop.ends_in_hint = false; + } + + return has_hint; + } + + /* returns true if it sees a hint op before the first moveto */ + bool drop_hints_in_str (ParsedCStr &str, const SubrSubsetParam ¶m, DropHintsParam &drop) + { + bool seen_hint = false; + + for (unsigned int pos = 0; pos < str.values.len; pos++) + { + bool has_hint = false; + switch (str.values[pos].op) + { + case OpCode_callsubr: + has_hint = drop_hints_in_subr (str, pos, + *param.parsed_local_subrs, str.values[pos].subr_num, + param, drop); + + break; + + case OpCode_callgsubr: + has_hint = drop_hints_in_subr (str, pos, + *param.parsed_global_subrs, str.values[pos].subr_num, + param, drop); + break; + + case OpCode_rmoveto: + case OpCode_hmoveto: + case OpCode_vmoveto: + drop.seen_moveto = true; + break; + + case OpCode_hintmask: + case OpCode_cntrmask: + if (drop.seen_moveto) + { + str.values[pos].set_drop (); + break; + } + HB_FALLTHROUGH; + + case OpCode_hstemhm: + case OpCode_vstemhm: + case OpCode_hstem: + case OpCode_vstem: + has_hint = true; + str.values[pos].set_drop (); + if (str.at_end (pos)) + drop.ends_in_hint = true; + break; + + case OpCode_dotsection: + str.values[pos].set_drop (); + break; + + default: + /* NONE */ + break; + } + if (has_hint) + { + for (int i = pos - 1; i >= 0; i--) + { + ParsedCSOp &csop = str.values[(unsigned)i]; + if (csop.for_drop ()) + break; + csop.set_drop (); + if (csop.op == OpCode_vsindexcs) + drop.vsindex_dropped = true; + } + seen_hint |= has_hint; + } + } + + return seen_hint; + } + + void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos, + unsigned int subr_num, ParsedCStrs &subrs, + hb_set_t *closure, + const SubrSubsetParam ¶m) + { + hb_set_add (closure, subr_num); + collect_subr_refs_in_str (subrs[subr_num], param); + } + + void collect_subr_refs_in_str (ParsedCStr &str, const SubrSubsetParam ¶m) + { + for (unsigned int pos = 0; pos < str.values.len; pos++) + { + if (!str.values[pos].for_drop ()) + { + switch (str.values[pos].op) + { + case OpCode_callsubr: + collect_subr_refs_in_subr (str, pos, + str.values[pos].subr_num, *param.parsed_local_subrs, + param.local_closure, param); + break; + + case OpCode_callgsubr: + collect_subr_refs_in_subr (str, pos, + str.values[pos].subr_num, *param.parsed_global_subrs, + param.global_closure, param); + break; + + default: break; + } + } + } + } + + bool encode_str (const ParsedCStr &str, const unsigned int fd, StrBuff &buff) const + { + buff.init (); + StrEncoder encoder (buff); + encoder.reset (); + /* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints, + * re-insert it at the beginning of charstreing */ + if (str.has_prefix () && str.is_hint_dropped ()) + { + encoder.encode_num (str.prefix_num ()); + if (str.prefix_op () != OpCode_Invalid) + encoder.encode_op (str.prefix_op ()); + } + for (unsigned int i = 0; i < str.get_count(); i++) + { + const ParsedCSOp &opstr = str.values[i]; + if (!opstr.for_drop () && !opstr.for_skip ()) + { + switch (opstr.op) + { + case OpCode_callsubr: + encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num)); + encoder.encode_op (OpCode_callsubr); + break; + + case OpCode_callgsubr: + encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num)); + encoder.encode_op (OpCode_callgsubr); + break; + + default: + encoder.copy_str (opstr.str); + break; + } + } + } + return !encoder.is_error (); + } + + protected: + SubrClosures closures; + + ParsedCStrs parsed_charstrings; + ParsedCStrs parsed_global_subrs; + hb_vector_t<ParsedCStrs> parsed_local_subrs; + + SubrRemaps remaps; + + private: + typedef typename SUBRS::count_type subr_count_type; +}; +}; /* namespace CFF */ + +HB_INTERNAL bool +hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs, + unsigned int fdCount, + const CFF::FDSelect &src, /* IN */ + unsigned int &subset_fd_count /* OUT */, + unsigned int &subset_fdselect_size /* OUT */, + unsigned int &subset_fdselect_format /* OUT */, + hb_vector_t<CFF::code_pair> &fdselect_ranges /* OUT */, + CFF::Remap &fdmap /* OUT */); + +HB_INTERNAL bool +hb_serialize_cff_fdselect (hb_serialize_context_t *c, + unsigned int num_glyphs, + const CFF::FDSelect &src, + unsigned int fd_count, + unsigned int fdselect_format, + unsigned int size, + const hb_vector_t<CFF::code_pair> &fdselect_ranges); + +#endif /* HB_SUBSET_CFF_COMMON_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc new file mode 100644 index 00000000000..09364a22cea --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc @@ -0,0 +1,1108 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#include "hb-open-type.hh" +#include "hb-ot-cff1-table.hh" +#include "hb-set.h" +#include "hb-subset-cff1.hh" +#include "hb-subset-plan.hh" +#include "hb-subset-cff-common.hh" +#include "hb-cff1-interp-cs.hh" + +using namespace CFF; + +struct RemapSID : Remap +{ + unsigned int add (unsigned int sid) + { + if ((sid != CFF_UNDEF_SID) && !is_std_std (sid)) + return offset_sid (Remap::add (unoffset_sid (sid))); + else + return sid; + } + + unsigned int operator[] (unsigned int sid) const + { + if (is_std_std (sid) || (sid == CFF_UNDEF_SID)) + return sid; + else + return offset_sid (Remap::operator [] (unoffset_sid (sid))); + } + + static const unsigned int num_std_strings = 391; + + static bool is_std_std (unsigned int sid) { return sid < num_std_strings; } + static unsigned int offset_sid (unsigned int sid) { return sid + num_std_strings; } + static unsigned int unoffset_sid (unsigned int sid) { return sid - num_std_strings; } +}; + +struct CFF1SubTableOffsets : CFFSubTableOffsets +{ + CFF1SubTableOffsets () + : CFFSubTableOffsets (), + nameIndexOffset (0), + encodingOffset (0) + { + stringIndexInfo.init (); + charsetInfo.init (); + privateDictInfo.init (); + } + + unsigned int nameIndexOffset; + TableInfo stringIndexInfo; + unsigned int encodingOffset; + TableInfo charsetInfo; + TableInfo privateDictInfo; +}; + +/* a copy of a parsed out CFF1TopDictValues augmented with additional operators */ +struct CFF1TopDictValuesMod : CFF1TopDictValues +{ + void init (const CFF1TopDictValues *base_= &Null(CFF1TopDictValues)) + { + SUPER::init (); + base = base_; + } + + void fini () { SUPER::fini (); } + + unsigned get_count () const { return base->get_count () + SUPER::get_count (); } + const CFF1TopDictVal &get_value (unsigned int i) const + { + if (i < base->get_count ()) + return (*base)[i]; + else + return SUPER::values[i - base->get_count ()]; + } + const CFF1TopDictVal &operator [] (unsigned int i) const { return get_value (i); } + + void reassignSIDs (const RemapSID& sidmap) + { + for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + nameSIDs[i] = sidmap[base->nameSIDs[i]]; + } + + protected: + typedef CFF1TopDictValues SUPER; + const CFF1TopDictValues *base; +}; + +struct TopDictModifiers +{ + TopDictModifiers (const CFF1SubTableOffsets &offsets_, + const unsigned int (&nameSIDs_)[NameDictValues::ValCount]) + : offsets (offsets_), + nameSIDs (nameSIDs_) + {} + + const CFF1SubTableOffsets &offsets; + const unsigned int (&nameSIDs)[NameDictValues::ValCount]; +}; + +struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal> +{ + bool serialize (hb_serialize_context_t *c, + const CFF1TopDictVal &opstr, + const TopDictModifiers &mod) const + { + TRACE_SERIALIZE (this); + + OpCode op = opstr.op; + switch (op) + { + case OpCode_charset: + return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.charsetInfo.offset)); + + case OpCode_Encoding: + return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.encodingOffset)); + + case OpCode_Private: + { + if (unlikely (!UnsizedByteStr::serialize_int2 (c, mod.offsets.privateDictInfo.size))) + return_trace (false); + if (unlikely (!UnsizedByteStr::serialize_int4 (c, mod.offsets.privateDictInfo.offset))) + return_trace (false); + HBUINT8 *p = c->allocate_size<HBUINT8> (1); + if (unlikely (p == nullptr)) return_trace (false); + p->set (OpCode_Private); + } + break; + + case OpCode_version: + case OpCode_Notice: + case OpCode_Copyright: + case OpCode_FullName: + case OpCode_FamilyName: + case OpCode_Weight: + case OpCode_PostScript: + case OpCode_BaseFontName: + case OpCode_FontName: + return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[NameDictValues::name_op_to_index (op)])); + + case OpCode_ROS: + { + /* for registry & ordering, reassigned SIDs are serialized + * for supplement, the original byte string is copied along with the op code */ + OpStr supp_op; + supp_op.op = op; + supp_op.str.str = opstr.str.str + opstr.last_arg_offset; + if ( unlikely (!(opstr.str.len >= opstr.last_arg_offset + 3))) + return_trace (false); + supp_op.str.len = opstr.str.len - opstr.last_arg_offset; + return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::registry]) && + UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) && + copy_opstr (c, supp_op)); + } + default: + return_trace (CFFTopDict_OpSerializer<CFF1TopDictVal>::serialize (c, opstr, mod.offsets)); + } + return_trace (true); + } + + unsigned int calculate_serialized_size (const CFF1TopDictVal &opstr) const + { + OpCode op = opstr.op; + switch (op) + { + case OpCode_charset: + case OpCode_Encoding: + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); + + case OpCode_Private: + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private); + + case OpCode_version: + case OpCode_Notice: + case OpCode_Copyright: + case OpCode_FullName: + case OpCode_FamilyName: + case OpCode_Weight: + case OpCode_PostScript: + case OpCode_BaseFontName: + case OpCode_FontName: + return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op); + + case OpCode_ROS: + return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.len - opstr.last_arg_offset)/* supplement + op */; + + default: + return CFFTopDict_OpSerializer<CFF1TopDictVal>::calculate_serialized_size (opstr); + } + } +}; + +struct FontDictValuesMod +{ + void init (const CFF1FontDictValues *base_, + unsigned int fontName_, + const TableInfo &privateDictInfo_) + { + base = base_; + fontName = fontName_; + privateDictInfo = privateDictInfo_; + } + + unsigned get_count () const { return base->get_count (); } + + const OpStr &operator [] (unsigned int i) const { return (*base)[i]; } + + const CFF1FontDictValues *base; + TableInfo privateDictInfo; + unsigned int fontName; +}; + +struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer +{ + bool serialize (hb_serialize_context_t *c, + const OpStr &opstr, + const FontDictValuesMod &mod) const + { + TRACE_SERIALIZE (this); + + if (opstr.op == OpCode_FontName) + return_trace (FontDict::serialize_uint2_op (c, opstr.op, mod.fontName)); + else + return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo)); + } + + unsigned int calculate_serialized_size (const OpStr &opstr) const + { + if (opstr.op == OpCode_FontName) + return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName); + else + return SUPER::calculate_serialized_size (opstr); + } + + private: + typedef CFFFontDict_OpSerializer SUPER; +}; + +struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> +{ + static void flush_args_and_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param) + { + if (env.arg_start > 0) + flush_width (env, param); + + switch (op) + { + case OpCode_hstem: + case OpCode_hstemhm: + case OpCode_vstem: + case OpCode_vstemhm: + case OpCode_hintmask: + case OpCode_cntrmask: + case OpCode_dotsection: + if (param.drop_hints) + { + env.clear_args (); + return; + } + HB_FALLTHROUGH; + + default: + SUPER::flush_args_and_op (op, env, param); + break; + } + } + static void flush_args (CFF1CSInterpEnv &env, FlattenParam& param) + { + StrEncoder encoder (param.flatStr); + for (unsigned int i = env.arg_start; i < env.argStack.get_count (); i++) + encoder.encode_num (env.eval_arg (i)); + SUPER::flush_args (env, param); + } + + static void flush_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param) + { + StrEncoder encoder (param.flatStr); + encoder.encode_op (op); + } + + static void flush_width (CFF1CSInterpEnv &env, FlattenParam& param) + { + assert (env.has_width); + StrEncoder encoder (param.flatStr); + encoder.encode_num (env.width); + } + + static void flush_hintmask (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param) + { + SUPER::flush_hintmask (op, env, param); + if (!param.drop_hints) + { + StrEncoder encoder (param.flatStr); + for (unsigned int i = 0; i < env.hintmask_size; i++) + encoder.encode_byte (env.substr[i]); + } + } + + private: + typedef CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> SUPER; +}; + +struct RangeList : hb_vector_t<code_pair> +{ + /* replace the first glyph ID in the "glyph" field each range with a nLeft value */ + bool finalize (unsigned int last_glyph) + { + bool two_byte = false; + for (unsigned int i = (*this).len; i > 0; i--) + { + code_pair &pair = (*this)[i - 1]; + unsigned int nLeft = last_glyph - pair.glyph - 1; + if (nLeft >= 0x100) + two_byte = true; + last_glyph = pair.glyph; + pair.glyph = nLeft; + } + return two_byte; + } +}; + +struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam> +{ + static void process_op (OpCode op, CFF1CSInterpEnv &env, SubrSubsetParam& param) + { + switch (op) { + + case OpCode_return: + param.current_parsed_str->add_op (op, env.substr); + param.current_parsed_str->set_parsed (); + env.returnFromSubr (); + param.set_current_str (env, false); + break; + + case OpCode_endchar: + param.current_parsed_str->add_op (op, env.substr); + param.current_parsed_str->set_parsed (); + SUPER::process_op (op, env, param); + break; + + case OpCode_callsubr: + process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); + break; + + case OpCode_callgsubr: + process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); + break; + + default: + SUPER::process_op (op, env, param); + param.current_parsed_str->add_op (op, env.substr); + break; + } + } + + protected: + static void process_call_subr (OpCode op, CSType type, + CFF1CSInterpEnv &env, SubrSubsetParam& param, + CFF1BiasedSubrs& subrs, hb_set_t *closure) + { + SubByteStr substr = env.substr; + env.callSubr (subrs, type); + param.current_parsed_str->add_call_op (op, substr, env.context.subr_num); + hb_set_add (closure, env.context.subr_num); + param.set_current_str (env, true); + } + + private: + typedef CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam> SUPER; +}; + +struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_SubrSubset> +{ + static void finalize_parsed_str (CFF1CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring) + { + /* insert width at the beginning of the charstring as necessary */ + if (env.has_width) + charstring.set_prefix (env.width); + + /* subroutines/charstring left on the call stack are legally left unmarked + * unmarked when a subroutine terminates with endchar. mark them. + */ + param.current_parsed_str->set_parsed (); + for (unsigned int i = 0; i < env.callStack.get_count (); i++) + { + ParsedCStr *parsed_str = param.get_parsed_str_for_context (env.callStack[i]); + if (likely (parsed_str != nullptr)) + parsed_str->set_parsed (); + else + env.set_error (); + } + } +}; + +struct cff_subset_plan { + cff_subset_plan () + : final_size (0), + offsets (), + orig_fdcount (0), + subset_fdcount (1), + subset_fdselect_format (0), + drop_hints (false), + desubroutinize(false) + { + topdict_sizes.init (); + topdict_sizes.resize (1); + topdict_mod.init (); + subset_fdselect_ranges.init (); + fdmap.init (); + subset_charstrings.init (); + subset_globalsubrs.init (); + subset_localsubrs.init (); + fontdicts_mod.init (); + subset_enc_code_ranges.init (); + subset_enc_supp_codes.init (); + subset_charset_ranges.init (); + sidmap.init (); + for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + topDictModSIDs[i] = CFF_UNDEF_SID; + } + + ~cff_subset_plan () + { + topdict_sizes.fini (); + topdict_mod.fini (); + subset_fdselect_ranges.fini (); + fdmap.fini (); + subset_charstrings.fini_deep (); + subset_globalsubrs.fini_deep (); + subset_localsubrs.fini_deep (); + fontdicts_mod.fini (); + subset_enc_code_ranges.fini (); + subset_enc_supp_codes.init (); + subset_charset_ranges.fini (); + sidmap.fini (); + fontdicts_mod.fini (); + } + + unsigned int plan_subset_encoding (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) + { + const Encoding *encoding = acc.encoding; + unsigned int size0, size1, supp_size; + hb_codepoint_t code, last_code = CFF_UNDEF_CODE; + hb_vector_t<hb_codepoint_t> supp_codes; + + subset_enc_code_ranges.resize (0); + supp_size = 0; + supp_codes.init (); + + subset_enc_num_codes = plan->glyphs.len - 1; + unsigned int glyph; + for (glyph = 1; glyph < plan->glyphs.len; glyph++) + { + hb_codepoint_t orig_glyph = plan->glyphs[glyph]; + code = acc.glyph_to_code (orig_glyph); + if (code == CFF_UNDEF_CODE) + { + subset_enc_num_codes = glyph - 1; + break; + } + + if (code != last_code + 1) + { + code_pair pair = { code, glyph }; + subset_enc_code_ranges.push (pair); + } + last_code = code; + + if (encoding != &Null(Encoding)) + { + hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph); + encoding->get_supplement_codes (sid, supp_codes); + for (unsigned int i = 0; i < supp_codes.len; i++) + { + code_pair pair = { supp_codes[i], sid }; + subset_enc_supp_codes.push (pair); + } + supp_size += SuppEncoding::static_size * supp_codes.len; + } + } + supp_codes.fini (); + + subset_enc_code_ranges.finalize (glyph); + + assert (subset_enc_num_codes <= 0xFF); + size0 = Encoding0::min_size + HBUINT8::static_size * subset_enc_num_codes; + size1 = Encoding1::min_size + Encoding1_Range::static_size * subset_enc_code_ranges.len; + + if (size0 < size1) + subset_enc_format = 0; + else + subset_enc_format = 1; + + return Encoding::calculate_serialized_size ( + subset_enc_format, + subset_enc_format? subset_enc_code_ranges.len: subset_enc_num_codes, + subset_enc_supp_codes.len); + } + + unsigned int plan_subset_charset (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) + { + unsigned int size0, size_ranges; + hb_codepoint_t sid, last_sid = CFF_UNDEF_CODE; + + subset_charset_ranges.resize (0); + unsigned int glyph; + for (glyph = 1; glyph < plan->glyphs.len; glyph++) + { + hb_codepoint_t orig_glyph = plan->glyphs[glyph]; + sid = acc.glyph_to_sid (orig_glyph); + + if (!acc.is_CID ()) + sid = sidmap.add (sid); + + if (sid != last_sid + 1) + { + code_pair pair = { sid, glyph }; + subset_charset_ranges.push (pair); + } + last_sid = sid; + } + + bool two_byte = subset_charset_ranges.finalize (glyph); + + size0 = Charset0::min_size + HBUINT16::static_size * (plan->glyphs.len - 1); + if (!two_byte) + size_ranges = Charset1::min_size + Charset1_Range::static_size * subset_charset_ranges.len; + else + size_ranges = Charset2::min_size + Charset2_Range::static_size * subset_charset_ranges.len; + + if (size0 < size_ranges) + subset_charset_format = 0; + else if (!two_byte) + subset_charset_format = 1; + else + subset_charset_format = 2; + + return Charset::calculate_serialized_size ( + subset_charset_format, + subset_charset_format? subset_charset_ranges.len: plan->glyphs.len); + } + + bool collect_sids_in_dicts (const OT::cff1::accelerator_subset_t &acc) + { + if (unlikely (!sidmap.reset (acc.stringIndex->count))) + return false; + + for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + { + unsigned int sid = acc.topDict.nameSIDs[i]; + if (sid != CFF_UNDEF_SID) + { + (void)sidmap.add (sid); + topDictModSIDs[i] = sidmap[sid]; + } + } + + if (acc.fdArray != &Null(CFF1FDArray)) + for (unsigned int i = 0; i < orig_fdcount; i++) + if (fdmap.includes (i)) + (void)sidmap.add (acc.fontDicts[i].fontName); + + return true; + } + + bool create (const OT::cff1::accelerator_subset_t &acc, + hb_subset_plan_t *plan) + { + /* make sure notdef is first */ + if ((plan->glyphs.len == 0) || (plan->glyphs[0] != 0)) return false; + + final_size = 0; + num_glyphs = plan->glyphs.len; + orig_fdcount = acc.fdCount; + drop_hints = plan->drop_hints; + desubroutinize = plan->desubroutinize; + + /* check whether the subset renumbers any glyph IDs */ + gid_renum = false; + for (unsigned int glyph = 0; glyph < plan->glyphs.len; glyph++) + { + if (plan->glyphs[glyph] != glyph) { + gid_renum = true; + break; + } + } + + subset_charset = gid_renum || !acc.is_predef_charset (); + subset_encoding = !acc.is_CID() && !acc.is_predef_encoding (); + + /* CFF header */ + final_size += OT::cff1::static_size; + + /* Name INDEX */ + offsets.nameIndexOffset = final_size; + final_size += acc.nameIndex->get_size (); + + /* top dict INDEX */ + { + /* Add encoding/charset to a (copy of) top dict as necessary */ + topdict_mod.init (&acc.topDict); + bool need_to_add_enc = (subset_encoding && !acc.topDict.has_op (OpCode_Encoding)); + bool need_to_add_set = (subset_charset && !acc.topDict.has_op (OpCode_charset)); + if (need_to_add_enc || need_to_add_set) + { + if (need_to_add_enc) + topdict_mod.add_op (OpCode_Encoding); + if (need_to_add_set) + topdict_mod.add_op (OpCode_charset); + } + offsets.topDictInfo.offset = final_size; + CFF1TopDict_OpSerializer topSzr; + unsigned int topDictSize = TopDict::calculate_serialized_size (topdict_mod, topSzr); + offsets.topDictInfo.offSize = calcOffSize(topDictSize); + if (unlikely (offsets.topDictInfo.offSize > 4)) + return false; + final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<CFF1TopDictValuesMod> + (offsets.topDictInfo.offSize, + &topdict_mod, 1, topdict_sizes, topSzr); + } + + /* Determine re-mapping of font index as fdmap among other info */ + if (acc.fdSelect != &Null(CFF1FDSelect)) + { + if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, + orig_fdcount, + *acc.fdSelect, + subset_fdcount, + offsets.FDSelectInfo.size, + subset_fdselect_format, + subset_fdselect_ranges, + fdmap))) + return false; + } + else + fdmap.identity (1); + + /* remove unused SIDs & reassign SIDs */ + { + /* SIDs for name strings in dicts are added before glyph names so they fit in 16-bit int range */ + if (unlikely (!collect_sids_in_dicts (acc))) + return false; + if (unlikely (sidmap.get_count () > 0x8000)) /* assumption: a dict won't reference that many strings */ + return false; + if (subset_charset) + offsets.charsetInfo.size = plan_subset_charset (acc, plan); + + topdict_mod.reassignSIDs (sidmap); + } + + /* String INDEX */ + { + offsets.stringIndexInfo.offset = final_size; + offsets.stringIndexInfo.size = acc.stringIndex->calculate_serialized_size (offsets.stringIndexInfo.offSize, sidmap); + final_size += offsets.stringIndexInfo.size; + } + + if (desubroutinize) + { + /* Flatten global & local subrs */ + SubrFlattener<const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_Flatten> + flattener(acc, plan->glyphs, plan->drop_hints); + if (!flattener.flatten (subset_charstrings)) + return false; + + /* no global/local subroutines */ + offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (1, 0, 0); + } + else + { + /* Subset subrs: collect used subroutines, leaving all unused ones behind */ + if (!subr_subsetter.subset (acc, plan->glyphs, plan->drop_hints)) + return false; + + /* encode charstrings, global subrs, local subrs with new subroutine numbers */ + if (!subr_subsetter.encode_charstrings (acc, plan->glyphs, subset_charstrings)) + return false; + + if (!subr_subsetter.encode_globalsubrs (subset_globalsubrs)) + return false; + + /* global subrs */ + unsigned int dataSize = subset_globalsubrs.total_size (); + offsets.globalSubrsInfo.offSize = calcOffSize (dataSize); + if (unlikely (offsets.globalSubrsInfo.offSize > 4)) + return false; + offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (offsets.globalSubrsInfo.offSize, subset_globalsubrs.len, dataSize); + + /* local subrs */ + if (!offsets.localSubrsInfos.resize (orig_fdcount)) + return false; + if (!subset_localsubrs.resize (orig_fdcount)) + return false; + for (unsigned int fd = 0; fd < orig_fdcount; fd++) + { + subset_localsubrs[fd].init (); + offsets.localSubrsInfos[fd].init (); + if (fdmap.includes (fd)) + { + if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) + return false; + + unsigned int dataSize = subset_localsubrs[fd].total_size (); + if (dataSize > 0) + { + offsets.localSubrsInfos[fd].offset = final_size; + offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); + if (unlikely (offsets.localSubrsInfos[fd].offSize > 4)) + return false; + offsets.localSubrsInfos[fd].size = CFF1Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); + } + } + } + } + + /* global subrs */ + offsets.globalSubrsInfo.offset = final_size; + final_size += offsets.globalSubrsInfo.size; + + /* Encoding */ + if (!subset_encoding) + offsets.encodingOffset = acc.topDict.EncodingOffset; + else + { + offsets.encodingOffset = final_size; + final_size += plan_subset_encoding (acc, plan); + } + + /* Charset */ + if (!subset_charset && acc.is_predef_charset ()) + offsets.charsetInfo.offset = acc.topDict.CharsetOffset; + else + offsets.charsetInfo.offset = final_size; + final_size += offsets.charsetInfo.size; + + /* FDSelect */ + if (acc.fdSelect != &Null(CFF1FDSelect)) + { + offsets.FDSelectInfo.offset = final_size; + final_size += offsets.FDSelectInfo.size; + } + + /* FDArray (FDIndex) */ + if (acc.fdArray != &Null(CFF1FDArray)) { + offsets.FDArrayInfo.offset = final_size; + CFF1FontDict_OpSerializer fontSzr; + unsigned int dictsSize = 0; + for (unsigned int i = 0; i < acc.fontDicts.len; i++) + if (fdmap.includes (i)) + dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); + + offsets.FDArrayInfo.offSize = calcOffSize (dictsSize); + if (unlikely (offsets.FDArrayInfo.offSize > 4)) + return false; + final_size += CFF1Index::calculate_serialized_size (offsets.FDArrayInfo.offSize, subset_fdcount, dictsSize); + } + + /* CharStrings */ + { + offsets.charStringsInfo.offset = final_size; + unsigned int dataSize = subset_charstrings.total_size (); + offsets.charStringsInfo.offSize = calcOffSize (dataSize); + if (unlikely (offsets.charStringsInfo.offSize > 4)) + return false; + final_size += CFF1CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize); + } + + /* private dicts & local subrs */ + offsets.privateDictInfo.offset = final_size; + for (unsigned int i = 0; i < orig_fdcount; i++) + { + if (fdmap.includes (i)) + { + bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; + CFFPrivateDict_OpSerializer privSzr (desubroutinize, plan->drop_hints); + unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); + TableInfo privInfo = { final_size, priv_size, 0 }; + FontDictValuesMod fontdict_mod; + if (!acc.is_CID ()) + fontdict_mod.init ( &Null(CFF1FontDictValues), CFF_UNDEF_SID, privInfo ); + else + fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo ); + fontdicts_mod.push (fontdict_mod); + final_size += privInfo.size; + + if (!plan->desubroutinize && has_localsubrs) + { + offsets.localSubrsInfos[i].offset = final_size; + final_size += offsets.localSubrsInfos[i].size; + } + } + } + + if (!acc.is_CID ()) + offsets.privateDictInfo = fontdicts_mod[0].privateDictInfo; + + return ((subset_charstrings.len == plan->glyphs.len) + && (fontdicts_mod.len == subset_fdcount)); + } + + unsigned int get_final_size () const { return final_size; } + + unsigned int final_size; + hb_vector_t<unsigned int> topdict_sizes; + CFF1TopDictValuesMod topdict_mod; + CFF1SubTableOffsets offsets; + + unsigned int num_glyphs; + unsigned int orig_fdcount; + unsigned int subset_fdcount; + unsigned int subset_fdselect_format; + hb_vector_t<code_pair> subset_fdselect_ranges; + + /* font dict index remap table from fullset FDArray to subset FDArray. + * set to CFF_UNDEF_CODE if excluded from subset */ + Remap fdmap; + + StrBuffArray subset_charstrings; + StrBuffArray subset_globalsubrs; + hb_vector_t<StrBuffArray> subset_localsubrs; + hb_vector_t<FontDictValuesMod> fontdicts_mod; + + bool drop_hints; + + bool gid_renum; + bool subset_encoding; + uint8_t subset_enc_format; + unsigned int subset_enc_num_codes; + RangeList subset_enc_code_ranges; + hb_vector_t<code_pair> subset_enc_supp_codes; + + uint8_t subset_charset_format; + RangeList subset_charset_ranges; + bool subset_charset; + + RemapSID sidmap; + unsigned int topDictModSIDs[NameDictValues::ValCount]; + + bool desubroutinize; + CFF1SubrSubsetter subr_subsetter; +}; + +static inline bool _write_cff1 (const cff_subset_plan &plan, + const OT::cff1::accelerator_subset_t &acc, + const hb_vector_t<hb_codepoint_t>& glyphs, + unsigned int dest_sz, + void *dest) +{ + hb_serialize_context_t c (dest, dest_sz); + + char RETURN_OP[1] = { OpCode_return }; + const ByteStr NULL_SUBR (RETURN_OP, 1); + + OT::cff1 *cff = c.start_serialize<OT::cff1> (); + if (unlikely (!c.extend_min (*cff))) + return false; + + /* header */ + cff->version.major.set (0x01); + cff->version.minor.set (0x00); + cff->nameIndex.set (cff->min_size); + cff->offSize.set (4); /* unused? */ + + /* name INDEX */ + { + assert (cff->nameIndex == c.head - c.start); + CFF1NameIndex *dest = c.start_embed<CFF1NameIndex> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, *acc.nameIndex))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF name INDEX"); + return false; + } + } + + /* top dict INDEX */ + { + assert (plan.offsets.topDictInfo.offset == c.head - c.start); + CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > (); + if (dest == nullptr) return false; + CFF1TopDict_OpSerializer topSzr; + TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs); + if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize, + &plan.topdict_mod, 1, + plan.topdict_sizes, topSzr, modifier))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF top dict"); + return false; + } + } + + /* String INDEX */ + { + assert (plan.offsets.stringIndexInfo.offset == c.head - c.start); + CFF1StringIndex *dest = c.start_embed<CFF1StringIndex> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, *acc.stringIndex, plan.offsets.stringIndexInfo.offSize, plan.sidmap))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF string INDEX"); + return false; + } + } + + /* global subrs */ + { + assert (plan.offsets.globalSubrsInfo.offset != 0); + assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start); + + CFF1Subrs *dest = c.start_embed <CFF1Subrs> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize global subroutines"); + return false; + } + } + + /* Encoding */ + if (plan.subset_encoding) + { + assert (plan.offsets.encodingOffset == c.head - c.start); + Encoding *dest = c.start_embed<Encoding> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, + plan.subset_enc_format, + plan.subset_enc_num_codes, + plan.subset_enc_code_ranges, + plan.subset_enc_supp_codes))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize Encoding"); + return false; + } + } + + /* Charset */ + if (plan.subset_charset) + { + assert (plan.offsets.charsetInfo.offset == c.head - c.start); + Charset *dest = c.start_embed<Charset> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, + plan.subset_charset_format, + plan.num_glyphs, + plan.subset_charset_ranges))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize Charset"); + return false; + } + } + + /* FDSelect */ + if (acc.fdSelect != &Null(CFF1FDSelect)) + { + assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); + + if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *acc.fdSelect, acc.fdCount, + plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, + plan.subset_fdselect_ranges))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF subset FDSelect"); + return false; + } + } + + /* FDArray (FD Index) */ + if (acc.fdArray != &Null(CFF1FDArray)) + { + assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); + CFF1FDArray *fda = c.start_embed<CFF1FDArray> (); + if (unlikely (fda == nullptr)) return false; + CFF1FontDict_OpSerializer fontSzr; + if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, + plan.fontdicts_mod, + fontSzr))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF FDArray"); + return false; + } + } + + /* CharStrings */ + { + assert (plan.offsets.charStringsInfo.offset == c.head - c.start); + CFF1CharStrings *cs = c.start_embed<CFF1CharStrings> (); + if (unlikely (cs == nullptr)) return false; + if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF CharStrings"); + return false; + } + } + + /* private dicts & local subrs */ + assert (plan.offsets.privateDictInfo.offset == c.head - c.start); + for (unsigned int i = 0; i < acc.privateDicts.len; i++) + { + if (plan.fdmap.includes (i)) + { + PrivateDict *pd = c.start_embed<PrivateDict> (); + if (unlikely (pd == nullptr)) return false; + unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size; + bool result; + CFFPrivateDict_OpSerializer privSzr (plan.desubroutinize, plan.drop_hints); + /* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */ + unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0; + result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); + if (unlikely (!result)) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); + return false; + } + if (plan.offsets.localSubrsInfos[i].size > 0) + { + CFF1Subrs *dest = c.start_embed <CFF1Subrs> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); + return false; + } + } + } + } + + assert (c.head == c.end); + c.end_serialize (); + + return true; +} + +static bool +_hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc, + const char *data, + hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) +{ + cff_subset_plan cff_plan; + + if (unlikely (!cff_plan.create (acc, plan))) + { + DEBUG_MSG(SUBSET, nullptr, "Failed to generate a cff subsetting plan."); + return false; + } + + unsigned int cff_prime_size = cff_plan.get_final_size (); + char *cff_prime_data = (char *) calloc (1, cff_prime_size); + + if (unlikely (!_write_cff1 (cff_plan, acc, plan->glyphs, + cff_prime_size, cff_prime_data))) { + DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff."); + free (cff_prime_data); + return false; + } + + *prime = hb_blob_create (cff_prime_data, + cff_prime_size, + HB_MEMORY_MODE_READONLY, + cff_prime_data, + free); + return true; +} + +/** + * hb_subset_cff1: + * Subsets the CFF table according to a provided plan. + * + * Return value: subsetted cff table. + **/ +bool +hb_subset_cff1 (hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) +{ + hb_blob_t *cff_blob = hb_sanitize_context_t().reference_table<CFF::cff1> (plan->source); + const char *data = hb_blob_get_data(cff_blob, nullptr); + + OT::cff1::accelerator_subset_t acc; + acc.init(plan->source); + bool result = likely (acc.is_valid ()) && + _hb_subset_cff1 (acc, data, plan, prime); + hb_blob_destroy (cff_blob); + acc.fini (); + + return result; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.hh new file mode 100644 index 00000000000..1ec8678845a --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.hh @@ -0,0 +1,38 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#ifndef HB_SUBSET_CFF1_HH +#define HB_SUBSET_CFF1_HH + +#include "hb.hh" + +#include "hb-subset-plan.hh" + +HB_INTERNAL bool +hb_subset_cff1 (hb_subset_plan_t *plan, + hb_blob_t **cff_prime /* OUT */); + +#endif /* HB_SUBSET_CFF1_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc new file mode 100644 index 00000000000..5a5f29d3569 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc @@ -0,0 +1,624 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#include "hb-open-type.hh" +#include "hb-ot-cff2-table.hh" +#include "hb-set.h" +#include "hb-subset-cff2.hh" +#include "hb-subset-plan.hh" +#include "hb-subset-cff-common.hh" +#include "hb-cff2-interp-cs.hh" + +using namespace CFF; + +struct CFF2SubTableOffsets : CFFSubTableOffsets +{ + CFF2SubTableOffsets () + : CFFSubTableOffsets (), + varStoreOffset (0) + {} + + unsigned int varStoreOffset; +}; + +struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> +{ + bool serialize (hb_serialize_context_t *c, + const OpStr &opstr, + const CFF2SubTableOffsets &offsets) const + { + TRACE_SERIALIZE (this); + + switch (opstr.op) + { + case OpCode_vstore: + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset)); + + default: + return_trace (CFFTopDict_OpSerializer<>::serialize (c, opstr, offsets)); + } + } + + unsigned int calculate_serialized_size (const OpStr &opstr) const + { + switch (opstr.op) + { + case OpCode_vstore: + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + + default: + return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); + } + } +}; + +struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> +{ + static void flush_args_and_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param) + { + switch (op) + { + case OpCode_return: + case OpCode_endchar: + /* dummy opcodes in CFF2. ignore */ + break; + + case OpCode_hstem: + case OpCode_hstemhm: + case OpCode_vstem: + case OpCode_vstemhm: + case OpCode_hintmask: + case OpCode_cntrmask: + if (param.drop_hints) + { + env.clear_args (); + return; + } + HB_FALLTHROUGH; + + default: + SUPER::flush_args_and_op (op, env, param); + break; + } + } + + static void flush_args (CFF2CSInterpEnv &env, FlattenParam& param) + { + for (unsigned int i = 0; i < env.argStack.get_count ();) + { + const BlendArg &arg = env.argStack[i]; + if (arg.blending ()) + { + if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues)))) + { + env.set_error (); + return; + } + flatten_blends (arg, i, env, param); + i += arg.numValues; + } + else + { + StrEncoder encoder (param.flatStr); + encoder.encode_num (arg); + i++; + } + } + SUPER::flush_args (env, param); + } + + static void flatten_blends (const BlendArg &arg, unsigned int i, CFF2CSInterpEnv &env, FlattenParam& param) + { + /* flatten the default values */ + StrEncoder encoder (param.flatStr); + for (unsigned int j = 0; j < arg.numValues; j++) + { + const BlendArg &arg1 = env.argStack[i + j]; + if (unlikely (!((arg1.blending () && (arg.numValues == arg1.numValues) && (arg1.valueIndex == j) && + (arg1.deltas.len == env.get_region_count ()))))) + { + env.set_error (); + return; + } + encoder.encode_num (arg1); + } + /* flatten deltas for each value */ + for (unsigned int j = 0; j < arg.numValues; j++) + { + const BlendArg &arg1 = env.argStack[i + j]; + for (unsigned int k = 0; k < arg1.deltas.len; k++) + encoder.encode_num (arg1.deltas[k]); + } + /* flatten the number of values followed by blend operator */ + encoder.encode_int (arg.numValues); + encoder.encode_op (OpCode_blendcs); + } + + static void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param) + { + switch (op) + { + case OpCode_return: + case OpCode_endchar: + return; + default: + StrEncoder encoder (param.flatStr); + encoder.encode_op (op); + } + } + + private: + typedef CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> SUPER; + typedef CSOpSet<BlendArg, CFF2CSOpSet_Flatten, CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET; +}; + +struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam> +{ + static void process_op (OpCode op, CFF2CSInterpEnv &env, SubrSubsetParam& param) + { + switch (op) { + + case OpCode_return: + param.current_parsed_str->set_parsed (); + env.returnFromSubr (); + param.set_current_str (env, false); + break; + + case OpCode_endchar: + param.current_parsed_str->set_parsed (); + SUPER::process_op (op, env, param); + break; + + case OpCode_callsubr: + process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); + break; + + case OpCode_callgsubr: + process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); + break; + + default: + SUPER::process_op (op, env, param); + param.current_parsed_str->add_op (op, env.substr); + break; + } + } + + protected: + static void process_call_subr (OpCode op, CSType type, + CFF2CSInterpEnv &env, SubrSubsetParam& param, + CFF2BiasedSubrs& subrs, hb_set_t *closure) + { + SubByteStr substr = env.substr; + env.callSubr (subrs, type); + param.current_parsed_str->add_call_op (op, substr, env.context.subr_num); + hb_set_add (closure, env.context.subr_num); + param.set_current_str (env, true); + } + + private: + typedef CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam> SUPER; +}; + +struct CFF2SubrSubsetter : SubrSubsetter<CFF2SubrSubsetter, CFF2Subrs, const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_SubrSubset> +{ + static void finalize_parsed_str (CFF2CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring) + { + /* vsindex is inserted at the beginning of the charstring as necessary */ + if (env.seen_vsindex ()) + { + Number ivs; + ivs.set_int ((int)env.get_ivs ()); + charstring.set_prefix (ivs, OpCode_vsindexcs); + } + } +}; + +struct cff2_subset_plan { + cff2_subset_plan () + : final_size (0), + orig_fdcount (0), + subset_fdcount(1), + subset_fdselect_format (0), + drop_hints (false), + desubroutinize (false) + { + subset_fdselect_ranges.init (); + fdmap.init (); + subset_charstrings.init (); + subset_globalsubrs.init (); + subset_localsubrs.init (); + privateDictInfos.init (); + } + + ~cff2_subset_plan () + { + subset_fdselect_ranges.fini (); + fdmap.fini (); + subset_charstrings.fini_deep (); + subset_globalsubrs.fini_deep (); + subset_localsubrs.fini_deep (); + privateDictInfos.fini (); + } + + bool create (const OT::cff2::accelerator_subset_t &acc, + hb_subset_plan_t *plan) + { + final_size = 0; + orig_fdcount = acc.fdArray->count; + + drop_hints = plan->drop_hints; + desubroutinize = plan->desubroutinize; + + /* CFF2 header */ + final_size += OT::cff2::static_size; + + /* top dict */ + { + CFF2TopDict_OpSerializer topSzr; + offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr); + final_size += offsets.topDictInfo.size; + } + + if (desubroutinize) + { + /* Flatten global & local subrs */ + SubrFlattener<const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_Flatten> + flattener(acc, plan->glyphs, plan->drop_hints); + if (!flattener.flatten (subset_charstrings)) + return false; + + /* no global/local subroutines */ + offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (1, 0, 0); + } + else + { + /* Subset subrs: collect used subroutines, leaving all unused ones behind */ + if (!subr_subsetter.subset (acc, plan->glyphs, plan->drop_hints)) + return false; + + /* encode charstrings, global subrs, local subrs with new subroutine numbers */ + if (!subr_subsetter.encode_charstrings (acc, plan->glyphs, subset_charstrings)) + return false; + + if (!subr_subsetter.encode_globalsubrs (subset_globalsubrs)) + return false; + + /* global subrs */ + unsigned int dataSize = subset_globalsubrs.total_size (); + offsets.globalSubrsInfo.offSize = calcOffSize (dataSize); + offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (offsets.globalSubrsInfo.offSize, subset_globalsubrs.len, dataSize); + + /* local subrs */ + if (!offsets.localSubrsInfos.resize (orig_fdcount)) + return false; + if (!subset_localsubrs.resize (orig_fdcount)) + return false; + for (unsigned int fd = 0; fd < orig_fdcount; fd++) + { + subset_localsubrs[fd].init (); + offsets.localSubrsInfos[fd].init (); + if (fdmap.includes (fd)) + { + if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) + return false; + + unsigned int dataSize = subset_localsubrs[fd].total_size (); + if (dataSize > 0) + { + offsets.localSubrsInfos[fd].offset = final_size; + offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); + offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); + } + } + } + } + + /* global subrs */ + offsets.globalSubrsInfo.offset = final_size; + final_size += offsets.globalSubrsInfo.size; + + /* variation store */ + if (acc.varStore != &Null(CFF2VariationStore)) + { + offsets.varStoreOffset = final_size; + final_size += acc.varStore->get_size (); + } + + /* FDSelect */ + if (acc.fdSelect != &Null(CFF2FDSelect)) + { + offsets.FDSelectInfo.offset = final_size; + if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, + orig_fdcount, + *(const FDSelect *)acc.fdSelect, + subset_fdcount, + offsets.FDSelectInfo.size, + subset_fdselect_format, + subset_fdselect_ranges, + fdmap))) + return false; + + final_size += offsets.FDSelectInfo.size; + } + else + fdmap.identity (1); + + /* FDArray (FDIndex) */ + { + offsets.FDArrayInfo.offset = final_size; + CFFFontDict_OpSerializer fontSzr; + unsigned int dictsSize = 0; + for (unsigned int i = 0; i < acc.fontDicts.len; i++) + if (fdmap.includes (i)) + dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); + + offsets.FDArrayInfo.offSize = calcOffSize (dictsSize); + final_size += CFF2Index::calculate_serialized_size (offsets.FDArrayInfo.offSize, subset_fdcount, dictsSize); + } + + /* CharStrings */ + { + offsets.charStringsInfo.offset = final_size; + unsigned int dataSize = subset_charstrings.total_size (); + offsets.charStringsInfo.offSize = calcOffSize (dataSize); + final_size += CFF2CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize); + } + + /* private dicts & local subrs */ + offsets.privateDictsOffset = final_size; + for (unsigned int i = 0; i < orig_fdcount; i++) + { + if (fdmap.includes (i)) + { + bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; + CFFPrivateDict_OpSerializer privSzr (desubroutinize, drop_hints); + unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); + TableInfo privInfo = { final_size, priv_size, 0 }; + privateDictInfos.push (privInfo); + final_size += privInfo.size; + + if (!plan->desubroutinize && has_localsubrs) + { + offsets.localSubrsInfos[i].offset = final_size; + final_size += offsets.localSubrsInfos[i].size; + } + } + } + + return true; + } + + unsigned int get_final_size () const { return final_size; } + + unsigned int final_size; + CFF2SubTableOffsets offsets; + + unsigned int orig_fdcount; + unsigned int subset_fdcount; + unsigned int subset_fdselect_format; + hb_vector_t<code_pair> subset_fdselect_ranges; + + Remap fdmap; + + StrBuffArray subset_charstrings; + StrBuffArray subset_globalsubrs; + hb_vector_t<StrBuffArray> subset_localsubrs; + hb_vector_t<TableInfo> privateDictInfos; + + bool drop_hints; + bool desubroutinize; + CFF2SubrSubsetter subr_subsetter; +}; + +static inline bool _write_cff2 (const cff2_subset_plan &plan, + const OT::cff2::accelerator_subset_t &acc, + const hb_vector_t<hb_codepoint_t>& glyphs, + unsigned int dest_sz, + void *dest) +{ + hb_serialize_context_t c (dest, dest_sz); + + OT::cff2 *cff2 = c.start_serialize<OT::cff2> (); + if (unlikely (!c.extend_min (*cff2))) + return false; + + /* header */ + cff2->version.major.set (0x02); + cff2->version.minor.set (0x00); + cff2->topDict.set (OT::cff2::static_size); + + /* top dict */ + { + assert (cff2->topDict == c.head - c.start); + cff2->topDictSize.set (plan.offsets.topDictInfo.size); + TopDict &dict = cff2 + cff2->topDict; + CFF2TopDict_OpSerializer topSzr; + if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 top dict"); + return false; + } + } + + /* global subrs */ + { + assert (cff2->topDict + plan.offsets.topDictInfo.size == c.head - c.start); + CFF2Subrs *dest = c.start_embed <CFF2Subrs> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize global subroutines"); + return false; + } + } + + /* variation store */ + if (acc.varStore != &Null(CFF2VariationStore)) + { + assert (plan.offsets.varStoreOffset == c.head - c.start); + CFF2VariationStore *dest = c.start_embed<CFF2VariationStore> (); + if (unlikely (!dest->serialize (&c, acc.varStore))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 Variation Store"); + return false; + } + } + + /* FDSelect */ + if (acc.fdSelect != &Null(CFF2FDSelect)) + { + assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); + + if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *(const FDSelect *)acc.fdSelect, acc.fdArray->count, + plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, + plan.subset_fdselect_ranges))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 subset FDSelect"); + return false; + } + } + + /* FDArray (FD Index) */ + { + assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); + CFF2FDArray *fda = c.start_embed<CFF2FDArray> (); + if (unlikely (fda == nullptr)) return false; + CFFFontDict_OpSerializer fontSzr; + if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, + acc.fontDicts, plan.subset_fdcount, plan.fdmap, + fontSzr, plan.privateDictInfos))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 FDArray"); + return false; + } + } + + /* CharStrings */ + { + assert (plan.offsets.charStringsInfo.offset == c.head - c.start); + CFF2CharStrings *cs = c.start_embed<CFF2CharStrings> (); + if (unlikely (cs == nullptr)) return false; + if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 CharStrings"); + return false; + } + } + + /* private dicts & local subrs */ + assert (plan.offsets.privateDictsOffset == c.head - c.start); + for (unsigned int i = 0; i < acc.privateDicts.len; i++) + { + if (plan.fdmap.includes (i)) + { + PrivateDict *pd = c.start_embed<PrivateDict> (); + if (unlikely (pd == nullptr)) return false; + unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size; + bool result; + CFFPrivateDict_OpSerializer privSzr (plan.desubroutinize, plan.drop_hints); + /* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */ + unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0; + result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); + if (unlikely (!result)) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); + return false; + } + if (plan.offsets.localSubrsInfos[i].size > 0) + { + CFF2Subrs *dest = c.start_embed <CFF2Subrs> (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); + return false; + } + } + } + } + + assert (c.head == c.end); + c.end_serialize (); + + return true; +} + +static bool +_hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, + const char *data, + hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) +{ + cff2_subset_plan cff2_plan; + + if (unlikely (!cff2_plan.create (acc, plan))) + { + DEBUG_MSG(SUBSET, nullptr, "Failed to generate a cff2 subsetting plan."); + return false; + } + + unsigned int cff2_prime_size = cff2_plan.get_final_size (); + char *cff2_prime_data = (char *) calloc (1, cff2_prime_size); + + if (unlikely (!_write_cff2 (cff2_plan, acc, plan->glyphs, + cff2_prime_size, cff2_prime_data))) { + DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff2."); + free (cff2_prime_data); + return false; + } + + *prime = hb_blob_create (cff2_prime_data, + cff2_prime_size, + HB_MEMORY_MODE_READONLY, + cff2_prime_data, + free); + return true; +} + +/** + * hb_subset_cff2: + * Subsets the CFF2 table according to a provided plan. + * + * Return value: subsetted cff2 table. + **/ +bool +hb_subset_cff2 (hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) +{ + hb_blob_t *cff2_blob = hb_sanitize_context_t().reference_table<CFF::cff2> (plan->source); + const char *data = hb_blob_get_data(cff2_blob, nullptr); + + OT::cff2::accelerator_subset_t acc; + acc.init(plan->source); + bool result = likely (acc.is_valid ()) && + _hb_subset_cff2 (acc, data, plan, prime); + + hb_blob_destroy (cff2_blob); + acc.fini (); + + return result; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.hh new file mode 100644 index 00000000000..a07dc290e5c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.hh @@ -0,0 +1,38 @@ +/* + * Copyright © 2018 Adobe 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. + * + * Adobe Author(s): Michiharu Ariza + */ + +#ifndef HB_SUBSET_CFF2_HH +#define HB_SUBSET_CFF2_HH + +#include "hb.hh" + +#include "hb-subset-plan.hh" + +HB_INTERNAL bool +hb_subset_cff2 (hb_subset_plan_t *plan, + hb_blob_t **cff2_prime /* OUT */); + +#endif /* HB_SUBSET_CFF2_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc index aafd31b9d3f..f718a566b19 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.cc @@ -35,7 +35,7 @@ * Since: 1.8.0 **/ hb_subset_input_t * -hb_subset_input_create_or_fail (void) +hb_subset_input_create_or_fail () { hb_subset_input_t *input = hb_object_create<hb_subset_input_t>(); @@ -131,3 +131,16 @@ hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input) { return subset_input->drop_layout; } + +HB_EXTERN void +hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, + hb_bool_t desubroutinize) +{ + subset_input->desubroutinize = desubroutinize; +} + +HB_EXTERN hb_bool_t +hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input) +{ + return subset_input->desubroutinize; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.hh index 7f625f2e443..8dad94f584e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-input.hh @@ -43,6 +43,7 @@ struct hb_subset_input_t bool drop_hints : 1; bool drop_layout : 1; + bool desubroutinize : 1; /* TODO * * features diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.cc index 56a2bba522d..5c0983b7160 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.cc @@ -30,6 +30,7 @@ #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" +#include "hb-ot-cff1-table.hh" static void _add_gid_and_children (const OT::glyf::accelerator_t &glyf, @@ -53,6 +54,19 @@ _add_gid_and_children (const OT::glyf::accelerator_t &glyf, } static void +_add_cff_seac_components (const OT::cff1::accelerator_t &cff, + hb_codepoint_t gid, + hb_set_t *gids_to_retain) +{ + hb_codepoint_t base_gid, accent_gid; + if (cff.get_seac_components (gid, &base_gid, &accent_gid)) + { + hb_set_add (gids_to_retain, base_gid); + hb_set_add (gids_to_retain, accent_gid); + } +} + +static void _gsub_closure (hb_face_t *face, hb_set_t *gids_to_retain) { hb_set_t lookup_indices; @@ -89,8 +103,10 @@ _populate_gids_to_retain (hb_face_t *face, { OT::cmap::accelerator_t cmap; OT::glyf::accelerator_t glyf; + OT::cff1::accelerator_t cff; cmap.init (face); glyf.init (face); + cff.init (face); hb_set_t *initial_gids_to_retain = hb_set_create (); initial_gids_to_retain->add (0); // Not-def @@ -120,6 +136,8 @@ _populate_gids_to_retain (hb_face_t *face, while (initial_gids_to_retain->next (&gid)) { _add_gid_and_children (glyf, gid, all_gids_to_retain); + if (cff.is_valid ()) + _add_cff_seac_components (cff, gid, all_gids_to_retain); } hb_set_destroy (initial_gids_to_retain); @@ -130,6 +148,7 @@ _populate_gids_to_retain (hb_face_t *face, while (all_gids_to_retain->next (&gid)) glyphs->push (gid); + cff.fini (); glyf.fini (); cmap.fini (); @@ -163,6 +182,7 @@ hb_subset_plan_create (hb_face_t *face, plan->drop_hints = input->drop_hints; plan->drop_layout = input->drop_layout; + plan->desubroutinize = input->desubroutinize; plan->unicodes = hb_set_create(); plan->glyphs.init(); plan->source = hb_face_reference (face); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.hh index c574f8f810b..a710a4dc040 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-plan.hh @@ -40,6 +40,7 @@ struct hb_subset_plan_t bool drop_hints : 1; bool drop_layout : 1; + bool desubroutinize : 1; // For each cp that we'd like to retain maps to the corresponding gid. hb_set_t *unicodes; @@ -54,9 +55,8 @@ struct hb_subset_plan_t hb_face_t *source; hb_face_t *dest; - inline bool - new_gid_for_codepoint (hb_codepoint_t codepoint, - hb_codepoint_t *new_gid) const + bool new_gid_for_codepoint (hb_codepoint_t codepoint, + hb_codepoint_t *new_gid) const { hb_codepoint_t old_gid = codepoint_to_glyph->get (codepoint); if (old_gid == HB_MAP_VALUE_INVALID) @@ -65,9 +65,8 @@ struct hb_subset_plan_t return new_gid_for_old_gid (old_gid, new_gid); } - inline bool - new_gid_for_old_gid (hb_codepoint_t old_gid, - hb_codepoint_t *new_gid) const + bool new_gid_for_old_gid (hb_codepoint_t old_gid, + hb_codepoint_t *new_gid) const { hb_codepoint_t gid = glyph_map->get (old_gid); if (gid == HB_MAP_VALUE_INVALID) @@ -77,7 +76,7 @@ struct hb_subset_plan_t return true; } - inline bool + bool add_table (hb_tag_t tag, hb_blob_t *contents) { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc index a3917b8626b..37e7cec2e3b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.cc @@ -40,6 +40,9 @@ #include "hb-ot-maxp-table.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-post-table.hh" +#include "hb-ot-cff1-table.hh" +#include "hb-ot-cff2-table.hh" +#include "hb-ot-vorg-table.hh" #include "hb-ot-layout-gsub-table.hh" #include "hb-ot-layout-gpos-table.hh" @@ -77,10 +80,10 @@ _subset2 (hb_subset_plan_t *plan) return false; } retry: - hb_serialize_context_t serializer (buf, buf_size); + hb_serialize_context_t serializer ((void *) buf, buf_size); hb_subset_context_t c (plan, &serializer); result = table->subset (&c); - if (serializer.ran_out_of_room) + if (serializer.in_error ()) { 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); @@ -177,7 +180,18 @@ _subset_table (hb_subset_plan_t *plan, case HB_OT_TAG_post: result = _subset<const OT::post> (plan); break; - + case HB_OT_TAG_cff1: + result = _subset<const OT::cff1> (plan); + break; + case HB_OT_TAG_cff2: + result = _subset<const OT::cff2> (plan); + break; + case HB_OT_TAG_VORG: + result = _subset<const OT::VORG> (plan); + break; + case HB_OT_TAG_GDEF: + result = _subset2<const OT::GDEF> (plan); + break; case HB_OT_TAG_GSUB: result = _subset2<const OT::GSUB> (plan); break; @@ -210,9 +224,9 @@ _should_drop_table (hb_subset_plan_t *plan, hb_tag_t tag) case HB_TAG ('V', 'D', 'M', 'X'): /* hint table, fallthrough */ return plan->drop_hints; // Drop Layout Tables if requested. - case HB_TAG ('G', 'D', 'E', 'F'): /* temporary */ - case HB_TAG ('G', 'P', 'O', 'S'): /* temporary */ - case HB_TAG ('G', 'S', 'U', 'B'): /* temporary */ + case HB_OT_TAG_GDEF: + case HB_OT_TAG_GPOS: + case HB_OT_TAG_GSUB: return plan->drop_layout; // Drop these tables below by default, list pulled // from fontTools: diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.h index 3b306dd81f5..f582e46df71 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.h @@ -66,6 +66,11 @@ hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input, HB_EXTERN hb_bool_t hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input); +HB_EXTERN void +hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, + hb_bool_t desubroutinize); +HB_EXTERN hb_bool_t +hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input); /* hb_subset () */ HB_EXTERN hb_face_t * diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.hh index e43c79f5ee6..45cb763ecb6 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset.hh @@ -39,11 +39,10 @@ struct hb_subset_context_t : hb_dispatch_context_t<hb_subset_context_t, bool, HB_DEBUG_SUBSET> { - inline const char *get_name (void) { return "SUBSET"; } + const char *get_name () { return "SUBSET"; } 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 HB_UNUSED) const { return false; } + bool dispatch (const T &obj) { return obj.subset (this); } + static bool default_return_value () { return true; } hb_subset_plan_t *plan; hb_serialize_context_t *serializer; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ucdn.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ucdn.cc index 10608aff518..534935f13d2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ucdn.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ucdn.cc @@ -223,12 +223,12 @@ hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED, #if HB_USE_ATEXIT -static void free_static_ucdn_funcs (void); +static void free_static_ucdn_funcs (); #endif static struct hb_ucdn_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t<hb_ucdn_unicode_funcs_lazy_loader_t> { - static inline hb_unicode_funcs_t *create (void) + static hb_unicode_funcs_t *create () { hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr); @@ -251,7 +251,7 @@ static struct hb_ucdn_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader #if HB_USE_ATEXIT static -void free_static_ucdn_funcs (void) +void free_static_ucdn_funcs () { static_ucdn_funcs.free_instance (); } @@ -259,10 +259,10 @@ void free_static_ucdn_funcs (void) extern "C" HB_INTERNAL hb_unicode_funcs_t * -hb_ucdn_get_unicode_funcs (void); +hb_ucdn_get_unicode_funcs (); hb_unicode_funcs_t * -hb_ucdn_get_unicode_funcs (void) +hb_ucdn_get_unicode_funcs () { return static_ucdn_funcs.get_unconst (); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc index 5accf3643cd..4ac521d38cf 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.cc @@ -123,12 +123,12 @@ hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED } -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); +extern "C" hb_unicode_funcs_t *hb_glib_get_unicode_funcs (); +extern "C" hb_unicode_funcs_t *hb_icu_get_unicode_funcs (); +extern "C" hb_unicode_funcs_t *hb_ucdn_get_unicode_funcs (); hb_unicode_funcs_t * -hb_unicode_funcs_get_default (void) +hb_unicode_funcs_get_default () { #if defined(HAVE_UCDN) return hb_ucdn_get_unicode_funcs (); @@ -151,7 +151,7 @@ hb_unicode_funcs_get_default (void) * hb_unicode_funcs_create: (Xconstructor) * @parent: (nullable): * - * + * * * Return value: (transfer full): * @@ -197,14 +197,14 @@ DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) = /** * hb_unicode_funcs_get_empty: * - * + * * * Return value: (transfer full): * * Since: 0.9.2 **/ hb_unicode_funcs_t * -hb_unicode_funcs_get_empty (void) +hb_unicode_funcs_get_empty () { return const_cast<hb_unicode_funcs_t *> (&Null(hb_unicode_funcs_t)); } @@ -213,7 +213,7 @@ hb_unicode_funcs_get_empty (void) * hb_unicode_funcs_reference: (skip) * @ufuncs: Unicode functions. * - * + * * * Return value: (transfer full): * @@ -229,7 +229,7 @@ hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_destroy: (skip) * @ufuncs: Unicode functions. * - * + * * * Since: 0.9.2 **/ @@ -251,14 +251,14 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) /** * hb_unicode_funcs_set_user_data: (skip) * @ufuncs: Unicode functions. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: + * * - * * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -275,9 +275,9 @@ hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_funcs_get_user_data: (skip) * @ufuncs: Unicode functions. - * @key: + * @key: + * * - * * * Return value: (transfer none): * @@ -295,7 +295,7 @@ hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs, * hb_unicode_funcs_make_immutable: * @ufuncs: Unicode functions. * - * + * * * Since: 0.9.2 **/ @@ -312,9 +312,9 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_is_immutable: * @ufuncs: Unicode functions. * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -328,9 +328,9 @@ hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_get_parent: * @ufuncs: Unicode functions. * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -384,13 +384,13 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE /** * hb_unicode_compose: * @ufuncs: Unicode functions. - * @a: - * @b: + * @a: + * @b: * @ab: (out): * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -406,13 +406,13 @@ hb_unicode_compose (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_decompose: * @ufuncs: Unicode functions. - * @ab: + * @ab: * @a: (out): * @b: (out): * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 **/ @@ -428,12 +428,12 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_decompose_compatibility: * @ufuncs: Unicode functions. - * @u: + * @u: * @decomposed: (out): * - * * - * Return value: + * + * Return value: * * Since: 0.9.2 * Deprecated: 2.0.0 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh index d3fd5ea4bae..82ebb106472 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-unicode.hh @@ -67,27 +67,27 @@ struct hb_unicode_funcs_t hb_unicode_funcs_t *parent; #define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \ - inline return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); } + return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); } HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE #undef HB_UNICODE_FUNC_IMPLEMENT - inline hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b, - hb_codepoint_t *ab) + hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b, + hb_codepoint_t *ab) { *ab = 0; if (unlikely (!a || !b)) return false; return func.compose (this, a, b, ab, user_data.compose); } - inline hb_bool_t decompose (hb_codepoint_t ab, - hb_codepoint_t *a, hb_codepoint_t *b) + hb_bool_t decompose (hb_codepoint_t ab, + hb_codepoint_t *a, hb_codepoint_t *b) { *a = ab; *b = 0; return func.decompose (this, ab, a, b, user_data.decompose); } - inline unsigned int decompose_compatibility (hb_codepoint_t u, - hb_codepoint_t *decomposed) + unsigned int decompose_compatibility (hb_codepoint_t u, + hb_codepoint_t *decomposed) { unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility); if (ret == 1 && u == decomposed[0]) { @@ -98,7 +98,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE return ret; } - inline unsigned int + unsigned int modified_combining_class (hb_codepoint_t u) { /* XXX This hack belongs to the Myanmar shaper. */ @@ -117,14 +117,14 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE return _hb_modified_combining_class[combining_class (u)]; } - static inline hb_bool_t + static hb_bool_t is_variation_selector (hb_codepoint_t unicode) { /* U+180B..180D MONGOLIAN FREE VARIATION SELECTORs are handled in the * Arabic shaper. No need to match them here. */ return unlikely (hb_in_ranges<hb_codepoint_t> (unicode, - 0xFE00u, 0xFE0Fu, /* VARIATION SELECTOR-1..16 */ - 0xE0100u, 0xE01EFu)); /* VARIATION SELECTOR-17..256 */ + 0xFE00u, 0xFE0Fu, /* VARIATION SELECTOR-1..16 */ + 0xE0100u, 0xE01EFu)); /* VARIATION SELECTOR-17..256 */ } /* Default_Ignorable codepoints: @@ -164,7 +164,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE * E0100..E01EF # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256 * E01F0..E0FFF # Cn [3600] <reserved-E01F0>..<reserved-E0FFF> */ - static inline hb_bool_t + static hb_bool_t is_default_ignorable (hb_codepoint_t ch) { hb_codepoint_t plane = ch >> 16; @@ -216,7 +216,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE SPACE_PUNCTUATION, SPACE_NARROW, }; - static inline space_t + static space_t space_fallback_type (hb_codepoint_t u) { switch (u) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc index 1fae6435b2c..8d0473d95fb 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc @@ -205,7 +205,7 @@ struct hb_uniscribe_shaper_funcs_t SSOT ScriptShapeOpenType; SPOT ScriptPlaceOpenType; - inline void init (void) + void init () { HMODULE hinstLib; this->ScriptItemizeOpenType = nullptr; @@ -232,12 +232,12 @@ struct hb_uniscribe_shaper_funcs_t }; -static void free_static_uniscribe_shaper_funcs (void); +static void free_static_uniscribe_shaper_funcs (); static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_uniscribe_shaper_funcs_t, hb_uniscribe_shaper_funcs_lazy_loader_t> { - static inline hb_uniscribe_shaper_funcs_t *create (void) + static hb_uniscribe_shaper_funcs_t *create () { hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t)); if (unlikely (!funcs)) @@ -251,11 +251,11 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis return funcs; } - static inline void destroy (hb_uniscribe_shaper_funcs_t *p) + static void destroy (hb_uniscribe_shaper_funcs_t *p) { free ((void *) p); } - static inline hb_uniscribe_shaper_funcs_t *get_null (void) + static hb_uniscribe_shaper_funcs_t *get_null () { return nullptr; } @@ -263,14 +263,14 @@ static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t<hb_unis #if HB_USE_ATEXIT static -void free_static_uniscribe_shaper_funcs (void) +void free_static_uniscribe_shaper_funcs () { static_uniscribe_shaper_funcs.free_instance (); } #endif static hb_uniscribe_shaper_funcs_t * -hb_uniscribe_shaper_get_funcs (void) +hb_uniscribe_shaper_get_funcs () { return static_uniscribe_shaper_funcs.get_unconst (); } @@ -288,9 +288,8 @@ struct active_feature_t { a->rec.lParameter < b->rec.lParameter ? -1 : a->rec.lParameter > b->rec.lParameter ? 1 : 0; } - bool operator== (const active_feature_t *f) { - return cmp (this, f) == 0; - } + bool operator== (const active_feature_t *f) + { return cmp (this, f) == 0; } }; struct feature_event_t { @@ -298,7 +297,8 @@ struct feature_event_t { bool start; active_feature_t feature; - static int cmp (const void *pa, const void *pb) { + static int cmp (const void *pa, const void *pb) + { const feature_event_t *a = (const feature_event_t *) pa; const feature_event_t *b = (const feature_event_t *) pb; return a->index < b->index ? -1 : a->index > b->index ? 1 : @@ -695,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); + active_features.remove (feature - active_features.arrayZ ()); } } @@ -886,8 +886,8 @@ retry: &items[i].a, script_tags[i], language_tag, - range_char_counts, - range_properties, + range_char_counts.arrayZ (), + range_properties.arrayZ (), range_properties.len, pchars + chars_offset, item_chars_len, @@ -927,8 +927,8 @@ retry: &items[i].a, script_tags[i], language_tag, - range_char_counts, - range_properties, + range_char_counts.arrayZ (), + range_properties.arrayZ (), range_properties.len, pchars + chars_offset, log_clusters + chars_offset, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf.hh index 54ede3c167a..59ec75ebc1e 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-utf.hh @@ -36,7 +36,7 @@ struct hb_utf8_t { typedef uint8_t codepoint_t; - static inline const codepoint_t * + static const codepoint_t * next (const codepoint_t *text, const codepoint_t *end, hb_codepoint_t *unicode, @@ -105,7 +105,7 @@ struct hb_utf8_t return text; } - static inline const codepoint_t * + static const codepoint_t * prev (const codepoint_t *text, const codepoint_t *start, hb_codepoint_t *unicode, @@ -122,13 +122,11 @@ struct hb_utf8_t return end - 1; } - static inline unsigned int + static unsigned int strlen (const codepoint_t *text) - { - return ::strlen ((const char *) text); - } + { return ::strlen ((const char *) text); } - static inline unsigned int + static unsigned int encode_len (hb_codepoint_t unicode) { if (unicode < 0x0080u) return 1; @@ -138,7 +136,7 @@ struct hb_utf8_t return 3; } - static inline codepoint_t * + static codepoint_t * encode (codepoint_t *text, const codepoint_t *end, hb_codepoint_t unicode) @@ -185,7 +183,7 @@ struct hb_utf16_xe_t static_assert (sizeof (TCodepoint) == 2, ""); typedef TCodepoint codepoint_t; - static inline const codepoint_t * + static const codepoint_t * next (const codepoint_t *text, const codepoint_t *end, hb_codepoint_t *unicode, @@ -217,7 +215,7 @@ struct hb_utf16_xe_t return text; } - static inline const codepoint_t * + static const codepoint_t * prev (const codepoint_t *text, const codepoint_t *start, hb_codepoint_t *unicode, @@ -250,7 +248,7 @@ struct hb_utf16_xe_t } - static inline unsigned int + static unsigned int strlen (const codepoint_t *text) { unsigned int l = 0; @@ -258,13 +256,13 @@ struct hb_utf16_xe_t return l; } - static inline unsigned int + static unsigned int encode_len (hb_codepoint_t unicode) { return unicode < 0x10000 ? 1 : 2; } - static inline codepoint_t * + static codepoint_t * encode (codepoint_t *text, const codepoint_t *end, hb_codepoint_t unicode) @@ -293,7 +291,7 @@ struct hb_utf32_xe_t static_assert (sizeof (TCodepoint) == 4, ""); typedef TCodepoint codepoint_t; - static inline const TCodepoint * + static const TCodepoint * next (const TCodepoint *text, const TCodepoint *end HB_UNUSED, hb_codepoint_t *unicode, @@ -305,7 +303,7 @@ struct hb_utf32_xe_t return text; } - static inline const TCodepoint * + static const TCodepoint * prev (const TCodepoint *text, const TCodepoint *start HB_UNUSED, hb_codepoint_t *unicode, @@ -317,7 +315,7 @@ struct hb_utf32_xe_t return text; } - static inline unsigned int + static unsigned int strlen (const TCodepoint *text) { unsigned int l = 0; @@ -325,13 +323,13 @@ struct hb_utf32_xe_t return l; } - static inline unsigned int + static unsigned int encode_len (hb_codepoint_t unicode HB_UNUSED) { return 1; } - static inline codepoint_t * + static codepoint_t * encode (codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t unicode) @@ -351,7 +349,7 @@ struct hb_latin1_t { typedef uint8_t codepoint_t; - static inline const codepoint_t * + static const codepoint_t * next (const codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t *unicode, @@ -361,7 +359,7 @@ struct hb_latin1_t return text; } - static inline const codepoint_t * + static const codepoint_t * prev (const codepoint_t *text, const codepoint_t *start HB_UNUSED, hb_codepoint_t *unicode, @@ -371,7 +369,7 @@ struct hb_latin1_t return text; } - static inline unsigned int + static unsigned int strlen (const codepoint_t *text) { unsigned int l = 0; @@ -379,13 +377,13 @@ struct hb_latin1_t return l; } - static inline unsigned int + static unsigned int encode_len (hb_codepoint_t unicode HB_UNUSED) { return 1; } - static inline codepoint_t * + static codepoint_t * encode (codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t unicode) @@ -402,7 +400,7 @@ struct hb_ascii_t { typedef uint8_t codepoint_t; - static inline const codepoint_t * + static const codepoint_t * next (const codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t *unicode, @@ -414,7 +412,7 @@ struct hb_ascii_t return text; } - static inline const codepoint_t * + static const codepoint_t * prev (const codepoint_t *text, const codepoint_t *start HB_UNUSED, hb_codepoint_t *unicode, @@ -426,7 +424,7 @@ struct hb_ascii_t return text; } - static inline unsigned int + static unsigned int strlen (const codepoint_t *text) { unsigned int l = 0; @@ -434,13 +432,13 @@ struct hb_ascii_t return l; } - static inline unsigned int + static unsigned int encode_len (hb_codepoint_t unicode HB_UNUSED) { return 1; } - static inline codepoint_t * + static codepoint_t * encode (codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t unicode) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh index 787512f9221..d8e3f4ef109 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh @@ -21,7 +21,6 @@ * 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 */ @@ -29,19 +28,18 @@ #define HB_VECTOR_HH #include "hb.hh" +#include "hb-array.hh" 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) }; + enum { item_size = hb_static_size (Type) }; HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount); - inline hb_vector_t (void) { init (); } - inline ~hb_vector_t (void) { fini (); } + hb_vector_t () { init (); } + ~hb_vector_t () { fini (); } unsigned int len; private: @@ -50,21 +48,21 @@ struct hb_vector_t Type static_array[PreallocedCount]; public: - void init (void) + void init () { len = 0; allocated = ARRAY_LENGTH (static_array); arrayZ_ = nullptr; } - inline void fini (void) + void fini () { if (arrayZ_) free (arrayZ_); arrayZ_ = nullptr; allocated = len = 0; } - inline void fini_deep (void) + void fini_deep () { Type *array = arrayZ(); unsigned int count = len; @@ -73,57 +71,77 @@ struct hb_vector_t fini (); } - inline Type * arrayZ (void) - { return arrayZ_ ? arrayZ_ : static_array; } - inline const Type * arrayZ (void) const - { return arrayZ_ ? arrayZ_ : static_array; } + Type * arrayZ () { return arrayZ_ ? arrayZ_ : static_array; } + const Type * arrayZ () const { return arrayZ_ ? arrayZ_ : static_array; } - inline Type& operator [] (unsigned int i) + Type& operator [] (int i_) { + unsigned int i = (unsigned int) i_; if (unlikely (i >= len)) return Crap (Type); return arrayZ()[i]; } - inline const Type& operator [] (unsigned int i) const + const Type& operator [] (int i_) const { + unsigned int i = (unsigned int) i_; if (unlikely (i >= len)) return Null(Type); return arrayZ()[i]; } - inline hb_array_t<Type> as_array (void) + hb_array_t<Type> as_array () { return hb_array (arrayZ(), len); } - inline hb_array_t<const Type> as_array (void) const + hb_array_t<const Type> as_array () const { return hb_array (arrayZ(), len); } - inline hb_sorted_array_t<Type> as_sorted_array (void) + hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int count) const + { return as_array ().sub_array (start_offset, count);} + hb_array_t<const Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const + { return as_array ().sub_array (start_offset, count);} + hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int count) + { return as_array ().sub_array (start_offset, count);} + hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) + { return as_array ().sub_array (start_offset, count);} + + hb_sorted_array_t<Type> as_sorted_array () { return hb_sorted_array (arrayZ(), len); } - inline hb_sorted_array_t<const Type> as_sorted_array (void) const + hb_sorted_array_t<const Type> as_sorted_array () 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(); } + hb_array_t<const Type> sorted_sub_array (unsigned int start_offset, unsigned int count) const + { return as_sorted_array ().sorted_sub_array (start_offset, count);} + hb_array_t<const Type> sorted_sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const + { return as_sorted_array ().sorted_sub_array (start_offset, count);} + hb_array_t<Type> sorted_sub_array (unsigned int start_offset, unsigned int count) + { return as_sorted_array ().sorted_sub_array (start_offset, count);} + hb_array_t<Type> sorted_sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) + { return as_sorted_array ().sorted_sub_array (start_offset, count);} + + template <typename T> explicit_operator T * () { return arrayZ(); } + template <typename T> explicit_operator const T * () const { return arrayZ(); } + operator hb_array_t<Type> () { return as_array (); } + operator hb_array_t<const Type> () const { return as_array (); } - inline Type * operator + (unsigned int i) { return arrayZ() + i; } - inline const Type * operator + (unsigned int i) const { return arrayZ() + i; } + Type * operator + (unsigned int i) { return arrayZ() + i; } + const Type * operator + (unsigned int i) const { return arrayZ() + i; } - inline Type *push (void) + Type *push () { if (unlikely (!resize (len + 1))) return &Crap(Type); return &arrayZ()[len - 1]; } - inline Type *push (const Type& v) + Type *push (const Type& v) { Type *p = push (); *p = v; return p; } - inline bool in_error (void) const { return allocated == 0; } + bool in_error () const { return allocated == 0; } /* Allocate for size but don't adjust len. */ - inline bool alloc (unsigned int size) + bool alloc (unsigned int size) { if (unlikely (!allocated)) return false; @@ -164,7 +182,7 @@ struct hb_vector_t return true; } - inline bool resize (int size_) + bool resize (int size_) { unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; if (!alloc (size)) @@ -177,13 +195,13 @@ struct hb_vector_t return true; } - inline void pop (void) + void pop () { if (!len) return; len--; } - inline void remove (unsigned int i) + void remove (unsigned int i) { if (unlikely (i >= len)) return; @@ -194,7 +212,7 @@ struct hb_vector_t len--; } - inline void shrink (int size_) + void shrink (int size_) { unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; if (size < len) @@ -202,7 +220,7 @@ struct hb_vector_t } template <typename T> - inline Type *find (T v) + Type *find (T v) { Type *array = arrayZ(); for (unsigned int i = 0; i < len; i++) @@ -211,7 +229,7 @@ struct hb_vector_t return nullptr; } template <typename T> - inline const Type *find (T v) const + const Type *find (T v) const { const Type *array = arrayZ(); for (unsigned int i = 0; i < len; i++) @@ -220,26 +238,26 @@ struct hb_vector_t return nullptr; } - inline void qsort (int (*cmp)(const void*, const void*)) + void qsort (int (*cmp)(const void*, const void*)) { as_array ().qsort (cmp); } - inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) + 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, Type *not_found = nullptr) + 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 + 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, Type *not_found = nullptr) + 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 Type *not_found = nullptr) const + 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 = nullptr, + 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/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh index 6df0a55b1bb..a55e92d5ddc 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh @@ -29,12 +29,36 @@ #ifndef HB_HH #define HB_HH -#define _GNU_SOURCE 1 - #ifdef HAVE_CONFIG_H #include "config.h" #endif +/* + * Following added based on what AC_USE_SYSTEM_EXTENSIONS adds to + * config.h.in. Copied here for the convenience of those embedding + * HarfBuzz and not using our build system. + */ +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif @@ -137,14 +161,14 @@ struct _hb_alignof /* https://github.com/harfbuzz/harfbuzz/issues/1127 */ #ifndef explicit_operator -#define explicit_operator +#define explicit_operator operator #endif #else /* __cplusplus >= 201103L */ /* https://github.com/harfbuzz/harfbuzz/issues/1127 */ #ifndef explicit_operator -#define explicit_operator explicit +#define explicit_operator explicit operator #endif #endif /* __cplusplus < 201103L */ @@ -357,21 +381,21 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); TypeName(const TypeName<T1, T2>&); \ void operator=(const TypeName<T1, T2>&) #define HB_NO_CREATE_COPY_ASSIGN(TypeName) \ - TypeName(void); \ + TypeName(); \ TypeName(const TypeName&); \ void operator=(const TypeName&) #define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE(TypeName, T) \ - TypeName(void); \ + TypeName(); \ TypeName(const TypeName<T>&); \ void operator=(const TypeName<T>&) #define HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \ - TypeName(void); \ + TypeName(); \ TypeName(const TypeName<T1, T2>&); \ void operator=(const TypeName<T1, T2>&) #else /* __cpluspplus >= 201103L */ -#define HB_NO_COPY_ASSIGN(TypeName) +#define HB_NO_COPY_ASSIGN(TypeName) static_assert (true, "") #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, "") diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-name-table.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-name-table.cc index 58c98f07ab6..518e4eb6e64 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-name-table.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-name-table.cc @@ -24,7 +24,7 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb.h" +#include "hb.hh" #include "hb-ot.h" #include <stdlib.h> @@ -41,7 +41,7 @@ main (int argc, char **argv) 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; + blob = nullptr; unsigned int count; const hb_ot_name_entry_t *entries = hb_ot_name_list_names (face, &count); @@ -63,5 +63,7 @@ main (int argc, char **argv) printf ("%s\n", buf); } + hb_face_destroy (face); + return count ? 0 : 1; } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-unicode-ranges.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-unicode-ranges.cc index d9342d7bb28..ec9d17acd23 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-unicode-ranges.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-unicode-ranges.cc @@ -42,7 +42,7 @@ test (hb_codepoint_t cp, unsigned int bit) } static void -test_get_unicode_range_bit (void) +test_get_unicode_range_bit () { test (0x0000, 0); test (0x0042, 0); @@ -60,7 +60,7 @@ test_get_unicode_range_bit (void) } int -main (void) +main () { test_get_unicode_range_bit (); return 0; |