From 2cd8b0fe12bfff91766553466c373294ad80e2d9 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Thu, 31 Jan 2019 23:16:40 +0000 Subject: harfbuzz 2.3.1 git-svn-id: svn://tug.org/texlive/trunk@49891 c570f23f-e606-0410-a88d-b1316a301751 --- .../libs/harfbuzz/harfbuzz-src/src/Makefile.am | 18 +- .../harfbuzz/harfbuzz-src/src/Makefile.sources | 1 + .../harfbuzz/harfbuzz-src/src/gen-indic-table.py | 3 + .../harfbuzz-src/src/gen-os2-unicode-ranges.py | 11 +- .../harfbuzz/harfbuzz-src/src/gen-use-table.py | 7 +- .../harfbuzz/harfbuzz-src/src/hb-aat-fdsc-table.hh | 2 +- .../harfbuzz-src/src/hb-aat-layout-ankr-table.hh | 18 +- .../harfbuzz-src/src/hb-aat-layout-bsln-table.hh | 2 +- .../harfbuzz-src/src/hb-aat-layout-common.hh | 69 +++-- .../harfbuzz-src/src/hb-aat-layout-feat-table.hh | 7 +- .../harfbuzz-src/src/hb-aat-layout-just-table.hh | 2 +- .../harfbuzz-src/src/hb-aat-layout-kerx-table.hh | 103 +++---- .../harfbuzz-src/src/hb-aat-layout-lcar-table.hh | 4 +- .../harfbuzz-src/src/hb-aat-layout-morx-table.hh | 159 +++++------ .../harfbuzz-src/src/hb-aat-layout-trak-table.hh | 4 +- .../harfbuzz/harfbuzz-src/src/hb-aat-layout.cc | 14 +- .../harfbuzz/harfbuzz-src/src/hb-aat-ltag-table.hh | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-aat-map.hh | 6 +- .../libs/harfbuzz/harfbuzz-src/src/hb-array.hh | 131 ++++----- .../libs/harfbuzz/harfbuzz-src/src/hb-blob.cc | 12 + .../libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh | 2 +- .../harfbuzz-src/src/hb-cff-interp-common.hh | 229 +++++++-------- .../harfbuzz-src/src/hb-cff-interp-cs-common.hh | 251 ++++++++-------- .../harfbuzz-src/src/hb-cff-interp-dict-common.hh | 64 ++--- .../harfbuzz/harfbuzz-src/src/hb-cff1-interp-cs.hh | 26 +- .../harfbuzz/harfbuzz-src/src/hb-cff2-interp-cs.hh | 62 ++-- .../libs/harfbuzz/harfbuzz-src/src/hb-common.h | 6 +- .../libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc | 12 +- .../libs/harfbuzz/harfbuzz-src/src/hb-debug.hh | 26 -- .../harfbuzz/harfbuzz-src/src/hb-directwrite.cc | 15 +- .../libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh | 24 +- .../libs/harfbuzz/harfbuzz-src/src/hb-face.cc | 6 +- .../libs/harfbuzz/harfbuzz-src/src/hb-font.cc | 18 +- .../source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc | 8 +- .../harfbuzz-src/src/hb-gobject-structs.cc | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-iter.hh | 153 ++++++++++ .../libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh | 50 ++-- .../libs/harfbuzz/harfbuzz-src/src/hb-map.hh | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-null.hh | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-object.hh | 25 +- .../libs/harfbuzz/harfbuzz-src/src/hb-open-file.hh | 17 +- .../libs/harfbuzz/harfbuzz-src/src/hb-open-type.hh | 27 +- .../harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh | 124 ++++---- .../harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.cc | 56 ++-- .../harfbuzz/harfbuzz-src/src/hb-ot-cff1-table.hh | 179 ++++++------ .../harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.cc | 28 +- .../harfbuzz/harfbuzz-src/src/hb-ot-cff2-table.hh | 139 ++++----- .../harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh | 30 +- .../harfbuzz-src/src/hb-ot-color-cbdt-table.hh | 8 +- .../harfbuzz-src/src/hb-ot-color-colr-table.hh | 12 +- .../harfbuzz-src/src/hb-ot-color-cpal-table.hh | 10 +- .../harfbuzz-src/src/hb-ot-color-sbix-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-color-svg-table.hh | 4 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc | 8 +- .../harfbuzz/harfbuzz-src/src/hb-ot-gasp-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-glyf-table.hh | 12 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hdmx-table.hh | 8 +- .../harfbuzz/harfbuzz-src/src/hb-ot-head-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hhea-table.hh | 4 +- .../harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh | 20 +- .../harfbuzz/harfbuzz-src/src/hb-ot-kern-table.hh | 14 +- .../harfbuzz-src/src/hb-ot-layout-base-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-layout-common.hh | 34 +-- .../harfbuzz-src/src/hb-ot-layout-gdef-table.hh | 6 +- .../harfbuzz-src/src/hb-ot-layout-gpos-table.hh | 40 +-- .../harfbuzz-src/src/hb-ot-layout-gsub-table.hh | 66 ++--- .../harfbuzz-src/src/hb-ot-layout-gsubgpos.hh | 32 +-- .../harfbuzz-src/src/hb-ot-layout-jstf-table.hh | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc | 20 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-map.cc | 22 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-map.hh | 14 +- .../harfbuzz/harfbuzz-src/src/hb-ot-math-table.hh | 6 +- .../harfbuzz/harfbuzz-src/src/hb-ot-maxp-table.hh | 4 +- .../harfbuzz/harfbuzz-src/src/hb-ot-name-table.hh | 14 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-name.cc | 6 +- .../harfbuzz/harfbuzz-src/src/hb-ot-os2-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh | 12 +- .../src/hb-ot-shape-complex-indic-table.cc | 3 + .../src/hb-ot-shape-complex-use-table.cc | 3 + .../harfbuzz-src/src/hb-ot-shape-fallback.cc | 31 +- .../harfbuzz-src/src/hb-ot-shape-fallback.hh | 3 +- .../libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc | 17 +- .../harfbuzz/harfbuzz-src/src/hb-ot-stat-table.hh | 6 +- .../harfbuzz-src/src/hb-ot-var-avar-table.hh | 2 +- .../harfbuzz-src/src/hb-ot-var-fvar-table.hh | 4 +- .../harfbuzz-src/src/hb-ot-var-hvar-table.hh | 8 +- .../harfbuzz-src/src/hb-ot-var-mvar-table.hh | 2 +- .../harfbuzz/harfbuzz-src/src/hb-ot-vorg-table.hh | 12 +- .../harfbuzz/harfbuzz-src/src/hb-set-digest.hh | 18 +- .../libs/harfbuzz/harfbuzz-src/src/hb-set.hh | 79 ++++-- .../harfbuzz-src/src/hb-subset-cff-common.cc | 18 +- .../harfbuzz-src/src/hb-subset-cff-common.hh | 296 ++++++++++--------- .../harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc | 315 ++++++++++----------- .../harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc | 130 ++++----- .../harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc | 14 +- .../harfbuzz/harfbuzz-src/src/hb-subset-plan.cc | 2 +- .../libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc | 41 +-- .../libs/harfbuzz/harfbuzz-src/src/hb-vector.hh | 97 +++---- Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh | 131 ++++++++- .../libs/harfbuzz/harfbuzz-src/src/test-iter.cc | 84 ++++++ .../harfbuzz-src/src/test-unicode-ranges.cc | 1 - 102 files changed, 2083 insertions(+), 1788 deletions(-) create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-src/src/test-iter.cc (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src') diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am index 3618d03a2c7..4a130e1524c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am @@ -384,15 +384,23 @@ dump_use_data_SOURCES = dump-use-data.cc hb-ot-shape-complex-use-table.cc dump_use_data_CPPFLAGS = $(HBCFLAGS) dump_use_data_LDADD = libharfbuzz.la $(HBLIBS) -check_PROGRAMS += test-ot-tag test-unicode-ranges -TESTS += test-ot-tag test-unicode-ranges +COMPILED_TESTS = test-iter test-ot-tag test-unicode-ranges +COMPILED_TESTS_CPPFLAGS = $(HBCFLAGS) -DMAIN -UNDEBUG +COMPILED_TESTS_LDADD = libharfbuzz.la $(HBLIBS) +check_PROGRAMS += $(COMPILED_TESTS) +TESTS += $(COMPILED_TESTS) + +test_iter_SOURCES = test-iter.cc hb-static.cc +test_iter_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS) +test_iter_LDADD = $(COMPILED_TESTS_LDADD) test_ot_tag_SOURCES = hb-ot-tag.cc -test_ot_tag_CPPFLAGS = $(HBCFLAGS) -DMAIN -test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS) +test_ot_tag_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS) +test_ot_tag_LDADD = $(COMPILED_TESTS_LDADD) test_unicode_ranges_SOURCES = test-unicode-ranges.cc -test_unicode_ranges_LDADD = libharfbuzz.la $(HBLIBS) +test_unicode_ranges_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS) +test_unicode_ranges_LDADD = $(COMPILED_TESTS_LDADD) TESTS_ENVIRONMENT = \ srcdir="$(srcdir)" \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources index 98b62288978..0da4abe05b1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.sources @@ -36,6 +36,7 @@ HB_BASE_sources = \ hb-face.hh \ hb-font.cc \ hb-font.hh \ + hb-iter.hh \ hb-kern.hh \ hb-machinery.hh \ hb-map.cc \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py index e65b9814adf..6532ee7e0f7 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-indic-table.py @@ -131,6 +131,8 @@ for i in range (2): what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"] what_short = ["ISC", "IMC"] +print ('#pragma GCC diagnostic push') +print ('#pragma GCC diagnostic ignored "-Wunused-macros"') for i in range (2): print () vv = sorted (values[i].keys ()) @@ -148,6 +150,7 @@ for i in range (2): (what_short[i], s, what[i], v.upper (), ' '* ((48-1 - len (what[i]) - 1 - len (v)) // 8), values[i][v], v)) +print ('#pragma GCC diagnostic pop') print () print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)") print () diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-os2-unicode-ranges.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-os2-unicode-ranges.py index d768313ddde..8cf59858802 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-os2-unicode-ranges.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-os2-unicode-ranges.py @@ -10,8 +10,11 @@ import io import re import sys -reload(sys) -sys.setdefaultencoding('utf-8') +try: + reload(sys) + sys.setdefaultencoding('utf-8') +except NameError: + pass # Python 3 print ("""static OS2Range _hb_os2_unicode_ranges[] = {""") @@ -32,12 +35,12 @@ with io.open(input_file, mode="r", encoding="utf-8") as f: current_bit = fields[0] fields = fields[1:] elif len(fields) > 3: - raise Error("bad input :(.") + raise Exception("bad input :(.") name = fields[0] ranges = re.split("-", fields[1]) if len(ranges) != 2: - raise Error("bad input :(.") + raise Exception("bad input :(.") v = tuple((int(ranges[0], 16), int(ranges[1], 16), int(current_bit), name)) all_ranges.append(v) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py index 099f6a18518..be204b60bce 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/gen-use-table.py @@ -1,8 +1,10 @@ #!/usr/bin/env python +# flake8: noqa from __future__ import print_function, division, absolute_import -import io, sys +import io +import sys if len (sys.argv) != 5: print ("usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt", file=sys.stderr) @@ -453,6 +455,8 @@ num = 0 offset = 0 starts = [] ends = [] +print ('#pragma GCC diagnostic push') +print ('#pragma GCC diagnostic ignored "-Wunused-macros"') for k,v in sorted(use_mapping.items()): if k in use_positions and use_positions[k]: continue print ("#define %s USE_%s /* %s */" % (k, k, v.__name__[3:])) @@ -461,6 +465,7 @@ for k,v in sorted(use_positions.items()): for suf in v.keys(): tag = k + suf print ("#define %s USE_%s" % (tag, tag)) +print ('#pragma GCC diagnostic pop') print ("") print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {") for u in uu: 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 index a1af595f9ff..1188e352f03 100644 --- 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 @@ -74,7 +74,7 @@ struct FontDescriptor struct fdsc { - enum { tableTag = HB_AAT_TAG_fdsc }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_fdsc; enum { Weight = HB_TAG ('w','g','h','t'), 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 4235b363a1f..236e4aaf1e3 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 @@ -58,20 +58,16 @@ typedef LArrayOf GlyphAnchors; struct ankr { - enum { tableTag = HB_AAT_TAG_ankr }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_ankr; const Anchor &get_anchor (hb_codepoint_t glyph_id, unsigned int i, - unsigned int num_glyphs, - const char *end) const + unsigned int num_glyphs) const { - const Offset *offset = (this+lookupTable).get_value (glyph_id, num_glyphs); + const NNOffsetTo *offset = (this+lookupTable).get_value (glyph_id, num_glyphs); if (!offset) return Null(Anchor); - const GlyphAnchors &anchors = StructAtOffset (&(this+anchorData), *offset); - /* TODO Use sanitizer; to avoid overflows and more. */ - if (unlikely ((const char *) &anchors + anchors.get_size () > end)) - return Null(Anchor); + const GlyphAnchors &anchors = &(this+anchorData) + *offset; return anchors[i]; } @@ -80,15 +76,15 @@ struct ankr TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && version == 0 && - lookupTable.sanitize (c, this))); + lookupTable.sanitize (c, this, &(this+anchorData)))); } protected: HBUINT16 version; /* Version number (set to zero) */ HBUINT16 flags; /* Flags (currently unused; set to zero) */ - LOffsetTo >, false> + LOffsetTo > > lookupTable; /* Offset to the table's lookup table */ - LOffsetTo + LNNOffsetTo anchorData; /* Offset to the glyph data table */ public: 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 5bc59cbb10a..9139d28183c 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 @@ -116,7 +116,7 @@ struct BaselineTableFormat3Part struct bsln { - enum { tableTag = HB_AAT_TAG_bsln }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_bsln; bool sanitize (hb_sanitize_context_t *c) const { 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 95d6b312ab5..27ade28fe19 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 @@ -77,7 +77,7 @@ struct LookupFormat0 template struct LookupSegmentSingle { - enum { TerminationWordCount = 2 }; + static constexpr unsigned TerminationWordCount = 2u; int cmp (hb_codepoint_t g) const { return g < first ? -1 : g <= last ? 0 : +1 ; } @@ -136,7 +136,7 @@ struct LookupFormat2 template struct LookupSegmentArray { - enum { TerminationWordCount = 2 }; + static constexpr unsigned TerminationWordCount = 2u; const T* get_value (hb_codepoint_t glyph_id, const void *base) const { @@ -164,7 +164,7 @@ struct LookupSegmentArray GlyphID last; /* Last GlyphID in this segment */ GlyphID first; /* First GlyphID in this segment */ - OffsetTo, HBUINT16, false> + NNOffsetTo > valuesZ; /* A 16-bit offset from the start of * the table to the data. */ public: @@ -207,7 +207,7 @@ struct LookupFormat4 template struct LookupSingle { - enum { TerminationWordCount = 1 }; + static constexpr unsigned TerminationWordCount = 1u; int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } @@ -394,7 +394,7 @@ struct Lookup case 4: return_trace (u.format4.sanitize (c, base)); case 6: return_trace (u.format6.sanitize (c, base)); case 8: return_trace (u.format8.sanitize (c, base)); - case 10: return_trace (false); /* No need to support format10 apparently */ + case 10: return_trace (false); /* We don't support format10 here currently. */ default:return_trace (true); } } @@ -511,9 +511,10 @@ struct StateTable const Entry *get_entries () const { return (this+entryTable).arrayZ; } - const Entry *get_entryZ (int state, unsigned int klass) const + const Entry &get_entry (int state, unsigned int klass) const { - if (unlikely (klass >= nClasses)) return nullptr; + if (unlikely (klass >= nClasses)) + klass = StateTable >::CLASS_OUT_OF_BOUNDS; const HBUSHORT *states = (this+stateArrayTable).arrayZ; const Entry *entries = (this+entryTable).arrayZ; @@ -521,7 +522,7 @@ struct StateTable unsigned int entry = states[state * nClasses + klass]; DEBUG_MSG (APPLY, nullptr, "e%u", entry); - return &entries[entry]; + return entries[entry]; } bool sanitize (hb_sanitize_context_t *c, @@ -529,6 +530,7 @@ struct StateTable { TRACE_SANITIZE (this); if (unlikely (!(c->check_struct (this) && + nClasses >= 4 /* Ensure pre-defined classes fit. */ && classTable.sanitize (c, this)))) return_trace (false); const HBUSHORT *states = (this+stateArrayTable).arrayZ; @@ -571,7 +573,7 @@ struct StateTable -min_state, row_stride))) return_trace (false); - if ((c->max_ops -= state_neg - min_state) < 0) + if ((c->max_ops -= state_neg - min_state) <= 0) return_trace (false); { /* Sweep new states. */ const HBUSHORT *stop = &states[min_state * num_classes]; @@ -590,7 +592,7 @@ struct StateTable max_state + 1, row_stride))) return_trace (false); - if ((c->max_ops -= max_state - state_pos + 1) < 0) + if ((c->max_ops -= max_state - state_pos + 1) <= 0) return_trace (false); { /* Sweep new states. */ if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes))) @@ -606,7 +608,7 @@ struct StateTable if (unlikely (!c->check_array (entries, num_entries))) return_trace (false); - if ((c->max_ops -= num_entries - entry) < 0) + if ((c->max_ops -= num_entries - entry) <= 0) return_trace (false); { /* Sweep new entries. */ const Entry *stop = &entries[num_entries]; @@ -629,11 +631,11 @@ struct StateTable protected: HBUINT nClasses; /* Number of classes, which is the number of indices * in a single line in the state array. */ - OffsetTo + NNOffsetTo classTable; /* Offset to the class table. */ - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> stateArrayTable;/* Offset to the state array. */ - OffsetTo >, HBUINT, false> + NNOffsetTo >, HBUINT> entryTable; /* Offset to the entry array. */ public: @@ -669,7 +671,7 @@ struct ClassTable struct ObsoleteTypes { - enum { extended = false }; + static constexpr bool extended = false; typedef HBUINT16 HBUINT; typedef HBUINT8 HBUSHORT; typedef ClassTable ClassTypeNarrow; @@ -699,7 +701,7 @@ struct ObsoleteTypes }; struct ExtendedTypes { - enum { extended = true }; + static constexpr bool extended = true; typedef HBUINT32 HBUINT; typedef HBUINT16 HBUSHORT; typedef Lookup ClassTypeNarrow; @@ -707,22 +709,22 @@ struct ExtendedTypes template static unsigned int offsetToIndex (unsigned int offset, - const void *base, - const T *array) + const void *base HB_UNUSED, + const T *array HB_UNUSED) { return offset; } template static unsigned int byteOffsetToIndex (unsigned int offset, - const void *base, - const T *array) + const void *base HB_UNUSED, + const T *array HB_UNUSED) { return offset / 2; } template static unsigned int wordOffsetToIndex (unsigned int offset, - const void *base, - const T *array) + const void *base HB_UNUSED, + const T *array HB_UNUSED) { return offset; } @@ -745,16 +747,13 @@ struct StateTableDriver buffer->clear_output (); int state = StateTable::STATE_START_OF_TEXT; - bool last_was_dont_advance = false; for (buffer->idx = 0; buffer->successful;) { unsigned int klass = buffer->idx < buffer->len ? machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) : (unsigned) StateTable::CLASS_END_OF_TEXT; DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx); - const Entry *entry = machine.get_entryZ (state, klass); - if (unlikely (!entry)) - break; + const Entry &entry = machine.get_entry (state, klass); /* Unsafe-to-break before this if not in state 0, as things might * go differently if we start from state 0 here. @@ -765,31 +764,28 @@ struct StateTableDriver /* If there's no action and we're just epsilon-transitioning to state 0, * safe to break. */ if (c->is_actionable (this, entry) || - !(entry->newState == StateTable::STATE_START_OF_TEXT && - entry->flags == context_t::DontAdvance)) + !(entry.newState == StateTable::STATE_START_OF_TEXT && + entry.flags == context_t::DontAdvance)) buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1); } /* Unsafe-to-break if end-of-text would kick in here. */ if (buffer->idx + 2 <= buffer->len) { - const Entry *end_entry = machine.get_entryZ (state, 0); + const Entry &end_entry = machine.get_entry (state, StateTable::CLASS_END_OF_TEXT); if (c->is_actionable (this, end_entry)) buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); } - if (unlikely (!c->transition (this, entry))) - break; - - last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0; + c->transition (this, entry); - state = machine.new_state (entry->newState); + state = machine.new_state (entry.newState); DEBUG_MSG (APPLY, nullptr, "s%d", state); if (buffer->idx == buffer->len) break; - if (!last_was_dont_advance) + if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0) buffer->next_glyph (); } @@ -825,7 +821,6 @@ struct hb_aat_apply_context_t : hb_buffer_t *buffer; hb_sanitize_context_t sanitizer; const ankr *ankr_table; - const char *ankr_end; /* Unused. For debug tracing only. */ unsigned int lookup_index; @@ -838,7 +833,7 @@ struct hb_aat_apply_context_t : HB_INTERNAL ~hb_aat_apply_context_t (); - HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_, const char *ankr_end_); + HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_); 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 63c69a20f9f..ab23ee05693 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 @@ -118,11 +118,10 @@ struct FeatureName if (selectors_count) { hb_array_t arr = settings_table.sub_array (start_offset, selectors_count); - unsigned int count = arr.len; - for (unsigned int i = 0; i < count; i++) + for (unsigned int i = 0; i < arr.length; i++) settings_table[start_offset + i].get_info (&selectors[i], default_selector); } - return settings_table.len; + return settings_table.length; } hb_aat_layout_feature_type_t get_feature_type () const @@ -155,7 +154,7 @@ struct FeatureName struct feat { - enum { tableTag = HB_AAT_TAG_feat }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_feat; bool has_data () const { return version.to_int (); } 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 d39945abd6b..d53f8f19eff 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 @@ -382,7 +382,7 @@ struct JustificationHeader struct just { - enum { tableTag = HB_AAT_TAG_just }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_just; bool sanitize (hb_sanitize_context_t *c) const { 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 291f3e35b40..a64c8073819 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 @@ -170,11 +170,11 @@ struct Format1Entry DEFINE_SIZE_STATIC (2); }; - static bool performAction (const Entry *entry) - { return entry->data.kernActionIndex != 0xFFFF; } + static bool performAction (const Entry &entry) + { return entry.data.kernActionIndex != 0xFFFF; } - static unsigned int kernActionIndex (const Entry *entry) - { return entry->data.kernActionIndex; } + static unsigned int kernActionIndex (const Entry &entry) + { return entry.data.kernActionIndex; } }; template <> struct Format1Entry @@ -192,11 +192,11 @@ struct Format1Entry typedef void EntryData; - static bool performAction (const Entry *entry) - { return entry->flags & Offset; } + static bool performAction (const Entry &entry) + { return entry.flags & Offset; } - static unsigned int kernActionIndex (const Entry *entry) - { return entry->flags & Offset; } + static unsigned int kernActionIndex (const Entry &entry) + { return entry.flags & Offset; } }; template @@ -210,7 +210,7 @@ struct KerxSubTableFormat1 struct driver_context_t { - enum { in_place = true }; + static constexpr bool in_place = true; enum { DontAdvance = Format1EntryT::DontAdvance, @@ -228,15 +228,15 @@ struct KerxSubTableFormat1 crossStream (table->header.coverage & table->header.CrossStream) {} bool is_actionable (StateTableDriver *driver HB_UNUSED, - const Entry *entry) + const Entry &entry) { return Format1EntryT::performAction (entry); } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; - unsigned int flags = entry->flags; + unsigned int flags = entry.flags; if (flags & Format1EntryT::Reset) depth = 0; @@ -259,7 +259,7 @@ struct KerxSubTableFormat1 if (!c->sanitizer.check_array (actions, depth, tuple_count)) { depth = 0; - return false; + return; } hb_mask_t kern_mask = c->plan->kern_mask; @@ -334,8 +334,6 @@ struct KerxSubTableFormat1 } } } - - return true; } private: @@ -374,7 +372,7 @@ struct KerxSubTableFormat1 protected: KernSubTableHeader header; StateTable machine; - OffsetTo, HBUINT, false>kernAction; + NNOffsetTo, HBUINT> kernAction; public: DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 5 * sizeof (HBUINT)); }; @@ -443,13 +441,13 @@ struct KerxSubTableFormat2 protected: KernSubTableHeader header; HBUINT rowWidth; /* The width, in bytes, of a row in the table. */ - OffsetTo + NNOffsetTo leftClassTable; /* Offset from beginning of this subtable to * left-hand class table. */ - OffsetTo + NNOffsetTo rightClassTable;/* Offset from beginning of this subtable to * right-hand class table. */ - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> array; /* Offset from beginning of this subtable to * the start of the kerning array. */ public: @@ -471,7 +469,7 @@ struct KerxSubTableFormat4 struct driver_context_t { - enum { in_place = true }; + static constexpr bool in_place = true; enum Flags { Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */ @@ -498,16 +496,16 @@ struct KerxSubTableFormat4 mark (0) {} bool is_actionable (StateTableDriver *driver HB_UNUSED, - const Entry *entry) + const Entry &entry) { - return entry->data.ankrActionIndex != 0xFFFF; + return entry.data.ankrActionIndex != 0xFFFF; } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; - if (mark_set && entry->data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len) + if (mark_set && entry.data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len) { hb_glyph_position_t &o = buffer->cur_pos(); switch (action_type) @@ -515,9 +513,8 @@ struct KerxSubTableFormat4 case 0: /* Control Point Actions.*/ { /* indexed into glyph outline. */ - const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; - if (!c->sanitizer.check_array (data, 2)) - return false; + const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex]; + if (!c->sanitizer.check_array (data, 2)) return; HB_UNUSED unsigned int markControlPoint = *data++; HB_UNUSED unsigned int currControlPoint = *data++; hb_position_t markX = 0; @@ -532,7 +529,7 @@ struct KerxSubTableFormat4 currControlPoint, HB_DIRECTION_LTR /*XXX*/, &currX, &currY)) - return true; /* True, such that the machine continues. */ + return; o.x_offset = markX - currX; o.y_offset = markY - currY; @@ -542,19 +539,16 @@ struct KerxSubTableFormat4 case 1: /* Anchor Point Actions. */ { /* Indexed into 'ankr' table. */ - const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; - if (!c->sanitizer.check_array (data, 2)) - return false; + const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex]; + if (!c->sanitizer.check_array (data, 2)) return; unsigned int markAnchorPoint = *data++; unsigned int currAnchorPoint = *data++; - const Anchor markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint, - markAnchorPoint, - c->sanitizer.get_num_glyphs (), - c->ankr_end); - const Anchor currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint, - currAnchorPoint, - c->sanitizer.get_num_glyphs (), - c->ankr_end); + const Anchor &markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint, + markAnchorPoint, + c->sanitizer.get_num_glyphs ()); + const Anchor &currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint, + currAnchorPoint, + c->sanitizer.get_num_glyphs ()); o.x_offset = c->font->em_scale_x (markAnchor.xCoordinate) - c->font->em_scale_x (currAnchor.xCoordinate); o.y_offset = c->font->em_scale_y (markAnchor.yCoordinate) - c->font->em_scale_y (currAnchor.yCoordinate); @@ -563,9 +557,8 @@ struct KerxSubTableFormat4 case 2: /* Control Point Coordinate Actions. */ { - const FWORD *data = (const FWORD *) &ankrData[entry->data.ankrActionIndex]; - if (!c->sanitizer.check_array (data, 4)) - return false; + const FWORD *data = (const FWORD *) &ankrData[entry.data.ankrActionIndex]; + if (!c->sanitizer.check_array (data, 4)) return; int markX = *data++; int markY = *data++; int currX = *data++; @@ -581,13 +574,11 @@ struct KerxSubTableFormat4 buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT; } - if (entry->flags & Mark) + if (entry.flags & Mark) { mark_set = true; mark = buffer->idx; } - - return true; } private: @@ -721,18 +712,18 @@ struct KerxSubTableFormat6 { struct Long { - LOffsetTo, false> rowIndexTable; - LOffsetTo, false> columnIndexTable; - LOffsetTo, false> array; + LNNOffsetTo > rowIndexTable; + LNNOffsetTo > columnIndexTable; + LNNOffsetTo > array; } l; struct Short { - LOffsetTo, false> rowIndexTable; - LOffsetTo, false> columnIndexTable; - LOffsetTo, false> array; + LNNOffsetTo > rowIndexTable; + LNNOffsetTo > columnIndexTable; + LNNOffsetTo > array; } s; } u; - LOffsetTo, false> vector; + LNNOffsetTo > vector; public: DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24); }; @@ -981,8 +972,8 @@ struct kerx : KerxTable { friend struct KerxTable; - enum { tableTag = HB_AAT_TAG_kerx }; - enum { minVersion = 2u }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_kerx; + static constexpr unsigned minVersion = 2u; typedef KerxSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; 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 cac96971721..4be799fbca2 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,7 +40,7 @@ typedef ArrayOf LigCaretClassEntry; struct lcar { - enum { tableTag = HB_AAT_TAG_lcar }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_lcar; unsigned int get_lig_carets (hb_font_t *font, hb_direction_t direction, @@ -55,7 +55,7 @@ struct lcar if (caret_count) { hb_array_t arr = array.sub_array (start_offset, caret_count); - unsigned int count = arr.len; + unsigned int count = arr.length; for (unsigned int i = 0; i < count; ++i) switch (format) { 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 c7600aa25dc..4a1d959efec 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 { - enum { in_place = true }; + static constexpr bool in_place = true; enum Flags { MarkFirst = 0x8000, /* If set, make the current glyph the first @@ -74,15 +74,15 @@ struct RearrangementSubtable start (0), end (0) {} bool is_actionable (StateTableDriver *driver HB_UNUSED, - const Entry *entry) + const Entry &entry) { - return (entry->flags & Verb) && start < end; + return (entry.flags & Verb) && start < end; } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; - unsigned int flags = entry->flags; + unsigned int flags = entry.flags; if (flags & MarkFirst) start = buffer->idx; @@ -152,8 +152,6 @@ struct RearrangementSubtable } } } - - return true; } public: @@ -204,7 +202,7 @@ struct ContextualSubtable struct driver_context_t { - enum { in_place = true }; + static constexpr bool in_place = true; enum Flags { SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ @@ -223,39 +221,39 @@ struct ContextualSubtable subs (table+table->substitutionTables) {} bool is_actionable (StateTableDriver *driver, - const Entry *entry) + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; if (buffer->idx == buffer->len && !mark_set) return false; - return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF; + return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF; } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; /* Looks like CoreText applies neither mark nor current substitution for * end-of-text if mark was not explicitly set. */ if (buffer->idx == buffer->len && !mark_set) - return true; + return; const GlyphID *replacement; replacement = nullptr; if (Types::extended) { - if (entry->data.markIndex != 0xFFFF) + if (entry.data.markIndex != 0xFFFF) { - const Lookup &lookup = subs[entry->data.markIndex]; + const Lookup &lookup = subs[entry.data.markIndex]; replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs); } } else { - unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint; + unsigned int offset = entry.data.markIndex + buffer->info[mark].codepoint; const UnsizedArrayOf &subs_old = (const UnsizedArrayOf &) subs; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; if (!replacement->sanitize (&c->sanitizer) || !*replacement) @@ -272,15 +270,15 @@ struct ContextualSubtable unsigned int idx = MIN (buffer->idx, buffer->len - 1); if (Types::extended) { - if (entry->data.currentIndex != 0xFFFF) + if (entry.data.currentIndex != 0xFFFF) { - const Lookup &lookup = subs[entry->data.currentIndex]; + const Lookup &lookup = subs[entry.data.currentIndex]; replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs); } } else { - unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint; + unsigned int offset = entry.data.currentIndex + buffer->info[idx].codepoint; const UnsizedArrayOf &subs_old = (const UnsizedArrayOf &) subs; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; if (!replacement->sanitize (&c->sanitizer) || !*replacement) @@ -292,13 +290,11 @@ struct ContextualSubtable ret = true; } - if (entry->flags & SetMark) + if (entry.flags & SetMark) { mark_set = true; mark = buffer->idx; } - - return true; } public: @@ -330,7 +326,8 @@ struct ContextualSubtable unsigned int num_entries = 0; if (unlikely (!machine.sanitize (c, &num_entries))) return_trace (false); - if (!Types::extended) return_trace (true); + if (!Types::extended) + return_trace (substitutionTables.sanitize (c, this, 0)); unsigned int num_lookups = 0; @@ -351,7 +348,7 @@ struct ContextualSubtable protected: StateTable machine; - OffsetTo, HBUINT, false>, HBUINT, false> + NNOffsetTo, HBUINT, false>, HBUINT> substitutionTables; public: DEFINE_SIZE_STATIC (20); @@ -384,11 +381,11 @@ struct LigatureEntry DEFINE_SIZE_STATIC (2); }; - static bool performAction (const Entry *entry) - { return entry->flags & PerformAction; } + static bool performAction (const Entry &entry) + { return entry.flags & PerformAction; } - static unsigned int ligActionIndex (const Entry *entry) - { return entry->data.ligActionIndex; } + static unsigned int ligActionIndex (const Entry &entry) + { return entry.data.ligActionIndex; } }; template <> struct LigatureEntry @@ -406,11 +403,11 @@ struct LigatureEntry typedef void EntryData; - static bool performAction (const Entry *entry) - { return entry->flags & Offset; } + static bool performAction (const Entry &entry) + { return entry.flags & Offset; } - static unsigned int ligActionIndex (const Entry *entry) - { return entry->flags & Offset; } + static unsigned int ligActionIndex (const Entry &entry) + { return entry.flags & Offset; } }; @@ -424,7 +421,7 @@ struct LigatureSubtable struct driver_context_t { - enum { in_place = false }; + static constexpr bool in_place = false; enum { DontAdvance = LigatureEntryT::DontAdvance, @@ -452,26 +449,23 @@ struct LigatureSubtable match_length (0) {} bool is_actionable (StateTableDriver *driver HB_UNUSED, - const Entry *entry) + const Entry &entry) { return LigatureEntryT::performAction (entry); } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; DEBUG_MSG (APPLY, nullptr, "Ligature transition at %u", buffer->idx); - if (entry->flags & LigatureEntryT::SetComponent) + if (entry.flags & LigatureEntryT::SetComponent) { - if (unlikely (match_length >= ARRAY_LENGTH (match_positions))) - return false; - /* Never mark same index twice, in case DontAdvance was used... */ - if (match_length && match_positions[match_length - 1] == buffer->out_len) + if (match_length && match_positions[(match_length - 1u) % ARRAY_LENGTH (match_positions)] == buffer->out_len) match_length--; - match_positions[match_length++] = buffer->out_len; + match_positions[match_length++ % ARRAY_LENGTH (match_positions)] = buffer->out_len; DEBUG_MSG (APPLY, nullptr, "Set component at %u", buffer->out_len); } @@ -481,10 +475,10 @@ struct LigatureSubtable unsigned int end = buffer->out_len; if (unlikely (!match_length)) - return true; + return; if (buffer->idx >= buffer->len) - return false; // TODO Work on previous instead? + return; /* TODO Work on previous instead? */ unsigned int cursor = match_length; @@ -505,9 +499,9 @@ struct LigatureSubtable } DEBUG_MSG (APPLY, nullptr, "Moving to stack position %u", cursor - 1); - buffer->move_to (match_positions[--cursor]); + buffer->move_to (match_positions[--cursor % ARRAY_LENGTH (match_positions)]); - if (unlikely (!actionData->sanitize (&c->sanitizer))) return false; + if (unlikely (!actionData->sanitize (&c->sanitizer))) break; action = *actionData; uint32_t uoffset = action & LigActionOffset; @@ -517,7 +511,7 @@ struct LigatureSubtable unsigned int component_idx = buffer->cur().codepoint + offset; component_idx = Types::wordOffsetToIndex (component_idx, table, component.arrayZ); const HBUINT16 &componentData = component[component_idx]; - if (unlikely (!componentData.sanitize (&c->sanitizer))) return false; + if (unlikely (!componentData.sanitize (&c->sanitizer))) break; ligature_idx += componentData; DEBUG_MSG (APPLY, nullptr, "Action store %u last %u", @@ -527,23 +521,23 @@ struct LigatureSubtable { ligature_idx = Types::offsetToIndex (ligature_idx, table, ligature.arrayZ); const GlyphID &ligatureData = ligature[ligature_idx]; - if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false; + if (unlikely (!ligatureData.sanitize (&c->sanitizer))) break; hb_codepoint_t lig = ligatureData; DEBUG_MSG (APPLY, nullptr, "Produced ligature %u", lig); buffer->replace_glyph (lig); - unsigned int lig_end = match_positions[match_length - 1] + 1; + unsigned int lig_end = match_positions[(match_length - 1u) % ARRAY_LENGTH (match_positions)] + 1u; /* Now go and delete all subsequent components. */ - while (match_length - 1 > cursor) + while (match_length - 1u > cursor) { DEBUG_MSG (APPLY, nullptr, "Skipping ligature component"); - buffer->move_to (match_positions[--match_length]); + buffer->move_to (match_positions[--match_length % ARRAY_LENGTH (match_positions)]); buffer->replace_glyph (DELETED_GLYPH); } buffer->move_to (lig_end); - buffer->merge_out_clusters (match_positions[cursor], buffer->out_len); + buffer->merge_out_clusters (match_positions[cursor % ARRAY_LENGTH (match_positions)], buffer->out_len); } actionData++; @@ -551,8 +545,6 @@ struct LigatureSubtable while (!(action & LigActionLast)); buffer->move_to (end); } - - return true; } public: @@ -590,11 +582,11 @@ struct LigatureSubtable protected: StateTable machine; - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> ligAction; /* Offset to the ligature action table. */ - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> component; /* Offset to the component table. */ - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> ligature; /* Offset to the actual ligature lists. */ public: DEFINE_SIZE_STATIC (28); @@ -660,7 +652,7 @@ struct InsertionSubtable struct driver_context_t { - enum { in_place = false }; + static constexpr bool in_place = false; enum Flags { SetMark = 0x8000, /* If set, mark the current glyph. */ @@ -713,28 +705,29 @@ struct InsertionSubtable hb_aat_apply_context_t *c_) : ret (false), c (c_), - mark_set (false), mark (0), insertionAction (table+table->insertionAction) {} bool is_actionable (StateTableDriver *driver HB_UNUSED, - const Entry *entry) + const Entry &entry) { - return (entry->flags & (CurrentInsertCount | MarkedInsertCount)) && - (entry->data.currentInsertIndex != 0xFFFF ||entry->data.markedInsertIndex != 0xFFFF); + return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) && + (entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF); } - bool transition (StateTableDriver *driver, - const Entry *entry) + void transition (StateTableDriver *driver, + const Entry &entry) { hb_buffer_t *buffer = driver->buffer; - unsigned int flags = entry->flags; + unsigned int flags = entry.flags; + + unsigned mark_loc = buffer->out_len; - if (entry->data.markedInsertIndex != 0xFFFF && mark_set) + if (entry.data.markedInsertIndex != 0xFFFF) { unsigned int count = (flags & MarkedInsertCount); - unsigned int start = entry->data.markedInsertIndex; + unsigned int start = entry.data.markedInsertIndex; const GlyphID *glyphs = &insertionAction[start]; - if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false; + if (unlikely (!c->sanitizer.check_array (glyphs, count))) count = 0; bool before = flags & MarkedInsertBefore; @@ -754,12 +747,15 @@ struct InsertionSubtable buffer->unsafe_to_break_from_outbuffer (mark, MIN (buffer->idx + 1, buffer->len)); } - if (entry->data.currentInsertIndex != 0xFFFF) + if (flags & SetMark) + mark = mark_loc; + + if (entry.data.currentInsertIndex != 0xFFFF) { unsigned int count = (flags & CurrentInsertCount) >> 5; - unsigned int start = entry->data.currentInsertIndex; + unsigned int start = entry.data.currentInsertIndex; const GlyphID *glyphs = &insertionAction[start]; - if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false; + if (unlikely (!c->sanitizer.check_array (glyphs, count))) count = 0; bool before = flags & CurrentInsertBefore; @@ -790,21 +786,12 @@ struct InsertionSubtable */ buffer->move_to ((flags & DontAdvance) ? end : end + count); } - - if (flags & SetMark) - { - mark_set = true; - mark = buffer->out_len; - } - - return true; } public: bool ret; private: hb_aat_apply_context_t *c; - bool mark_set; unsigned int mark; const UnsizedArrayOf &insertionAction; }; @@ -832,7 +819,7 @@ struct InsertionSubtable protected: StateTable machine; - OffsetTo, HBUINT, false> + NNOffsetTo, HBUINT> insertionAction; /* Byte offset from stateHeader to the start of * the insertion glyph table. */ public: @@ -961,7 +948,7 @@ struct Chain hb_aat_layout_feature_type_t type = (hb_aat_layout_feature_type_t) (unsigned int) feature.featureType; hb_aat_layout_feature_selector_t setting = (hb_aat_layout_feature_selector_t) (unsigned int) feature.featureSetting; retry: - const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch ((uint16_t) type); + const hb_aat_map_builder_t::feature_info_t *info = map->features.bsearch (type); if (info && info->setting == setting) { flags &= feature.disableFlags; @@ -1096,7 +1083,7 @@ struct Chain template struct mortmorx { - enum { tableTag = HB_AAT_TAG_morx }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_morx; bool has_data () const { return version != 0; } @@ -1158,11 +1145,11 @@ struct mortmorx struct morx : mortmorx { - enum { tableTag = HB_AAT_TAG_morx }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_morx; }; struct mort : mortmorx { - enum { tableTag = HB_AAT_TAG_mort }; + static constexpr hb_tag_t 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 0648f6175f7..0c8e4558ffc 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 @@ -66,7 +66,7 @@ struct TrackTableEntry NameID trackNameID; /* The 'name' table index for this track. * (a short word or phrase like "loose" * or "very tight") */ - OffsetTo, HBUINT16, false> + NNOffsetTo > valuesZ; /* Offset from start of tracking table to * per-size tracking values for this track. */ @@ -160,7 +160,7 @@ struct TrackData struct trak { - enum { tableTag = HB_AAT_TAG_trak }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_trak; bool has_data () const { return version.to_int (); } 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 8de8205f574..5168a9c85ff 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 @@ -157,7 +157,6 @@ AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *p buffer (buffer_), sanitizer (), ankr_table (&Null(AAT::ankr)), - ankr_end (nullptr), lookup_index (0), debug_depth (0) { @@ -171,12 +170,8 @@ 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_, - const char *ankr_end_) -{ - ankr_table = ankr_table_; - ankr_end = ankr_end_; -} +AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_) +{ ankr_table = ankr_table_; } /* @@ -286,11 +281,8 @@ hb_aat_layout_position (const hb_ot_shape_plan_t *plan, hb_blob_t *kerx_blob = font->face->table.kerx.get_blob (); const AAT::kerx& kerx = *kerx_blob->as (); - hb_blob_t *ankr_blob = font->face->table.ankr.get_blob ();; - const AAT::ankr& ankr = *font->face->table.ankr; - AAT::hb_aat_apply_context_t c (plan, font, buffer, kerx_blob); - c.set_ankr_table (&ankr, ankr_blob->data + ankr_blob->length); + c.set_ankr_table (font->face->table.ankr.get ()); kerx.apply (&c); } 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 3b00b55914e..6f34a0095a0 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 @@ -50,7 +50,7 @@ struct FTStringRange } protected: - OffsetTo, HBUINT16, false> + NNOffsetTo > tag; /* Offset from the start of the table to * the beginning of the string */ HBUINT16 length; /* String length (in bytes) */ @@ -60,7 +60,7 @@ struct FTStringRange struct ltag { - enum { tableTag = HB_AAT_TAG_ltag }; + static constexpr hb_tag_t tableTag = HB_AAT_TAG_ltag; hb_language_t get_language (unsigned int i) const { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc index 1c65a6759bc..98c5d7fe4d7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-map.cc @@ -54,11 +54,11 @@ void hb_aat_map_builder_t::compile (hb_aat_map_t &m) { /* Sort features and merge duplicates */ - if (features.len) + if (features.length) { features.qsort (); unsigned int j = 0; - for (unsigned int i = 1; i < features.len; i++) + for (unsigned int i = 1; i < features.length; i++) if (features[i].type != features[j].type) features[++j] = features[i]; features.shrink (j + 1); 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 fa312dbec39..3d5ad0e642f 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 @@ -44,7 +44,7 @@ struct hb_aat_map_t void fini () { chain_flags.fini (); } public: - hb_vector_t chain_flags; + hb_vector_t chain_flags; }; struct hb_aat_map_builder_t @@ -74,7 +74,7 @@ struct hb_aat_map_builder_t (a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0); } - int cmp (unsigned int ty) const + int cmp (hb_aat_layout_feature_type_t ty) const { return (type != ty) ? (type < ty ? -1 : 1) : 0; } @@ -84,7 +84,7 @@ struct hb_aat_map_builder_t hb_face_t *face; public: - hb_vector_t features; + hb_vector_t features; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh index d4df16546cd..52b775e9569 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh @@ -28,67 +28,57 @@ #define HB_ARRAY_HH #include "hb.hh" +#include "hb-dsalgs.hh" +#include "hb-iter.hh" +#include "hb-null.hh" template struct hb_sorted_array_t; template -struct hb_array_t +struct hb_array_t : + hb_iter_t, Type>, + hb_iter_mixin_t, Type> { - 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 hb_array_t (Type (&array_)[len_]) : arrayZ (array_), len (len_) {} + hb_array_t () : arrayZ (nullptr), length (0) {} + hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {} + template hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {} + /* - * Operators. + * Iterator implementation. */ - - Type& operator [] (int i_) const + typedef Type __item_type__; + Type& __item_at__ (unsigned i) const { - unsigned int i = (unsigned int) i_; - if (unlikely (i >= len)) return CrapOrNull(Type); + if (unlikely (i >= length)) 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 () { return hb_array_t (arrayZ, len); } - template operator T * () const { return arrayZ; } - - hb_array_t & operator += (unsigned int count) + void __forward__ (unsigned n) { - if (unlikely (count > len)) - count = len; - len -= count; - arrayZ += count; - return *this; + if (unlikely (n > length)) + n = length; + length -= n; + arrayZ += n; } - hb_array_t & operator -= (unsigned int count) + void __rewind__ (unsigned n) { - if (unlikely (count > len)) - count = len; - len -= count; - return *this; + if (unlikely (n > length)) + n = length; + length -= n; } - hb_array_t & operator ++ () { *this += 1; } - hb_array_t & operator -- () { *this -= 1; } - hb_array_t operator + (unsigned int count) - { hb_array_t copy (*this); *this += count; return copy; } - hb_array_t operator - (unsigned int count) - { hb_array_t copy (*this); *this -= count; return copy; } - hb_array_t operator ++ (int) - { hb_array_t copy (*this); ++*this; return copy; } - hb_array_t operator -- (int) - { hb_array_t copy (*this); --*this; return copy; } + unsigned __len__ () const { return length; } + bool __random_access__ () const { return true; } + + /* Extra operators. + */ + Type * operator & () const { return arrayZ; } + operator hb_array_t () { return hb_array_t (arrayZ, length); } + template operator T * () const { return arrayZ; } /* * Compare, Sort, and Search. @@ -97,8 +87,8 @@ struct hb_array_t /* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */ int cmp (const hb_array_t &a) const { - if (len != a.len) - return (int) a.len - (int) len; + if (length != a.length) + return (int) a.length - (int) length; return hb_memcmp (a.arrayZ, arrayZ, get_size ()); } static int cmp (const void *pa, const void *pb) @@ -111,7 +101,7 @@ struct hb_array_t template Type *lsearch (const T &x, Type *not_found = nullptr) { - unsigned int count = len; + unsigned int count = length; for (unsigned int i = 0; i < count; i++) if (!this->arrayZ[i].cmp (x)) return &this->arrayZ[i]; @@ -120,7 +110,7 @@ struct hb_array_t template const Type *lsearch (const T &x, const Type *not_found = nullptr) const { - unsigned int count = len; + unsigned int count = length; for (unsigned int i = 0; i < count; i++) if (!this->arrayZ[i].cmp (x)) return &this->arrayZ[i]; @@ -129,33 +119,36 @@ struct hb_array_t hb_sorted_array_t qsort (int (*cmp_)(const void*, const void*)) { - ::qsort (arrayZ, len, item_size, cmp_); + if (likely (length)) + ::qsort (arrayZ, length, this->item_size, cmp_); return hb_sorted_array_t (*this); } hb_sorted_array_t qsort () { - ::qsort (arrayZ, len, item_size, Type::cmp); + if (likely (length)) + ::qsort (arrayZ, length, this->item_size, Type::cmp); return hb_sorted_array_t (*this); } void qsort (unsigned int start, unsigned int end) { - end = MIN (end, len); + end = MIN (end, length); assert (start <= end); - ::qsort (arrayZ + start, end - start, item_size, Type::cmp); + if (likely (start < end)) + ::qsort (arrayZ + start, end - start, this->item_size, Type::cmp); } /* * Other methods. */ - unsigned int get_size () const { return len * item_size; } + unsigned int get_size () const { return length * this->item_size; } hb_array_t 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; + unsigned int count = length; if (unlikely (start_offset > count)) count = 0; else @@ -169,11 +162,11 @@ struct hb_array_t /* Only call if you allocated the underlying array using malloc() or similar. */ void free () - { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } + { ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; } template bool sanitize (hb_sanitize_context_t *c) const - { return c->check_array (arrayZ, len); } + { return c->check_array (arrayZ, length); } /* * Members @@ -181,11 +174,14 @@ struct hb_array_t public: Type *arrayZ; - unsigned int len; + unsigned int length; }; -template -inline hb_array_t hb_array (T *array, unsigned int len) -{ return hb_array_t (array, len); } +template inline hb_array_t +hb_array (T *array, unsigned int length) +{ return hb_array_t (array, length); } +template inline hb_array_t +hb_array (T (&array_)[length_]) +{ return hb_array_t (array_); } enum hb_bfind_not_found_t @@ -196,11 +192,15 @@ enum hb_bfind_not_found_t }; template -struct hb_sorted_array_t : hb_array_t +struct hb_sorted_array_t : + hb_sorted_iter_t, Type>, + hb_array_t, + hb_iter_mixin_t, Type> { hb_sorted_array_t () : hb_array_t () {} hb_sorted_array_t (const hb_array_t &o) : hb_array_t (o) {} - hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t (array_, len_) {} + hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t (array_, length_) {} + template hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t (array_) {} hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const { return hb_sorted_array_t (((const hb_array_t *) (this))->sub_array (start_offset, seg_count)); } @@ -224,7 +224,7 @@ struct hb_sorted_array_t : hb_array_t 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; + int min = 0, max = (int) this->length - 1; const Type *array = this->arrayZ; while (min <= max) { @@ -253,7 +253,7 @@ struct hb_sorted_array_t : hb_array_t break; case HB_BFIND_NOT_FOUND_STORE_CLOSEST: - if (max < 0 || (max < (int) this->len && array[max].cmp (x) > 0)) + if (max < 0 || (max < (int) this->length && array[max].cmp (x) > 0)) max++; *i = max; break; @@ -262,9 +262,12 @@ struct hb_sorted_array_t : hb_array_t return false; } }; -template -inline hb_sorted_array_t hb_sorted_array (T *array, unsigned int len) -{ return hb_sorted_array_t (array, len); } +template inline hb_sorted_array_t +hb_sorted_array (T *array, unsigned int length) +{ return hb_sorted_array_t (array, length); } +template inline hb_sorted_array_t +hb_sorted_array (T (&array_)[length_]) +{ return hb_sorted_array_t (array_); } typedef hb_array_t hb_bytes_t; 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 b53b20bd147..bcf381e1aa4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-blob.cc @@ -25,6 +25,18 @@ * Red Hat Author(s): Behdad Esfahbod */ + +/* https://github.com/harfbuzz/harfbuzz/issues/1308 + * http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html + * https://www.oracle.com/technetwork/articles/servers-storage-dev/standardheaderfiles-453865.html + */ +#ifndef _POSIX_C_SOURCE +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-macros" +#define _POSIX_C_SOURCE 200809L +#pragma GCC diagnostic pop +#endif + #include "hb.hh" #include "hb-blob.hh" diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh index 8a3170ca9a5..330f88bacc9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.hh @@ -119,7 +119,7 @@ struct hb_buffer_t /* Text before / after the main buffer contents. * Always in Unicode, and ordered outward. * Index 0 is for "pre-context", 1 for "post-context". */ - enum { CONTEXT_LENGTH = 5 }; + static constexpr unsigned CONTEXT_LENGTH = 5u; hb_codepoint_t context[2][CONTEXT_LENGTH]; unsigned int context_len[2]; 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 index c2be034a1ce..72e9e06c818 100644 --- 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 @@ -30,7 +30,7 @@ namespace CFF { using namespace OT; -typedef unsigned int OpCode; +typedef unsigned int op_code_t; /* === Dict operators === */ @@ -88,11 +88,11 @@ typedef unsigned int OpCode; /* Two byte escape operators 12, (0-41) */ #define OpCode_ESC_Base 256 -#define Make_OpCode_ESC(byte2) ((OpCode)(OpCode_ESC_Base + (byte2))) +#define Make_OpCode_ESC(byte2) ((op_code_t)(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; } +inline op_code_t Unmake_OpCode_ESC (op_code_t op) { return (op_code_t)(op - OpCode_ESC_Base); } +inline bool Is_OpCode_ESC (op_code_t op) { return op >= OpCode_ESC_Base; } +inline unsigned int OpCode_Size (op_code_t 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) */ @@ -215,7 +215,7 @@ inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1; #define OpCode_Invalid 0xFFFFu -struct Number +struct number_t { void init () { set_real (0.0); } void fini () {} @@ -235,19 +235,19 @@ struct Number bool in_int_range () const { return ((double) (int16_t) to_int () == value); } - bool operator > (const Number &n) const + bool operator > (const number_t &n) const { return value > n.to_real (); } - bool operator < (const Number &n) const + bool operator < (const number_t &n) const { return n > *this; } - bool operator >= (const Number &n) const + bool operator >= (const number_t &n) const { return !(*this < n); } - bool operator <= (const Number &n) const + bool operator <= (const number_t &n) const { return !(*this > n); } - const Number &operator += (const Number &n) + const number_t &operator += (const number_t &n) { set_real (to_real () + n.to_real ()); @@ -263,7 +263,7 @@ struct UnsizedByteStr : UnsizedArrayOf { // encode 2-byte int (Dict/CharString) or 4-byte int (Dict) template - static bool serialize_int (hb_serialize_context_t *c, OpCode intOp, int value) + static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, int value) { TRACE_SERIALIZE (this); @@ -290,92 +290,73 @@ struct UnsizedByteStr : UnsizedArrayOf /* 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 + * byte_str_t, 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 +/* Holder of a section of byte string within a CFFIndex entry */ +struct byte_str_t : hb_ubytes_t { - 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) {} + byte_str_t () + : hb_ubytes_t () {} + byte_str_t (const UnsizedByteStr& s, unsigned int l) + : hb_ubytes_t ((const unsigned char*)&s, l) {} + byte_str_t (const unsigned char *s, unsigned int l) + : hb_ubytes_t (s, l) {} + byte_str_t (const hb_ubytes_t &ub) /* conversion from hb_ubytes_t */ + : hb_ubytes_t (ub) {} + /* 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 (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; } + byte_str_t sub_str (unsigned int offset, unsigned int len_) const + { return byte_str_t (hb_ubytes_t::sub_array (offset, len_)); } bool check_limit (unsigned int offset, unsigned int count) const - { return (offset + count <= len); } - - const UnsizedByteStr *str; - unsigned int len; + { return (offset + count <= length); } }; -struct SubByteStr +/* A byte string associated with the current offset and an error condition */ +struct byte_str_ref_t { - SubByteStr () + byte_str_ref_t () { init (); } void init () { - str = ByteStr (0); + str = byte_str_t (); offset = 0; error = false; } void fini () {} - SubByteStr (const ByteStr &str_, unsigned int offset_ = 0) + byte_str_ref_t (const byte_str_t &str_, unsigned int offset_ = 0) : str (str_), offset (offset_), error (false) {} - void reset (const ByteStr &str_, unsigned int offset_ = 0) + void reset (const byte_str_t &str_, unsigned int offset_ = 0) { str = str_; offset = offset_; error = false; } - const HBUINT8& operator [] (int i) { - if (unlikely ((unsigned int)(offset + i) >= str.len)) + const unsigned char& operator [] (int i) { + if (unlikely ((unsigned int)(offset + i) >= str.length)) { set_error (); - return Null(HBUINT8); + return Null(unsigned char); } else return str[offset + i]; } - operator ByteStr () const { return ByteStr (str, offset, str.len - offset); } + /* Conversion to byte_str_t */ + operator byte_str_t () const { return str.sub_str (offset, str.length - offset); } + + byte_str_t sub_str (unsigned int offset_, unsigned int len_) const + { return str.sub_str (offset_, len_); } bool avail (unsigned int count=1) const { @@ -383,13 +364,13 @@ struct SubByteStr } void inc (unsigned int count=1) { - if (likely (!in_error () && (offset <= str.len) && (offset + count <= str.len))) + if (likely (!in_error () && (offset <= str.length) && (offset + count <= str.length))) { offset += count; } else { - offset = str.len; + offset = str.length; set_error (); } } @@ -397,18 +378,18 @@ struct SubByteStr void set_error () { error = true; } bool in_error () const { return error; } - ByteStr str; + byte_str_t str; unsigned int offset; /* beginning of the sub-string within str */ protected: bool error; }; -typedef hb_vector_t ByteStrArray; +typedef hb_vector_t byte_str_array_t; /* stack */ template -struct Stack +struct stack_t { void init () { @@ -416,7 +397,7 @@ struct Stack count = 0; elements.init (); elements.resize (kSizeLimit); - for (unsigned int i = 0; i < elements.len; i++) + for (unsigned int i = 0; i < elements.length; i++) elements[i].init (); } @@ -433,7 +414,7 @@ struct Stack void push (const ELEM &v) { - if (likely (count < elements.len)) + if (likely (count < elements.length)) elements[count++] = v; else set_error (); @@ -441,7 +422,7 @@ struct Stack ELEM &push () { - if (likely (count < elements.len)) + if (likely (count < elements.length)) return elements[count++]; else { @@ -482,7 +463,7 @@ struct Stack void unpop () { - if (likely (count < elements.len)) + if (likely (count < elements.length)) count++; else set_error (); @@ -496,17 +477,17 @@ struct Stack unsigned int get_count () const { return count; } bool is_empty () const { return count == 0; } - static const unsigned int kSizeLimit = LIMIT; + static constexpr unsigned kSizeLimit = LIMIT; protected: bool error; unsigned int count; - hb_vector_t elements; + hb_vector_t elements; }; /* argument stack */ -template -struct ArgStack : Stack +template +struct arg_stack_t : stack_t { void push_int (int v) { @@ -541,18 +522,18 @@ struct ArgStack : Stack return (unsigned)i; } - void push_longint_from_substr (SubByteStr& substr) + void push_longint_from_substr (byte_str_ref_t& str_ref) { - push_int ((substr[0] << 24) | (substr[1] << 16) | (substr[2] << 8) | (substr[3])); - substr.inc (4); + push_int ((str_ref[0] << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3])); + str_ref.inc (4); } - bool push_fixed_from_substr (SubByteStr& substr) + bool push_fixed_from_substr (byte_str_ref_t& str_ref) { - if (unlikely (!substr.avail (4))) + if (unlikely (!str_ref.avail (4))) return false; - push_fixed ((int32_t)*(const HBUINT32*)&substr[0]); - substr.inc (4); + push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]); + str_ref.inc (4); return true; } @@ -562,36 +543,36 @@ struct ArgStack : Stack } private: - typedef Stack S; + typedef stack_t S; }; /* an operator prefixed by its operands in a byte string */ -struct OpStr +struct op_str_t { void init () {} void fini () {} - OpCode op; - ByteStr str; + op_code_t op; + byte_str_t str; }; /* base of OP_SERIALIZER */ -struct OpSerializer +struct op_serializer_t { protected: - bool copy_opstr (hb_serialize_context_t *c, const OpStr& opstr) const + bool copy_opstr (hb_serialize_context_t *c, const op_str_t& opstr) const { TRACE_SERIALIZE (this); - HBUINT8 *d = c->allocate_size (opstr.str.len); + HBUINT8 *d = c->allocate_size (opstr.str.length); if (unlikely (d == nullptr)) return_trace (false); - memcpy (d, &opstr.str.str[0], opstr.str.len); + memcpy (d, &opstr.str[0], opstr.str.length); return_trace (true); } }; template -struct ParsedValues +struct parsed_values_t { void init () { @@ -600,30 +581,30 @@ struct ParsedValues } void fini () { values.fini_deep (); } - void add_op (OpCode op, const SubByteStr& substr = SubByteStr ()) + void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t ()) { VAL *val = values.push (); val->op = op; - val->str = ByteStr (substr.str, opStart, substr.offset - opStart); - opStart = substr.offset; + val->str = str_ref.str.sub_str (opStart, str_ref.offset - opStart); + opStart = str_ref.offset; } - void add_op (OpCode op, const SubByteStr& substr, const VAL &v) + void add_op (op_code_t op, const byte_str_ref_t& str_ref, const VAL &v) { VAL *val = values.push (v); val->op = op; - val->str = ByteStr (substr.str, opStart, substr.offset - opStart); - opStart = substr.offset; + val->str = str_ref.sub_str ( opStart, str_ref.offset - opStart); + opStart = str_ref.offset; } - bool has_op (OpCode op) const + bool has_op (op_code_t 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; } + unsigned get_count () const { return values.length; } const VAL &get_value (unsigned int i) const { return values[i]; } const VAL &operator [] (unsigned int i) const { return get_value (i); } @@ -631,35 +612,35 @@ struct ParsedValues hb_vector_t values; }; -template -struct InterpEnv +template +struct interp_env_t { - void init (const ByteStr &str_) + void init (const byte_str_t &str_) { - substr.reset (str_); + str_ref.reset (str_); argStack.init (); error = false; } void fini () { argStack.fini (); } bool in_error () const - { return error || substr.in_error () || argStack.in_error (); } + { return error || str_ref.in_error () || argStack.in_error (); } void set_error () { error = true; } - OpCode fetch_op () + op_code_t fetch_op () { - OpCode op = OpCode_Invalid; - if (unlikely (!substr.avail ())) + op_code_t op = OpCode_Invalid; + if (unlikely (!str_ref.avail ())) return OpCode_Invalid; - op = (OpCode)(unsigned char)substr[0]; + op = (op_code_t)(unsigned char)str_ref[0]; if (op == OpCode_escape) { - if (unlikely (!substr.avail ())) + if (unlikely (!str_ref.avail ())) return OpCode_Invalid; - op = Make_OpCode_ESC(substr[1]); - substr.inc (); + op = Make_OpCode_ESC(str_ref[1]); + str_ref.inc (); } - substr.inc (); + str_ref.inc (); return op; } @@ -683,35 +664,35 @@ struct InterpEnv pop_n_args (argStack.get_count ()); } - SubByteStr substr; - ArgStack argStack; + byte_str_ref_t str_ref; + arg_stack_t argStack; protected: bool error; }; -typedef InterpEnv<> NumInterpEnv; +typedef interp_env_t<> num_interp_env_t; -template -struct OpSet +template +struct opset_t { - static void process_op (OpCode op, InterpEnv& env) + static void process_op (op_code_t op, interp_env_t& env) { switch (op) { case OpCode_shortint: - env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1])); - env.substr.inc (2); + env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1])); + env.str_ref.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 (); + env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108)); + env.str_ref.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 (); + env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108)); + env.str_ref.inc (); break; default: @@ -730,9 +711,9 @@ struct OpSet }; template -struct Interpreter { +struct interpreter_t { - ~Interpreter() { fini (); } + ~interpreter_t() { fini (); } void fini () { env.fini (); } 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 index e78d5571c94..283bdf14afe 100644 --- 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 @@ -33,34 +33,34 @@ namespace CFF { using namespace OT; -enum CSType { +enum cs_type_t { CSType_CharString, CSType_GlobalSubr, CSType_LocalSubr }; -struct CallContext +struct call_context_t { - void init (const SubByteStr substr_=SubByteStr (), CSType type_=CSType_CharString, unsigned int subr_num_=0) + void init (const byte_str_ref_t substr_=byte_str_ref_t (), cs_type_t type_=CSType_CharString, unsigned int subr_num_=0) { - substr = substr_; + str_ref = substr_; type = type_; subr_num = subr_num_; } void fini () {} - SubByteStr substr; - CSType type; + byte_str_ref_t str_ref; + cs_type_t type; unsigned int subr_num; }; /* call stack */ const unsigned int kMaxCallLimit = 10; -struct CallStack : Stack {}; +struct call_stack_t : stack_t {}; template -struct BiasedSubrs +struct biased_subrs_t { void init (const SUBRS &subrs_) { @@ -79,10 +79,10 @@ struct BiasedSubrs unsigned int get_count () const { return (subrs == nullptr)? 0: subrs->count; } unsigned int get_bias () const { return bias; } - ByteStr operator [] (unsigned int index) const + byte_str_t operator [] (unsigned int index) const { if (unlikely ((subrs == nullptr) || index >= subrs->count)) - return Null(ByteStr); + return Null(byte_str_t); else return (*subrs)[index]; } @@ -92,7 +92,7 @@ struct BiasedSubrs const SUBRS *subrs; }; -struct Point +struct point_t { void init () { @@ -106,27 +106,28 @@ struct Point 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); } + void move_x (const number_t &dx) { x += dx; } + void move_y (const number_t &dy) { y += dy; } + void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); } + void move (const point_t &d) { move_x (d.x); move_y (d.y); } - Number x; - Number y; + number_t x; + number_t y; }; template -struct CSInterpEnv : InterpEnv +struct cs_interp_env_t : interp_env_t { - void init (const ByteStr &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_) + void init (const byte_str_t &str, const SUBRS &globalSubrs_, const SUBRS &localSubrs_) { - InterpEnv::init (str); + interp_env_t::init (str); context.init (str, CSType_CharString); seen_moveto = true; seen_hintmask = false; hstem_count = 0; vstem_count = 0; + hintmask_size = 0; pt.init (); callStack.init (); globalSubrs.init (globalSubrs_); @@ -134,7 +135,7 @@ struct CSInterpEnv : InterpEnv } void fini () { - InterpEnv::fini (); + interp_env_t::fini (); callStack.fini (); globalSubrs.fini (); @@ -146,7 +147,7 @@ struct CSInterpEnv : InterpEnv return callStack.in_error () || SUPER::in_error (); } - bool popSubrNum (const BiasedSubrs& biasedSubrs, unsigned int &subr_num) + bool popSubrNum (const biased_subrs_t& biasedSubrs, unsigned int &subr_num) { int n = SUPER::argStack.pop_int (); n += biasedSubrs.get_bias (); @@ -157,7 +158,7 @@ struct CSInterpEnv : InterpEnv return true; } - void callSubr (const BiasedSubrs& biasedSubrs, CSType type) + void callSubr (const biased_subrs_t& biasedSubrs, cs_type_t type) { unsigned int subr_num; @@ -167,19 +168,19 @@ struct CSInterpEnv : InterpEnv SUPER::set_error (); return; } - context.substr = SUPER::substr; + context.str_ref = SUPER::str_ref; callStack.push (context); context.init ( biasedSubrs[subr_num], type, subr_num); - SUPER::substr = context.substr; + SUPER::str_ref = context.str_ref; } void returnFromSubr () { - if (unlikely (SUPER::substr.in_error ())) + if (unlikely (SUPER::str_ref.in_error ())) SUPER::set_error (); context = callStack.pop (); - SUPER::substr = context.substr; + SUPER::str_ref = context.str_ref; } void determine_hintmask_size () @@ -195,14 +196,14 @@ struct CSInterpEnv : InterpEnv 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; } + const number_t &get_x () const { return pt.x; } + const number_t &get_y () const { return pt.y; } + const point_t &get_pt () const { return pt; } - void moveto (const Point &pt_ ) { pt = pt_; } + void moveto (const point_t &pt_ ) { pt = pt_; } public: - CallContext context; + call_context_t context; bool endchar_flag; bool seen_moveto; bool seen_hintmask; @@ -210,18 +211,18 @@ struct CSInterpEnv : InterpEnv unsigned int hstem_count; unsigned int vstem_count; unsigned int hintmask_size; - CallStack callStack; - BiasedSubrs globalSubrs; - BiasedSubrs localSubrs; + call_stack_t callStack; + biased_subrs_t globalSubrs; + biased_subrs_t localSubrs; private: - Point pt; + point_t pt; - typedef InterpEnv SUPER; + typedef interp_env_t SUPER; }; template -struct PathProcsNull +struct path_procs_null_t { static void rmoveto (ENV &env, PARAM& param) {} static void hmoveto (ENV &env, PARAM& param) {} @@ -236,19 +237,19 @@ struct PathProcsNull 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 moveto (ENV &env, PARAM& param, const point_t &pt) {} + static void line (ENV &env, PARAM& param, const point_t &pt1) {} + static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &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 > -struct CSOpSet : OpSet +template > +struct cs_opset_t : opset_t { - static void process_op (OpCode op, ENV &env, PARAM& param) + static void process_op (op_code_t op, ENV &env, PARAM& param) { switch (op) { @@ -262,7 +263,7 @@ struct CSOpSet : OpSet break; case OpCode_fixedcs: - env.argStack.push_fixed_from_substr (env.substr); + env.argStack.push_fixed_from_substr (env.str_ref); break; case OpCode_callsubr: @@ -370,37 +371,37 @@ struct CSOpSet : OpSet } } - static void process_hstem (OpCode op, ENV &env, PARAM& param) + static void process_hstem (op_code_t 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) + static void process_vstem (op_code_t 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) + static void process_hintmask (op_code_t op, ENV &env, PARAM& param) { env.determine_hintmask_size (); - if (likely (env.substr.avail (env.hintmask_size))) + if (likely (env.str_ref.avail (env.hintmask_size))) { OPSET::flush_hintmask (op, env, param); - env.substr.inc (env.hintmask_size); + env.str_ref.inc (env.hintmask_size); } } - static void process_post_flex (OpCode op, ENV &env, PARAM& param) + static void process_post_flex (op_code_t 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 check_width (op_code_t op, ENV &env, PARAM& param) {} - static void process_post_move (OpCode op, ENV &env, PARAM& param) + static void process_post_move (op_code_t op, ENV &env, PARAM& param) { if (!env.seen_moveto) { @@ -410,12 +411,12 @@ struct CSOpSet : OpSet OPSET::flush_args_and_op (op, env, param); } - static void process_post_path (OpCode op, ENV &env, PARAM& param) + static void process_post_path (op_code_t 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) + static void flush_args_and_op (op_code_t op, ENV &env, PARAM& param) { OPSET::flush_args (env, param); OPSET::flush_op (op, env, param); @@ -426,16 +427,16 @@ struct CSOpSet : OpSet env.pop_n_args (env.argStack.get_count ()); } - static void flush_op (OpCode op, ENV &env, PARAM& param) + static void flush_op (op_code_t op, ENV &env, PARAM& param) { } - static void flush_hintmask (OpCode op, ENV &env, PARAM& param) + static void flush_hintmask (op_code_t op, ENV &env, PARAM& param) { OPSET::flush_args_and_op (op, env, param); } - static bool is_number_op (OpCode op) + static bool is_number_op (op_code_t op) { switch (op) { @@ -454,31 +455,31 @@ struct CSOpSet : OpSet } protected: - typedef OpSet SUPER; + typedef opset_t SUPER; }; template -struct PathProcs +struct path_procs_t { static void rmoveto (ENV &env, PARAM& param) { - Point pt1 = env.get_pt (); - const Number &dy = env.pop_arg (); - const Number &dx = env.pop_arg (); + point_t pt1 = env.get_pt (); + const number_t &dy = env.pop_arg (); + const number_t &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 (); + point_t 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 (); + point_t pt1 = env.get_pt (); pt1.move_y (env.pop_arg ()); PATH::moveto (env, param, pt1); } @@ -487,7 +488,7 @@ struct PathProcs { for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (i), env.eval_arg (i+1)); PATH::line (env, param, pt1); } @@ -495,7 +496,7 @@ struct PathProcs static void hlineto (ENV &env, PARAM& param) { - Point pt1; + point_t pt1; unsigned int i = 0; for (; i + 2 <= env.argStack.get_count (); i += 2) { @@ -515,7 +516,7 @@ struct PathProcs static void vlineto (ENV &env, PARAM& param) { - Point pt1; + point_t pt1; unsigned int i = 0; for (; i + 2 <= env.argStack.get_count (); i += 2) { @@ -537,11 +538,11 @@ struct PathProcs { for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (i), env.eval_arg (i+1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move (env.eval_arg (i+4), env.eval_arg (i+5)); PATH::curve (env, param, pt1, pt2, pt3); } @@ -552,17 +553,17 @@ struct PathProcs unsigned int i = 0; for (; i + 6 <= env.argStack.get_count (); i += 6) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (i), env.eval_arg (i+1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); - Point pt3 = pt2; + point_t 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 (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (i), env.eval_arg (i+1)); PATH::line (env, param, pt1); } @@ -574,17 +575,17 @@ struct PathProcs unsigned int line_limit = (env.argStack.get_count () % 6); for (; i + 2 <= line_limit; i += 2) { - Point pt1 = env.get_pt (); + point_t 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 (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (i), env.eval_arg (i+1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+2), env.eval_arg (i+3)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move (env.eval_arg (i+4), env.eval_arg (i+5)); PATH::curve (env, param, pt1, pt2, pt3); } @@ -593,15 +594,15 @@ struct PathProcs static void vvcurveto (ENV &env, PARAM& param) { unsigned int i = 0; - Point pt1 = env.get_pt (); + point_t 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; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_y (env.eval_arg (i+3)); PATH::curve (env, param, pt1, pt2, pt3); pt1 = env.get_pt (); @@ -611,15 +612,15 @@ struct PathProcs static void hhcurveto (ENV &env, PARAM& param) { unsigned int i = 0; - Point pt1 = env.get_pt (); + point_t 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; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_x (env.eval_arg (i+3)); PATH::curve (env, param, pt1, pt2, pt3); pt1 = env.get_pt (); @@ -628,15 +629,15 @@ struct PathProcs static void vhcurveto (ENV &env, PARAM& param) { - Point pt1, pt2, pt3; + point_t pt1, pt2, pt3; unsigned int i = 0; if ((env.argStack.get_count () % 8) >= 4) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move_y (env.eval_arg (i)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_x (env.eval_arg (i+3)); i += 4; @@ -689,15 +690,15 @@ struct PathProcs static void hvcurveto (ENV &env, PARAM& param) { - Point pt1, pt2, pt3; + point_t pt1, pt2, pt3; unsigned int i = 0; if ((env.argStack.get_count () % 8) >= 4) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move_x (env.eval_arg (i)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_y (env.eval_arg (i+3)); i += 4; @@ -749,31 +750,31 @@ struct PathProcs } /* default actions to be overridden */ - static void moveto (ENV &env, PARAM& param, const Point &pt) + static void moveto (ENV &env, PARAM& param, const point_t &pt) { env.moveto (pt); } - static void line (ENV &env, PARAM& param, const Point &pt1) + static void line (ENV &env, PARAM& param, const point_t &pt1) { PATH::moveto (env, param, pt1); } - static void curve (ENV &env, PARAM& param, const Point &pt1, const Point &pt2, const Point &pt3) + static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &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 (); + point_t pt1 = env.get_pt (); pt1.move_x (env.eval_arg (0)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (1), env.eval_arg (2)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_x (env.eval_arg (3)); - Point pt4 = pt3; + point_t pt4 = pt3; pt4.move_x (env.eval_arg (4)); - Point pt5 = pt4; + point_t pt5 = pt4; pt5.move_x (env.eval_arg (5)); pt5.y = pt1.y; - Point pt6 = pt5; + point_t pt6 = pt5; pt6.move_x (env.eval_arg (6)); curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); @@ -786,17 +787,17 @@ struct PathProcs { if (likely (env.argStack.get_count () == 13)) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (0), env.eval_arg (1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (2), env.eval_arg (3)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move (env.eval_arg (4), env.eval_arg (5)); - Point pt4 = pt3; + point_t pt4 = pt3; pt4.move (env.eval_arg (6), env.eval_arg (7)); - Point pt5 = pt4; + point_t pt5 = pt4; pt5.move (env.eval_arg (8), env.eval_arg (9)); - Point pt6 = pt5; + point_t pt6 = pt5; pt6.move (env.eval_arg (10), env.eval_arg (11)); curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); @@ -809,17 +810,17 @@ struct PathProcs { if (likely (env.argStack.get_count () == 9)) { - Point pt1 = env.get_pt (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (0), env.eval_arg (1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (2), env.eval_arg (3)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move_x (env.eval_arg (4)); - Point pt4 = pt3; + point_t pt4 = pt3; pt4.move_x (env.eval_arg (5)); - Point pt5 = pt4; + point_t pt5 = pt4; pt5.move (env.eval_arg (6), env.eval_arg (7)); - Point pt6 = pt5; + point_t pt6 = pt5; pt6.move_x (env.eval_arg (8)); pt6.y = env.get_pt ().y; @@ -833,22 +834,22 @@ struct PathProcs { if (likely (env.argStack.get_count () == 11)) { - Point d; + point_t 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 (); + point_t pt1 = env.get_pt (); pt1.move (env.eval_arg (0), env.eval_arg (1)); - Point pt2 = pt1; + point_t pt2 = pt1; pt2.move (env.eval_arg (2), env.eval_arg (3)); - Point pt3 = pt2; + point_t pt3 = pt2; pt3.move (env.eval_arg (4), env.eval_arg (5)); - Point pt4 = pt3; + point_t pt4 = pt3; pt4.move (env.eval_arg (6), env.eval_arg (7)); - Point pt5 = pt4; + point_t pt5 = pt4; pt5.move (env.eval_arg (8), env.eval_arg (9)); - Point pt6 = pt5; + point_t pt6 = pt5; if (fabs (d.x.to_real ()) > fabs (d.y.to_real ())) { @@ -869,8 +870,8 @@ struct PathProcs 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) + const point_t &pt1, const point_t &pt2, const point_t &pt3, + const point_t &pt4, const point_t &pt5, const point_t &pt6) { PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt4, pt5, pt6); @@ -878,7 +879,7 @@ struct PathProcs }; template -struct CSInterpreter : Interpreter +struct cs_interpreter_t : interpreter_t { bool interpret (PARAM& param) { @@ -896,7 +897,7 @@ struct CSInterpreter : Interpreter } private: - typedef Interpreter SUPER; + typedef interpreter_t SUPER; }; } /* namespace CFF */ 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 index 8000d76b8bd..2c54909a1bc 100644 --- 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 @@ -35,28 +35,28 @@ namespace CFF { using namespace OT; /* an opstr and the parsed out dict value(s) */ -struct DictVal : OpStr +struct dict_val_t : op_str_t { void init () { single_val.set_int (0); } void fini () {} - Number single_val; + number_t single_val; }; -typedef DictVal NumDictVal; +typedef dict_val_t num_dict_val_t; -template struct DictValues : ParsedValues {}; +template struct dict_values_t : parsed_values_t {}; -template -struct TopDictValues : DictValues +template +struct top_dict_values_t : dict_values_t { void init () { - DictValues::init (); + dict_values_t::init (); charStringsOffset = 0; FDArrayOffset = 0; } - void fini () { DictValues::fini (); } + void fini () { dict_values_t::fini (); } unsigned int calculate_serialized_op_size (const OPSTR& opstr) const { @@ -67,7 +67,7 @@ struct TopDictValues : DictValues return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return opstr.str.len; + return opstr.str.length; } } @@ -75,26 +75,26 @@ struct TopDictValues : DictValues unsigned int FDArrayOffset; }; -struct DictOpSet : OpSet +struct dict_opset_t : opset_t { - static void process_op (OpCode op, InterpEnv& env) + static void process_op (op_code_t op, interp_env_t& env) { switch (op) { case OpCode_longintdict: /* 5-byte integer */ - env.argStack.push_longint_from_substr (env.substr); + env.argStack.push_longint_from_substr (env.str_ref); break; case OpCode_BCD: /* real number */ - env.argStack.push_real (parse_bcd (env.substr)); + env.argStack.push_real (parse_bcd (env.str_ref)); break; default: - OpSet::process_op (op, env); + opset_t::process_op (op, env); break; } } - static double parse_bcd (SubByteStr& substr) + static double parse_bcd (byte_str_ref_t& str_ref) { bool neg = false; double int_part = 0; @@ -115,13 +115,13 @@ struct DictOpSet : OpSet char d; if ((i & 1) == 0) { - if (!substr.avail ()) + if (!str_ref.avail ()) { - substr.set_error (); + str_ref.set_error (); return 0.0; } - byte = substr[0]; - substr.inc (); + byte = str_ref[0]; + str_ref.inc (); d = byte >> 4; } else @@ -130,7 +130,7 @@ struct DictOpSet : OpSet switch (d) { case RESERVED: - substr.set_error (); + str_ref.set_error (); return value; case END: @@ -162,7 +162,7 @@ struct DictOpSet : OpSet case NEG: if (i != 0) { - substr.set_error (); + str_ref.set_error (); return 0.0; } neg = true; @@ -171,7 +171,7 @@ struct DictOpSet : OpSet case DECIMAL: if (part != INT_PART) { - substr.set_error (); + str_ref.set_error (); return value; } part = FRAC_PART; @@ -184,7 +184,7 @@ struct DictOpSet : OpSet case EXP_POS: if (part == EXP_PART) { - substr.set_error (); + str_ref.set_error (); return value; } part = EXP_PART; @@ -220,7 +220,7 @@ struct DictOpSet : OpSet return value; } - static bool is_hint_op (OpCode op) + static bool is_hint_op (op_code_t op) { switch (op) { @@ -245,10 +245,10 @@ struct DictOpSet : OpSet } }; -template -struct TopDictOpSet : DictOpSet +template +struct top_dict_opset_t : dict_opset_t { - static void process_op (OpCode op, InterpEnv& env, TopDictValues & dictval) + static void process_op (op_code_t op, interp_env_t& env, top_dict_values_t & dictval) { switch (op) { case OpCode_CharStrings: @@ -263,19 +263,19 @@ struct TopDictOpSet : DictOpSet env.clear_args (); break; default: - DictOpSet::process_op (op, env); + dict_opset_t::process_op (op, env); break; } } }; -template -struct DictInterpreter : Interpreter +template +struct dict_interpreter_t : interpreter_t { bool interpret (PARAM& param) { param.init (); - while (SUPER::env.substr.avail ()) + while (SUPER::env.str_ref.avail ()) { OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); if (unlikely (SUPER::env.in_error ())) @@ -286,7 +286,7 @@ struct DictInterpreter : Interpreter } private: - typedef Interpreter SUPER; + typedef interpreter_t SUPER; }; } /* namespace CFF */ 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 index 68e1d81d762..c7209ed804d 100644 --- 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 @@ -33,12 +33,12 @@ namespace CFF { using namespace OT; -typedef BiasedSubrs CFF1BiasedSubrs; +typedef biased_subrs_t cff1_biased_subrs_t; -struct CFF1CSInterpEnv : CSInterpEnv +struct cff1_cs_interp_env_t : cs_interp_env_t { template - void init (const ByteStr &str, ACC &acc, unsigned int fd) + void init (const byte_str_t &str, ACC &acc, unsigned int fd) { SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); processed_width = false; @@ -74,20 +74,20 @@ struct CFF1CSInterpEnv : CSInterpEnv bool processed_width; bool has_width; unsigned int arg_start; - Number width; + number_t width; bool in_seac; private: - typedef CSInterpEnv SUPER; + typedef cs_interp_env_t SUPER; }; -template > -struct CFF1CSOpSet : CSOpSet +template > +struct cff1_cs_opset_t : cs_opset_t { /* 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) + static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param) { switch (op) { case OpCode_dotsection: @@ -109,7 +109,7 @@ struct CFF1CSOpSet : CSOpSet } } - static void check_width (OpCode op, CFF1CSInterpEnv &env, PARAM& param) + static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param) { if (!env.processed_width) { @@ -139,22 +139,22 @@ struct CFF1CSOpSet : CSOpSet } } - static void process_seac (CFF1CSInterpEnv &env, PARAM& param) + static void process_seac (cff1_cs_interp_env_t &env, PARAM& param) { } - static void flush_args (CFF1CSInterpEnv &env, PARAM& param) + static void flush_args (cff1_cs_interp_env_t &env, PARAM& param) { SUPER::flush_args (env, param); env.clear_args (); /* pop off width */ } private: - typedef CSOpSet SUPER; + typedef cs_opset_t SUPER; }; template -struct CFF1CSInterpreter : CSInterpreter {}; +struct cff1_cs_interpreter_t : cs_interpreter_t {}; } /* namespace CFF */ 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 index 709bdefa1dc..49e5ee7397e 100644 --- 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 @@ -33,26 +33,26 @@ namespace CFF { using namespace OT; -struct BlendArg : Number +struct blend_arg_t : number_t { void init () { - Number::init (); + number_t::init (); deltas.init (); } void fini () { - Number::fini (); + number_t::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_int (int v) { reset_blends (); number_t::set_int (v); } + void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); } + void set_real (double v) { reset_blends (); number_t::set_real (v); } void set_blends (unsigned int numValues_, unsigned int valueIndex_, - unsigned int numBlends, hb_array_t blends_) + unsigned int numBlends, hb_array_t blends_) { numValues = numValues_; valueIndex = valueIndex_; @@ -61,7 +61,7 @@ struct BlendArg : Number deltas[i] = blends_[i]; } - bool blending () const { return deltas.len > 0; } + bool blending () const { return deltas.length > 0; } void reset_blends () { numValues = valueIndex = 0; @@ -70,16 +70,16 @@ struct BlendArg : Number unsigned int numValues; unsigned int valueIndex; - hb_vector_t deltas; + hb_vector_t deltas; }; -typedef InterpEnv BlendInterpEnv; -typedef BiasedSubrs CFF2BiasedSubrs; +typedef interp_env_t BlendInterpEnv; +typedef biased_subrs_t cff2_biased_subrs_t; -struct CFF2CSInterpEnv : CSInterpEnv +struct cff2_cs_interp_env_t : cs_interp_env_t { template - void init (const ByteStr &str, ACC &acc, unsigned int fd, + void init (const byte_str_t &str, ACC &acc, unsigned int fd, const int *coords_=nullptr, unsigned int num_coords_=0) { SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); @@ -100,9 +100,9 @@ struct CFF2CSInterpEnv : CSInterpEnv SUPER::fini (); } - OpCode fetch_op () + op_code_t fetch_op () { - if (this->substr.avail ()) + if (this->str_ref.avail ()) return SUPER::fetch_op (); /* make up return or endchar op */ @@ -112,16 +112,16 @@ struct CFF2CSInterpEnv : CSInterpEnv return OpCode_return; } - const BlendArg& eval_arg (unsigned int i) + const blend_arg_t& eval_arg (unsigned int i) { - BlendArg &arg = argStack[i]; + blend_arg_t &arg = argStack[i]; blend_arg (arg); return arg; } - const BlendArg& pop_arg () + const blend_arg_t& pop_arg () { - BlendArg &arg = argStack.pop (); + blend_arg_t &arg = argStack.pop (); blend_arg (arg); return arg; } @@ -163,14 +163,14 @@ struct CFF2CSInterpEnv : CSInterpEnv bool seen_vsindex () const { return seen_vsindex_; } protected: - void blend_arg (BlendArg &arg) + void blend_arg (blend_arg_t &arg) { if (do_blend && arg.blending ()) { - if (likely (scalars.len == arg.deltas.len)) + if (likely (scalars.length == arg.deltas.length)) { double v = arg.to_real (); - for (unsigned int i = 0; i < scalars.len; i++) + for (unsigned int i = 0; i < scalars.length; i++) { v += (double)scalars[i] * arg.deltas[i].to_real (); } @@ -191,12 +191,12 @@ struct CFF2CSInterpEnv : CSInterpEnv bool seen_vsindex_; bool seen_blend; - typedef CSInterpEnv SUPER; + typedef cs_interp_env_t SUPER; }; -template > -struct CFF2CSOpSet : CSOpSet +template > +struct cff2_cs_opset_t : cs_opset_t { - static void process_op (OpCode op, CFF2CSInterpEnv &env, PARAM& param) + static void process_op (op_code_t op, cff2_cs_interp_env_t &env, PARAM& param) { switch (op) { case OpCode_callsubr: @@ -228,7 +228,7 @@ struct CFF2CSOpSet : CSOpSet } } - static void process_blend (CFF2CSInterpEnv &env, PARAM& param) + static void process_blend (cff2_cs_interp_env_t &env, PARAM& param) { unsigned int n, k; @@ -245,7 +245,7 @@ struct CFF2CSOpSet : CSOpSet } for (unsigned int i = 0; i < n; i++) { - const hb_array_t blends = env.argStack.get_subarray (start + n + (i * k)); + const hb_array_t blends = env.argStack.get_subarray (start + n + (i * k)); env.argStack[start + i].set_blends (n, i, k, blends); } @@ -253,18 +253,18 @@ struct CFF2CSOpSet : CSOpSet env.argStack.pop (k * n); } - static void process_vsindex (CFF2CSInterpEnv &env, PARAM& param) + static void process_vsindex (cff2_cs_interp_env_t &env, PARAM& param) { env.process_vsindex (); env.clear_args (); } private: - typedef CSOpSet SUPER; + typedef cs_opset_t SUPER; }; template -struct CFF2CSInterpreter : CSInterpreter {}; +struct cff2_cs_interpreter_t : cs_interpreter_t {}; } /* namespace CFF */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.h index ae23698a576..2b29e4441d4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-common.h @@ -67,7 +67,7 @@ typedef unsigned __int64 uint64_t; # include #endif -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define HB_DEPRECATED __attribute__((__deprecated__)) #elif defined(_MSC_VER) && (_MSC_VER >= 1300) #define HB_DEPRECATED __declspec(deprecated) @@ -75,7 +75,7 @@ typedef unsigned __int64 uint64_t; #define HB_DEPRECATED #endif -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) #define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) #define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) @@ -108,7 +108,7 @@ typedef union _hb_var_int_t { typedef uint32_t hb_tag_t; #define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF))) -#define HB_UNTAG(tag) (((tag)>>24)&0xFF), (((tag)>>16)&0xFF), (((tag)>>8)&0xFF), ((tag)&0xFF) +#define HB_UNTAG(tag) (uint8_t)(((tag)>>24)&0xFF), (uint8_t)(((tag)>>16)&0xFF), (uint8_t)(((tag)>>8)&0xFF), (uint8_t)((tag)&0xFF) #define HB_TAG_NONE HB_TAG(0,0,0,0) #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) 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 c181950d21d..42ea3ea2b3f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc @@ -527,7 +527,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, /* Scan events and save features for each range. */ hb_vector_t active_features; unsigned int last_index = 0; - for (unsigned int i = 0; i < feature_events.len; i++) + for (unsigned int i = 0; i < feature_events.length; i++) { feature_event_t *event = &feature_events[i]; @@ -536,13 +536,13 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, /* Save a snapshot of active features and the range. */ range_record_t *range = range_records.push (); - if (active_features.len) + if (active_features.length) { CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); /* TODO sort and resolve conflicting features? */ /* active_features.qsort (); */ - for (unsigned int j = 0; j < active_features.len; j++) + for (unsigned int j = 0; j < active_features.length; j++) { CFStringRef keys[] = { kCTFontFeatureTypeIdentifierKey, @@ -730,7 +730,7 @@ resize_and_retry: CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), kCTFontAttributeName, ct_font); - if (num_features && range_records.len) + if (num_features && range_records.length) { unsigned int start = 0; range_record_t *last_range = &range_records[0]; @@ -879,7 +879,7 @@ resize_and_retry: * Also see: https://bugs.chromium.org/p/chromium/issues/detail?id=597098 */ bool matched = false; - for (unsigned int i = 0; i < range_records.len; i++) + for (unsigned int i = 0; i < range_records.length; i++) if (range_records[i].font && CFEqual (run_ct_font, range_records[i].font)) { matched = true; @@ -1142,7 +1142,7 @@ fail: if (line) CFRelease (line); - for (unsigned int i = 0; i < range_records.len; i++) + for (unsigned int i = 0; i < range_records.length; i++) if (range_records[i].font) CFRelease (range_records[i].font); 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 41a85b58c10..d7d0165a91f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-debug.hh @@ -401,30 +401,6 @@ struct hb_no_trace_t { #define TRACE_APPLY(this) hb_no_trace_t trace #endif -#ifndef HB_DEBUG_CLOSURE -#define HB_DEBUG_CLOSURE (HB_DEBUG+0) -#endif -#if HB_DEBUG_CLOSURE -#define TRACE_CLOSURE(this) \ - hb_auto_trace_t trace \ - (&c->debug_depth, c->get_name (), this, HB_FUNC, \ - " ") -#else -#define TRACE_CLOSURE(this) hb_no_trace_t trace HB_UNUSED -#endif - -#ifndef HB_DEBUG_COLLECT_GLYPHS -#define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) -#endif -#if HB_DEBUG_COLLECT_GLYPHS -#define TRACE_COLLECT_GLYPHS(this) \ - hb_auto_trace_t trace \ - (&c->debug_depth, c->get_name (), this, HB_FUNC, \ - " ") -#else -#define TRACE_COLLECT_GLYPHS(this) hb_no_trace_t trace HB_UNUSED -#endif - #ifndef HB_DEBUG_SANITIZE #define HB_DEBUG_SANITIZE (HB_DEBUG+0) #endif @@ -476,8 +452,6 @@ struct hb_no_trace_t { #ifndef HB_DEBUG_DISPATCH #define HB_DEBUG_DISPATCH ( \ HB_DEBUG_APPLY + \ - HB_DEBUG_CLOSURE + \ - HB_DEBUG_COLLECT_GLYPHS + \ HB_DEBUG_SANITIZE + \ HB_DEBUG_SERIALIZE + \ HB_DEBUG_SUBSET + \ 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 e93cf90a30f..aaf10a1d6e4 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-directwrite.cc @@ -71,6 +71,8 @@ public: *fontFileStream = mFontFileStream; return S_OK; } + + virtual ~DWriteFontFileLoader() {} }; class DWriteFontFileStream : public IDWriteFontFileStream @@ -122,6 +124,8 @@ public: virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime (OUT UINT64* lastWriteTime) { return E_NOTIMPL; } + + virtual ~DWriteFontFileStream() {} }; @@ -133,8 +137,8 @@ struct hb_directwrite_face_data_t { IDWriteFactory *dwriteFactory; IDWriteFontFile *fontFile; - IDWriteFontFileStream *fontFileStream; - IDWriteFontFileLoader *fontFileLoader; + DWriteFontFileStream *fontFileStream; + DWriteFontFileLoader *fontFileLoader; IDWriteFontFace *fontFace; hb_blob_t *faceBlob; }; @@ -281,7 +285,7 @@ public: public: TextAnalysis (const wchar_t* text, uint32_t textLength, const wchar_t* localeName, DWRITE_READING_DIRECTION readingDirection) - : mText (text), mTextLength (textLength), mLocaleName (localeName), + : mTextLength (textLength), mText (text), mLocaleName (localeName), mReadingDirection (readingDirection), mCurrentRun (nullptr) {} ~TextAnalysis () { @@ -516,7 +520,6 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan, { hb_face_t *face = font->face; const hb_directwrite_face_data_t *face_data = face->data.directwrite; - const hb_directwrite_font_data_t *font_data = font->data.directwrite; IDWriteFactory *dwriteFactory = face_data->dwriteFactory; IDWriteFontFace *fontFace = face_data->fontFace; @@ -770,7 +773,7 @@ retry_getglyphs: /* Calculate visual-clusters. That's what we ship. */ for (unsigned int i = 0; i < glyphCount; i++) - vis_clusters[i] = -1; + vis_clusters[i] = (uint32_t) -1; for (unsigned int i = 0; i < buffer->len; i++) { uint32_t *p = @@ -778,7 +781,7 @@ retry_getglyphs: *p = MIN (*p, buffer->info[i].cluster); } for (unsigned int i = 1; i < glyphCount; i++) - if (vis_clusters[i] == -1) + if (vis_clusters[i] == (uint32_t) -1) vis_clusters[i] = vis_clusters[i - 1]; #undef utf16_index 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 48ce9897d5e..cb3057c54cd 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-dsalgs.hh @@ -28,7 +28,6 @@ #define HB_DSALGS_HH #include "hb.hh" - #include "hb-null.hh" @@ -107,7 +106,7 @@ hb_bit_storage (T v) _BitScanReverse (&where, v); return 1 + where; } -# if _WIN64 +# if defined(_WIN64) if (sizeof (T) <= 8) { unsigned long where; @@ -181,7 +180,7 @@ hb_ctz (T v) _BitScanForward (&where, v); return where; } -# if _WIN64 +# if defined(_WIN64) if (sizeof (T) <= 8) { unsigned long where; @@ -237,10 +236,13 @@ hb_ctz (T v) template static inline T* hb_addressof (T& arg) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" /* https://en.cppreference.com/w/cpp/memory/addressof */ return reinterpret_cast( &const_cast( reinterpret_cast(arg))); +#pragma GCC diagnostic pop } /* ASCII tag/character handling */ @@ -554,26 +556,26 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o struct HbOpOr { - enum { passthru_left = true }; - enum { passthru_right = true }; + static constexpr bool passthru_left = true; + static constexpr bool passthru_right = true; template static void process (T &o, const T &a, const T &b) { o = a | b; } }; struct HbOpAnd { - enum { passthru_left = false }; - enum { passthru_right = false }; + static constexpr bool passthru_left = false; + static constexpr bool passthru_right = false; template static void process (T &o, const T &a, const T &b) { o = a & b; } }; struct HbOpMinus { - enum { passthru_left = true }; - enum { passthru_right = false }; + static constexpr bool passthru_left = true; + static constexpr bool passthru_right = false; template static void process (T &o, const T &a, const T &b) { o = a & ~b; } }; struct HbOpXor { - enum { passthru_left = true }; - enum { passthru_right = true }; + static constexpr bool passthru_left = true; + static constexpr bool passthru_right = true; template static void process (T &o, const T &a, const T &b) { o = a ^ b; } }; 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 8bb8c512106..375ef9293a9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-face.cc @@ -599,7 +599,7 @@ struct hb_face_builder_data_t hb_blob_t *blob; }; - hb_vector_t tables; + hb_vector_t tables; }; static hb_face_builder_data_t * @@ -619,7 +619,7 @@ _hb_face_builder_data_destroy (void *user_data) { hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data; - for (unsigned int i = 0; i < data->tables.len; i++) + for (unsigned int i = 0; i < data->tables.length; i++) hb_blob_destroy (data->tables[i].blob); data->tables.fini (); @@ -631,7 +631,7 @@ static hb_blob_t * _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) { - unsigned int table_count = data->tables.len; + unsigned int table_count = data->tables.length; unsigned int face_length = table_count * 16 + 12; for (unsigned int i = 0; i < table_count; i++) 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 0f0bcadc1b5..817a1a7b0ea 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -139,10 +139,10 @@ hb_font_get_nominal_glyphs_default (hb_font_t *font, for (unsigned int i = 0; i < count; i++) { if (!font->get_nominal_glyph (*first_unicode, first_glyph)) - return i; + return i; - first_unicode = &StructAtOffset (first_unicode, unicode_stride); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_unicode = &StructAtOffsetUnaligned (first_unicode, unicode_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); } return count; } @@ -238,8 +238,8 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->get_glyph_h_advance (*first_glyph); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } return; } @@ -250,7 +250,7 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->parent_scale_x_distance (*first_advance); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } } @@ -270,8 +270,8 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->get_glyph_v_advance (*first_glyph); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } return; } @@ -282,7 +282,7 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->parent_scale_y_distance (*first_advance); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } } 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 5f6e3808756..1900f30bce2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -228,8 +228,8 @@ hb_ft_get_nominal_glyphs (hb_font_t *font HB_UNUSED, done < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode)); done++) { - first_unicode = &StructAtOffset (first_unicode, unicode_stride); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_unicode = &StructAtOffsetUnaligned (first_unicode, unicode_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); } /* We don't need to do ft_font->symbol dance here, since HB calls the singular * nominal_glyph() for what we don't handle here. */ @@ -292,8 +292,8 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, } *first_advance = (v * mult + (1<<9)) >> 10; - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } } 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 846240e9322..3cff880aac3 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 @@ -64,7 +64,7 @@ hb_gobject_##name##_get_type () \ } #define HB_DEFINE_OBJECT_TYPE(name) \ - HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy); + HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy) #define HB_DEFINE_VALUE_TYPE(name) \ static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \ @@ -75,7 +75,7 @@ hb_gobject_##name##_get_type () \ return c; \ } \ static void _hb_##name##_destroy (hb_##name##_t *l) { free (l); } \ - HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy); + HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy) HB_DEFINE_OBJECT_TYPE (buffer) HB_DEFINE_OBJECT_TYPE (blob) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh new file mode 100644 index 00000000000..c4ab26dc063 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-iter.hh @@ -0,0 +1,153 @@ +/* + * 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" +#include "hb-null.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. + * hb_iter_tator objects are small, light-weight, objects that can be + * copied by value. If the collection / object being iterated on + * is writable, then the iterator returns lvalues, otherwise it + * returns rvalues. + */ + +/* Base class for all iterators. */ +template +struct hb_iter_t +{ + typedef Iter iter_t; + typedef iter_t const_iter_t; + typedef Item item_t; + static constexpr unsigned item_size = hb_static_size (Item); + + private: + /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ + const iter_t* thiz () const { return static_cast (this); } + iter_t* thiz () { return static_cast< iter_t *> (this); } + public: + + /* Operators. */ + operator iter_t () { return iter(); } + explicit_operator bool () const { return more (); } + item_t& operator * () const { return item (); } + item_t& operator [] (signed i) const { return item_at ((unsigned) i); } + iter_t& operator += (unsigned count) { forward (count); return *thiz(); } + iter_t& operator ++ () { next (); return *thiz(); } + iter_t& operator -= (unsigned count) { rewind (count); return *thiz(); } + iter_t& operator -- () { prev (); return *thiz(); } + iter_t operator + (unsigned count) { iter_t c (*thiz()); c += count; return c; } + iter_t operator ++ (int) { iter_t c (*thiz()); ++*thiz(); return c; } + iter_t operator - (unsigned count) { iter_t c (*thiz()); c -= count; return c; } + iter_t operator -- (int) { iter_t c (*thiz()); --*thiz(); return c; } + + /* Methods. */ + iter_t iter () const { return *thiz(); } + const_iter_t const_iter () const { return iter (); } + item_t& item () const { return thiz()->__item__ (); } + item_t& item_at (unsigned i) const { return thiz()->__item_at__ (i); } + bool more () const { return thiz()->__more__ (); } + unsigned len () const { return thiz()->__len__ (); } + void next () { thiz()->__next__ (); } + void forward (unsigned n) { thiz()->__forward__ (n); } + void prev () { thiz()->__prev__ (); } + void rewind (unsigned n) { thiz()->__rewind__ (n); } + bool random_access () const { return thiz()->__random_access__ (); } + + protected: + hb_iter_t () {} + hb_iter_t (const hb_iter_t &o HB_UNUSED) {} + void operator = (const hb_iter_t &o HB_UNUSED) {} +}; + +/* Base class for sorted iterators. Does not enforce anything. + * Just for class taxonomy and requirements. */ +template +struct hb_sorted_iter_t : hb_iter_t +{ + protected: + hb_sorted_iter_t () {} + hb_sorted_iter_t (const hb_sorted_iter_t &o) : hb_iter_t (o) {} + void operator = (const hb_sorted_iter_t &o HB_UNUSED) {} +}; + +/* Mixin to fill in what the subclass doesn't provide. */ +template +struct hb_iter_mixin_t +{ + private: + /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ + const iter_t* thiz () const { return static_cast (this); } + iter_t* thiz () { return static_cast< iter_t *> (this); } + public: + + /* Access: Implement __item__(), or __item_at__() if random-access. */ + item_t& __item__ () const { return thiz()->item_at (0); } + item_t& __item_at__ (unsigned i) const { return *(thiz() + i); } + + /* Termination: Implement __more__(), or __len__() if random-access. */ + bool __more__ () const { return thiz()->__len__ (); } + unsigned __len__ () const + { iter_t c (*thiz()); unsigned l = 0; while (c) { c++; l++; }; return l; } + + /* Advancing: Implement __next__(), or __forward__() if random-access. */ + void __next__ () { thiz()->forward (1); } + void __forward__ (unsigned n) { while (n--) thiz()->next (); } + + /* Rewinding: Implement __prev__() or __rewind__() if bidirectional. */ + void __prev__ () { thiz()->rewind (1); } + void __rewind__ (unsigned n) { while (n--) thiz()->prev (); } + + /* Random access: Return true if item_at(), len(), forward() are fast. */ + bool __random_access__ () const { return false; } +}; + + +/* Functions operating on iterators or iteratables. */ + +template inline void +hb_fill (const C& c, const V &v) +{ + for (typename C::iter_t i (c); i; i++) + hb_assign (*i, v); +} + +template inline bool +hb_copy (hb_iter_t &id, hb_iter_t &is) +{ + for (; id && is; ++id, ++is) + *id = *is; + return !is; +} + + +#endif /* HB_ITER_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh index 9d2ae95556b..b22c2389c3c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-machinery.hh @@ -64,6 +64,22 @@ static inline const Type& StructAtOffset(const void *P, unsigned int offset) template static inline Type& StructAtOffset(void *P, unsigned int offset) { return * reinterpret_cast ((char *) P + offset); } +template +static inline const Type& StructAtOffsetUnaligned(const void *P, unsigned int offset) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" + return * reinterpret_cast ((char *) P + offset); +#pragma GCC diagnostic pop +} +template +static inline Type& StructAtOffsetUnaligned(void *P, unsigned int offset) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" + return * reinterpret_cast ((char *) P + offset); +#pragma GCC diagnostic pop +} /* StructAfter(X) returns the struct T& that is placed after X. * Works with X of variable size also. X must implement get_size() */ @@ -97,30 +113,30 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_STATIC(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \ unsigned int get_size () const { return (size); } \ - enum { null_size = (size) }; \ - enum { min_size = (size) }; \ - enum { static_size = (size) } + static constexpr unsigned null_size = (size); \ + static constexpr unsigned min_size = (size); \ + static constexpr unsigned static_size = (size) #define DEFINE_SIZE_UNION(size, _member) \ DEFINE_COMPILES_ASSERTION ((void) this->u._member.static_size) \ DEFINE_INSTANCE_ASSERTION (sizeof(this->u._member) == (size)) \ - enum { null_size = (size) }; \ - enum { min_size = (size) } + static constexpr unsigned null_size = (size); \ + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_MIN(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ - enum { null_size = (size) }; \ - enum { min_size = (size) } + static constexpr unsigned null_size = (size); \ + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_UNBOUNDED(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ - enum { min_size = (size) } + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_ARRAY(size, array) \ DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \ - enum { null_size = (size) }; \ - enum { min_size = (size) } + static constexpr unsigned null_size = (size); \ + static constexpr unsigned min_size = (size) #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \ @@ -134,7 +150,7 @@ static inline Type& StructAfter(TObject &X) template struct hb_dispatch_context_t { - enum { max_debug_depth = MaxDebugDepth }; + static constexpr unsigned max_debug_depth = MaxDebugDepth; typedef Return return_t; template bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; } @@ -268,15 +284,12 @@ struct hb_sanitize_context_t : if (!obj) return; const char *obj_start = (const char *) obj; - const char *obj_end = (const char *) obj + obj->get_size (); - assert (obj_start <= obj_end); /* Must not overflow. */ - - if (unlikely (obj_end < this->start || this->end < obj_start)) + if (unlikely (obj_start < this->start || this->end <= obj_start)) this->start = this->end = nullptr; else { - this->start = MAX (this->start, obj_start); - this->end = MIN (this->end , obj_end ); + this->start = obj_start; + this->end = obj_start + MIN (this->end - obj_start, obj->get_size ()); } } @@ -667,7 +680,6 @@ template struct BEInt { public: - typedef Type type; void set (Type V) { v = V; } operator Type () const { return v; } private: uint8_t v; @@ -676,7 +688,6 @@ template struct BEInt { public: - typedef Type type; void set (Type V) { v[0] = (V >> 8) & 0xFF; @@ -705,7 +716,6 @@ template struct BEInt { public: - typedef Type type; void set (Type V) { v[0] = (V >> 16) & 0xFF; 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 3b119daa8e2..02d5406674c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-map.hh @@ -166,7 +166,7 @@ struct hb_map_t hb_codepoint_t operator [] (unsigned int key) const { return get (key); } - enum { INVALID = HB_MAP_VALUE_INVALID }; + static constexpr hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID; void clear () { 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 8a3e0d4056e..204c2fefd83 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-null.hh @@ -93,7 +93,7 @@ struct _hb_assign > template static inline void hb_assign (T &o, const V v) -{ _hb_assign >::value (o, v); }; +{ _hb_assign >::value (o, 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 6eb1173d82f..68520f2a160 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-object.hh @@ -45,7 +45,7 @@ template struct hb_lockable_set_t { - hb_vector_t items; + hb_vector_t items; void init () { items.init (); } @@ -77,9 +77,10 @@ struct hb_lockable_set_t { l.lock (); item_t *item = items.find (v); - if (item) { + if (item) + { item_t old = *item; - *item = items[items.len - 1]; + *item = items[items.length - 1]; items.pop (); l.unlock (); old.fini (); @@ -113,18 +114,20 @@ struct hb_lockable_set_t void fini (lock_t &l) { - if (!items.len) { - /* No need for locking. */ + if (!items.length) + { + /* No need to lock. */ items.fini (); return; } l.lock (); - while (items.len) { - item_t old = items[items.len - 1]; - items.pop (); - l.unlock (); - old.fini (); - l.lock (); + while (items.length) + { + item_t old = items[items.length - 1]; + items.pop (); + l.unlock (); + old.fini (); + l.lock (); } items.fini (); l.unlock (); 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 822a92d3946..32a223cdf34 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 @@ -130,7 +130,7 @@ typedef struct OffsetTable sfnt_version.set (sfnt_tag); /* Take space for numTables, searchRange, entrySelector, RangeShift * and the TableRecords themselves. */ - if (unlikely (!tables.serialize (c, items.len))) return_trace (false); + if (unlikely (!tables.serialize (c, items.length))) return_trace (false); const char *dir_end = (const char *) c->head; HBUINT32 *checksum_adjustment = nullptr; @@ -154,7 +154,8 @@ typedef struct OffsetTable c->align (4); const char *end = (const char *) c->head; - if (items[i].tag == HB_OT_TAG_head && end - start >= head::static_size) + if (items[i].tag == HB_OT_TAG_head && + (unsigned) (end - start) >= head::static_size) { head *h = (head *) start; checksum_adjustment = &h->checkSumAdjustment; @@ -173,7 +174,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 < items.len; i++) + for (unsigned int i = 0; i < items.length; i++) { TableRecord &rec = tables.arrayZ[i]; checksum.set (checksum + rec.checkSum); @@ -298,7 +299,7 @@ struct ResourceRecord HBINT16 nameOffset; /* Offset from beginning of resource name list * to resource name, -1 means there is none. */ HBUINT8 attrs; /* Resource attributes */ - OffsetTo, HBUINT24, false> + NNOffsetTo, HBUINT24> offset; /* Offset from beginning of data block to * data for this resource */ HBUINT32 reserved; /* Reserved for handle to resource */ @@ -333,7 +334,7 @@ struct ResourceTypeRecord protected: Tag tag; /* Resource type. */ HBUINT16 resCountM1; /* Number of resources minus 1. */ - OffsetTo, HBUINT16, false> + NNOffsetTo > resourcesZ; /* Offset from beginning of resource type list * to reference item list for this type. */ public: @@ -389,7 +390,7 @@ struct ResourceMap HBUINT32 reserved1; /* Reserved for handle to next resource map */ HBUINT16 resreved2; /* Reserved for file reference number */ HBUINT16 attrs; /* Resource fork attribute */ - OffsetTo, HBUINT16, false> + NNOffsetTo > typeList; /* Offset from beginning of map to * resource type list */ Offset16 nameList; /* Offset from beginning of map to @@ -421,10 +422,10 @@ struct ResourceForkHeader } protected: - LOffsetTo, false> + LNNOffsetTo > data; /* Offset from beginning of resource fork * to resource data */ - LOffsetTo + LNNOffsetTo map; /* Offset from beginning of resource fork * to resource map */ HBUINT32 dataLen; /* Length of resource data */ 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 7f88279a792..6abb898626c 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 @@ -159,7 +159,7 @@ typedef HBUINT16 GlyphID; /* Script/language-system/feature index */ struct Index : HBUINT16 { - enum { NOT_FOUND_INDEX = 0xFFFFu }; + static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFu; }; DECLARE_NULL_NAMESPACE_BYTES (OT, Index); @@ -337,7 +337,10 @@ struct OffsetTo : Offset } DEFINE_SIZE_STATIC (sizeof (OffsetType)); }; -template struct LOffsetTo : OffsetTo {}; +/* Partial specializations. */ +template struct LOffsetTo : OffsetTo {}; +template struct NNOffsetTo : OffsetTo {}; +template struct LNNOffsetTo : OffsetTo {}; template static inline const Type& operator + (const Base &base, const OffsetTo &offset) { return offset (base); } @@ -352,8 +355,8 @@ static inline Type& operator + (Base &base, OffsetTo template struct UnsizedArrayOf { - typedef Type ItemType; - enum { item_size = hb_static_size (Type) }; + typedef Type item_t; + static constexpr unsigned item_size = hb_static_size (Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); @@ -508,8 +511,8 @@ struct SortedUnsizedArrayOf : UnsizedArrayOf template struct ArrayOf { - typedef Type ItemType; - enum { item_size = hb_static_size (Type) }; + typedef Type item_t; + static constexpr unsigned item_size = hb_static_size (Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); @@ -557,8 +560,8 @@ struct ArrayOf bool serialize (hb_serialize_context_t *c, hb_array_t items) { TRACE_SERIALIZE (this); - if (unlikely (!serialize (c, items.len))) return_trace (false); - for (unsigned int i = 0; i < items.len; i++) + if (unlikely (!serialize (c, items.length))) return_trace (false); + for (unsigned int i = 0; i < items.length; i++) hb_assign (arrayZ[i], items[i]); return_trace (true); } @@ -679,7 +682,7 @@ struct OffsetListOf : OffsetArrayOf template struct HeadlessArrayOf { - enum { item_size = Type::static_size }; + static constexpr unsigned item_size = Type::static_size; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType); @@ -703,9 +706,9 @@ struct HeadlessArrayOf { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - lenP1.set (items.len + 1); /* TODO(serialize) Overflow? */ + lenP1.set (items.length + 1); /* TODO(serialize) Overflow? */ if (unlikely (!c->extend (*this))) return_trace (false); - for (unsigned int i = 0; i < items.len; i++) + for (unsigned int i = 0; i < items.length; i++) arrayZ[i] = items[i]; return_trace (true); } @@ -888,7 +891,7 @@ struct VarSizedBinSearchHeader template struct VarSizedBinSearchArrayOf { - enum { item_size = Type::static_size }; + static constexpr unsigned item_size = Type::static_size; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type); 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 index db04b3eb239..c645953e5b9 100644 --- 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 @@ -55,27 +55,27 @@ inline unsigned int calcOffSize(unsigned int dataSize) return size; } -struct code_pair +struct code_pair_t { hb_codepoint_t code; hb_codepoint_t glyph; }; -typedef hb_vector_t StrBuff; -struct StrBuffArray : hb_vector_t +typedef hb_vector_t str_buff_t; +struct str_buff_vec_t : hb_vector_t { 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; + for (unsigned int i = 0; i < length; i++) + size += (*this)[i].length; return size; } private: - typedef hb_vector_t SUPER; + typedef hb_vector_t SUPER; }; /* CFF INDEX */ @@ -117,10 +117,10 @@ struct CFFIndex bool serialize (hb_serialize_context_t *c, unsigned int offSize_, - const ByteStrArray &byteArray) + const byte_str_array_t &byteArray) { TRACE_SERIALIZE (this); - if (byteArray.len == 0) + if (byteArray.length == 0) { COUNT *dest = c->allocate_min (); if (unlikely (dest == nullptr)) return_trace (false); @@ -130,15 +130,15 @@ struct CFFIndex { /* serialize CFFIndex header */ if (unlikely (!c->extend_min (*this))) return_trace (false); - this->count.set (byteArray.len); + this->count.set (byteArray.length); this->offSize.set (offSize_); - if (!unlikely (c->allocate_size (offSize_ * (byteArray.len + 1)))) + if (!unlikely (c->allocate_size (offSize_ * (byteArray.length + 1)))) return_trace (false); /* serialize indices */ unsigned int offset = 1; unsigned int i = 0; - for (; i < byteArray.len; i++) + for (; i < byteArray.length; i++) { set_offset_at (i, offset); offset += byteArray[i].get_size (); @@ -146,12 +146,13 @@ struct CFFIndex set_offset_at (i, offset); /* serialize data */ - for (unsigned int i = 0; i < byteArray.len; i++) + for (unsigned int i = 0; i < byteArray.length; i++) { - ByteStr *dest = c->start_embed (); - if (unlikely (dest == nullptr || - !dest->serialize (c, byteArray[i]))) + const byte_str_t &bs = byteArray[i]; + unsigned char *dest = c->allocate_size (bs.length); + if (unlikely (dest == nullptr)) return_trace (false); + memcpy (dest, &bs[0], bs.length); } } return_trace (true); @@ -159,14 +160,14 @@ struct CFFIndex bool serialize (hb_serialize_context_t *c, unsigned int offSize_, - const StrBuffArray &buffArray) + const str_buff_vec_t &buffArray) { - ByteStrArray byteArray; + byte_str_array_t byteArray; byteArray.init (); - byteArray.resize (buffArray.len); - for (unsigned int i = 0; i < byteArray.len; i++) + byteArray.resize (buffArray.length); + for (unsigned int i = 0; i < byteArray.length; i++) { - byteArray[i] = ByteStr (buffArray[i].arrayZ (), buffArray[i].len); + byteArray[i] = byte_str_t (buffArray[i].arrayZ (), buffArray[i].length); } bool result = this->serialize (c, offSize_, byteArray); byteArray.fini (); @@ -205,17 +206,17 @@ struct CFFIndex return 0; } - const char *data_base () const - { return (const char *)this + min_size + offset_array_size (); } + const unsigned char *data_base () const + { return (const unsigned char *)this + min_size + offset_array_size (); } unsigned int data_size () const { return HBINT8::static_size; } - ByteStr operator [] (unsigned int index) const + byte_str_t operator [] (unsigned int index) const { if (likely (index < count)) - return ByteStr (data_base () + offset_at (index) - 1, length_at (index)); + return byte_str_t (data_base () + offset_at (index) - 1, length_at (index)); else - return Null(ByteStr); + return Null(byte_str_t); } unsigned int get_size () const @@ -255,11 +256,11 @@ struct CFFIndex template struct CFFIndexOf : CFFIndex { - const ByteStr operator [] (unsigned int index) const + const byte_str_t operator [] (unsigned int index) const { if (likely (index < CFFIndex::count)) - return ByteStr (CFFIndex::data_base () + CFFIndex::offset_at (index) - 1, CFFIndex::length_at (index)); - return Null(ByteStr); + return byte_str_t (CFFIndex::data_base () + CFFIndex::offset_at (index) - 1, CFFIndex::length_at (index)); + return Null(byte_str_t); } template @@ -363,7 +364,7 @@ struct Dict : UnsizedByteStr } template - static bool serialize_int_op (hb_serialize_context_t *c, OpCode op, int value, OpCode intOp) + static bool serialize_int_op (hb_serialize_context_t *c, op_code_t op, int value, op_code_t intOp) { // XXX: not sure why but LLVM fails to compile the following 'unlikely' macro invocation if (/*unlikely*/ (!serialize_int (c, intOp, value))) @@ -383,18 +384,18 @@ struct Dict : UnsizedByteStr return_trace (true); } - static bool serialize_uint4_op (hb_serialize_context_t *c, OpCode op, int value) + static bool serialize_uint4_op (hb_serialize_context_t *c, op_code_t op, int value) { return serialize_int_op (c, op, value, OpCode_longintdict); } - static bool serialize_uint2_op (hb_serialize_context_t *c, OpCode op, int value) + static bool serialize_uint2_op (hb_serialize_context_t *c, op_code_t op, int value) { return serialize_int_op (c, op, value, OpCode_shortint); } - static bool serialize_offset4_op (hb_serialize_context_t *c, OpCode op, int value) + static bool serialize_offset4_op (hb_serialize_context_t *c, op_code_t op, int value) { return serialize_uint4_op (c, op, value); } - static bool serialize_offset2_op (hb_serialize_context_t *c, OpCode op, int value) + static bool serialize_offset2_op (hb_serialize_context_t *c, op_code_t op, int value) { return serialize_uint2_op (c, op, value); } @@ -404,7 +405,7 @@ struct TopDict : Dict {}; struct FontDict : Dict {}; struct PrivateDict : Dict {}; -struct TableInfo +struct table_info_t { void init () { offSize = offset = size = 0; } @@ -415,7 +416,7 @@ struct TableInfo /* 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 +struct remap_t : hb_vector_t { void init () { SUPER::init (); } @@ -425,7 +426,7 @@ struct Remap : hb_vector_t { if (unlikely (!SUPER::resize (size))) return false; - for (unsigned int i = 0; i < len; i++) + for (unsigned int i = 0; i < length; i++) (*this)[i] = CFF_UNDEF_CODE; count = 0; return true; @@ -436,14 +437,14 @@ struct Remap : hb_vector_t if (unlikely (!SUPER::resize (size))) return false; unsigned int i; - for (i = 0; i < len; i++) + for (i = 0; i < length; i++) (*this)[i] = i; count = i; return true; } bool excludes (hb_codepoint_t id) const - { return (id < len) && ((*this)[id] == CFF_UNDEF_CODE); } + { return (id < length) && ((*this)[id] == CFF_UNDEF_CODE); } bool includes (hb_codepoint_t id) const { return !excludes (id); } @@ -476,15 +477,15 @@ struct FDArray : CFFIndexOf { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - this->count.set (fontDicts.len); + this->count.set (fontDicts.length); this->offSize.set (offSize_); - if (!unlikely (c->allocate_size (offSize_ * (fontDicts.len + 1)))) + if (!unlikely (c->allocate_size (offSize_ * (fontDicts.length + 1)))) return_trace (false); /* serialize font dict offsets */ unsigned int offset = 1; unsigned int fid = 0; - for (; fid < fontDicts.len; fid++) + for (; fid < fontDicts.length; fid++) { CFFIndexOf::set_offset_at (fid, offset); offset += FontDict::calculate_serialized_size (fontDicts[fid], opszr); @@ -492,7 +493,7 @@ struct FDArray : CFFIndexOf CFFIndexOf::set_offset_at (fid, offset); /* serialize font dicts */ - for (unsigned int i = 0; i < fontDicts.len; i++) + for (unsigned int i = 0; i < fontDicts.length; i++) { FontDict *dict = c->start_embed (); if (unlikely (!dict->serialize (c, fontDicts[i], opszr, fontDicts[i]))) @@ -507,9 +508,9 @@ struct FDArray : CFFIndexOf unsigned int offSize_, const hb_vector_t &fontDicts, unsigned int fdCount, - const Remap &fdmap, + const remap_t &fdmap, OP_SERIALIZER& opszr, - const hb_vector_t &privateInfos) + const hb_vector_t &privateInfos) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -521,7 +522,7 @@ struct FDArray : CFFIndexOf /* serialize font dict offsets */ unsigned int offset = 1; unsigned int fid = 0; - for (unsigned i = 0; i < fontDicts.len; i++) + for (unsigned i = 0; i < fontDicts.length; i++) if (fdmap.includes (i)) { CFFIndexOf::set_offset_at (fid++, offset); @@ -530,7 +531,7 @@ struct FDArray : CFFIndexOf CFFIndexOf::set_offset_at (fid, offset); /* serialize font dicts */ - for (unsigned int i = 0; i < fontDicts.len; i++) + for (unsigned int i = 0; i < fontDicts.length; i++) if (fdmap.includes (i)) { FontDict *dict = c->start_embed (); @@ -545,7 +546,7 @@ struct FDArray : CFFIndexOf static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, const hb_vector_t &fontDicts, unsigned int fdCount, - const Remap &fdmap, + const remap_t &fdmap, OP_SERIALIZER& opszr) { unsigned int dictsSize = 0; @@ -587,10 +588,10 @@ struct FDSelect0 { template struct FDSelect3_4_Range { - bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const + bool sanitize (hb_sanitize_context_t *c, const void */*nullptr*/, unsigned int fdcount) const { TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this) && (first < c->get_num_glyphs ()) && (fd < fdcount))); + return_trace (first < c->get_num_glyphs () && (fd < fdcount)); } GID_TYPE first; @@ -602,21 +603,21 @@ struct FDSelect3_4_Range { template struct FDSelect3_4 { unsigned int get_size () const - { return GID_TYPE::static_size * 2 + FDSelect3_4_Range::static_size * nRanges; } + { return GID_TYPE::static_size * 2 + ranges.get_size (); } 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)))) + if (unlikely (!c->check_struct (this) || !ranges.sanitize (c, nullptr, fdcount) || + (nRanges () == 0) || ranges[0].first != 0)) return_trace (false); - for (unsigned int i = 0; i < nRanges; i++) + for (unsigned int i = 1; 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 (ranges[i - 1].first >= ranges[i].first)) + return_trace (false); } + if (unlikely (!sentinel().sanitize (c) || (sentinel() != c->get_num_glyphs ()))) return_trace (false); @@ -626,18 +627,19 @@ struct FDSelect3_4 { hb_codepoint_t get_fd (hb_codepoint_t glyph) const { unsigned int i; - for (i = 1; i < nRanges; 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 (ranges[nRanges - 1]); } - const GID_TYPE &sentinel () const { return StructAfter (ranges[nRanges - 1]); } + GID_TYPE &nRanges () { return ranges.len; } + GID_TYPE nRanges () const { return ranges.len; } + GID_TYPE &sentinel () { return StructAfter (ranges[nRanges () - 1]); } + const GID_TYPE &sentinel () const { return StructAfter (ranges[nRanges () - 1]); } - GID_TYPE nRanges; - FDSelect3_4_Range ranges[VAR]; + ArrayOf, GID_TYPE> ranges; /* GID_TYPE sentinel */ DEFINE_SIZE_ARRAY (GID_TYPE::static_size, ranges); 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 index 51cecb6f5b4..8773c05a228 100644 --- 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 @@ -161,7 +161,7 @@ hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code) return CFF_UNDEF_SID; } -struct Bounds +struct bounds_t { void init () { @@ -169,7 +169,7 @@ struct Bounds max.set_int (-0x80000000, -0x80000000); } - void update (const Point &pt) + void update (const point_t &pt) { if (pt.x < min.x) min.x = pt.x; if (pt.x > max.x) max.x = pt.x; @@ -177,7 +177,7 @@ struct Bounds if (pt.y > max.y) max.y = pt.y; } - void merge (const Bounds &b) + void merge (const bounds_t &b) { if (empty ()) *this = b; @@ -190,7 +190,7 @@ struct Bounds } } - void offset (const Point &delta) + void offset (const point_t &delta) { if (!empty ()) { @@ -202,11 +202,11 @@ struct Bounds bool empty () const { return (min.x >= max.x) || (min.y >= max.y); } - Point min; - Point max; + point_t min; + point_t max; }; -struct ExtentsParam +struct extents_param_t { void init (const OT::cff1::accelerator_t *_cff) { @@ -220,20 +220,20 @@ struct ExtentsParam bool is_path_open () const { return path_open; } bool path_open; - Bounds bounds; + bounds_t bounds; const OT::cff1::accelerator_t *cff; }; -struct CFF1PathProcs_Extents : PathProcs +struct cff1_path_procs_extents_t : path_procs_t { - static void moveto (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt) + static void moveto (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt) { param.end_path (); env.moveto (pt); } - static void line (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1) + static void line (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1) { if (!param.is_path_open ()) { @@ -244,7 +244,7 @@ struct CFF1PathProcs_Extents : PathProcs +struct cff1_cs_opset_extents_t : cff1_cs_opset_t { - static void process_seac (CFF1CSInterpEnv &env, ExtentsParam& param) + static void process_seac (cff1_cs_interp_env_t &env, extents_param_t& param) { unsigned int n = env.argStack.get_count (); - Point delta; + point_t 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; + bounds_t 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))) @@ -286,17 +286,17 @@ struct CFF1CSOpSet_Extents : CFF1CSOpSetis_valid () || (glyph >= cff->num_glyphs))) return false; unsigned int fd = cff->fdSelect->get_fd (glyph); - CFF1CSInterpreter interp; - const ByteStr str = (*cff->charStrings)[glyph]; + cff1_cs_interpreter_t interp; + const byte_str_t str = (*cff->charStrings)[glyph]; interp.env.init (str, *cff, fd); interp.env.set_in_seac (in_seac); - ExtentsParam param; + extents_param_t param; param.init (cff); if (unlikely (!interp.interpret (param))) return false; bounds = param.bounds; @@ -305,7 +305,7 @@ bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Boun bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const { - Bounds bounds; + bounds_t bounds; if (!_get_bounds (this, glyph, bounds)) return false; @@ -334,7 +334,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extent return true; } -struct GetSeacParam +struct get_seac_param_t { void init (const OT::cff1::accelerator_t *_cff) { @@ -350,9 +350,9 @@ struct GetSeacParam hb_codepoint_t accent; }; -struct CFF1CSOpSet_Seac : CFF1CSOpSet +struct cff1_cs_opset_seac_t : cff1_cs_opset_t { - static void process_seac (CFF1CSInterpEnv &env, GetSeacParam& param) + static void process_seac (cff1_cs_interp_env_t &env, get_seac_param_t& param) { unsigned int n = env.argStack.get_count (); hb_codepoint_t base_char = (hb_codepoint_t)env.argStack[n-2].to_int (); @@ -368,10 +368,10 @@ bool OT::cff1::accelerator_t::get_seac_components (hb_codepoint_t glyph, hb_code if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false; unsigned int fd = fdSelect->get_fd (glyph); - CFF1CSInterpreter interp; - const ByteStr str = (*charStrings)[glyph]; + cff1_cs_interpreter_t interp; + const byte_str_t str = (*charStrings)[glyph]; interp.env.init (str, *this, fd); - GetSeacParam param; + get_seac_param_t param; param.init (this); if (unlikely (!interp.interpret (param))) 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 index 72dc0ef3e01..1effdf006cd 100644 --- 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 @@ -193,20 +193,20 @@ struct Encoding { bool serialize (hb_serialize_context_t *c, uint8_t format, unsigned int enc_count, - const hb_vector_t& code_ranges, - const hb_vector_t& supp_codes) + const hb_vector_t& code_ranges, + const hb_vector_t& 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)); + dest->format.set (format | ((supp_codes.length > 0)? 0x80: 0)); if (format == 0) { Encoding0 *fmt0 = c->allocate_size (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++) + for (unsigned int i = 0; i < code_ranges.length; i++) { hb_codepoint_t code = code_ranges[i].code; for (int left = (int)code_ranges[i].glyph; left >= 0; left--) @@ -217,10 +217,10 @@ struct Encoding { } else { - Encoding1 *fmt1 = c->allocate_size (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.len); + Encoding1 *fmt1 = c->allocate_size (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length); if (unlikely (fmt1 == nullptr)) return_trace (false); - fmt1->nRanges.set (code_ranges.len); - for (unsigned int i = 0; i < code_ranges.len; i++) + fmt1->nRanges.set (code_ranges.length); + for (unsigned int i = 0; i < code_ranges.length; i++) { if (unlikely (!((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF)))) return_trace (false); @@ -228,12 +228,12 @@ struct Encoding { fmt1->ranges[i].nLeft.set (code_ranges[i].glyph); } } - if (supp_codes.len > 0) + if (supp_codes.length > 0) { - CFF1SuppEncData *suppData = c->allocate_size (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.len); + CFF1SuppEncData *suppData = c->allocate_size (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length); if (unlikely (suppData == nullptr)) return_trace (false); - suppData->nSups.set (supp_codes.len); - for (unsigned int i = 0; i < supp_codes.len; i++) + suppData->nSups.set (supp_codes.length); + for (unsigned int i = 0; i < supp_codes.length; i++) { suppData->supps[i].code.set (supp_codes[i].code); suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */ @@ -467,7 +467,7 @@ struct Charset { bool serialize (hb_serialize_context_t *c, uint8_t format, unsigned int num_glyphs, - const hb_vector_t& sid_ranges) + const hb_vector_t& sid_ranges) { TRACE_SERIALIZE (this); Charset *dest = c->extend_min (*this); @@ -478,7 +478,7 @@ struct Charset { Charset0 *fmt0 = c->allocate_size (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++) + for (unsigned int i = 0; i < sid_ranges.length; i++) { hb_codepoint_t sid = sid_ranges[i].code; for (int left = (int)sid_ranges[i].glyph; left >= 0; left--) @@ -487,9 +487,9 @@ struct Charset { } else if (format == 1) { - Charset1 *fmt1 = c->allocate_size (Charset1::min_size + Charset1_Range::static_size * sid_ranges.len); + Charset1 *fmt1 = c->allocate_size (Charset1::min_size + Charset1_Range::static_size * sid_ranges.length); if (unlikely (fmt1 == nullptr)) return_trace (false); - for (unsigned int i = 0; i < sid_ranges.len; i++) + for (unsigned int i = 0; i < sid_ranges.length; i++) { if (unlikely (!(sid_ranges[i].glyph <= 0xFF))) return_trace (false); @@ -499,9 +499,9 @@ struct Charset { } else /* format 2 */ { - Charset2 *fmt2 = c->allocate_size (Charset2::min_size + Charset2_Range::static_size * sid_ranges.len); + Charset2 *fmt2 = c->allocate_size (Charset2::min_size + Charset2_Range::static_size * sid_ranges.length); if (unlikely (fmt2 == nullptr)) return_trace (false); - for (unsigned int i = 0; i < sid_ranges.len; i++) + for (unsigned int i = 0; i < sid_ranges.length; i++) { if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF))) return_trace (false); @@ -573,7 +573,7 @@ struct Charset { struct CFF1StringIndex : CFF1Index { bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings, - unsigned int offSize_, const Remap &sidmap) + unsigned int offSize_, const remap_t &sidmap) { TRACE_SERIALIZE (this); if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0))) @@ -584,7 +584,7 @@ struct CFF1StringIndex : CFF1Index return_trace (true); } - ByteStrArray bytesArray; + byte_str_array_t bytesArray; bytesArray.init (); if (!bytesArray.resize (sidmap.get_count ())) return_trace (false); @@ -601,7 +601,7 @@ struct CFF1StringIndex : CFF1Index } /* in parallel to above */ - unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const + unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const remap_t &sidmap) const { offSize = 0; if ((count == 0) || (sidmap.get_count () == 0)) @@ -617,18 +617,18 @@ struct CFF1StringIndex : CFF1Index } }; -struct CFF1TopDictInterpEnv : NumInterpEnv +struct cff1_top_dict_interp_env_t : num_interp_env_t { - CFF1TopDictInterpEnv () - : NumInterpEnv(), prev_offset(0), last_offset(0) {} + cff1_top_dict_interp_env_t () + : num_interp_env_t(), prev_offset(0), last_offset(0) {} unsigned int prev_offset; unsigned int last_offset; }; -struct NameDictValues +struct name_dict_values_t { - enum NameDictValIndex + enum name_dict_val_index_t { version, notice, @@ -657,7 +657,7 @@ struct NameDictValues unsigned int operator[] (unsigned int i) const { assert (i < ValCount); return values[i]; } - static enum NameDictValIndex name_op_to_index (OpCode op) + static enum name_dict_val_index_t name_op_to_index (op_code_t op) { switch (op) { default: // can't happen - just make some compiler happy @@ -685,16 +685,16 @@ struct NameDictValues unsigned int values[ValCount]; }; -struct CFF1TopDictVal : OpStr +struct cff1_top_dict_val_t : op_str_t { unsigned int last_arg_offset; }; -struct CFF1TopDictValues : TopDictValues +struct cff1_top_dict_values_t : top_dict_values_t { void init () { - TopDictValues::init (); + top_dict_values_t::init (); nameSIDs.init (); ros_supplement = 0; @@ -704,12 +704,12 @@ struct CFF1TopDictValues : TopDictValues FDSelectOffset = 0; privateDictInfo.init (); } - void fini () { TopDictValues::fini (); } + void fini () { top_dict_values_t::fini (); } bool is_CID () const - { return nameSIDs[NameDictValues::registry] != CFF_UNDEF_SID; } + { return nameSIDs[name_dict_values_t::registry] != CFF_UNDEF_SID; } - NameDictValues nameSIDs; + name_dict_values_t nameSIDs; unsigned int ros_supplement_offset; unsigned int ros_supplement; unsigned int cidCount; @@ -717,14 +717,14 @@ struct CFF1TopDictValues : TopDictValues unsigned int EncodingOffset; unsigned int CharsetOffset; unsigned int FDSelectOffset; - TableInfo privateDictInfo; + table_info_t privateDictInfo; }; -struct CFF1TopDictOpSet : TopDictOpSet +struct cff1_top_dict_opset_t : top_dict_opset_t { - static void process_op (OpCode op, CFF1TopDictInterpEnv& env, CFF1TopDictValues& dictval) + static void process_op (op_code_t op, cff1_top_dict_interp_env_t& env, cff1_top_dict_values_t& dictval) { - CFF1TopDictVal val; + cff1_top_dict_val_t val; val.last_arg_offset = (env.last_offset-1) - dictval.opStart; /* offset to the last argument */ switch (op) { @@ -736,7 +736,7 @@ struct CFF1TopDictOpSet : TopDictOpSet case OpCode_Weight: case OpCode_PostScript: case OpCode_BaseFontName: - dictval.nameSIDs[NameDictValues::name_op_to_index (op)] = env.argStack.pop_uint (); + dictval.nameSIDs[name_dict_values_t::name_op_to_index (op)] = env.argStack.pop_uint (); env.clear_args (); break; case OpCode_isFixedPitch: @@ -765,8 +765,8 @@ struct CFF1TopDictOpSet : TopDictOpSet 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 (); + dictval.nameSIDs[name_dict_values_t::ordering] = env.argStack.pop_uint (); + dictval.nameSIDs[name_dict_values_t::registry] = env.argStack.pop_uint (); env.clear_args (); break; @@ -794,8 +794,8 @@ struct CFF1TopDictOpSet : TopDictOpSet break; default: - env.last_offset = env.substr.offset; - TopDictOpSet::process_op (op, env, dictval); + env.last_offset = env.str_ref.offset; + top_dict_opset_t::process_op (op, env, dictval); /* Record this operand below if stack is empty, otherwise done */ if (!env.argStack.is_empty ()) return; break; @@ -803,27 +803,27 @@ struct CFF1TopDictOpSet : TopDictOpSet if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr, val); + dictval.add_op (op, env.str_ref, val); } }; -struct CFF1FontDictValues : DictValues +struct cff1_font_dict_values_t : dict_values_t { void init () { - DictValues::init (); + dict_values_t::init (); privateDictInfo.init (); fontName = CFF_UNDEF_SID; } - void fini () { DictValues::fini (); } + void fini () { dict_values_t::fini (); } - TableInfo privateDictInfo; + table_info_t privateDictInfo; unsigned int fontName; }; -struct CFF1FontDictOpSet : DictOpSet +struct cff1_font_dict_opset_t : dict_opset_t { - static void process_op (OpCode op, NumInterpEnv& env, CFF1FontDictValues& dictval) + static void process_op (op_code_t op, num_interp_env_t& env, cff1_font_dict_values_t& dictval) { switch (op) { case OpCode_FontName: @@ -841,36 +841,36 @@ struct CFF1FontDictOpSet : DictOpSet break; default: - DictOpSet::process_op (op, env); + dict_opset_t::process_op (op, env); if (!env.argStack.is_empty ()) return; break; } if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); } }; template -struct CFF1PrivateDictValues_Base : DictValues +struct cff1_private_dict_values_base_t : dict_values_t { void init () { - DictValues::init (); + dict_values_t::init (); subrsOffset = 0; localSubrs = &Null(CFF1Subrs); } - void fini () { DictValues::fini (); } + void fini () { dict_values_t::fini (); } unsigned int calculate_serialized_size () const { unsigned int size = 0; - for (unsigned int i = 0; i < DictValues::get_count; i++) - if (DictValues::get_value (i).op == OpCode_Subrs) + for (unsigned int i = 0; i < dict_values_t::get_count; i++) + if (dict_values_t::get_value (i).op == OpCode_Subrs) size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); else - size += DictValues::get_value (i).str.len; + size += dict_values_t::get_value (i).str.length; return size; } @@ -878,14 +878,14 @@ struct CFF1PrivateDictValues_Base : DictValues const CFF1Subrs *localSubrs; }; -typedef CFF1PrivateDictValues_Base CFF1PrivateDictValues_Subset; -typedef CFF1PrivateDictValues_Base CFF1PrivateDictValues; +typedef cff1_private_dict_values_base_t cff1_private_dict_values_subset_t; +typedef cff1_private_dict_values_base_t cff1_private_dict_values_t; -struct CFF1PrivateDictOpSet : DictOpSet +struct cff1_private_dict_opset_t : dict_opset_t { - static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues& dictval) + static void process_op (op_code_t op, num_interp_env_t& env, cff1_private_dict_values_t& dictval) { - NumDictVal val; + num_dict_val_t val; val.init (); switch (op) { @@ -917,20 +917,20 @@ struct CFF1PrivateDictOpSet : DictOpSet break; default: - DictOpSet::process_op (op, env); + dict_opset_t::process_op (op, env); if (!env.argStack.is_empty ()) return; break; } if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr, val); + dictval.add_op (op, env.str_ref, val); } }; -struct CFF1PrivateDictOpSet_Subset : DictOpSet +struct cff1_private_dict_opset_subset : dict_opset_t { - static void process_op (OpCode op, NumInterpEnv& env, CFF1PrivateDictValues_Subset& dictval) + static void process_op (op_code_t op, num_interp_env_t& env, cff1_private_dict_values_subset_t& dictval) { switch (op) { case OpCode_BlueValues: @@ -959,25 +959,24 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet break; default: - DictOpSet::process_op (op, env); + dict_opset_t::process_op (op, env); if (!env.argStack.is_empty ()) return; break; } if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); } }; -typedef DictInterpreter CFF1TopDict_Interpreter; -typedef DictInterpreter CFF1FontDict_Interpreter; -typedef DictInterpreter CFF1PrivateDict_Interpreter; +typedef dict_interpreter_t cff1_top_dict_interpreter_t; +typedef dict_interpreter_t cff1_font_dict_interpreter_t; typedef CFF1Index CFF1NameIndex; typedef CFF1IndexOf CFF1TopDictIndex; -}; /* namespace CFF */ +} /* namespace CFF */ namespace OT { @@ -985,7 +984,7 @@ using namespace CFF; struct cff1 { - static const hb_tag_t tableTag = HB_OT_TAG_cff1; + static constexpr hb_tag_t tableTag = HB_OT_TAG_cff1; bool sanitize (hb_sanitize_context_t *c) const { @@ -1023,9 +1022,9 @@ struct cff1 { fini (); return; } { /* parse top dict */ - const ByteStr topDictStr = (*topDictIndex)[0]; + const byte_str_t topDictStr = (*topDictIndex)[0]; if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } - CFF1TopDict_Interpreter top_interp; + cff1_top_dict_interpreter_t top_interp; top_interp.env.init (topDictStr); topDict.init (); if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } @@ -1082,24 +1081,24 @@ struct cff1 { for (unsigned int i = 0; i < fdCount; i++) { - ByteStr fontDictStr = (*fdArray)[i]; + byte_str_t fontDictStr = (*fdArray)[i]; if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } - CFF1FontDictValues *font; - CFF1FontDict_Interpreter font_interp; + cff1_font_dict_values_t *font; + cff1_font_dict_interpreter_t font_interp; font_interp.env.init (fontDictStr); font = fontDicts.push (); - if (unlikely (font == &Crap(CFF1FontDictValues))) { fini (); return; } + if (unlikely (font == &Crap(cff1_font_dict_values_t))) { fini (); return; } font->init (); if (unlikely (!font_interp.interpret (*font))) { fini (); return; } PRIVDICTVAL *priv = &privateDicts[i]; - const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } - DictInterpreter priv_interp; + dict_interpreter_t priv_interp; priv_interp.env.init (privDictStr); priv->init (); if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + priv->localSubrs = &StructAtOffsetOrNull (&privDictStr, priv->subrsOffset); if (priv->localSubrs != &Null(CFF1Subrs) && unlikely (!priv->localSubrs->sanitize (&sc))) { fini (); return; } @@ -1107,17 +1106,17 @@ struct cff1 } else /* non-CID */ { - CFF1TopDictValues *font = &topDict; + cff1_top_dict_values_t *font = &topDict; PRIVDICTVAL *priv = &privateDicts[0]; - const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } - DictInterpreter priv_interp; + dict_interpreter_t priv_interp; priv_interp.env.init (privDictStr); priv->init (); if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + priv->localSubrs = &StructAtOffsetOrNull (&privDictStr, priv->subrsOffset); if (priv->localSubrs != &Null(CFF1Subrs) && unlikely (!priv->localSubrs->sanitize (&sc))) { fini (); return; } @@ -1167,20 +1166,20 @@ struct cff1 const CFF1FDSelect *fdSelect; unsigned int fdCount; - CFF1TopDictValues topDict; - hb_vector_t fontDicts; + cff1_top_dict_values_t topDict; + hb_vector_t fontDicts; hb_vector_t privateDicts; unsigned int num_glyphs; }; - struct accelerator_t : accelerator_templ_t + struct accelerator_t : accelerator_templ_t { 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 + struct accelerator_subset_t : accelerator_templ_t { void init (hb_face_t *face) { @@ -1257,7 +1256,7 @@ struct cff1 const Encoding *encoding; private: - typedef accelerator_templ_t SUPER; + typedef accelerator_templ_t SUPER; }; bool subset (hb_subset_plan_t *plan) const 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 index 7188a3bfe86..7daa5365670 100644 --- 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 @@ -29,7 +29,7 @@ using namespace CFF; -struct ExtentsParam +struct extents_param_t { void init () { @@ -44,7 +44,7 @@ struct ExtentsParam void end_path () { path_open = false; } bool is_path_open () const { return path_open; } - void update_bounds (const Point &pt) + void update_bounds (const point_t &pt) { if (pt.x < min_x) min_x = pt.x; if (pt.x > max_x) max_x = pt.x; @@ -53,21 +53,21 @@ struct ExtentsParam } bool path_open; - Number min_x; - Number min_y; - Number max_x; - Number max_y; + number_t min_x; + number_t min_y; + number_t max_x; + number_t max_y; }; -struct CFF2PathProcs_Extents : PathProcs +struct cff2_path_procs_extents_t : path_procs_t { - static void moveto (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt) + static void moveto (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt) { param.end_path (); env.moveto (pt); } - static void line (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1) + static void line (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1) { if (!param.is_path_open ()) { @@ -78,7 +78,7 @@ struct CFF2PathProcs_Extents : PathProcs {}; +struct cff2_cs_opset_extents_t : cff2_cs_opset_t {}; bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, hb_codepoint_t glyph, @@ -104,10 +104,10 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, unsigned int num_coords; const int *coords = hb_font_get_var_coords_normalized (font, &num_coords); unsigned int fd = fdSelect->get_fd (glyph); - CFF2CSInterpreter interp; - const ByteStr str = (*charStrings)[glyph]; + cff2_cs_interpreter_t interp; + const byte_str_t str = (*charStrings)[glyph]; interp.env.init (str, *this, fd, coords, num_coords); - ExtentsParam param; + extents_param_t param; param.init (); if (unlikely (!interp.interpret (param))) return false; 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 index 25c41ef8cc1..a7b0ba9beb6 100644 --- 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 @@ -136,22 +136,22 @@ struct CFF2VariationStore DEFINE_SIZE_MIN (2 + VariationStore::min_size); }; -struct CFF2TopDictValues : TopDictValues<> +struct cff2_top_dict_values_t : top_dict_values_t<> { void init () { - TopDictValues<>::init (); + top_dict_values_t<>::init (); vstoreOffset = 0; FDSelectOffset = 0; } - void fini () { TopDictValues<>::fini (); } + void fini () { top_dict_values_t<>::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; + op_code_t op = get_value (i).op; switch (op) { case OpCode_vstore: @@ -159,7 +159,7 @@ struct CFF2TopDictValues : TopDictValues<> size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); break; default: - size += TopDictValues<>::calculate_serialized_op_size (get_value (i)); + size += top_dict_values_t<>::calculate_serialized_op_size (get_value (i)); break; } } @@ -170,16 +170,16 @@ struct CFF2TopDictValues : TopDictValues<> unsigned int FDSelectOffset; }; -struct CFF2TopDictOpSet : TopDictOpSet<> +struct cff2_top_dict_opset_t : top_dict_opset_t<> { - static void process_op (OpCode op, NumInterpEnv& env, CFF2TopDictValues& dictval) + static void process_op (op_code_t op, num_interp_env_t& env, cff2_top_dict_values_t& dictval) { switch (op) { case OpCode_FontMatrix: { - DictVal val; + dict_val_t val; val.init (); - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); env.clear_args (); } break; @@ -201,27 +201,27 @@ struct CFF2TopDictOpSet : TopDictOpSet<> if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); } - typedef TopDictOpSet<> SUPER; + typedef top_dict_opset_t<> SUPER; }; -struct CFF2FontDictValues : DictValues +struct cff2_font_dict_values_t : dict_values_t { void init () { - DictValues::init (); + dict_values_t::init (); privateDictInfo.init (); } - void fini () { DictValues::fini (); } + void fini () { dict_values_t::fini (); } - TableInfo privateDictInfo; + table_info_t privateDictInfo; }; -struct CFF2FontDictOpSet : DictOpSet +struct cff2_font_dict_opset_t : dict_opset_t { - static void process_op (OpCode op, NumInterpEnv& env, CFF2FontDictValues& dictval) + static void process_op (op_code_t op, num_interp_env_t& env, cff2_font_dict_values_t& dictval) { switch (op) { case OpCode_Private: @@ -238,33 +238,33 @@ struct CFF2FontDictOpSet : DictOpSet if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); } private: - typedef DictOpSet SUPER; + typedef dict_opset_t SUPER; }; template -struct CFF2PrivateDictValues_Base : DictValues +struct cff2_private_dict_values_base_t : dict_values_t { void init () { - DictValues::init (); + dict_values_t::init (); subrsOffset = 0; localSubrs = &Null(CFF2Subrs); ivs = 0; } - void fini () { DictValues::fini (); } + void fini () { dict_values_t::fini (); } unsigned int calculate_serialized_size () const { unsigned int size = 0; - for (unsigned int i = 0; i < DictValues::get_count; i++) - if (DictValues::get_value (i).op == OpCode_Subrs) + for (unsigned int i = 0; i < dict_values_t::get_count; i++) + if (dict_values_t::get_value (i).op == OpCode_Subrs) size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); else - size += DictValues::get_value (i).str.len; + size += dict_values_t::get_value (i).str.length; return size; } @@ -273,14 +273,14 @@ struct CFF2PrivateDictValues_Base : DictValues unsigned int ivs; }; -typedef CFF2PrivateDictValues_Base CFF2PrivateDictValues_Subset; -typedef CFF2PrivateDictValues_Base CFF2PrivateDictValues; +typedef cff2_private_dict_values_base_t cff2_private_dict_values_subset_t; +typedef cff2_private_dict_values_base_t cff2_private_dict_values_t; -struct CFF2PrivDictInterpEnv : NumInterpEnv +struct cff2_priv_dict_interp_env_t : num_interp_env_t { - void init (const ByteStr &str) + void init (const byte_str_t &str) { - NumInterpEnv::init (str); + num_interp_env_t::init (str); ivs = 0; seen_vsindex = false; } @@ -302,11 +302,11 @@ struct CFF2PrivDictInterpEnv : NumInterpEnv bool seen_vsindex; }; -struct CFF2PrivateDictOpSet : DictOpSet +struct cff2_private_dict_opset_t : dict_opset_t { - static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues& dictval) + static void process_op (op_code_t op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_t& dictval) { - NumDictVal val; + num_dict_val_t val; val.init (); switch (op) { @@ -341,20 +341,20 @@ struct CFF2PrivateDictOpSet : DictOpSet break; default: - DictOpSet::process_op (op, env); + dict_opset_t::process_op (op, env); if (!env.argStack.is_empty ()) return; break; } if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr, val); + dictval.add_op (op, env.str_ref, val); } }; -struct CFF2PrivateDictOpSet_Subset : DictOpSet +struct cff2_private_dict_opset_subset_t : dict_opset_t { - static void process_op (OpCode op, CFF2PrivDictInterpEnv& env, CFF2PrivateDictValues_Subset& dictval) + static void process_op (op_code_t op, cff2_priv_dict_interp_env_t& env, cff2_private_dict_values_subset_t& dictval) { switch (op) { case OpCode_BlueValues: @@ -390,17 +390,17 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet if (unlikely (env.in_error ())) return; - dictval.add_op (op, env.substr); + dictval.add_op (op, env.str_ref); } private: - typedef DictOpSet SUPER; + typedef dict_opset_t SUPER; }; -typedef DictInterpreter CFF2TopDict_Interpreter; -typedef DictInterpreter CFF2FontDict_Interpreter; +typedef dict_interpreter_t cff2_top_dict_interpreter_t; +typedef dict_interpreter_t cff2_font_dict_interpreter_t; -}; /* namespace CFF */ +} /* namespace CFF */ namespace OT { @@ -408,7 +408,7 @@ using namespace CFF; struct cff2 { - static const hb_tag_t tableTag = HB_OT_TAG_cff2; + static constexpr hb_tag_t tableTag = HB_OT_TAG_cff2; bool sanitize (hb_sanitize_context_t *c) const { @@ -438,9 +438,9 @@ struct cff2 { fini (); return; } { /* parse top dict */ - ByteStr topDictStr (cff2 + cff2->topDict, cff2->topDictSize); + byte_str_t topDictStr (cff2 + cff2->topDict, cff2->topDictSize); if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } - CFF2TopDict_Interpreter top_interp; + cff2_top_dict_interpreter_t top_interp; top_interp.env.init (topDictStr); topDict.init (); if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } @@ -469,24 +469,24 @@ struct cff2 /* parse font dicts and gather private dicts */ for (unsigned int i = 0; i < fdCount; i++) { - const ByteStr fontDictStr = (*fdArray)[i]; + const byte_str_t fontDictStr = (*fdArray)[i]; if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } - CFF2FontDictValues *font; - CFF2FontDict_Interpreter font_interp; + cff2_font_dict_values_t *font; + cff2_font_dict_interpreter_t font_interp; font_interp.env.init (fontDictStr); font = fontDicts.push (); - if (unlikely (font == &Crap(CFF2FontDictValues))) { fini (); return; } + if (unlikely (font == &Crap(cff2_font_dict_values_t))) { fini (); return; } font->init (); if (unlikely (!font_interp.interpret (*font))) { fini (); return; } - const ByteStr privDictStr (StructAtOffsetOrNull (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); + const byte_str_t privDictStr (StructAtOffsetOrNull (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } - DictInterpreter priv_interp; + dict_interpreter_t priv_interp; priv_interp.env.init(privDictStr); privateDicts[i].init (); if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; } - privateDicts[i].localSubrs = &StructAtOffsetOrNull (privDictStr.str, privateDicts[i].subrsOffset); + privateDicts[i].localSubrs = &StructAtOffsetOrNull (&privDictStr[0], privateDicts[i].subrsOffset); if (privateDicts[i].localSubrs != &Null(CFF2Subrs) && unlikely (!privateDicts[i].localSubrs->sanitize (&sc))) { fini (); return; } @@ -496,6 +496,7 @@ struct cff2 void fini () { sc.end_processing (); + topDict.fini (); fontDicts.fini_deep (); privateDicts.fini_deep (); hb_blob_destroy (blob); @@ -505,32 +506,32 @@ struct cff2 bool is_valid () const { return blob != nullptr; } protected: - hb_blob_t *blob; - hb_sanitize_context_t sc; + 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 fontDicts; + cff2_top_dict_values_t topDict; + const CFF2Subrs *globalSubrs; + const CFF2VariationStore *varStore; + const CFF2CharStrings *charStrings; + const CFF2FDArray *fdArray; + const CFF2FDSelect *fdSelect; + unsigned int fdCount; + + hb_vector_t fontDicts; hb_vector_t privateDicts; - unsigned int num_glyphs; + unsigned int num_glyphs; }; - struct accelerator_t : accelerator_templ_t + struct accelerator_t : accelerator_templ_t { HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const; }; - typedef accelerator_templ_t accelerator_subset_t; + typedef accelerator_templ_t accelerator_subset_t; bool subset (hb_subset_plan_t *plan) const { @@ -551,9 +552,9 @@ struct cff2 } public: - FixedVersion version; /* Version of CFF2 table. set to 0x0200u */ - OffsetTo topDict; /* headerSize = Offset to Top DICT. */ - HBUINT16 topDictSize; /* Top DICT size */ + FixedVersion version; /* Version of CFF2 table. set to 0x0200u */ + NNOffsetTo topDict; /* headerSize = Offset to Top DICT. */ + HBUINT16 topDictSize; /* Top DICT size */ public: DEFINE_SIZE_STATIC (5); 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 7567e52cf1e..0526c35cb99 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 @@ -92,23 +92,23 @@ struct CmapSubtableFormat4 this->format.set (4); this->length.set (get_sub_table_size (segments)); - this->segCountX2.set (segments.len * 2); - this->entrySelector.set (MAX (1u, hb_bit_storage (segments.len)) - 1); + this->segCountX2.set (segments.length * 2); + this->entrySelector.set (MAX (1u, hb_bit_storage (segments.length)) - 1); this->searchRange.set (2 * (1u << this->entrySelector)); - this->rangeShift.set (segments.len * 2 > this->searchRange - ? 2 * segments.len - this->searchRange + this->rangeShift.set (segments.length * 2 > this->searchRange + ? 2 * segments.length - this->searchRange : 0); - HBUINT16 *end_count = c->allocate_size (HBUINT16::static_size * segments.len); + HBUINT16 *end_count = c->allocate_size (HBUINT16::static_size * segments.length); c->allocate_size (HBUINT16::static_size); // 2 bytes of padding. - HBUINT16 *start_count = c->allocate_size (HBUINT16::static_size * segments.len); - HBINT16 *id_delta = c->allocate_size (HBUINT16::static_size * segments.len); - HBUINT16 *id_range_offset = c->allocate_size (HBUINT16::static_size * segments.len); + HBUINT16 *start_count = c->allocate_size (HBUINT16::static_size * segments.length); + HBINT16 *id_delta = c->allocate_size (HBUINT16::static_size * segments.length); + HBUINT16 *id_range_offset = c->allocate_size (HBUINT16::static_size * segments.length); if (id_range_offset == nullptr) return_trace (false); - for (unsigned int i = 0; i < segments.len; i++) + for (unsigned int i = 0; i < segments.length; i++) { end_count[i].set (segments[i].end_code); start_count[i].set (segments[i].start_code); @@ -157,7 +157,7 @@ struct CmapSubtableFormat4 static size_t get_sub_table_size (const hb_vector_t &segments) { size_t segment_size = 0; - for (unsigned int i = 0; i < segments.len; i++) + for (unsigned int i = 0; i < segments.length; i++) { // Parallel array entries segment_size += @@ -532,7 +532,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented static size_t get_sub_table_size (const hb_vector_t &groups) { - return 16 + 12 * groups.len; + return 16 + 12 * groups.length; } static bool create_sub_table_plan (const hb_subset_plan_t *plan, @@ -560,7 +560,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented } DEBUG_MSG(SUBSET, nullptr, "cmap"); - for (unsigned int i = 0; i < groups->len; i++) { + for (unsigned int i = 0; i < groups->length; i++) { CmapSubtableLongGroup& group = (*groups)[i]; DEBUG_MSG(SUBSET, nullptr, " %d: U+%04X-U+%04X, gid %d-%d", i, (uint32_t) group.startCharCode, (uint32_t) group.endCharCode, (uint32_t) group.glyphID, (uint32_t) group.glyphID + ((uint32_t) group.endCharCode - (uint32_t) group.startCharCode)); } @@ -841,7 +841,7 @@ struct EncodingRecord struct cmap { - enum { tableTag = HB_OT_TAG_cmap }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_cmap; struct subset_plan { @@ -1054,8 +1054,8 @@ struct cmap done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph); done++) { - first_unicode = &StructAtOffset (first_unicode, unicode_stride); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_unicode = &StructAtOffsetUnaligned (first_unicode, unicode_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); } return done; } 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 b1971a7615b..333ceaaba81 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 @@ -56,7 +56,7 @@ struct SmallGlyphMetrics extents->x_bearing = bearingX; extents->y_bearing = bearingY; extents->width = width; - extents->height = -height; + extents->height = - (hb_position_t) height; } HBUINT8 height; @@ -283,7 +283,7 @@ struct BitmapSizeTable } protected: - LOffsetTo + LNNOffsetTo indexSubtableArrayOffset; HBUINT32 indexTablesSize; HBUINT32 numberOfIndexSubtables; @@ -332,7 +332,7 @@ struct CBLC { friend struct CBDT; - enum { tableTag = HB_OT_TAG_CBLC }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_CBLC; bool sanitize (hb_sanitize_context_t *c) const { @@ -378,7 +378,7 @@ struct CBLC struct CBDT { - enum { tableTag = HB_OT_TAG_CBDT }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_CBDT; struct accelerator_t { 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 3883604a535..a57911ad0aa 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 @@ -87,7 +87,7 @@ struct BaseGlyphRecord struct COLR { - enum { tableTag = HB_OT_TAG_COLR }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_COLR; bool has_data () const { return numBaseGlyphs; } @@ -104,14 +104,14 @@ struct COLR if (count) { hb_array_t segment_layers = glyph_layers.sub_array (start_offset, *count); - *count = segment_layers.len; - for (unsigned int i = 0; i < segment_layers.len; i++) + *count = segment_layers.length; + for (unsigned int i = 0; i < segment_layers.length; i++) { layers[i].glyph = segment_layers.arrayZ[i].glyphId; layers[i].color_index = segment_layers.arrayZ[i].colorIdx; } } - return glyph_layers.len; + return glyph_layers.length; } bool sanitize (hb_sanitize_context_t *c) const @@ -125,9 +125,9 @@ struct COLR protected: HBUINT16 version; /* Table version number (starts at 0). */ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */ - LOffsetTo, false> + LNNOffsetTo > baseGlyphsZ; /* Offset to Base Glyph records. */ - LOffsetTo, false> + LNNOffsetTo > layersZ; /* Offset to Layer Records. */ HBUINT16 numLayers; /* Number of Layer Records. */ public: 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 bd57d8a3591..4070493504b 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 @@ -87,15 +87,15 @@ struct CPALV1Tail } protected: - LOffsetTo, false> + LNNOffsetTo > paletteFlagsZ; /* Offset from the beginning of CPAL table to * the Palette Type Array. Set to 0 if no array * is provided. */ - LOffsetTo, false> + LNNOffsetTo > paletteLabelsZ; /* Offset from the beginning of CPAL table to * the palette labels array. Set to 0 if no * array is provided. */ - LOffsetTo, false> + LNNOffsetTo > colorLabelsZ; /* Offset from the beginning of CPAL table to * the color labels array. Set to 0 * if no array is provided. */ @@ -107,7 +107,7 @@ typedef HBUINT32 BGRAColor; struct CPAL { - enum { tableTag = HB_OT_TAG_CPAL }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_CPAL; bool has_data () const { return numPalettes; } @@ -176,7 +176,7 @@ struct CPAL HBUINT16 numPalettes; /* Number of palettes in the table. */ HBUINT16 numColorRecords; /* Total number of color records, combined for * all palettes. */ - LOffsetTo, false> + LNNOffsetTo > colorRecordsZ; /* Offset from the beginning of CPAL table to * the first ColorRecord. */ UnsizedArrayOf 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 ed93d6526b5..f6bdbb3dde0 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 @@ -130,7 +130,7 @@ struct SBIXStrike struct sbix { - enum { tableTag = HB_OT_TAG_sbix }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_sbix; bool has_data () const { return version; } 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 554453f7594..6e8eddf2473 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 @@ -62,7 +62,7 @@ struct SVGDocumentIndexEntry * this index entry. */ HBUINT16 endGlyphID; /* The last glyph ID in the range described by * this index entry. Must be >= startGlyphID. */ - LOffsetTo, false> + LNNOffsetTo > svgDoc; /* Offset from the beginning of the SVG Document Index * to an SVG document. Must be non-zero. */ HBUINT32 svgDocLength; /* Length of the SVG document. @@ -73,7 +73,7 @@ struct SVGDocumentIndexEntry struct SVG { - enum { tableTag = HB_OT_TAG_SVG }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_SVG; bool has_data () const { return svgDocEntries; } 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 c080f0fd937..20b09df524c 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 @@ -112,8 +112,8 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, for (unsigned int i = 0; i < count; i++) { *first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font)); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } } @@ -132,8 +132,8 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, for (unsigned int i = 0; i < count; i++) { *first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font)); - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); + first_glyph = &StructAtOffsetUnaligned (first_glyph, glyph_stride); + first_advance = &StructAtOffsetUnaligned (first_advance, advance_stride); } } 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 index d328fd22243..94fff58a158 100644 --- 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 @@ -57,7 +57,7 @@ struct GaspRange struct gasp { - enum { tableTag = HB_OT_TAG_gasp }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_gasp; const GaspRange &get_gasp_range (unsigned int i) const { return gaspRanges[i]; } 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 a6dec40d240..c2b38b05bae 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,7 +45,7 @@ struct loca { friend struct glyf; - enum { tableTag = HB_OT_TAG_loca }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_loca; bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const { @@ -71,7 +71,7 @@ struct loca struct glyf { - enum { tableTag = HB_OT_TAG_glyf }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_glyf; bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const { @@ -200,8 +200,8 @@ struct glyf }; static bool get_iterator (const char * glyph_data, - unsigned int length, - CompositeGlyphHeader::Iterator *iterator /* OUT */) + unsigned int length, + CompositeGlyphHeader::Iterator *iterator /* OUT */) { if (length < GlyphHeader::static_size) return false; /* Empty glyph; zero extents. */ @@ -355,8 +355,8 @@ struct glyf } bool get_offsets (hb_codepoint_t glyph, - unsigned int *start_offset /* OUT */, - unsigned int *end_offset /* OUT */) const + unsigned int *start_offset /* OUT */, + unsigned int *end_offset /* OUT */) const { if (unlikely (glyph >= num_glyphs)) return false; 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 48421ee2cbb..95229c523b7 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 @@ -57,7 +57,7 @@ struct DeviceRecord } unsigned int len () const - { return this->subset_plan->glyphs.len; } + { return this->subset_plan->glyphs.length; } const HBUINT8* operator [] (unsigned int i) const { @@ -119,7 +119,7 @@ struct DeviceRecord struct hdmx { - enum { tableTag = HB_OT_TAG_hdmx }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_hdmx; unsigned int get_size () const { return min_size + numRecords * sizeDeviceRecord; } @@ -140,7 +140,7 @@ struct hdmx this->version.set (source_hdmx->version); this->numRecords.set (source_hdmx->numRecords); - this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->glyphs.len)); + this->sizeDeviceRecord.set (DeviceRecord::get_size (plan->glyphs.length)); for (unsigned int i = 0; i < source_hdmx->numRecords; i++) { @@ -156,7 +156,7 @@ struct hdmx 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); + return min_size + source_hdmx->numRecords * DeviceRecord::get_size (plan->glyphs.length); } bool subset (hb_subset_plan_t *plan) const 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 41062ca326a..3c0bb3d6ddd 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,7 +45,7 @@ struct head { friend struct OffsetTable; - enum { tableTag = HB_OT_TAG_head }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_head; unsigned int get_upem () const { 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 7bc1817eefe..c3155b79eef 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 @@ -86,10 +86,10 @@ struct _hea }; struct hhea : _hea { - enum { tableTag = HB_OT_TAG_hhea }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_hhea; }; struct vhea : _hea { - enum { tableTag = HB_OT_TAG_vhea }; + static constexpr hb_tag_t 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 fa74a0e3858..a95a56f32de 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 @@ -94,7 +94,7 @@ struct hmtxvmtx /* All the trailing glyphs with the same advance can use one LongMetric * and just keep LSB */ hb_vector_t &gids = plan->glyphs; - unsigned int num_advances = gids.len; + unsigned int num_advances = gids.length; unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]); while (num_advances > 1 && last_advance == _mtx.get_advance (gids[num_advances - 2])) @@ -104,14 +104,14 @@ struct hmtxvmtx /* alloc the new table */ size_t dest_sz = num_advances * 4 - + (gids.len - num_advances) * 2; + + (gids.length - num_advances) * 2; void *dest = (void *) malloc (dest_sz); if (unlikely (!dest)) { return false; } DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in src has %d advances, %d lsbs", HB_UNTAG(T::tableTag), _mtx.num_advances, _mtx.num_metrics - _mtx.num_advances); - DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in dest has %d advances, %d lsbs, %u bytes", HB_UNTAG(T::tableTag), num_advances, gids.len - num_advances, (unsigned int) dest_sz); + DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in dest has %d advances, %d lsbs, %u bytes", HB_UNTAG(T::tableTag), num_advances, gids.length - num_advances, (unsigned int) dest_sz); const char *source_table = hb_blob_get_data (_mtx.table.get_blob (), nullptr); // Copy everything over @@ -120,7 +120,7 @@ struct hmtxvmtx char * dest_pos = (char *) dest; bool failed = false; - for (unsigned int i = 0; i < gids.len; i++) + for (unsigned int i = 0; i < gids.length; i++) { /* the last metric or the one for gids[i] */ LongMetric *src_metric = old_metrics + MIN ((hb_codepoint_t) _mtx.num_advances - 1, gids[i]); @@ -323,14 +323,14 @@ struct hmtxvmtx }; struct hmtx : hmtxvmtx { - enum { tableTag = HB_OT_TAG_hmtx }; - enum { variationsTag = HB_OT_TAG_HVAR }; - enum { os2Tag = HB_OT_TAG_OS2 }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_hmtx; + static constexpr hb_tag_t variationsTag = HB_OT_TAG_HVAR; + static constexpr hb_tag_t os2Tag = HB_OT_TAG_OS2; }; struct vmtx : hmtxvmtx { - enum { tableTag = HB_OT_TAG_vmtx }; - enum { variationsTag = HB_OT_TAG_VVAR }; - enum { os2Tag = HB_TAG_NONE }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_vmtx; + static constexpr hb_tag_t variationsTag = HB_OT_TAG_VVAR; + static constexpr hb_tag_t 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 5e75d083b76..ec6a3c84c2b 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 @@ -160,7 +160,7 @@ struct KernSubTable struct KernOTSubTableHeader { - enum { apple = false }; + static constexpr bool apple = false; typedef AAT::ObsoleteTypes Types; unsigned int tuple_count () const { return 0; } @@ -197,8 +197,8 @@ struct KernOT : AAT::KerxTable { friend struct AAT::KerxTable; - enum { tableTag = HB_OT_TAG_kern }; - enum { minVersion = 0u }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_kern; + static constexpr unsigned minVersion = 0u; typedef KernOTSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; @@ -215,7 +215,7 @@ struct KernOT : AAT::KerxTable struct KernAATSubTableHeader { - enum { apple = true }; + static constexpr bool apple = true; typedef AAT::ObsoleteTypes Types; unsigned int tuple_count () const { return 0; } @@ -252,8 +252,8 @@ struct KernAAT : AAT::KerxTable { friend struct AAT::KerxTable; - enum { tableTag = HB_OT_TAG_kern }; - enum { minVersion = 0x00010000u }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_kern; + static constexpr unsigned minVersion = 0x00010000u; typedef KernAATSubTableHeader SubTableHeader; typedef SubTableHeader::Types Types; @@ -269,7 +269,7 @@ struct KernAAT : AAT::KerxTable struct kern { - enum { tableTag = HB_OT_TAG_kern }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_kern; bool has_data () const { return u.version32; } unsigned int get_type () const { return u.major; } 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 6c39932670f..dd0fba1ff40 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 @@ -464,7 +464,7 @@ struct Axis struct BASE { - enum { tableTag = HB_OT_TAG_BASE }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_BASE; const Axis &get_axis (hb_direction_t direction) const { return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; } 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 d9f5728b65c..39a8bbabdff 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 @@ -900,14 +900,14 @@ struct CoverageFormat2 TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!glyphs.len)) + if (unlikely (!glyphs.length)) { rangeRecord.len.set (0); return_trace (true); } unsigned int num_ranges = 1; - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) if (glyphs[i - 1] + 1 != glyphs[i]) num_ranges++; rangeRecord.len.set (num_ranges); @@ -916,7 +916,7 @@ struct CoverageFormat2 unsigned int range = 0; rangeRecord[range].start = glyphs[0]; rangeRecord[range].value.set (0); - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) { if (glyphs[i - 1] + 1 != glyphs[i]) { @@ -1048,10 +1048,10 @@ struct Coverage if (unlikely (!c->extend_min (*this))) return_trace (false); unsigned int num_ranges = 1; - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) if (glyphs[i - 1] + 1 != glyphs[i]) num_ranges++; - u.format.set (glyphs.len * 2 < num_ranges * 3 ? 1 : 2); + u.format.set (glyphs.length * 2 < num_ranges * 3 ? 1 : 2); switch (u.format) { @@ -1199,7 +1199,7 @@ struct ClassDefFormat1 TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!glyphs.len)) + if (unlikely (!glyphs.length)) { startGlyph.set (0); classValue.len.set (0); @@ -1207,13 +1207,13 @@ struct ClassDefFormat1 } hb_codepoint_t glyph_min = glyphs[0]; - hb_codepoint_t glyph_max = glyphs[glyphs.len - 1]; + hb_codepoint_t glyph_max = glyphs[glyphs.length - 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++) + for (unsigned int i = 0; i < glyphs.length; i++) classValue[glyphs[i] - glyph_min] = klasses[i]; return_trace (true); @@ -1239,7 +1239,7 @@ struct ClassDefFormat1 } c->serializer->propagate_error (glyphs, klasses); ClassDef_serialize (c->serializer, glyphs, klasses); - return_trace (glyphs.len); + return_trace (glyphs.length); } bool sanitize (hb_sanitize_context_t *c) const @@ -1335,14 +1335,14 @@ struct ClassDefFormat2 TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!glyphs.len)) + if (unlikely (!glyphs.length)) { rangeRecord.len.set (0); return_trace (true); } unsigned int num_ranges = 1; - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) if (glyphs[i - 1] + 1 != glyphs[i] || klasses[i - 1] != klasses[i]) num_ranges++; @@ -1352,7 +1352,7 @@ struct ClassDefFormat2 unsigned int range = 0; rangeRecord[range].start = glyphs[0]; rangeRecord[range].value.set (klasses[0]); - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) { if (glyphs[i - 1] + 1 != glyphs[i] || klasses[i - 1] != klasses[i]) @@ -1390,7 +1390,7 @@ struct ClassDefFormat2 } c->serializer->propagate_error (glyphs, klasses); ClassDef_serialize (c->serializer, glyphs, klasses); - return_trace (glyphs.len); + return_trace (glyphs.length); } bool sanitize (hb_sanitize_context_t *c) const @@ -1485,13 +1485,13 @@ struct ClassDef if (unlikely (!c->extend_min (*this))) return_trace (false); unsigned int format = 2; - if (glyphs.len) + if (glyphs.length) { hb_codepoint_t glyph_min = glyphs[0]; - hb_codepoint_t glyph_max = glyphs[glyphs.len - 1]; + hb_codepoint_t glyph_max = glyphs[glyphs.length - 1]; unsigned int num_ranges = 1; - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) if (glyphs[i - 1] + 1 != glyphs[i] || klasses[i - 1] != klasses[i]) num_ranges++; @@ -1949,7 +1949,7 @@ struct FeatureVariationRecord struct FeatureVariations { - enum { NOT_FOUND_INDEX = 0xFFFFFFFFu }; + static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFFFFFu; bool find_index (const int *coords, unsigned int coord_len, unsigned int *index) const 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 3099fb96a80..06c26fbb42c 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 @@ -64,7 +64,7 @@ struct AttachList if (point_count) { hb_array_t array = points.sub_array (start_offset, point_count); - unsigned int count = array.len; + unsigned int count = array.length; for (unsigned int i = 0; i < count; i++) point_array[i] = array[i]; } @@ -221,7 +221,7 @@ struct LigGlyph if (caret_count) { hb_array_t > array = carets.sub_array (start_offset, caret_count); - unsigned int count = array.len; + unsigned int count = array.length; for (unsigned int i = 0; i < count; i++) caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store); } @@ -341,7 +341,7 @@ struct MarkGlyphSets struct GDEF { - enum { tableTag = HB_OT_TAG_GDEF }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_GDEF; enum GlyphClasses { UnclassifiedGlyph = 0, 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 b123336109b..e17a2824168 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 @@ -84,16 +84,16 @@ struct ValueFormat : HBUINT16 HBINT16 yAdvance; /* Vertical adjustment for advance--in * design units (only used for vertical * writing) */ - Offset xPlaDevice; /* Offset to Device table for + OffsetTo xPlaDevice; /* Offset to Device table for * horizontal placement--measured from * beginning of PosTable (may be NULL) */ - Offset yPlaDevice; /* Offset to Device table for vertical + OffsetTo yPlaDevice; /* Offset to Device table for vertical * placement--measured from beginning * of PosTable (may be NULL) */ - Offset xAdvDevice; /* Offset to Device table for + OffsetTo xAdvDevice; /* Offset to Device table for * horizontal advance--measured from * beginning of PosTable (may be NULL) */ - Offset yAdvDevice; /* Offset to Device table for vertical + OffsetTo yAdvDevice; /* Offset to Device table for vertical * advance--measured from beginning of * PosTable (may be NULL) */ #endif @@ -177,13 +177,13 @@ struct ValueFormat : HBUINT16 { return *CastP > (value); } static const OffsetTo& get_device (const Value* value, bool *worked=nullptr) { - if (worked) *worked |= *value; + if (worked) *worked |= bool (*value); return *CastP > (value); } static const HBINT16& get_short (const Value* value, bool *worked=nullptr) { - if (worked) *worked |= *value; + if (worked) *worked |= bool (*value); return *CastP (value); } @@ -472,10 +472,7 @@ struct SinglePosFormat1 { return (this+coverage).intersects (glyphs); } 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+coverage).add_coverage (c->input))) return; } const Coverage &get_coverage () const { return this+coverage; } @@ -527,10 +524,7 @@ struct SinglePosFormat2 { return (this+coverage).intersects (glyphs); } 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+coverage).add_coverage (c->input))) return; } const Coverage &get_coverage () const { return this+coverage; } @@ -642,7 +636,6 @@ struct PairSet void collect_glyphs (hb_collect_glyphs_context_t *c, const ValueFormat *valueFormats) const { - TRACE_COLLECT_GLYPHS (this); unsigned int len1 = valueFormats[0].get_len (); unsigned int len2 = valueFormats[1].get_len (); unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2); @@ -743,7 +736,6 @@ struct PairPosFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count = pairSet.len; for (unsigned int i = 0; i < count; i++) @@ -820,7 +812,6 @@ struct PairPosFormat2 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; } @@ -971,10 +962,7 @@ struct CursivePosFormat1 { return (this+coverage).intersects (glyphs); } 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+coverage).add_coverage (c->input))) return; } const Coverage &get_coverage () const { return this+coverage; } @@ -1138,7 +1126,6 @@ struct MarkBasePosFormat1 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; } @@ -1260,7 +1247,6 @@ struct MarkLigPosFormat1 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; } @@ -1381,7 +1367,6 @@ struct MarkMarkPosFormat1 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; } @@ -1584,10 +1569,7 @@ struct PosLookup : Lookup } hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const - { - TRACE_COLLECT_GLYPHS (this); - return_trace (dispatch (c)); - } + { return dispatch (c); } template void add_coverage (set_t *glyphs) const @@ -1619,7 +1601,7 @@ struct PosLookup : Lookup struct GPOS : GSUBGPOS { - enum { tableTag = HB_OT_TAG_GPOS }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_GPOS; const PosLookup& get_lookup (unsigned int i) const { return CastR (GSUBGPOS::get_lookup (i)); } 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 180e7f2decd..33b8f0ebda1 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 @@ -46,7 +46,6 @@ struct SingleSubstFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { /* TODO Switch to range-based API to work around malicious fonts. @@ -59,7 +58,6 @@ struct SingleSubstFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { @@ -120,7 +118,7 @@ struct SingleSubstFormat1 } c->serializer->propagate_error (from, to); SingleSubst_serialize (c->serializer, from, to); - return_trace (from.len); + return_trace (from.length); } bool sanitize (hb_sanitize_context_t *c) const @@ -147,7 +145,6 @@ struct SingleSubstFormat2 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = substitute.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { @@ -160,7 +157,6 @@ struct SingleSubstFormat2 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count = substitute.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -218,7 +214,7 @@ struct SingleSubstFormat2 } c->serializer->propagate_error (from, to); SingleSubst_serialize (c->serializer, from, to); - return_trace (from.len); + return_trace (from.length); } bool sanitize (hb_sanitize_context_t *c) const @@ -249,12 +245,12 @@ struct SingleSubst if (unlikely (!c->extend_min (u.format))) return_trace (false); unsigned int format = 2; int delta = 0; - if (glyphs.len) + if (glyphs.length) { format = 1; /* TODO(serialize) check for wrap-around */ delta = substitutes[0] - glyphs[0]; - for (unsigned int i = 1; i < glyphs.len; i++) + for (unsigned int i = 1; i < glyphs.length; i++) if (delta != (int) (substitutes[i] - glyphs[i])) { format = 2; break; @@ -298,17 +294,13 @@ struct Sequence { void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = substitute.len; for (unsigned int i = 0; i < count; i++) c->out->add (substitute[i]); } void collect_glyphs (hb_collect_glyphs_context_t *c) const - { - TRACE_COLLECT_GLYPHS (this); - c->output->add_array (substitute.arrayZ, substitute.len); - } + { c->output->add_array (substitute.arrayZ, substitute.len); } bool apply (hb_ot_apply_context_t *c) const { @@ -369,7 +361,6 @@ struct MultipleSubstFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = sequence.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { @@ -382,7 +373,6 @@ struct MultipleSubstFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count = sequence.len; for (unsigned int i = 0; i < count; i++) @@ -414,8 +404,8 @@ struct MultipleSubstFormat1 { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!sequence.serialize (c, glyphs.len))) return_trace (false); - for (unsigned int i = 0; i < glyphs.len; i++) + if (unlikely (!sequence.serialize (c, glyphs.length))) return_trace (false); + for (unsigned int i = 0; i < glyphs.length; i++) { unsigned int substitute_len = substitute_len_list[i]; if (unlikely (!sequence[i].serialize (c, this) @@ -490,17 +480,13 @@ struct AlternateSet { void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = alternates.len; for (unsigned int i = 0; i < count; i++) c->out->add (alternates[i]); } void collect_glyphs (hb_collect_glyphs_context_t *c) const - { - TRACE_COLLECT_GLYPHS (this); - c->output->add_array (alternates.arrayZ, alternates.len); - } + { c->output->add_array (alternates.arrayZ, alternates.len); } bool apply (hb_ot_apply_context_t *c) const { @@ -555,7 +541,6 @@ struct AlternateSubstFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = alternateSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { @@ -568,7 +553,6 @@ struct AlternateSubstFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count = alternateSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -604,8 +588,8 @@ struct AlternateSubstFormat1 { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!alternateSet.serialize (c, glyphs.len))) return_trace (false); - for (unsigned int i = 0; i < glyphs.len; i++) + if (unlikely (!alternateSet.serialize (c, glyphs.length))) return_trace (false); + for (unsigned int i = 0; i < glyphs.length; i++) { unsigned int alternate_len = alternate_len_list[i]; if (unlikely (!alternateSet[i].serialize (c, this) @@ -690,7 +674,6 @@ struct Ligature void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = component.lenP1; for (unsigned int i = 1; i < count; i++) if (!c->glyphs->has (component[i])) @@ -700,7 +683,6 @@ struct Ligature 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); } @@ -798,7 +780,6 @@ struct LigatureSet void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int num_ligs = ligature.len; for (unsigned int i = 0; i < num_ligs; i++) (this+ligature[i]).closure (c); @@ -806,7 +787,6 @@ struct LigatureSet void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); unsigned int num_ligs = ligature.len; for (unsigned int i = 0; i < num_ligs; i++) (this+ligature[i]).collect_glyphs (c); @@ -841,12 +821,12 @@ struct LigatureSet bool serialize (hb_serialize_context_t *c, hb_array_t ligatures, hb_array_t component_count_list, - hb_array_t component_list /* Starting from second for each ligature */) + hb_array_t &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, ligatures.len))) return_trace (false); - for (unsigned int i = 0; i < ligatures.len; i++) + if (unlikely (!ligature.serialize (c, ligatures.length))) return_trace (false); + for (unsigned int i = 0; i < ligatures.length; i++) { unsigned int component_count = MAX (component_count_list[i] - 1, 0); if (unlikely (!ligature[i].serialize (c, this) @@ -891,7 +871,6 @@ struct LigatureSubstFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); unsigned int count = ligatureSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) { @@ -904,7 +883,6 @@ struct LigatureSubstFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count = ligatureSet.len; for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) @@ -947,8 +925,8 @@ struct LigatureSubstFormat1 { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - if (unlikely (!ligatureSet.serialize (c, first_glyphs.len))) return_trace (false); - for (unsigned int i = 0; i < first_glyphs.len; i++) + if (unlikely (!ligatureSet.serialize (c, first_glyphs.length))) return_trace (false); + for (unsigned int i = 0; i < first_glyphs.length; i++) { unsigned int ligature_count = ligature_per_first_glyph_count_list[i]; if (unlikely (!ligatureSet[i].serialize (c, this) @@ -958,8 +936,6 @@ struct LigatureSubstFormat1 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 (component_count_list[i] - 1, 0); } return_trace (coverage.serialize (c, this).serialize (c, first_glyphs)); } @@ -1070,7 +1046,6 @@ struct ReverseChainSingleSubstFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); const OffsetArrayOf &lookahead = StructAfter > (backtrack); unsigned int count; @@ -1098,7 +1073,6 @@ struct ReverseChainSingleSubstFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); if (unlikely (!(this+coverage).add_coverage (c->input))) return; unsigned int count; @@ -1304,9 +1278,8 @@ struct SubstLookup : Lookup 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)) - return_trace (HB_VOID); + return hb_closure_context_t::default_return_value (); c->set_recurse_func (dispatch_closure_recurse_func); @@ -1314,14 +1287,13 @@ struct SubstLookup : Lookup c->flush (); - return_trace (ret); + return ret; } 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); - return_trace (dispatch (c)); + return dispatch (c); } template @@ -1438,7 +1410,7 @@ struct SubstLookup : Lookup struct GSUB : GSUBGPOS { - enum { tableTag = HB_OT_TAG_GSUB }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_GSUB; const SubstLookup& get_lookup (unsigned int i) const { return CastR (GSUBGPOS::get_lookup (i)); } 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 ac6e646384f..88d834da4be 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 @@ -59,7 +59,7 @@ struct hb_intersects_context_t : }; struct hb_closure_context_t : - hb_dispatch_context_t + hb_dispatch_context_t { const char *get_name () { return "CLOSURE"; } typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); @@ -151,7 +151,7 @@ struct hb_would_apply_context_t : struct hb_collect_glyphs_context_t : - hb_dispatch_context_t + hb_dispatch_context_t { const char *get_name () { return "COLLECT_GLYPHS"; } typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); @@ -643,7 +643,7 @@ struct hb_get_subtables_context_t : hb_set_digest_t digest; }; - typedef hb_vector_t array_t; + typedef hb_vector_t array_t; /* Dispatch interface. */ const char *get_name () { return "GET_SUBTABLES"; } @@ -1296,7 +1296,6 @@ struct Rule void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const { - TRACE_CLOSURE (this); const UnsizedArrayOf &lookupRecord = StructAfter > (inputZ.as_array ((inputCount ? inputCount - 1 : 0))); context_closure_lookup (c, @@ -1308,7 +1307,6 @@ struct Rule void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const { - TRACE_COLLECT_GLYPHS (this); const UnsizedArrayOf &lookupRecord = StructAfter > (inputZ.as_array (inputCount ? inputCount - 1 : 0)); context_collect_glyphs_lookup (c, @@ -1376,7 +1374,6 @@ struct RuleSet void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const { - TRACE_CLOSURE (this); unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) (this+rule[i]).closure (c, lookup_context); @@ -1385,7 +1382,6 @@ struct RuleSet void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const { - TRACE_COLLECT_GLYPHS (this); unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) (this+rule[i]).collect_glyphs (c, lookup_context); @@ -1455,8 +1451,6 @@ struct ContextFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); - struct ContextClosureLookupContext lookup_context = { {intersects_glyph}, nullptr @@ -1474,7 +1468,6 @@ struct ContextFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); struct ContextCollectGlyphsLookupContext lookup_context = { @@ -1567,7 +1560,6 @@ struct ContextFormat2 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); if (!(this+coverage).intersects (c->glyphs)) return; @@ -1588,7 +1580,6 @@ struct ContextFormat2 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); const ClassDef &class_def = this+classDef; @@ -1681,7 +1672,6 @@ struct ContextFormat3 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); if (!(this+coverageZ[0]).intersects (c->glyphs)) return; @@ -1698,7 +1688,6 @@ struct ContextFormat3 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); (this+coverageZ[0]).add_coverage (c->input); const LookupRecord *lookupRecord = &StructAfter (coverageZ.as_array (glyphCount)); @@ -1950,7 +1939,6 @@ struct ChainRule void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const { - TRACE_CLOSURE (this); const HeadlessArrayOf &input = StructAfter > (backtrack); const ArrayOf &lookahead = StructAfter > (input); const ArrayOf &lookup = StructAfter > (lookahead); @@ -1965,7 +1953,6 @@ struct ChainRule void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const { - TRACE_COLLECT_GLYPHS (this); const HeadlessArrayOf &input = StructAfter > (backtrack); const ArrayOf &lookahead = StructAfter > (input); const ArrayOf &lookup = StructAfter > (lookahead); @@ -2046,7 +2033,6 @@ struct ChainRuleSet } void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const { - TRACE_CLOSURE (this); unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) (this+rule[i]).closure (c, lookup_context); @@ -2054,7 +2040,6 @@ struct ChainRuleSet void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const { - TRACE_COLLECT_GLYPHS (this); unsigned int num_rules = rule.len; for (unsigned int i = 0; i < num_rules; i++) (this+rule[i]).collect_glyphs (c, lookup_context); @@ -2119,8 +2104,6 @@ struct ChainContextFormat1 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); - struct ChainContextClosureLookupContext lookup_context = { {intersects_glyph}, {nullptr, nullptr, nullptr} @@ -2138,7 +2121,6 @@ struct ChainContextFormat1 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); struct ChainContextCollectGlyphsLookupContext lookup_context = { @@ -2232,7 +2214,6 @@ struct ChainContextFormat2 } void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); if (!(this+coverage).intersects (c->glyphs)) return; @@ -2257,7 +2238,6 @@ struct ChainContextFormat2 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); (this+coverage).add_coverage (c->input); const ClassDef &backtrack_class_def = this+backtrackClassDef; @@ -2382,7 +2362,6 @@ struct ChainContextFormat3 void closure (hb_closure_context_t *c) const { - TRACE_CLOSURE (this); const OffsetArrayOf &input = StructAfter > (backtrack); if (!(this+input[0]).intersects (c->glyphs)) @@ -2404,7 +2383,6 @@ struct ChainContextFormat3 void collect_glyphs (hb_collect_glyphs_context_t *c) const { - TRACE_COLLECT_GLYPHS (this); const OffsetArrayOf &input = StructAfter > (backtrack); (this+input[0]).add_coverage (c->input); @@ -2636,7 +2614,7 @@ struct hb_ot_layout_lookup_accelerator_t bool apply (hb_ot_apply_context_t *c) const { - for (unsigned int i = 0; i < subtables.len; i++) + for (unsigned int i = 0; i < subtables.length; i++) if (subtables[i].apply (c)) return true; return false; @@ -2686,7 +2664,7 @@ struct GSUBGPOS { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) .find_index (coords, num_coords, index); } const Feature& get_feature_variation (unsigned int feature_index, - unsigned int variations_index) const + unsigned int variations_index) const { if (FeatureVariations::NOT_FOUND_INDEX != variations_index && version.to_int () >= 0x00010001u) 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 3beedc49b40..1dd31d5b0c5 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 @@ -195,7 +195,7 @@ struct JstfScript struct JSTF { - enum { tableTag = HB_OT_TAG_JSTF }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_JSTF; unsigned int get_script_count () const { return scriptList.len; } 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 67ce9235349..d32be04a812 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 @@ -684,7 +684,7 @@ struct hb_collect_features_context_t feature_indexes (feature_indexes_), script_count(0),langsys_count(0) {} - bool inline visited (const OT::Script &s) + bool visited (const OT::Script &s) { /* We might have Null() object here. Don't want to involve * that in the memoize. So, detect empty objects and return. */ @@ -697,7 +697,7 @@ struct hb_collect_features_context_t return visited (s, visited_script); } - bool inline visited (const OT::LangSys &l) + bool visited (const OT::LangSys &l) { /* We might have Null() object here. Don't want to involve * that in the memoize. So, detect empty objects and return. */ @@ -713,7 +713,7 @@ struct hb_collect_features_context_t private: template - bool inline visited (const T &p, hb_set_t &visited_set) + bool visited (const T &p, hb_set_t &visited_set) { hb_codepoint_t delta = (hb_codepoint_t) ((uintptr_t) &p - (uintptr_t) &g); if (visited_set.has (delta)) @@ -1299,8 +1299,8 @@ hb_ot_layout_feature_get_characters (hb_face_t *face, struct GSUBProxy { - enum { table_index = 0 }; - enum { inplace = false }; + static constexpr unsigned table_index = 0u; + static constexpr bool inplace = false; typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : @@ -1313,8 +1313,8 @@ struct GSUBProxy struct GPOSProxy { - enum { table_index = 1 }; - enum { inplace = true }; + static constexpr unsigned table_index = 1u; + static constexpr bool inplace = true; typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : @@ -1387,7 +1387,7 @@ apply_string (OT::hb_ot_apply_context_t *c, if (likely (!lookup.is_reverse ())) { /* in/out forward substitution/positioning */ - if (Proxy::table_index == 0) + if (Proxy::table_index == 0u) buffer->clear_output (); buffer->idx = 0; @@ -1404,7 +1404,7 @@ apply_string (OT::hb_ot_apply_context_t *c, else { /* in-place backward substitution/positioning */ - if (Proxy::table_index == 0) + if (Proxy::table_index == 0u) buffer->remove_output (); buffer->idx = buffer->len - 1; @@ -1423,7 +1423,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, OT::hb_ot_apply_context_t c (table_index, font, buffer); c.set_recurse_func (Proxy::Lookup::apply_recurse_func); - for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stage_index++) { + for (unsigned int stage_index = 0; stage_index < stages[table_index].length; stage_index++) { const stage_map_t *stage = &stages[table_index][stage_index]; for (; i < stage->last_lookup; i++) { 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 884202cb1e2..ef0bcc716df 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 @@ -33,7 +33,7 @@ void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const { - for (unsigned int i = 0; i < lookups[table_index].len; i++) + for (unsigned int i = 0; i < lookups[table_index].length; i++) hb_set_add (lookups_out, lookups[table_index][i].index); } @@ -82,7 +82,7 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, if (unlikely (!tag)) return; feature_info_t *info = feature_infos.push(); info->tag = tag; - info->seq = feature_infos.len; + info->seq = feature_infos.length; info->max_value = value; info->flags = flags; info->default_value = (flags & F_GLOBAL) ? value : 0; @@ -174,11 +174,11 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, } /* Sort features and merge duplicates */ - if (feature_infos.len) + if (feature_infos.length) { feature_infos.qsort (); unsigned int j = 0; - for (unsigned int i = 1; i < feature_infos.len; i++) + for (unsigned int i = 1; i < feature_infos.length; i++) if (feature_infos[i].tag != feature_infos[j].tag) feature_infos[++j] = feature_infos[i]; else { @@ -202,7 +202,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, /* Allocate bits now */ unsigned int next_bit = global_bit_shift + 1; - for (unsigned int i = 0; i < feature_infos.len; i++) + for (unsigned int i = 0; i < feature_infos.length; i++) { const feature_info_t *info = &feature_infos[i]; @@ -292,7 +292,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, key.variations_index[table_index], global_bit_mask); - for (unsigned i = 0; i < m.features.len; i++) + for (unsigned i = 0; i < m.features.length; i++) if (m.features[i].stage[table_index] == stage) add_lookups (m, table_index, m.features[i].index[table_index], @@ -303,12 +303,12 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, m.features[i].random); /* Sort lookups and merge duplicates */ - if (last_num_lookups < m.lookups[table_index].len) + if (last_num_lookups < m.lookups[table_index].length) { - m.lookups[table_index].qsort (last_num_lookups, m.lookups[table_index].len); + m.lookups[table_index].qsort (last_num_lookups, m.lookups[table_index].length); unsigned int j = last_num_lookups; - for (unsigned int i = j + 1; i < m.lookups[table_index].len; i++) + for (unsigned int i = j + 1; i < m.lookups[table_index].length; i++) if (m.lookups[table_index][i].index != m.lookups[table_index][j].index) m.lookups[table_index][++j] = m.lookups[table_index][i]; else @@ -320,9 +320,9 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, m.lookups[table_index].shrink (j + 1); } - last_num_lookups = m.lookups[table_index].len; + last_num_lookups = m.lookups[table_index].length; - if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) { + if (stage_index < stages[table_index].length && stages[table_index][stage_index].index == stage) { hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push (); stage_map->last_lookup = last_num_lookups; stage_map->pause_func = stages[table_index][stage_index].pause_func; 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 35e94934019..28407c2176e 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 @@ -145,9 +145,9 @@ struct hb_ot_map_t *lookup_count = 0; return; } - assert (stage <= stages[table_index].len); + assert (stage <= stages[table_index].length); unsigned int start = stage ? stages[table_index][stage - 1].last_lookup : 0; - unsigned int end = stage < stages[table_index].len ? stages[table_index][stage].last_lookup : lookups[table_index].len; + unsigned int end = stage < stages[table_index].length ? stages[table_index][stage].last_lookup : lookups[table_index].length; *plookups = end == start ? nullptr : &lookups[table_index][start]; *lookup_count = end - start; } @@ -167,9 +167,9 @@ struct hb_ot_map_t hb_mask_t global_mask; - hb_vector_t features; - hb_vector_t lookups[2]; /* GSUB/GPOS */ - hb_vector_t stages[2]; /* GSUB/GPOS */ + hb_vector_t features; + hb_vector_t lookups[2]; /* GSUB/GPOS */ + hb_vector_t stages[2]; /* GSUB/GPOS */ }; enum hb_ot_map_feature_flags_t @@ -275,8 +275,8 @@ struct hb_ot_map_builder_t private: unsigned int current_stage[2]; /* GSUB/GPOS */ - hb_vector_t feature_infos; - hb_vector_t stages[2]; /* GSUB/GPOS */ + hb_vector_t feature_infos; + hb_vector_t stages[2]; /* GSUB/GPOS */ }; 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 120ab065465..62bf072e94d 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 @@ -510,7 +510,7 @@ struct MathGlyphAssembly { int scale = font->dir_scale (direction); hb_array_t arr = partRecords.sub_array (start_offset, parts_count); - unsigned int count = arr.len; + unsigned int count = arr.length; for (unsigned int i = 0; i < count; i++) arr[i].extract (parts[i], scale, font); } @@ -555,7 +555,7 @@ struct MathGlyphConstruction { int scale = font->dir_scale (direction); hb_array_t arr = mathGlyphVariantRecord.sub_array (start_offset, variants_count); - unsigned int count = arr.len; + unsigned int count = arr.length; for (unsigned int i = 0; i < count; i++) { variants[i].glyph = arr[i].variantGlyph; @@ -679,7 +679,7 @@ struct MathVariants struct MATH { - enum { tableTag = HB_OT_TAG_MATH }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_MATH; bool has_data () const { return version.to_int (); } 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 ba474fd585d..e4b67ab2915 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 @@ -71,7 +71,7 @@ struct maxpV1Tail struct maxp { - enum { tableTag = HB_OT_TAG_maxp }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_maxp; unsigned int get_num_glyphs () const { return numGlyphs; } @@ -105,7 +105,7 @@ struct maxp } maxp *maxp_prime = (maxp *) hb_blob_get_data (maxp_prime_blob, nullptr); - maxp_prime->set_num_glyphs (plan->glyphs.len); + maxp_prime->set_num_glyphs (plan->glyphs.length); if (plan->drop_hints) drop_hint_fields (plan, maxp_prime); 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 705ae0e9215..c8ababd7b83 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 @@ -151,7 +151,7 @@ _hb_ot_name_entry_cmp (const void *pa, const void *pb) struct name { - enum { tableTag = HB_OT_TAG_name }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_name; unsigned int get_size () const { return min_size + count * nameRecordZ.item_size; } @@ -188,9 +188,9 @@ struct name this->table->count); this->names.init (); - this->names.alloc (all_names.len); + this->names.alloc (all_names.length); - for (unsigned int i = 0; i < all_names.len; i++) + for (unsigned int i = 0; i < all_names.length; i++) { hb_ot_name_entry_t *entry = this->names.push (); @@ -204,7 +204,7 @@ struct name /* Walk and pick best only for each name_id,language pair, * while dropping unsupported encodings. */ unsigned int j = 0; - for (unsigned int i = 0; i < this->names.len; i++) + for (unsigned int i = 0; i < this->names.length; i++) { if (this->names[i].entry_score == UNSUPPORTED || this->names[i].language == HB_LANGUAGE_INVALID) @@ -231,8 +231,8 @@ struct name const hb_ot_name_entry_t key = {name_id, {0}, language}; const hb_ot_name_entry_t *entry = (const hb_ot_name_entry_t *) hb_bsearch (&key, - this->names.arrayZ(), - this->names.len, + (const hb_ot_name_entry_t *) this->names, + this->names.length, sizeof (key), _hb_ot_name_entry_cmp_key); if (!entry) @@ -263,7 +263,7 @@ struct name /* We only implement format 0 for now. */ HBUINT16 format; /* Format selector (=0/1). */ HBUINT16 count; /* Number of name records. */ - OffsetTo, HBUINT16, false> + NNOffsetTo > stringOffset; /* Offset to start of string storage (from start of table). */ UnsizedArrayOf nameRecordZ; /* The name records where count is the number of records. */ 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 b2eda293137..907ae6ab504 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 @@ -59,8 +59,8 @@ hb_ot_name_list_names (hb_face_t *face, unsigned int *num_entries /* OUT */) { const OT::name_accelerator_t &name = *face->table.name; - if (num_entries) *num_entries = name.names.len; - return name.names.arrayZ(); + if (num_entries) *num_entries = name.names.length; + return (const hb_ot_name_entry_t *) name.names; } @@ -70,7 +70,7 @@ 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); + unsigned int src_len = bytes.length / 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; 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 4c1812c3229..68dd63e01e5 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 @@ -92,7 +92,7 @@ struct OS2V5Tail struct OS2 { - enum { tableTag = HB_OT_TAG_OS2 }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_OS2; bool has_data () const { return this != &Null (OS2); } 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 33b7070ee08..43c1143cf58 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 @@ -71,7 +71,7 @@ struct postV2Tail struct post { - enum { tableTag = HB_OT_TAG_post }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_post; bool subset (hb_subset_plan_t *plan) const { @@ -114,7 +114,7 @@ struct post const uint8_t *end = (const uint8_t *) (const void *) table + table_length; for (const uint8_t *data = pool; - index_to_offset.len < 65535 && data < end && data + *data < end; + index_to_offset.length < 65535 && data < end && data + *data < end; data += 1 + *data) index_to_offset.push (data - pool); } @@ -129,9 +129,9 @@ struct post char *buf, unsigned int buf_len) const { hb_bytes_t s = find_glyph_name (glyph); - if (!s.len) return false; + if (!s.length) return false; if (!buf_len) return true; - unsigned int len = MIN (buf_len - 1, s.len); + unsigned int len = MIN (buf_len - 1, s.length); strncpy (buf, s.arrayZ, len); buf[len] = '\0'; return true; @@ -226,7 +226,7 @@ struct post return format1_names (index); index -= NUM_FORMAT1_NAMES; - if (index >= index_to_offset.len) + if (index >= index_to_offset.length) return hb_bytes_t (); unsigned int offset = index_to_offset[index]; @@ -241,7 +241,7 @@ struct post hb_blob_ptr_t table; uint32_t version; const ArrayOf *glyphNameIndex; - hb_vector_t index_to_offset; + hb_vector_t index_to_offset; const uint8_t *pool; hb_atomic_ptr_t gids_sorted_by_name; }; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic-table.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic-table.cc index b7e4e7c7c0b..43b5ef8b7b8 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic-table.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic-table.cc @@ -16,6 +16,8 @@ #include "hb-ot-shape-complex-indic.hh" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-macros" #define ISC_A INDIC_SYLLABIC_CATEGORY_AVAGRAHA /* 16 chars; Avagraha */ #define ISC_Bi INDIC_SYLLABIC_CATEGORY_BINDU /* 83 chars; Bindu */ @@ -69,6 +71,7 @@ #define IMC_TLR INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT /* 4 chars; Top_And_Left_And_Right */ #define IMC_TR INDIC_MATRA_CATEGORY_TOP_AND_RIGHT /* 13 chars; Top_And_Right */ #define IMC_VOL INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT /* 19 chars; Visual_Order_Left */ +#pragma GCC diagnostic pop #define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use-table.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use-table.cc index 2f3eb703eaa..835b95bbfc9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use-table.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use-table.cc @@ -17,6 +17,8 @@ #include "hb-ot-shape-complex-use.hh" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-macros" #define B USE_B /* BASE */ #define CGJ USE_CGJ /* CGJ */ #define CS USE_CS /* CONS_WITH_STACKER */ @@ -55,6 +57,7 @@ #define VMBlw USE_VMBlw #define VMPst USE_VMPst #define VMAbv USE_VMAbv +#pragma GCC diagnostic pop static const USE_TABLE_ELEMENT_TYPE use_table[] = { diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc index d3afdffaf2c..f9d4a75f51c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc @@ -180,12 +180,18 @@ _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t static void zero_mark_advances (hb_buffer_t *buffer, unsigned int start, - unsigned int end) + unsigned int end, + bool adjust_offsets_when_zeroing) { hb_glyph_info_t *info = buffer->info; for (unsigned int i = start; i < end; i++) if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) { + if (adjust_offsets_when_zeroing) + { + buffer->pos[i].x_offset -= buffer->pos[i].x_advance; + buffer->pos[i].y_offset -= buffer->pos[i].y_advance; + } buffer->pos[i].x_advance = 0; buffer->pos[i].y_advance = 0; } @@ -303,7 +309,8 @@ position_around_base (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer, unsigned int base, - unsigned int end) + unsigned int end, + bool adjust_offsets_when_zeroing) { hb_direction_t horiz_dir = HB_DIRECTION_INVALID; @@ -314,11 +321,15 @@ position_around_base (const hb_ot_shape_plan_t *plan, &base_extents)) { /* If extents don't work, zero marks and go home. */ - zero_mark_advances (buffer, base + 1, end); + zero_mark_advances (buffer, base + 1, end, adjust_offsets_when_zeroing); return; } - base_extents.x_bearing += buffer->pos[base].x_offset; base_extents.y_bearing += buffer->pos[base].y_offset; + /* Use horizontal advance for horizontal positioning. + * Generally a better idea. Also works for zero-ink glyphs. See: + * https://github.com/harfbuzz/harfbuzz/issues/1532 */ + base_extents.x_bearing = 0; + base_extents.width = font->get_glyph_h_advance (buffer->info[base].codepoint); unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[base]); /* Use integer for num_lig_components such that it doesn't convert to unsigned @@ -394,7 +405,8 @@ position_cluster (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer, unsigned int start, - unsigned int end) + unsigned int end, + bool adjust_offsets_when_zeroing) { if (end - start < 2) return; @@ -410,7 +422,7 @@ position_cluster (const hb_ot_shape_plan_t *plan, if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[j]))) break; - position_around_base (plan, font, buffer, i, j); + position_around_base (plan, font, buffer, i, j, adjust_offsets_when_zeroing); i = j - 1; } @@ -419,7 +431,8 @@ position_cluster (const hb_ot_shape_plan_t *plan, void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, hb_font_t *font, - hb_buffer_t *buffer) + hb_buffer_t *buffer, + bool adjust_offsets_when_zeroing) { _hb_buffer_assert_gsubgpos_vars (buffer); @@ -428,10 +441,10 @@ _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, hb_glyph_info_t *info = buffer->info; for (unsigned int i = 1; i < count; i++) if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))) { - position_cluster (plan, font, buffer, start, i); + position_cluster (plan, font, buffer, start, i, adjust_offsets_when_zeroing); start = i; } - position_cluster (plan, font, buffer, start, count); + position_cluster (plan, font, buffer, start, count, adjust_offsets_when_zeroing); } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.hh index 12f18ed12f2..5faf5f2dfb1 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.hh @@ -34,7 +34,8 @@ HB_INTERNAL void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, hb_font_t *font, - hb_buffer_t *buffer); + hb_buffer_t *buffer, + bool adjust_offsets_when_zeroing); HB_INTERNAL void _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t *plan, hb_font_t *font, 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 6e5ce1523a3..e9d97c9b062 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 @@ -428,6 +428,20 @@ hb_set_unicode_props (hb_buffer_t *buffer) _hb_glyph_info_set_continuation (&info[i]); } } + /* Or part of the Other_Grapheme_Extend that is not marks. + * As of Unicode 11 that is just: + * + * 200C ; Other_Grapheme_Extend # Cf ZERO WIDTH NON-JOINER + * FF9E..FF9F ; Other_Grapheme_Extend # Lm [2] HALFWIDTH KATAKANA VOICED SOUND MARK..HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK + * E0020..E007F ; Other_Grapheme_Extend # Cf [96] TAG SPACE..CANCEL TAG + * + * ZWNJ is special, we don't want to merge it as there's no need, and keeping + * it separate results in more granular clusters. Ignore Katakana for now. + * Tags are used for Emoji sub-region flag sequences: + * https://github.com/harfbuzz/harfbuzz/issues/1556 + */ + else if (unlikely (hb_in_range (info[i].codepoint, 0xE0020u, 0xE007Fu))) + _hb_glyph_info_set_continuation (&info[i]); } } @@ -891,7 +905,8 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c) &pos[i].y_offset); if (c->plan->fallback_mark_positioning) - _hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer); + _hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer, + adjust_offsets_when_zeroing); } static inline void 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 ffab28c8b10..04a2ee99e8c 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 @@ -225,7 +225,7 @@ struct StatAxisRecord struct STAT { - enum { tableTag = HB_OT_TAG_STAT }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_STAT; bool sanitize (hb_sanitize_context_t *c) const { @@ -249,7 +249,7 @@ struct STAT * in the 'fvar' table. In all fonts, must * be greater than zero if axisValueCount * is greater than zero. */ - LOffsetTo, false> + LNNOffsetTo > designAxesOffset; /* Offset in bytes from the beginning of * the STAT table to the start of the design @@ -257,7 +257,7 @@ struct STAT * set to zero; if designAxisCount is greater * than zero, must be greater than zero. */ HBUINT16 axisValueCount; /* The number of axis value tables. */ - LOffsetTo >, false> + LNNOffsetTo > > offsetToAxisValueOffsets; /* Offset in bytes from the beginning of * the STAT table to the start of the design 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 67a60f5e0c5..c4a192dc918 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 @@ -99,7 +99,7 @@ struct SegmentMaps : ArrayOf struct avar { - enum { tableTag = HB_OT_TAG_avar }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_avar; bool sanitize (hb_sanitize_context_t *c) const { 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 76c9eb2cc44..78cb3c867fa 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 @@ -96,7 +96,7 @@ struct AxisRecord struct fvar { - enum { tableTag = HB_OT_TAG_fvar }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_fvar; bool has_data () const { return version.to_int (); } @@ -268,7 +268,7 @@ struct fvar { hb_array_t instanceCoords = instance->get_coordinates (axisCount) .sub_array (0, *coords_length); - for (unsigned int i = 0; i < instanceCoords.len; i++) + for (unsigned int i = 0; i < instanceCoords.length; i++) coords[i] = instanceCoords.arrayZ[i].to_float (); } return axisCount; 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 2640f07ee19..a8d9fe3c875 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 @@ -100,8 +100,8 @@ struct DeltaSetIndexMap struct HVARVVAR { - enum { HVARTag = HB_OT_TAG_HVAR }; - enum { VVARTag = HB_OT_TAG_VVAR }; + static constexpr hb_tag_t HVARTag = HB_OT_TAG_HVAR; + static constexpr hb_tag_t VVARTag = HB_OT_TAG_VVAR; bool sanitize (hb_sanitize_context_t *c) const { @@ -140,10 +140,10 @@ struct HVARVVAR }; struct HVAR : HVARVVAR { - enum { tableTag = HB_OT_TAG_HVAR }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_HVAR; }; struct VVAR : HVARVVAR { - enum { tableTag = HB_OT_TAG_VVAR }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_VVAR; bool sanitize (hb_sanitize_context_t *c) const { 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 a5eeddc5427..0dd63e510b4 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 @@ -58,7 +58,7 @@ struct VariationValueRecord struct MVAR { - enum { tableTag = HB_OT_TAG_MVAR }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_MVAR; bool sanitize (hb_sanitize_context_t *c) const { 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 884d04312ff..0202fcc5658 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 @@ -57,7 +57,7 @@ struct VertOriginMetric struct VORG { - enum { tableTag = HB_OT_TAG_VORG }; + static constexpr hb_tag_t tableTag = HB_OT_TAG_VORG; bool has_data () const { return version.to_int (); } @@ -85,12 +85,12 @@ struct VORG subset_table->version.minor.set (0); subset_table->defaultVertOriginY.set (vorg_table->defaultVertOriginY); - subset_table->vertYOrigins.len.set (subset_metrics.len); + subset_table->vertYOrigins.len.set (subset_metrics.length); bool success = true; - if (subset_metrics.len > 0) + if (subset_metrics.length > 0) { - unsigned int size = VertOriginMetric::static_size * subset_metrics.len; + unsigned int size = VertOriginMetric::static_size * subset_metrics.length; VertOriginMetric *metrics = c.allocate_size (size); if (likely (metrics != nullptr)) memcpy (metrics, &subset_metrics[0], size); @@ -112,7 +112,7 @@ struct VORG subset_metrics.init (); unsigned int glyph = 0; unsigned int i = 0; - while ((glyph < plan->glyphs.len) && (i < vertYOrigins.len)) + while ((glyph < plan->glyphs.length) && (i < vertYOrigins.len)) { if (plan->glyphs[glyph] > vertYOrigins[i].glyph) i++; @@ -129,7 +129,7 @@ struct VORG } /* alloc the new table */ - unsigned int dest_sz = VORG::min_size + VertOriginMetric::static_size * subset_metrics.len; + unsigned int dest_sz = VORG::min_size + VertOriginMetric::static_size * subset_metrics.length; void *dest = (void *) malloc (dest_sz); if (unlikely (!dest)) { 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 9f49af17810..b97526f7750 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 @@ -48,15 +48,15 @@ template struct hb_set_digest_lowest_bits_t { - enum { mask_bytes = sizeof (mask_t) }; - enum { mask_bits = sizeof (mask_t) * 8 }; - 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 constexpr unsigned mask_bytes = sizeof (mask_t); + static constexpr unsigned mask_bits = sizeof (mask_t) * 8; + static constexpr unsigned 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), ""); 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 19596880e61..64a136385ff 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set.hh @@ -161,7 +161,7 @@ struct hb_set_t } typedef unsigned long long elt_t; - enum { PAGE_BITS = 512 }; + static constexpr unsigned PAGE_BITS = 512; static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); static unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } @@ -169,10 +169,10 @@ struct hb_set_t typedef hb_vector_size_t vector_t; - enum { ELT_BITS = sizeof (elt_t) * 8 }; - enum { ELT_MASK = ELT_BITS - 1 }; - enum { BITS = sizeof (vector_t) * 8 }; - enum { MASK = BITS - 1 }; + static constexpr unsigned ELT_BITS = sizeof (elt_t) * 8; + static constexpr unsigned ELT_MASK = ELT_BITS - 1; + static constexpr unsigned BITS = sizeof (vector_t) * 8; + static constexpr unsigned MASK = BITS - 1; static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, ""); elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; } @@ -186,8 +186,8 @@ struct hb_set_t hb_object_header_t header; bool successful; /* Allocations successful */ mutable unsigned int population; - hb_vector_t page_map; - hb_vector_t pages; + hb_vector_t page_map; + hb_vector_t pages; void init_shallow () { @@ -220,7 +220,7 @@ struct hb_set_t if (unlikely (!successful)) return false; if (!pages.resize (count) || !page_map.resize (count)) { - pages.resize (page_map.len); + pages.resize (page_map.length); successful = false; return false; } @@ -238,7 +238,7 @@ struct hb_set_t } bool is_empty () const { - unsigned int count = pages.len; + unsigned int count = pages.length; for (unsigned int i = 0; i < count; i++) if (!pages[i].is_empty ()) return false; @@ -373,7 +373,7 @@ struct hb_set_t void set (const hb_set_t *other) { if (unlikely (!successful)) return; - unsigned int count = other->pages.len; + unsigned int count = other->pages.length; if (!resize (count)) return; population = other->population; @@ -386,8 +386,8 @@ struct hb_set_t if (get_population () != other->get_population ()) return false; - unsigned int na = pages.len; - unsigned int nb = other->pages.len; + unsigned int na = pages.length; + unsigned int nb = other->pages.length; unsigned int a = 0, b = 0; for (; a < na && b < nb; ) @@ -429,8 +429,8 @@ struct hb_set_t dirty (); - unsigned int na = pages.len; - unsigned int nb = other->pages.len; + unsigned int na = pages.length; + unsigned int nb = other->pages.length; unsigned int next_page = na; unsigned int count = 0, newCount = 0; @@ -461,7 +461,7 @@ struct hb_set_t if (Op::passthru_right) count += nb - b; - if (count > pages.len) + if (count > pages.length) if (!resize (count)) return; newCount = count; @@ -517,7 +517,7 @@ struct hb_set_t page_at (count).v = other->page_at (b).v; } assert (!count); - if (pages.len > newCount) + if (pages.length > newCount) resize (newCount); } @@ -547,7 +547,7 @@ struct hb_set_t page_map_t map = {get_major (*codepoint), 0}; unsigned int i; page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST); - if (i < page_map.len && page_map[i].major == map.major) + if (i < page_map.length && page_map[i].major == map.major) { if (pages[page_map[i].index].next (codepoint)) { @@ -556,7 +556,7 @@ struct hb_set_t } i++; } - for (; i < page_map.len; i++) + for (; i < page_map.length; i++) { hb_codepoint_t m = pages[page_map[i].index].get_min (); if (m != INVALID) @@ -578,7 +578,7 @@ struct hb_set_t page_map_t map = {get_major (*codepoint), 0}; unsigned int i; page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST); - if (i < page_map.len && page_map[i].major == map.major) + if (i < page_map.length && page_map[i].major == map.major) { if (pages[page_map[i].index].previous (codepoint)) { @@ -642,7 +642,7 @@ struct hb_set_t return population; unsigned int pop = 0; - unsigned int count = pages.len; + unsigned int count = pages.length; for (unsigned int i = 0; i < count; i++) pop += pages[i].get_population (); @@ -651,7 +651,7 @@ struct hb_set_t } hb_codepoint_t get_min () const { - unsigned int count = pages.len; + unsigned int count = pages.length; for (unsigned int i = 0; i < count; i++) if (!page_at (i).is_empty ()) return page_map[i].major * page_t::PAGE_BITS + page_at (i).get_min (); @@ -659,28 +659,55 @@ struct hb_set_t } hb_codepoint_t get_max () const { - unsigned int count = pages.len; + unsigned int count = pages.length; for (int i = count - 1; i >= 0; i++) if (!page_at (i).is_empty ()) 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; + static constexpr hb_codepoint_t INVALID = HB_SET_VALUE_INVALID; + + /* + * Iterator implementation. + */ + struct const_iter_t : hb_sorted_iter_t + { + const_iter_t (const hb_set_t &s_) : + s (s_), v (INVALID), l (s.get_population () + 1) { __next__ (); } + + typedef hb_codepoint_t __item_type__; + hb_codepoint_t __item__ () const { return v; } + bool __more__ () const { return v != INVALID; } + void __next__ () { s.next (&v); if (l) l--; } + void __prev__ () { s.previous (&v); } + unsigned __len__ () { return l; } + + protected: + const hb_set_t &s; + hb_codepoint_t v; + unsigned l; + }; + const_iter_t const_iter () const { return const_iter_t (*this); } + operator const_iter_t () const { return const_iter (); } + typedef const_iter_t iter_t; + iter_t iter () const { return const_iter (); } + + protected: page_t *page_for_insert (hb_codepoint_t g) { - page_map_t map = {get_major (g), pages.len}; + page_map_t map = {get_major (g), pages.length}; unsigned int i; if (!page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST)) { - if (!resize (pages.len + 1)) + if (!resize (pages.length + 1)) return nullptr; pages[map.index].init0 (); memmove (page_map + i + 1, page_map + i, - (page_map.len - 1 - i) * page_map.item_size); + (page_map.length - 1 - i) * page_map.item_size); page_map[i] = map; } return &pages[page_map[i].index]; 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 index b6127a9aba1..3e617d58bca 100644 --- 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 @@ -49,15 +49,15 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, unsigned int &subset_fd_count /* OUT */, unsigned int &subset_fdselect_size /* OUT */, unsigned int &subset_fdselect_format /* OUT */, - hb_vector_t &fdselect_ranges /* OUT */, - Remap &fdmap /* OUT */) + hb_vector_t &fdselect_ranges /* OUT */, + remap_t &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; + unsigned int subset_num_glyphs = glyphs.length; if (subset_num_glyphs == 0) return true; @@ -76,7 +76,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, { num_ranges++; prev_fd = fd; - code_pair pair = { fd, i }; + code_pair_t pair = { fd, i }; fdselect_ranges.push (pair); } } @@ -106,7 +106,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, } /* update each font dict index stored as "code" in fdselect_ranges */ - for (unsigned int i = 0; i < fdselect_ranges.len; i++) + for (unsigned int i = 0; i < fdselect_ranges.length; i++) fdselect_ranges[i].code = fdmap[fdselect_ranges[i].code]; } @@ -148,13 +148,13 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c, const unsigned int num_glyphs, const FDSelect &src, unsigned int size, - const hb_vector_t &fdselect_ranges) + const hb_vector_t &fdselect_ranges) { TRACE_SERIALIZE (this); FDSELECT3_4 *p = c->allocate_size (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->nRanges ().set (fdselect_ranges.length); + for (unsigned int i = 0; i < fdselect_ranges.length; i++) { p->ranges[i].first.set (fdselect_ranges[i].glyph); p->ranges[i].fd.set (fdselect_ranges[i].code); @@ -174,7 +174,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, unsigned int fd_count, unsigned int fdselect_format, unsigned int size, - const hb_vector_t &fdselect_ranges) + const hb_vector_t &fdselect_ranges) { TRACE_SERIALIZE (this); FDSelect *p = c->allocate_min (); 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 index 820a0908509..915b4c45287 100644 --- 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 @@ -35,16 +35,16 @@ namespace CFF { /* Used for writing a temporary charstring */ -struct StrEncoder +struct str_encoder_t { - StrEncoder (StrBuff &buff_) + str_encoder_t (str_buff_t &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))) + if (unlikely (buff.push (b) == &Crap(unsigned char))) set_error (); } @@ -79,7 +79,7 @@ struct StrEncoder } } - void encode_num (const Number& n) + void encode_num (const number_t& n) { if (n.in_int_range ()) { @@ -96,7 +96,7 @@ struct StrEncoder } } - void encode_op (OpCode op) + void encode_op (op_code_t op) { if (Is_OpCode_ESC (op)) { @@ -107,16 +107,16 @@ struct StrEncoder encode_byte (op); } - void copy_str (const ByteStr &str) + void copy_str (const byte_str_t &str) { - unsigned int offset = buff.len; - buff.resize (offset + str.len); - if (unlikely (buff.len < offset + str.len)) + unsigned int offset = buff.length; + buff.resize (offset + str.length); + if (unlikely (buff.length < offset + str.length)) { set_error (); return; } - memcpy (&buff[offset], &str.str[0], str.len); + memcpy (&buff[offset], &str[0], str.length); } bool is_error () const { return error; } @@ -124,12 +124,12 @@ struct StrEncoder protected: void set_error () { error = true; } - StrBuff &buff; + str_buff_t &buff; bool error; }; -struct CFFSubTableOffsets { - CFFSubTableOffsets () : privateDictsOffset (0) +struct cff_sub_table_offsets_t { + cff_sub_table_offsets_t () : privateDictsOffset (0) { topDictInfo.init (); FDSelectInfo.init (); @@ -139,23 +139,23 @@ struct CFFSubTableOffsets { localSubrsInfos.init (); } - ~CFFSubTableOffsets () { localSubrsInfos.fini (); } + ~cff_sub_table_offsets_t () { localSubrsInfos.fini (); } - TableInfo topDictInfo; - TableInfo FDSelectInfo; - TableInfo FDArrayInfo; - TableInfo charStringsInfo; + table_info_t topDictInfo; + table_info_t FDSelectInfo; + table_info_t FDArrayInfo; + table_info_t charStringsInfo; unsigned int privateDictsOffset; - TableInfo globalSubrsInfo; - hb_vector_t localSubrsInfos; + table_info_t globalSubrsInfo; + hb_vector_t localSubrsInfos; }; -template -struct CFFTopDict_OpSerializer : OpSerializer +template +struct cff_top_dict_op_serializer_t : op_serializer_t { bool serialize (hb_serialize_context_t *c, const OPSTR &opstr, - const CFFSubTableOffsets &offsets) const + const cff_sub_table_offsets_t &offsets) const { TRACE_SERIALIZE (this); @@ -186,16 +186,16 @@ struct CFFTopDict_OpSerializer : OpSerializer return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return opstr.str.len; + return opstr.str.length; } } }; -struct CFFFontDict_OpSerializer : OpSerializer +struct cff_font_dict_op_serializer_t : op_serializer_t { bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const TableInfo &privateDictInfo) const + const op_str_t &opstr, + const table_info_t &privateDictInfo) const { TRACE_SERIALIZE (this); @@ -215,34 +215,34 @@ struct CFFFontDict_OpSerializer : OpSerializer } else { - HBUINT8 *d = c->allocate_size (opstr.str.len); + HBUINT8 *d = c->allocate_size (opstr.str.length); if (unlikely (d == nullptr)) return_trace (false); - memcpy (d, &opstr.str.str[0], opstr.str.len); + memcpy (d, &opstr.str[0], opstr.str.length); } return_trace (true); } - unsigned int calculate_serialized_size (const OpStr &opstr) const + unsigned int calculate_serialized_size (const op_str_t &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; + return opstr.str.length; } }; -struct CFFPrivateDict_OpSerializer : OpSerializer +struct cff_private_dict_op_serializer_t : op_serializer_t { - CFFPrivateDict_OpSerializer (bool desubroutinize_, bool drop_hints_) + cff_private_dict_op_serializer_t (bool desubroutinize_, bool drop_hints_) : desubroutinize (desubroutinize_), drop_hints (drop_hints_) {} bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, + const op_str_t &opstr, const unsigned int subrsOffset) const { TRACE_SERIALIZE (this); - if (drop_hints && DictOpSet::is_hint_op (opstr.op)) + if (drop_hints && dict_opset_t::is_hint_op (opstr.op)) return true; if (opstr.op == OpCode_Subrs) { @@ -255,10 +255,10 @@ struct CFFPrivateDict_OpSerializer : OpSerializer return_trace (copy_opstr (c, opstr)); } - unsigned int calculate_serialized_size (const OpStr &opstr, + unsigned int calculate_serialized_size (const op_str_t &opstr, bool has_localsubr=true) const { - if (drop_hints && DictOpSet::is_hint_op (opstr.op)) + if (drop_hints && dict_opset_t::is_hint_op (opstr.op)) return 0; if (opstr.op == OpCode_Subrs) { @@ -268,7 +268,7 @@ struct CFFPrivateDict_OpSerializer : OpSerializer return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op); } else - return opstr.str.len; + return opstr.str.length; } protected: @@ -276,39 +276,36 @@ struct CFFPrivateDict_OpSerializer : OpSerializer const bool drop_hints; }; -struct FlattenParam +struct flatten_param_t { - StrBuff &flatStr; + str_buff_t &flatStr; bool drop_hints; }; template -struct SubrFlattener +struct subr_flattener_t { - SubrFlattener (const ACC &acc_, - const hb_vector_t &glyphs_, - bool drop_hints_) - : acc (acc_), - glyphs (glyphs_), - drop_hints (drop_hints_) - {} + subr_flattener_t (const ACC &acc_, + const hb_vector_t &glyphs_, + bool drop_hints_) : acc (acc_), glyphs (glyphs_), + drop_hints (drop_hints_) {} - bool flatten (StrBuffArray &flat_charstrings) + bool flatten (str_buff_vec_t &flat_charstrings) { - if (!flat_charstrings.resize (glyphs.len)) + if (!flat_charstrings.resize (glyphs.length)) return false; - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) flat_charstrings[i].init (); - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) { hb_codepoint_t glyph = glyphs[i]; - const ByteStr str = (*acc.charStrings)[glyph]; + const byte_str_t str = (*acc.charStrings)[glyph]; unsigned int fd = acc.fdSelect->get_fd (glyph); if (unlikely (fd >= acc.fdCount)) return false; - CSInterpreter interp; + cs_interpreter_t interp; interp.env.init (str, acc, fd); - FlattenParam param = { flat_charstrings[i], drop_hints }; + flatten_param_t param = { flat_charstrings[i], drop_hints }; if (unlikely (!interp.interpret (param))) return false; } @@ -320,9 +317,9 @@ struct SubrFlattener bool drop_hints; }; -struct SubrClosures +struct subr_closures_t { - SubrClosures () : valid (false), global_closure (nullptr) + subr_closures_t () : valid (false), global_closure (nullptr) { local_closures.init (); } void init (unsigned int fd_count) @@ -334,7 +331,7 @@ struct SubrClosures if (!local_closures.resize (fd_count)) valid = false; - for (unsigned int i = 0; i < local_closures.len; i++) + for (unsigned int i = 0; i < local_closures.length; i++) { local_closures[i] = hb_set_create (); if (local_closures[i] == hb_set_get_empty ()) @@ -345,7 +342,7 @@ struct SubrClosures void fini () { hb_set_destroy (global_closure); - for (unsigned int i = 0; i < local_closures.len; i++) + for (unsigned int i = 0; i < local_closures.length; i++) hb_set_destroy (local_closures[i]); local_closures.fini (); } @@ -353,7 +350,7 @@ struct SubrClosures void reset () { hb_set_clear (global_closure); - for (unsigned int i = 0; i < local_closures.len; i++) + for (unsigned int i = 0; i < local_closures.length; i++) hb_set_clear (local_closures[i]); } @@ -363,18 +360,18 @@ struct SubrClosures hb_vector_t local_closures; }; -struct ParsedCSOp : OpStr +struct parsed_cs_op_t : op_str_t { void init (unsigned int subr_num_ = 0) { - OpStr::init (); + op_str_t::init (); subr_num = subr_num_; drop_flag = false; keep_flag = false; skip_flag = false; } - void fini () { OpStr::fini (); } + void fini () { op_str_t::fini (); } bool for_drop () const { return drop_flag; } void set_drop () { if (!for_keep ()) drop_flag = true; } @@ -393,7 +390,7 @@ struct ParsedCSOp : OpStr bool skip_flag : 1; }; -struct ParsedCStr : ParsedValues +struct parsed_cs_str_t : parsed_values_t { void init () { @@ -403,13 +400,13 @@ struct ParsedCStr : ParsedValues has_prefix_ = false; } - void add_op (OpCode op, const SubByteStr& substr) + void add_op (op_code_t op, const byte_str_ref_t& str_ref) { if (!is_parsed ()) - SUPER::add_op (op, substr); + SUPER::add_op (op, str_ref); } - void add_call_op (OpCode op, const SubByteStr& substr, unsigned int subr_num) + void add_call_op (op_code_t op, const byte_str_ref_t& str_ref, unsigned int subr_num) { if (!is_parsed ()) { @@ -417,13 +414,13 @@ struct ParsedCStr : ParsedValues if (likely (parsed_len > 0)) values[parsed_len-1].set_skip (); - ParsedCSOp val; + parsed_cs_op_t val; val.init (subr_num); - SUPER::add_op (op, substr, val); + SUPER::add_op (op, str_ref, val); } } - void set_prefix (const Number &num, OpCode op = OpCode_Invalid) + void set_prefix (const number_t &num, op_code_t op = OpCode_Invalid) { has_prefix_ = true; prefix_op_ = op; @@ -432,7 +429,7 @@ struct ParsedCStr : ParsedValues bool at_end (unsigned int pos) const { - return ((pos + 1 >= values.len) /* CFF2 */ + return ((pos + 1 >= values.length) /* CFF2 */ || (values[pos + 1].op == OpCode_return)); } @@ -446,42 +443,42 @@ struct ParsedCStr : ParsedValues 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_; } + op_code_t prefix_op () const { return prefix_op_; } + const number_t &prefix_num () const { return prefix_num_; } protected: bool parsed; bool hint_dropped; bool vsindex_dropped; bool has_prefix_; - OpCode prefix_op_; - Number prefix_num_; + op_code_t prefix_op_; + number_t prefix_num_; private: - typedef ParsedValues SUPER; + typedef parsed_values_t SUPER; }; -struct ParsedCStrs : hb_vector_t +struct parsed_cs_str_vec_t : hb_vector_t { void init (unsigned int len_ = 0) { SUPER::init (); resize (len_); - for (unsigned int i = 0; i < len; i++) + for (unsigned int i = 0; i < length; i++) (*this)[i].init (); } void fini () { SUPER::fini_deep (); } private: - typedef hb_vector_t SUPER; + typedef hb_vector_t SUPER; }; -struct SubrSubsetParam +struct subr_subset_param_t { - 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_) + void init (parsed_cs_str_t *parsed_charstring_, + parsed_cs_str_vec_t *parsed_global_subrs_, parsed_cs_str_vec_t *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; @@ -492,7 +489,7 @@ struct SubrSubsetParam drop_hints = drop_hints_; } - ParsedCStr *get_parsed_str_for_context (CallContext &context) + parsed_cs_str_t *get_parsed_str_for_context (call_context_t &context) { switch (context.type) { @@ -500,12 +497,12 @@ struct SubrSubsetParam return parsed_charstring; case CSType_LocalSubr: - if (likely (context.subr_num < parsed_local_subrs->len)) + if (likely (context.subr_num < parsed_local_subrs->length)) return &(*parsed_local_subrs)[context.subr_num]; break; case CSType_GlobalSubr: - if (likely (context.subr_num < parsed_global_subrs->len)) + if (likely (context.subr_num < parsed_global_subrs->length)) return &(*parsed_global_subrs)[context.subr_num]; break; } @@ -515,13 +512,13 @@ struct SubrSubsetParam template void set_current_str (ENV &env, bool calling) { - ParsedCStr *parsed_str = get_parsed_str_for_context (env.context); + parsed_cs_str_t *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))) + if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0))) env.set_error (); else current_parsed_str = parsed_str; @@ -530,17 +527,17 @@ struct SubrSubsetParam env.set_error (); } - ParsedCStr *current_parsed_str; + parsed_cs_str_t *current_parsed_str; - ParsedCStr *parsed_charstring; - ParsedCStrs *parsed_global_subrs; - ParsedCStrs *parsed_local_subrs; + parsed_cs_str_t *parsed_charstring; + parsed_cs_str_vec_t *parsed_global_subrs; + parsed_cs_str_vec_t *parsed_local_subrs; hb_set_t *global_closure; hb_set_t *local_closure; bool drop_hints; }; -struct SubrRemap : Remap +struct subr_remap_t : remap_t { void create (hb_set_t *closure) { @@ -548,7 +545,7 @@ struct SubrRemap : Remap * 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++) + for (hb_codepoint_t old_num = 0; old_num < length; old_num++) { if (hb_set_has (closure, old_num)) add (old_num); @@ -564,10 +561,10 @@ struct SubrRemap : Remap hb_codepoint_t operator[] (unsigned int old_num) const { - if (old_num >= len) + if (old_num >= length) return CFF_UNDEF_CODE; else - return Remap::operator[] (old_num); + return remap_t::operator[] (old_num); } int biased_num (unsigned int old_num) const @@ -580,15 +577,15 @@ struct SubrRemap : Remap int bias; }; -struct SubrRemaps +struct subr_remap_ts { - SubrRemaps () + subr_remap_ts () { global_remap.init (); local_remaps.init (); } - ~SubrRemaps () { fini (); } + ~subr_remap_ts () { fini (); } void init (unsigned int fdCount) { @@ -597,10 +594,10 @@ struct SubrRemaps local_remaps[i].init (); } - void create (SubrClosures& closures) + void create (subr_closures_t& closures) { global_remap.create (closures.global_closure); - for (unsigned int i = 0; i < local_remaps.len; i++) + for (unsigned int i = 0; i < local_remaps.length; i++) local_remaps[i].create (closures.local_closures[i]); } @@ -610,21 +607,21 @@ struct SubrRemaps local_remaps.fini_deep (); } - SubrRemap global_remap; - hb_vector_t local_remaps; + subr_remap_t global_remap; + hb_vector_t local_remaps; }; template -struct SubrSubsetter +struct subr_subsetter_t { - SubrSubsetter () + subr_subsetter_t () { parsed_charstrings.init (); parsed_global_subrs.init (); parsed_local_subrs.init (); } - ~SubrSubsetter () + ~subr_subsetter_t () { closures.fini (); remaps.fini (); @@ -652,7 +649,7 @@ struct SubrSubsetter closures.init (acc.fdCount); remaps.init (acc.fdCount); - parsed_charstrings.init (glyphs.len); + parsed_charstrings.init (glyphs.length); parsed_global_subrs.init (acc.globalSubrs->count); parsed_local_subrs.resize (acc.fdCount); for (unsigned int i = 0; i < acc.fdCount; i++) @@ -663,18 +660,18 @@ struct SubrSubsetter return false; /* phase 1 & 2 */ - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) { hb_codepoint_t glyph = glyphs[i]; - const ByteStr str = (*acc.charStrings)[glyph]; + const byte_str_t str = (*acc.charStrings)[glyph]; unsigned int fd = acc.fdSelect->get_fd (glyph); if (unlikely (fd >= acc.fdCount)) return false; - CSInterpreter interp; + cs_interpreter_t interp; interp.env.init (str, acc, fd); - SubrSubsetParam param; + subr_subset_param_t param; param.init (&parsed_charstrings[i], &parsed_global_subrs, &parsed_local_subrs[fd], closures.global_closure, closures.local_closures[fd], @@ -690,18 +687,18 @@ struct SubrSubsetter if (drop_hints) { /* mark hint ops and arguments for drop */ - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) { unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); if (unlikely (fd >= acc.fdCount)) return false; - SubrSubsetParam param; + subr_subset_param_t param; param.init (&parsed_charstrings[i], &parsed_global_subrs, &parsed_local_subrs[fd], closures.global_closure, closures.local_closures[fd], drop_hints); - DropHintsParam drop; + drop_hints_param_t drop; if (drop_hints_in_str (parsed_charstrings[i], param, drop)) { parsed_charstrings[i].set_hint_dropped (); @@ -712,12 +709,12 @@ struct SubrSubsetter /* after dropping hints recreate closures of actually used subrs */ closures.reset (); - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) { unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); if (unlikely (fd >= acc.fdCount)) return false; - SubrSubsetParam param; + subr_subset_param_t param; param.init (&parsed_charstrings[i], &parsed_global_subrs, &parsed_local_subrs[fd], closures.global_closure, closures.local_closures[fd], @@ -731,11 +728,11 @@ struct SubrSubsetter return true; } - bool encode_charstrings (ACC &acc, const hb_vector_t &glyphs, StrBuffArray &buffArray) const + bool encode_charstrings (ACC &acc, const hb_vector_t &glyphs, str_buff_vec_t &buffArray) const { - if (unlikely (!buffArray.resize (glyphs.len))) + if (unlikely (!buffArray.resize (glyphs.length))) return false; - for (unsigned int i = 0; i < glyphs.len; i++) + for (unsigned int i = 0; i < glyphs.length; i++) { unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); if (unlikely (fd >= acc.fdCount)) @@ -746,13 +743,13 @@ struct SubrSubsetter return true; } - bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const + bool encode_subrs (const parsed_cs_str_vec_t &subrs, const subr_remap_t& remap, unsigned int fd, str_buff_vec_t &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++) + for (unsigned int old_num = 0; old_num < subrs.length; old_num++) { hb_codepoint_t new_num = remap[old_num]; if (new_num != CFF_UNDEF_CODE) @@ -764,20 +761,20 @@ struct SubrSubsetter return true; } - bool encode_globalsubrs (StrBuffArray &buffArray) + bool encode_globalsubrs (str_buff_vec_t &buffArray) { return encode_subrs (parsed_global_subrs, remaps.global_remap, 0, buffArray); } - bool encode_localsubrs (unsigned int fd, StrBuffArray &buffArray) const + bool encode_localsubrs (unsigned int fd, str_buff_vec_t &buffArray) const { return encode_subrs (parsed_local_subrs[fd], remaps.local_remaps[fd], fd, buffArray); } protected: - struct DropHintsParam + struct drop_hints_param_t { - DropHintsParam () + drop_hints_param_t () : seen_moveto (false), ends_in_hint (false), vsindex_dropped (false) {} @@ -787,9 +784,9 @@ struct SubrSubsetter bool vsindex_dropped; }; - bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos, - ParsedCStrs &subrs, unsigned int subr_num, - const SubrSubsetParam ¶m, DropHintsParam &drop) + bool drop_hints_in_subr (parsed_cs_str_t &str, unsigned int pos, + parsed_cs_str_vec_t &subrs, unsigned int subr_num, + const subr_subset_param_t ¶m, drop_hints_param_t &drop) { drop.ends_in_hint = false; bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop); @@ -809,11 +806,11 @@ struct SubrSubsetter } /* 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 drop_hints_in_str (parsed_cs_str_t &str, const subr_subset_param_t ¶m, drop_hints_param_t &drop) { bool seen_hint = false; - for (unsigned int pos = 0; pos < str.values.len; pos++) + for (unsigned int pos = 0; pos < str.values.length; pos++) { bool has_hint = false; switch (str.values[pos].op) @@ -868,7 +865,7 @@ struct SubrSubsetter { for (int i = pos - 1; i >= 0; i--) { - ParsedCSOp &csop = str.values[(unsigned)i]; + parsed_cs_op_t &csop = str.values[(unsigned)i]; if (csop.for_drop ()) break; csop.set_drop (); @@ -882,18 +879,18 @@ struct SubrSubsetter return seen_hint; } - void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos, - unsigned int subr_num, ParsedCStrs &subrs, + void collect_subr_refs_in_subr (parsed_cs_str_t &str, unsigned int pos, + unsigned int subr_num, parsed_cs_str_vec_t &subrs, hb_set_t *closure, - const SubrSubsetParam ¶m) + const subr_subset_param_t ¶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) + void collect_subr_refs_in_str (parsed_cs_str_t &str, const subr_subset_param_t ¶m) { - for (unsigned int pos = 0; pos < str.values.len; pos++) + for (unsigned int pos = 0; pos < str.values.length; pos++) { if (!str.values[pos].for_drop ()) { @@ -917,10 +914,10 @@ struct SubrSubsetter } } - bool encode_str (const ParsedCStr &str, const unsigned int fd, StrBuff &buff) const + bool encode_str (const parsed_cs_str_t &str, const unsigned int fd, str_buff_t &buff) const { buff.init (); - StrEncoder encoder (buff); + str_encoder_t 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 */ @@ -932,7 +929,7 @@ struct SubrSubsetter } for (unsigned int i = 0; i < str.get_count(); i++) { - const ParsedCSOp &opstr = str.values[i]; + const parsed_cs_op_t &opstr = str.values[i]; if (!opstr.for_drop () && !opstr.for_skip ()) { switch (opstr.op) @@ -957,18 +954,19 @@ struct SubrSubsetter } protected: - SubrClosures closures; + subr_closures_t closures; - ParsedCStrs parsed_charstrings; - ParsedCStrs parsed_global_subrs; - hb_vector_t parsed_local_subrs; + parsed_cs_str_vec_t parsed_charstrings; + parsed_cs_str_vec_t parsed_global_subrs; + hb_vector_t parsed_local_subrs; - SubrRemaps remaps; + subr_remap_ts remaps; private: typedef typename SUBRS::count_type subr_count_type; }; -}; /* namespace CFF */ + +} /* namespace CFF */ HB_INTERNAL bool hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, @@ -977,8 +975,8 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, unsigned int &subset_fd_count /* OUT */, unsigned int &subset_fdselect_size /* OUT */, unsigned int &subset_fdselect_format /* OUT */, - hb_vector_t &fdselect_ranges /* OUT */, - CFF::Remap &fdmap /* OUT */); + hb_vector_t &fdselect_ranges /* OUT */, + CFF::remap_t &fdmap /* OUT */); HB_INTERNAL bool hb_serialize_cff_fdselect (hb_serialize_context_t *c, @@ -987,6 +985,6 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, unsigned int fd_count, unsigned int fdselect_format, unsigned int size, - const hb_vector_t &fdselect_ranges); + const hb_vector_t &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 index 09364a22cea..5133a4de65c 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff1.cc @@ -34,12 +34,12 @@ using namespace CFF; -struct RemapSID : Remap +struct remap_sid_t : remap_t { unsigned int add (unsigned int sid) { if ((sid != CFF_UNDEF_SID) && !is_std_std (sid)) - return offset_sid (Remap::add (unoffset_sid (sid))); + return offset_sid (remap_t::add (unoffset_sid (sid))); else return sid; } @@ -49,7 +49,7 @@ struct RemapSID : Remap if (is_std_std (sid) || (sid == CFF_UNDEF_SID)) return sid; else - return offset_sid (Remap::operator [] (unoffset_sid (sid))); + return offset_sid (remap_t::operator [] (unoffset_sid (sid))); } static const unsigned int num_std_strings = 391; @@ -59,10 +59,10 @@ struct RemapSID : Remap static unsigned int unoffset_sid (unsigned int sid) { return sid - num_std_strings; } }; -struct CFF1SubTableOffsets : CFFSubTableOffsets +struct cff1_sub_table_offsets_t : cff_sub_table_offsets_t { - CFF1SubTableOffsets () - : CFFSubTableOffsets (), + cff1_sub_table_offsets_t () + : cff_sub_table_offsets_t (), nameIndexOffset (0), encodingOffset (0) { @@ -72,16 +72,16 @@ struct CFF1SubTableOffsets : CFFSubTableOffsets } unsigned int nameIndexOffset; - TableInfo stringIndexInfo; + table_info_t stringIndexInfo; unsigned int encodingOffset; - TableInfo charsetInfo; - TableInfo privateDictInfo; + table_info_t charsetInfo; + table_info_t privateDictInfo; }; -/* a copy of a parsed out CFF1TopDictValues augmented with additional operators */ -struct CFF1TopDictValuesMod : CFF1TopDictValues +/* a copy of a parsed out cff1_top_dict_values_t augmented with additional operators */ +struct cff1_top_dict_values_mod_t : cff1_top_dict_values_t { - void init (const CFF1TopDictValues *base_= &Null(CFF1TopDictValues)) + void init (const cff1_top_dict_values_t *base_= &Null(cff1_top_dict_values_t)) { SUPER::init (); base = base_; @@ -90,47 +90,47 @@ struct CFF1TopDictValuesMod : CFF1TopDictValues void fini () { SUPER::fini (); } unsigned get_count () const { return base->get_count () + SUPER::get_count (); } - const CFF1TopDictVal &get_value (unsigned int i) const + const cff1_top_dict_val_t &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); } + const cff1_top_dict_val_t &operator [] (unsigned int i) const { return get_value (i); } - void reassignSIDs (const RemapSID& sidmap) + void reassignSIDs (const remap_sid_t& sidmap) { - for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++) nameSIDs[i] = sidmap[base->nameSIDs[i]]; } protected: - typedef CFF1TopDictValues SUPER; - const CFF1TopDictValues *base; + typedef cff1_top_dict_values_t SUPER; + const cff1_top_dict_values_t *base; }; -struct TopDictModifiers +struct top_dict_modifiers_t { - TopDictModifiers (const CFF1SubTableOffsets &offsets_, - const unsigned int (&nameSIDs_)[NameDictValues::ValCount]) + top_dict_modifiers_t (const cff1_sub_table_offsets_t &offsets_, + const unsigned int (&nameSIDs_)[name_dict_values_t::ValCount]) : offsets (offsets_), nameSIDs (nameSIDs_) {} - const CFF1SubTableOffsets &offsets; - const unsigned int (&nameSIDs)[NameDictValues::ValCount]; + const cff1_sub_table_offsets_t &offsets; + const unsigned int (&nameSIDs)[name_dict_values_t::ValCount]; }; -struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer +struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t { bool serialize (hb_serialize_context_t *c, - const CFF1TopDictVal &opstr, - const TopDictModifiers &mod) const + const cff1_top_dict_val_t &opstr, + const top_dict_modifiers_t &mod) const { TRACE_SERIALIZE (this); - OpCode op = opstr.op; + op_code_t op = opstr.op; switch (op) { case OpCode_charset: @@ -160,31 +160,30 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer 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)])); + return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[name_dict_values_t::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; + op_str_t 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))) + if ( unlikely (!(opstr.str.length >= 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]) && + supp_op.str = byte_str_t (&opstr.str + opstr.last_arg_offset, opstr.str.length - opstr.last_arg_offset); + return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::registry]) && + UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::ordering]) && copy_opstr (c, supp_op)); } default: - return_trace (CFFTopDict_OpSerializer::serialize (c, opstr, mod.offsets)); + return_trace (cff_top_dict_op_serializer_t::serialize (c, opstr, mod.offsets)); } return_trace (true); } - unsigned int calculate_serialized_size (const CFF1TopDictVal &opstr) const + unsigned int calculate_serialized_size (const cff1_top_dict_val_t &opstr) const { - OpCode op = opstr.op; + op_code_t op = opstr.op; switch (op) { case OpCode_charset: @@ -206,19 +205,19 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer 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 */; + return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.length - opstr.last_arg_offset)/* supplement + op */; default: - return CFFTopDict_OpSerializer::calculate_serialized_size (opstr); + return cff_top_dict_op_serializer_t::calculate_serialized_size (opstr); } } }; -struct FontDictValuesMod +struct font_dict_values_mod_t { - void init (const CFF1FontDictValues *base_, + void init (const cff1_font_dict_values_t *base_, unsigned int fontName_, - const TableInfo &privateDictInfo_) + const table_info_t &privateDictInfo_) { base = base_; fontName = fontName_; @@ -227,18 +226,18 @@ struct FontDictValuesMod unsigned get_count () const { return base->get_count (); } - const OpStr &operator [] (unsigned int i) const { return (*base)[i]; } + const op_str_t &operator [] (unsigned int i) const { return (*base)[i]; } - const CFF1FontDictValues *base; - TableInfo privateDictInfo; + const cff1_font_dict_values_t *base; + table_info_t privateDictInfo; unsigned int fontName; }; -struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer +struct cff1_font_dict_op_serializer_t : cff_font_dict_op_serializer_t { bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const FontDictValuesMod &mod) const + const op_str_t &opstr, + const font_dict_values_mod_t &mod) const { TRACE_SERIALIZE (this); @@ -248,7 +247,7 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo)); } - unsigned int calculate_serialized_size (const OpStr &opstr) const + unsigned int calculate_serialized_size (const op_str_t &opstr) const { if (opstr.op == OpCode_FontName) return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName); @@ -257,12 +256,12 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer } private: - typedef CFFFontDict_OpSerializer SUPER; + typedef cff_font_dict_op_serializer_t SUPER; }; -struct CFF1CSOpSet_Flatten : CFF1CSOpSet +struct cff1_cs_opset_flatten_t : cff1_cs_opset_t { - static void flush_args_and_op (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param) + static void flush_args_and_op (op_code_t op, cff1_cs_interp_env_t &env, flatten_param_t& param) { if (env.arg_start > 0) flush_width (env, param); @@ -288,51 +287,51 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet break; } } - static void flush_args (CFF1CSInterpEnv &env, FlattenParam& param) + static void flush_args (cff1_cs_interp_env_t &env, flatten_param_t& param) { - StrEncoder encoder (param.flatStr); + str_encoder_t 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) + static void flush_op (op_code_t op, cff1_cs_interp_env_t &env, flatten_param_t& param) { - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); encoder.encode_op (op); } - static void flush_width (CFF1CSInterpEnv &env, FlattenParam& param) + static void flush_width (cff1_cs_interp_env_t &env, flatten_param_t& param) { assert (env.has_width); - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); encoder.encode_num (env.width); } - static void flush_hintmask (OpCode op, CFF1CSInterpEnv &env, FlattenParam& param) + static void flush_hintmask (op_code_t op, cff1_cs_interp_env_t &env, flatten_param_t& param) { SUPER::flush_hintmask (op, env, param); if (!param.drop_hints) { - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); for (unsigned int i = 0; i < env.hintmask_size; i++) - encoder.encode_byte (env.substr[i]); + encoder.encode_byte (env.str_ref[i]); } } private: - typedef CFF1CSOpSet SUPER; + typedef cff1_cs_opset_t SUPER; }; -struct RangeList : hb_vector_t +struct range_list_t : hb_vector_t { /* 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--) + for (unsigned int i = (*this).length; i > 0; i--) { - code_pair &pair = (*this)[i - 1]; + code_pair_t &pair = (*this)[i - 1]; unsigned int nLeft = last_glyph - pair.glyph - 1; if (nLeft >= 0x100) two_byte = true; @@ -343,21 +342,21 @@ struct RangeList : hb_vector_t } }; -struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet +struct cff1_cs_opset_subr_subset_t : cff1_cs_opset_t { - static void process_op (OpCode op, CFF1CSInterpEnv &env, SubrSubsetParam& param) + static void process_op (op_code_t op, cff1_cs_interp_env_t &env, subr_subset_param_t& param) { switch (op) { case OpCode_return: - param.current_parsed_str->add_op (op, env.substr); + param.current_parsed_str->add_op (op, env.str_ref); 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->add_op (op, env.str_ref); param.current_parsed_str->set_parsed (); SUPER::process_op (op, env, param); break; @@ -372,30 +371,30 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSetadd_op (op, env.substr); + param.current_parsed_str->add_op (op, env.str_ref); break; } } protected: - static void process_call_subr (OpCode op, CSType type, - CFF1CSInterpEnv &env, SubrSubsetParam& param, - CFF1BiasedSubrs& subrs, hb_set_t *closure) + static void process_call_subr (op_code_t op, cs_type_t type, + cff1_cs_interp_env_t &env, subr_subset_param_t& param, + cff1_biased_subrs_t& subrs, hb_set_t *closure) { - SubByteStr substr = env.substr; + byte_str_ref_t str_ref = env.str_ref; env.callSubr (subrs, type); - param.current_parsed_str->add_call_op (op, substr, env.context.subr_num); + param.current_parsed_str->add_call_op (op, str_ref, env.context.subr_num); hb_set_add (closure, env.context.subr_num); param.set_current_str (env, true); } private: - typedef CFF1CSOpSet SUPER; + typedef cff1_cs_opset_t SUPER; }; -struct CFF1SubrSubsetter : SubrSubsetter +struct cff1_subr_subsetter_t : subr_subsetter_t { - static void finalize_parsed_str (CFF1CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring) + static void finalize_parsed_str (cff1_cs_interp_env_t &env, subr_subset_param_t& param, parsed_cs_str_t &charstring) { /* insert width at the beginning of the charstring as necessary */ if (env.has_width) @@ -407,7 +406,7 @@ struct CFF1SubrSubsetter : SubrSubsetterset_parsed (); for (unsigned int i = 0; i < env.callStack.get_count (); i++) { - ParsedCStr *parsed_str = param.get_parsed_str_for_context (env.callStack[i]); + parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]); if (likely (parsed_str != nullptr)) parsed_str->set_parsed (); else @@ -439,7 +438,7 @@ struct cff_subset_plan { subset_enc_supp_codes.init (); subset_charset_ranges.init (); sidmap.init (); - for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++) topDictModSIDs[i] = CFF_UNDEF_SID; } @@ -454,10 +453,9 @@ struct cff_subset_plan { subset_localsubrs.fini_deep (); fontdicts_mod.fini (); subset_enc_code_ranges.fini (); - subset_enc_supp_codes.init (); + subset_enc_supp_codes.fini (); 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) @@ -471,9 +469,9 @@ struct cff_subset_plan { supp_size = 0; supp_codes.init (); - subset_enc_num_codes = plan->glyphs.len - 1; + subset_enc_num_codes = plan->glyphs.length - 1; unsigned int glyph; - for (glyph = 1; glyph < plan->glyphs.len; glyph++) + for (glyph = 1; glyph < plan->glyphs.length; glyph++) { hb_codepoint_t orig_glyph = plan->glyphs[glyph]; code = acc.glyph_to_code (orig_glyph); @@ -485,7 +483,7 @@ struct cff_subset_plan { if (code != last_code + 1) { - code_pair pair = { code, glyph }; + code_pair_t pair = { code, glyph }; subset_enc_code_ranges.push (pair); } last_code = code; @@ -494,12 +492,12 @@ struct cff_subset_plan { { 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++) + for (unsigned int i = 0; i < supp_codes.length; i++) { - code_pair pair = { supp_codes[i], sid }; + code_pair_t pair = { supp_codes[i], sid }; subset_enc_supp_codes.push (pair); } - supp_size += SuppEncoding::static_size * supp_codes.len; + supp_size += SuppEncoding::static_size * supp_codes.length; } } supp_codes.fini (); @@ -508,7 +506,7 @@ struct cff_subset_plan { 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; + size1 = Encoding1::min_size + Encoding1_Range::static_size * subset_enc_code_ranges.length; if (size0 < size1) subset_enc_format = 0; @@ -517,8 +515,8 @@ struct cff_subset_plan { 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); + subset_enc_format? subset_enc_code_ranges.length: subset_enc_num_codes, + subset_enc_supp_codes.length); } unsigned int plan_subset_charset (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) @@ -528,7 +526,7 @@ struct cff_subset_plan { subset_charset_ranges.resize (0); unsigned int glyph; - for (glyph = 1; glyph < plan->glyphs.len; glyph++) + for (glyph = 1; glyph < plan->glyphs.length; glyph++) { hb_codepoint_t orig_glyph = plan->glyphs[glyph]; sid = acc.glyph_to_sid (orig_glyph); @@ -538,7 +536,7 @@ struct cff_subset_plan { if (sid != last_sid + 1) { - code_pair pair = { sid, glyph }; + code_pair_t pair = { sid, glyph }; subset_charset_ranges.push (pair); } last_sid = sid; @@ -546,11 +544,11 @@ struct cff_subset_plan { bool two_byte = subset_charset_ranges.finalize (glyph); - size0 = Charset0::min_size + HBUINT16::static_size * (plan->glyphs.len - 1); + size0 = Charset0::min_size + HBUINT16::static_size * (plan->glyphs.length - 1); if (!two_byte) - size_ranges = Charset1::min_size + Charset1_Range::static_size * subset_charset_ranges.len; + size_ranges = Charset1::min_size + Charset1_Range::static_size * subset_charset_ranges.length; else - size_ranges = Charset2::min_size + Charset2_Range::static_size * subset_charset_ranges.len; + size_ranges = Charset2::min_size + Charset2_Range::static_size * subset_charset_ranges.length; if (size0 < size_ranges) subset_charset_format = 0; @@ -561,7 +559,7 @@ struct cff_subset_plan { return Charset::calculate_serialized_size ( subset_charset_format, - subset_charset_format? subset_charset_ranges.len: plan->glyphs.len); + subset_charset_format? subset_charset_ranges.length: plan->glyphs.length); } bool collect_sids_in_dicts (const OT::cff1::accelerator_subset_t &acc) @@ -569,7 +567,7 @@ struct cff_subset_plan { if (unlikely (!sidmap.reset (acc.stringIndex->count))) return false; - for (unsigned int i = 0; i < NameDictValues::ValCount; i++) + for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++) { unsigned int sid = acc.topDict.nameSIDs[i]; if (sid != CFF_UNDEF_SID) @@ -591,17 +589,17 @@ struct cff_subset_plan { hb_subset_plan_t *plan) { /* make sure notdef is first */ - if ((plan->glyphs.len == 0) || (plan->glyphs[0] != 0)) return false; + if ((plan->glyphs.length == 0) || (plan->glyphs[0] != 0)) return false; final_size = 0; - num_glyphs = plan->glyphs.len; + num_glyphs = plan->glyphs.length; 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++) + for (unsigned int glyph = 0; glyph < plan->glyphs.length; glyph++) { if (plan->glyphs[glyph] != glyph) { gid_renum = true; @@ -633,12 +631,12 @@ struct cff_subset_plan { topdict_mod.add_op (OpCode_charset); } offsets.topDictInfo.offset = final_size; - CFF1TopDict_OpSerializer topSzr; + cff1_top_dict_op_serializer_t 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::calculate_serialized_size + final_size += CFF1IndexOf::calculate_serialized_size (offsets.topDictInfo.offSize, &topdict_mod, 1, topdict_sizes, topSzr); } @@ -682,7 +680,7 @@ struct cff_subset_plan { if (desubroutinize) { /* Flatten global & local subrs */ - SubrFlattener + subr_flattener_t flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) return false; @@ -708,7 +706,7 @@ struct cff_subset_plan { 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); + offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (offsets.globalSubrsInfo.offSize, subset_globalsubrs.length, dataSize); /* local subrs */ if (!offsets.localSubrsInfos.resize (orig_fdcount)) @@ -731,7 +729,7 @@ struct cff_subset_plan { 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); + offsets.localSubrsInfos[fd].size = CFF1Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].length, dataSize); } } } @@ -767,9 +765,9 @@ struct cff_subset_plan { /* FDArray (FDIndex) */ if (acc.fdArray != &Null(CFF1FDArray)) { offsets.FDArrayInfo.offset = final_size; - CFF1FontDict_OpSerializer fontSzr; + cff1_font_dict_op_serializer_t fontSzr; unsigned int dictsSize = 0; - for (unsigned int i = 0; i < acc.fontDicts.len; i++) + for (unsigned int i = 0; i < acc.fontDicts.length; i++) if (fdmap.includes (i)) dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); @@ -786,7 +784,7 @@ struct cff_subset_plan { 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); + final_size += CFF1CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.length, dataSize); } /* private dicts & local subrs */ @@ -796,12 +794,12 @@ struct cff_subset_plan { if (fdmap.includes (i)) { bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; - CFFPrivateDict_OpSerializer privSzr (desubroutinize, plan->drop_hints); + cff_private_dict_op_serializer_t 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; + table_info_t privInfo = { final_size, priv_size, 0 }; + font_dict_values_mod_t fontdict_mod; if (!acc.is_CID ()) - fontdict_mod.init ( &Null(CFF1FontDictValues), CFF_UNDEF_SID, privInfo ); + fontdict_mod.init ( &Null(cff1_font_dict_values_t), CFF_UNDEF_SID, privInfo ); else fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo ); fontdicts_mod.push (fontdict_mod); @@ -818,50 +816,50 @@ struct cff_subset_plan { if (!acc.is_CID ()) offsets.privateDictInfo = fontdicts_mod[0].privateDictInfo; - return ((subset_charstrings.len == plan->glyphs.len) - && (fontdicts_mod.len == subset_fdcount)); + return ((subset_charstrings.length == plan->glyphs.length) + && (fontdicts_mod.length == subset_fdcount)); } unsigned int get_final_size () const { return final_size; } unsigned int final_size; - hb_vector_t topdict_sizes; - CFF1TopDictValuesMod topdict_mod; - CFF1SubTableOffsets offsets; + hb_vector_t topdict_sizes; + cff1_top_dict_values_mod_t topdict_mod; + cff1_sub_table_offsets_t offsets; unsigned int num_glyphs; unsigned int orig_fdcount; unsigned int subset_fdcount; unsigned int subset_fdselect_format; - hb_vector_t subset_fdselect_ranges; + hb_vector_t 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; + remap_t fdmap; - StrBuffArray subset_charstrings; - StrBuffArray subset_globalsubrs; - hb_vector_t subset_localsubrs; - hb_vector_t fontdicts_mod; + str_buff_vec_t subset_charstrings; + str_buff_vec_t subset_globalsubrs; + hb_vector_t subset_localsubrs; + hb_vector_t fontdicts_mod; - bool drop_hints; + 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 subset_enc_supp_codes; + bool gid_renum; + bool subset_encoding; + uint8_t subset_enc_format; + unsigned int subset_enc_num_codes; + range_list_t subset_enc_code_ranges; + hb_vector_t subset_enc_supp_codes; - uint8_t subset_charset_format; - RangeList subset_charset_ranges; - bool subset_charset; + uint8_t subset_charset_format; + range_list_t subset_charset_ranges; + bool subset_charset; - RemapSID sidmap; - unsigned int topDictModSIDs[NameDictValues::ValCount]; + remap_sid_t sidmap; + unsigned int topDictModSIDs[name_dict_values_t::ValCount]; - bool desubroutinize; - CFF1SubrSubsetter subr_subsetter; + bool desubroutinize; + cff1_subr_subsetter_t subr_subsetter; }; static inline bool _write_cff1 (const cff_subset_plan &plan, @@ -872,9 +870,6 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, { 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 (); if (unlikely (!c.extend_min (*cff))) return false; @@ -887,7 +882,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* name INDEX */ { - assert (cff->nameIndex == c.head - c.start); + assert (cff->nameIndex == (unsigned) (c.head - c.start)); CFF1NameIndex *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, *acc.nameIndex))) @@ -899,11 +894,11 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* top dict INDEX */ { - assert (plan.offsets.topDictInfo.offset == c.head - c.start); + assert (plan.offsets.topDictInfo.offset == (unsigned) (c.head - c.start)); CFF1IndexOf *dest = c.start_embed< CFF1IndexOf > (); if (dest == nullptr) return false; - CFF1TopDict_OpSerializer topSzr; - TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs); + cff1_top_dict_op_serializer_t topSzr; + top_dict_modifiers_t modifier (plan.offsets, plan.topDictModSIDs); if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize, &plan.topdict_mod, 1, plan.topdict_sizes, topSzr, modifier))) @@ -915,7 +910,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* String INDEX */ { - assert (plan.offsets.stringIndexInfo.offset == c.head - c.start); + assert (plan.offsets.stringIndexInfo.offset == (unsigned) (c.head - c.start)); CFF1StringIndex *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, *acc.stringIndex, plan.offsets.stringIndexInfo.offSize, plan.sidmap))) @@ -928,7 +923,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* global subrs */ { assert (plan.offsets.globalSubrsInfo.offset != 0); - assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start); + assert (plan.offsets.globalSubrsInfo.offset == (unsigned) (c.head - c.start)); CFF1Subrs *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; @@ -942,7 +937,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* Encoding */ if (plan.subset_encoding) { - assert (plan.offsets.encodingOffset == c.head - c.start); + assert (plan.offsets.encodingOffset == (unsigned) (c.head - c.start)); Encoding *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, @@ -959,7 +954,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* Charset */ if (plan.subset_charset) { - assert (plan.offsets.charsetInfo.offset == c.head - c.start); + assert (plan.offsets.charsetInfo.offset == (unsigned) (c.head - c.start)); Charset *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, @@ -975,9 +970,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* FDSelect */ if (acc.fdSelect != &Null(CFF1FDSelect)) { - assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); + assert (plan.offsets.FDSelectInfo.offset == (unsigned) (c.head - c.start)); - if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *acc.fdSelect, acc.fdCount, + if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.length, *acc.fdSelect, acc.fdCount, plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, plan.subset_fdselect_ranges))) { @@ -989,10 +984,10 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* FDArray (FD Index) */ if (acc.fdArray != &Null(CFF1FDArray)) { - assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); + assert (plan.offsets.FDArrayInfo.offset == (unsigned) (c.head - c.start)); CFF1FDArray *fda = c.start_embed (); if (unlikely (fda == nullptr)) return false; - CFF1FontDict_OpSerializer fontSzr; + cff1_font_dict_op_serializer_t fontSzr; if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, plan.fontdicts_mod, fontSzr))) @@ -1004,7 +999,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, /* CharStrings */ { - assert (plan.offsets.charStringsInfo.offset == c.head - c.start); + assert (plan.offsets.charStringsInfo.offset == (unsigned) (c.head - c.start)); CFF1CharStrings *cs = c.start_embed (); if (unlikely (cs == nullptr)) return false; if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) @@ -1015,8 +1010,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, } /* private dicts & local subrs */ - assert (plan.offsets.privateDictInfo.offset == c.head - c.start); - for (unsigned int i = 0; i < acc.privateDicts.len; i++) + assert (plan.offsets.privateDictInfo.offset == (unsigned) (c.head - c.start)); + for (unsigned int i = 0; i < acc.privateDicts.length; i++) { if (plan.fdmap.includes (i)) { @@ -1024,7 +1019,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, 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); + cff_private_dict_op_serializer_t 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); @@ -1054,9 +1049,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, 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 */) + const char *data, + hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) { cff_subset_plan cff_plan; 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 index 5a5f29d3569..73a292d0655 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-cff2.cc @@ -34,21 +34,21 @@ using namespace CFF; -struct CFF2SubTableOffsets : CFFSubTableOffsets +struct cff2_sub_table_offsets_t : cff_sub_table_offsets_t { - CFF2SubTableOffsets () - : CFFSubTableOffsets (), + cff2_sub_table_offsets_t () + : cff_sub_table_offsets_t (), varStoreOffset (0) {} unsigned int varStoreOffset; }; -struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> +struct cff2_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<> { bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const CFF2SubTableOffsets &offsets) const + const op_str_t &opstr, + const cff2_sub_table_offsets_t &offsets) const { TRACE_SERIALIZE (this); @@ -58,11 +58,11 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset)); default: - return_trace (CFFTopDict_OpSerializer<>::serialize (c, opstr, offsets)); + return_trace (cff_top_dict_op_serializer_t<>::serialize (c, opstr, offsets)); } } - unsigned int calculate_serialized_size (const OpStr &opstr) const + unsigned int calculate_serialized_size (const op_str_t &opstr) const { switch (opstr.op) { @@ -70,14 +70,14 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); + return cff_top_dict_op_serializer_t<>::calculate_serialized_size (opstr); } } }; -struct CFF2CSOpSet_Flatten : CFF2CSOpSet +struct cff2_cs_opset_flatten_t : cff2_cs_opset_t { - static void flush_args_and_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param) + static void flush_args_and_op (op_code_t op, cff2_cs_interp_env_t &env, flatten_param_t& param) { switch (op) { @@ -105,11 +105,11 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet } } - static void flush_args (CFF2CSInterpEnv &env, FlattenParam& param) + static void flush_args (cff2_cs_interp_env_t &env, flatten_param_t& param) { for (unsigned int i = 0; i < env.argStack.get_count ();) { - const BlendArg &arg = env.argStack[i]; + const blend_arg_t &arg = env.argStack[i]; if (arg.blending ()) { if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues)))) @@ -122,7 +122,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet } else { - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); encoder.encode_num (arg); i++; } @@ -130,15 +130,15 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet SUPER::flush_args (env, param); } - static void flatten_blends (const BlendArg &arg, unsigned int i, CFF2CSInterpEnv &env, FlattenParam& param) + static void flatten_blends (const blend_arg_t &arg, unsigned int i, cff2_cs_interp_env_t &env, flatten_param_t& param) { /* flatten the default values */ - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); for (unsigned int j = 0; j < arg.numValues; j++) { - const BlendArg &arg1 = env.argStack[i + j]; + const blend_arg_t &arg1 = env.argStack[i + j]; if (unlikely (!((arg1.blending () && (arg.numValues == arg1.numValues) && (arg1.valueIndex == j) && - (arg1.deltas.len == env.get_region_count ()))))) + (arg1.deltas.length == env.get_region_count ()))))) { env.set_error (); return; @@ -148,8 +148,8 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet /* 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++) + const blend_arg_t &arg1 = env.argStack[i + j]; + for (unsigned int k = 0; k < arg1.deltas.length; k++) encoder.encode_num (arg1.deltas[k]); } /* flatten the number of values followed by blend operator */ @@ -157,7 +157,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet encoder.encode_op (OpCode_blendcs); } - static void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param) + static void flush_op (op_code_t op, cff2_cs_interp_env_t &env, flatten_param_t& param) { switch (op) { @@ -165,19 +165,19 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet case OpCode_endchar: return; default: - StrEncoder encoder (param.flatStr); + str_encoder_t encoder (param.flatStr); encoder.encode_op (op); } } private: - typedef CFF2CSOpSet SUPER; - typedef CSOpSet CSOPSET; + typedef cff2_cs_opset_t SUPER; + typedef cs_opset_t CSOPSET; }; -struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet +struct cff2_cs_opset_subr_subset_t : cff2_cs_opset_t { - static void process_op (OpCode op, CFF2CSInterpEnv &env, SubrSubsetParam& param) + static void process_op (op_code_t op, cff2_cs_interp_env_t &env, subr_subset_param_t& param) { switch (op) { @@ -202,35 +202,35 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSetadd_op (op, env.substr); + param.current_parsed_str->add_op (op, env.str_ref); break; } } protected: - static void process_call_subr (OpCode op, CSType type, - CFF2CSInterpEnv &env, SubrSubsetParam& param, - CFF2BiasedSubrs& subrs, hb_set_t *closure) + static void process_call_subr (op_code_t op, cs_type_t type, + cff2_cs_interp_env_t &env, subr_subset_param_t& param, + cff2_biased_subrs_t& subrs, hb_set_t *closure) { - SubByteStr substr = env.substr; + byte_str_ref_t str_ref = env.str_ref; env.callSubr (subrs, type); - param.current_parsed_str->add_call_op (op, substr, env.context.subr_num); + param.current_parsed_str->add_call_op (op, str_ref, env.context.subr_num); hb_set_add (closure, env.context.subr_num); param.set_current_str (env, true); } private: - typedef CFF2CSOpSet SUPER; + typedef cff2_cs_opset_t SUPER; }; -struct CFF2SubrSubsetter : SubrSubsetter +struct cff2_subr_subsetter_t : subr_subsetter_t { - static void finalize_parsed_str (CFF2CSInterpEnv &env, SubrSubsetParam& param, ParsedCStr &charstring) + static void finalize_parsed_str (cff2_cs_interp_env_t &env, subr_subset_param_t& param, parsed_cs_str_t &charstring) { /* vsindex is inserted at the beginning of the charstring as necessary */ if (env.seen_vsindex ()) { - Number ivs; + number_t ivs; ivs.set_int ((int)env.get_ivs ()); charstring.set_prefix (ivs, OpCode_vsindexcs); } @@ -278,7 +278,7 @@ struct cff2_subset_plan { /* top dict */ { - CFF2TopDict_OpSerializer topSzr; + cff2_top_dict_op_serializer_t topSzr; offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr); final_size += offsets.topDictInfo.size; } @@ -286,7 +286,7 @@ struct cff2_subset_plan { if (desubroutinize) { /* Flatten global & local subrs */ - SubrFlattener + subr_flattener_t flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) return false; @@ -310,7 +310,7 @@ struct cff2_subset_plan { /* 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); + offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (offsets.globalSubrsInfo.offSize, subset_globalsubrs.length, dataSize); /* local subrs */ if (!offsets.localSubrsInfos.resize (orig_fdcount)) @@ -331,7 +331,7 @@ struct cff2_subset_plan { { 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); + offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].length, dataSize); } } } @@ -370,9 +370,9 @@ struct cff2_subset_plan { /* FDArray (FDIndex) */ { offsets.FDArrayInfo.offset = final_size; - CFFFontDict_OpSerializer fontSzr; + cff_font_dict_op_serializer_t fontSzr; unsigned int dictsSize = 0; - for (unsigned int i = 0; i < acc.fontDicts.len; i++) + for (unsigned int i = 0; i < acc.fontDicts.length; i++) if (fdmap.includes (i)) dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); @@ -385,7 +385,7 @@ struct cff2_subset_plan { 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); + final_size += CFF2CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.length, dataSize); } /* private dicts & local subrs */ @@ -395,9 +395,9 @@ struct cff2_subset_plan { if (fdmap.includes (i)) { bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; - CFFPrivateDict_OpSerializer privSzr (desubroutinize, drop_hints); + cff_private_dict_op_serializer_t 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 }; + table_info_t privInfo = { final_size, priv_size, 0 }; privateDictInfos.push (privInfo); final_size += privInfo.size; @@ -415,23 +415,23 @@ struct cff2_subset_plan { unsigned int get_final_size () const { return final_size; } unsigned int final_size; - CFF2SubTableOffsets offsets; + cff2_sub_table_offsets_t offsets; unsigned int orig_fdcount; unsigned int subset_fdcount; unsigned int subset_fdselect_format; - hb_vector_t subset_fdselect_ranges; + hb_vector_t subset_fdselect_ranges; - Remap fdmap; + remap_t fdmap; - StrBuffArray subset_charstrings; - StrBuffArray subset_globalsubrs; - hb_vector_t subset_localsubrs; - hb_vector_t privateDictInfos; + str_buff_vec_t subset_charstrings; + str_buff_vec_t subset_globalsubrs; + hb_vector_t subset_localsubrs; + hb_vector_t privateDictInfos; bool drop_hints; bool desubroutinize; - CFF2SubrSubsetter subr_subsetter; + cff2_subr_subsetter_t subr_subsetter; }; static inline bool _write_cff2 (const cff2_subset_plan &plan, @@ -453,10 +453,10 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* top dict */ { - assert (cff2->topDict == c.head - c.start); + assert (cff2->topDict == (unsigned) (c.head - c.start)); cff2->topDictSize.set (plan.offsets.topDictInfo.size); TopDict &dict = cff2 + cff2->topDict; - CFF2TopDict_OpSerializer topSzr; + cff2_top_dict_op_serializer_t topSzr; if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 top dict"); @@ -466,7 +466,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* global subrs */ { - assert (cff2->topDict + plan.offsets.topDictInfo.size == c.head - c.start); + assert (cff2->topDict + plan.offsets.topDictInfo.size == (unsigned) (c.head - c.start)); CFF2Subrs *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs))) @@ -479,7 +479,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* variation store */ if (acc.varStore != &Null(CFF2VariationStore)) { - assert (plan.offsets.varStoreOffset == c.head - c.start); + assert (plan.offsets.varStoreOffset == (unsigned) (c.head - c.start)); CFF2VariationStore *dest = c.start_embed (); if (unlikely (!dest->serialize (&c, acc.varStore))) { @@ -491,9 +491,9 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* FDSelect */ if (acc.fdSelect != &Null(CFF2FDSelect)) { - assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); + assert (plan.offsets.FDSelectInfo.offset == (unsigned) (c.head - c.start)); - if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *(const FDSelect *)acc.fdSelect, acc.fdArray->count, + if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.length, *(const FDSelect *)acc.fdSelect, acc.fdArray->count, plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, plan.subset_fdselect_ranges))) { @@ -504,10 +504,10 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* FDArray (FD Index) */ { - assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); + assert (plan.offsets.FDArrayInfo.offset == (unsigned) (c.head - c.start)); CFF2FDArray *fda = c.start_embed (); if (unlikely (fda == nullptr)) return false; - CFFFontDict_OpSerializer fontSzr; + cff_font_dict_op_serializer_t fontSzr; if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, acc.fontDicts, plan.subset_fdcount, plan.fdmap, fontSzr, plan.privateDictInfos))) @@ -519,7 +519,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, /* CharStrings */ { - assert (plan.offsets.charStringsInfo.offset == c.head - c.start); + assert (plan.offsets.charStringsInfo.offset == (unsigned) (c.head - c.start)); CFF2CharStrings *cs = c.start_embed (); if (unlikely (cs == nullptr)) return false; if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) @@ -530,8 +530,8 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, } /* private dicts & local subrs */ - assert (plan.offsets.privateDictsOffset == c.head - c.start); - for (unsigned int i = 0; i < acc.privateDicts.len; i++) + assert (plan.offsets.privateDictsOffset == (unsigned) (c.head - c.start)); + for (unsigned int i = 0; i < acc.privateDicts.length; i++) { if (plan.fdmap.includes (i)) { @@ -539,7 +539,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, 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); + cff_private_dict_op_serializer_t 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); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc index 2219d379c1e..cca364d1de0 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-subset-glyf.cc @@ -39,17 +39,17 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, hb_vector_t *instruction_ranges /* OUT */) { unsigned int total = 0; - for (unsigned int i = 0; i < glyph_ids.len; i++) + for (unsigned int i = 0; i < glyph_ids.length; i++) { hb_codepoint_t next_glyph = glyph_ids[i]; - if (!instruction_ranges->resize (instruction_ranges->len + 2)) + if (!instruction_ranges->resize (instruction_ranges->length + 2)) { DEBUG_MSG(SUBSET, nullptr, "Failed to resize instruction_ranges."); return false; } - unsigned int *instruction_start = &(*instruction_ranges)[instruction_ranges->len - 2]; + unsigned int *instruction_start = &(*instruction_ranges)[instruction_ranges->length - 2]; *instruction_start = 0; - unsigned int *instruction_end = &(*instruction_ranges)[instruction_ranges->len - 1]; + unsigned int *instruction_end = &(*instruction_ranges)[instruction_ranges->length - 1]; *instruction_end = 0; unsigned int start_offset, end_offset; @@ -79,7 +79,7 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, *glyf_size = total; *use_short_loca = (total <= 131070); - *loca_size = (glyph_ids.len + 1) + *loca_size = (glyph_ids.length + 1) * (*use_short_loca ? sizeof (OT::HBUINT16) : sizeof (OT::HBUINT32)); DEBUG_MSG(SUBSET, nullptr, "preparing to subset glyf: final size %d, loca size %d, using %s loca", @@ -167,7 +167,7 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, char *glyf_prime_data_next = glyf_prime_data; bool success = true; - for (unsigned int i = 0; i < glyph_ids.len; i++) + for (unsigned int i = 0; i < glyph_ids.length; i++) { unsigned int start_offset, end_offset; if (unlikely (!(glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset) && @@ -215,7 +215,7 @@ _write_glyf_and_loca_prime (hb_subset_plan_t *plan, glyf_prime_data_next += length + (length % 2); // Align to 2 bytes for short loca. } - success = success && _write_loca_entry (glyph_ids.len, + success = success && _write_loca_entry (glyph_ids.length, glyf_prime_data_next - glyf_prime_data, use_short_loca, loca_prime_data, 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 5c0983b7160..cff3426707a 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 @@ -159,7 +159,7 @@ static void _create_old_gid_to_new_gid_map (const hb_vector_t &glyphs, hb_map_t *glyph_map) { - for (unsigned int i = 0; i < glyphs.len; i++) { + for (unsigned int i = 0; i < glyphs.length; i++) { glyph_map->set (glyphs[i], i); } } 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 8d0473d95fb..31c50dfeb7b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-uniscribe.cc @@ -215,9 +215,12 @@ struct hb_uniscribe_shaper_funcs_t hinstLib = GetModuleHandle (TEXT ("usp10.dll")); if (hinstLib) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" this->ScriptItemizeOpenType = (SIOT) GetProcAddress (hinstLib, "ScriptItemizeOpenType"); this->ScriptShapeOpenType = (SSOT) GetProcAddress (hinstLib, "ScriptShapeOpenType"); this->ScriptPlaceOpenType = (SPOT) GetProcAddress (hinstLib, "ScriptPlaceOpenType"); +#pragma GCC diagnostic pop } if (!this->ScriptItemizeOpenType || !this->ScriptShapeOpenType || @@ -652,7 +655,7 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan, /* Scan events and save features for each range. */ hb_vector_t active_features; unsigned int last_index = 0; - for (unsigned int i = 0; i < feature_events.len; i++) + for (unsigned int i = 0; i < feature_events.length; i++) { feature_event_t *event = &feature_events[i]; @@ -661,26 +664,26 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan, /* Save a snapshot of active features and the range. */ range_record_t *range = range_records.push (); - unsigned int offset = feature_records.len; + unsigned int offset = feature_records.length; active_features.qsort (); - for (unsigned int j = 0; j < active_features.len; j++) + for (unsigned int j = 0; j < active_features.length; j++) { - if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.len - 1].tagFeature) + if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.length - 1].tagFeature) { feature_records.push (active_features[j].rec); } else { /* Overrides value for existing feature. */ - feature_records[feature_records.len - 1].lParameter = active_features[j].rec.lParameter; + feature_records[feature_records.length - 1].lParameter = active_features[j].rec.lParameter; } } /* Will convert to pointer after all is ready, since feature_records.array * may move as we grow it. */ range->props.potfRecords = reinterpret_cast (offset); - range->props.cotfRecords = feature_records.len - offset; + range->props.cotfRecords = feature_records.length - offset; range->index_first = last_index; range->index_last = event->index - 1; @@ -699,14 +702,14 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan, } } - if (!range_records.len) /* No active feature found. */ + if (!range_records.length) /* No active feature found. */ num_features = 0; /* Fixup the pointers. */ - for (unsigned int i = 0; i < range_records.len; i++) + for (unsigned int i = 0; i < range_records.length; i++) { range_record_t *range = &range_records[i]; - range->props.potfRecords = feature_records + reinterpret_cast (range->props.potfRecords); + range->props.potfRecords = (OPENTYPE_FEATURE_RECORD *) feature_records + reinterpret_cast (range->props.potfRecords); } } @@ -817,7 +820,7 @@ retry: script_tags, &item_count); if (unlikely (FAILED (hr))) - FAIL ("ScriptItemizeOpenType() failed: 0x%08xL", hr); + FAIL ("ScriptItemizeOpenType() failed: 0x%08lx", hr); #undef MAX_ITEMS @@ -853,8 +856,8 @@ retry: range--; while (log_clusters[k] > range->index_last) range++; - if (!range_properties.len || - &range->props != range_properties[range_properties.len - 1]) + if (!range_properties.length || + &range->props != range_properties[range_properties.length - 1]) { TEXTRANGE_PROPERTIES **props = range_properties.push (); int *c = range_char_counts.push (); @@ -869,7 +872,7 @@ retry: } else { - range_char_counts[range_char_counts.len - 1]++; + range_char_counts[range_char_counts.length - 1]++; } last_range = range; @@ -888,7 +891,7 @@ retry: language_tag, range_char_counts.arrayZ (), range_properties.arrayZ (), - range_properties.len, + range_properties.length, pchars + chars_offset, item_chars_len, glyphs_size - glyphs_offset, @@ -916,7 +919,7 @@ retry: } if (unlikely (FAILED (hr))) { - FAIL ("ScriptShapeOpenType() failed: 0x%08xL", hr); + FAIL ("ScriptShapeOpenType() failed: 0x%08lx", hr); } for (unsigned int j = chars_offset; j < chars_offset + item_chars_len; j++) @@ -929,7 +932,7 @@ retry: language_tag, range_char_counts.arrayZ (), range_properties.arrayZ (), - range_properties.len, + range_properties.length, pchars + chars_offset, log_clusters + chars_offset, char_props + chars_offset, @@ -942,7 +945,7 @@ retry: offsets + glyphs_offset, nullptr); if (unlikely (FAILED (hr))) - FAIL ("ScriptPlaceOpenType() failed: 0x%08xL", hr); + FAIL ("ScriptPlaceOpenType() failed: 0x%08lx", hr); if (DEBUG_ENABLED (UNISCRIBE)) fprintf (stderr, "Item %d RTL %d LayoutRTL %d LogicalOrder %d ScriptTag %c%c%c%c\n", @@ -961,13 +964,13 @@ retry: /* Calculate visual-clusters. That's what we ship. */ for (unsigned int i = 0; i < glyphs_len; i++) - vis_clusters[i] = -1; + vis_clusters[i] = (uint32_t) -1; for (unsigned int i = 0; i < buffer->len; i++) { uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]]; *p = MIN (*p, buffer->info[i].cluster); } for (unsigned int i = 1; i < glyphs_len; i++) - if (vis_clusters[i] == -1) + if (vis_clusters[i] == (uint32_t) -1) vis_clusters[i] = vis_clusters[i - 1]; #undef utf16_index 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 d8e3f4ef109..2fd739b5c1f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-vector.hh @@ -29,29 +29,28 @@ #include "hb.hh" #include "hb-array.hh" +#include "hb-null.hh" -template +template struct hb_vector_t { - typedef Type ItemType; - enum { item_size = hb_static_size (Type) }; + typedef Type item_t; + static constexpr unsigned item_size = hb_static_size (Type); - HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount); + HB_NO_COPY_ASSIGN_TEMPLATE (hb_vector_t, Type); hb_vector_t () { init (); } ~hb_vector_t () { fini (); } - unsigned int len; + unsigned int length; private: - unsigned int allocated; /* == 0 means allocation failed. */ + int allocated; /* == -1 means allocation failed. */ Type *arrayZ_; - Type static_array[PreallocedCount]; public: void init () { - len = 0; - allocated = ARRAY_LENGTH (static_array); + allocated = length = 0; arrayZ_ = nullptr; } @@ -59,40 +58,41 @@ struct hb_vector_t { if (arrayZ_) free (arrayZ_); - arrayZ_ = nullptr; - allocated = len = 0; + init (); } void fini_deep () { Type *array = arrayZ(); - unsigned int count = len; + unsigned int count = length; for (unsigned int i = 0; i < count; i++) array[i].fini (); fini (); } - Type * arrayZ () { return arrayZ_ ? arrayZ_ : static_array; } - const Type * arrayZ () const { return arrayZ_ ? arrayZ_ : static_array; } + const Type * arrayZ () const { return arrayZ_; } + Type * arrayZ () { return arrayZ_; } Type& operator [] (int i_) { unsigned int i = (unsigned int) i_; - if (unlikely (i >= len)) + if (unlikely (i >= length)) return Crap (Type); return arrayZ()[i]; } const Type& operator [] (int i_) const { unsigned int i = (unsigned int) i_; - if (unlikely (i >= len)) + if (unlikely (i >= length)) return Null(Type); return arrayZ()[i]; } + explicit_operator bool () const { return length; } + hb_array_t as_array () - { return hb_array (arrayZ(), len); } + { return hb_array (arrayZ(), length); } hb_array_t as_array () const - { return hb_array (arrayZ(), len); } + { return hb_array (arrayZ(), length); } hb_array_t sub_array (unsigned int start_offset, unsigned int count) const { return as_array ().sub_array (start_offset, count);} @@ -104,9 +104,9 @@ struct hb_vector_t { return as_array ().sub_array (start_offset, count);} hb_sorted_array_t as_sorted_array () - { return hb_sorted_array (arrayZ(), len); } + { return hb_sorted_array (arrayZ(), length); } hb_sorted_array_t as_sorted_array () const - { return hb_sorted_array (arrayZ(), len); } + { return hb_sorted_array (arrayZ(), length); } hb_array_t sorted_sub_array (unsigned int start_offset, unsigned int count) const { return as_sorted_array ().sorted_sub_array (start_offset, count);} @@ -127,9 +127,9 @@ struct hb_vector_t Type *push () { - if (unlikely (!resize (len + 1))) + if (unlikely (!resize (length + 1))) return &Crap(Type); - return &arrayZ()[len - 1]; + return &arrayZ()[length - 1]; } Type *push (const Type& v) { @@ -138,15 +138,15 @@ struct hb_vector_t return p; } - bool in_error () const { return allocated == 0; } + bool in_error () const { return allocated < 0; } - /* Allocate for size but don't adjust len. */ + /* Allocate for size but don't adjust length. */ bool alloc (unsigned int size) { - if (unlikely (!allocated)) + if (unlikely (allocated < 0)) return false; - if (likely (size <= allocated)) + if (likely (size <= (unsigned) allocated)) return true; /* Reallocate */ @@ -156,23 +156,16 @@ struct hb_vector_t new_allocated += (new_allocated >> 1) + 8; Type *new_array = nullptr; - - if (!arrayZ_) - { - new_array = (Type *) calloc (new_allocated, sizeof (Type)); - if (new_array) - memcpy (new_array, static_array, len * sizeof (Type)); - } - else - { - bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); - if (likely (!overflows)) - new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type)); - } + bool overflows = + (int) new_allocated < 0 || + (new_allocated < (unsigned) allocated) || + hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); + if (likely (!overflows)) + new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type)); if (unlikely (!new_array)) { - allocated = 0; + allocated = -1; return false; } @@ -188,42 +181,42 @@ struct hb_vector_t if (!alloc (size)) return false; - if (size > len) - memset (arrayZ() + len, 0, (size - len) * sizeof (*arrayZ())); + if (size > length) + memset (arrayZ() + length, 0, (size - length) * sizeof (*arrayZ())); - len = size; + length = size; return true; } void pop () { - if (!len) return; - len--; + if (!length) return; + length--; } void remove (unsigned int i) { - if (unlikely (i >= len)) + if (unlikely (i >= length)) return; Type *array = arrayZ(); memmove (static_cast (&array[i]), static_cast (&array[i + 1]), - (len - i - 1) * sizeof (Type)); - len--; + (length - i - 1) * sizeof (Type)); + length--; } void shrink (int size_) { unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; - if (size < len) - len = size; + if (size < length) + length = size; } template Type *find (T v) { Type *array = arrayZ(); - for (unsigned int i = 0; i < len; i++) + for (unsigned int i = 0; i < length; i++) if (array[i] == v) return &array[i]; return nullptr; @@ -232,7 +225,7 @@ struct hb_vector_t const Type *find (T v) const { const Type *array = arrayZ(); - for (unsigned int i = 0; i < len; i++) + for (unsigned int i = 0; i < length; i++) if (array[i] == v) return &array[i]; return nullptr; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh index a55e92d5ddc..5b66ba85d19 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb.hh @@ -29,6 +29,102 @@ #ifndef HB_HH #define HB_HH +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC +#if defined(_MSC_VER) +#pragma warning( disable: 4068 ) /* Unknown pragma */ +#endif +#if defined(__GNUC__) || defined(__clang__) +/* Rules: + * + * - All pragmas are declared GCC even if they are clang ones. Otherwise GCC + * nags, even though we instruct it to ignore -Wunknown-pragmas. ¯\_(ツ)_/¯ + * + * - Within each category, keep sorted. + * + * - Warnings whose scope can be expanded in future compiler versions shall + * be declared as "warning". Otherwise, either ignored or error. + */ + +/* Setup. Don't sort order within this category. */ +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING +#pragma GCC diagnostic warning "-Wall" +#pragma GCC diagnostic warning "-Wextra" +#endif +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#endif +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING +//#pragma GCC diagnostic warning "-Weverything" +#endif + +/* Error. Should never happen. */ +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR +#pragma GCC diagnostic error "-Wc++11-narrowing" +#pragma GCC diagnostic error "-Wcast-align" +#pragma GCC diagnostic error "-Wcast-function-type" +#pragma GCC diagnostic error "-Wdelete-non-virtual-dtor" +#pragma GCC diagnostic error "-Wformat-security" +#pragma GCC diagnostic error "-Wimplicit-function-declaration" +#pragma GCC diagnostic error "-Winit-self" +#pragma GCC diagnostic error "-Wmissing-braces" +#pragma GCC diagnostic error "-Wmissing-declarations" +#pragma GCC diagnostic error "-Wmissing-prototypes" +#pragma GCC diagnostic error "-Wnested-externs" +#pragma GCC diagnostic error "-Wold-style-definition" +#pragma GCC diagnostic error "-Wpointer-arith" +#pragma GCC diagnostic error "-Wredundant-decls" +#pragma GCC diagnostic error "-Wreorder" +#pragma GCC diagnostic error "-Wsign-compare" +#pragma GCC diagnostic error "-Wstrict-prototypes" +#pragma GCC diagnostic error "-Wstring-conversion" +#pragma GCC diagnostic error "-Wswitch-enum" +#pragma GCC diagnostic error "-Wtautological-overlap-compare" +#pragma GCC diagnostic error "-Wunneeded-internal-declaration" +#pragma GCC diagnostic error "-Wunused" +#pragma GCC diagnostic error "-Wunused-local-typedefs" +#pragma GCC diagnostic error "-Wunused-value" +#pragma GCC diagnostic error "-Wunused-variable" +#pragma GCC diagnostic error "-Wvla" +#pragma GCC diagnostic error "-Wwrite-strings" +#endif + +/* Warning. To be investigated if happens. */ +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING +#pragma GCC diagnostic warning "-Wbuiltin-macro-redefined" +#pragma GCC diagnostic warning "-Wdisabled-optimization" +#pragma GCC diagnostic warning "-Wformat=2" +#pragma GCC diagnostic warning "-Wignored-pragma-optimize" +#pragma GCC diagnostic warning "-Wlogical-op" +#pragma GCC diagnostic warning "-Wmaybe-uninitialized" +#pragma GCC diagnostic warning "-Wmissing-format-attribute" +#pragma GCC diagnostic warning "-Wundef" +#endif + +/* Ignored currently, but should be fixed at some point. */ +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED +#pragma GCC diagnostic ignored "-Wconversion" // TODO fix +#pragma GCC diagnostic ignored "-Wformat-signedness" // TODO fix +#pragma GCC diagnostic ignored "-Wshadow" // TODO fix +#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" // TODO fix +#pragma GCC diagnostic ignored "-Wunused-parameter" // TODO fix +#endif + +/* Ignored intentionally. */ +#ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#pragma GCC diagnostic ignored "-Wpacked" // Erratic impl in clang +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic ignored "-Wtype-limits" +#endif + +#endif +#endif + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -59,10 +155,6 @@ # define __EXTENSIONS__ 1 #endif -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#endif - #if defined (_MSC_VER) && defined (HB_DLL_EXPORT) #define HB_EXTERN __declspec (dllexport) extern #endif @@ -137,7 +229,7 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1] #endif // static_assert -#ifdef __GNUC__ +#if defined(__GNUC__) #if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) #define thread_local __thread #endif @@ -187,7 +279,7 @@ struct _hb_alignof #define __attribute__(x) #endif -#if __GNUC__ >= 3 +#if defined(__GNUC__) && (__GNUC__ >= 3) #define HB_PURE_FUNC __attribute__((pure)) #define HB_CONST_FUNC __attribute__((const)) #define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) @@ -196,7 +288,7 @@ struct _hb_alignof #define HB_CONST_FUNC #define HB_PRINTF_FUNC(format_idx, arg_idx) #endif -#if __GNUC__ >= 4 +#if defined(__GNUC__) && (__GNUC__ >= 4) #define HB_UNUSED __attribute__((unused)) #elif defined(_MSC_VER) /* https://github.com/harfbuzz/harfbuzz/issues/635 */ #define HB_UNUSED __pragma(warning(suppress: 4100 4101)) @@ -219,7 +311,7 @@ struct _hb_alignof # endif #endif -#if __GNUC__ >= 3 +#if defined(__GNUC__) && (__GNUC__ >= 3) #define HB_FUNC __PRETTY_FUNCTION__ #elif defined(_MSC_VER) #define HB_FUNC __FUNCSIG__ @@ -251,7 +343,7 @@ struct _hb_alignof #if defined(__clang__) && __cplusplus >= 201103L /* clang's fallthrough annotations are only available starting in C++11. */ # define HB_FALLTHROUGH [[clang::fallthrough]] -#elif __GNUC__ >= 7 +#elif defined(__GNUC__) && (__GNUC__ >= 7) /* GNU fallthrough attribute is available from GCC7 */ # define HB_FALLTHROUGH __attribute__((fallthrough)) #elif defined(_MSC_VER) @@ -377,6 +469,9 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); #define HB_NO_COPY_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) +#define HB_NO_COPY_ASSIGN_TEMPLATE(TypeName, T) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) #define HB_NO_COPY_ASSIGN_TEMPLATE2(TypeName, T1, T2) \ TypeName(const TypeName&); \ void operator=(const TypeName&) @@ -396,6 +491,7 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); #else /* __cpluspplus >= 201103L */ #define HB_NO_COPY_ASSIGN(TypeName) static_assert (true, "") +#define HB_NO_COPY_ASSIGN_TEMPLATE(TypeName, T) 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, "") @@ -468,7 +564,8 @@ typedef uint64_t hb_vector_size_impl_t; static inline T& operator |= (T &l, T r) { l = l | r; return l; } \ static inline T& operator &= (T& l, T r) { l = l & r; return l; } \ static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \ - } + } \ + static_assert (true, "") /* Useful for set-operations on small enums. * For example, for testing "x ∈ {x1, x2, x3}" use: @@ -545,13 +642,17 @@ template struct hb_remove_pointer { typedef T value; }; #define hb_remove_pointer(T) hb_remove_pointer::value -/* Headers we include for everyone. Keep sorted. They express dependency amongst - * themselves, but no other file should include them.*/ +/* Headers we include for everyone. Keep topologically sorted by dependency. + * They express dependency amongst themselves, but no other file should include + * them directly.*/ #include "hb-atomic.hh" -#include "hb-debug.hh" -#include "hb-dsalgs.hh" #include "hb-mutex.hh" #include "hb-null.hh" -#include "hb-object.hh" +#include "hb-dsalgs.hh" // Requires: hb-null +#include "hb-iter.hh" // Requires: hb-null +#include "hb-debug.hh" // Requires: hb-atomic hb-dsalgs +#include "hb-array.hh" // Requires: hb-dsalgs hb-iter hb-null +#include "hb-vector.hh" // Requires: hb-array hb-null +#include "hb-object.hh" // Requires: hb-atomic hb-mutex hb-vector #endif /* HB_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/test-iter.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-iter.cc new file mode 100644 index 00000000000..05430b009c7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/test-iter.cc @@ -0,0 +1,84 @@ +/* + * Copyright © 2018 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "hb.hh" +#include "hb-iter.hh" + +#include "hb-array.hh" +#include "hb-set.hh" + + +template +struct array_iter_t : hb_iter_t, T>, hb_iter_mixin_t, T> +{ + array_iter_t (hb_array_t arr_) : arr (arr_) {} + + typedef T __item_type__; + T& __item_at__ (unsigned i) const { return arr[i]; } + void __forward__ (unsigned n) { arr += n; } + void __rewind__ (unsigned n) { arr -= n; } + unsigned __len__ () const { return arr.length; } + bool __random_access__ () const { return true; } + + private: + hb_array_t arr; +}; + +template +struct some_array_t +{ + some_array_t (hb_array_t arr_) : arr (arr_) {} + + typedef array_iter_t iter_t; + array_iter_t iter () { return array_iter_t (arr); } + operator array_iter_t () { return iter (); } + operator hb_iter_t > () { return iter (); } + + private: + hb_array_t arr; +}; + +int +main (int argc, char **argv) +{ + const int src[10] = {}; + int dst[20]; + hb_vector_t v; + + array_iter_t s (src); /* Implicit conversion from static array. */ + array_iter_t s2 (v); /* Implicit conversion from vector. */ + array_iter_t t (dst); + + some_array_t a (src); + + s2 = s; + + hb_fill (t, 42); + hb_copy (t, s); + // hb_copy (t, a.iter ()); + + return 0; +} 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 ec9d17acd23..0eef8c24b50 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 @@ -25,7 +25,6 @@ */ #include "hb.hh" - #include "hb-ot-os2-unicode-ranges.hh" static void -- cgit v1.2.3