Bug 1524102 - Update HarfBuzz to version 2.3.1. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D18170
This commit is contained in:
Ryan VanderMeulen
2019-01-31 12:01:26 +00:00
parent 4963e62f84
commit 838d890d08
108 changed files with 2099 additions and 1800 deletions

View File

@@ -1,3 +1,10 @@
Overview of changes leading to 2.3.1
Wednesday, January 30, 2019
====================================
- AAT bug fixes.
- Misc internal housekeeping cleanup.
Overview of changes leading to 2.3.0 Overview of changes leading to 2.3.0
Thursday, December 20, 2018 Thursday, December 20, 2018
==================================== ====================================

View File

@@ -1,7 +1,7 @@
This directory contains the HarfBuzz source from the upstream repo: This directory contains the HarfBuzz source from the upstream repo:
https://github.com/harfbuzz/harfbuzz https://github.com/harfbuzz/harfbuzz
Current version: 2.3.0 [commit 4941e95f10fe0fe658752134a42b58896fb19c42] Current version: 2.3.1 [commit 55d1d7c8bcd8d97c4e618e5dd21f13df50b10ce8]
UPDATING: UPDATING:

View File

@@ -1,6 +1,6 @@
[![Travis Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg)](https://travis-ci.org/harfbuzz/harfbuzz) [![Travis Build Status](https://travis-ci.org/harfbuzz/harfbuzz.svg?branch=master)](https://travis-ci.org/harfbuzz/harfbuzz)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true)](https://ci.appveyor.com/project/harfbuzz/harfbuzz) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/0t0flrxpstj9lb9w?svg=true&branch=master)](https://ci.appveyor.com/project/harfbuzz/harfbuzz)
[![CircleCI Build Status](https://circleci.com/gh/harfbuzz/harfbuzz.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz) [![CircleCI Build Status](https://circleci.com/gh/harfbuzz/harfbuzz/tree/master.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz/tree/master)
[![Coverity Code Health](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz) [![Coverity Code Health](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/behdad-harfbuzz)
[![Codacy Code Health](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz) [![Codacy Code Health](https://api.codacy.com/project/badge/Grade/f17f1708783c447488bc8dd317150eaa)](https://app.codacy.com/app/behdad/harfbuzz)
[![Codecov Code Coverage](https://codecov.io/gh/harfbuzz/harfbuzz/branch/master/graph/badge.svg)](https://codecov.io/gh/harfbuzz/harfbuzz) [![Codecov Code Coverage](https://codecov.io/gh/harfbuzz/harfbuzz/branch/master/graph/badge.svg)](https://codecov.io/gh/harfbuzz/harfbuzz)

View File

@@ -1,6 +1,6 @@
AC_PREREQ([2.64]) AC_PREREQ([2.64])
AC_INIT([HarfBuzz], AC_INIT([HarfBuzz],
[2.3.0], [2.3.1],
[https://github.com/harfbuzz/harfbuzz/issues/new], [https://github.com/harfbuzz/harfbuzz/issues/new],
[harfbuzz], [harfbuzz],
[http://harfbuzz.org/]) [http://harfbuzz.org/])
@@ -102,9 +102,6 @@ if test "x$GCC" = "xyes"; then
# by overriding CXXFLAGS. # by overriding CXXFLAGS.
CXXFLAGS="-fno-rtti $CXXFLAGS -fno-exceptions -fno-threadsafe-statics" CXXFLAGS="-fno-rtti $CXXFLAGS -fno-exceptions -fno-threadsafe-statics"
# Assorted warnings
CXXFLAGS="$CXXFLAGS -Wcast-align"
case "$host" in case "$host" in
*-*-mingw*) *-*-mingw*)
;; ;;

View File

@@ -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_CPPFLAGS = $(HBCFLAGS)
dump_use_data_LDADD = libharfbuzz.la $(HBLIBS) dump_use_data_LDADD = libharfbuzz.la $(HBLIBS)
check_PROGRAMS += test-ot-tag test-unicode-ranges COMPILED_TESTS = test-iter test-ot-tag test-unicode-ranges
TESTS += 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_SOURCES = hb-ot-tag.cc
test_ot_tag_CPPFLAGS = $(HBCFLAGS) -DMAIN test_ot_tag_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS) test_ot_tag_LDADD = $(COMPILED_TESTS_LDADD)
test_unicode_ranges_SOURCES = test-unicode-ranges.cc 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 = \ TESTS_ENVIRONMENT = \
srcdir="$(srcdir)" \ srcdir="$(srcdir)" \

View File

@@ -36,6 +36,7 @@ HB_BASE_sources = \
hb-face.hh \ hb-face.hh \
hb-font.cc \ hb-font.cc \
hb-font.hh \ hb-font.hh \
hb-iter.hh \
hb-kern.hh \ hb-kern.hh \
hb-machinery.hh \ hb-machinery.hh \
hb-map.cc \ hb-map.cc \

View File

@@ -131,6 +131,8 @@ for i in range (2):
what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"] what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"]
what_short = ["ISC", "IMC"] what_short = ["ISC", "IMC"]
print ('#pragma GCC diagnostic push')
print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
for i in range (2): for i in range (2):
print () print ()
vv = sorted (values[i].keys ()) vv = sorted (values[i].keys ())
@@ -148,6 +150,7 @@ for i in range (2):
(what_short[i], s, what[i], v.upper (), (what_short[i], s, what[i], v.upper (),
' '* ((48-1 - len (what[i]) - 1 - len (v)) // 8), ' '* ((48-1 - len (what[i]) - 1 - len (v)) // 8),
values[i][v], v)) values[i][v], v))
print ('#pragma GCC diagnostic pop')
print () print ()
print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)") print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)")
print () print ()

View File

@@ -10,8 +10,11 @@ import io
import re import re
import sys import sys
reload(sys) try:
sys.setdefaultencoding('utf-8') reload(sys)
sys.setdefaultencoding('utf-8')
except NameError:
pass # Python 3
print ("""static OS2Range _hb_os2_unicode_ranges[] = 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] current_bit = fields[0]
fields = fields[1:] fields = fields[1:]
elif len(fields) > 3: elif len(fields) > 3:
raise Error("bad input :(.") raise Exception("bad input :(.")
name = fields[0] name = fields[0]
ranges = re.split("-", fields[1]) ranges = re.split("-", fields[1])
if len(ranges) != 2: 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)) v = tuple((int(ranges[0], 16), int(ranges[1], 16), int(current_bit), name))
all_ranges.append(v) all_ranges.append(v)

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
# flake8: noqa
from __future__ import print_function, division, absolute_import from __future__ import print_function, division, absolute_import
import io, sys import io
import sys
if len (sys.argv) != 5: if len (sys.argv) != 5:
print ("usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt", file=sys.stderr) 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 offset = 0
starts = [] starts = []
ends = [] ends = []
print ('#pragma GCC diagnostic push')
print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
for k,v in sorted(use_mapping.items()): for k,v in sorted(use_mapping.items()):
if k in use_positions and use_positions[k]: continue if k in use_positions and use_positions[k]: continue
print ("#define %s USE_%s /* %s */" % (k, k, v.__name__[3:])) 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(): for suf in v.keys():
tag = k + suf tag = k + suf
print ("#define %s USE_%s" % (tag, tag)) print ("#define %s USE_%s" % (tag, tag))
print ('#pragma GCC diagnostic pop')
print ("") print ("")
print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {") print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {")
for u in uu: for u in uu:

View File

@@ -74,7 +74,7 @@ struct FontDescriptor
struct fdsc struct fdsc
{ {
enum { tableTag = HB_AAT_TAG_fdsc }; static constexpr hb_tag_t tableTag = HB_AAT_TAG_fdsc;
enum { enum {
Weight = HB_TAG ('w','g','h','t'), Weight = HB_TAG ('w','g','h','t'),

View File

@@ -58,20 +58,16 @@ typedef LArrayOf<Anchor> GlyphAnchors;
struct ankr 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, const Anchor &get_anchor (hb_codepoint_t glyph_id,
unsigned int i, unsigned int i,
unsigned int num_glyphs, unsigned int num_glyphs) const
const char *end) const
{ {
const Offset<HBUINT16, false> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs); const NNOffsetTo<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
if (!offset) if (!offset)
return Null(Anchor); return Null(Anchor);
const GlyphAnchors &anchors = StructAtOffset<GlyphAnchors> (&(this+anchorData), *offset); const GlyphAnchors &anchors = &(this+anchorData) + *offset;
/* TODO Use sanitizer; to avoid overflows and more. */
if (unlikely ((const char *) &anchors + anchors.get_size () > end))
return Null(Anchor);
return anchors[i]; return anchors[i];
} }
@@ -80,15 +76,15 @@ struct ankr
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) && return_trace (likely (c->check_struct (this) &&
version == 0 && version == 0 &&
lookupTable.sanitize (c, this))); lookupTable.sanitize (c, this, &(this+anchorData))));
} }
protected: protected:
HBUINT16 version; /* Version number (set to zero) */ HBUINT16 version; /* Version number (set to zero) */
HBUINT16 flags; /* Flags (currently unused; set to zero) */ HBUINT16 flags; /* Flags (currently unused; set to zero) */
LOffsetTo<Lookup<Offset<HBUINT16, false> >, false> LOffsetTo<Lookup<NNOffsetTo<GlyphAnchors> > >
lookupTable; /* Offset to the table's lookup table */ lookupTable; /* Offset to the table's lookup table */
LOffsetTo<HBUINT8, false> LNNOffsetTo<HBUINT8>
anchorData; /* Offset to the glyph data table */ anchorData; /* Offset to the glyph data table */
public: public:

View File

@@ -116,7 +116,7 @@ struct BaselineTableFormat3Part
struct bsln 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 bool sanitize (hb_sanitize_context_t *c) const
{ {

View File

@@ -77,7 +77,7 @@ struct LookupFormat0
template <typename T> template <typename T>
struct LookupSegmentSingle struct LookupSegmentSingle
{ {
enum { TerminationWordCount = 2 }; static constexpr unsigned TerminationWordCount = 2u;
int cmp (hb_codepoint_t g) const int cmp (hb_codepoint_t g) const
{ return g < first ? -1 : g <= last ? 0 : +1 ; } { return g < first ? -1 : g <= last ? 0 : +1 ; }
@@ -136,7 +136,7 @@ struct LookupFormat2
template <typename T> template <typename T>
struct LookupSegmentArray struct LookupSegmentArray
{ {
enum { TerminationWordCount = 2 }; static constexpr unsigned TerminationWordCount = 2u;
const T* get_value (hb_codepoint_t glyph_id, const void *base) const const T* get_value (hb_codepoint_t glyph_id, const void *base) const
{ {
@@ -164,7 +164,7 @@ struct LookupSegmentArray
GlyphID last; /* Last GlyphID in this segment */ GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */ GlyphID first; /* First GlyphID in this segment */
OffsetTo<UnsizedArrayOf<T>, HBUINT16, false> NNOffsetTo<UnsizedArrayOf<T> >
valuesZ; /* A 16-bit offset from the start of valuesZ; /* A 16-bit offset from the start of
* the table to the data. */ * the table to the data. */
public: public:
@@ -207,7 +207,7 @@ struct LookupFormat4
template <typename T> template <typename T>
struct LookupSingle struct LookupSingle
{ {
enum { TerminationWordCount = 1 }; static constexpr unsigned TerminationWordCount = 1u;
int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } 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 4: return_trace (u.format4.sanitize (c, base));
case 6: return_trace (u.format6.sanitize (c, base)); case 6: return_trace (u.format6.sanitize (c, base));
case 8: return_trace (u.format8.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); default:return_trace (true);
} }
} }
@@ -511,9 +511,10 @@ struct StateTable
const Entry<Extra> *get_entries () const const Entry<Extra> *get_entries () const
{ return (this+entryTable).arrayZ; } { return (this+entryTable).arrayZ; }
const Entry<Extra> *get_entryZ (int state, unsigned int klass) const const Entry<Extra> &get_entry (int state, unsigned int klass) const
{ {
if (unlikely (klass >= nClasses)) return nullptr; if (unlikely (klass >= nClasses))
klass = StateTable<Types, Entry<Extra> >::CLASS_OUT_OF_BOUNDS;
const HBUSHORT *states = (this+stateArrayTable).arrayZ; const HBUSHORT *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ;
@@ -521,7 +522,7 @@ struct StateTable
unsigned int entry = states[state * nClasses + klass]; unsigned int entry = states[state * nClasses + klass];
DEBUG_MSG (APPLY, nullptr, "e%u", entry); DEBUG_MSG (APPLY, nullptr, "e%u", entry);
return &entries[entry]; return entries[entry];
} }
bool sanitize (hb_sanitize_context_t *c, bool sanitize (hb_sanitize_context_t *c,
@@ -529,6 +530,7 @@ struct StateTable
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!(c->check_struct (this) && if (unlikely (!(c->check_struct (this) &&
nClasses >= 4 /* Ensure pre-defined classes fit. */ &&
classTable.sanitize (c, this)))) return_trace (false); classTable.sanitize (c, this)))) return_trace (false);
const HBUSHORT *states = (this+stateArrayTable).arrayZ; const HBUSHORT *states = (this+stateArrayTable).arrayZ;
@@ -571,7 +573,7 @@ struct StateTable
-min_state, -min_state,
row_stride))) row_stride)))
return_trace (false); return_trace (false);
if ((c->max_ops -= state_neg - min_state) < 0) if ((c->max_ops -= state_neg - min_state) <= 0)
return_trace (false); return_trace (false);
{ /* Sweep new states. */ { /* Sweep new states. */
const HBUSHORT *stop = &states[min_state * num_classes]; const HBUSHORT *stop = &states[min_state * num_classes];
@@ -590,7 +592,7 @@ struct StateTable
max_state + 1, max_state + 1,
row_stride))) row_stride)))
return_trace (false); 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); return_trace (false);
{ /* Sweep new states. */ { /* Sweep new states. */
if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes))) 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))) if (unlikely (!c->check_array (entries, num_entries)))
return_trace (false); return_trace (false);
if ((c->max_ops -= num_entries - entry) < 0) if ((c->max_ops -= num_entries - entry) <= 0)
return_trace (false); return_trace (false);
{ /* Sweep new entries. */ { /* Sweep new entries. */
const Entry<Extra> *stop = &entries[num_entries]; const Entry<Extra> *stop = &entries[num_entries];
@@ -629,11 +631,11 @@ struct StateTable
protected: protected:
HBUINT nClasses; /* Number of classes, which is the number of indices HBUINT nClasses; /* Number of classes, which is the number of indices
* in a single line in the state array. */ * in a single line in the state array. */
OffsetTo<ClassType, HBUINT, false> NNOffsetTo<ClassType, HBUINT>
classTable; /* Offset to the class table. */ classTable; /* Offset to the class table. */
OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT>
stateArrayTable;/* Offset to the state array. */ stateArrayTable;/* Offset to the state array. */
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT, false> NNOffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT>
entryTable; /* Offset to the entry array. */ entryTable; /* Offset to the entry array. */
public: public:
@@ -669,7 +671,7 @@ struct ClassTable
struct ObsoleteTypes struct ObsoleteTypes
{ {
enum { extended = false }; static constexpr bool extended = false;
typedef HBUINT16 HBUINT; typedef HBUINT16 HBUINT;
typedef HBUINT8 HBUSHORT; typedef HBUINT8 HBUSHORT;
typedef ClassTable<HBUINT8> ClassTypeNarrow; typedef ClassTable<HBUINT8> ClassTypeNarrow;
@@ -699,7 +701,7 @@ struct ObsoleteTypes
}; };
struct ExtendedTypes struct ExtendedTypes
{ {
enum { extended = true }; static constexpr bool extended = true;
typedef HBUINT32 HBUINT; typedef HBUINT32 HBUINT;
typedef HBUINT16 HBUSHORT; typedef HBUINT16 HBUSHORT;
typedef Lookup<HBUINT16> ClassTypeNarrow; typedef Lookup<HBUINT16> ClassTypeNarrow;
@@ -707,22 +709,22 @@ struct ExtendedTypes
template <typename T> template <typename T>
static unsigned int offsetToIndex (unsigned int offset, static unsigned int offsetToIndex (unsigned int offset,
const void *base, const void *base HB_UNUSED,
const T *array) const T *array HB_UNUSED)
{ {
return offset; return offset;
} }
template <typename T> template <typename T>
static unsigned int byteOffsetToIndex (unsigned int offset, static unsigned int byteOffsetToIndex (unsigned int offset,
const void *base, const void *base HB_UNUSED,
const T *array) const T *array HB_UNUSED)
{ {
return offset / 2; return offset / 2;
} }
template <typename T> template <typename T>
static unsigned int wordOffsetToIndex (unsigned int offset, static unsigned int wordOffsetToIndex (unsigned int offset,
const void *base, const void *base HB_UNUSED,
const T *array) const T *array HB_UNUSED)
{ {
return offset; return offset;
} }
@@ -745,16 +747,13 @@ struct StateTableDriver
buffer->clear_output (); buffer->clear_output ();
int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT; int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT;
bool last_was_dont_advance = false;
for (buffer->idx = 0; buffer->successful;) for (buffer->idx = 0; buffer->successful;)
{ {
unsigned int klass = buffer->idx < buffer->len ? unsigned int klass = buffer->idx < buffer->len ?
machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) : machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
(unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT; (unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx); DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const Entry<EntryData> *entry = machine.get_entryZ (state, klass); const Entry<EntryData> &entry = machine.get_entry (state, klass);
if (unlikely (!entry))
break;
/* Unsafe-to-break before this if not in state 0, as things might /* Unsafe-to-break before this if not in state 0, as things might
* go differently if we start from state 0 here. * 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, /* If there's no action and we're just epsilon-transitioning to state 0,
* safe to break. */ * safe to break. */
if (c->is_actionable (this, entry) || if (c->is_actionable (this, entry) ||
!(entry->newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT && !(entry.newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
entry->flags == context_t::DontAdvance)) entry.flags == context_t::DontAdvance))
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1); buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
} }
/* Unsafe-to-break if end-of-text would kick in here. */ /* Unsafe-to-break if end-of-text would kick in here. */
if (buffer->idx + 2 <= buffer->len) if (buffer->idx + 2 <= buffer->len)
{ {
const Entry<EntryData> *end_entry = machine.get_entryZ (state, 0); const Entry<EntryData> &end_entry = machine.get_entry (state, StateTable<Types, EntryData>::CLASS_END_OF_TEXT);
if (c->is_actionable (this, end_entry)) if (c->is_actionable (this, end_entry))
buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); buffer->unsafe_to_break (buffer->idx, buffer->idx + 2);
} }
if (unlikely (!c->transition (this, entry))) c->transition (this, entry);
break;
last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops-- > 0; state = machine.new_state (entry.newState);
state = machine.new_state (entry->newState);
DEBUG_MSG (APPLY, nullptr, "s%d", state); DEBUG_MSG (APPLY, nullptr, "s%d", state);
if (buffer->idx == buffer->len) if (buffer->idx == buffer->len)
break; break;
if (!last_was_dont_advance) if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0)
buffer->next_glyph (); buffer->next_glyph ();
} }
@@ -825,7 +821,6 @@ struct hb_aat_apply_context_t :
hb_buffer_t *buffer; hb_buffer_t *buffer;
hb_sanitize_context_t sanitizer; hb_sanitize_context_t sanitizer;
const ankr *ankr_table; const ankr *ankr_table;
const char *ankr_end;
/* Unused. For debug tracing only. */ /* Unused. For debug tracing only. */
unsigned int lookup_index; unsigned int lookup_index;
@@ -838,7 +833,7 @@ struct hb_aat_apply_context_t :
HB_INTERNAL ~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; } void set_lookup_index (unsigned int i) { lookup_index = i; }
}; };

View File

@@ -118,11 +118,10 @@ struct FeatureName
if (selectors_count) if (selectors_count)
{ {
hb_array_t<const SettingName> arr = settings_table.sub_array (start_offset, selectors_count); hb_array_t<const SettingName> arr = settings_table.sub_array (start_offset, selectors_count);
unsigned int count = arr.len; for (unsigned int i = 0; i < arr.length; i++)
for (unsigned int i = 0; i < count; i++)
settings_table[start_offset + i].get_info (&selectors[i], default_selector); 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 hb_aat_layout_feature_type_t get_feature_type () const
@@ -155,7 +154,7 @@ struct FeatureName
struct feat 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 (); } bool has_data () const { return version.to_int (); }

View File

@@ -382,7 +382,7 @@ struct JustificationHeader
struct just 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 bool sanitize (hb_sanitize_context_t *c) const
{ {

View File

@@ -170,11 +170,11 @@ struct Format1Entry<true>
DEFINE_SIZE_STATIC (2); DEFINE_SIZE_STATIC (2);
}; };
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->data.kernActionIndex != 0xFFFF; } { return entry.data.kernActionIndex != 0xFFFF; }
static unsigned int kernActionIndex (const Entry<EntryData> *entry) static unsigned int kernActionIndex (const Entry<EntryData> &entry)
{ return entry->data.kernActionIndex; } { return entry.data.kernActionIndex; }
}; };
template <> template <>
struct Format1Entry<false> struct Format1Entry<false>
@@ -192,11 +192,11 @@ struct Format1Entry<false>
typedef void EntryData; typedef void EntryData;
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
static unsigned int kernActionIndex (const Entry<EntryData> *entry) static unsigned int kernActionIndex (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
}; };
template <typename KernSubTableHeader> template <typename KernSubTableHeader>
@@ -210,7 +210,7 @@ struct KerxSubTableFormat1
struct driver_context_t struct driver_context_t
{ {
enum { in_place = true }; static constexpr bool in_place = true;
enum enum
{ {
DontAdvance = Format1EntryT::DontAdvance, DontAdvance = Format1EntryT::DontAdvance,
@@ -228,15 +228,15 @@ struct KerxSubTableFormat1
crossStream (table->header.coverage & table->header.CrossStream) {} crossStream (table->header.coverage & table->header.CrossStream) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return Format1EntryT::performAction (entry); return Format1EntryT::performAction (entry);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
if (flags & Format1EntryT::Reset) if (flags & Format1EntryT::Reset)
depth = 0; depth = 0;
@@ -259,7 +259,7 @@ struct KerxSubTableFormat1
if (!c->sanitizer.check_array (actions, depth, tuple_count)) if (!c->sanitizer.check_array (actions, depth, tuple_count))
{ {
depth = 0; depth = 0;
return false; return;
} }
hb_mask_t kern_mask = c->plan->kern_mask; hb_mask_t kern_mask = c->plan->kern_mask;
@@ -334,8 +334,6 @@ struct KerxSubTableFormat1
} }
} }
} }
return true;
} }
private: private:
@@ -374,7 +372,7 @@ struct KerxSubTableFormat1
protected: protected:
KernSubTableHeader header; KernSubTableHeader header;
StateTable<Types, EntryData> machine; StateTable<Types, EntryData> machine;
OffsetTo<UnsizedArrayOf<FWORD>, HBUINT, false>kernAction; NNOffsetTo<UnsizedArrayOf<FWORD>, HBUINT> kernAction;
public: public:
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 5 * sizeof (HBUINT)); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 5 * sizeof (HBUINT));
}; };
@@ -443,13 +441,13 @@ struct KerxSubTableFormat2
protected: protected:
KernSubTableHeader header; KernSubTableHeader header;
HBUINT rowWidth; /* The width, in bytes, of a row in the table. */ HBUINT rowWidth; /* The width, in bytes, of a row in the table. */
OffsetTo<typename Types::ClassTypeWide, HBUINT, false> NNOffsetTo<typename Types::ClassTypeWide, HBUINT>
leftClassTable; /* Offset from beginning of this subtable to leftClassTable; /* Offset from beginning of this subtable to
* left-hand class table. */ * left-hand class table. */
OffsetTo<typename Types::ClassTypeWide, HBUINT, false> NNOffsetTo<typename Types::ClassTypeWide, HBUINT>
rightClassTable;/* Offset from beginning of this subtable to rightClassTable;/* Offset from beginning of this subtable to
* right-hand class table. */ * right-hand class table. */
OffsetTo<UnsizedArrayOf<FWORD>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<FWORD>, HBUINT>
array; /* Offset from beginning of this subtable to array; /* Offset from beginning of this subtable to
* the start of the kerning array. */ * the start of the kerning array. */
public: public:
@@ -471,7 +469,7 @@ struct KerxSubTableFormat4
struct driver_context_t struct driver_context_t
{ {
enum { in_place = true }; static constexpr bool in_place = true;
enum Flags enum Flags
{ {
Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */ Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */
@@ -498,16 +496,16 @@ struct KerxSubTableFormat4
mark (0) {} mark (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return entry->data.ankrActionIndex != 0xFFFF; return entry.data.ankrActionIndex != 0xFFFF;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; 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(); hb_glyph_position_t &o = buffer->cur_pos();
switch (action_type) switch (action_type)
@@ -515,9 +513,8 @@ struct KerxSubTableFormat4
case 0: /* Control Point Actions.*/ case 0: /* Control Point Actions.*/
{ {
/* indexed into glyph outline. */ /* indexed into glyph outline. */
const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 2)) if (!c->sanitizer.check_array (data, 2)) return;
return false;
HB_UNUSED unsigned int markControlPoint = *data++; HB_UNUSED unsigned int markControlPoint = *data++;
HB_UNUSED unsigned int currControlPoint = *data++; HB_UNUSED unsigned int currControlPoint = *data++;
hb_position_t markX = 0; hb_position_t markX = 0;
@@ -532,7 +529,7 @@ struct KerxSubTableFormat4
currControlPoint, currControlPoint,
HB_DIRECTION_LTR /*XXX*/, HB_DIRECTION_LTR /*XXX*/,
&currX, &currY)) &currX, &currY))
return true; /* True, such that the machine continues. */ return;
o.x_offset = markX - currX; o.x_offset = markX - currX;
o.y_offset = markY - currY; o.y_offset = markY - currY;
@@ -542,19 +539,16 @@ struct KerxSubTableFormat4
case 1: /* Anchor Point Actions. */ case 1: /* Anchor Point Actions. */
{ {
/* Indexed into 'ankr' table. */ /* Indexed into 'ankr' table. */
const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 2)) if (!c->sanitizer.check_array (data, 2)) return;
return false;
unsigned int markAnchorPoint = *data++; unsigned int markAnchorPoint = *data++;
unsigned int currAnchorPoint = *data++; unsigned int currAnchorPoint = *data++;
const Anchor markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint, const Anchor &markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint,
markAnchorPoint, markAnchorPoint,
c->sanitizer.get_num_glyphs (), c->sanitizer.get_num_glyphs ());
c->ankr_end); const Anchor &currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint,
const Anchor currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint, currAnchorPoint,
currAnchorPoint, c->sanitizer.get_num_glyphs ());
c->sanitizer.get_num_glyphs (),
c->ankr_end);
o.x_offset = c->font->em_scale_x (markAnchor.xCoordinate) - c->font->em_scale_x (currAnchor.xCoordinate); o.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); 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. */ case 2: /* Control Point Coordinate Actions. */
{ {
const FWORD *data = (const FWORD *) &ankrData[entry->data.ankrActionIndex]; const FWORD *data = (const FWORD *) &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 4)) if (!c->sanitizer.check_array (data, 4)) return;
return false;
int markX = *data++; int markX = *data++;
int markY = *data++; int markY = *data++;
int currX = *data++; int currX = *data++;
@@ -581,13 +574,11 @@ struct KerxSubTableFormat4
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT; buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
} }
if (entry->flags & Mark) if (entry.flags & Mark)
{ {
mark_set = true; mark_set = true;
mark = buffer->idx; mark = buffer->idx;
} }
return true;
} }
private: private:
@@ -721,18 +712,18 @@ struct KerxSubTableFormat6
{ {
struct Long struct Long
{ {
LOffsetTo<Lookup<HBUINT32>, false> rowIndexTable; LNNOffsetTo<Lookup<HBUINT32> > rowIndexTable;
LOffsetTo<Lookup<HBUINT32>, false> columnIndexTable; LNNOffsetTo<Lookup<HBUINT32> > columnIndexTable;
LOffsetTo<UnsizedArrayOf<FWORD32>, false> array; LNNOffsetTo<UnsizedArrayOf<FWORD32> > array;
} l; } l;
struct Short struct Short
{ {
LOffsetTo<Lookup<HBUINT16>, false> rowIndexTable; LNNOffsetTo<Lookup<HBUINT16> > rowIndexTable;
LOffsetTo<Lookup<HBUINT16>, false> columnIndexTable; LNNOffsetTo<Lookup<HBUINT16> > columnIndexTable;
LOffsetTo<UnsizedArrayOf<FWORD>, false> array; LNNOffsetTo<UnsizedArrayOf<FWORD> > array;
} s; } s;
} u; } u;
LOffsetTo<UnsizedArrayOf<FWORD>, false> vector; LNNOffsetTo<UnsizedArrayOf<FWORD> > vector;
public: public:
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24); DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24);
}; };
@@ -981,8 +972,8 @@ struct kerx : KerxTable<kerx>
{ {
friend struct KerxTable<kerx>; friend struct KerxTable<kerx>;
enum { tableTag = HB_AAT_TAG_kerx }; static constexpr hb_tag_t tableTag = HB_AAT_TAG_kerx;
enum { minVersion = 2u }; static constexpr unsigned minVersion = 2u;
typedef KerxSubTableHeader SubTableHeader; typedef KerxSubTableHeader SubTableHeader;
typedef SubTableHeader::Types Types; typedef SubTableHeader::Types Types;

View File

@@ -40,7 +40,7 @@ typedef ArrayOf<HBINT16> LigCaretClassEntry;
struct lcar 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, unsigned int get_lig_carets (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
@@ -55,7 +55,7 @@ struct lcar
if (caret_count) if (caret_count)
{ {
hb_array_t<const HBINT16> arr = array.sub_array (start_offset, caret_count); hb_array_t<const HBINT16> 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) for (unsigned int i = 0; i < count; ++i)
switch (format) switch (format)
{ {

View File

@@ -54,7 +54,7 @@ struct RearrangementSubtable
struct driver_context_t struct driver_context_t
{ {
enum { in_place = true }; static constexpr bool in_place = true;
enum Flags enum Flags
{ {
MarkFirst = 0x8000, /* If set, make the current glyph the first MarkFirst = 0x8000, /* If set, make the current glyph the first
@@ -74,15 +74,15 @@ struct RearrangementSubtable
start (0), end (0) {} start (0), end (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return (entry->flags & Verb) && start < end; return (entry.flags & Verb) && start < end;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
if (flags & MarkFirst) if (flags & MarkFirst)
start = buffer->idx; start = buffer->idx;
@@ -152,8 +152,6 @@ struct RearrangementSubtable
} }
} }
} }
return true;
} }
public: public:
@@ -204,7 +202,7 @@ struct ContextualSubtable
struct driver_context_t struct driver_context_t
{ {
enum { in_place = true }; static constexpr bool in_place = true;
enum Flags enum Flags
{ {
SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */
@@ -223,39 +221,39 @@ struct ContextualSubtable
subs (table+table->substitutionTables) {} subs (table+table->substitutionTables) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver, bool is_actionable (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
if (buffer->idx == buffer->len && !mark_set) if (buffer->idx == buffer->len && !mark_set)
return false; return false;
return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF; return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
/* Looks like CoreText applies neither mark nor current substitution for /* Looks like CoreText applies neither mark nor current substitution for
* end-of-text if mark was not explicitly set. */ * end-of-text if mark was not explicitly set. */
if (buffer->idx == buffer->len && !mark_set) if (buffer->idx == buffer->len && !mark_set)
return true; return;
const GlyphID *replacement; const GlyphID *replacement;
replacement = nullptr; replacement = nullptr;
if (Types::extended) if (Types::extended)
{ {
if (entry->data.markIndex != 0xFFFF) if (entry.data.markIndex != 0xFFFF)
{ {
const Lookup<GlyphID> &lookup = subs[entry->data.markIndex]; const Lookup<GlyphID> &lookup = subs[entry.data.markIndex];
replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs); replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs);
} }
} }
else else
{ {
unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint; unsigned int offset = entry.data.markIndex + buffer->info[mark].codepoint;
const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
if (!replacement->sanitize (&c->sanitizer) || !*replacement) if (!replacement->sanitize (&c->sanitizer) || !*replacement)
@@ -272,15 +270,15 @@ struct ContextualSubtable
unsigned int idx = MIN (buffer->idx, buffer->len - 1); unsigned int idx = MIN (buffer->idx, buffer->len - 1);
if (Types::extended) if (Types::extended)
{ {
if (entry->data.currentIndex != 0xFFFF) if (entry.data.currentIndex != 0xFFFF)
{ {
const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex]; const Lookup<GlyphID> &lookup = subs[entry.data.currentIndex];
replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs); replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs);
} }
} }
else else
{ {
unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint; unsigned int offset = entry.data.currentIndex + buffer->info[idx].codepoint;
const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
if (!replacement->sanitize (&c->sanitizer) || !*replacement) if (!replacement->sanitize (&c->sanitizer) || !*replacement)
@@ -292,13 +290,11 @@ struct ContextualSubtable
ret = true; ret = true;
} }
if (entry->flags & SetMark) if (entry.flags & SetMark)
{ {
mark_set = true; mark_set = true;
mark = buffer->idx; mark = buffer->idx;
} }
return true;
} }
public: public:
@@ -330,7 +326,8 @@ struct ContextualSubtable
unsigned int num_entries = 0; unsigned int num_entries = 0;
if (unlikely (!machine.sanitize (c, &num_entries))) return_trace (false); 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; unsigned int num_lookups = 0;
@@ -351,7 +348,7 @@ struct ContextualSubtable
protected: protected:
StateTable<Types, EntryData> StateTable<Types, EntryData>
machine; machine;
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false>, HBUINT, false> NNOffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT, false>, HBUINT>
substitutionTables; substitutionTables;
public: public:
DEFINE_SIZE_STATIC (20); DEFINE_SIZE_STATIC (20);
@@ -384,11 +381,11 @@ struct LigatureEntry<true>
DEFINE_SIZE_STATIC (2); DEFINE_SIZE_STATIC (2);
}; };
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & PerformAction; } { return entry.flags & PerformAction; }
static unsigned int ligActionIndex (const Entry<EntryData> *entry) static unsigned int ligActionIndex (const Entry<EntryData> &entry)
{ return entry->data.ligActionIndex; } { return entry.data.ligActionIndex; }
}; };
template <> template <>
struct LigatureEntry<false> struct LigatureEntry<false>
@@ -406,11 +403,11 @@ struct LigatureEntry<false>
typedef void EntryData; typedef void EntryData;
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
static unsigned int ligActionIndex (const Entry<EntryData> *entry) static unsigned int ligActionIndex (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
}; };
@@ -424,7 +421,7 @@ struct LigatureSubtable
struct driver_context_t struct driver_context_t
{ {
enum { in_place = false }; static constexpr bool in_place = false;
enum enum
{ {
DontAdvance = LigatureEntryT::DontAdvance, DontAdvance = LigatureEntryT::DontAdvance,
@@ -452,26 +449,23 @@ struct LigatureSubtable
match_length (0) {} match_length (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return LigatureEntryT::performAction (entry); return LigatureEntryT::performAction (entry);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
DEBUG_MSG (APPLY, nullptr, "Ligature transition at %u", buffer->idx); 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... */ /* 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_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); DEBUG_MSG (APPLY, nullptr, "Set component at %u", buffer->out_len);
} }
@@ -481,10 +475,10 @@ struct LigatureSubtable
unsigned int end = buffer->out_len; unsigned int end = buffer->out_len;
if (unlikely (!match_length)) if (unlikely (!match_length))
return true; return;
if (buffer->idx >= buffer->len) if (buffer->idx >= buffer->len)
return false; // TODO Work on previous instead? return; /* TODO Work on previous instead? */
unsigned int cursor = match_length; unsigned int cursor = match_length;
@@ -505,9 +499,9 @@ struct LigatureSubtable
} }
DEBUG_MSG (APPLY, nullptr, "Moving to stack position %u", cursor - 1); 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; action = *actionData;
uint32_t uoffset = action & LigActionOffset; uint32_t uoffset = action & LigActionOffset;
@@ -517,7 +511,7 @@ struct LigatureSubtable
unsigned int component_idx = buffer->cur().codepoint + offset; unsigned int component_idx = buffer->cur().codepoint + offset;
component_idx = Types::wordOffsetToIndex (component_idx, table, component.arrayZ); component_idx = Types::wordOffsetToIndex (component_idx, table, component.arrayZ);
const HBUINT16 &componentData = component[component_idx]; const HBUINT16 &componentData = component[component_idx];
if (unlikely (!componentData.sanitize (&c->sanitizer))) return false; if (unlikely (!componentData.sanitize (&c->sanitizer))) break;
ligature_idx += componentData; ligature_idx += componentData;
DEBUG_MSG (APPLY, nullptr, "Action store %u last %u", DEBUG_MSG (APPLY, nullptr, "Action store %u last %u",
@@ -527,23 +521,23 @@ struct LigatureSubtable
{ {
ligature_idx = Types::offsetToIndex (ligature_idx, table, ligature.arrayZ); ligature_idx = Types::offsetToIndex (ligature_idx, table, ligature.arrayZ);
const GlyphID &ligatureData = ligature[ligature_idx]; 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; hb_codepoint_t lig = ligatureData;
DEBUG_MSG (APPLY, nullptr, "Produced ligature %u", lig); DEBUG_MSG (APPLY, nullptr, "Produced ligature %u", lig);
buffer->replace_glyph (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. */ /* Now go and delete all subsequent components. */
while (match_length - 1 > cursor) while (match_length - 1u > cursor)
{ {
DEBUG_MSG (APPLY, nullptr, "Skipping ligature component"); 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->replace_glyph (DELETED_GLYPH);
} }
buffer->move_to (lig_end); 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++; actionData++;
@@ -551,8 +545,6 @@ struct LigatureSubtable
while (!(action & LigActionLast)); while (!(action & LigActionLast));
buffer->move_to (end); buffer->move_to (end);
} }
return true;
} }
public: public:
@@ -590,11 +582,11 @@ struct LigatureSubtable
protected: protected:
StateTable<Types, EntryData> StateTable<Types, EntryData>
machine; machine;
OffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT>
ligAction; /* Offset to the ligature action table. */ ligAction; /* Offset to the ligature action table. */
OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT>
component; /* Offset to the component table. */ component; /* Offset to the component table. */
OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<GlyphID>, HBUINT>
ligature; /* Offset to the actual ligature lists. */ ligature; /* Offset to the actual ligature lists. */
public: public:
DEFINE_SIZE_STATIC (28); DEFINE_SIZE_STATIC (28);
@@ -660,7 +652,7 @@ struct InsertionSubtable
struct driver_context_t struct driver_context_t
{ {
enum { in_place = false }; static constexpr bool in_place = false;
enum Flags enum Flags
{ {
SetMark = 0x8000, /* If set, mark the current glyph. */ SetMark = 0x8000, /* If set, mark the current glyph. */
@@ -713,28 +705,29 @@ struct InsertionSubtable
hb_aat_apply_context_t *c_) : hb_aat_apply_context_t *c_) :
ret (false), ret (false),
c (c_), c (c_),
mark_set (false),
mark (0), mark (0),
insertionAction (table+table->insertionAction) {} insertionAction (table+table->insertionAction) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return (entry->flags & (CurrentInsertCount | MarkedInsertCount)) && return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) &&
(entry->data.currentInsertIndex != 0xFFFF ||entry->data.markedInsertIndex != 0xFFFF); (entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, void transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
if (entry->data.markedInsertIndex != 0xFFFF && mark_set) unsigned mark_loc = buffer->out_len;
if (entry.data.markedInsertIndex != 0xFFFF)
{ {
unsigned int count = (flags & MarkedInsertCount); unsigned int count = (flags & MarkedInsertCount);
unsigned int start = entry->data.markedInsertIndex; unsigned int start = entry.data.markedInsertIndex;
const GlyphID *glyphs = &insertionAction[start]; 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; bool before = flags & MarkedInsertBefore;
@@ -754,12 +747,15 @@ struct InsertionSubtable
buffer->unsafe_to_break_from_outbuffer (mark, MIN (buffer->idx + 1, buffer->len)); 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 count = (flags & CurrentInsertCount) >> 5;
unsigned int start = entry->data.currentInsertIndex; unsigned int start = entry.data.currentInsertIndex;
const GlyphID *glyphs = &insertionAction[start]; 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; bool before = flags & CurrentInsertBefore;
@@ -790,21 +786,12 @@ struct InsertionSubtable
*/ */
buffer->move_to ((flags & DontAdvance) ? end : end + count); buffer->move_to ((flags & DontAdvance) ? end : end + count);
} }
if (flags & SetMark)
{
mark_set = true;
mark = buffer->out_len;
}
return true;
} }
public: public:
bool ret; bool ret;
private: private:
hb_aat_apply_context_t *c; hb_aat_apply_context_t *c;
bool mark_set;
unsigned int mark; unsigned int mark;
const UnsizedArrayOf<GlyphID> &insertionAction; const UnsizedArrayOf<GlyphID> &insertionAction;
}; };
@@ -832,7 +819,7 @@ struct InsertionSubtable
protected: protected:
StateTable<Types, EntryData> StateTable<Types, EntryData>
machine; machine;
OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT, false> NNOffsetTo<UnsizedArrayOf<GlyphID>, HBUINT>
insertionAction; /* Byte offset from stateHeader to the start of insertionAction; /* Byte offset from stateHeader to the start of
* the insertion glyph table. */ * the insertion glyph table. */
public: 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_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; hb_aat_layout_feature_selector_t setting = (hb_aat_layout_feature_selector_t) (unsigned int) feature.featureSetting;
retry: 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) if (info && info->setting == setting)
{ {
flags &= feature.disableFlags; flags &= feature.disableFlags;
@@ -1096,7 +1083,7 @@ struct Chain
template <typename Types> template <typename Types>
struct mortmorx 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; } bool has_data () const { return version != 0; }
@@ -1158,11 +1145,11 @@ struct mortmorx
struct morx : mortmorx<ExtendedTypes> struct morx : mortmorx<ExtendedTypes>
{ {
enum { tableTag = HB_AAT_TAG_morx }; static constexpr hb_tag_t tableTag = HB_AAT_TAG_morx;
}; };
struct mort : mortmorx<ObsoleteTypes> struct mort : mortmorx<ObsoleteTypes>
{ {
enum { tableTag = HB_AAT_TAG_mort }; static constexpr hb_tag_t tableTag = HB_AAT_TAG_mort;
}; };

View File

@@ -66,7 +66,7 @@ struct TrackTableEntry
NameID trackNameID; /* The 'name' table index for this track. NameID trackNameID; /* The 'name' table index for this track.
* (a short word or phrase like "loose" * (a short word or phrase like "loose"
* or "very tight") */ * or "very tight") */
OffsetTo<UnsizedArrayOf<FWORD>, HBUINT16, false> NNOffsetTo<UnsizedArrayOf<FWORD> >
valuesZ; /* Offset from start of tracking table to valuesZ; /* Offset from start of tracking table to
* per-size tracking values for this track. */ * per-size tracking values for this track. */
@@ -160,7 +160,7 @@ struct TrackData
struct trak 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 (); } bool has_data () const { return version.to_int (); }

View File

@@ -157,7 +157,6 @@ AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *p
buffer (buffer_), buffer (buffer_),
sanitizer (), sanitizer (),
ankr_table (&Null(AAT::ankr)), ankr_table (&Null(AAT::ankr)),
ankr_end (nullptr),
lookup_index (0), lookup_index (0),
debug_depth (0) debug_depth (0)
{ {
@@ -171,12 +170,8 @@ AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t ()
{ sanitizer.end_processing (); } { sanitizer.end_processing (); }
void void
AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_, AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_)
const char *ankr_end_) { ankr_table = ankr_table_; }
{
ankr_table = ankr_table_;
ankr_end = ankr_end_;
}
/* /*
@@ -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 (); hb_blob_t *kerx_blob = font->face->table.kerx.get_blob ();
const AAT::kerx& kerx = *kerx_blob->as<AAT::kerx> (); const AAT::kerx& kerx = *kerx_blob->as<AAT::kerx> ();
hb_blob_t *ankr_blob = font->face->table.ankr.get_blob ();;
const AAT::ankr& ankr = *font->face->table.ankr;
AAT::hb_aat_apply_context_t c (plan, font, buffer, kerx_blob); 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); kerx.apply (&c);
} }

View File

@@ -50,7 +50,7 @@ struct FTStringRange
} }
protected: protected:
OffsetTo<UnsizedArrayOf<HBUINT8>, HBUINT16, false> NNOffsetTo<UnsizedArrayOf<HBUINT8> >
tag; /* Offset from the start of the table to tag; /* Offset from the start of the table to
* the beginning of the string */ * the beginning of the string */
HBUINT16 length; /* String length (in bytes) */ HBUINT16 length; /* String length (in bytes) */
@@ -60,7 +60,7 @@ struct FTStringRange
struct ltag 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 hb_language_t get_language (unsigned int i) const
{ {

View File

@@ -54,11 +54,11 @@ void
hb_aat_map_builder_t::compile (hb_aat_map_t &m) hb_aat_map_builder_t::compile (hb_aat_map_t &m)
{ {
/* Sort features and merge duplicates */ /* Sort features and merge duplicates */
if (features.len) if (features.length)
{ {
features.qsort (); features.qsort ();
unsigned int j = 0; 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) if (features[i].type != features[j].type)
features[++j] = features[i]; features[++j] = features[i];
features.shrink (j + 1); features.shrink (j + 1);

View File

@@ -44,7 +44,7 @@ struct hb_aat_map_t
void fini () { chain_flags.fini (); } void fini () { chain_flags.fini (); }
public: public:
hb_vector_t<hb_mask_t, 1> chain_flags; hb_vector_t<hb_mask_t> chain_flags;
}; };
struct hb_aat_map_builder_t 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); (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; return (type != ty) ? (type < ty ? -1 : 1) : 0;
} }
@@ -84,7 +84,7 @@ struct hb_aat_map_builder_t
hb_face_t *face; hb_face_t *face;
public: public:
hb_vector_t<feature_info_t, 32> features; hb_vector_t<feature_info_t> features;
}; };

View File

@@ -28,68 +28,58 @@
#define HB_ARRAY_HH #define HB_ARRAY_HH
#include "hb.hh" #include "hb.hh"
#include "hb-dsalgs.hh"
#include "hb-iter.hh"
#include "hb-null.hh"
template <typename Type> template <typename Type>
struct hb_sorted_array_t; struct hb_sorted_array_t;
template <typename Type> template <typename Type>
struct hb_array_t struct hb_array_t :
hb_iter_t<hb_array_t<Type>, Type>,
hb_iter_mixin_t<hb_array_t<Type>, Type>
{ {
typedef Type ItemType;
enum { item_size = hb_static_size (Type) };
/* /*
* Constructors. * Constructors.
*/ */
hb_array_t () : arrayZ (nullptr), len (0) {} hb_array_t () : arrayZ (nullptr), length (0) {}
hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), len (o.len) {} hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} template <unsigned int length_> hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {}
template <unsigned int len_> hb_array_t (Type (&array_)[len_]) : arrayZ (array_), len (len_) {}
/* /*
* Operators. * Iterator implementation.
*/ */
typedef Type __item_type__;
Type& operator [] (int i_) const Type& __item_at__ (unsigned i) const
{ {
unsigned int i = (unsigned int) i_; if (unlikely (i >= length)) return CrapOrNull (Type);
if (unlikely (i >= len)) return CrapOrNull(Type);
return arrayZ[i]; return arrayZ[i];
} }
void __forward__ (unsigned n)
{
if (unlikely (n > length))
n = length;
length -= n;
arrayZ += n;
}
void __rewind__ (unsigned n)
{
if (unlikely (n > length))
n = length;
length -= n;
}
unsigned __len__ () const { return length; }
bool __random_access__ () const { return true; }
explicit_operator bool () const { return len; } /* Extra operators.
*/
Type * operator & () const { return arrayZ; } Type * operator & () const { return arrayZ; }
Type & operator * () { return (this->operator [])[0]; } operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, length); }
operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, len); }
template <typename T> operator T * () const { return arrayZ; } template <typename T> operator T * () const { return arrayZ; }
hb_array_t<Type> & operator += (unsigned int count)
{
if (unlikely (count > len))
count = len;
len -= count;
arrayZ += count;
return *this;
}
hb_array_t<Type> & operator -= (unsigned int count)
{
if (unlikely (count > len))
count = len;
len -= count;
return *this;
}
hb_array_t<Type> & operator ++ () { *this += 1; }
hb_array_t<Type> & operator -- () { *this -= 1; }
hb_array_t<Type> operator + (unsigned int count)
{ hb_array_t<Type> copy (*this); *this += count; return copy; }
hb_array_t<Type> operator - (unsigned int count)
{ hb_array_t<Type> copy (*this); *this -= count; return copy; }
hb_array_t<Type> operator ++ (int)
{ hb_array_t<Type> copy (*this); ++*this; return copy; }
hb_array_t<Type> operator -- (int)
{ hb_array_t<Type> copy (*this); --*this; return copy; }
/* /*
* Compare, Sort, and Search. * 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. */ /* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */
int cmp (const hb_array_t<Type> &a) const int cmp (const hb_array_t<Type> &a) const
{ {
if (len != a.len) if (length != a.length)
return (int) a.len - (int) len; return (int) a.length - (int) length;
return hb_memcmp (a.arrayZ, arrayZ, get_size ()); return hb_memcmp (a.arrayZ, arrayZ, get_size ());
} }
static int cmp (const void *pa, const void *pb) static int cmp (const void *pa, const void *pb)
@@ -111,7 +101,7 @@ struct hb_array_t
template <typename T> template <typename T>
Type *lsearch (const T &x, Type *not_found = nullptr) 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++) for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x)) if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i]; return &this->arrayZ[i];
@@ -120,7 +110,7 @@ struct hb_array_t
template <typename T> template <typename T>
const Type *lsearch (const T &x, const Type *not_found = nullptr) const 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++) for (unsigned int i = 0; i < count; i++)
if (!this->arrayZ[i].cmp (x)) if (!this->arrayZ[i].cmp (x))
return &this->arrayZ[i]; return &this->arrayZ[i];
@@ -129,33 +119,36 @@ struct hb_array_t
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*)) hb_sorted_array_t<Type> 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<Type> (*this); return hb_sorted_array_t<Type> (*this);
} }
hb_sorted_array_t<Type> qsort () hb_sorted_array_t<Type> qsort ()
{ {
::qsort (arrayZ, len, item_size, Type::cmp); if (likely (length))
::qsort (arrayZ, length, this->item_size, Type::cmp);
return hb_sorted_array_t<Type> (*this); return hb_sorted_array_t<Type> (*this);
} }
void qsort (unsigned int start, unsigned int end) void qsort (unsigned int start, unsigned int end)
{ {
end = MIN (end, len); end = MIN (end, length);
assert (start <= end); 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. * Other methods.
*/ */
unsigned int get_size () const { return len * item_size; } unsigned int get_size () const { return length * this->item_size; }
hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const hb_array_t<Type> sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const
{ {
if (!start_offset && !seg_count) if (!start_offset && !seg_count)
return *this; return *this;
unsigned int count = len; unsigned int count = length;
if (unlikely (start_offset > count)) if (unlikely (start_offset > count))
count = 0; count = 0;
else else
@@ -169,11 +162,11 @@ struct hb_array_t
/* Only call if you allocated the underlying array using malloc() or similar. */ /* Only call if you allocated the underlying array using malloc() or similar. */
void free () void free ()
{ ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } { ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; }
template <typename hb_sanitize_context_t> template <typename hb_sanitize_context_t>
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
{ return c->check_array (arrayZ, len); } { return c->check_array (arrayZ, length); }
/* /*
* Members * Members
@@ -181,11 +174,14 @@ struct hb_array_t
public: public:
Type *arrayZ; Type *arrayZ;
unsigned int len; unsigned int length;
}; };
template <typename T> template <typename T> inline hb_array_t<T>
inline hb_array_t<T> hb_array (T *array, unsigned int len) hb_array (T *array, unsigned int length)
{ return hb_array_t<T> (array, len); } { return hb_array_t<T> (array, length); }
template <typename T, unsigned int length_> inline hb_array_t<T>
hb_array (T (&array_)[length_])
{ return hb_array_t<T> (array_); }
enum hb_bfind_not_found_t enum hb_bfind_not_found_t
@@ -196,11 +192,15 @@ enum hb_bfind_not_found_t
}; };
template <typename Type> template <typename Type>
struct hb_sorted_array_t : hb_array_t<Type> struct hb_sorted_array_t :
hb_sorted_iter_t<hb_sorted_array_t<Type>, Type>,
hb_array_t<Type>,
hb_iter_mixin_t<hb_sorted_array_t<Type>, Type>
{ {
hb_sorted_array_t () : hb_array_t<Type> () {} hb_sorted_array_t () : hb_array_t<Type> () {}
hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {} hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
hb_sorted_array_t (Type *array_, unsigned int len_) : hb_array_t<Type> (array_, len_) {} hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
template <unsigned int length_> hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const hb_sorted_array_t<Type> sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
{ return hb_sorted_array_t<Type> (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); } { return hb_sorted_array_t<Type> (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); }
@@ -224,7 +224,7 @@ struct hb_sorted_array_t : hb_array_t<Type>
hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE, hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
unsigned int to_store = (unsigned int) -1) const 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; const Type *array = this->arrayZ;
while (min <= max) while (min <= max)
{ {
@@ -253,7 +253,7 @@ struct hb_sorted_array_t : hb_array_t<Type>
break; break;
case HB_BFIND_NOT_FOUND_STORE_CLOSEST: 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++; max++;
*i = max; *i = max;
break; break;
@@ -262,9 +262,12 @@ struct hb_sorted_array_t : hb_array_t<Type>
return false; return false;
} }
}; };
template <typename T> template <typename T> inline hb_sorted_array_t<T>
inline hb_sorted_array_t<T> hb_sorted_array (T *array, unsigned int len) hb_sorted_array (T *array, unsigned int length)
{ return hb_sorted_array_t<T> (array, len); } { return hb_sorted_array_t<T> (array, length); }
template <typename T, unsigned int length_> inline hb_sorted_array_t<T>
hb_sorted_array (T (&array_)[length_])
{ return hb_sorted_array_t<T> (array_); }
typedef hb_array_t<const char> hb_bytes_t; typedef hb_array_t<const char> hb_bytes_t;

View File

@@ -25,6 +25,18 @@
* Red Hat Author(s): Behdad Esfahbod * 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.hh"
#include "hb-blob.hh" #include "hb-blob.hh"

View File

@@ -119,7 +119,7 @@ struct hb_buffer_t
/* Text before / after the main buffer contents. /* Text before / after the main buffer contents.
* Always in Unicode, and ordered outward. * Always in Unicode, and ordered outward.
* Index 0 is for "pre-context", 1 for "post-context". */ * 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]; hb_codepoint_t context[2][CONTEXT_LENGTH];
unsigned int context_len[2]; unsigned int context_len[2];

View File

@@ -30,7 +30,7 @@ namespace CFF {
using namespace OT; using namespace OT;
typedef unsigned int OpCode; typedef unsigned int op_code_t;
/* === Dict operators === */ /* === Dict operators === */
@@ -88,11 +88,11 @@ typedef unsigned int OpCode;
/* Two byte escape operators 12, (0-41) */ /* Two byte escape operators 12, (0-41) */
#define OpCode_ESC_Base 256 #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 op_code_t Unmake_OpCode_ESC (op_code_t op) { return (op_code_t)(op - OpCode_ESC_Base); }
inline bool Is_OpCode_ESC (OpCode op) { return op >= OpCode_ESC_Base; } inline bool Is_OpCode_ESC (op_code_t op) { return op >= OpCode_ESC_Base; }
inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1; } 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_Copyright Make_OpCode_ESC(0) /* CFF Top */
#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */ #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 #define OpCode_Invalid 0xFFFFu
struct Number struct number_t
{ {
void init () { set_real (0.0); } void init () { set_real (0.0); }
void fini () {} void fini () {}
@@ -235,19 +235,19 @@ struct Number
bool in_int_range () const bool in_int_range () const
{ return ((double) (int16_t) to_int () == value); } { 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 (); } { return value > n.to_real (); }
bool operator < (const Number &n) const bool operator < (const number_t &n) const
{ return n > *this; } { return n > *this; }
bool operator >= (const Number &n) const bool operator >= (const number_t &n) const
{ return !(*this < n); } { return !(*this < n); }
bool operator <= (const Number &n) const bool operator <= (const number_t &n) const
{ return !(*this > n); } { return !(*this > n); }
const Number &operator += (const Number &n) const number_t &operator += (const number_t &n)
{ {
set_real (to_real () + n.to_real ()); set_real (to_real () + n.to_real ());
@@ -263,7 +263,7 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
{ {
// encode 2-byte int (Dict/CharString) or 4-byte int (Dict) // encode 2-byte int (Dict/CharString) or 4-byte int (Dict)
template <typename INTTYPE, int minVal, int maxVal> template <typename INTTYPE, int minVal, int maxVal>
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); TRACE_SERIALIZE (this);
@@ -290,92 +290,73 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
/* Defining null_size allows a Null object may be created. Should be safe because: /* 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, * A descendent struct Dict uses a Null pointer to indicate a missing table,
* checked before access. * 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 * checks the length before access. A Null pointer is used as the initial pointer
* along with zero length by the default ctor. * along with zero length by the default ctor.
*/ */
DEFINE_SIZE_MIN(0); 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 () byte_str_t ()
: str (&Null(UnsizedByteStr)), len (0) {} : hb_ubytes_t () {}
ByteStr (const UnsizedByteStr& s, unsigned int l) byte_str_t (const UnsizedByteStr& s, unsigned int l)
: str (&s), len (l) {} : hb_ubytes_t ((const unsigned char*)&s, l) {}
ByteStr (const char *s, unsigned int l=0) byte_str_t (const unsigned char *s, unsigned int l)
: str ((const UnsizedByteStr *)s), len (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 */ /* sub-string */
ByteStr (const ByteStr &bs, unsigned int offset, unsigned int len_) byte_str_t sub_str (unsigned int offset, unsigned int len_) const
{ { return byte_str_t (hb_ubytes_t::sub_array (offset, len_)); }
str = (const UnsizedByteStr *)&bs.str[offset];
len = len_;
}
bool sanitize (hb_sanitize_context_t *c) const { return str->sanitize (c, len); }
const HBUINT8& operator [] (unsigned int i) const
{
if (likely (str && (i < len)))
return (*str)[i];
else
return Null(HBUINT8);
}
bool serialize (hb_serialize_context_t *c, const ByteStr &src)
{
TRACE_SERIALIZE (this);
HBUINT8 *dest = c->allocate_size<HBUINT8> (src.len);
if (unlikely (dest == nullptr))
return_trace (false);
memcpy (dest, src.str, src.len);
return_trace (true);
}
unsigned int get_size () const { return len; }
bool check_limit (unsigned int offset, unsigned int count) const bool check_limit (unsigned int offset, unsigned int count) const
{ return (offset + count <= len); } { return (offset + count <= length); }
const UnsizedByteStr *str;
unsigned int len;
}; };
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 (); } { init (); }
void init () void init ()
{ {
str = ByteStr (0); str = byte_str_t ();
offset = 0; offset = 0;
error = false; error = false;
} }
void fini () {} 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) {} : 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_; str = str_;
offset = offset_; offset = offset_;
error = false; error = false;
} }
const HBUINT8& operator [] (int i) { const unsigned char& operator [] (int i) {
if (unlikely ((unsigned int)(offset + i) >= str.len)) if (unlikely ((unsigned int)(offset + i) >= str.length))
{ {
set_error (); set_error ();
return Null(HBUINT8); return Null(unsigned char);
} }
else else
return str[offset + i]; 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 bool avail (unsigned int count=1) const
{ {
@@ -383,13 +364,13 @@ struct SubByteStr
} }
void inc (unsigned int count=1) 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; offset += count;
} }
else else
{ {
offset = str.len; offset = str.length;
set_error (); set_error ();
} }
} }
@@ -397,18 +378,18 @@ struct SubByteStr
void set_error () { error = true; } void set_error () { error = true; }
bool in_error () const { return error; } bool in_error () const { return error; }
ByteStr str; byte_str_t str;
unsigned int offset; /* beginning of the sub-string within str */ unsigned int offset; /* beginning of the sub-string within str */
protected: protected:
bool error; bool error;
}; };
typedef hb_vector_t<ByteStr> ByteStrArray; typedef hb_vector_t<byte_str_t> byte_str_array_t;
/* stack */ /* stack */
template <typename ELEM, int LIMIT> template <typename ELEM, int LIMIT>
struct Stack struct stack_t
{ {
void init () void init ()
{ {
@@ -416,7 +397,7 @@ struct Stack
count = 0; count = 0;
elements.init (); elements.init ();
elements.resize (kSizeLimit); elements.resize (kSizeLimit);
for (unsigned int i = 0; i < elements.len; i++) for (unsigned int i = 0; i < elements.length; i++)
elements[i].init (); elements[i].init ();
} }
@@ -433,7 +414,7 @@ struct Stack
void push (const ELEM &v) void push (const ELEM &v)
{ {
if (likely (count < elements.len)) if (likely (count < elements.length))
elements[count++] = v; elements[count++] = v;
else else
set_error (); set_error ();
@@ -441,7 +422,7 @@ struct Stack
ELEM &push () ELEM &push ()
{ {
if (likely (count < elements.len)) if (likely (count < elements.length))
return elements[count++]; return elements[count++];
else else
{ {
@@ -482,7 +463,7 @@ struct Stack
void unpop () void unpop ()
{ {
if (likely (count < elements.len)) if (likely (count < elements.length))
count++; count++;
else else
set_error (); set_error ();
@@ -496,17 +477,17 @@ struct Stack
unsigned int get_count () const { return count; } unsigned int get_count () const { return count; }
bool is_empty () const { return count == 0; } bool is_empty () const { return count == 0; }
static const unsigned int kSizeLimit = LIMIT; static constexpr unsigned kSizeLimit = LIMIT;
protected: protected:
bool error; bool error;
unsigned int count; unsigned int count;
hb_vector_t<ELEM, kSizeLimit> elements; hb_vector_t<ELEM> elements;
}; };
/* argument stack */ /* argument stack */
template <typename ARG=Number> template <typename ARG=number_t>
struct ArgStack : Stack<ARG, 513> struct arg_stack_t : stack_t<ARG, 513>
{ {
void push_int (int v) void push_int (int v)
{ {
@@ -541,18 +522,18 @@ struct ArgStack : Stack<ARG, 513>
return (unsigned)i; 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])); push_int ((str_ref[0] << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3]));
substr.inc (4); 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; return false;
push_fixed ((int32_t)*(const HBUINT32*)&substr[0]); push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
substr.inc (4); str_ref.inc (4);
return true; return true;
} }
@@ -562,36 +543,36 @@ struct ArgStack : Stack<ARG, 513>
} }
private: private:
typedef Stack<ARG, 513> S; typedef stack_t<ARG, 513> S;
}; };
/* an operator prefixed by its operands in a byte string */ /* an operator prefixed by its operands in a byte string */
struct OpStr struct op_str_t
{ {
void init () {} void init () {}
void fini () {} void fini () {}
OpCode op; op_code_t op;
ByteStr str; byte_str_t str;
}; };
/* base of OP_SERIALIZER */ /* base of OP_SERIALIZER */
struct OpSerializer struct op_serializer_t
{ {
protected: 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); TRACE_SERIALIZE (this);
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len); HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
if (unlikely (d == nullptr)) return_trace (false); 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); return_trace (true);
} }
}; };
template <typename VAL> template <typename VAL>
struct ParsedValues struct parsed_values_t
{ {
void init () void init ()
{ {
@@ -600,30 +581,30 @@ struct ParsedValues
} }
void fini () { values.fini_deep (); } 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 *val = values.push ();
val->op = op; val->op = op;
val->str = ByteStr (substr.str, opStart, substr.offset - opStart); val->str = str_ref.str.sub_str (opStart, str_ref.offset - opStart);
opStart = substr.offset; 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 *val = values.push (v);
val->op = op; val->op = op;
val->str = ByteStr (substr.str, opStart, substr.offset - opStart); val->str = str_ref.sub_str ( opStart, str_ref.offset - opStart);
opStart = substr.offset; 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++) for (unsigned int i = 0; i < get_count (); i++)
if (get_value (i).op == op) return true; if (get_value (i).op == op) return true;
return false; 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 &get_value (unsigned int i) const { return values[i]; }
const VAL &operator [] (unsigned int i) const { return get_value (i); } const VAL &operator [] (unsigned int i) const { return get_value (i); }
@@ -631,35 +612,35 @@ struct ParsedValues
hb_vector_t<VAL> values; hb_vector_t<VAL> values;
}; };
template <typename ARG=Number> template <typename ARG=number_t>
struct InterpEnv 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 (); argStack.init ();
error = false; error = false;
} }
void fini () { argStack.fini (); } void fini () { argStack.fini (); }
bool in_error () const 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; } void set_error () { error = true; }
OpCode fetch_op () op_code_t fetch_op ()
{ {
OpCode op = OpCode_Invalid; op_code_t op = OpCode_Invalid;
if (unlikely (!substr.avail ())) if (unlikely (!str_ref.avail ()))
return OpCode_Invalid; return OpCode_Invalid;
op = (OpCode)(unsigned char)substr[0]; op = (op_code_t)(unsigned char)str_ref[0];
if (op == OpCode_escape) { if (op == OpCode_escape) {
if (unlikely (!substr.avail ())) if (unlikely (!str_ref.avail ()))
return OpCode_Invalid; return OpCode_Invalid;
op = Make_OpCode_ESC(substr[1]); op = Make_OpCode_ESC(str_ref[1]);
substr.inc (); str_ref.inc ();
} }
substr.inc (); str_ref.inc ();
return op; return op;
} }
@@ -683,35 +664,35 @@ struct InterpEnv
pop_n_args (argStack.get_count ()); pop_n_args (argStack.get_count ());
} }
SubByteStr substr; byte_str_ref_t str_ref;
ArgStack<ARG> argStack; arg_stack_t<ARG> argStack;
protected: protected:
bool error; bool error;
}; };
typedef InterpEnv<> NumInterpEnv; typedef interp_env_t<> num_interp_env_t;
template <typename ARG=Number> template <typename ARG=number_t>
struct OpSet struct opset_t
{ {
static void process_op (OpCode op, InterpEnv<ARG>& env) static void process_op (op_code_t op, interp_env_t<ARG>& env)
{ {
switch (op) { switch (op) {
case OpCode_shortint: case OpCode_shortint:
env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1])); env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
env.substr.inc (2); env.str_ref.inc (2);
break; break;
case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1: case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108)); env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
env.substr.inc (); env.str_ref.inc ();
break; break;
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108)); env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
env.substr.inc (); env.str_ref.inc ();
break; break;
default: default:
@@ -730,9 +711,9 @@ struct OpSet
}; };
template <typename ENV> template <typename ENV>
struct Interpreter { struct interpreter_t {
~Interpreter() { fini (); } ~interpreter_t() { fini (); }
void fini () { env.fini (); } void fini () { env.fini (); }

View File

@@ -33,34 +33,34 @@ namespace CFF {
using namespace OT; using namespace OT;
enum CSType { enum cs_type_t {
CSType_CharString, CSType_CharString,
CSType_GlobalSubr, CSType_GlobalSubr,
CSType_LocalSubr 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_; type = type_;
subr_num = subr_num_; subr_num = subr_num_;
} }
void fini () {} void fini () {}
SubByteStr substr; byte_str_ref_t str_ref;
CSType type; cs_type_t type;
unsigned int subr_num; unsigned int subr_num;
}; };
/* call stack */ /* call stack */
const unsigned int kMaxCallLimit = 10; const unsigned int kMaxCallLimit = 10;
struct CallStack : Stack<CallContext, kMaxCallLimit> {}; struct call_stack_t : stack_t<call_context_t, kMaxCallLimit> {};
template <typename SUBRS> template <typename SUBRS>
struct BiasedSubrs struct biased_subrs_t
{ {
void init (const SUBRS &subrs_) 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_count () const { return (subrs == nullptr)? 0: subrs->count; }
unsigned int get_bias () const { return bias; } 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)) if (unlikely ((subrs == nullptr) || index >= subrs->count))
return Null(ByteStr); return Null(byte_str_t);
else else
return (*subrs)[index]; return (*subrs)[index];
} }
@@ -92,7 +92,7 @@ struct BiasedSubrs
const SUBRS *subrs; const SUBRS *subrs;
}; };
struct Point struct point_t
{ {
void init () void init ()
{ {
@@ -106,27 +106,28 @@ struct Point
y.set_int (_y); y.set_int (_y);
} }
void move_x (const Number &dx) { x += dx; } void move_x (const number_t &dx) { x += dx; }
void move_y (const Number &dy) { y += dy; } void move_y (const number_t &dy) { y += dy; }
void move (const Number &dx, const Number &dy) { move_x (dx); move_y (dy); } void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); }
void move (const Point &d) { move_x (d.x); move_y (d.y); } void move (const point_t &d) { move_x (d.x); move_y (d.y); }
Number x; number_t x;
Number y; number_t y;
}; };
template <typename ARG, typename SUBRS> template <typename ARG, typename SUBRS>
struct CSInterpEnv : InterpEnv<ARG> struct cs_interp_env_t : interp_env_t<ARG>
{ {
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<ARG>::init (str); interp_env_t<ARG>::init (str);
context.init (str, CSType_CharString); context.init (str, CSType_CharString);
seen_moveto = true; seen_moveto = true;
seen_hintmask = false; seen_hintmask = false;
hstem_count = 0; hstem_count = 0;
vstem_count = 0; vstem_count = 0;
hintmask_size = 0;
pt.init (); pt.init ();
callStack.init (); callStack.init ();
globalSubrs.init (globalSubrs_); globalSubrs.init (globalSubrs_);
@@ -134,7 +135,7 @@ struct CSInterpEnv : InterpEnv<ARG>
} }
void fini () void fini ()
{ {
InterpEnv<ARG>::fini (); interp_env_t<ARG>::fini ();
callStack.fini (); callStack.fini ();
globalSubrs.fini (); globalSubrs.fini ();
@@ -146,7 +147,7 @@ struct CSInterpEnv : InterpEnv<ARG>
return callStack.in_error () || SUPER::in_error (); return callStack.in_error () || SUPER::in_error ();
} }
bool popSubrNum (const BiasedSubrs<SUBRS>& biasedSubrs, unsigned int &subr_num) bool popSubrNum (const biased_subrs_t<SUBRS>& biasedSubrs, unsigned int &subr_num)
{ {
int n = SUPER::argStack.pop_int (); int n = SUPER::argStack.pop_int ();
n += biasedSubrs.get_bias (); n += biasedSubrs.get_bias ();
@@ -157,7 +158,7 @@ struct CSInterpEnv : InterpEnv<ARG>
return true; return true;
} }
void callSubr (const BiasedSubrs<SUBRS>& biasedSubrs, CSType type) void callSubr (const biased_subrs_t<SUBRS>& biasedSubrs, cs_type_t type)
{ {
unsigned int subr_num; unsigned int subr_num;
@@ -167,19 +168,19 @@ struct CSInterpEnv : InterpEnv<ARG>
SUPER::set_error (); SUPER::set_error ();
return; return;
} }
context.substr = SUPER::substr; context.str_ref = SUPER::str_ref;
callStack.push (context); callStack.push (context);
context.init ( biasedSubrs[subr_num], type, subr_num); context.init ( biasedSubrs[subr_num], type, subr_num);
SUPER::substr = context.substr; SUPER::str_ref = context.str_ref;
} }
void returnFromSubr () void returnFromSubr ()
{ {
if (unlikely (SUPER::substr.in_error ())) if (unlikely (SUPER::str_ref.in_error ()))
SUPER::set_error (); SUPER::set_error ();
context = callStack.pop (); context = callStack.pop ();
SUPER::substr = context.substr; SUPER::str_ref = context.str_ref;
} }
void determine_hintmask_size () void determine_hintmask_size ()
@@ -195,14 +196,14 @@ struct CSInterpEnv : InterpEnv<ARG>
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; } void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
bool is_endchar () const { return endchar_flag; } bool is_endchar () const { return endchar_flag; }
const Number &get_x () const { return pt.x; } const number_t &get_x () const { return pt.x; }
const Number &get_y () const { return pt.y; } const number_t &get_y () const { return pt.y; }
const Point &get_pt () const { return pt; } const point_t &get_pt () const { return pt; }
void moveto (const Point &pt_ ) { pt = pt_; } void moveto (const point_t &pt_ ) { pt = pt_; }
public: public:
CallContext context; call_context_t context;
bool endchar_flag; bool endchar_flag;
bool seen_moveto; bool seen_moveto;
bool seen_hintmask; bool seen_hintmask;
@@ -210,18 +211,18 @@ struct CSInterpEnv : InterpEnv<ARG>
unsigned int hstem_count; unsigned int hstem_count;
unsigned int vstem_count; unsigned int vstem_count;
unsigned int hintmask_size; unsigned int hintmask_size;
CallStack callStack; call_stack_t callStack;
BiasedSubrs<SUBRS> globalSubrs; biased_subrs_t<SUBRS> globalSubrs;
BiasedSubrs<SUBRS> localSubrs; biased_subrs_t<SUBRS> localSubrs;
private: private:
Point pt; point_t pt;
typedef InterpEnv<ARG> SUPER; typedef interp_env_t<ARG> SUPER;
}; };
template <typename ENV, typename PARAM> template <typename ENV, typename PARAM>
struct PathProcsNull struct path_procs_null_t
{ {
static void rmoveto (ENV &env, PARAM& param) {} static void rmoveto (ENV &env, PARAM& param) {}
static void hmoveto (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 hhcurveto (ENV &env, PARAM& param) {}
static void vhcurveto (ENV &env, PARAM& param) {} static void vhcurveto (ENV &env, PARAM& param) {}
static void hvcurveto (ENV &env, PARAM& param) {} static void hvcurveto (ENV &env, PARAM& param) {}
static void moveto (ENV &env, PARAM& param, const Point &pt) {} static void moveto (ENV &env, PARAM& param, const point_t &pt) {}
static void line (ENV &env, PARAM& param, const Point &pt1) {} static void line (ENV &env, PARAM& param, const point_t &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) {}
static void hflex (ENV &env, PARAM& param) {} static void hflex (ENV &env, PARAM& param) {}
static void flex (ENV &env, PARAM& param) {} static void flex (ENV &env, PARAM& param) {}
static void hflex1 (ENV &env, PARAM& param) {} static void hflex1 (ENV &env, PARAM& param) {}
static void flex1 (ENV &env, PARAM& param) {} static void flex1 (ENV &env, PARAM& param) {}
}; };
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=PathProcsNull<ENV, PARAM> > template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=path_procs_null_t<ENV, PARAM> >
struct CSOpSet : OpSet<ARG> struct cs_opset_t : opset_t<ARG>
{ {
static void process_op (OpCode op, ENV &env, PARAM& param) static void process_op (op_code_t op, ENV &env, PARAM& param)
{ {
switch (op) { switch (op) {
@@ -262,7 +263,7 @@ struct CSOpSet : OpSet<ARG>
break; break;
case OpCode_fixedcs: case OpCode_fixedcs:
env.argStack.push_fixed_from_substr (env.substr); env.argStack.push_fixed_from_substr (env.str_ref);
break; break;
case OpCode_callsubr: case OpCode_callsubr:
@@ -370,37 +371,37 @@ struct CSOpSet : OpSet<ARG>
} }
} }
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; env.hstem_count += env.argStack.get_count () / 2;
OPSET::flush_args_and_op (op, env, param); 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; env.vstem_count += env.argStack.get_count () / 2;
OPSET::flush_args_and_op (op, env, param); 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 (); 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); 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); 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) if (!env.seen_moveto)
{ {
@@ -410,12 +411,12 @@ struct CSOpSet : OpSet<ARG>
OPSET::flush_args_and_op (op, env, param); 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); 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_args (env, param);
OPSET::flush_op (op, env, param); OPSET::flush_op (op, env, param);
@@ -426,16 +427,16 @@ struct CSOpSet : OpSet<ARG>
env.pop_n_args (env.argStack.get_count ()); 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); 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) switch (op)
{ {
@@ -454,31 +455,31 @@ struct CSOpSet : OpSet<ARG>
} }
protected: protected:
typedef OpSet<ARG> SUPER; typedef opset_t<ARG> SUPER;
}; };
template <typename PATH, typename ENV, typename PARAM> template <typename PATH, typename ENV, typename PARAM>
struct PathProcs struct path_procs_t
{ {
static void rmoveto (ENV &env, PARAM& param) static void rmoveto (ENV &env, PARAM& param)
{ {
Point pt1 = env.get_pt (); point_t pt1 = env.get_pt ();
const Number &dy = env.pop_arg (); const number_t &dy = env.pop_arg ();
const Number &dx = env.pop_arg (); const number_t &dx = env.pop_arg ();
pt1.move (dx, dy); pt1.move (dx, dy);
PATH::moveto (env, param, pt1); PATH::moveto (env, param, pt1);
} }
static void hmoveto (ENV &env, PARAM& param) static void hmoveto (ENV &env, PARAM& param)
{ {
Point pt1 = env.get_pt (); point_t pt1 = env.get_pt ();
pt1.move_x (env.pop_arg ()); pt1.move_x (env.pop_arg ());
PATH::moveto (env, param, pt1); PATH::moveto (env, param, pt1);
} }
static void vmoveto (ENV &env, PARAM& param) static void vmoveto (ENV &env, PARAM& param)
{ {
Point pt1 = env.get_pt (); point_t pt1 = env.get_pt ();
pt1.move_y (env.pop_arg ()); pt1.move_y (env.pop_arg ());
PATH::moveto (env, param, pt1); PATH::moveto (env, param, pt1);
} }
@@ -487,7 +488,7 @@ struct PathProcs
{ {
for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2) 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)); pt1.move (env.eval_arg (i), env.eval_arg (i+1));
PATH::line (env, param, pt1); PATH::line (env, param, pt1);
} }
@@ -495,7 +496,7 @@ struct PathProcs
static void hlineto (ENV &env, PARAM& param) static void hlineto (ENV &env, PARAM& param)
{ {
Point pt1; point_t pt1;
unsigned int i = 0; unsigned int i = 0;
for (; i + 2 <= env.argStack.get_count (); i += 2) for (; i + 2 <= env.argStack.get_count (); i += 2)
{ {
@@ -515,7 +516,7 @@ struct PathProcs
static void vlineto (ENV &env, PARAM& param) static void vlineto (ENV &env, PARAM& param)
{ {
Point pt1; point_t pt1;
unsigned int i = 0; unsigned int i = 0;
for (; i + 2 <= env.argStack.get_count (); i += 2) 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) 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)); 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)); 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)); pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
} }
@@ -552,17 +553,17 @@ struct PathProcs
unsigned int i = 0; unsigned int i = 0;
for (; i + 6 <= env.argStack.get_count (); i += 6) 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)); 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)); 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)); pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
} }
for (; i + 2 <= env.argStack.get_count (); i += 2) 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)); pt1.move (env.eval_arg (i), env.eval_arg (i+1));
PATH::line (env, param, pt1); PATH::line (env, param, pt1);
} }
@@ -574,17 +575,17 @@ struct PathProcs
unsigned int line_limit = (env.argStack.get_count () % 6); unsigned int line_limit = (env.argStack.get_count () % 6);
for (; i + 2 <= line_limit; i += 2) 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)); pt1.move (env.eval_arg (i), env.eval_arg (i+1));
PATH::line (env, param, pt1); PATH::line (env, param, pt1);
} }
for (; i + 6 <= env.argStack.get_count (); i += 6) 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)); 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)); 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)); pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
} }
@@ -593,15 +594,15 @@ struct PathProcs
static void vvcurveto (ENV &env, PARAM& param) static void vvcurveto (ENV &env, PARAM& param)
{ {
unsigned int i = 0; unsigned int i = 0;
Point pt1 = env.get_pt (); point_t pt1 = env.get_pt ();
if ((env.argStack.get_count () & 1) != 0) if ((env.argStack.get_count () & 1) != 0)
pt1.move_x (env.eval_arg (i++)); pt1.move_x (env.eval_arg (i++));
for (; i + 4 <= env.argStack.get_count (); i += 4) for (; i + 4 <= env.argStack.get_count (); i += 4)
{ {
pt1.move_y (env.eval_arg (i)); 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)); 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)); pt3.move_y (env.eval_arg (i+3));
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
pt1 = env.get_pt (); pt1 = env.get_pt ();
@@ -611,15 +612,15 @@ struct PathProcs
static void hhcurveto (ENV &env, PARAM& param) static void hhcurveto (ENV &env, PARAM& param)
{ {
unsigned int i = 0; unsigned int i = 0;
Point pt1 = env.get_pt (); point_t pt1 = env.get_pt ();
if ((env.argStack.get_count () & 1) != 0) if ((env.argStack.get_count () & 1) != 0)
pt1.move_y (env.eval_arg (i++)); pt1.move_y (env.eval_arg (i++));
for (; i + 4 <= env.argStack.get_count (); i += 4) for (; i + 4 <= env.argStack.get_count (); i += 4)
{ {
pt1.move_x (env.eval_arg (i)); 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)); 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)); pt3.move_x (env.eval_arg (i+3));
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
pt1 = env.get_pt (); pt1 = env.get_pt ();
@@ -628,15 +629,15 @@ struct PathProcs
static void vhcurveto (ENV &env, PARAM& param) static void vhcurveto (ENV &env, PARAM& param)
{ {
Point pt1, pt2, pt3; point_t pt1, pt2, pt3;
unsigned int i = 0; unsigned int i = 0;
if ((env.argStack.get_count () % 8) >= 4) 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)); 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)); 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)); pt3.move_x (env.eval_arg (i+3));
i += 4; i += 4;
@@ -689,15 +690,15 @@ struct PathProcs
static void hvcurveto (ENV &env, PARAM& param) static void hvcurveto (ENV &env, PARAM& param)
{ {
Point pt1, pt2, pt3; point_t pt1, pt2, pt3;
unsigned int i = 0; unsigned int i = 0;
if ((env.argStack.get_count () % 8) >= 4) 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)); 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)); 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)); pt3.move_y (env.eval_arg (i+3));
i += 4; i += 4;
@@ -749,31 +750,31 @@ struct PathProcs
} }
/* default actions to be overridden */ /* 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); } { 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); } { 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); } { PATH::moveto (env, param, pt3); }
static void hflex (ENV &env, PARAM& param) static void hflex (ENV &env, PARAM& param)
{ {
if (likely (env.argStack.get_count () == 7)) 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)); pt1.move_x (env.eval_arg (0));
Point pt2 = pt1; point_t pt2 = pt1;
pt2.move (env.eval_arg (1), env.eval_arg (2)); pt2.move (env.eval_arg (1), env.eval_arg (2));
Point pt3 = pt2; point_t pt3 = pt2;
pt3.move_x (env.eval_arg (3)); pt3.move_x (env.eval_arg (3));
Point pt4 = pt3; point_t pt4 = pt3;
pt4.move_x (env.eval_arg (4)); pt4.move_x (env.eval_arg (4));
Point pt5 = pt4; point_t pt5 = pt4;
pt5.move_x (env.eval_arg (5)); pt5.move_x (env.eval_arg (5));
pt5.y = pt1.y; pt5.y = pt1.y;
Point pt6 = pt5; point_t pt6 = pt5;
pt6.move_x (env.eval_arg (6)); pt6.move_x (env.eval_arg (6));
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
@@ -786,17 +787,17 @@ struct PathProcs
{ {
if (likely (env.argStack.get_count () == 13)) 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)); 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)); 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)); 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)); 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)); 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)); pt6.move (env.eval_arg (10), env.eval_arg (11));
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
@@ -809,17 +810,17 @@ struct PathProcs
{ {
if (likely (env.argStack.get_count () == 9)) 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)); 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)); pt2.move (env.eval_arg (2), env.eval_arg (3));
Point pt3 = pt2; point_t pt3 = pt2;
pt3.move_x (env.eval_arg (4)); pt3.move_x (env.eval_arg (4));
Point pt4 = pt3; point_t pt4 = pt3;
pt4.move_x (env.eval_arg (5)); pt4.move_x (env.eval_arg (5));
Point pt5 = pt4; point_t pt5 = pt4;
pt5.move (env.eval_arg (6), env.eval_arg (7)); 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.move_x (env.eval_arg (8));
pt6.y = env.get_pt ().y; pt6.y = env.get_pt ().y;
@@ -833,22 +834,22 @@ struct PathProcs
{ {
if (likely (env.argStack.get_count () == 11)) if (likely (env.argStack.get_count () == 11))
{ {
Point d; point_t d;
d.init (); d.init ();
for (unsigned int i = 0; i < 10; i += 2) for (unsigned int i = 0; i < 10; i += 2)
d.move (env.eval_arg (i), env.eval_arg (i+1)); 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)); 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)); 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)); 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)); 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)); 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 ())) if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
{ {
@@ -869,8 +870,8 @@ struct PathProcs
protected: protected:
static void curve2 (ENV &env, PARAM& param, static void curve2 (ENV &env, PARAM& param,
const Point &pt1, const Point &pt2, const Point &pt3, const point_t &pt1, const point_t &pt2, const point_t &pt3,
const Point &pt4, const Point &pt5, const Point &pt6) const point_t &pt4, const point_t &pt5, const point_t &pt6)
{ {
PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt1, pt2, pt3);
PATH::curve (env, param, pt4, pt5, pt6); PATH::curve (env, param, pt4, pt5, pt6);
@@ -878,7 +879,7 @@ struct PathProcs
}; };
template <typename ENV, typename OPSET, typename PARAM> template <typename ENV, typename OPSET, typename PARAM>
struct CSInterpreter : Interpreter<ENV> struct cs_interpreter_t : interpreter_t<ENV>
{ {
bool interpret (PARAM& param) bool interpret (PARAM& param)
{ {
@@ -896,7 +897,7 @@ struct CSInterpreter : Interpreter<ENV>
} }
private: private:
typedef Interpreter<ENV> SUPER; typedef interpreter_t<ENV> SUPER;
}; };
} /* namespace CFF */ } /* namespace CFF */

View File

@@ -35,28 +35,28 @@ namespace CFF {
using namespace OT; using namespace OT;
/* an opstr and the parsed out dict value(s) */ /* 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 init () { single_val.set_int (0); }
void fini () {} void fini () {}
Number single_val; number_t single_val;
}; };
typedef DictVal NumDictVal; typedef dict_val_t num_dict_val_t;
template <typename VAL> struct DictValues : ParsedValues<VAL> {}; template <typename VAL> struct dict_values_t : parsed_values_t<VAL> {};
template <typename OPSTR=OpStr> template <typename OPSTR=op_str_t>
struct TopDictValues : DictValues<OPSTR> struct top_dict_values_t : dict_values_t<OPSTR>
{ {
void init () void init ()
{ {
DictValues<OPSTR>::init (); dict_values_t<OPSTR>::init ();
charStringsOffset = 0; charStringsOffset = 0;
FDArrayOffset = 0; FDArrayOffset = 0;
} }
void fini () { DictValues<OPSTR>::fini (); } void fini () { dict_values_t<OPSTR>::fini (); }
unsigned int calculate_serialized_op_size (const OPSTR& opstr) const unsigned int calculate_serialized_op_size (const OPSTR& opstr) const
{ {
@@ -67,7 +67,7 @@ struct TopDictValues : DictValues<OPSTR>
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default: default:
return opstr.str.len; return opstr.str.length;
} }
} }
@@ -75,26 +75,26 @@ struct TopDictValues : DictValues<OPSTR>
unsigned int FDArrayOffset; unsigned int FDArrayOffset;
}; };
struct DictOpSet : OpSet<Number> struct dict_opset_t : opset_t<number_t>
{ {
static void process_op (OpCode op, InterpEnv<Number>& env) static void process_op (op_code_t op, interp_env_t<number_t>& env)
{ {
switch (op) { switch (op) {
case OpCode_longintdict: /* 5-byte integer */ case OpCode_longintdict: /* 5-byte integer */
env.argStack.push_longint_from_substr (env.substr); env.argStack.push_longint_from_substr (env.str_ref);
break; break;
case OpCode_BCD: /* real number */ case OpCode_BCD: /* real number */
env.argStack.push_real (parse_bcd (env.substr)); env.argStack.push_real (parse_bcd (env.str_ref));
break; break;
default: default:
OpSet<Number>::process_op (op, env); opset_t<number_t>::process_op (op, env);
break; break;
} }
} }
static double parse_bcd (SubByteStr& substr) static double parse_bcd (byte_str_ref_t& str_ref)
{ {
bool neg = false; bool neg = false;
double int_part = 0; double int_part = 0;
@@ -115,13 +115,13 @@ struct DictOpSet : OpSet<Number>
char d; char d;
if ((i & 1) == 0) if ((i & 1) == 0)
{ {
if (!substr.avail ()) if (!str_ref.avail ())
{ {
substr.set_error (); str_ref.set_error ();
return 0.0; return 0.0;
} }
byte = substr[0]; byte = str_ref[0];
substr.inc (); str_ref.inc ();
d = byte >> 4; d = byte >> 4;
} }
else else
@@ -130,7 +130,7 @@ struct DictOpSet : OpSet<Number>
switch (d) switch (d)
{ {
case RESERVED: case RESERVED:
substr.set_error (); str_ref.set_error ();
return value; return value;
case END: case END:
@@ -162,7 +162,7 @@ struct DictOpSet : OpSet<Number>
case NEG: case NEG:
if (i != 0) if (i != 0)
{ {
substr.set_error (); str_ref.set_error ();
return 0.0; return 0.0;
} }
neg = true; neg = true;
@@ -171,7 +171,7 @@ struct DictOpSet : OpSet<Number>
case DECIMAL: case DECIMAL:
if (part != INT_PART) if (part != INT_PART)
{ {
substr.set_error (); str_ref.set_error ();
return value; return value;
} }
part = FRAC_PART; part = FRAC_PART;
@@ -184,7 +184,7 @@ struct DictOpSet : OpSet<Number>
case EXP_POS: case EXP_POS:
if (part == EXP_PART) if (part == EXP_PART)
{ {
substr.set_error (); str_ref.set_error ();
return value; return value;
} }
part = EXP_PART; part = EXP_PART;
@@ -220,7 +220,7 @@ struct DictOpSet : OpSet<Number>
return value; return value;
} }
static bool is_hint_op (OpCode op) static bool is_hint_op (op_code_t op)
{ {
switch (op) switch (op)
{ {
@@ -245,10 +245,10 @@ struct DictOpSet : OpSet<Number>
} }
}; };
template <typename VAL=OpStr> template <typename VAL=op_str_t>
struct TopDictOpSet : DictOpSet struct top_dict_opset_t : dict_opset_t
{ {
static void process_op (OpCode op, InterpEnv<Number>& env, TopDictValues<VAL> & dictval) static void process_op (op_code_t op, interp_env_t<number_t>& env, top_dict_values_t<VAL> & dictval)
{ {
switch (op) { switch (op) {
case OpCode_CharStrings: case OpCode_CharStrings:
@@ -263,19 +263,19 @@ struct TopDictOpSet : DictOpSet
env.clear_args (); env.clear_args ();
break; break;
default: default:
DictOpSet::process_op (op, env); dict_opset_t::process_op (op, env);
break; break;
} }
} }
}; };
template <typename OPSET, typename PARAM, typename ENV=NumInterpEnv> template <typename OPSET, typename PARAM, typename ENV=num_interp_env_t>
struct DictInterpreter : Interpreter<ENV> struct dict_interpreter_t : interpreter_t<ENV>
{ {
bool interpret (PARAM& param) bool interpret (PARAM& param)
{ {
param.init (); param.init ();
while (SUPER::env.substr.avail ()) while (SUPER::env.str_ref.avail ())
{ {
OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param);
if (unlikely (SUPER::env.in_error ())) if (unlikely (SUPER::env.in_error ()))
@@ -286,7 +286,7 @@ struct DictInterpreter : Interpreter<ENV>
} }
private: private:
typedef Interpreter<ENV> SUPER; typedef interpreter_t<ENV> SUPER;
}; };
} /* namespace CFF */ } /* namespace CFF */

View File

@@ -33,12 +33,12 @@ namespace CFF {
using namespace OT; using namespace OT;
typedef BiasedSubrs<CFF1Subrs> CFF1BiasedSubrs; typedef biased_subrs_t<CFF1Subrs> cff1_biased_subrs_t;
struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs> struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
{ {
template <typename ACC> template <typename ACC>
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); SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
processed_width = false; processed_width = false;
@@ -74,20 +74,20 @@ struct CFF1CSInterpEnv : CSInterpEnv<Number, CFF1Subrs>
bool processed_width; bool processed_width;
bool has_width; bool has_width;
unsigned int arg_start; unsigned int arg_start;
Number width; number_t width;
bool in_seac; bool in_seac;
private: private:
typedef CSInterpEnv<Number, CFF1Subrs> SUPER; typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
}; };
template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF1CSInterpEnv, PARAM> > template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM> >
struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH> struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
{ {
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */ /* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
/* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */ /* 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) { switch (op) {
case OpCode_dotsection: case OpCode_dotsection:
@@ -109,7 +109,7 @@ struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
} }
} }
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) if (!env.processed_width)
{ {
@@ -139,22 +139,22 @@ struct CFF1CSOpSet : CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH>
} }
} }
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); SUPER::flush_args (env, param);
env.clear_args (); /* pop off width */ env.clear_args (); /* pop off width */
} }
private: private:
typedef CSOpSet<Number, OPSET, CFF1CSInterpEnv, PARAM, PATH> SUPER; typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH> SUPER;
}; };
template <typename OPSET, typename PARAM> template <typename OPSET, typename PARAM>
struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {}; struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
} /* namespace CFF */ } /* namespace CFF */

View File

@@ -33,26 +33,26 @@ namespace CFF {
using namespace OT; using namespace OT;
struct BlendArg : Number struct blend_arg_t : number_t
{ {
void init () void init ()
{ {
Number::init (); number_t::init ();
deltas.init (); deltas.init ();
} }
void fini () void fini ()
{ {
Number::fini (); number_t::fini ();
deltas.fini_deep (); deltas.fini_deep ();
} }
void set_int (int v) { reset_blends (); Number::set_int (v); } void set_int (int v) { reset_blends (); number_t::set_int (v); }
void set_fixed (int32_t v) { reset_blends (); Number::set_fixed (v); } void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
void set_real (double v) { reset_blends (); Number::set_real (v); } void set_real (double v) { reset_blends (); number_t::set_real (v); }
void set_blends (unsigned int numValues_, unsigned int valueIndex_, void set_blends (unsigned int numValues_, unsigned int valueIndex_,
unsigned int numBlends, hb_array_t<const BlendArg> blends_) unsigned int numBlends, hb_array_t<const blend_arg_t> blends_)
{ {
numValues = numValues_; numValues = numValues_;
valueIndex = valueIndex_; valueIndex = valueIndex_;
@@ -61,7 +61,7 @@ struct BlendArg : Number
deltas[i] = blends_[i]; deltas[i] = blends_[i];
} }
bool blending () const { return deltas.len > 0; } bool blending () const { return deltas.length > 0; }
void reset_blends () void reset_blends ()
{ {
numValues = valueIndex = 0; numValues = valueIndex = 0;
@@ -70,16 +70,16 @@ struct BlendArg : Number
unsigned int numValues; unsigned int numValues;
unsigned int valueIndex; unsigned int valueIndex;
hb_vector_t<Number> deltas; hb_vector_t<number_t> deltas;
}; };
typedef InterpEnv<BlendArg> BlendInterpEnv; typedef interp_env_t<blend_arg_t> BlendInterpEnv;
typedef BiasedSubrs<CFF2Subrs> CFF2BiasedSubrs; typedef biased_subrs_t<CFF2Subrs> cff2_biased_subrs_t;
struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs> struct cff2_cs_interp_env_t : cs_interp_env_t<blend_arg_t, CFF2Subrs>
{ {
template <typename ACC> template <typename ACC>
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) const int *coords_=nullptr, unsigned int num_coords_=0)
{ {
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
@@ -100,9 +100,9 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
SUPER::fini (); SUPER::fini ();
} }
OpCode fetch_op () op_code_t fetch_op ()
{ {
if (this->substr.avail ()) if (this->str_ref.avail ())
return SUPER::fetch_op (); return SUPER::fetch_op ();
/* make up return or endchar op */ /* make up return or endchar op */
@@ -112,16 +112,16 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
return OpCode_return; 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); blend_arg (arg);
return 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); blend_arg (arg);
return arg; return arg;
} }
@@ -163,14 +163,14 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
bool seen_vsindex () const { return seen_vsindex_; } bool seen_vsindex () const { return seen_vsindex_; }
protected: protected:
void blend_arg (BlendArg &arg) void blend_arg (blend_arg_t &arg)
{ {
if (do_blend && arg.blending ()) if (do_blend && arg.blending ())
{ {
if (likely (scalars.len == arg.deltas.len)) if (likely (scalars.length == arg.deltas.length))
{ {
double v = arg.to_real (); 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 (); v += (double)scalars[i] * arg.deltas[i].to_real ();
} }
@@ -191,12 +191,12 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
bool seen_vsindex_; bool seen_vsindex_;
bool seen_blend; bool seen_blend;
typedef CSInterpEnv<BlendArg, CFF2Subrs> SUPER; typedef cs_interp_env_t<blend_arg_t, CFF2Subrs> SUPER;
}; };
template <typename OPSET, typename PARAM, typename PATH=PathProcsNull<CFF2CSInterpEnv, PARAM> > template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff2_cs_interp_env_t, PARAM> >
struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH> struct cff2_cs_opset_t : cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH>
{ {
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) { switch (op) {
case OpCode_callsubr: case OpCode_callsubr:
@@ -228,7 +228,7 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
} }
} }
static void process_blend (CFF2CSInterpEnv &env, PARAM& param) static void process_blend (cff2_cs_interp_env_t &env, PARAM& param)
{ {
unsigned int n, k; unsigned int n, k;
@@ -245,7 +245,7 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
} }
for (unsigned int i = 0; i < n; i++) for (unsigned int i = 0; i < n; i++)
{ {
const hb_array_t<const BlendArg> blends = env.argStack.get_subarray (start + n + (i * k)); const hb_array_t<const blend_arg_t> blends = env.argStack.get_subarray (start + n + (i * k));
env.argStack[start + i].set_blends (n, i, k, blends); env.argStack[start + i].set_blends (n, i, k, blends);
} }
@@ -253,18 +253,18 @@ struct CFF2CSOpSet : CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH>
env.argStack.pop (k * n); 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.process_vsindex ();
env.clear_args (); env.clear_args ();
} }
private: private:
typedef CSOpSet<BlendArg, OPSET, CFF2CSInterpEnv, PARAM, PATH> SUPER; typedef cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH> SUPER;
}; };
template <typename OPSET, typename PARAM> template <typename OPSET, typename PARAM>
struct CFF2CSInterpreter : CSInterpreter<CFF2CSInterpEnv, OPSET, PARAM> {}; struct cff2_cs_interpreter_t : cs_interpreter_t<cff2_cs_interp_env_t, OPSET, PARAM> {};
} /* namespace CFF */ } /* namespace CFF */

View File

@@ -67,7 +67,7 @@ typedef unsigned __int64 uint64_t;
# include <stdint.h> # include <stdint.h>
#endif #endif
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define HB_DEPRECATED __attribute__((__deprecated__)) #define HB_DEPRECATED __attribute__((__deprecated__))
#elif defined(_MSC_VER) && (_MSC_VER >= 1300) #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
#define HB_DEPRECATED __declspec(deprecated) #define HB_DEPRECATED __declspec(deprecated)
@@ -75,7 +75,7 @@ typedef unsigned __int64 uint64_t;
#define HB_DEPRECATED #define HB_DEPRECATED
#endif #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"))) #define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
#define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) #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; 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_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_NONE HB_TAG(0,0,0,0)
#define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) #define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)

View File

@@ -527,7 +527,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
/* Scan events and save features for each range. */ /* Scan events and save features for each range. */
hb_vector_t<active_feature_t> active_features; hb_vector_t<active_feature_t> active_features;
unsigned int last_index = 0; 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]; 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. */ /* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push (); range_record_t *range = range_records.push ();
if (active_features.len) if (active_features.length)
{ {
CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
/* TODO sort and resolve conflicting features? */ /* TODO sort and resolve conflicting features? */
/* active_features.qsort (); */ /* 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[] = { CFStringRef keys[] = {
kCTFontFeatureTypeIdentifierKey, kCTFontFeatureTypeIdentifierKey,
@@ -730,7 +730,7 @@ resize_and_retry:
CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
kCTFontAttributeName, ct_font); kCTFontAttributeName, ct_font);
if (num_features && range_records.len) if (num_features && range_records.length)
{ {
unsigned int start = 0; unsigned int start = 0;
range_record_t *last_range = &range_records[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 * Also see: https://bugs.chromium.org/p/chromium/issues/detail?id=597098
*/ */
bool matched = false; 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)) if (range_records[i].font && CFEqual (run_ct_font, range_records[i].font))
{ {
matched = true; matched = true;
@@ -1142,7 +1142,7 @@ fail:
if (line) if (line)
CFRelease (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) if (range_records[i].font)
CFRelease (range_records[i].font); CFRelease (range_records[i].font);

View File

@@ -401,30 +401,6 @@ struct hb_no_trace_t {
#define TRACE_APPLY(this) hb_no_trace_t<bool> trace #define TRACE_APPLY(this) hb_no_trace_t<bool> trace
#endif #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<HB_DEBUG_CLOSURE, hb_void_t> trace \
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
" ")
#else
#define TRACE_CLOSURE(this) hb_no_trace_t<hb_void_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<HB_DEBUG_COLLECT_GLYPHS, hb_void_t> trace \
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
" ")
#else
#define TRACE_COLLECT_GLYPHS(this) hb_no_trace_t<hb_void_t> trace HB_UNUSED
#endif
#ifndef HB_DEBUG_SANITIZE #ifndef HB_DEBUG_SANITIZE
#define HB_DEBUG_SANITIZE (HB_DEBUG+0) #define HB_DEBUG_SANITIZE (HB_DEBUG+0)
#endif #endif
@@ -476,8 +452,6 @@ struct hb_no_trace_t {
#ifndef HB_DEBUG_DISPATCH #ifndef HB_DEBUG_DISPATCH
#define HB_DEBUG_DISPATCH ( \ #define HB_DEBUG_DISPATCH ( \
HB_DEBUG_APPLY + \ HB_DEBUG_APPLY + \
HB_DEBUG_CLOSURE + \
HB_DEBUG_COLLECT_GLYPHS + \
HB_DEBUG_SANITIZE + \ HB_DEBUG_SANITIZE + \
HB_DEBUG_SERIALIZE + \ HB_DEBUG_SERIALIZE + \
HB_DEBUG_SUBSET + \ HB_DEBUG_SUBSET + \

View File

@@ -71,6 +71,8 @@ public:
*fontFileStream = mFontFileStream; *fontFileStream = mFontFileStream;
return S_OK; return S_OK;
} }
virtual ~DWriteFontFileLoader() {}
}; };
class DWriteFontFileStream : public IDWriteFontFileStream class DWriteFontFileStream : public IDWriteFontFileStream
@@ -122,6 +124,8 @@ public:
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE
GetLastWriteTime (OUT UINT64* lastWriteTime) { return E_NOTIMPL; } GetLastWriteTime (OUT UINT64* lastWriteTime) { return E_NOTIMPL; }
virtual ~DWriteFontFileStream() {}
}; };
@@ -133,8 +137,8 @@ struct hb_directwrite_face_data_t
{ {
IDWriteFactory *dwriteFactory; IDWriteFactory *dwriteFactory;
IDWriteFontFile *fontFile; IDWriteFontFile *fontFile;
IDWriteFontFileStream *fontFileStream; DWriteFontFileStream *fontFileStream;
IDWriteFontFileLoader *fontFileLoader; DWriteFontFileLoader *fontFileLoader;
IDWriteFontFace *fontFace; IDWriteFontFace *fontFace;
hb_blob_t *faceBlob; hb_blob_t *faceBlob;
}; };
@@ -281,7 +285,7 @@ public:
public: public:
TextAnalysis (const wchar_t* text, uint32_t textLength, TextAnalysis (const wchar_t* text, uint32_t textLength,
const wchar_t* localeName, DWRITE_READING_DIRECTION readingDirection) const wchar_t* localeName, DWRITE_READING_DIRECTION readingDirection)
: mText (text), mTextLength (textLength), mLocaleName (localeName), : mTextLength (textLength), mText (text), mLocaleName (localeName),
mReadingDirection (readingDirection), mCurrentRun (nullptr) {} mReadingDirection (readingDirection), mCurrentRun (nullptr) {}
~TextAnalysis () ~TextAnalysis ()
{ {
@@ -516,7 +520,6 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
{ {
hb_face_t *face = font->face; hb_face_t *face = font->face;
const hb_directwrite_face_data_t *face_data = face->data.directwrite; 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; IDWriteFactory *dwriteFactory = face_data->dwriteFactory;
IDWriteFontFace *fontFace = face_data->fontFace; IDWriteFontFace *fontFace = face_data->fontFace;
@@ -770,7 +773,7 @@ retry_getglyphs:
/* Calculate visual-clusters. That's what we ship. */ /* Calculate visual-clusters. That's what we ship. */
for (unsigned int i = 0; i < glyphCount; i++) 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++) for (unsigned int i = 0; i < buffer->len; i++)
{ {
uint32_t *p = uint32_t *p =
@@ -778,7 +781,7 @@ retry_getglyphs:
*p = MIN (*p, buffer->info[i].cluster); *p = MIN (*p, buffer->info[i].cluster);
} }
for (unsigned int i = 1; i < glyphCount; i++) 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]; vis_clusters[i] = vis_clusters[i - 1];
#undef utf16_index #undef utf16_index

View File

@@ -28,7 +28,6 @@
#define HB_DSALGS_HH #define HB_DSALGS_HH
#include "hb.hh" #include "hb.hh"
#include "hb-null.hh" #include "hb-null.hh"
@@ -107,7 +106,7 @@ hb_bit_storage (T v)
_BitScanReverse (&where, v); _BitScanReverse (&where, v);
return 1 + where; return 1 + where;
} }
# if _WIN64 # if defined(_WIN64)
if (sizeof (T) <= 8) if (sizeof (T) <= 8)
{ {
unsigned long where; unsigned long where;
@@ -181,7 +180,7 @@ hb_ctz (T v)
_BitScanForward (&where, v); _BitScanForward (&where, v);
return where; return where;
} }
# if _WIN64 # if defined(_WIN64)
if (sizeof (T) <= 8) if (sizeof (T) <= 8)
{ {
unsigned long where; unsigned long where;
@@ -237,10 +236,13 @@ hb_ctz (T v)
template <typename T> template <typename T>
static inline T* hb_addressof (T& arg) 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 */ /* https://en.cppreference.com/w/cpp/memory/addressof */
return reinterpret_cast<T*>( return reinterpret_cast<T*>(
&const_cast<char&>( &const_cast<char&>(
reinterpret_cast<const volatile char&>(arg))); reinterpret_cast<const volatile char&>(arg)));
#pragma GCC diagnostic pop
} }
/* ASCII tag/character handling */ /* 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 struct HbOpOr
{ {
enum { passthru_left = true }; static constexpr bool passthru_left = true;
enum { passthru_right = true }; static constexpr bool passthru_right = true;
template <typename T> static void process (T &o, const T &a, const T &b) { o = a | b; } template <typename T> static void process (T &o, const T &a, const T &b) { o = a | b; }
}; };
struct HbOpAnd struct HbOpAnd
{ {
enum { passthru_left = false }; static constexpr bool passthru_left = false;
enum { passthru_right = false }; static constexpr bool passthru_right = false;
template <typename T> static void process (T &o, const T &a, const T &b) { o = a & b; } template <typename T> static void process (T &o, const T &a, const T &b) { o = a & b; }
}; };
struct HbOpMinus struct HbOpMinus
{ {
enum { passthru_left = true }; static constexpr bool passthru_left = true;
enum { passthru_right = false }; static constexpr bool passthru_right = false;
template <typename T> static void process (T &o, const T &a, const T &b) { o = a & ~b; } template <typename T> static void process (T &o, const T &a, const T &b) { o = a & ~b; }
}; };
struct HbOpXor struct HbOpXor
{ {
enum { passthru_left = true }; static constexpr bool passthru_left = true;
enum { passthru_right = true }; static constexpr bool passthru_right = true;
template <typename T> static void process (T &o, const T &a, const T &b) { o = a ^ b; } template <typename T> static void process (T &o, const T &a, const T &b) { o = a ^ b; }
}; };

View File

@@ -599,7 +599,7 @@ struct hb_face_builder_data_t
hb_blob_t *blob; hb_blob_t *blob;
}; };
hb_vector_t<table_entry_t, 32> tables; hb_vector_t<table_entry_t> tables;
}; };
static hb_face_builder_data_t * 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; 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); hb_blob_destroy (data->tables[i].blob);
data->tables.fini (); data->tables.fini ();
@@ -631,7 +631,7 @@ static hb_blob_t *
_hb_face_builder_data_reference_blob (hb_face_builder_data_t *data) _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; unsigned int face_length = table_count * 16 + 12;
for (unsigned int i = 0; i < table_count; i++) for (unsigned int i = 0; i < table_count; i++)

View File

@@ -139,10 +139,10 @@ hb_font_get_nominal_glyphs_default (hb_font_t *font,
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!font->get_nominal_glyph (*first_unicode, first_glyph)) if (!font->get_nominal_glyph (*first_unicode, first_glyph))
return i; return i;
first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride); first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
} }
return count; 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++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->get_glyph_h_advance (*first_glyph); *first_advance = font->get_glyph_h_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
} }
return; return;
} }
@@ -250,7 +250,7 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font,
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->parent_scale_x_distance (*first_advance); *first_advance = font->parent_scale_x_distance (*first_advance);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (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++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->get_glyph_v_advance (*first_glyph); *first_advance = font->get_glyph_v_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
} }
return; return;
} }
@@ -282,7 +282,7 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font,
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->parent_scale_y_distance (*first_advance); *first_advance = font->parent_scale_y_distance (*first_advance);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
} }
} }

View File

@@ -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 < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode));
done++) done++)
{ {
first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride); first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
} }
/* We don't need to do ft_font->symbol dance here, since HB calls the singular /* 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. */ * 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_advance = (v * mult + (1<<9)) >> 10;
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
} }
} }

View File

@@ -64,7 +64,7 @@ hb_gobject_##name##_get_type () \
} }
#define HB_DEFINE_OBJECT_TYPE(name) \ #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) \ #define HB_DEFINE_VALUE_TYPE(name) \
static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \ static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \
@@ -75,7 +75,7 @@ hb_gobject_##name##_get_type () \
return c; \ return c; \
} \ } \
static void _hb_##name##_destroy (hb_##name##_t *l) { free (l); } \ 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 (buffer)
HB_DEFINE_OBJECT_TYPE (blob) HB_DEFINE_OBJECT_TYPE (blob)

153
gfx/harfbuzz/src/hb-iter.hh Normal file
View File

@@ -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 <typename Iter, typename Item = typename Iter::__item_type__>
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<const iter_t *> (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 <typename Iter, typename Item = typename Iter::__item_type__>
struct hb_sorted_iter_t : hb_iter_t<Iter, Item>
{
protected:
hb_sorted_iter_t () {}
hb_sorted_iter_t (const hb_sorted_iter_t &o) : hb_iter_t<Iter, Item> (o) {}
void operator = (const hb_sorted_iter_t &o HB_UNUSED) {}
};
/* Mixin to fill in what the subclass doesn't provide. */
template <typename iter_t, typename item_t = typename iter_t::__item_type__>
struct hb_iter_mixin_t
{
private:
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
const iter_t* thiz () const { return static_cast<const iter_t *> (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 <typename C, typename V> inline void
hb_fill (const C& c, const V &v)
{
for (typename C::iter_t i (c); i; i++)
hb_assign (*i, v);
}
template <typename S, typename D> inline bool
hb_copy (hb_iter_t<D> &id, hb_iter_t<S> &is)
{
for (; id && is; ++id, ++is)
*id = *is;
return !is;
}
#endif /* HB_ITER_HH */

View File

@@ -64,6 +64,22 @@ static inline const Type& StructAtOffset(const void *P, unsigned int offset)
template<typename Type> template<typename Type>
static inline Type& StructAtOffset(void *P, unsigned int offset) static inline Type& StructAtOffset(void *P, unsigned int offset)
{ return * reinterpret_cast<Type*> ((char *) P + offset); } { return * reinterpret_cast<Type*> ((char *) P + offset); }
template<typename Type>
static inline const Type& StructAtOffsetUnaligned(const void *P, unsigned int offset)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
return * reinterpret_cast<Type*> ((char *) P + offset);
#pragma GCC diagnostic pop
}
template<typename Type>
static inline Type& StructAtOffsetUnaligned(void *P, unsigned int offset)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
return * reinterpret_cast<Type*> ((char *) P + offset);
#pragma GCC diagnostic pop
}
/* StructAfter<T>(X) returns the struct T& that is placed after X. /* StructAfter<T>(X) returns the struct T& that is placed after X.
* Works with X of variable size also. X must implement get_size() */ * 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 DEFINE_SIZE_STATIC(size) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)) \
unsigned int get_size () const { return (size); } \ unsigned int get_size () const { return (size); } \
enum { null_size = (size) }; \ static constexpr unsigned null_size = (size); \
enum { min_size = (size) }; \ static constexpr unsigned min_size = (size); \
enum { static_size = (size) } static constexpr unsigned static_size = (size)
#define DEFINE_SIZE_UNION(size, _member) \ #define DEFINE_SIZE_UNION(size, _member) \
DEFINE_COMPILES_ASSERTION ((void) this->u._member.static_size) \ DEFINE_COMPILES_ASSERTION ((void) this->u._member.static_size) \
DEFINE_INSTANCE_ASSERTION (sizeof(this->u._member) == (size)) \ DEFINE_INSTANCE_ASSERTION (sizeof(this->u._member) == (size)) \
enum { null_size = (size) }; \ static constexpr unsigned null_size = (size); \
enum { min_size = (size) } static constexpr unsigned min_size = (size)
#define DEFINE_SIZE_MIN(size) \ #define DEFINE_SIZE_MIN(size) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \
enum { null_size = (size) }; \ static constexpr unsigned null_size = (size); \
enum { min_size = (size) } static constexpr unsigned min_size = (size)
#define DEFINE_SIZE_UNBOUNDED(size) \ #define DEFINE_SIZE_UNBOUNDED(size) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)) \
enum { min_size = (size) } static constexpr unsigned min_size = (size)
#define DEFINE_SIZE_ARRAY(size, array) \ #define DEFINE_SIZE_ARRAY(size, array) \
DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \ DEFINE_COMPILES_ASSERTION ((void) (array)[0].static_size) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof ((array)[0])) \
enum { null_size = (size) }; \ static constexpr unsigned null_size = (size); \
enum { min_size = (size) } static constexpr unsigned min_size = (size)
#define DEFINE_SIZE_ARRAY_SIZED(size, array) \ #define DEFINE_SIZE_ARRAY_SIZED(size, array) \
unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \ unsigned int get_size () const { return (size - (array).min_size + (array).get_size ()); } \
@@ -134,7 +150,7 @@ static inline Type& StructAfter(TObject &X)
template <typename Context, typename Return, unsigned int MaxDebugDepth> template <typename Context, typename Return, unsigned int MaxDebugDepth>
struct hb_dispatch_context_t struct hb_dispatch_context_t
{ {
enum { max_debug_depth = MaxDebugDepth }; static constexpr unsigned max_debug_depth = MaxDebugDepth;
typedef Return return_t; typedef Return return_t;
template <typename T, typename F> template <typename T, typename F>
bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; } 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; if (!obj) return;
const char *obj_start = (const char *) obj; const char *obj_start = (const char *) obj;
const char *obj_end = (const char *) obj + obj->get_size (); if (unlikely (obj_start < this->start || this->end <= obj_start))
assert (obj_start <= obj_end); /* Must not overflow. */
if (unlikely (obj_end < this->start || this->end < obj_start))
this->start = this->end = nullptr; this->start = this->end = nullptr;
else else
{ {
this->start = MAX (this->start, obj_start); this->start = obj_start;
this->end = MIN (this->end , obj_end ); this->end = obj_start + MIN<uintptr_t> (this->end - obj_start, obj->get_size ());
} }
} }
@@ -667,7 +680,6 @@ template <typename Type>
struct BEInt<Type, 1> struct BEInt<Type, 1>
{ {
public: public:
typedef Type type;
void set (Type V) { v = V; } void set (Type V) { v = V; }
operator Type () const { return v; } operator Type () const { return v; }
private: uint8_t v; private: uint8_t v;
@@ -676,7 +688,6 @@ template <typename Type>
struct BEInt<Type, 2> struct BEInt<Type, 2>
{ {
public: public:
typedef Type type;
void set (Type V) void set (Type V)
{ {
v[0] = (V >> 8) & 0xFF; v[0] = (V >> 8) & 0xFF;
@@ -705,7 +716,6 @@ template <typename Type>
struct BEInt<Type, 3> struct BEInt<Type, 3>
{ {
public: public:
typedef Type type;
void set (Type V) void set (Type V)
{ {
v[0] = (V >> 16) & 0xFF; v[0] = (V >> 16) & 0xFF;

View File

@@ -166,7 +166,7 @@ struct hb_map_t
hb_codepoint_t operator [] (unsigned int key) const hb_codepoint_t operator [] (unsigned int key) const
{ return get (key); } { return get (key); }
enum { INVALID = HB_MAP_VALUE_INVALID }; static constexpr hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID;
void clear () void clear ()
{ {

View File

@@ -93,7 +93,7 @@ struct _hb_assign<T, T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
template <typename T, typename V> template <typename T, typename V>
static inline void hb_assign (T &o, const V v) static inline void hb_assign (T &o, const V v)
{ _hb_assign<T, V, _hb_bool_type<true> >::value (o, v); }; { _hb_assign<T, V, _hb_bool_type<true> >::value (o, v); }
/* /*

View File

@@ -45,7 +45,7 @@
template <typename item_t, typename lock_t> template <typename item_t, typename lock_t>
struct hb_lockable_set_t struct hb_lockable_set_t
{ {
hb_vector_t <item_t, 1> items; hb_vector_t<item_t> items;
void init () { items.init (); } void init () { items.init (); }
@@ -77,9 +77,10 @@ struct hb_lockable_set_t
{ {
l.lock (); l.lock ();
item_t *item = items.find (v); item_t *item = items.find (v);
if (item) { if (item)
{
item_t old = *item; item_t old = *item;
*item = items[items.len - 1]; *item = items[items.length - 1];
items.pop (); items.pop ();
l.unlock (); l.unlock ();
old.fini (); old.fini ();
@@ -113,18 +114,20 @@ struct hb_lockable_set_t
void fini (lock_t &l) void fini (lock_t &l)
{ {
if (!items.len) { if (!items.length)
/* No need for locking. */ {
/* No need to lock. */
items.fini (); items.fini ();
return; return;
} }
l.lock (); l.lock ();
while (items.len) { while (items.length)
item_t old = items[items.len - 1]; {
items.pop (); item_t old = items[items.length - 1];
l.unlock (); items.pop ();
old.fini (); l.unlock ();
l.lock (); old.fini ();
l.lock ();
} }
items.fini (); items.fini ();
l.unlock (); l.unlock ();

View File

@@ -130,7 +130,7 @@ typedef struct OffsetTable
sfnt_version.set (sfnt_tag); sfnt_version.set (sfnt_tag);
/* Take space for numTables, searchRange, entrySelector, RangeShift /* Take space for numTables, searchRange, entrySelector, RangeShift
* and the TableRecords themselves. */ * 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; const char *dir_end = (const char *) c->head;
HBUINT32 *checksum_adjustment = nullptr; HBUINT32 *checksum_adjustment = nullptr;
@@ -154,7 +154,8 @@ typedef struct OffsetTable
c->align (4); c->align (4);
const char *end = (const char *) c->head; 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; head *h = (head *) start;
checksum_adjustment = &h->checkSumAdjustment; checksum_adjustment = &h->checkSumAdjustment;
@@ -173,7 +174,7 @@ typedef struct OffsetTable
/* The following line is a slower version of the following block. */ /* 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, (const char *) c->head - (const char *) this);
checksum.set_for_data (this, dir_end - (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]; TableRecord &rec = tables.arrayZ[i];
checksum.set (checksum + rec.checkSum); checksum.set (checksum + rec.checkSum);
@@ -298,7 +299,7 @@ struct ResourceRecord
HBINT16 nameOffset; /* Offset from beginning of resource name list HBINT16 nameOffset; /* Offset from beginning of resource name list
* to resource name, -1 means there is none. */ * to resource name, -1 means there is none. */
HBUINT8 attrs; /* Resource attributes */ HBUINT8 attrs; /* Resource attributes */
OffsetTo<LArrayOf<HBUINT8>, HBUINT24, false> NNOffsetTo<LArrayOf<HBUINT8>, HBUINT24>
offset; /* Offset from beginning of data block to offset; /* Offset from beginning of data block to
* data for this resource */ * data for this resource */
HBUINT32 reserved; /* Reserved for handle to resource */ HBUINT32 reserved; /* Reserved for handle to resource */
@@ -333,7 +334,7 @@ struct ResourceTypeRecord
protected: protected:
Tag tag; /* Resource type. */ Tag tag; /* Resource type. */
HBUINT16 resCountM1; /* Number of resources minus 1. */ HBUINT16 resCountM1; /* Number of resources minus 1. */
OffsetTo<UnsizedArrayOf<ResourceRecord>, HBUINT16, false> NNOffsetTo<UnsizedArrayOf<ResourceRecord> >
resourcesZ; /* Offset from beginning of resource type list resourcesZ; /* Offset from beginning of resource type list
* to reference item list for this type. */ * to reference item list for this type. */
public: public:
@@ -389,7 +390,7 @@ struct ResourceMap
HBUINT32 reserved1; /* Reserved for handle to next resource map */ HBUINT32 reserved1; /* Reserved for handle to next resource map */
HBUINT16 resreved2; /* Reserved for file reference number */ HBUINT16 resreved2; /* Reserved for file reference number */
HBUINT16 attrs; /* Resource fork attribute */ HBUINT16 attrs; /* Resource fork attribute */
OffsetTo<ArrayOfM1<ResourceTypeRecord>, HBUINT16, false> NNOffsetTo<ArrayOfM1<ResourceTypeRecord> >
typeList; /* Offset from beginning of map to typeList; /* Offset from beginning of map to
* resource type list */ * resource type list */
Offset16 nameList; /* Offset from beginning of map to Offset16 nameList; /* Offset from beginning of map to
@@ -421,10 +422,10 @@ struct ResourceForkHeader
} }
protected: protected:
LOffsetTo<UnsizedArrayOf<HBUINT8>, false> LNNOffsetTo<UnsizedArrayOf<HBUINT8> >
data; /* Offset from beginning of resource fork data; /* Offset from beginning of resource fork
* to resource data */ * to resource data */
LOffsetTo<ResourceMap, false> LNNOffsetTo<ResourceMap >
map; /* Offset from beginning of resource fork map; /* Offset from beginning of resource fork
* to resource map */ * to resource map */
HBUINT32 dataLen; /* Length of resource data */ HBUINT32 dataLen; /* Length of resource data */

View File

@@ -159,7 +159,7 @@ typedef HBUINT16 GlyphID;
/* Script/language-system/feature index */ /* Script/language-system/feature index */
struct Index : HBUINT16 { struct Index : HBUINT16 {
enum { NOT_FOUND_INDEX = 0xFFFFu }; static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFu;
}; };
DECLARE_NULL_NAMESPACE_BYTES (OT, Index); DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
@@ -337,7 +337,10 @@ struct OffsetTo : Offset<OffsetType, has_null>
} }
DEFINE_SIZE_STATIC (sizeof (OffsetType)); DEFINE_SIZE_STATIC (sizeof (OffsetType));
}; };
template <typename Type, bool has_null=true> struct LOffsetTo : OffsetTo<Type, HBUINT32, has_null> {}; /* Partial specializations. */
template <typename Type, bool has_null=true> struct LOffsetTo : OffsetTo<Type, HBUINT32, has_null> {};
template <typename Type, typename OffsetType=HBUINT16 > struct NNOffsetTo : OffsetTo<Type, OffsetType, false> {};
template <typename Type > struct LNNOffsetTo : OffsetTo<Type, HBUINT32, false> {};
template <typename Base, typename OffsetType, bool has_null, typename Type> template <typename Base, typename OffsetType, bool has_null, typename Type>
static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType, has_null> &offset) { return offset (base); } static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType, has_null> &offset) { return offset (base); }
@@ -352,8 +355,8 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
template <typename Type> template <typename Type>
struct UnsizedArrayOf struct UnsizedArrayOf
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; static constexpr unsigned item_size = hb_static_size (Type);
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
@@ -508,8 +511,8 @@ struct SortedUnsizedArrayOf : UnsizedArrayOf<Type>
template <typename Type, typename LenType=HBUINT16> template <typename Type, typename LenType=HBUINT16>
struct ArrayOf struct ArrayOf
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; static constexpr unsigned item_size = hb_static_size (Type);
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); 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<const T> items) bool serialize (hb_serialize_context_t *c, hb_array_t<const T> items)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!serialize (c, items.len))) return_trace (false); if (unlikely (!serialize (c, items.length))) return_trace (false);
for (unsigned int i = 0; i < items.len; i++) for (unsigned int i = 0; i < items.length; i++)
hb_assign (arrayZ[i], items[i]); hb_assign (arrayZ[i], items[i]);
return_trace (true); return_trace (true);
} }
@@ -679,7 +682,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
template <typename Type, typename LenType=HBUINT16> template <typename Type, typename LenType=HBUINT16>
struct HeadlessArrayOf 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); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (HeadlessArrayOf, Type, LenType);
@@ -703,9 +706,9 @@ struct HeadlessArrayOf
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); 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); 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]; arrayZ[i] = items[i];
return_trace (true); return_trace (true);
} }
@@ -888,7 +891,7 @@ struct VarSizedBinSearchHeader
template <typename Type> template <typename Type>
struct VarSizedBinSearchArrayOf struct VarSizedBinSearchArrayOf
{ {
enum { item_size = Type::static_size }; static constexpr unsigned item_size = Type::static_size;
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (VarSizedBinSearchArrayOf, Type);

View File

@@ -55,27 +55,27 @@ inline unsigned int calcOffSize(unsigned int dataSize)
return size; return size;
} }
struct code_pair struct code_pair_t
{ {
hb_codepoint_t code; hb_codepoint_t code;
hb_codepoint_t glyph; hb_codepoint_t glyph;
}; };
typedef hb_vector_t<char, 1> StrBuff; typedef hb_vector_t<unsigned char> str_buff_t;
struct StrBuffArray : hb_vector_t<StrBuff> struct str_buff_vec_t : hb_vector_t<str_buff_t>
{ {
void fini () { SUPER::fini_deep (); } void fini () { SUPER::fini_deep (); }
unsigned int total_size () const unsigned int total_size () const
{ {
unsigned int size = 0; unsigned int size = 0;
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < length; i++)
size += (*this)[i].len; size += (*this)[i].length;
return size; return size;
} }
private: private:
typedef hb_vector_t<StrBuff> SUPER; typedef hb_vector_t<str_buff_t> SUPER;
}; };
/* CFF INDEX */ /* CFF INDEX */
@@ -117,10 +117,10 @@ struct CFFIndex
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
unsigned int offSize_, unsigned int offSize_,
const ByteStrArray &byteArray) const byte_str_array_t &byteArray)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (byteArray.len == 0) if (byteArray.length == 0)
{ {
COUNT *dest = c->allocate_min<COUNT> (); COUNT *dest = c->allocate_min<COUNT> ();
if (unlikely (dest == nullptr)) return_trace (false); if (unlikely (dest == nullptr)) return_trace (false);
@@ -130,15 +130,15 @@ struct CFFIndex
{ {
/* serialize CFFIndex header */ /* serialize CFFIndex header */
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (byteArray.len); this->count.set (byteArray.length);
this->offSize.set (offSize_); this->offSize.set (offSize_);
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.len + 1)))) if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.length + 1))))
return_trace (false); return_trace (false);
/* serialize indices */ /* serialize indices */
unsigned int offset = 1; unsigned int offset = 1;
unsigned int i = 0; unsigned int i = 0;
for (; i < byteArray.len; i++) for (; i < byteArray.length; i++)
{ {
set_offset_at (i, offset); set_offset_at (i, offset);
offset += byteArray[i].get_size (); offset += byteArray[i].get_size ();
@@ -146,12 +146,13 @@ struct CFFIndex
set_offset_at (i, offset); set_offset_at (i, offset);
/* serialize data */ /* 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<ByteStr> (); const byte_str_t &bs = byteArray[i];
if (unlikely (dest == nullptr || unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
!dest->serialize (c, byteArray[i]))) if (unlikely (dest == nullptr))
return_trace (false); return_trace (false);
memcpy (dest, &bs[0], bs.length);
} }
} }
return_trace (true); return_trace (true);
@@ -159,14 +160,14 @@ struct CFFIndex
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
unsigned int offSize_, unsigned int offSize_,
const StrBuffArray &buffArray) const str_buff_vec_t &buffArray)
{ {
ByteStrArray byteArray; byte_str_array_t byteArray;
byteArray.init (); byteArray.init ();
byteArray.resize (buffArray.len); byteArray.resize (buffArray.length);
for (unsigned int i = 0; i < byteArray.len; i++) 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); bool result = this->serialize (c, offSize_, byteArray);
byteArray.fini (); byteArray.fini ();
@@ -205,17 +206,17 @@ struct CFFIndex
return 0; return 0;
} }
const char *data_base () const const unsigned char *data_base () const
{ return (const char *)this + min_size + offset_array_size (); } { return (const unsigned char *)this + min_size + offset_array_size (); }
unsigned int data_size () const { return HBINT8::static_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)) 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 else
return Null(ByteStr); return Null(byte_str_t);
} }
unsigned int get_size () const unsigned int get_size () const
@@ -255,11 +256,11 @@ struct CFFIndex
template <typename COUNT, typename TYPE> template <typename COUNT, typename TYPE>
struct CFFIndexOf : CFFIndex<COUNT> struct CFFIndexOf : CFFIndex<COUNT>
{ {
const ByteStr operator [] (unsigned int index) const const byte_str_t operator [] (unsigned int index) const
{ {
if (likely (index < CFFIndex<COUNT>::count)) if (likely (index < CFFIndex<COUNT>::count))
return ByteStr (CFFIndex<COUNT>::data_base () + CFFIndex<COUNT>::offset_at (index) - 1, CFFIndex<COUNT>::length_at (index)); return byte_str_t (CFFIndex<COUNT>::data_base () + CFFIndex<COUNT>::offset_at (index) - 1, CFFIndex<COUNT>::length_at (index));
return Null(ByteStr); return Null(byte_str_t);
} }
template <typename DATA, typename PARAM1, typename PARAM2> template <typename DATA, typename PARAM1, typename PARAM2>
@@ -363,7 +364,7 @@ struct Dict : UnsizedByteStr
} }
template <typename INTTYPE, int minVal, int maxVal> template <typename INTTYPE, int minVal, int maxVal>
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 // XXX: not sure why but LLVM fails to compile the following 'unlikely' macro invocation
if (/*unlikely*/ (!serialize_int<INTTYPE, minVal, maxVal> (c, intOp, value))) if (/*unlikely*/ (!serialize_int<INTTYPE, minVal, maxVal> (c, intOp, value)))
@@ -383,18 +384,18 @@ struct Dict : UnsizedByteStr
return_trace (true); 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<HBUINT32, 0, 0x7FFFFFFF> (c, op, value, OpCode_longintdict); } { return serialize_int_op<HBUINT32, 0, 0x7FFFFFFF> (c, op, value, OpCode_longintdict); }
static bool serialize_uint2_op (hb_serialize_context_t *c, OpCode op, int value) static bool serialize_uint2_op (hb_serialize_context_t *c, op_code_t op, int value)
{ return serialize_int_op<HBUINT16, 0, 0x7FFF> (c, op, value, OpCode_shortint); } { return serialize_int_op<HBUINT16, 0, 0x7FFF> (c, op, value, OpCode_shortint); }
static bool serialize_offset4_op (hb_serialize_context_t *c, OpCode op, int value) static bool serialize_offset4_op (hb_serialize_context_t *c, op_code_t op, int value)
{ {
return serialize_uint4_op (c, op, 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); return serialize_uint2_op (c, op, value);
} }
@@ -404,7 +405,7 @@ struct TopDict : Dict {};
struct FontDict : Dict {}; struct FontDict : Dict {};
struct PrivateDict : Dict {}; struct PrivateDict : Dict {};
struct TableInfo struct table_info_t
{ {
void init () { offSize = offset = size = 0; } void init () { offSize = offset = size = 0; }
@@ -415,7 +416,7 @@ struct TableInfo
/* used to remap font index or SID from fullset to subset. /* used to remap font index or SID from fullset to subset.
* set to CFF_UNDEF_CODE if excluded from subset */ * set to CFF_UNDEF_CODE if excluded from subset */
struct Remap : hb_vector_t<hb_codepoint_t> struct remap_t : hb_vector_t<hb_codepoint_t>
{ {
void init () { SUPER::init (); } void init () { SUPER::init (); }
@@ -425,7 +426,7 @@ struct Remap : hb_vector_t<hb_codepoint_t>
{ {
if (unlikely (!SUPER::resize (size))) if (unlikely (!SUPER::resize (size)))
return false; return false;
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < length; i++)
(*this)[i] = CFF_UNDEF_CODE; (*this)[i] = CFF_UNDEF_CODE;
count = 0; count = 0;
return true; return true;
@@ -436,14 +437,14 @@ struct Remap : hb_vector_t<hb_codepoint_t>
if (unlikely (!SUPER::resize (size))) if (unlikely (!SUPER::resize (size)))
return false; return false;
unsigned int i; unsigned int i;
for (i = 0; i < len; i++) for (i = 0; i < length; i++)
(*this)[i] = i; (*this)[i] = i;
count = i; count = i;
return true; return true;
} }
bool excludes (hb_codepoint_t id) const 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 bool includes (hb_codepoint_t id) const
{ return !excludes (id); } { return !excludes (id); }
@@ -476,15 +477,15 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
this->count.set (fontDicts.len); this->count.set (fontDicts.length);
this->offSize.set (offSize_); this->offSize.set (offSize_);
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.len + 1)))) if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.length + 1))))
return_trace (false); return_trace (false);
/* serialize font dict offsets */ /* serialize font dict offsets */
unsigned int offset = 1; unsigned int offset = 1;
unsigned int fid = 0; unsigned int fid = 0;
for (; fid < fontDicts.len; fid++) for (; fid < fontDicts.length; fid++)
{ {
CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset);
offset += FontDict::calculate_serialized_size (fontDicts[fid], opszr); offset += FontDict::calculate_serialized_size (fontDicts[fid], opszr);
@@ -492,7 +493,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset);
/* serialize font dicts */ /* 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<FontDict> (); FontDict *dict = c->start_embed<FontDict> ();
if (unlikely (!dict->serialize (c, fontDicts[i], opszr, fontDicts[i]))) if (unlikely (!dict->serialize (c, fontDicts[i], opszr, fontDicts[i])))
@@ -507,9 +508,9 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
unsigned int offSize_, unsigned int offSize_,
const hb_vector_t<DICTVAL> &fontDicts, const hb_vector_t<DICTVAL> &fontDicts,
unsigned int fdCount, unsigned int fdCount,
const Remap &fdmap, const remap_t &fdmap,
OP_SERIALIZER& opszr, OP_SERIALIZER& opszr,
const hb_vector_t<TableInfo> &privateInfos) const hb_vector_t<table_info_t> &privateInfos)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
@@ -521,7 +522,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
/* serialize font dict offsets */ /* serialize font dict offsets */
unsigned int offset = 1; unsigned int offset = 1;
unsigned int fid = 0; unsigned int fid = 0;
for (unsigned i = 0; i < fontDicts.len; i++) for (unsigned i = 0; i < fontDicts.length; i++)
if (fdmap.includes (i)) if (fdmap.includes (i))
{ {
CFFIndexOf<COUNT, FontDict>::set_offset_at (fid++, offset); CFFIndexOf<COUNT, FontDict>::set_offset_at (fid++, offset);
@@ -530,7 +531,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset); CFFIndexOf<COUNT, FontDict>::set_offset_at (fid, offset);
/* serialize font dicts */ /* 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)) if (fdmap.includes (i))
{ {
FontDict *dict = c->start_embed<FontDict> (); FontDict *dict = c->start_embed<FontDict> ();
@@ -545,7 +546,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
const hb_vector_t<DICTVAL> &fontDicts, const hb_vector_t<DICTVAL> &fontDicts,
unsigned int fdCount, unsigned int fdCount,
const Remap &fdmap, const remap_t &fdmap,
OP_SERIALIZER& opszr) OP_SERIALIZER& opszr)
{ {
unsigned int dictsSize = 0; unsigned int dictsSize = 0;
@@ -587,10 +588,10 @@ struct FDSelect0 {
template <typename GID_TYPE, typename FD_TYPE> template <typename GID_TYPE, typename FD_TYPE>
struct FDSelect3_4_Range { 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); 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; GID_TYPE first;
@@ -602,21 +603,21 @@ struct FDSelect3_4_Range {
template <typename GID_TYPE, typename FD_TYPE> template <typename GID_TYPE, typename FD_TYPE>
struct FDSelect3_4 { struct FDSelect3_4 {
unsigned int get_size () const unsigned int get_size () const
{ return GID_TYPE::static_size * 2 + FDSelect3_4_Range<GID_TYPE, FD_TYPE>::static_size * nRanges; } { return GID_TYPE::static_size * 2 + ranges.get_size (); }
bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const
{ {
TRACE_SANITIZE (this); 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); 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))) if (unlikely (ranges[i - 1].first >= ranges[i].first))
return_trace (false); return_trace (false);
if ((0 < i) && unlikely (ranges[i - 1].first >= ranges[i].first))
return_trace (false);
} }
if (unlikely (!sentinel().sanitize (c) || (sentinel() != c->get_num_glyphs ()))) if (unlikely (!sentinel().sanitize (c) || (sentinel() != c->get_num_glyphs ())))
return_trace (false); return_trace (false);
@@ -626,18 +627,19 @@ struct FDSelect3_4 {
hb_codepoint_t get_fd (hb_codepoint_t glyph) const hb_codepoint_t get_fd (hb_codepoint_t glyph) const
{ {
unsigned int i; unsigned int i;
for (i = 1; i < nRanges; i++) for (i = 1; i < nRanges (); i++)
if (glyph < ranges[i].first) if (glyph < ranges[i].first)
break; break;
return (hb_codepoint_t)ranges[i - 1].fd; return (hb_codepoint_t)ranges[i - 1].fd;
} }
GID_TYPE &sentinel () { return StructAfter<GID_TYPE> (ranges[nRanges - 1]); } GID_TYPE &nRanges () { return ranges.len; }
const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges - 1]); } GID_TYPE nRanges () const { return ranges.len; }
GID_TYPE &sentinel () { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
GID_TYPE nRanges; ArrayOf<FDSelect3_4_Range<GID_TYPE, FD_TYPE>, GID_TYPE> ranges;
FDSelect3_4_Range<GID_TYPE, FD_TYPE> ranges[VAR];
/* GID_TYPE sentinel */ /* GID_TYPE sentinel */
DEFINE_SIZE_ARRAY (GID_TYPE::static_size, ranges); DEFINE_SIZE_ARRAY (GID_TYPE::static_size, ranges);

View File

@@ -161,7 +161,7 @@ hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code)
return CFF_UNDEF_SID; return CFF_UNDEF_SID;
} }
struct Bounds struct bounds_t
{ {
void init () void init ()
{ {
@@ -169,7 +169,7 @@ struct Bounds
max.set_int (-0x80000000, -0x80000000); 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 < min.x) min.x = pt.x;
if (pt.x > max.x) max.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; if (pt.y > max.y) max.y = pt.y;
} }
void merge (const Bounds &b) void merge (const bounds_t &b)
{ {
if (empty ()) if (empty ())
*this = b; *this = b;
@@ -190,7 +190,7 @@ struct Bounds
} }
} }
void offset (const Point &delta) void offset (const point_t &delta)
{ {
if (!empty ()) if (!empty ())
{ {
@@ -202,11 +202,11 @@ struct Bounds
bool empty () const bool empty () const
{ return (min.x >= max.x) || (min.y >= max.y); } { return (min.x >= max.x) || (min.y >= max.y); }
Point min; point_t min;
Point max; point_t max;
}; };
struct ExtentsParam struct extents_param_t
{ {
void init (const OT::cff1::accelerator_t *_cff) void init (const OT::cff1::accelerator_t *_cff)
{ {
@@ -220,20 +220,20 @@ struct ExtentsParam
bool is_path_open () const { return path_open; } bool is_path_open () const { return path_open; }
bool path_open; bool path_open;
Bounds bounds; bounds_t bounds;
const OT::cff1::accelerator_t *cff; const OT::cff1::accelerator_t *cff;
}; };
struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv, ExtentsParam> struct cff1_path_procs_extents_t : path_procs_t<cff1_path_procs_extents_t, cff1_cs_interp_env_t, extents_param_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 (); param.end_path ();
env.moveto (pt); 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 ()) if (!param.is_path_open ())
{ {
@@ -244,7 +244,7 @@ struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv,
param.bounds.update (env.get_pt ()); param.bounds.update (env.get_pt ());
} }
static void curve (CFF1CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3) static void curve (cff1_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
{ {
if (!param.is_path_open ()) if (!param.is_path_open ())
{ {
@@ -259,20 +259,20 @@ struct CFF1PathProcs_Extents : PathProcs<CFF1PathProcs_Extents, CFF1CSInterpEnv,
} }
}; };
static bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac=false); static bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, bounds_t &bounds, bool in_seac=false);
struct CFF1CSOpSet_Extents : CFF1CSOpSet<CFF1CSOpSet_Extents, ExtentsParam, CFF1PathProcs_Extents> struct cff1_cs_opset_extents_t : cff1_cs_opset_t<cff1_cs_opset_extents_t, extents_param_t, cff1_path_procs_extents_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 (); unsigned int n = env.argStack.get_count ();
Point delta; point_t delta;
delta.x = env.argStack[n-4]; delta.x = env.argStack[n-4];
delta.y = env.argStack[n-3]; 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 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 ()); 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 if (likely (!env.in_seac && base && accent
&& _get_bounds (param.cff, base, base_bounds, true) && _get_bounds (param.cff, base, base_bounds, true)
&& _get_bounds (param.cff, accent, accent_bounds, true))) && _get_bounds (param.cff, accent, accent_bounds, true)))
@@ -286,17 +286,17 @@ struct CFF1CSOpSet_Extents : CFF1CSOpSet<CFF1CSOpSet_Extents, ExtentsParam, CFF1
} }
}; };
bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, Bounds &bounds, bool in_seac) bool _get_bounds (const OT::cff1::accelerator_t *cff, hb_codepoint_t glyph, bounds_t &bounds, bool in_seac)
{ {
bounds.init (); bounds.init ();
if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false; if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false;
unsigned int fd = cff->fdSelect->get_fd (glyph); unsigned int fd = cff->fdSelect->get_fd (glyph);
CFF1CSInterpreter<CFF1CSOpSet_Extents, ExtentsParam> interp; cff1_cs_interpreter_t<cff1_cs_opset_extents_t, extents_param_t> interp;
const ByteStr str = (*cff->charStrings)[glyph]; const byte_str_t str = (*cff->charStrings)[glyph];
interp.env.init (str, *cff, fd); interp.env.init (str, *cff, fd);
interp.env.set_in_seac (in_seac); interp.env.set_in_seac (in_seac);
ExtentsParam param; extents_param_t param;
param.init (cff); param.init (cff);
if (unlikely (!interp.interpret (param))) return false; if (unlikely (!interp.interpret (param))) return false;
bounds = param.bounds; 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 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)) if (!_get_bounds (this, glyph, bounds))
return false; return false;
@@ -334,7 +334,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_codepoint_t glyph, hb_glyph_extent
return true; return true;
} }
struct GetSeacParam struct get_seac_param_t
{ {
void init (const OT::cff1::accelerator_t *_cff) void init (const OT::cff1::accelerator_t *_cff)
{ {
@@ -350,9 +350,9 @@ struct GetSeacParam
hb_codepoint_t accent; hb_codepoint_t accent;
}; };
struct CFF1CSOpSet_Seac : CFF1CSOpSet<CFF1CSOpSet_Seac, GetSeacParam> struct cff1_cs_opset_seac_t : cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_param_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 (); unsigned int n = env.argStack.get_count ();
hb_codepoint_t base_char = (hb_codepoint_t)env.argStack[n-2].to_int (); 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; if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false;
unsigned int fd = fdSelect->get_fd (glyph); unsigned int fd = fdSelect->get_fd (glyph);
CFF1CSInterpreter<CFF1CSOpSet_Seac, GetSeacParam> interp; cff1_cs_interpreter_t<cff1_cs_opset_seac_t, get_seac_param_t> interp;
const ByteStr str = (*charStrings)[glyph]; const byte_str_t str = (*charStrings)[glyph];
interp.env.init (str, *this, fd); interp.env.init (str, *this, fd);
GetSeacParam param; get_seac_param_t param;
param.init (this); param.init (this);
if (unlikely (!interp.interpret (param))) return false; if (unlikely (!interp.interpret (param))) return false;

View File

@@ -193,20 +193,20 @@ struct Encoding {
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
uint8_t format, uint8_t format,
unsigned int enc_count, unsigned int enc_count,
const hb_vector_t<code_pair>& code_ranges, const hb_vector_t<code_pair_t>& code_ranges,
const hb_vector_t<code_pair>& supp_codes) const hb_vector_t<code_pair_t>& supp_codes)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
Encoding *dest = c->extend_min (*this); Encoding *dest = c->extend_min (*this);
if (unlikely (dest == nullptr)) return_trace (false); 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) if (format == 0)
{ {
Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count); Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count);
if (unlikely (fmt0 == nullptr)) return_trace (false); if (unlikely (fmt0 == nullptr)) return_trace (false);
fmt0->nCodes.set (enc_count); fmt0->nCodes.set (enc_count);
unsigned int glyph = 0; 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; hb_codepoint_t code = code_ranges[i].code;
for (int left = (int)code_ranges[i].glyph; left >= 0; left--) for (int left = (int)code_ranges[i].glyph; left >= 0; left--)
@@ -217,10 +217,10 @@ struct Encoding {
} }
else else
{ {
Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.len); Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length);
if (unlikely (fmt1 == nullptr)) return_trace (false); if (unlikely (fmt1 == nullptr)) return_trace (false);
fmt1->nRanges.set (code_ranges.len); fmt1->nRanges.set (code_ranges.length);
for (unsigned int i = 0; i < code_ranges.len; i++) for (unsigned int i = 0; i < code_ranges.length; i++)
{ {
if (unlikely (!((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF)))) if (unlikely (!((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF))))
return_trace (false); return_trace (false);
@@ -228,12 +228,12 @@ struct Encoding {
fmt1->ranges[i].nLeft.set (code_ranges[i].glyph); 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> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.len); CFF1SuppEncData *suppData = c->allocate_size<CFF1SuppEncData> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length);
if (unlikely (suppData == nullptr)) return_trace (false); if (unlikely (suppData == nullptr)) return_trace (false);
suppData->nSups.set (supp_codes.len); suppData->nSups.set (supp_codes.length);
for (unsigned int i = 0; i < supp_codes.len; i++) for (unsigned int i = 0; i < supp_codes.length; i++)
{ {
suppData->supps[i].code.set (supp_codes[i].code); suppData->supps[i].code.set (supp_codes[i].code);
suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */ suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */
@@ -467,7 +467,7 @@ struct Charset {
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
uint8_t format, uint8_t format,
unsigned int num_glyphs, unsigned int num_glyphs,
const hb_vector_t<code_pair>& sid_ranges) const hb_vector_t<code_pair_t>& sid_ranges)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
Charset *dest = c->extend_min (*this); Charset *dest = c->extend_min (*this);
@@ -478,7 +478,7 @@ struct Charset {
Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1)); Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1));
if (unlikely (fmt0 == nullptr)) return_trace (false); if (unlikely (fmt0 == nullptr)) return_trace (false);
unsigned int glyph = 0; 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; hb_codepoint_t sid = sid_ranges[i].code;
for (int left = (int)sid_ranges[i].glyph; left >= 0; left--) for (int left = (int)sid_ranges[i].glyph; left >= 0; left--)
@@ -487,9 +487,9 @@ struct Charset {
} }
else if (format == 1) else if (format == 1)
{ {
Charset1 *fmt1 = c->allocate_size<Charset1> (Charset1::min_size + Charset1_Range::static_size * sid_ranges.len); Charset1 *fmt1 = c->allocate_size<Charset1> (Charset1::min_size + Charset1_Range::static_size * sid_ranges.length);
if (unlikely (fmt1 == nullptr)) return_trace (false); 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))) if (unlikely (!(sid_ranges[i].glyph <= 0xFF)))
return_trace (false); return_trace (false);
@@ -499,9 +499,9 @@ struct Charset {
} }
else /* format 2 */ else /* format 2 */
{ {
Charset2 *fmt2 = c->allocate_size<Charset2> (Charset2::min_size + Charset2_Range::static_size * sid_ranges.len); Charset2 *fmt2 = c->allocate_size<Charset2> (Charset2::min_size + Charset2_Range::static_size * sid_ranges.length);
if (unlikely (fmt2 == nullptr)) return_trace (false); 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))) if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF)))
return_trace (false); return_trace (false);
@@ -573,7 +573,7 @@ struct Charset {
struct CFF1StringIndex : CFF1Index struct CFF1StringIndex : CFF1Index
{ {
bool serialize (hb_serialize_context_t *c, const CFF1StringIndex &strings, 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); TRACE_SERIALIZE (this);
if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0))) if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0)))
@@ -584,7 +584,7 @@ struct CFF1StringIndex : CFF1Index
return_trace (true); return_trace (true);
} }
ByteStrArray bytesArray; byte_str_array_t bytesArray;
bytesArray.init (); bytesArray.init ();
if (!bytesArray.resize (sidmap.get_count ())) if (!bytesArray.resize (sidmap.get_count ()))
return_trace (false); return_trace (false);
@@ -601,7 +601,7 @@ struct CFF1StringIndex : CFF1Index
} }
/* in parallel to above */ /* 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; offSize = 0;
if ((count == 0) || (sidmap.get_count () == 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 () cff1_top_dict_interp_env_t ()
: NumInterpEnv(), prev_offset(0), last_offset(0) {} : num_interp_env_t(), prev_offset(0), last_offset(0) {}
unsigned int prev_offset; unsigned int prev_offset;
unsigned int last_offset; unsigned int last_offset;
}; };
struct NameDictValues struct name_dict_values_t
{ {
enum NameDictValIndex enum name_dict_val_index_t
{ {
version, version,
notice, notice,
@@ -657,7 +657,7 @@ struct NameDictValues
unsigned int operator[] (unsigned int i) const unsigned int operator[] (unsigned int i) const
{ assert (i < ValCount); return values[i]; } { 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) { switch (op) {
default: // can't happen - just make some compiler happy default: // can't happen - just make some compiler happy
@@ -685,16 +685,16 @@ struct NameDictValues
unsigned int values[ValCount]; unsigned int values[ValCount];
}; };
struct CFF1TopDictVal : OpStr struct cff1_top_dict_val_t : op_str_t
{ {
unsigned int last_arg_offset; unsigned int last_arg_offset;
}; };
struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal> struct cff1_top_dict_values_t : top_dict_values_t<cff1_top_dict_val_t>
{ {
void init () void init ()
{ {
TopDictValues<CFF1TopDictVal>::init (); top_dict_values_t<cff1_top_dict_val_t>::init ();
nameSIDs.init (); nameSIDs.init ();
ros_supplement = 0; ros_supplement = 0;
@@ -704,12 +704,12 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
FDSelectOffset = 0; FDSelectOffset = 0;
privateDictInfo.init (); privateDictInfo.init ();
} }
void fini () { TopDictValues<CFF1TopDictVal>::fini (); } void fini () { top_dict_values_t<cff1_top_dict_val_t>::fini (); }
bool is_CID () const 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_offset;
unsigned int ros_supplement; unsigned int ros_supplement;
unsigned int cidCount; unsigned int cidCount;
@@ -717,14 +717,14 @@ struct CFF1TopDictValues : TopDictValues<CFF1TopDictVal>
unsigned int EncodingOffset; unsigned int EncodingOffset;
unsigned int CharsetOffset; unsigned int CharsetOffset;
unsigned int FDSelectOffset; unsigned int FDSelectOffset;
TableInfo privateDictInfo; table_info_t privateDictInfo;
}; };
struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal> struct cff1_top_dict_opset_t : top_dict_opset_t<cff1_top_dict_val_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 */ val.last_arg_offset = (env.last_offset-1) - dictval.opStart; /* offset to the last argument */
switch (op) { switch (op) {
@@ -736,7 +736,7 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
case OpCode_Weight: case OpCode_Weight:
case OpCode_PostScript: case OpCode_PostScript:
case OpCode_BaseFontName: 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 (); env.clear_args ();
break; break;
case OpCode_isFixedPitch: case OpCode_isFixedPitch:
@@ -765,8 +765,8 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
case OpCode_ROS: case OpCode_ROS:
dictval.ros_supplement = env.argStack.pop_uint (); dictval.ros_supplement = env.argStack.pop_uint ();
dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint (); dictval.nameSIDs[name_dict_values_t::ordering] = env.argStack.pop_uint ();
dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint (); dictval.nameSIDs[name_dict_values_t::registry] = env.argStack.pop_uint ();
env.clear_args (); env.clear_args ();
break; break;
@@ -794,8 +794,8 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
break; break;
default: default:
env.last_offset = env.substr.offset; env.last_offset = env.str_ref.offset;
TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval); top_dict_opset_t<cff1_top_dict_val_t>::process_op (op, env, dictval);
/* Record this operand below if stack is empty, otherwise done */ /* Record this operand below if stack is empty, otherwise done */
if (!env.argStack.is_empty ()) return; if (!env.argStack.is_empty ()) return;
break; break;
@@ -803,27 +803,27 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
if (unlikely (env.in_error ())) return; if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr, val); dictval.add_op (op, env.str_ref, val);
} }
}; };
struct CFF1FontDictValues : DictValues<OpStr> struct cff1_font_dict_values_t : dict_values_t<op_str_t>
{ {
void init () void init ()
{ {
DictValues<OpStr>::init (); dict_values_t<op_str_t>::init ();
privateDictInfo.init (); privateDictInfo.init ();
fontName = CFF_UNDEF_SID; fontName = CFF_UNDEF_SID;
} }
void fini () { DictValues<OpStr>::fini (); } void fini () { dict_values_t<op_str_t>::fini (); }
TableInfo privateDictInfo; table_info_t privateDictInfo;
unsigned int fontName; 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) { switch (op) {
case OpCode_FontName: case OpCode_FontName:
@@ -841,36 +841,36 @@ struct CFF1FontDictOpSet : DictOpSet
break; break;
default: default:
DictOpSet::process_op (op, env); dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return; if (!env.argStack.is_empty ()) return;
break; break;
} }
if (unlikely (env.in_error ())) return; if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr); dictval.add_op (op, env.str_ref);
} }
}; };
template <typename VAL> template <typename VAL>
struct CFF1PrivateDictValues_Base : DictValues<VAL> struct cff1_private_dict_values_base_t : dict_values_t<VAL>
{ {
void init () void init ()
{ {
DictValues<VAL>::init (); dict_values_t<VAL>::init ();
subrsOffset = 0; subrsOffset = 0;
localSubrs = &Null(CFF1Subrs); localSubrs = &Null(CFF1Subrs);
} }
void fini () { DictValues<VAL>::fini (); } void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const unsigned int calculate_serialized_size () const
{ {
unsigned int size = 0; unsigned int size = 0;
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++) for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs) if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
else else
size += DictValues<VAL>::get_value (i).str.len; size += dict_values_t<VAL>::get_value (i).str.length;
return size; return size;
} }
@@ -878,14 +878,14 @@ struct CFF1PrivateDictValues_Base : DictValues<VAL>
const CFF1Subrs *localSubrs; const CFF1Subrs *localSubrs;
}; };
typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset; typedef cff1_private_dict_values_base_t<op_str_t> cff1_private_dict_values_subset_t;
typedef CFF1PrivateDictValues_Base<NumDictVal> CFF1PrivateDictValues; typedef cff1_private_dict_values_base_t<num_dict_val_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 (); val.init ();
switch (op) { switch (op) {
@@ -917,20 +917,20 @@ struct CFF1PrivateDictOpSet : DictOpSet
break; break;
default: default:
DictOpSet::process_op (op, env); dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return; if (!env.argStack.is_empty ()) return;
break; break;
} }
if (unlikely (env.in_error ())) return; 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) { switch (op) {
case OpCode_BlueValues: case OpCode_BlueValues:
@@ -959,25 +959,24 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet
break; break;
default: default:
DictOpSet::process_op (op, env); dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return; if (!env.argStack.is_empty ()) return;
break; break;
} }
if (unlikely (env.in_error ())) return; if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr); dictval.add_op (op, env.str_ref);
} }
}; };
typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues, CFF1TopDictInterpEnv> CFF1TopDict_Interpreter; typedef dict_interpreter_t<cff1_top_dict_opset_t, cff1_top_dict_values_t, cff1_top_dict_interp_env_t> cff1_top_dict_interpreter_t;
typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter; typedef dict_interpreter_t<cff1_font_dict_opset_t, cff1_font_dict_values_t> cff1_font_dict_interpreter_t;
typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_Interpreter;
typedef CFF1Index CFF1NameIndex; typedef CFF1Index CFF1NameIndex;
typedef CFF1IndexOf<TopDict> CFF1TopDictIndex; typedef CFF1IndexOf<TopDict> CFF1TopDictIndex;
}; /* namespace CFF */ } /* namespace CFF */
namespace OT { namespace OT {
@@ -985,7 +984,7 @@ using namespace CFF;
struct cff1 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 bool sanitize (hb_sanitize_context_t *c) const
{ {
@@ -1023,9 +1022,9 @@ struct cff1
{ fini (); return; } { fini (); return; }
{ /* parse top dict */ { /* parse top dict */
const ByteStr topDictStr = (*topDictIndex)[0]; const byte_str_t topDictStr = (*topDictIndex)[0];
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
CFF1TopDict_Interpreter top_interp; cff1_top_dict_interpreter_t top_interp;
top_interp.env.init (topDictStr); top_interp.env.init (topDictStr);
topDict.init (); topDict.init ();
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
@@ -1082,24 +1081,24 @@ struct cff1
{ {
for (unsigned int i = 0; i < fdCount; i++) 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; } if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
CFF1FontDictValues *font; cff1_font_dict_values_t *font;
CFF1FontDict_Interpreter font_interp; cff1_font_dict_interpreter_t font_interp;
font_interp.env.init (fontDictStr); font_interp.env.init (fontDictStr);
font = fontDicts.push (); font = fontDicts.push ();
if (unlikely (font == &Crap(CFF1FontDictValues))) { fini (); return; } if (unlikely (font == &Crap(cff1_font_dict_values_t))) { fini (); return; }
font->init (); font->init ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; } if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
PRIVDICTVAL *priv = &privateDicts[i]; PRIVDICTVAL *priv = &privateDicts[i];
const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size); const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp; dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr); priv_interp.env.init (privDictStr);
priv->init (); priv->init ();
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset); priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (&privDictStr, priv->subrsOffset);
if (priv->localSubrs != &Null(CFF1Subrs) && if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc))) unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
@@ -1107,17 +1106,17 @@ struct cff1
} }
else /* non-CID */ else /* non-CID */
{ {
CFF1TopDictValues *font = &topDict; cff1_top_dict_values_t *font = &topDict;
PRIVDICTVAL *priv = &privateDicts[0]; PRIVDICTVAL *priv = &privateDicts[0];
const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size); const byte_str_t privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp; dict_interpreter_t<PRIVOPSET, PRIVDICTVAL> priv_interp;
priv_interp.env.init (privDictStr); priv_interp.env.init (privDictStr);
priv->init (); priv->init ();
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset); priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (&privDictStr, priv->subrsOffset);
if (priv->localSubrs != &Null(CFF1Subrs) && if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc))) unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
@@ -1167,20 +1166,20 @@ struct cff1
const CFF1FDSelect *fdSelect; const CFF1FDSelect *fdSelect;
unsigned int fdCount; unsigned int fdCount;
CFF1TopDictValues topDict; cff1_top_dict_values_t topDict;
hb_vector_t<CFF1FontDictValues> fontDicts; hb_vector_t<cff1_font_dict_values_t> fontDicts;
hb_vector_t<PRIVDICTVAL> privateDicts; hb_vector_t<PRIVDICTVAL> privateDicts;
unsigned int num_glyphs; unsigned int num_glyphs;
}; };
struct accelerator_t : accelerator_templ_t<CFF1PrivateDictOpSet, CFF1PrivateDictValues> struct accelerator_t : accelerator_templ_t<cff1_private_dict_opset_t, cff1_private_dict_values_t>
{ {
HB_INTERNAL bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const; 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; HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
}; };
struct accelerator_subset_t : accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> struct accelerator_subset_t : accelerator_templ_t<cff1_private_dict_opset_subset, cff1_private_dict_values_subset_t>
{ {
void init (hb_face_t *face) void init (hb_face_t *face)
{ {
@@ -1257,7 +1256,7 @@ struct cff1
const Encoding *encoding; const Encoding *encoding;
private: private:
typedef accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> SUPER; typedef accelerator_templ_t<cff1_private_dict_opset_subset, cff1_private_dict_values_subset_t> SUPER;
}; };
bool subset (hb_subset_plan_t *plan) const bool subset (hb_subset_plan_t *plan) const

View File

@@ -29,7 +29,7 @@
using namespace CFF; using namespace CFF;
struct ExtentsParam struct extents_param_t
{ {
void init () void init ()
{ {
@@ -44,7 +44,7 @@ struct ExtentsParam
void end_path () { path_open = false; } void end_path () { path_open = false; }
bool is_path_open () const { return path_open; } 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 < min_x) min_x = pt.x;
if (pt.x > max_x) max_x = pt.x; if (pt.x > max_x) max_x = pt.x;
@@ -53,21 +53,21 @@ struct ExtentsParam
} }
bool path_open; bool path_open;
Number min_x; number_t min_x;
Number min_y; number_t min_y;
Number max_x; number_t max_x;
Number max_y; number_t max_y;
}; };
struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv, ExtentsParam> struct cff2_path_procs_extents_t : path_procs_t<cff2_path_procs_extents_t, cff2_cs_interp_env_t, extents_param_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 (); param.end_path ();
env.moveto (pt); 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 ()) if (!param.is_path_open ())
{ {
@@ -78,7 +78,7 @@ struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv,
param.update_bounds (env.get_pt ()); param.update_bounds (env.get_pt ());
} }
static void curve (CFF2CSInterpEnv &env, ExtentsParam& param, const Point &pt1, const Point &pt2, const Point &pt3) static void curve (cff2_cs_interp_env_t &env, extents_param_t& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
{ {
if (!param.is_path_open ()) if (!param.is_path_open ())
{ {
@@ -93,7 +93,7 @@ struct CFF2PathProcs_Extents : PathProcs<CFF2PathProcs_Extents, CFF2CSInterpEnv,
} }
}; };
struct CFF2CSOpSet_Extents : CFF2CSOpSet<CFF2CSOpSet_Extents, ExtentsParam, CFF2PathProcs_Extents> {}; struct cff2_cs_opset_extents_t : cff2_cs_opset_t<cff2_cs_opset_extents_t, extents_param_t, cff2_path_procs_extents_t> {};
bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
@@ -104,10 +104,10 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
unsigned int num_coords; unsigned int num_coords;
const int *coords = hb_font_get_var_coords_normalized (font, &num_coords); const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
unsigned int fd = fdSelect->get_fd (glyph); unsigned int fd = fdSelect->get_fd (glyph);
CFF2CSInterpreter<CFF2CSOpSet_Extents, ExtentsParam> interp; cff2_cs_interpreter_t<cff2_cs_opset_extents_t, extents_param_t> interp;
const ByteStr str = (*charStrings)[glyph]; const byte_str_t str = (*charStrings)[glyph];
interp.env.init (str, *this, fd, coords, num_coords); interp.env.init (str, *this, fd, coords, num_coords);
ExtentsParam param; extents_param_t param;
param.init (); param.init ();
if (unlikely (!interp.interpret (param))) return false; if (unlikely (!interp.interpret (param))) return false;

View File

@@ -136,22 +136,22 @@ struct CFF2VariationStore
DEFINE_SIZE_MIN (2 + VariationStore::min_size); DEFINE_SIZE_MIN (2 + VariationStore::min_size);
}; };
struct CFF2TopDictValues : TopDictValues<> struct cff2_top_dict_values_t : top_dict_values_t<>
{ {
void init () void init ()
{ {
TopDictValues<>::init (); top_dict_values_t<>::init ();
vstoreOffset = 0; vstoreOffset = 0;
FDSelectOffset = 0; FDSelectOffset = 0;
} }
void fini () { TopDictValues<>::fini (); } void fini () { top_dict_values_t<>::fini (); }
unsigned int calculate_serialized_size () const unsigned int calculate_serialized_size () const
{ {
unsigned int size = 0; unsigned int size = 0;
for (unsigned int i = 0; i < get_count (); i++) 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) switch (op)
{ {
case OpCode_vstore: case OpCode_vstore:
@@ -159,7 +159,7 @@ struct CFF2TopDictValues : TopDictValues<>
size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
break; break;
default: default:
size += TopDictValues<>::calculate_serialized_op_size (get_value (i)); size += top_dict_values_t<>::calculate_serialized_op_size (get_value (i));
break; break;
} }
} }
@@ -170,16 +170,16 @@ struct CFF2TopDictValues : TopDictValues<>
unsigned int FDSelectOffset; 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) { switch (op) {
case OpCode_FontMatrix: case OpCode_FontMatrix:
{ {
DictVal val; dict_val_t val;
val.init (); val.init ();
dictval.add_op (op, env.substr); dictval.add_op (op, env.str_ref);
env.clear_args (); env.clear_args ();
} }
break; break;
@@ -201,27 +201,27 @@ struct CFF2TopDictOpSet : TopDictOpSet<>
if (unlikely (env.in_error ())) return; 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<OpStr> struct cff2_font_dict_values_t : dict_values_t<op_str_t>
{ {
void init () void init ()
{ {
DictValues<OpStr>::init (); dict_values_t<op_str_t>::init ();
privateDictInfo.init (); privateDictInfo.init ();
} }
void fini () { DictValues<OpStr>::fini (); } void fini () { dict_values_t<op_str_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) { switch (op) {
case OpCode_Private: case OpCode_Private:
@@ -238,33 +238,33 @@ struct CFF2FontDictOpSet : DictOpSet
if (unlikely (env.in_error ())) return; if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr); dictval.add_op (op, env.str_ref);
} }
private: private:
typedef DictOpSet SUPER; typedef dict_opset_t SUPER;
}; };
template <typename VAL> template <typename VAL>
struct CFF2PrivateDictValues_Base : DictValues<VAL> struct cff2_private_dict_values_base_t : dict_values_t<VAL>
{ {
void init () void init ()
{ {
DictValues<VAL>::init (); dict_values_t<VAL>::init ();
subrsOffset = 0; subrsOffset = 0;
localSubrs = &Null(CFF2Subrs); localSubrs = &Null(CFF2Subrs);
ivs = 0; ivs = 0;
} }
void fini () { DictValues<VAL>::fini (); } void fini () { dict_values_t<VAL>::fini (); }
unsigned int calculate_serialized_size () const unsigned int calculate_serialized_size () const
{ {
unsigned int size = 0; unsigned int size = 0;
for (unsigned int i = 0; i < DictValues<VAL>::get_count; i++) for (unsigned int i = 0; i < dict_values_t<VAL>::get_count; i++)
if (DictValues<VAL>::get_value (i).op == OpCode_Subrs) if (dict_values_t<VAL>::get_value (i).op == OpCode_Subrs)
size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs);
else else
size += DictValues<VAL>::get_value (i).str.len; size += dict_values_t<VAL>::get_value (i).str.length;
return size; return size;
} }
@@ -273,14 +273,14 @@ struct CFF2PrivateDictValues_Base : DictValues<VAL>
unsigned int ivs; unsigned int ivs;
}; };
typedef CFF2PrivateDictValues_Base<OpStr> CFF2PrivateDictValues_Subset; typedef cff2_private_dict_values_base_t<op_str_t> cff2_private_dict_values_subset_t;
typedef CFF2PrivateDictValues_Base<NumDictVal> CFF2PrivateDictValues; typedef cff2_private_dict_values_base_t<num_dict_val_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; ivs = 0;
seen_vsindex = false; seen_vsindex = false;
} }
@@ -302,11 +302,11 @@ struct CFF2PrivDictInterpEnv : NumInterpEnv
bool seen_vsindex; 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 (); val.init ();
switch (op) { switch (op) {
@@ -341,20 +341,20 @@ struct CFF2PrivateDictOpSet : DictOpSet
break; break;
default: default:
DictOpSet::process_op (op, env); dict_opset_t::process_op (op, env);
if (!env.argStack.is_empty ()) return; if (!env.argStack.is_empty ()) return;
break; break;
} }
if (unlikely (env.in_error ())) return; 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) { switch (op) {
case OpCode_BlueValues: case OpCode_BlueValues:
@@ -390,17 +390,17 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet
if (unlikely (env.in_error ())) return; if (unlikely (env.in_error ())) return;
dictval.add_op (op, env.substr); dictval.add_op (op, env.str_ref);
} }
private: private:
typedef DictOpSet SUPER; typedef dict_opset_t SUPER;
}; };
typedef DictInterpreter<CFF2TopDictOpSet, CFF2TopDictValues> CFF2TopDict_Interpreter; typedef dict_interpreter_t<cff2_top_dict_opset_t, cff2_top_dict_values_t> cff2_top_dict_interpreter_t;
typedef DictInterpreter<CFF2FontDictOpSet, CFF2FontDictValues> CFF2FontDict_Interpreter; typedef dict_interpreter_t<cff2_font_dict_opset_t, cff2_font_dict_values_t> cff2_font_dict_interpreter_t;
}; /* namespace CFF */ } /* namespace CFF */
namespace OT { namespace OT {
@@ -408,7 +408,7 @@ using namespace CFF;
struct cff2 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 bool sanitize (hb_sanitize_context_t *c) const
{ {
@@ -438,9 +438,9 @@ struct cff2
{ fini (); return; } { fini (); return; }
{ /* parse top dict */ { /* 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; } if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
CFF2TopDict_Interpreter top_interp; cff2_top_dict_interpreter_t top_interp;
top_interp.env.init (topDictStr); top_interp.env.init (topDictStr);
topDict.init (); topDict.init ();
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
@@ -469,24 +469,24 @@ struct cff2
/* parse font dicts and gather private dicts */ /* parse font dicts and gather private dicts */
for (unsigned int i = 0; i < fdCount; i++) 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; } if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
CFF2FontDictValues *font; cff2_font_dict_values_t *font;
CFF2FontDict_Interpreter font_interp; cff2_font_dict_interpreter_t font_interp;
font_interp.env.init (fontDictStr); font_interp.env.init (fontDictStr);
font = fontDicts.push (); font = fontDicts.push ();
if (unlikely (font == &Crap(CFF2FontDictValues))) { fini (); return; } if (unlikely (font == &Crap(cff2_font_dict_values_t))) { fini (); return; }
font->init (); font->init ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; } if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
const ByteStr privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); const byte_str_t privDictStr (StructAtOffsetOrNull<UnsizedByteStr> (cff2, font->privateDictInfo.offset), font->privateDictInfo.size);
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
DictInterpreter<PRIVOPSET, PRIVDICTVAL, CFF2PrivDictInterpEnv> priv_interp; dict_interpreter_t<PRIVOPSET, PRIVDICTVAL, cff2_priv_dict_interp_env_t> priv_interp;
priv_interp.env.init(privDictStr); priv_interp.env.init(privDictStr);
privateDicts[i].init (); privateDicts[i].init ();
if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; } if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; }
privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (privDictStr.str, privateDicts[i].subrsOffset); privateDicts[i].localSubrs = &StructAtOffsetOrNull<CFF2Subrs> (&privDictStr[0], privateDicts[i].subrsOffset);
if (privateDicts[i].localSubrs != &Null(CFF2Subrs) && if (privateDicts[i].localSubrs != &Null(CFF2Subrs) &&
unlikely (!privateDicts[i].localSubrs->sanitize (&sc))) unlikely (!privateDicts[i].localSubrs->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
@@ -496,6 +496,7 @@ struct cff2
void fini () void fini ()
{ {
sc.end_processing (); sc.end_processing ();
topDict.fini ();
fontDicts.fini_deep (); fontDicts.fini_deep ();
privateDicts.fini_deep (); privateDicts.fini_deep ();
hb_blob_destroy (blob); hb_blob_destroy (blob);
@@ -505,32 +506,32 @@ struct cff2
bool is_valid () const { return blob != nullptr; } bool is_valid () const { return blob != nullptr; }
protected: protected:
hb_blob_t *blob; hb_blob_t *blob;
hb_sanitize_context_t sc; hb_sanitize_context_t sc;
public: public:
CFF2TopDictValues topDict; cff2_top_dict_values_t topDict;
const CFF2Subrs *globalSubrs; const CFF2Subrs *globalSubrs;
const CFF2VariationStore *varStore; const CFF2VariationStore *varStore;
const CFF2CharStrings *charStrings; const CFF2CharStrings *charStrings;
const CFF2FDArray *fdArray; const CFF2FDArray *fdArray;
const CFF2FDSelect *fdSelect; const CFF2FDSelect *fdSelect;
unsigned int fdCount; unsigned int fdCount;
hb_vector_t<CFF2FontDictValues> fontDicts; hb_vector_t<cff2_font_dict_values_t> fontDicts;
hb_vector_t<PRIVDICTVAL> privateDicts; hb_vector_t<PRIVDICTVAL> privateDicts;
unsigned int num_glyphs; unsigned int num_glyphs;
}; };
struct accelerator_t : accelerator_templ_t<CFF2PrivateDictOpSet, CFF2PrivateDictValues> struct accelerator_t : accelerator_templ_t<cff2_private_dict_opset_t, cff2_private_dict_values_t>
{ {
HB_INTERNAL bool get_extents (hb_font_t *font, HB_INTERNAL bool get_extents (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents) const; hb_glyph_extents_t *extents) const;
}; };
typedef accelerator_templ_t<CFF2PrivateDictOpSet_Subset, CFF2PrivateDictValues_Subset> accelerator_subset_t; typedef accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t> accelerator_subset_t;
bool subset (hb_subset_plan_t *plan) const bool subset (hb_subset_plan_t *plan) const
{ {
@@ -551,9 +552,9 @@ struct cff2
} }
public: public:
FixedVersion<HBUINT8> version; /* Version of CFF2 table. set to 0x0200u */ FixedVersion<HBUINT8> version; /* Version of CFF2 table. set to 0x0200u */
OffsetTo<TopDict, HBUINT8, false> topDict; /* headerSize = Offset to Top DICT. */ NNOffsetTo<TopDict, HBUINT8> topDict; /* headerSize = Offset to Top DICT. */
HBUINT16 topDictSize; /* Top DICT size */ HBUINT16 topDictSize; /* Top DICT size */
public: public:
DEFINE_SIZE_STATIC (5); DEFINE_SIZE_STATIC (5);

View File

@@ -92,23 +92,23 @@ struct CmapSubtableFormat4
this->format.set (4); this->format.set (4);
this->length.set (get_sub_table_size (segments)); this->length.set (get_sub_table_size (segments));
this->segCountX2.set (segments.len * 2); this->segCountX2.set (segments.length * 2);
this->entrySelector.set (MAX (1u, hb_bit_storage (segments.len)) - 1); this->entrySelector.set (MAX (1u, hb_bit_storage (segments.length)) - 1);
this->searchRange.set (2 * (1u << this->entrySelector)); this->searchRange.set (2 * (1u << this->entrySelector));
this->rangeShift.set (segments.len * 2 > this->searchRange this->rangeShift.set (segments.length * 2 > this->searchRange
? 2 * segments.len - this->searchRange ? 2 * segments.length - this->searchRange
: 0); : 0);
HBUINT16 *end_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.len); HBUINT16 *end_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.length);
c->allocate_size<HBUINT16> (HBUINT16::static_size); // 2 bytes of padding. c->allocate_size<HBUINT16> (HBUINT16::static_size); // 2 bytes of padding.
HBUINT16 *start_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.len); HBUINT16 *start_count = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.length);
HBINT16 *id_delta = c->allocate_size<HBINT16> (HBUINT16::static_size * segments.len); HBINT16 *id_delta = c->allocate_size<HBINT16> (HBUINT16::static_size * segments.length);
HBUINT16 *id_range_offset = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.len); HBUINT16 *id_range_offset = c->allocate_size<HBUINT16> (HBUINT16::static_size * segments.length);
if (id_range_offset == nullptr) if (id_range_offset == nullptr)
return_trace (false); 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); end_count[i].set (segments[i].end_code);
start_count[i].set (segments[i].start_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<segment_plan> &segments) static size_t get_sub_table_size (const hb_vector_t<segment_plan> &segments)
{ {
size_t segment_size = 0; 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 // Parallel array entries
segment_size += segment_size +=
@@ -532,7 +532,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
static size_t get_sub_table_size (const hb_vector_t<CmapSubtableLongGroup> &groups) static size_t get_sub_table_size (const hb_vector_t<CmapSubtableLongGroup> &groups)
{ {
return 16 + 12 * groups.len; return 16 + 12 * groups.length;
} }
static bool create_sub_table_plan (const hb_subset_plan_t *plan, static bool create_sub_table_plan (const hb_subset_plan_t *plan,
@@ -560,7 +560,7 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
} }
DEBUG_MSG(SUBSET, nullptr, "cmap"); 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]; 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)); 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 struct cmap
{ {
enum { tableTag = HB_OT_TAG_cmap }; static constexpr hb_tag_t tableTag = HB_OT_TAG_cmap;
struct subset_plan struct subset_plan
{ {
@@ -1054,8 +1054,8 @@ struct cmap
done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph); done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph);
done++) done++)
{ {
first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride); first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
} }
return done; return done;
} }

View File

@@ -56,7 +56,7 @@ struct SmallGlyphMetrics
extents->x_bearing = bearingX; extents->x_bearing = bearingX;
extents->y_bearing = bearingY; extents->y_bearing = bearingY;
extents->width = width; extents->width = width;
extents->height = -height; extents->height = - (hb_position_t) height;
} }
HBUINT8 height; HBUINT8 height;
@@ -283,7 +283,7 @@ struct BitmapSizeTable
} }
protected: protected:
LOffsetTo<IndexSubtableArray, false> LNNOffsetTo<IndexSubtableArray>
indexSubtableArrayOffset; indexSubtableArrayOffset;
HBUINT32 indexTablesSize; HBUINT32 indexTablesSize;
HBUINT32 numberOfIndexSubtables; HBUINT32 numberOfIndexSubtables;
@@ -332,7 +332,7 @@ struct CBLC
{ {
friend struct CBDT; 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 bool sanitize (hb_sanitize_context_t *c) const
{ {
@@ -378,7 +378,7 @@ struct CBLC
struct CBDT struct CBDT
{ {
enum { tableTag = HB_OT_TAG_CBDT }; static constexpr hb_tag_t tableTag = HB_OT_TAG_CBDT;
struct accelerator_t struct accelerator_t
{ {

View File

@@ -87,7 +87,7 @@ struct BaseGlyphRecord
struct COLR struct COLR
{ {
enum { tableTag = HB_OT_TAG_COLR }; static constexpr hb_tag_t tableTag = HB_OT_TAG_COLR;
bool has_data () const { return numBaseGlyphs; } bool has_data () const { return numBaseGlyphs; }
@@ -104,14 +104,14 @@ struct COLR
if (count) if (count)
{ {
hb_array_t<const LayerRecord> segment_layers = glyph_layers.sub_array (start_offset, *count); hb_array_t<const LayerRecord> segment_layers = glyph_layers.sub_array (start_offset, *count);
*count = segment_layers.len; *count = segment_layers.length;
for (unsigned int i = 0; i < segment_layers.len; i++) for (unsigned int i = 0; i < segment_layers.length; i++)
{ {
layers[i].glyph = segment_layers.arrayZ[i].glyphId; layers[i].glyph = segment_layers.arrayZ[i].glyphId;
layers[i].color_index = segment_layers.arrayZ[i].colorIdx; 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 bool sanitize (hb_sanitize_context_t *c) const
@@ -125,9 +125,9 @@ struct COLR
protected: protected:
HBUINT16 version; /* Table version number (starts at 0). */ HBUINT16 version; /* Table version number (starts at 0). */
HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */
LOffsetTo<SortedUnsizedArrayOf<BaseGlyphRecord>, false> LNNOffsetTo<SortedUnsizedArrayOf<BaseGlyphRecord> >
baseGlyphsZ; /* Offset to Base Glyph records. */ baseGlyphsZ; /* Offset to Base Glyph records. */
LOffsetTo<UnsizedArrayOf<LayerRecord>, false> LNNOffsetTo<UnsizedArrayOf<LayerRecord> >
layersZ; /* Offset to Layer Records. */ layersZ; /* Offset to Layer Records. */
HBUINT16 numLayers; /* Number of Layer Records. */ HBUINT16 numLayers; /* Number of Layer Records. */
public: public:

View File

@@ -87,15 +87,15 @@ struct CPALV1Tail
} }
protected: protected:
LOffsetTo<UnsizedArrayOf<HBUINT32>, false> LNNOffsetTo<UnsizedArrayOf<HBUINT32> >
paletteFlagsZ; /* Offset from the beginning of CPAL table to paletteFlagsZ; /* Offset from the beginning of CPAL table to
* the Palette Type Array. Set to 0 if no array * the Palette Type Array. Set to 0 if no array
* is provided. */ * is provided. */
LOffsetTo<UnsizedArrayOf<NameID>, false> LNNOffsetTo<UnsizedArrayOf<NameID> >
paletteLabelsZ; /* Offset from the beginning of CPAL table to paletteLabelsZ; /* Offset from the beginning of CPAL table to
* the palette labels array. Set to 0 if no * the palette labels array. Set to 0 if no
* array is provided. */ * array is provided. */
LOffsetTo<UnsizedArrayOf<NameID>, false> LNNOffsetTo<UnsizedArrayOf<NameID> >
colorLabelsZ; /* Offset from the beginning of CPAL table to colorLabelsZ; /* Offset from the beginning of CPAL table to
* the color labels array. Set to 0 * the color labels array. Set to 0
* if no array is provided. */ * if no array is provided. */
@@ -107,7 +107,7 @@ typedef HBUINT32 BGRAColor;
struct CPAL struct CPAL
{ {
enum { tableTag = HB_OT_TAG_CPAL }; static constexpr hb_tag_t tableTag = HB_OT_TAG_CPAL;
bool has_data () const { return numPalettes; } bool has_data () const { return numPalettes; }
@@ -176,7 +176,7 @@ struct CPAL
HBUINT16 numPalettes; /* Number of palettes in the table. */ HBUINT16 numPalettes; /* Number of palettes in the table. */
HBUINT16 numColorRecords; /* Total number of color records, combined for HBUINT16 numColorRecords; /* Total number of color records, combined for
* all palettes. */ * all palettes. */
LOffsetTo<UnsizedArrayOf<BGRAColor>, false> LNNOffsetTo<UnsizedArrayOf<BGRAColor> >
colorRecordsZ; /* Offset from the beginning of CPAL table to colorRecordsZ; /* Offset from the beginning of CPAL table to
* the first ColorRecord. */ * the first ColorRecord. */
UnsizedArrayOf<HBUINT16> UnsizedArrayOf<HBUINT16>

View File

@@ -130,7 +130,7 @@ struct SBIXStrike
struct sbix struct sbix
{ {
enum { tableTag = HB_OT_TAG_sbix }; static constexpr hb_tag_t tableTag = HB_OT_TAG_sbix;
bool has_data () const { return version; } bool has_data () const { return version; }

View File

@@ -62,7 +62,7 @@ struct SVGDocumentIndexEntry
* this index entry. */ * this index entry. */
HBUINT16 endGlyphID; /* The last glyph ID in the range described by HBUINT16 endGlyphID; /* The last glyph ID in the range described by
* this index entry. Must be >= startGlyphID. */ * this index entry. Must be >= startGlyphID. */
LOffsetTo<UnsizedArrayOf<HBUINT8>, false> LNNOffsetTo<UnsizedArrayOf<HBUINT8> >
svgDoc; /* Offset from the beginning of the SVG Document Index svgDoc; /* Offset from the beginning of the SVG Document Index
* to an SVG document. Must be non-zero. */ * to an SVG document. Must be non-zero. */
HBUINT32 svgDocLength; /* Length of the SVG document. HBUINT32 svgDocLength; /* Length of the SVG document.
@@ -73,7 +73,7 @@ struct SVGDocumentIndexEntry
struct SVG struct SVG
{ {
enum { tableTag = HB_OT_TAG_SVG }; static constexpr hb_tag_t tableTag = HB_OT_TAG_SVG;
bool has_data () const { return svgDocEntries; } bool has_data () const { return svgDocEntries; }

View File

@@ -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++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font)); *first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font));
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (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++) for (unsigned int i = 0; i < count; i++)
{ {
*first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font)); *first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font));
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride); first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride); first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
} }
} }

View File

@@ -57,7 +57,7 @@ struct GaspRange
struct gasp 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 const GaspRange &get_gasp_range (unsigned int i) const
{ return gaspRanges[i]; } { return gaspRanges[i]; }

View File

@@ -45,7 +45,7 @@ struct loca
{ {
friend struct glyf; 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 bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const
{ {
@@ -71,7 +71,7 @@ struct loca
struct glyf 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 bool sanitize (hb_sanitize_context_t *c HB_UNUSED) const
{ {
@@ -200,8 +200,8 @@ struct glyf
}; };
static bool get_iterator (const char * glyph_data, static bool get_iterator (const char * glyph_data,
unsigned int length, unsigned int length,
CompositeGlyphHeader::Iterator *iterator /* OUT */) CompositeGlyphHeader::Iterator *iterator /* OUT */)
{ {
if (length < GlyphHeader::static_size) if (length < GlyphHeader::static_size)
return false; /* Empty glyph; zero extents. */ return false; /* Empty glyph; zero extents. */
@@ -355,8 +355,8 @@ struct glyf
} }
bool get_offsets (hb_codepoint_t glyph, bool get_offsets (hb_codepoint_t glyph,
unsigned int *start_offset /* OUT */, unsigned int *start_offset /* OUT */,
unsigned int *end_offset /* OUT */) const unsigned int *end_offset /* OUT */) const
{ {
if (unlikely (glyph >= num_glyphs)) if (unlikely (glyph >= num_glyphs))
return false; return false;

View File

@@ -57,7 +57,7 @@ struct DeviceRecord
} }
unsigned int len () const unsigned int len () const
{ return this->subset_plan->glyphs.len; } { return this->subset_plan->glyphs.length; }
const HBUINT8* operator [] (unsigned int i) const const HBUINT8* operator [] (unsigned int i) const
{ {
@@ -119,7 +119,7 @@ struct DeviceRecord
struct hdmx struct hdmx
{ {
enum { tableTag = HB_OT_TAG_hdmx }; static constexpr hb_tag_t tableTag = HB_OT_TAG_hdmx;
unsigned int get_size () const unsigned int get_size () const
{ return min_size + numRecords * sizeDeviceRecord; } { return min_size + numRecords * sizeDeviceRecord; }
@@ -140,7 +140,7 @@ struct hdmx
this->version.set (source_hdmx->version); this->version.set (source_hdmx->version);
this->numRecords.set (source_hdmx->numRecords); 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++) 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) 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 bool subset (hb_subset_plan_t *plan) const

View File

@@ -45,7 +45,7 @@ struct head
{ {
friend struct OffsetTable; friend struct OffsetTable;
enum { tableTag = HB_OT_TAG_head }; static constexpr hb_tag_t tableTag = HB_OT_TAG_head;
unsigned int get_upem () const unsigned int get_upem () const
{ {

View File

@@ -86,10 +86,10 @@ struct _hea
}; };
struct hhea : _hea<hhea> { struct hhea : _hea<hhea> {
enum { tableTag = HB_OT_TAG_hhea }; static constexpr hb_tag_t tableTag = HB_OT_TAG_hhea;
}; };
struct vhea : _hea<vhea> { struct vhea : _hea<vhea> {
enum { tableTag = HB_OT_TAG_vhea }; static constexpr hb_tag_t tableTag = HB_OT_TAG_vhea;
}; };

View File

@@ -94,7 +94,7 @@ struct hmtxvmtx
/* All the trailing glyphs with the same advance can use one LongMetric /* All the trailing glyphs with the same advance can use one LongMetric
* and just keep LSB */ * and just keep LSB */
hb_vector_t<hb_codepoint_t> &gids = plan->glyphs; hb_vector_t<hb_codepoint_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]); unsigned int last_advance = _mtx.get_advance (gids[num_advances - 1]);
while (num_advances > 1 && while (num_advances > 1 &&
last_advance == _mtx.get_advance (gids[num_advances - 2])) last_advance == _mtx.get_advance (gids[num_advances - 2]))
@@ -104,14 +104,14 @@ struct hmtxvmtx
/* alloc the new table */ /* alloc the new table */
size_t dest_sz = num_advances * 4 size_t dest_sz = num_advances * 4
+ (gids.len - num_advances) * 2; + (gids.length - num_advances) * 2;
void *dest = (void *) malloc (dest_sz); void *dest = (void *) malloc (dest_sz);
if (unlikely (!dest)) if (unlikely (!dest))
{ {
return false; 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 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); const char *source_table = hb_blob_get_data (_mtx.table.get_blob (), nullptr);
// Copy everything over // Copy everything over
@@ -120,7 +120,7 @@ struct hmtxvmtx
char * dest_pos = (char *) dest; char * dest_pos = (char *) dest;
bool failed = false; 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] */ /* the last metric or the one for gids[i] */
LongMetric *src_metric = old_metrics + MIN ((hb_codepoint_t) _mtx.num_advances - 1, 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<hmtx, hhea> { struct hmtx : hmtxvmtx<hmtx, hhea> {
enum { tableTag = HB_OT_TAG_hmtx }; static constexpr hb_tag_t tableTag = HB_OT_TAG_hmtx;
enum { variationsTag = HB_OT_TAG_HVAR }; static constexpr hb_tag_t variationsTag = HB_OT_TAG_HVAR;
enum { os2Tag = HB_OT_TAG_OS2 }; static constexpr hb_tag_t os2Tag = HB_OT_TAG_OS2;
}; };
struct vmtx : hmtxvmtx<vmtx, vhea> { struct vmtx : hmtxvmtx<vmtx, vhea> {
enum { tableTag = HB_OT_TAG_vmtx }; static constexpr hb_tag_t tableTag = HB_OT_TAG_vmtx;
enum { variationsTag = HB_OT_TAG_VVAR }; static constexpr hb_tag_t variationsTag = HB_OT_TAG_VVAR;
enum { os2Tag = HB_TAG_NONE }; static constexpr hb_tag_t os2Tag = HB_TAG_NONE;
}; };
struct hmtx_accelerator_t : hmtx::accelerator_t {}; struct hmtx_accelerator_t : hmtx::accelerator_t {};

View File

@@ -160,7 +160,7 @@ struct KernSubTable
struct KernOTSubTableHeader struct KernOTSubTableHeader
{ {
enum { apple = false }; static constexpr bool apple = false;
typedef AAT::ObsoleteTypes Types; typedef AAT::ObsoleteTypes Types;
unsigned int tuple_count () const { return 0; } unsigned int tuple_count () const { return 0; }
@@ -197,8 +197,8 @@ struct KernOT : AAT::KerxTable<KernOT>
{ {
friend struct AAT::KerxTable<KernOT>; friend struct AAT::KerxTable<KernOT>;
enum { tableTag = HB_OT_TAG_kern }; static constexpr hb_tag_t tableTag = HB_OT_TAG_kern;
enum { minVersion = 0u }; static constexpr unsigned minVersion = 0u;
typedef KernOTSubTableHeader SubTableHeader; typedef KernOTSubTableHeader SubTableHeader;
typedef SubTableHeader::Types Types; typedef SubTableHeader::Types Types;
@@ -215,7 +215,7 @@ struct KernOT : AAT::KerxTable<KernOT>
struct KernAATSubTableHeader struct KernAATSubTableHeader
{ {
enum { apple = true }; static constexpr bool apple = true;
typedef AAT::ObsoleteTypes Types; typedef AAT::ObsoleteTypes Types;
unsigned int tuple_count () const { return 0; } unsigned int tuple_count () const { return 0; }
@@ -252,8 +252,8 @@ struct KernAAT : AAT::KerxTable<KernAAT>
{ {
friend struct AAT::KerxTable<KernAAT>; friend struct AAT::KerxTable<KernAAT>;
enum { tableTag = HB_OT_TAG_kern }; static constexpr hb_tag_t tableTag = HB_OT_TAG_kern;
enum { minVersion = 0x00010000u }; static constexpr unsigned minVersion = 0x00010000u;
typedef KernAATSubTableHeader SubTableHeader; typedef KernAATSubTableHeader SubTableHeader;
typedef SubTableHeader::Types Types; typedef SubTableHeader::Types Types;
@@ -269,7 +269,7 @@ struct KernAAT : AAT::KerxTable<KernAAT>
struct kern 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; } bool has_data () const { return u.version32; }
unsigned int get_type () const { return u.major; } unsigned int get_type () const { return u.major; }

View File

@@ -464,7 +464,7 @@ struct Axis
struct BASE 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 const Axis &get_axis (hb_direction_t direction) const
{ return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; } { return HB_DIRECTION_IS_VERTICAL (direction) ? this+vAxis : this+hAxis; }

View File

@@ -900,14 +900,14 @@ struct CoverageFormat2
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!glyphs.len)) if (unlikely (!glyphs.length))
{ {
rangeRecord.len.set (0); rangeRecord.len.set (0);
return_trace (true); return_trace (true);
} }
unsigned int num_ranges = 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]) if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++; num_ranges++;
rangeRecord.len.set (num_ranges); rangeRecord.len.set (num_ranges);
@@ -916,7 +916,7 @@ struct CoverageFormat2
unsigned int range = 0; unsigned int range = 0;
rangeRecord[range].start = glyphs[0]; rangeRecord[range].start = glyphs[0];
rangeRecord[range].value.set (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]) if (glyphs[i - 1] + 1 != glyphs[i])
{ {
@@ -1048,10 +1048,10 @@ struct Coverage
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
unsigned int num_ranges = 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]) if (glyphs[i - 1] + 1 != glyphs[i])
num_ranges++; 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) switch (u.format)
{ {
@@ -1199,7 +1199,7 @@ struct ClassDefFormat1
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!glyphs.len)) if (unlikely (!glyphs.length))
{ {
startGlyph.set (0); startGlyph.set (0);
classValue.len.set (0); classValue.len.set (0);
@@ -1207,13 +1207,13 @@ struct ClassDefFormat1
} }
hb_codepoint_t glyph_min = glyphs[0]; 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); startGlyph.set (glyph_min);
classValue.len.set (glyph_max - glyph_min + 1); classValue.len.set (glyph_max - glyph_min + 1);
if (unlikely (!c->extend (classValue))) return_trace (false); 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]; classValue[glyphs[i] - glyph_min] = klasses[i];
return_trace (true); return_trace (true);
@@ -1239,7 +1239,7 @@ struct ClassDefFormat1
} }
c->serializer->propagate_error (glyphs, klasses); c->serializer->propagate_error (glyphs, klasses);
ClassDef_serialize (c->serializer, glyphs, klasses); ClassDef_serialize (c->serializer, glyphs, klasses);
return_trace (glyphs.len); return_trace (glyphs.length);
} }
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
@@ -1335,14 +1335,14 @@ struct ClassDefFormat2
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!glyphs.len)) if (unlikely (!glyphs.length))
{ {
rangeRecord.len.set (0); rangeRecord.len.set (0);
return_trace (true); return_trace (true);
} }
unsigned int num_ranges = 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] || if (glyphs[i - 1] + 1 != glyphs[i] ||
klasses[i - 1] != klasses[i]) klasses[i - 1] != klasses[i])
num_ranges++; num_ranges++;
@@ -1352,7 +1352,7 @@ struct ClassDefFormat2
unsigned int range = 0; unsigned int range = 0;
rangeRecord[range].start = glyphs[0]; rangeRecord[range].start = glyphs[0];
rangeRecord[range].value.set (klasses[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] || if (glyphs[i - 1] + 1 != glyphs[i] ||
klasses[i - 1] != klasses[i]) klasses[i - 1] != klasses[i])
@@ -1390,7 +1390,7 @@ struct ClassDefFormat2
} }
c->serializer->propagate_error (glyphs, klasses); c->serializer->propagate_error (glyphs, klasses);
ClassDef_serialize (c->serializer, glyphs, klasses); ClassDef_serialize (c->serializer, glyphs, klasses);
return_trace (glyphs.len); return_trace (glyphs.length);
} }
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
@@ -1485,13 +1485,13 @@ struct ClassDef
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
unsigned int format = 2; unsigned int format = 2;
if (glyphs.len) if (glyphs.length)
{ {
hb_codepoint_t glyph_min = glyphs[0]; 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; 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] || if (glyphs[i - 1] + 1 != glyphs[i] ||
klasses[i - 1] != klasses[i]) klasses[i - 1] != klasses[i])
num_ranges++; num_ranges++;
@@ -1949,7 +1949,7 @@ struct FeatureVariationRecord
struct FeatureVariations struct FeatureVariations
{ {
enum { NOT_FOUND_INDEX = 0xFFFFFFFFu }; static constexpr unsigned NOT_FOUND_INDEX = 0xFFFFFFFFu;
bool find_index (const int *coords, unsigned int coord_len, bool find_index (const int *coords, unsigned int coord_len,
unsigned int *index) const unsigned int *index) const

View File

@@ -64,7 +64,7 @@ struct AttachList
if (point_count) if (point_count)
{ {
hb_array_t<const HBUINT16> array = points.sub_array (start_offset, point_count); hb_array_t<const HBUINT16> 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++) for (unsigned int i = 0; i < count; i++)
point_array[i] = array[i]; point_array[i] = array[i];
} }
@@ -221,7 +221,7 @@ struct LigGlyph
if (caret_count) if (caret_count)
{ {
hb_array_t <const OffsetTo<CaretValue> > array = carets.sub_array (start_offset, caret_count); hb_array_t <const OffsetTo<CaretValue> > 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++) for (unsigned int i = 0; i < count; i++)
caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store); caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store);
} }
@@ -341,7 +341,7 @@ struct MarkGlyphSets
struct GDEF struct GDEF
{ {
enum { tableTag = HB_OT_TAG_GDEF }; static constexpr hb_tag_t tableTag = HB_OT_TAG_GDEF;
enum GlyphClasses { enum GlyphClasses {
UnclassifiedGlyph = 0, UnclassifiedGlyph = 0,

View File

@@ -84,16 +84,16 @@ struct ValueFormat : HBUINT16
HBINT16 yAdvance; /* Vertical adjustment for advance--in HBINT16 yAdvance; /* Vertical adjustment for advance--in
* design units (only used for vertical * design units (only used for vertical
* writing) */ * writing) */
Offset xPlaDevice; /* Offset to Device table for OffsetTo<Device> xPlaDevice; /* Offset to Device table for
* horizontal placement--measured from * horizontal placement--measured from
* beginning of PosTable (may be NULL) */ * beginning of PosTable (may be NULL) */
Offset yPlaDevice; /* Offset to Device table for vertical OffsetTo<Device> yPlaDevice; /* Offset to Device table for vertical
* placement--measured from beginning * placement--measured from beginning
* of PosTable (may be NULL) */ * of PosTable (may be NULL) */
Offset xAdvDevice; /* Offset to Device table for OffsetTo<Device> xAdvDevice; /* Offset to Device table for
* horizontal advance--measured from * horizontal advance--measured from
* beginning of PosTable (may be NULL) */ * beginning of PosTable (may be NULL) */
Offset yAdvDevice; /* Offset to Device table for vertical OffsetTo<Device> yAdvDevice; /* Offset to Device table for vertical
* advance--measured from beginning of * advance--measured from beginning of
* PosTable (may be NULL) */ * PosTable (may be NULL) */
#endif #endif
@@ -177,13 +177,13 @@ struct ValueFormat : HBUINT16
{ return *CastP<OffsetTo<Device> > (value); } { return *CastP<OffsetTo<Device> > (value); }
static const OffsetTo<Device>& get_device (const Value* value, bool *worked=nullptr) static const OffsetTo<Device>& get_device (const Value* value, bool *worked=nullptr)
{ {
if (worked) *worked |= *value; if (worked) *worked |= bool (*value);
return *CastP<OffsetTo<Device> > (value); return *CastP<OffsetTo<Device> > (value);
} }
static const HBINT16& get_short (const Value* value, bool *worked=nullptr) static const HBINT16& get_short (const Value* value, bool *worked=nullptr)
{ {
if (worked) *worked |= *value; if (worked) *worked |= bool (*value);
return *CastP<HBINT16> (value); return *CastP<HBINT16> (value);
} }
@@ -472,10 +472,7 @@ struct SinglePosFormat1
{ return (this+coverage).intersects (glyphs); } { return (this+coverage).intersects (glyphs); }
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { if (unlikely (!(this+coverage).add_coverage (c->input))) return; }
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
}
const Coverage &get_coverage () const { return this+coverage; } const Coverage &get_coverage () const { return this+coverage; }
@@ -527,10 +524,7 @@ struct SinglePosFormat2
{ return (this+coverage).intersects (glyphs); } { return (this+coverage).intersects (glyphs); }
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { if (unlikely (!(this+coverage).add_coverage (c->input))) return; }
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
}
const Coverage &get_coverage () const { return this+coverage; } const Coverage &get_coverage () const { return this+coverage; }
@@ -642,7 +636,6 @@ struct PairSet
void collect_glyphs (hb_collect_glyphs_context_t *c, void collect_glyphs (hb_collect_glyphs_context_t *c,
const ValueFormat *valueFormats) const const ValueFormat *valueFormats) const
{ {
TRACE_COLLECT_GLYPHS (this);
unsigned int len1 = valueFormats[0].get_len (); unsigned int len1 = valueFormats[0].get_len ();
unsigned int len2 = valueFormats[1].get_len (); unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2); 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 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;
unsigned int count = pairSet.len; unsigned int count = pairSet.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
@@ -820,7 +812,6 @@ struct PairPosFormat2
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return; if (unlikely (!(this+coverage).add_coverage (c->input))) return;
if (unlikely (!(this+classDef2).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); } { return (this+coverage).intersects (glyphs); }
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { if (unlikely (!(this+coverage).add_coverage (c->input))) return; }
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
}
const Coverage &get_coverage () const { return this+coverage; } const Coverage &get_coverage () const { return this+coverage; }
@@ -1138,7 +1126,6 @@ struct MarkBasePosFormat1
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+markCoverage).add_coverage (c->input))) return; if (unlikely (!(this+markCoverage).add_coverage (c->input))) return;
if (unlikely (!(this+baseCoverage).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 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+markCoverage).add_coverage (c->input))) return;
if (unlikely (!(this+ligatureCoverage).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 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+mark1Coverage).add_coverage (c->input))) return;
if (unlikely (!(this+mark2Coverage).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 hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { return dispatch (c); }
TRACE_COLLECT_GLYPHS (this);
return_trace (dispatch (c));
}
template <typename set_t> template <typename set_t>
void add_coverage (set_t *glyphs) const void add_coverage (set_t *glyphs) const
@@ -1619,7 +1601,7 @@ struct PosLookup : Lookup
struct GPOS : GSUBGPOS 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 const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); } { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }

View File

@@ -46,7 +46,6 @@ struct SingleSubstFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{ {
/* TODO Switch to range-based API to work around malicious fonts. /* 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 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;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
{ {
@@ -120,7 +118,7 @@ struct SingleSubstFormat1
} }
c->serializer->propagate_error (from, to); c->serializer->propagate_error (from, to);
SingleSubst_serialize (c->serializer, from, to); SingleSubst_serialize (c->serializer, from, to);
return_trace (from.len); return_trace (from.length);
} }
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
@@ -147,7 +145,6 @@ struct SingleSubstFormat2
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = substitute.len; unsigned int count = substitute.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) 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 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;
unsigned int count = substitute.len; unsigned int count = substitute.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
@@ -218,7 +214,7 @@ struct SingleSubstFormat2
} }
c->serializer->propagate_error (from, to); c->serializer->propagate_error (from, to);
SingleSubst_serialize (c->serializer, from, to); SingleSubst_serialize (c->serializer, from, to);
return_trace (from.len); return_trace (from.length);
} }
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
@@ -249,12 +245,12 @@ struct SingleSubst
if (unlikely (!c->extend_min (u.format))) return_trace (false); if (unlikely (!c->extend_min (u.format))) return_trace (false);
unsigned int format = 2; unsigned int format = 2;
int delta = 0; int delta = 0;
if (glyphs.len) if (glyphs.length)
{ {
format = 1; format = 1;
/* TODO(serialize) check for wrap-around */ /* TODO(serialize) check for wrap-around */
delta = substitutes[0] - glyphs[0]; 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])) { if (delta != (int) (substitutes[i] - glyphs[i])) {
format = 2; format = 2;
break; break;
@@ -298,17 +294,13 @@ struct Sequence
{ {
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = substitute.len; unsigned int count = substitute.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
c->out->add (substitute[i]); c->out->add (substitute[i]);
} }
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { c->output->add_array (substitute.arrayZ, substitute.len); }
TRACE_COLLECT_GLYPHS (this);
c->output->add_array (substitute.arrayZ, substitute.len);
}
bool apply (hb_ot_apply_context_t *c) const bool apply (hb_ot_apply_context_t *c) const
{ {
@@ -369,7 +361,6 @@ struct MultipleSubstFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = sequence.len; unsigned int count = sequence.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) 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 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;
unsigned int count = sequence.len; unsigned int count = sequence.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
@@ -414,8 +404,8 @@ struct MultipleSubstFormat1
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!sequence.serialize (c, glyphs.len))) return_trace (false); if (unlikely (!sequence.serialize (c, glyphs.length))) return_trace (false);
for (unsigned int i = 0; i < glyphs.len; i++) for (unsigned int i = 0; i < glyphs.length; i++)
{ {
unsigned int substitute_len = substitute_len_list[i]; unsigned int substitute_len = substitute_len_list[i];
if (unlikely (!sequence[i].serialize (c, this) if (unlikely (!sequence[i].serialize (c, this)
@@ -490,17 +480,13 @@ struct AlternateSet
{ {
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = alternates.len; unsigned int count = alternates.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
c->out->add (alternates[i]); c->out->add (alternates[i]);
} }
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ { c->output->add_array (alternates.arrayZ, alternates.len); }
TRACE_COLLECT_GLYPHS (this);
c->output->add_array (alternates.arrayZ, alternates.len);
}
bool apply (hb_ot_apply_context_t *c) const bool apply (hb_ot_apply_context_t *c) const
{ {
@@ -555,7 +541,6 @@ struct AlternateSubstFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = alternateSet.len; unsigned int count = alternateSet.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) 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 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;
unsigned int count = alternateSet.len; unsigned int count = alternateSet.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
@@ -604,8 +588,8 @@ struct AlternateSubstFormat1
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!alternateSet.serialize (c, glyphs.len))) return_trace (false); if (unlikely (!alternateSet.serialize (c, glyphs.length))) return_trace (false);
for (unsigned int i = 0; i < glyphs.len; i++) for (unsigned int i = 0; i < glyphs.length; i++)
{ {
unsigned int alternate_len = alternate_len_list[i]; unsigned int alternate_len = alternate_len_list[i];
if (unlikely (!alternateSet[i].serialize (c, this) if (unlikely (!alternateSet[i].serialize (c, this)
@@ -690,7 +674,6 @@ struct Ligature
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = component.lenP1; unsigned int count = component.lenP1;
for (unsigned int i = 1; i < count; i++) for (unsigned int i = 1; i < count; i++)
if (!c->glyphs->has (component[i])) if (!c->glyphs->has (component[i]))
@@ -700,7 +683,6 @@ struct Ligature
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
c->input->add_array (component.arrayZ, component.lenP1 ? component.lenP1 - 1 : 0); c->input->add_array (component.arrayZ, component.lenP1 ? component.lenP1 - 1 : 0);
c->output->add (ligGlyph); c->output->add (ligGlyph);
} }
@@ -798,7 +780,6 @@ struct LigatureSet
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int num_ligs = ligature.len; unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++) for (unsigned int i = 0; i < num_ligs; i++)
(this+ligature[i]).closure (c); (this+ligature[i]).closure (c);
@@ -806,7 +787,6 @@ struct LigatureSet
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
unsigned int num_ligs = ligature.len; unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++) for (unsigned int i = 0; i < num_ligs; i++)
(this+ligature[i]).collect_glyphs (c); (this+ligature[i]).collect_glyphs (c);
@@ -841,12 +821,12 @@ struct LigatureSet
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
hb_array_t<const GlyphID> ligatures, hb_array_t<const GlyphID> ligatures,
hb_array_t<const unsigned int> component_count_list, hb_array_t<const unsigned int> component_count_list,
hb_array_t<const GlyphID> component_list /* Starting from second for each ligature */) hb_array_t<const GlyphID> &component_list /* Starting from second for each ligature */)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!ligature.serialize (c, ligatures.len))) return_trace (false); if (unlikely (!ligature.serialize (c, ligatures.length))) return_trace (false);
for (unsigned int i = 0; i < ligatures.len; i++) for (unsigned int i = 0; i < ligatures.length; i++)
{ {
unsigned int component_count = MAX<int> (component_count_list[i] - 1, 0); unsigned int component_count = MAX<int> (component_count_list[i] - 1, 0);
if (unlikely (!ligature[i].serialize (c, this) if (unlikely (!ligature[i].serialize (c, this)
@@ -891,7 +871,6 @@ struct LigatureSubstFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
unsigned int count = ligatureSet.len; unsigned int count = ligatureSet.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) 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 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;
unsigned int count = ligatureSet.len; unsigned int count = ligatureSet.len;
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ()) for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
@@ -947,8 +925,8 @@ struct LigatureSubstFormat1
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
if (unlikely (!ligatureSet.serialize (c, first_glyphs.len))) return_trace (false); if (unlikely (!ligatureSet.serialize (c, first_glyphs.length))) return_trace (false);
for (unsigned int i = 0; i < first_glyphs.len; i++) for (unsigned int i = 0; i < first_glyphs.length; i++)
{ {
unsigned int ligature_count = ligature_per_first_glyph_count_list[i]; unsigned int ligature_count = ligature_per_first_glyph_count_list[i];
if (unlikely (!ligatureSet[i].serialize (c, this) if (unlikely (!ligatureSet[i].serialize (c, this)
@@ -958,8 +936,6 @@ struct LigatureSubstFormat1
component_list))) return_trace (false); component_list))) return_trace (false);
ligatures_list += ligature_count; ligatures_list += ligature_count;
component_count_list += ligature_count; component_count_list += ligature_count;
for (unsigned int i = 0; i < ligature_count; i++)
component_list += MAX<int> (component_count_list[i] - 1, 0);
} }
return_trace (coverage.serialize (c, this).serialize (c, first_glyphs)); return_trace (coverage.serialize (c, this).serialize (c, first_glyphs));
} }
@@ -1070,7 +1046,6 @@ struct ReverseChainSingleSubstFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack); const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
unsigned int count; unsigned int count;
@@ -1098,7 +1073,6 @@ struct ReverseChainSingleSubstFormat1
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
if (unlikely (!(this+coverage).add_coverage (c->input))) return; if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count; 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 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)) 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); c->set_recurse_func (dispatch_closure_recurse_func);
@@ -1314,14 +1287,13 @@ struct SubstLookup : Lookup
c->flush (); c->flush ();
return_trace (ret); return ret;
} }
hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>);
return_trace (dispatch (c)); return dispatch (c);
} }
template <typename set_t> template <typename set_t>
@@ -1438,7 +1410,7 @@ struct SubstLookup : Lookup
struct GSUB : GSUBGPOS 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 const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }

View File

@@ -59,7 +59,7 @@ struct hb_intersects_context_t :
}; };
struct hb_closure_context_t : struct hb_closure_context_t :
hb_dispatch_context_t<hb_closure_context_t, hb_void_t, HB_DEBUG_CLOSURE> hb_dispatch_context_t<hb_closure_context_t, hb_void_t, 0>
{ {
const char *get_name () { return "CLOSURE"; } const char *get_name () { return "CLOSURE"; }
typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); 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 : struct hb_collect_glyphs_context_t :
hb_dispatch_context_t<hb_collect_glyphs_context_t, hb_void_t, HB_DEBUG_COLLECT_GLYPHS> hb_dispatch_context_t<hb_collect_glyphs_context_t, hb_void_t, 0>
{ {
const char *get_name () { return "COLLECT_GLYPHS"; } const char *get_name () { return "COLLECT_GLYPHS"; }
typedef return_t (*recurse_func_t) (hb_collect_glyphs_context_t *c, unsigned int lookup_index); 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; hb_set_digest_t digest;
}; };
typedef hb_vector_t<hb_applicable_t, 2> array_t; typedef hb_vector_t<hb_applicable_t> array_t;
/* Dispatch interface. */ /* Dispatch interface. */
const char *get_name () { return "GET_SUBTABLES"; } const char *get_name () { return "GET_SUBTABLES"; }
@@ -1296,7 +1296,6 @@ struct Rule
void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{ {
TRACE_CLOSURE (this);
const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
(inputZ.as_array ((inputCount ? inputCount - 1 : 0))); (inputZ.as_array ((inputCount ? inputCount - 1 : 0)));
context_closure_lookup (c, context_closure_lookup (c,
@@ -1308,7 +1307,6 @@ struct Rule
void collect_glyphs (hb_collect_glyphs_context_t *c, void collect_glyphs (hb_collect_glyphs_context_t *c,
ContextCollectGlyphsLookupContext &lookup_context) const ContextCollectGlyphsLookupContext &lookup_context) const
{ {
TRACE_COLLECT_GLYPHS (this);
const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> > const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
(inputZ.as_array (inputCount ? inputCount - 1 : 0)); (inputZ.as_array (inputCount ? inputCount - 1 : 0));
context_collect_glyphs_lookup (c, context_collect_glyphs_lookup (c,
@@ -1376,7 +1374,6 @@ struct RuleSet
void closure (hb_closure_context_t *c, void closure (hb_closure_context_t *c,
ContextClosureLookupContext &lookup_context) const ContextClosureLookupContext &lookup_context) const
{ {
TRACE_CLOSURE (this);
unsigned int num_rules = rule.len; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).closure (c, lookup_context); (this+rule[i]).closure (c, lookup_context);
@@ -1385,7 +1382,6 @@ struct RuleSet
void collect_glyphs (hb_collect_glyphs_context_t *c, void collect_glyphs (hb_collect_glyphs_context_t *c,
ContextCollectGlyphsLookupContext &lookup_context) const ContextCollectGlyphsLookupContext &lookup_context) const
{ {
TRACE_COLLECT_GLYPHS (this);
unsigned int num_rules = rule.len; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).collect_glyphs (c, lookup_context); (this+rule[i]).collect_glyphs (c, lookup_context);
@@ -1455,8 +1451,6 @@ struct ContextFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
struct ContextClosureLookupContext lookup_context = { struct ContextClosureLookupContext lookup_context = {
{intersects_glyph}, {intersects_glyph},
nullptr nullptr
@@ -1474,7 +1468,6 @@ struct ContextFormat1
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input); (this+coverage).add_coverage (c->input);
struct ContextCollectGlyphsLookupContext lookup_context = { struct ContextCollectGlyphsLookupContext lookup_context = {
@@ -1567,7 +1560,6 @@ struct ContextFormat2
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
if (!(this+coverage).intersects (c->glyphs)) if (!(this+coverage).intersects (c->glyphs))
return; return;
@@ -1588,7 +1580,6 @@ struct ContextFormat2
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input); (this+coverage).add_coverage (c->input);
const ClassDef &class_def = this+classDef; const ClassDef &class_def = this+classDef;
@@ -1681,7 +1672,6 @@ struct ContextFormat3
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
if (!(this+coverageZ[0]).intersects (c->glyphs)) if (!(this+coverageZ[0]).intersects (c->glyphs))
return; return;
@@ -1698,7 +1688,6 @@ struct ContextFormat3
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
(this+coverageZ[0]).add_coverage (c->input); (this+coverageZ[0]).add_coverage (c->input);
const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount)); const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
@@ -1950,7 +1939,6 @@ struct ChainRule
void closure (hb_closure_context_t *c, void closure (hb_closure_context_t *c,
ChainContextClosureLookupContext &lookup_context) const ChainContextClosureLookupContext &lookup_context) const
{ {
TRACE_CLOSURE (this);
const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack);
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
@@ -1965,7 +1953,6 @@ struct ChainRule
void collect_glyphs (hb_collect_glyphs_context_t *c, void collect_glyphs (hb_collect_glyphs_context_t *c,
ChainContextCollectGlyphsLookupContext &lookup_context) const ChainContextCollectGlyphsLookupContext &lookup_context) const
{ {
TRACE_COLLECT_GLYPHS (this);
const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack); const HeadlessArrayOf<HBUINT16> &input = StructAfter<HeadlessArrayOf<HBUINT16> > (backtrack);
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
@@ -2046,7 +2033,6 @@ struct ChainRuleSet
} }
void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
{ {
TRACE_CLOSURE (this);
unsigned int num_rules = rule.len; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).closure (c, lookup_context); (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 void collect_glyphs (hb_collect_glyphs_context_t *c, ChainContextCollectGlyphsLookupContext &lookup_context) const
{ {
TRACE_COLLECT_GLYPHS (this);
unsigned int num_rules = rule.len; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) for (unsigned int i = 0; i < num_rules; i++)
(this+rule[i]).collect_glyphs (c, lookup_context); (this+rule[i]).collect_glyphs (c, lookup_context);
@@ -2119,8 +2104,6 @@ struct ChainContextFormat1
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
struct ChainContextClosureLookupContext lookup_context = { struct ChainContextClosureLookupContext lookup_context = {
{intersects_glyph}, {intersects_glyph},
{nullptr, nullptr, nullptr} {nullptr, nullptr, nullptr}
@@ -2138,7 +2121,6 @@ struct ChainContextFormat1
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input); (this+coverage).add_coverage (c->input);
struct ChainContextCollectGlyphsLookupContext lookup_context = { struct ChainContextCollectGlyphsLookupContext lookup_context = {
@@ -2232,7 +2214,6 @@ struct ChainContextFormat2
} }
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
if (!(this+coverage).intersects (c->glyphs)) if (!(this+coverage).intersects (c->glyphs))
return; return;
@@ -2257,7 +2238,6 @@ struct ChainContextFormat2
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input); (this+coverage).add_coverage (c->input);
const ClassDef &backtrack_class_def = this+backtrackClassDef; const ClassDef &backtrack_class_def = this+backtrackClassDef;
@@ -2382,7 +2362,6 @@ struct ChainContextFormat3
void closure (hb_closure_context_t *c) const void closure (hb_closure_context_t *c) const
{ {
TRACE_CLOSURE (this);
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
if (!(this+input[0]).intersects (c->glyphs)) if (!(this+input[0]).intersects (c->glyphs))
@@ -2404,7 +2383,6 @@ struct ChainContextFormat3
void collect_glyphs (hb_collect_glyphs_context_t *c) const void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this);
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack); const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
(this+input[0]).add_coverage (c->input); (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 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)) if (subtables[i].apply (c))
return true; return true;
return false; return false;
@@ -2686,7 +2664,7 @@ struct GSUBGPOS
{ return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
.find_index (coords, num_coords, index); } .find_index (coords, num_coords, index); }
const Feature& get_feature_variation (unsigned int feature_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 && if (FeatureVariations::NOT_FOUND_INDEX != variations_index &&
version.to_int () >= 0x00010001u) version.to_int () >= 0x00010001u)

View File

@@ -195,7 +195,7 @@ struct JstfScript
struct JSTF struct JSTF
{ {
enum { tableTag = HB_OT_TAG_JSTF }; static constexpr hb_tag_t tableTag = HB_OT_TAG_JSTF;
unsigned int get_script_count () const unsigned int get_script_count () const
{ return scriptList.len; } { return scriptList.len; }

View File

@@ -684,7 +684,7 @@ struct hb_collect_features_context_t
feature_indexes (feature_indexes_), feature_indexes (feature_indexes_),
script_count(0),langsys_count(0) {} 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 /* We might have Null() object here. Don't want to involve
* that in the memoize. So, detect empty objects and return. */ * 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); 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 /* We might have Null() object here. Don't want to involve
* that in the memoize. So, detect empty objects and return. */ * that in the memoize. So, detect empty objects and return. */
@@ -713,7 +713,7 @@ struct hb_collect_features_context_t
private: private:
template <typename T> template <typename T>
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); hb_codepoint_t delta = (hb_codepoint_t) ((uintptr_t) &p - (uintptr_t) &g);
if (visited_set.has (delta)) if (visited_set.has (delta))
@@ -1299,8 +1299,8 @@ hb_ot_layout_feature_get_characters (hb_face_t *face,
struct GSUBProxy struct GSUBProxy
{ {
enum { table_index = 0 }; static constexpr unsigned table_index = 0u;
enum { inplace = false }; static constexpr bool inplace = false;
typedef OT::SubstLookup Lookup; typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) : GSUBProxy (hb_face_t *face) :
@@ -1313,8 +1313,8 @@ struct GSUBProxy
struct GPOSProxy struct GPOSProxy
{ {
enum { table_index = 1 }; static constexpr unsigned table_index = 1u;
enum { inplace = true }; static constexpr bool inplace = true;
typedef OT::PosLookup Lookup; typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) : GPOSProxy (hb_face_t *face) :
@@ -1387,7 +1387,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
if (likely (!lookup.is_reverse ())) if (likely (!lookup.is_reverse ()))
{ {
/* in/out forward substitution/positioning */ /* in/out forward substitution/positioning */
if (Proxy::table_index == 0) if (Proxy::table_index == 0u)
buffer->clear_output (); buffer->clear_output ();
buffer->idx = 0; buffer->idx = 0;
@@ -1404,7 +1404,7 @@ apply_string (OT::hb_ot_apply_context_t *c,
else else
{ {
/* in-place backward substitution/positioning */ /* in-place backward substitution/positioning */
if (Proxy::table_index == 0) if (Proxy::table_index == 0u)
buffer->remove_output (); buffer->remove_output ();
buffer->idx = buffer->len - 1; 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); OT::hb_ot_apply_context_t c (table_index, font, buffer);
c.set_recurse_func (Proxy::Lookup::apply_recurse_func); 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]; const stage_map_t *stage = &stages[table_index][stage_index];
for (; i < stage->last_lookup; i++) for (; i < stage->last_lookup; i++)
{ {

View File

@@ -33,7 +33,7 @@
void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const 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); 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; if (unlikely (!tag)) return;
feature_info_t *info = feature_infos.push(); feature_info_t *info = feature_infos.push();
info->tag = tag; info->tag = tag;
info->seq = feature_infos.len; info->seq = feature_infos.length;
info->max_value = value; info->max_value = value;
info->flags = flags; info->flags = flags;
info->default_value = (flags & F_GLOBAL) ? value : 0; 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 */ /* Sort features and merge duplicates */
if (feature_infos.len) if (feature_infos.length)
{ {
feature_infos.qsort (); feature_infos.qsort ();
unsigned int j = 0; 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) if (feature_infos[i].tag != feature_infos[j].tag)
feature_infos[++j] = feature_infos[i]; feature_infos[++j] = feature_infos[i];
else { else {
@@ -202,7 +202,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
/* Allocate bits now */ /* Allocate bits now */
unsigned int next_bit = global_bit_shift + 1; 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]; 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], key.variations_index[table_index],
global_bit_mask); 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) if (m.features[i].stage[table_index] == stage)
add_lookups (m, table_index, add_lookups (m, table_index,
m.features[i].index[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); m.features[i].random);
/* Sort lookups and merge duplicates */ /* 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; 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) if (m.lookups[table_index][i].index != m.lookups[table_index][j].index)
m.lookups[table_index][++j] = m.lookups[table_index][i]; m.lookups[table_index][++j] = m.lookups[table_index][i];
else else
@@ -320,9 +320,9 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m,
m.lookups[table_index].shrink (j + 1); 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 (); hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push ();
stage_map->last_lookup = last_num_lookups; stage_map->last_lookup = last_num_lookups;
stage_map->pause_func = stages[table_index][stage_index].pause_func; stage_map->pause_func = stages[table_index][stage_index].pause_func;

View File

@@ -145,9 +145,9 @@ struct hb_ot_map_t
*lookup_count = 0; *lookup_count = 0;
return; 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 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]; *plookups = end == start ? nullptr : &lookups[table_index][start];
*lookup_count = end - start; *lookup_count = end - start;
} }
@@ -167,9 +167,9 @@ struct hb_ot_map_t
hb_mask_t global_mask; hb_mask_t global_mask;
hb_vector_t<feature_map_t, 8> features; hb_vector_t<feature_map_t> features;
hb_vector_t<lookup_map_t, 16> lookups[2]; /* GSUB/GPOS */ hb_vector_t<lookup_map_t> lookups[2]; /* GSUB/GPOS */
hb_vector_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */ hb_vector_t<stage_map_t> stages[2]; /* GSUB/GPOS */
}; };
enum hb_ot_map_feature_flags_t enum hb_ot_map_feature_flags_t
@@ -275,8 +275,8 @@ struct hb_ot_map_builder_t
private: private:
unsigned int current_stage[2]; /* GSUB/GPOS */ unsigned int current_stage[2]; /* GSUB/GPOS */
hb_vector_t<feature_info_t, 32> feature_infos; hb_vector_t<feature_info_t> feature_infos;
hb_vector_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */ hb_vector_t<stage_info_t> stages[2]; /* GSUB/GPOS */
}; };

View File

@@ -510,7 +510,7 @@ struct MathGlyphAssembly
{ {
int scale = font->dir_scale (direction); int scale = font->dir_scale (direction);
hb_array_t<const MathGlyphPartRecord> arr = partRecords.sub_array (start_offset, parts_count); hb_array_t<const MathGlyphPartRecord> 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++) for (unsigned int i = 0; i < count; i++)
arr[i].extract (parts[i], scale, font); arr[i].extract (parts[i], scale, font);
} }
@@ -555,7 +555,7 @@ struct MathGlyphConstruction
{ {
int scale = font->dir_scale (direction); int scale = font->dir_scale (direction);
hb_array_t<const MathGlyphVariantRecord> arr = mathGlyphVariantRecord.sub_array (start_offset, variants_count); hb_array_t<const MathGlyphVariantRecord> 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++) for (unsigned int i = 0; i < count; i++)
{ {
variants[i].glyph = arr[i].variantGlyph; variants[i].glyph = arr[i].variantGlyph;
@@ -679,7 +679,7 @@ struct MathVariants
struct MATH 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 (); } bool has_data () const { return version.to_int (); }

View File

@@ -71,7 +71,7 @@ struct maxpV1Tail
struct maxp 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; } 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 *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) if (plan->drop_hints)
drop_hint_fields (plan, maxp_prime); drop_hint_fields (plan, maxp_prime);

View File

@@ -151,7 +151,7 @@ _hb_ot_name_entry_cmp (const void *pa, const void *pb)
struct name struct name
{ {
enum { tableTag = HB_OT_TAG_name }; static constexpr hb_tag_t tableTag = HB_OT_TAG_name;
unsigned int get_size () const unsigned int get_size () const
{ return min_size + count * nameRecordZ.item_size; } { return min_size + count * nameRecordZ.item_size; }
@@ -188,9 +188,9 @@ struct name
this->table->count); this->table->count);
this->names.init (); 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 (); 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, /* Walk and pick best only for each name_id,language pair,
* while dropping unsupported encodings. */ * while dropping unsupported encodings. */
unsigned int j = 0; 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 || if (this->names[i].entry_score == UNSUPPORTED ||
this->names[i].language == HB_LANGUAGE_INVALID) 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 key = {name_id, {0}, language};
const hb_ot_name_entry_t *entry = (const hb_ot_name_entry_t *) const hb_ot_name_entry_t *entry = (const hb_ot_name_entry_t *)
hb_bsearch (&key, hb_bsearch (&key,
this->names.arrayZ(), (const hb_ot_name_entry_t *) this->names,
this->names.len, this->names.length,
sizeof (key), sizeof (key),
_hb_ot_name_entry_cmp_key); _hb_ot_name_entry_cmp_key);
if (!entry) if (!entry)
@@ -263,7 +263,7 @@ struct name
/* We only implement format 0 for now. */ /* We only implement format 0 for now. */
HBUINT16 format; /* Format selector (=0/1). */ HBUINT16 format; /* Format selector (=0/1). */
HBUINT16 count; /* Number of name records. */ HBUINT16 count; /* Number of name records. */
OffsetTo<UnsizedArrayOf<HBUINT8>, HBUINT16, false> NNOffsetTo<UnsizedArrayOf<HBUINT8> >
stringOffset; /* Offset to start of string storage (from start of table). */ stringOffset; /* Offset to start of string storage (from start of table). */
UnsizedArrayOf<NameRecord> UnsizedArrayOf<NameRecord>
nameRecordZ; /* The name records where count is the number of records. */ nameRecordZ; /* The name records where count is the number of records. */

View File

@@ -59,8 +59,8 @@ hb_ot_name_list_names (hb_face_t *face,
unsigned int *num_entries /* OUT */) unsigned int *num_entries /* OUT */)
{ {
const OT::name_accelerator_t &name = *face->table.name; const OT::name_accelerator_t &name = *face->table.name;
if (num_entries) *num_entries = name.names.len; if (num_entries) *num_entries = name.names.length;
return name.names.arrayZ(); 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 */, unsigned int *text_size /* IN/OUT */,
typename out_utf_t::codepoint_t *text /* 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 = (const typename in_utf_t::codepoint_t *) bytes.arrayZ;
const typename in_utf_t::codepoint_t *src_end = src + src_len; const typename in_utf_t::codepoint_t *src_end = src + src_len;

View File

@@ -92,7 +92,7 @@ struct OS2V5Tail
struct OS2 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); } bool has_data () const { return this != &Null (OS2); }

View File

@@ -71,7 +71,7 @@ struct postV2Tail
struct post 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 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; const uint8_t *end = (const uint8_t *) (const void *) table + table_length;
for (const uint8_t *data = pool; 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) data += 1 + *data)
index_to_offset.push (data - pool); index_to_offset.push (data - pool);
} }
@@ -129,9 +129,9 @@ struct post
char *buf, unsigned int buf_len) const char *buf, unsigned int buf_len) const
{ {
hb_bytes_t s = find_glyph_name (glyph); hb_bytes_t s = find_glyph_name (glyph);
if (!s.len) return false; if (!s.length) return false;
if (!buf_len) return true; 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); strncpy (buf, s.arrayZ, len);
buf[len] = '\0'; buf[len] = '\0';
return true; return true;
@@ -226,7 +226,7 @@ struct post
return format1_names (index); return format1_names (index);
index -= NUM_FORMAT1_NAMES; index -= NUM_FORMAT1_NAMES;
if (index >= index_to_offset.len) if (index >= index_to_offset.length)
return hb_bytes_t (); return hb_bytes_t ();
unsigned int offset = index_to_offset[index]; unsigned int offset = index_to_offset[index];
@@ -241,7 +241,7 @@ struct post
hb_blob_ptr_t<post> table; hb_blob_ptr_t<post> table;
uint32_t version; uint32_t version;
const ArrayOf<HBUINT16> *glyphNameIndex; const ArrayOf<HBUINT16> *glyphNameIndex;
hb_vector_t<uint32_t, 1> index_to_offset; hb_vector_t<uint32_t> index_to_offset;
const uint8_t *pool; const uint8_t *pool;
hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name; hb_atomic_ptr_t<uint16_t *> gids_sorted_by_name;
}; };

View File

@@ -16,6 +16,8 @@
#include "hb-ot-shape-complex-indic.hh" #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_A INDIC_SYLLABIC_CATEGORY_AVAGRAHA /* 16 chars; Avagraha */
#define ISC_Bi INDIC_SYLLABIC_CATEGORY_BINDU /* 83 chars; Bindu */ #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_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_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 */ #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) #define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)

View File

@@ -17,6 +17,8 @@
#include "hb-ot-shape-complex-use.hh" #include "hb-ot-shape-complex-use.hh"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-macros"
#define B USE_B /* BASE */ #define B USE_B /* BASE */
#define CGJ USE_CGJ /* CGJ */ #define CGJ USE_CGJ /* CGJ */
#define CS USE_CS /* CONS_WITH_STACKER */ #define CS USE_CS /* CONS_WITH_STACKER */
@@ -55,6 +57,7 @@
#define VMBlw USE_VMBlw #define VMBlw USE_VMBlw
#define VMPst USE_VMPst #define VMPst USE_VMPst
#define VMAbv USE_VMAbv #define VMAbv USE_VMAbv
#pragma GCC diagnostic pop
static const USE_TABLE_ELEMENT_TYPE use_table[] = { static const USE_TABLE_ELEMENT_TYPE use_table[] = {

View File

@@ -180,12 +180,18 @@ _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t
static void static void
zero_mark_advances (hb_buffer_t *buffer, zero_mark_advances (hb_buffer_t *buffer,
unsigned int start, unsigned int start,
unsigned int end) unsigned int end,
bool adjust_offsets_when_zeroing)
{ {
hb_glyph_info_t *info = buffer->info; hb_glyph_info_t *info = buffer->info;
for (unsigned int i = start; i < end; i++) 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 (_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].x_advance = 0;
buffer->pos[i].y_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_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int base, unsigned int base,
unsigned int end) unsigned int end,
bool adjust_offsets_when_zeroing)
{ {
hb_direction_t horiz_dir = HB_DIRECTION_INVALID; hb_direction_t horiz_dir = HB_DIRECTION_INVALID;
@@ -314,11 +321,15 @@ position_around_base (const hb_ot_shape_plan_t *plan,
&base_extents)) &base_extents))
{ {
/* If extents don't work, zero marks and go home. */ /* 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; return;
} }
base_extents.x_bearing += buffer->pos[base].x_offset;
base_extents.y_bearing += buffer->pos[base].y_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]); 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 /* 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_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int start, unsigned int start,
unsigned int end) unsigned int end,
bool adjust_offsets_when_zeroing)
{ {
if (end - start < 2) if (end - start < 2)
return; 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]))) if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[j])))
break; break;
position_around_base (plan, font, buffer, i, j); position_around_base (plan, font, buffer, i, j, adjust_offsets_when_zeroing);
i = j - 1; i = j - 1;
} }
@@ -419,7 +431,8 @@ position_cluster (const hb_ot_shape_plan_t *plan,
void void
_hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,
hb_buffer_t *buffer) hb_buffer_t *buffer,
bool adjust_offsets_when_zeroing)
{ {
_hb_buffer_assert_gsubgpos_vars (buffer); _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; hb_glyph_info_t *info = buffer->info;
for (unsigned int i = 1; i < count; i++) for (unsigned int i = 1; i < count; i++)
if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[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; start = i;
} }
position_cluster (plan, font, buffer, start, count); position_cluster (plan, font, buffer, start, count, adjust_offsets_when_zeroing);
} }

View File

@@ -34,7 +34,8 @@
HB_INTERNAL void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, HB_INTERNAL void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
hb_font_t *font, 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_INTERNAL void _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,

View File

@@ -428,6 +428,20 @@ hb_set_unicode_props (hb_buffer_t *buffer)
_hb_glyph_info_set_continuation (&info[i]); _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<hb_codepoint_t> (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); &pos[i].y_offset);
if (c->plan->fallback_mark_positioning) 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 static inline void

View File

@@ -225,7 +225,7 @@ struct StatAxisRecord
struct STAT 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 bool sanitize (hb_sanitize_context_t *c) const
{ {
@@ -249,7 +249,7 @@ struct STAT
* in the 'fvar' table. In all fonts, must * in the 'fvar' table. In all fonts, must
* be greater than zero if axisValueCount * be greater than zero if axisValueCount
* is greater than zero. */ * is greater than zero. */
LOffsetTo<UnsizedArrayOf<StatAxisRecord>, false> LNNOffsetTo<UnsizedArrayOf<StatAxisRecord> >
designAxesOffset; designAxesOffset;
/* Offset in bytes from the beginning of /* Offset in bytes from the beginning of
* the STAT table to the start of the design * the STAT table to the start of the design
@@ -257,7 +257,7 @@ struct STAT
* set to zero; if designAxisCount is greater * set to zero; if designAxisCount is greater
* than zero, must be greater than zero. */ * than zero, must be greater than zero. */
HBUINT16 axisValueCount; /* The number of axis value tables. */ HBUINT16 axisValueCount; /* The number of axis value tables. */
LOffsetTo<UnsizedArrayOf<OffsetTo<AxisValue> >, false> LNNOffsetTo<UnsizedArrayOf<OffsetTo<AxisValue> > >
offsetToAxisValueOffsets; offsetToAxisValueOffsets;
/* Offset in bytes from the beginning of /* Offset in bytes from the beginning of
* the STAT table to the start of the design * the STAT table to the start of the design

View File

@@ -99,7 +99,7 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
struct avar 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 bool sanitize (hb_sanitize_context_t *c) const
{ {

View File

@@ -96,7 +96,7 @@ struct AxisRecord
struct fvar 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 (); } bool has_data () const { return version.to_int (); }
@@ -268,7 +268,7 @@ struct fvar
{ {
hb_array_t<const Fixed> instanceCoords = instance->get_coordinates (axisCount) hb_array_t<const Fixed> instanceCoords = instance->get_coordinates (axisCount)
.sub_array (0, *coords_length); .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 (); coords[i] = instanceCoords.arrayZ[i].to_float ();
} }
return axisCount; return axisCount;

View File

@@ -100,8 +100,8 @@ struct DeltaSetIndexMap
struct HVARVVAR struct HVARVVAR
{ {
enum { HVARTag = HB_OT_TAG_HVAR }; static constexpr hb_tag_t HVARTag = HB_OT_TAG_HVAR;
enum { VVARTag = HB_OT_TAG_VVAR }; static constexpr hb_tag_t VVARTag = HB_OT_TAG_VVAR;
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const
{ {
@@ -140,10 +140,10 @@ struct HVARVVAR
}; };
struct HVAR : HVARVVAR { struct HVAR : HVARVVAR {
enum { tableTag = HB_OT_TAG_HVAR }; static constexpr hb_tag_t tableTag = HB_OT_TAG_HVAR;
}; };
struct VVAR : HVARVVAR { 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 bool sanitize (hb_sanitize_context_t *c) const
{ {

View File

@@ -58,7 +58,7 @@ struct VariationValueRecord
struct MVAR 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 bool sanitize (hb_sanitize_context_t *c) const
{ {

View File

@@ -57,7 +57,7 @@ struct VertOriginMetric
struct VORG 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 (); } bool has_data () const { return version.to_int (); }
@@ -85,12 +85,12 @@ struct VORG
subset_table->version.minor.set (0); subset_table->version.minor.set (0);
subset_table->defaultVertOriginY.set (vorg_table->defaultVertOriginY); 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; 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<VertOriginMetric> (size); VertOriginMetric *metrics = c.allocate_size<VertOriginMetric> (size);
if (likely (metrics != nullptr)) if (likely (metrics != nullptr))
memcpy (metrics, &subset_metrics[0], size); memcpy (metrics, &subset_metrics[0], size);
@@ -112,7 +112,7 @@ struct VORG
subset_metrics.init (); subset_metrics.init ();
unsigned int glyph = 0; unsigned int glyph = 0;
unsigned int i = 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) if (plan->glyphs[glyph] > vertYOrigins[i].glyph)
i++; i++;
@@ -129,7 +129,7 @@ struct VORG
} }
/* alloc the new table */ /* 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); void *dest = (void *) malloc (dest_sz);
if (unlikely (!dest)) if (unlikely (!dest))
{ {

View File

@@ -48,15 +48,15 @@
template <typename mask_t, unsigned int shift> template <typename mask_t, unsigned int shift>
struct hb_set_digest_lowest_bits_t struct hb_set_digest_lowest_bits_t
{ {
enum { mask_bytes = sizeof (mask_t) }; static constexpr unsigned mask_bytes = sizeof (mask_t);
enum { mask_bits = sizeof (mask_t) * 8 }; static constexpr unsigned mask_bits = sizeof (mask_t) * 8;
enum { num_bits = 0 static constexpr unsigned num_bits = 0
+ (mask_bytes >= 1 ? 3 : 0) + (mask_bytes >= 1 ? 3 : 0)
+ (mask_bytes >= 2 ? 1 : 0) + (mask_bytes >= 2 ? 1 : 0)
+ (mask_bytes >= 4 ? 1 : 0) + (mask_bytes >= 4 ? 1 : 0)
+ (mask_bytes >= 8 ? 1 : 0) + (mask_bytes >= 8 ? 1 : 0)
+ (mask_bytes >= 16? 1 : 0) + (mask_bytes >= 16? 1 : 0)
+ 0 }; + 0;
static_assert ((shift < sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift < sizeof (hb_codepoint_t) * 8), "");
static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), ""); static_assert ((shift + num_bits <= sizeof (hb_codepoint_t) * 8), "");

View File

@@ -161,7 +161,7 @@ struct hb_set_t
} }
typedef unsigned long long elt_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_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, "");
static unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } 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<elt_t, PAGE_BITS / 8> vector_t; typedef hb_vector_size_t<elt_t, PAGE_BITS / 8> vector_t;
enum { ELT_BITS = sizeof (elt_t) * 8 }; static constexpr unsigned ELT_BITS = sizeof (elt_t) * 8;
enum { ELT_MASK = ELT_BITS - 1 }; static constexpr unsigned ELT_MASK = ELT_BITS - 1;
enum { BITS = sizeof (vector_t) * 8 }; static constexpr unsigned BITS = sizeof (vector_t) * 8;
enum { MASK = BITS - 1 }; static constexpr unsigned MASK = BITS - 1;
static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, ""); static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, "");
elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_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; hb_object_header_t header;
bool successful; /* Allocations successful */ bool successful; /* Allocations successful */
mutable unsigned int population; mutable unsigned int population;
hb_vector_t<page_map_t, 1> page_map; hb_vector_t<page_map_t> page_map;
hb_vector_t<page_t, 1> pages; hb_vector_t<page_t> pages;
void init_shallow () void init_shallow ()
{ {
@@ -220,7 +220,7 @@ struct hb_set_t
if (unlikely (!successful)) return false; if (unlikely (!successful)) return false;
if (!pages.resize (count) || !page_map.resize (count)) if (!pages.resize (count) || !page_map.resize (count))
{ {
pages.resize (page_map.len); pages.resize (page_map.length);
successful = false; successful = false;
return false; return false;
} }
@@ -238,7 +238,7 @@ struct hb_set_t
} }
bool is_empty () const bool is_empty () const
{ {
unsigned int count = pages.len; unsigned int count = pages.length;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!pages[i].is_empty ()) if (!pages[i].is_empty ())
return false; return false;
@@ -373,7 +373,7 @@ struct hb_set_t
void set (const hb_set_t *other) void set (const hb_set_t *other)
{ {
if (unlikely (!successful)) return; if (unlikely (!successful)) return;
unsigned int count = other->pages.len; unsigned int count = other->pages.length;
if (!resize (count)) if (!resize (count))
return; return;
population = other->population; population = other->population;
@@ -386,8 +386,8 @@ struct hb_set_t
if (get_population () != other->get_population ()) if (get_population () != other->get_population ())
return false; return false;
unsigned int na = pages.len; unsigned int na = pages.length;
unsigned int nb = other->pages.len; unsigned int nb = other->pages.length;
unsigned int a = 0, b = 0; unsigned int a = 0, b = 0;
for (; a < na && b < nb; ) for (; a < na && b < nb; )
@@ -429,8 +429,8 @@ struct hb_set_t
dirty (); dirty ();
unsigned int na = pages.len; unsigned int na = pages.length;
unsigned int nb = other->pages.len; unsigned int nb = other->pages.length;
unsigned int next_page = na; unsigned int next_page = na;
unsigned int count = 0, newCount = 0; unsigned int count = 0, newCount = 0;
@@ -461,7 +461,7 @@ struct hb_set_t
if (Op::passthru_right) if (Op::passthru_right)
count += nb - b; count += nb - b;
if (count > pages.len) if (count > pages.length)
if (!resize (count)) if (!resize (count))
return; return;
newCount = count; newCount = count;
@@ -517,7 +517,7 @@ struct hb_set_t
page_at (count).v = other->page_at (b).v; page_at (count).v = other->page_at (b).v;
} }
assert (!count); assert (!count);
if (pages.len > newCount) if (pages.length > newCount)
resize (newCount); resize (newCount);
} }
@@ -547,7 +547,7 @@ struct hb_set_t
page_map_t map = {get_major (*codepoint), 0}; page_map_t map = {get_major (*codepoint), 0};
unsigned int i; unsigned int i;
page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST); 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)) if (pages[page_map[i].index].next (codepoint))
{ {
@@ -556,7 +556,7 @@ struct hb_set_t
} }
i++; i++;
} }
for (; i < page_map.len; i++) for (; i < page_map.length; i++)
{ {
hb_codepoint_t m = pages[page_map[i].index].get_min (); hb_codepoint_t m = pages[page_map[i].index].get_min ();
if (m != INVALID) if (m != INVALID)
@@ -578,7 +578,7 @@ struct hb_set_t
page_map_t map = {get_major (*codepoint), 0}; page_map_t map = {get_major (*codepoint), 0};
unsigned int i; unsigned int i;
page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST); 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)) if (pages[page_map[i].index].previous (codepoint))
{ {
@@ -642,7 +642,7 @@ struct hb_set_t
return population; return population;
unsigned int pop = 0; unsigned int pop = 0;
unsigned int count = pages.len; unsigned int count = pages.length;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
pop += pages[i].get_population (); pop += pages[i].get_population ();
@@ -651,7 +651,7 @@ struct hb_set_t
} }
hb_codepoint_t get_min () const hb_codepoint_t get_min () const
{ {
unsigned int count = pages.len; unsigned int count = pages.length;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!page_at (i).is_empty ()) if (!page_at (i).is_empty ())
return page_map[i].major * page_t::PAGE_BITS + page_at (i).get_min (); 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 hb_codepoint_t get_max () const
{ {
unsigned int count = pages.len; unsigned int count = pages.length;
for (int i = count - 1; i >= 0; i++) for (int i = count - 1; i >= 0; i++)
if (!page_at (i).is_empty ()) if (!page_at (i).is_empty ())
return page_map[(unsigned) i].major * page_t::PAGE_BITS + page_at (i).get_max (); return page_map[(unsigned) i].major * page_t::PAGE_BITS + page_at (i).get_max ();
return INVALID; 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_codepoint_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_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; unsigned int i;
if (!page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST)) if (!page_map.bfind (map, &i, HB_BFIND_NOT_FOUND_STORE_CLOSEST))
{ {
if (!resize (pages.len + 1)) if (!resize (pages.length + 1))
return nullptr; return nullptr;
pages[map.index].init0 (); pages[map.index].init0 ();
memmove (page_map + i + 1, memmove (page_map + i + 1,
page_map + i, 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; page_map[i] = map;
} }
return &pages[page_map[i].index]; return &pages[page_map[i].index];

View File

@@ -49,15 +49,15 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
unsigned int &subset_fd_count /* OUT */, unsigned int &subset_fd_count /* OUT */,
unsigned int &subset_fdselect_size /* OUT */, unsigned int &subset_fdselect_size /* OUT */,
unsigned int &subset_fdselect_format /* OUT */, unsigned int &subset_fdselect_format /* OUT */,
hb_vector_t<code_pair> &fdselect_ranges /* OUT */, hb_vector_t<code_pair_t> &fdselect_ranges /* OUT */,
Remap &fdmap /* OUT */) remap_t &fdmap /* OUT */)
{ {
subset_fd_count = 0; subset_fd_count = 0;
subset_fdselect_size = 0; subset_fdselect_size = 0;
subset_fdselect_format = 0; subset_fdselect_format = 0;
unsigned int num_ranges = 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) if (subset_num_glyphs == 0)
return true; return true;
@@ -76,7 +76,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
{ {
num_ranges++; num_ranges++;
prev_fd = fd; prev_fd = fd;
code_pair pair = { fd, i }; code_pair_t pair = { fd, i };
fdselect_ranges.push (pair); fdselect_ranges.push (pair);
} }
} }
@@ -106,7 +106,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
} }
/* update each font dict index stored as "code" in fdselect_ranges */ /* 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]; 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 unsigned int num_glyphs,
const FDSelect &src, const FDSelect &src,
unsigned int size, unsigned int size,
const hb_vector_t<code_pair> &fdselect_ranges) const hb_vector_t<code_pair_t> &fdselect_ranges)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size); FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
if (unlikely (p == nullptr)) return_trace (false); if (unlikely (p == nullptr)) return_trace (false);
p->nRanges.set (fdselect_ranges.len); p->nRanges ().set (fdselect_ranges.length);
for (unsigned int i = 0; i < fdselect_ranges.len; i++) for (unsigned int i = 0; i < fdselect_ranges.length; i++)
{ {
p->ranges[i].first.set (fdselect_ranges[i].glyph); p->ranges[i].first.set (fdselect_ranges[i].glyph);
p->ranges[i].fd.set (fdselect_ranges[i].code); 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 fd_count,
unsigned int fdselect_format, unsigned int fdselect_format,
unsigned int size, unsigned int size,
const hb_vector_t<code_pair> &fdselect_ranges) const hb_vector_t<code_pair_t> &fdselect_ranges)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
FDSelect *p = c->allocate_min<FDSelect> (); FDSelect *p = c->allocate_min<FDSelect> ();

View File

@@ -35,16 +35,16 @@
namespace CFF { namespace CFF {
/* Used for writing a temporary charstring */ /* 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) {} : buff (buff_), error (false) {}
void reset () { buff.resize (0); } void reset () { buff.resize (0); }
void encode_byte (unsigned char b) 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 (); 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 ()) 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)) if (Is_OpCode_ESC (op))
{ {
@@ -107,16 +107,16 @@ struct StrEncoder
encode_byte (op); encode_byte (op);
} }
void copy_str (const ByteStr &str) void copy_str (const byte_str_t &str)
{ {
unsigned int offset = buff.len; unsigned int offset = buff.length;
buff.resize (offset + str.len); buff.resize (offset + str.length);
if (unlikely (buff.len < offset + str.len)) if (unlikely (buff.length < offset + str.length))
{ {
set_error (); set_error ();
return; return;
} }
memcpy (&buff[offset], &str.str[0], str.len); memcpy (&buff[offset], &str[0], str.length);
} }
bool is_error () const { return error; } bool is_error () const { return error; }
@@ -124,12 +124,12 @@ struct StrEncoder
protected: protected:
void set_error () { error = true; } void set_error () { error = true; }
StrBuff &buff; str_buff_t &buff;
bool error; bool error;
}; };
struct CFFSubTableOffsets { struct cff_sub_table_offsets_t {
CFFSubTableOffsets () : privateDictsOffset (0) cff_sub_table_offsets_t () : privateDictsOffset (0)
{ {
topDictInfo.init (); topDictInfo.init ();
FDSelectInfo.init (); FDSelectInfo.init ();
@@ -139,23 +139,23 @@ struct CFFSubTableOffsets {
localSubrsInfos.init (); localSubrsInfos.init ();
} }
~CFFSubTableOffsets () { localSubrsInfos.fini (); } ~cff_sub_table_offsets_t () { localSubrsInfos.fini (); }
TableInfo topDictInfo; table_info_t topDictInfo;
TableInfo FDSelectInfo; table_info_t FDSelectInfo;
TableInfo FDArrayInfo; table_info_t FDArrayInfo;
TableInfo charStringsInfo; table_info_t charStringsInfo;
unsigned int privateDictsOffset; unsigned int privateDictsOffset;
TableInfo globalSubrsInfo; table_info_t globalSubrsInfo;
hb_vector_t<TableInfo> localSubrsInfos; hb_vector_t<table_info_t> localSubrsInfos;
}; };
template <typename OPSTR=OpStr> template <typename OPSTR=op_str_t>
struct CFFTopDict_OpSerializer : OpSerializer struct cff_top_dict_op_serializer_t : op_serializer_t
{ {
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
const OPSTR &opstr, const OPSTR &opstr,
const CFFSubTableOffsets &offsets) const const cff_sub_table_offsets_t &offsets) const
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
@@ -186,16 +186,16 @@ struct CFFTopDict_OpSerializer : OpSerializer
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default: 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, bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const op_str_t &opstr,
const TableInfo &privateDictInfo) const const table_info_t &privateDictInfo) const
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
@@ -215,34 +215,34 @@ struct CFFFontDict_OpSerializer : OpSerializer
} }
else else
{ {
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.len); HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
if (unlikely (d == nullptr)) return_trace (false); 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); 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) if (opstr.op == OpCode_Private)
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private); return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
else 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_) {} : desubroutinize (desubroutinize_), drop_hints (drop_hints_) {}
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const op_str_t &opstr,
const unsigned int subrsOffset) const const unsigned int subrsOffset) const
{ {
TRACE_SERIALIZE (this); 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; return true;
if (opstr.op == OpCode_Subrs) if (opstr.op == OpCode_Subrs)
{ {
@@ -255,10 +255,10 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
return_trace (copy_opstr (c, opstr)); 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 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; return 0;
if (opstr.op == OpCode_Subrs) if (opstr.op == OpCode_Subrs)
{ {
@@ -268,7 +268,7 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op); return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op);
} }
else else
return opstr.str.len; return opstr.str.length;
} }
protected: protected:
@@ -276,39 +276,36 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
const bool drop_hints; const bool drop_hints;
}; };
struct FlattenParam struct flatten_param_t
{ {
StrBuff &flatStr; str_buff_t &flatStr;
bool drop_hints; bool drop_hints;
}; };
template <typename ACC, typename ENV, typename OPSET> template <typename ACC, typename ENV, typename OPSET>
struct SubrFlattener struct subr_flattener_t
{ {
SubrFlattener (const ACC &acc_, subr_flattener_t (const ACC &acc_,
const hb_vector_t<hb_codepoint_t> &glyphs_, const hb_vector_t<hb_codepoint_t> &glyphs_,
bool drop_hints_) bool drop_hints_) : acc (acc_), glyphs (glyphs_),
: acc (acc_), drop_hints (drop_hints_) {}
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; return false;
for (unsigned int i = 0; i < glyphs.len; i++) for (unsigned int i = 0; i < glyphs.length; i++)
flat_charstrings[i].init (); 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]; 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); unsigned int fd = acc.fdSelect->get_fd (glyph);
if (unlikely (fd >= acc.fdCount)) if (unlikely (fd >= acc.fdCount))
return false; return false;
CSInterpreter<ENV, OPSET, FlattenParam> interp; cs_interpreter_t<ENV, OPSET, flatten_param_t> interp;
interp.env.init (str, acc, fd); 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))) if (unlikely (!interp.interpret (param)))
return false; return false;
} }
@@ -320,9 +317,9 @@ struct SubrFlattener
bool drop_hints; 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 (); } { local_closures.init (); }
void init (unsigned int fd_count) void init (unsigned int fd_count)
@@ -334,7 +331,7 @@ struct SubrClosures
if (!local_closures.resize (fd_count)) if (!local_closures.resize (fd_count))
valid = false; 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 (); local_closures[i] = hb_set_create ();
if (local_closures[i] == hb_set_get_empty ()) if (local_closures[i] == hb_set_get_empty ())
@@ -345,7 +342,7 @@ struct SubrClosures
void fini () void fini ()
{ {
hb_set_destroy (global_closure); 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]); hb_set_destroy (local_closures[i]);
local_closures.fini (); local_closures.fini ();
} }
@@ -353,7 +350,7 @@ struct SubrClosures
void reset () void reset ()
{ {
hb_set_clear (global_closure); 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]); hb_set_clear (local_closures[i]);
} }
@@ -363,18 +360,18 @@ struct SubrClosures
hb_vector_t<hb_set_t *> local_closures; hb_vector_t<hb_set_t *> local_closures;
}; };
struct ParsedCSOp : OpStr struct parsed_cs_op_t : op_str_t
{ {
void init (unsigned int subr_num_ = 0) void init (unsigned int subr_num_ = 0)
{ {
OpStr::init (); op_str_t::init ();
subr_num = subr_num_; subr_num = subr_num_;
drop_flag = false; drop_flag = false;
keep_flag = false; keep_flag = false;
skip_flag = false; skip_flag = false;
} }
void fini () { OpStr::fini (); } void fini () { op_str_t::fini (); }
bool for_drop () const { return drop_flag; } bool for_drop () const { return drop_flag; }
void set_drop () { if (!for_keep ()) drop_flag = true; } void set_drop () { if (!for_keep ()) drop_flag = true; }
@@ -393,7 +390,7 @@ struct ParsedCSOp : OpStr
bool skip_flag : 1; bool skip_flag : 1;
}; };
struct ParsedCStr : ParsedValues<ParsedCSOp> struct parsed_cs_str_t : parsed_values_t<parsed_cs_op_t>
{ {
void init () void init ()
{ {
@@ -403,13 +400,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
has_prefix_ = false; 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 ()) 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 ()) if (!is_parsed ())
{ {
@@ -417,13 +414,13 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
if (likely (parsed_len > 0)) if (likely (parsed_len > 0))
values[parsed_len-1].set_skip (); values[parsed_len-1].set_skip ();
ParsedCSOp val; parsed_cs_op_t val;
val.init (subr_num); 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; has_prefix_ = true;
prefix_op_ = op; prefix_op_ = op;
@@ -432,7 +429,7 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
bool at_end (unsigned int pos) const 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)); || (values[pos + 1].op == OpCode_return));
} }
@@ -446,42 +443,42 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
void set_vsindex_dropped () { vsindex_dropped = true; } void set_vsindex_dropped () { vsindex_dropped = true; }
bool has_prefix () const { return has_prefix_; } bool has_prefix () const { return has_prefix_; }
OpCode prefix_op () const { return prefix_op_; } op_code_t prefix_op () const { return prefix_op_; }
const Number &prefix_num () const { return prefix_num_; } const number_t &prefix_num () const { return prefix_num_; }
protected: protected:
bool parsed; bool parsed;
bool hint_dropped; bool hint_dropped;
bool vsindex_dropped; bool vsindex_dropped;
bool has_prefix_; bool has_prefix_;
OpCode prefix_op_; op_code_t prefix_op_;
Number prefix_num_; number_t prefix_num_;
private: private:
typedef ParsedValues<ParsedCSOp> SUPER; typedef parsed_values_t<parsed_cs_op_t> SUPER;
}; };
struct ParsedCStrs : hb_vector_t<ParsedCStr> struct parsed_cs_str_vec_t : hb_vector_t<parsed_cs_str_t>
{ {
void init (unsigned int len_ = 0) void init (unsigned int len_ = 0)
{ {
SUPER::init (); SUPER::init ();
resize (len_); resize (len_);
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < length; i++)
(*this)[i].init (); (*this)[i].init ();
} }
void fini () { SUPER::fini_deep (); } void fini () { SUPER::fini_deep (); }
private: private:
typedef hb_vector_t<ParsedCStr> SUPER; typedef hb_vector_t<parsed_cs_str_t> SUPER;
}; };
struct SubrSubsetParam struct subr_subset_param_t
{ {
void init (ParsedCStr *parsed_charstring_, void init (parsed_cs_str_t *parsed_charstring_,
ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_, 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_, hb_set_t *global_closure_, hb_set_t *local_closure_,
bool drop_hints_) bool drop_hints_)
{ {
parsed_charstring = parsed_charstring_; parsed_charstring = parsed_charstring_;
current_parsed_str = parsed_charstring; current_parsed_str = parsed_charstring;
@@ -492,7 +489,7 @@ struct SubrSubsetParam
drop_hints = drop_hints_; 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) switch (context.type)
{ {
@@ -500,12 +497,12 @@ struct SubrSubsetParam
return parsed_charstring; return parsed_charstring;
case CSType_LocalSubr: 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]; return &(*parsed_local_subrs)[context.subr_num];
break; break;
case CSType_GlobalSubr: 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]; return &(*parsed_global_subrs)[context.subr_num];
break; break;
} }
@@ -515,13 +512,13 @@ struct SubrSubsetParam
template <typename ENV> template <typename ENV>
void set_current_str (ENV &env, bool calling) 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 (likely (parsed_str != nullptr))
{ {
/* If the called subroutine is parsed partially but not completely yet, /* If the called subroutine is parsed partially but not completely yet,
* it must be because we are calling it recursively. * it must be because we are calling it recursively.
* Handle it as an error. */ * 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 (); env.set_error ();
else else
current_parsed_str = parsed_str; current_parsed_str = parsed_str;
@@ -530,17 +527,17 @@ struct SubrSubsetParam
env.set_error (); env.set_error ();
} }
ParsedCStr *current_parsed_str; parsed_cs_str_t *current_parsed_str;
ParsedCStr *parsed_charstring; parsed_cs_str_t *parsed_charstring;
ParsedCStrs *parsed_global_subrs; parsed_cs_str_vec_t *parsed_global_subrs;
ParsedCStrs *parsed_local_subrs; parsed_cs_str_vec_t *parsed_local_subrs;
hb_set_t *global_closure; hb_set_t *global_closure;
hb_set_t *local_closure; hb_set_t *local_closure;
bool drop_hints; bool drop_hints;
}; };
struct SubrRemap : Remap struct subr_remap_t : remap_t
{ {
void create (hb_set_t *closure) 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. * no optimization based on usage counts. fonttools doesn't appear doing that either.
*/ */
reset (closure->get_max () + 1); 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)) if (hb_set_has (closure, old_num))
add (old_num); add (old_num);
@@ -564,10 +561,10 @@ struct SubrRemap : Remap
hb_codepoint_t operator[] (unsigned int old_num) const hb_codepoint_t operator[] (unsigned int old_num) const
{ {
if (old_num >= len) if (old_num >= length)
return CFF_UNDEF_CODE; return CFF_UNDEF_CODE;
else else
return Remap::operator[] (old_num); return remap_t::operator[] (old_num);
} }
int biased_num (unsigned int old_num) const int biased_num (unsigned int old_num) const
@@ -580,15 +577,15 @@ struct SubrRemap : Remap
int bias; int bias;
}; };
struct SubrRemaps struct subr_remap_ts
{ {
SubrRemaps () subr_remap_ts ()
{ {
global_remap.init (); global_remap.init ();
local_remaps.init (); local_remaps.init ();
} }
~SubrRemaps () { fini (); } ~subr_remap_ts () { fini (); }
void init (unsigned int fdCount) void init (unsigned int fdCount)
{ {
@@ -597,10 +594,10 @@ struct SubrRemaps
local_remaps[i].init (); local_remaps[i].init ();
} }
void create (SubrClosures& closures) void create (subr_closures_t& closures)
{ {
global_remap.create (closures.global_closure); 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]); local_remaps[i].create (closures.local_closures[i]);
} }
@@ -610,21 +607,21 @@ struct SubrRemaps
local_remaps.fini_deep (); local_remaps.fini_deep ();
} }
SubrRemap global_remap; subr_remap_t global_remap;
hb_vector_t<SubrRemap> local_remaps; hb_vector_t<subr_remap_t> local_remaps;
}; };
template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typename OPSET> template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typename OPSET>
struct SubrSubsetter struct subr_subsetter_t
{ {
SubrSubsetter () subr_subsetter_t ()
{ {
parsed_charstrings.init (); parsed_charstrings.init ();
parsed_global_subrs.init (); parsed_global_subrs.init ();
parsed_local_subrs.init (); parsed_local_subrs.init ();
} }
~SubrSubsetter () ~subr_subsetter_t ()
{ {
closures.fini (); closures.fini ();
remaps.fini (); remaps.fini ();
@@ -652,7 +649,7 @@ struct SubrSubsetter
closures.init (acc.fdCount); closures.init (acc.fdCount);
remaps.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_global_subrs.init (acc.globalSubrs->count);
parsed_local_subrs.resize (acc.fdCount); parsed_local_subrs.resize (acc.fdCount);
for (unsigned int i = 0; i < acc.fdCount; i++) for (unsigned int i = 0; i < acc.fdCount; i++)
@@ -663,18 +660,18 @@ struct SubrSubsetter
return false; return false;
/* phase 1 & 2 */ /* 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]; 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); unsigned int fd = acc.fdSelect->get_fd (glyph);
if (unlikely (fd >= acc.fdCount)) if (unlikely (fd >= acc.fdCount))
return false; return false;
CSInterpreter<ENV, OPSET, SubrSubsetParam> interp; cs_interpreter_t<ENV, OPSET, subr_subset_param_t> interp;
interp.env.init (str, acc, fd); interp.env.init (str, acc, fd);
SubrSubsetParam param; subr_subset_param_t param;
param.init (&parsed_charstrings[i], param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd], &parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd], closures.global_closure, closures.local_closures[fd],
@@ -690,18 +687,18 @@ struct SubrSubsetter
if (drop_hints) if (drop_hints)
{ {
/* mark hint ops and arguments for drop */ /* 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]); unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
if (unlikely (fd >= acc.fdCount)) if (unlikely (fd >= acc.fdCount))
return false; return false;
SubrSubsetParam param; subr_subset_param_t param;
param.init (&parsed_charstrings[i], param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd], &parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd], closures.global_closure, closures.local_closures[fd],
drop_hints); drop_hints);
DropHintsParam drop; drop_hints_param_t drop;
if (drop_hints_in_str (parsed_charstrings[i], param, drop)) if (drop_hints_in_str (parsed_charstrings[i], param, drop))
{ {
parsed_charstrings[i].set_hint_dropped (); parsed_charstrings[i].set_hint_dropped ();
@@ -712,12 +709,12 @@ struct SubrSubsetter
/* after dropping hints recreate closures of actually used subrs */ /* after dropping hints recreate closures of actually used subrs */
closures.reset (); 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]); unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
if (unlikely (fd >= acc.fdCount)) if (unlikely (fd >= acc.fdCount))
return false; return false;
SubrSubsetParam param; subr_subset_param_t param;
param.init (&parsed_charstrings[i], param.init (&parsed_charstrings[i],
&parsed_global_subrs, &parsed_local_subrs[fd], &parsed_global_subrs, &parsed_local_subrs[fd],
closures.global_closure, closures.local_closures[fd], closures.global_closure, closures.local_closures[fd],
@@ -731,11 +728,11 @@ struct SubrSubsetter
return true; return true;
} }
bool encode_charstrings (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, StrBuffArray &buffArray) const bool encode_charstrings (ACC &acc, const hb_vector_t<hb_codepoint_t> &glyphs, str_buff_vec_t &buffArray) const
{ {
if (unlikely (!buffArray.resize (glyphs.len))) if (unlikely (!buffArray.resize (glyphs.length)))
return false; 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]); unsigned int fd = acc.fdSelect->get_fd (glyphs[i]);
if (unlikely (fd >= acc.fdCount)) if (unlikely (fd >= acc.fdCount))
@@ -746,13 +743,13 @@ struct SubrSubsetter
return true; 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 (); unsigned int count = remap.get_count ();
if (unlikely (!buffArray.resize (count))) if (unlikely (!buffArray.resize (count)))
return false; 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]; hb_codepoint_t new_num = remap[old_num];
if (new_num != CFF_UNDEF_CODE) if (new_num != CFF_UNDEF_CODE)
@@ -764,20 +761,20 @@ struct SubrSubsetter
return true; 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); 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); return encode_subrs (parsed_local_subrs[fd], remaps.local_remaps[fd], fd, buffArray);
} }
protected: protected:
struct DropHintsParam struct drop_hints_param_t
{ {
DropHintsParam () drop_hints_param_t ()
: seen_moveto (false), : seen_moveto (false),
ends_in_hint (false), ends_in_hint (false),
vsindex_dropped (false) {} vsindex_dropped (false) {}
@@ -787,9 +784,9 @@ struct SubrSubsetter
bool vsindex_dropped; bool vsindex_dropped;
}; };
bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos, bool drop_hints_in_subr (parsed_cs_str_t &str, unsigned int pos,
ParsedCStrs &subrs, unsigned int subr_num, parsed_cs_str_vec_t &subrs, unsigned int subr_num,
const SubrSubsetParam &param, DropHintsParam &drop) const subr_subset_param_t &param, drop_hints_param_t &drop)
{ {
drop.ends_in_hint = false; drop.ends_in_hint = false;
bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop); 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 */ /* returns true if it sees a hint op before the first moveto */
bool drop_hints_in_str (ParsedCStr &str, const SubrSubsetParam &param, DropHintsParam &drop) bool drop_hints_in_str (parsed_cs_str_t &str, const subr_subset_param_t &param, drop_hints_param_t &drop)
{ {
bool seen_hint = false; 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; bool has_hint = false;
switch (str.values[pos].op) switch (str.values[pos].op)
@@ -868,7 +865,7 @@ struct SubrSubsetter
{ {
for (int i = pos - 1; i >= 0; i--) 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 ()) if (csop.for_drop ())
break; break;
csop.set_drop (); csop.set_drop ();
@@ -882,18 +879,18 @@ struct SubrSubsetter
return seen_hint; return seen_hint;
} }
void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos, void collect_subr_refs_in_subr (parsed_cs_str_t &str, unsigned int pos,
unsigned int subr_num, ParsedCStrs &subrs, unsigned int subr_num, parsed_cs_str_vec_t &subrs,
hb_set_t *closure, hb_set_t *closure,
const SubrSubsetParam &param) const subr_subset_param_t &param)
{ {
hb_set_add (closure, subr_num); hb_set_add (closure, subr_num);
collect_subr_refs_in_str (subrs[subr_num], param); collect_subr_refs_in_str (subrs[subr_num], param);
} }
void collect_subr_refs_in_str (ParsedCStr &str, const SubrSubsetParam &param) void collect_subr_refs_in_str (parsed_cs_str_t &str, const subr_subset_param_t &param)
{ {
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 ()) 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 (); buff.init ();
StrEncoder encoder (buff); str_encoder_t encoder (buff);
encoder.reset (); encoder.reset ();
/* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints, /* if a prefix (CFF1 width or CFF2 vsindex) has been removed along with hints,
* re-insert it at the beginning of charstreing */ * re-insert it at the beginning of charstreing */
@@ -932,7 +929,7 @@ struct SubrSubsetter
} }
for (unsigned int i = 0; i < str.get_count(); i++) 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 ()) if (!opstr.for_drop () && !opstr.for_skip ())
{ {
switch (opstr.op) switch (opstr.op)
@@ -957,18 +954,19 @@ struct SubrSubsetter
} }
protected: protected:
SubrClosures closures; subr_closures_t closures;
ParsedCStrs parsed_charstrings; parsed_cs_str_vec_t parsed_charstrings;
ParsedCStrs parsed_global_subrs; parsed_cs_str_vec_t parsed_global_subrs;
hb_vector_t<ParsedCStrs> parsed_local_subrs; hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
SubrRemaps remaps; subr_remap_ts remaps;
private: private:
typedef typename SUBRS::count_type subr_count_type; typedef typename SUBRS::count_type subr_count_type;
}; };
}; /* namespace CFF */
} /* namespace CFF */
HB_INTERNAL bool HB_INTERNAL bool
hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs, hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
@@ -977,8 +975,8 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
unsigned int &subset_fd_count /* OUT */, unsigned int &subset_fd_count /* OUT */,
unsigned int &subset_fdselect_size /* OUT */, unsigned int &subset_fdselect_size /* OUT */,
unsigned int &subset_fdselect_format /* OUT */, unsigned int &subset_fdselect_format /* OUT */,
hb_vector_t<CFF::code_pair> &fdselect_ranges /* OUT */, hb_vector_t<CFF::code_pair_t> &fdselect_ranges /* OUT */,
CFF::Remap &fdmap /* OUT */); CFF::remap_t &fdmap /* OUT */);
HB_INTERNAL bool HB_INTERNAL bool
hb_serialize_cff_fdselect (hb_serialize_context_t *c, 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 fd_count,
unsigned int fdselect_format, unsigned int fdselect_format,
unsigned int size, unsigned int size,
const hb_vector_t<CFF::code_pair> &fdselect_ranges); const hb_vector_t<CFF::code_pair_t> &fdselect_ranges);
#endif /* HB_SUBSET_CFF_COMMON_HH */ #endif /* HB_SUBSET_CFF_COMMON_HH */

View File

@@ -34,12 +34,12 @@
using namespace CFF; using namespace CFF;
struct RemapSID : Remap struct remap_sid_t : remap_t
{ {
unsigned int add (unsigned int sid) unsigned int add (unsigned int sid)
{ {
if ((sid != CFF_UNDEF_SID) && !is_std_std (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 else
return sid; return sid;
} }
@@ -49,7 +49,7 @@ struct RemapSID : Remap
if (is_std_std (sid) || (sid == CFF_UNDEF_SID)) if (is_std_std (sid) || (sid == CFF_UNDEF_SID))
return sid; return sid;
else 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; 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; } 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 () cff1_sub_table_offsets_t ()
: CFFSubTableOffsets (), : cff_sub_table_offsets_t (),
nameIndexOffset (0), nameIndexOffset (0),
encodingOffset (0) encodingOffset (0)
{ {
@@ -72,16 +72,16 @@ struct CFF1SubTableOffsets : CFFSubTableOffsets
} }
unsigned int nameIndexOffset; unsigned int nameIndexOffset;
TableInfo stringIndexInfo; table_info_t stringIndexInfo;
unsigned int encodingOffset; unsigned int encodingOffset;
TableInfo charsetInfo; table_info_t charsetInfo;
TableInfo privateDictInfo; table_info_t privateDictInfo;
}; };
/* a copy of a parsed out CFF1TopDictValues augmented with additional operators */ /* a copy of a parsed out cff1_top_dict_values_t augmented with additional operators */
struct CFF1TopDictValuesMod : CFF1TopDictValues 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 (); SUPER::init ();
base = base_; base = base_;
@@ -90,47 +90,47 @@ struct CFF1TopDictValuesMod : CFF1TopDictValues
void fini () { SUPER::fini (); } void fini () { SUPER::fini (); }
unsigned get_count () const { return base->get_count () + SUPER::get_count (); } 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 ()) if (i < base->get_count ())
return (*base)[i]; return (*base)[i];
else else
return SUPER::values[i - base->get_count ()]; 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]]; nameSIDs[i] = sidmap[base->nameSIDs[i]];
} }
protected: protected:
typedef CFF1TopDictValues SUPER; typedef cff1_top_dict_values_t SUPER;
const CFF1TopDictValues *base; const cff1_top_dict_values_t *base;
}; };
struct TopDictModifiers struct top_dict_modifiers_t
{ {
TopDictModifiers (const CFF1SubTableOffsets &offsets_, top_dict_modifiers_t (const cff1_sub_table_offsets_t &offsets_,
const unsigned int (&nameSIDs_)[NameDictValues::ValCount]) const unsigned int (&nameSIDs_)[name_dict_values_t::ValCount])
: offsets (offsets_), : offsets (offsets_),
nameSIDs (nameSIDs_) nameSIDs (nameSIDs_)
{} {}
const CFF1SubTableOffsets &offsets; const cff1_sub_table_offsets_t &offsets;
const unsigned int (&nameSIDs)[NameDictValues::ValCount]; const unsigned int (&nameSIDs)[name_dict_values_t::ValCount];
}; };
struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal> struct cff1_top_dict_op_serializer_t : cff_top_dict_op_serializer_t<cff1_top_dict_val_t>
{ {
bool serialize (hb_serialize_context_t *c, bool serialize (hb_serialize_context_t *c,
const CFF1TopDictVal &opstr, const cff1_top_dict_val_t &opstr,
const TopDictModifiers &mod) const const top_dict_modifiers_t &mod) const
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
OpCode op = opstr.op; op_code_t op = opstr.op;
switch (op) switch (op)
{ {
case OpCode_charset: case OpCode_charset:
@@ -160,31 +160,30 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
case OpCode_PostScript: case OpCode_PostScript:
case OpCode_BaseFontName: case OpCode_BaseFontName:
case OpCode_FontName: 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: case OpCode_ROS:
{ {
/* for registry & ordering, reassigned SIDs are serialized /* for registry & ordering, reassigned SIDs are serialized
* for supplement, the original byte string is copied along with the op code */ * 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.op = op;
supp_op.str.str = opstr.str.str + opstr.last_arg_offset; if ( unlikely (!(opstr.str.length >= opstr.last_arg_offset + 3)))
if ( unlikely (!(opstr.str.len >= opstr.last_arg_offset + 3)))
return_trace (false); return_trace (false);
supp_op.str.len = opstr.str.len - opstr.last_arg_offset; 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[NameDictValues::registry]) && return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::registry]) &&
UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) && UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[name_dict_values_t::ordering]) &&
copy_opstr (c, supp_op)); copy_opstr (c, supp_op));
} }
default: default:
return_trace (CFFTopDict_OpSerializer<CFF1TopDictVal>::serialize (c, opstr, mod.offsets)); return_trace (cff_top_dict_op_serializer_t<cff1_top_dict_val_t>::serialize (c, opstr, mod.offsets));
} }
return_trace (true); 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) switch (op)
{ {
case OpCode_charset: case OpCode_charset:
@@ -206,19 +205,19 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op); return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op);
case OpCode_ROS: 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: default:
return CFFTopDict_OpSerializer<CFF1TopDictVal>::calculate_serialized_size (opstr); return cff_top_dict_op_serializer_t<cff1_top_dict_val_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_, unsigned int fontName_,
const TableInfo &privateDictInfo_) const table_info_t &privateDictInfo_)
{ {
base = base_; base = base_;
fontName = fontName_; fontName = fontName_;
@@ -227,18 +226,18 @@ struct FontDictValuesMod
unsigned get_count () const { return base->get_count (); } 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; const cff1_font_dict_values_t *base;
TableInfo privateDictInfo; table_info_t privateDictInfo;
unsigned int fontName; 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, bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const op_str_t &opstr,
const FontDictValuesMod &mod) const const font_dict_values_mod_t &mod) const
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
@@ -248,7 +247,7 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
return_trace (SUPER::serialize (c, opstr, mod.privateDictInfo)); 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) if (opstr.op == OpCode_FontName)
return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName); return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_FontName);
@@ -257,12 +256,12 @@ struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer
} }
private: private:
typedef CFFFontDict_OpSerializer SUPER; typedef cff_font_dict_op_serializer_t SUPER;
}; };
struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> struct cff1_cs_opset_flatten_t : cff1_cs_opset_t<cff1_cs_opset_flatten_t, flatten_param_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) if (env.arg_start > 0)
flush_width (env, param); flush_width (env, param);
@@ -288,51 +287,51 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
break; 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++) for (unsigned int i = env.arg_start; i < env.argStack.get_count (); i++)
encoder.encode_num (env.eval_arg (i)); encoder.encode_num (env.eval_arg (i));
SUPER::flush_args (env, param); 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); 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); assert (env.has_width);
StrEncoder encoder (param.flatStr); str_encoder_t encoder (param.flatStr);
encoder.encode_num (env.width); 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); SUPER::flush_hintmask (op, env, param);
if (!param.drop_hints) if (!param.drop_hints)
{ {
StrEncoder encoder (param.flatStr); str_encoder_t encoder (param.flatStr);
for (unsigned int i = 0; i < env.hintmask_size; i++) for (unsigned int i = 0; i < env.hintmask_size; i++)
encoder.encode_byte (env.substr[i]); encoder.encode_byte (env.str_ref[i]);
} }
} }
private: private:
typedef CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam> SUPER; typedef cff1_cs_opset_t<cff1_cs_opset_flatten_t, flatten_param_t> SUPER;
}; };
struct RangeList : hb_vector_t<code_pair> struct range_list_t : hb_vector_t<code_pair_t>
{ {
/* replace the first glyph ID in the "glyph" field each range with a nLeft value */ /* replace the first glyph ID in the "glyph" field each range with a nLeft value */
bool finalize (unsigned int last_glyph) bool finalize (unsigned int last_glyph)
{ {
bool two_byte = false; 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; unsigned int nLeft = last_glyph - pair.glyph - 1;
if (nLeft >= 0x100) if (nLeft >= 0x100)
two_byte = true; two_byte = true;
@@ -343,21 +342,21 @@ struct RangeList : hb_vector_t<code_pair>
} }
}; };
struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam> struct cff1_cs_opset_subr_subset_t : cff1_cs_opset_t<cff1_cs_opset_subr_subset_t, subr_subset_param_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) { switch (op) {
case OpCode_return: 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 (); param.current_parsed_str->set_parsed ();
env.returnFromSubr (); env.returnFromSubr ();
param.set_current_str (env, false); param.set_current_str (env, false);
break; break;
case OpCode_endchar: 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 (); param.current_parsed_str->set_parsed ();
SUPER::process_op (op, env, param); SUPER::process_op (op, env, param);
break; break;
@@ -372,30 +371,30 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetPa
default: default:
SUPER::process_op (op, env, param); SUPER::process_op (op, env, param);
param.current_parsed_str->add_op (op, env.substr); param.current_parsed_str->add_op (op, env.str_ref);
break; break;
} }
} }
protected: protected:
static void process_call_subr (OpCode op, CSType type, static void process_call_subr (op_code_t op, cs_type_t type,
CFF1CSInterpEnv &env, SubrSubsetParam& param, cff1_cs_interp_env_t &env, subr_subset_param_t& param,
CFF1BiasedSubrs& subrs, hb_set_t *closure) 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); 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); hb_set_add (closure, env.context.subr_num);
param.set_current_str (env, true); param.set_current_str (env, true);
} }
private: private:
typedef CFF1CSOpSet<CFF1CSOpSet_SubrSubset, SubrSubsetParam> SUPER; typedef cff1_cs_opset_t<cff1_cs_opset_subr_subset_t, subr_subset_param_t> SUPER;
}; };
struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_SubrSubset> struct cff1_subr_subsetter_t : subr_subsetter_t<cff1_subr_subsetter_t, CFF1Subrs, const OT::cff1::accelerator_subset_t, cff1_cs_interp_env_t, cff1_cs_opset_subr_subset_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 */ /* insert width at the beginning of the charstring as necessary */
if (env.has_width) if (env.has_width)
@@ -407,7 +406,7 @@ struct CFF1SubrSubsetter : SubrSubsetter<CFF1SubrSubsetter, CFF1Subrs, const OT:
param.current_parsed_str->set_parsed (); param.current_parsed_str->set_parsed ();
for (unsigned int i = 0; i < env.callStack.get_count (); i++) 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)) if (likely (parsed_str != nullptr))
parsed_str->set_parsed (); parsed_str->set_parsed ();
else else
@@ -439,7 +438,7 @@ struct cff_subset_plan {
subset_enc_supp_codes.init (); subset_enc_supp_codes.init ();
subset_charset_ranges.init (); subset_charset_ranges.init ();
sidmap.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; topDictModSIDs[i] = CFF_UNDEF_SID;
} }
@@ -454,10 +453,9 @@ struct cff_subset_plan {
subset_localsubrs.fini_deep (); subset_localsubrs.fini_deep ();
fontdicts_mod.fini (); fontdicts_mod.fini ();
subset_enc_code_ranges.fini (); subset_enc_code_ranges.fini ();
subset_enc_supp_codes.init (); subset_enc_supp_codes.fini ();
subset_charset_ranges.fini (); subset_charset_ranges.fini ();
sidmap.fini (); sidmap.fini ();
fontdicts_mod.fini ();
} }
unsigned int plan_subset_encoding (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) 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_size = 0;
supp_codes.init (); supp_codes.init ();
subset_enc_num_codes = plan->glyphs.len - 1; subset_enc_num_codes = plan->glyphs.length - 1;
unsigned int glyph; 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]; hb_codepoint_t orig_glyph = plan->glyphs[glyph];
code = acc.glyph_to_code (orig_glyph); code = acc.glyph_to_code (orig_glyph);
@@ -485,7 +483,7 @@ struct cff_subset_plan {
if (code != last_code + 1) if (code != last_code + 1)
{ {
code_pair pair = { code, glyph }; code_pair_t pair = { code, glyph };
subset_enc_code_ranges.push (pair); subset_enc_code_ranges.push (pair);
} }
last_code = code; last_code = code;
@@ -494,12 +492,12 @@ struct cff_subset_plan {
{ {
hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph); hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph);
encoding->get_supplement_codes (sid, supp_codes); 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); 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 (); supp_codes.fini ();
@@ -508,7 +506,7 @@ struct cff_subset_plan {
assert (subset_enc_num_codes <= 0xFF); assert (subset_enc_num_codes <= 0xFF);
size0 = Encoding0::min_size + HBUINT8::static_size * subset_enc_num_codes; 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) if (size0 < size1)
subset_enc_format = 0; subset_enc_format = 0;
@@ -517,8 +515,8 @@ struct cff_subset_plan {
return Encoding::calculate_serialized_size ( return Encoding::calculate_serialized_size (
subset_enc_format, subset_enc_format,
subset_enc_format? subset_enc_code_ranges.len: subset_enc_num_codes, subset_enc_format? subset_enc_code_ranges.length: subset_enc_num_codes,
subset_enc_supp_codes.len); subset_enc_supp_codes.length);
} }
unsigned int plan_subset_charset (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) 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); subset_charset_ranges.resize (0);
unsigned int glyph; 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]; hb_codepoint_t orig_glyph = plan->glyphs[glyph];
sid = acc.glyph_to_sid (orig_glyph); sid = acc.glyph_to_sid (orig_glyph);
@@ -538,7 +536,7 @@ struct cff_subset_plan {
if (sid != last_sid + 1) if (sid != last_sid + 1)
{ {
code_pair pair = { sid, glyph }; code_pair_t pair = { sid, glyph };
subset_charset_ranges.push (pair); subset_charset_ranges.push (pair);
} }
last_sid = sid; last_sid = sid;
@@ -546,11 +544,11 @@ struct cff_subset_plan {
bool two_byte = subset_charset_ranges.finalize (glyph); 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) 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 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) if (size0 < size_ranges)
subset_charset_format = 0; subset_charset_format = 0;
@@ -561,7 +559,7 @@ struct cff_subset_plan {
return Charset::calculate_serialized_size ( return Charset::calculate_serialized_size (
subset_charset_format, 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) 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))) if (unlikely (!sidmap.reset (acc.stringIndex->count)))
return false; 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]; unsigned int sid = acc.topDict.nameSIDs[i];
if (sid != CFF_UNDEF_SID) if (sid != CFF_UNDEF_SID)
@@ -591,17 +589,17 @@ struct cff_subset_plan {
hb_subset_plan_t *plan) hb_subset_plan_t *plan)
{ {
/* make sure notdef is first */ /* 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; final_size = 0;
num_glyphs = plan->glyphs.len; num_glyphs = plan->glyphs.length;
orig_fdcount = acc.fdCount; orig_fdcount = acc.fdCount;
drop_hints = plan->drop_hints; drop_hints = plan->drop_hints;
desubroutinize = plan->desubroutinize; desubroutinize = plan->desubroutinize;
/* check whether the subset renumbers any glyph IDs */ /* check whether the subset renumbers any glyph IDs */
gid_renum = false; 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) { if (plan->glyphs[glyph] != glyph) {
gid_renum = true; gid_renum = true;
@@ -633,12 +631,12 @@ struct cff_subset_plan {
topdict_mod.add_op (OpCode_charset); topdict_mod.add_op (OpCode_charset);
} }
offsets.topDictInfo.offset = final_size; 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); unsigned int topDictSize = TopDict::calculate_serialized_size (topdict_mod, topSzr);
offsets.topDictInfo.offSize = calcOffSize(topDictSize); offsets.topDictInfo.offSize = calcOffSize(topDictSize);
if (unlikely (offsets.topDictInfo.offSize > 4)) if (unlikely (offsets.topDictInfo.offSize > 4))
return false; return false;
final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<CFF1TopDictValuesMod> final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<cff1_top_dict_values_mod_t>
(offsets.topDictInfo.offSize, (offsets.topDictInfo.offSize,
&topdict_mod, 1, topdict_sizes, topSzr); &topdict_mod, 1, topdict_sizes, topSzr);
} }
@@ -682,7 +680,7 @@ struct cff_subset_plan {
if (desubroutinize) if (desubroutinize)
{ {
/* Flatten global & local subrs */ /* Flatten global & local subrs */
SubrFlattener<const OT::cff1::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_Flatten> subr_flattener_t<const OT::cff1::accelerator_subset_t, cff1_cs_interp_env_t, cff1_cs_opset_flatten_t>
flattener(acc, plan->glyphs, plan->drop_hints); flattener(acc, plan->glyphs, plan->drop_hints);
if (!flattener.flatten (subset_charstrings)) if (!flattener.flatten (subset_charstrings))
return false; return false;
@@ -708,7 +706,7 @@ struct cff_subset_plan {
offsets.globalSubrsInfo.offSize = calcOffSize (dataSize); offsets.globalSubrsInfo.offSize = calcOffSize (dataSize);
if (unlikely (offsets.globalSubrsInfo.offSize > 4)) if (unlikely (offsets.globalSubrsInfo.offSize > 4))
return false; 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 */ /* local subrs */
if (!offsets.localSubrsInfos.resize (orig_fdcount)) if (!offsets.localSubrsInfos.resize (orig_fdcount))
@@ -731,7 +729,7 @@ struct cff_subset_plan {
offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize);
if (unlikely (offsets.localSubrsInfos[fd].offSize > 4)) if (unlikely (offsets.localSubrsInfos[fd].offSize > 4))
return false; 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) */ /* FDArray (FDIndex) */
if (acc.fdArray != &Null(CFF1FDArray)) { if (acc.fdArray != &Null(CFF1FDArray)) {
offsets.FDArrayInfo.offset = final_size; offsets.FDArrayInfo.offset = final_size;
CFF1FontDict_OpSerializer fontSzr; cff1_font_dict_op_serializer_t fontSzr;
unsigned int dictsSize = 0; 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)) if (fdmap.includes (i))
dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr);
@@ -786,7 +784,7 @@ struct cff_subset_plan {
offsets.charStringsInfo.offSize = calcOffSize (dataSize); offsets.charStringsInfo.offSize = calcOffSize (dataSize);
if (unlikely (offsets.charStringsInfo.offSize > 4)) if (unlikely (offsets.charStringsInfo.offSize > 4))
return false; 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 */ /* private dicts & local subrs */
@@ -796,12 +794,12 @@ struct cff_subset_plan {
if (fdmap.includes (i)) if (fdmap.includes (i))
{ {
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; 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); 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 };
FontDictValuesMod fontdict_mod; font_dict_values_mod_t fontdict_mod;
if (!acc.is_CID ()) 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 else
fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo ); fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo );
fontdicts_mod.push (fontdict_mod); fontdicts_mod.push (fontdict_mod);
@@ -818,50 +816,50 @@ struct cff_subset_plan {
if (!acc.is_CID ()) if (!acc.is_CID ())
offsets.privateDictInfo = fontdicts_mod[0].privateDictInfo; offsets.privateDictInfo = fontdicts_mod[0].privateDictInfo;
return ((subset_charstrings.len == plan->glyphs.len) return ((subset_charstrings.length == plan->glyphs.length)
&& (fontdicts_mod.len == subset_fdcount)); && (fontdicts_mod.length == subset_fdcount));
} }
unsigned int get_final_size () const { return final_size; } unsigned int get_final_size () const { return final_size; }
unsigned int final_size; unsigned int final_size;
hb_vector_t<unsigned int> topdict_sizes; hb_vector_t<unsigned int> topdict_sizes;
CFF1TopDictValuesMod topdict_mod; cff1_top_dict_values_mod_t topdict_mod;
CFF1SubTableOffsets offsets; cff1_sub_table_offsets_t offsets;
unsigned int num_glyphs; unsigned int num_glyphs;
unsigned int orig_fdcount; unsigned int orig_fdcount;
unsigned int subset_fdcount; unsigned int subset_fdcount;
unsigned int subset_fdselect_format; unsigned int subset_fdselect_format;
hb_vector_t<code_pair> subset_fdselect_ranges; hb_vector_t<code_pair_t> subset_fdselect_ranges;
/* font dict index remap table from fullset FDArray to subset FDArray. /* font dict index remap table from fullset FDArray to subset FDArray.
* set to CFF_UNDEF_CODE if excluded from subset */ * set to CFF_UNDEF_CODE if excluded from subset */
Remap fdmap; remap_t fdmap;
StrBuffArray subset_charstrings; str_buff_vec_t subset_charstrings;
StrBuffArray subset_globalsubrs; str_buff_vec_t subset_globalsubrs;
hb_vector_t<StrBuffArray> subset_localsubrs; hb_vector_t<str_buff_vec_t> subset_localsubrs;
hb_vector_t<FontDictValuesMod> fontdicts_mod; hb_vector_t<font_dict_values_mod_t> fontdicts_mod;
bool drop_hints; bool drop_hints;
bool gid_renum; bool gid_renum;
bool subset_encoding; bool subset_encoding;
uint8_t subset_enc_format; uint8_t subset_enc_format;
unsigned int subset_enc_num_codes; unsigned int subset_enc_num_codes;
RangeList subset_enc_code_ranges; range_list_t subset_enc_code_ranges;
hb_vector_t<code_pair> subset_enc_supp_codes; hb_vector_t<code_pair_t> subset_enc_supp_codes;
uint8_t subset_charset_format; uint8_t subset_charset_format;
RangeList subset_charset_ranges; range_list_t subset_charset_ranges;
bool subset_charset; bool subset_charset;
RemapSID sidmap; remap_sid_t sidmap;
unsigned int topDictModSIDs[NameDictValues::ValCount]; unsigned int topDictModSIDs[name_dict_values_t::ValCount];
bool desubroutinize; bool desubroutinize;
CFF1SubrSubsetter subr_subsetter; cff1_subr_subsetter_t subr_subsetter;
}; };
static inline bool _write_cff1 (const cff_subset_plan &plan, 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); hb_serialize_context_t c (dest, dest_sz);
char RETURN_OP[1] = { OpCode_return };
const ByteStr NULL_SUBR (RETURN_OP, 1);
OT::cff1 *cff = c.start_serialize<OT::cff1> (); OT::cff1 *cff = c.start_serialize<OT::cff1> ();
if (unlikely (!c.extend_min (*cff))) if (unlikely (!c.extend_min (*cff)))
return false; return false;
@@ -887,7 +882,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* name INDEX */ /* name INDEX */
{ {
assert (cff->nameIndex == c.head - c.start); assert (cff->nameIndex == (unsigned) (c.head - c.start));
CFF1NameIndex *dest = c.start_embed<CFF1NameIndex> (); CFF1NameIndex *dest = c.start_embed<CFF1NameIndex> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, *acc.nameIndex))) if (unlikely (!dest->serialize (&c, *acc.nameIndex)))
@@ -899,11 +894,11 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* top dict INDEX */ /* top dict INDEX */
{ {
assert (plan.offsets.topDictInfo.offset == c.head - c.start); assert (plan.offsets.topDictInfo.offset == (unsigned) (c.head - c.start));
CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > (); CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
if (dest == nullptr) return false; if (dest == nullptr) return false;
CFF1TopDict_OpSerializer topSzr; cff1_top_dict_op_serializer_t topSzr;
TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs); top_dict_modifiers_t modifier (plan.offsets, plan.topDictModSIDs);
if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize, if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize,
&plan.topdict_mod, 1, &plan.topdict_mod, 1,
plan.topdict_sizes, topSzr, modifier))) plan.topdict_sizes, topSzr, modifier)))
@@ -915,7 +910,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* String INDEX */ /* 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<CFF1StringIndex> (); CFF1StringIndex *dest = c.start_embed<CFF1StringIndex> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, *acc.stringIndex, plan.offsets.stringIndexInfo.offSize, plan.sidmap))) 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 */ /* global subrs */
{ {
assert (plan.offsets.globalSubrsInfo.offset != 0); 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 <CFF1Subrs> (); CFF1Subrs *dest = c.start_embed <CFF1Subrs> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
@@ -942,7 +937,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* Encoding */ /* Encoding */
if (plan.subset_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<Encoding> (); Encoding *dest = c.start_embed<Encoding> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, if (unlikely (!dest->serialize (&c,
@@ -959,7 +954,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* Charset */ /* Charset */
if (plan.subset_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<Charset> (); Charset *dest = c.start_embed<Charset> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, if (unlikely (!dest->serialize (&c,
@@ -975,9 +970,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* FDSelect */ /* FDSelect */
if (acc.fdSelect != &Null(CFF1FDSelect)) 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_format, plan.offsets.FDSelectInfo.size,
plan.subset_fdselect_ranges))) plan.subset_fdselect_ranges)))
{ {
@@ -989,10 +984,10 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* FDArray (FD Index) */ /* FDArray (FD Index) */
if (acc.fdArray != &Null(CFF1FDArray)) 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<CFF1FDArray> (); CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
if (unlikely (fda == nullptr)) return false; 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, if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
plan.fontdicts_mod, plan.fontdicts_mod,
fontSzr))) fontSzr)))
@@ -1004,7 +999,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
/* CharStrings */ /* 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<CFF1CharStrings> (); CFF1CharStrings *cs = c.start_embed<CFF1CharStrings> ();
if (unlikely (cs == nullptr)) return false; if (unlikely (cs == nullptr)) return false;
if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) 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 */ /* private dicts & local subrs */
assert (plan.offsets.privateDictInfo.offset == c.head - c.start); assert (plan.offsets.privateDictInfo.offset == (unsigned) (c.head - c.start));
for (unsigned int i = 0; i < acc.privateDicts.len; i++) for (unsigned int i = 0; i < acc.privateDicts.length; i++)
{ {
if (plan.fdmap.includes (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; if (unlikely (pd == nullptr)) return false;
unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size; unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size;
bool result; 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 */ /* 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; unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); 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 static bool
_hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc, _hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc,
const char *data, const char *data,
hb_subset_plan_t *plan, hb_subset_plan_t *plan,
hb_blob_t **prime /* OUT */) hb_blob_t **prime /* OUT */)
{ {
cff_subset_plan cff_plan; cff_subset_plan cff_plan;

View File

@@ -34,21 +34,21 @@
using namespace CFF; using namespace CFF;
struct CFF2SubTableOffsets : CFFSubTableOffsets struct cff2_sub_table_offsets_t : cff_sub_table_offsets_t
{ {
CFF2SubTableOffsets () cff2_sub_table_offsets_t ()
: CFFSubTableOffsets (), : cff_sub_table_offsets_t (),
varStoreOffset (0) varStoreOffset (0)
{} {}
unsigned int varStoreOffset; 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, bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const op_str_t &opstr,
const CFF2SubTableOffsets &offsets) const const cff2_sub_table_offsets_t &offsets) const
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
@@ -58,11 +58,11 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset)); return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset));
default: 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) switch (opstr.op)
{ {
@@ -70,14 +70,14 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
default: default:
return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); return cff_top_dict_op_serializer_t<>::calculate_serialized_size (opstr);
} }
} }
}; };
struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> struct cff2_cs_opset_flatten_t : cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatten_param_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) switch (op)
{ {
@@ -105,11 +105,11 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
} }
} }
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 ();) 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 (arg.blending ())
{ {
if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues)))) if (unlikely (!((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues))))
@@ -122,7 +122,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
} }
else else
{ {
StrEncoder encoder (param.flatStr); str_encoder_t encoder (param.flatStr);
encoder.encode_num (arg); encoder.encode_num (arg);
i++; i++;
} }
@@ -130,15 +130,15 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
SUPER::flush_args (env, param); 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 */ /* flatten the default values */
StrEncoder encoder (param.flatStr); str_encoder_t encoder (param.flatStr);
for (unsigned int j = 0; j < arg.numValues; j++) 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) && 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 (); env.set_error ();
return; return;
@@ -148,8 +148,8 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
/* flatten deltas for each value */ /* flatten deltas for each value */
for (unsigned int j = 0; j < arg.numValues; j++) 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];
for (unsigned int k = 0; k < arg1.deltas.len; k++) for (unsigned int k = 0; k < arg1.deltas.length; k++)
encoder.encode_num (arg1.deltas[k]); encoder.encode_num (arg1.deltas[k]);
} }
/* flatten the number of values followed by blend operator */ /* flatten the number of values followed by blend operator */
@@ -157,7 +157,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
encoder.encode_op (OpCode_blendcs); 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) switch (op)
{ {
@@ -165,19 +165,19 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
case OpCode_endchar: case OpCode_endchar:
return; return;
default: default:
StrEncoder encoder (param.flatStr); str_encoder_t encoder (param.flatStr);
encoder.encode_op (op); encoder.encode_op (op);
} }
} }
private: private:
typedef CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam> SUPER; typedef cff2_cs_opset_t<cff2_cs_opset_flatten_t, flatten_param_t> SUPER;
typedef CSOpSet<BlendArg, CFF2CSOpSet_Flatten, CFF2CSOpSet_Flatten, CFF2CSInterpEnv, FlattenParam> CSOPSET; typedef cs_opset_t<blend_arg_t, cff2_cs_opset_flatten_t, cff2_cs_opset_flatten_t, cff2_cs_interp_env_t, flatten_param_t> CSOPSET;
}; };
struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam> struct cff2_cs_opset_subr_subset_t : cff2_cs_opset_t<cff2_cs_opset_subr_subset_t, subr_subset_param_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) { switch (op) {
@@ -202,35 +202,35 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetPa
default: default:
SUPER::process_op (op, env, param); SUPER::process_op (op, env, param);
param.current_parsed_str->add_op (op, env.substr); param.current_parsed_str->add_op (op, env.str_ref);
break; break;
} }
} }
protected: protected:
static void process_call_subr (OpCode op, CSType type, static void process_call_subr (op_code_t op, cs_type_t type,
CFF2CSInterpEnv &env, SubrSubsetParam& param, cff2_cs_interp_env_t &env, subr_subset_param_t& param,
CFF2BiasedSubrs& subrs, hb_set_t *closure) 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); 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); hb_set_add (closure, env.context.subr_num);
param.set_current_str (env, true); param.set_current_str (env, true);
} }
private: private:
typedef CFF2CSOpSet<CFF2CSOpSet_SubrSubset, SubrSubsetParam> SUPER; typedef cff2_cs_opset_t<cff2_cs_opset_subr_subset_t, subr_subset_param_t> SUPER;
}; };
struct CFF2SubrSubsetter : SubrSubsetter<CFF2SubrSubsetter, CFF2Subrs, const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_SubrSubset> struct cff2_subr_subsetter_t : subr_subsetter_t<cff2_subr_subsetter_t, CFF2Subrs, const OT::cff2::accelerator_subset_t, cff2_cs_interp_env_t, cff2_cs_opset_subr_subset_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 */ /* vsindex is inserted at the beginning of the charstring as necessary */
if (env.seen_vsindex ()) if (env.seen_vsindex ())
{ {
Number ivs; number_t ivs;
ivs.set_int ((int)env.get_ivs ()); ivs.set_int ((int)env.get_ivs ());
charstring.set_prefix (ivs, OpCode_vsindexcs); charstring.set_prefix (ivs, OpCode_vsindexcs);
} }
@@ -278,7 +278,7 @@ struct cff2_subset_plan {
/* top dict */ /* top dict */
{ {
CFF2TopDict_OpSerializer topSzr; cff2_top_dict_op_serializer_t topSzr;
offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr); offsets.topDictInfo.size = TopDict::calculate_serialized_size (acc.topDict, topSzr);
final_size += offsets.topDictInfo.size; final_size += offsets.topDictInfo.size;
} }
@@ -286,7 +286,7 @@ struct cff2_subset_plan {
if (desubroutinize) if (desubroutinize)
{ {
/* Flatten global & local subrs */ /* Flatten global & local subrs */
SubrFlattener<const OT::cff2::accelerator_subset_t, CFF2CSInterpEnv, CFF2CSOpSet_Flatten> subr_flattener_t<const OT::cff2::accelerator_subset_t, cff2_cs_interp_env_t, cff2_cs_opset_flatten_t>
flattener(acc, plan->glyphs, plan->drop_hints); flattener(acc, plan->glyphs, plan->drop_hints);
if (!flattener.flatten (subset_charstrings)) if (!flattener.flatten (subset_charstrings))
return false; return false;
@@ -310,7 +310,7 @@ struct cff2_subset_plan {
/* global subrs */ /* global subrs */
unsigned int dataSize = subset_globalsubrs.total_size (); unsigned int dataSize = subset_globalsubrs.total_size ();
offsets.globalSubrsInfo.offSize = calcOffSize (dataSize); 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 */ /* local subrs */
if (!offsets.localSubrsInfos.resize (orig_fdcount)) if (!offsets.localSubrsInfos.resize (orig_fdcount))
@@ -331,7 +331,7 @@ struct cff2_subset_plan {
{ {
offsets.localSubrsInfos[fd].offset = final_size; offsets.localSubrsInfos[fd].offset = final_size;
offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); 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) */ /* FDArray (FDIndex) */
{ {
offsets.FDArrayInfo.offset = final_size; offsets.FDArrayInfo.offset = final_size;
CFFFontDict_OpSerializer fontSzr; cff_font_dict_op_serializer_t fontSzr;
unsigned int dictsSize = 0; 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)) if (fdmap.includes (i))
dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr);
@@ -385,7 +385,7 @@ struct cff2_subset_plan {
offsets.charStringsInfo.offset = final_size; offsets.charStringsInfo.offset = final_size;
unsigned int dataSize = subset_charstrings.total_size (); unsigned int dataSize = subset_charstrings.total_size ();
offsets.charStringsInfo.offSize = calcOffSize (dataSize); 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 */ /* private dicts & local subrs */
@@ -395,9 +395,9 @@ struct cff2_subset_plan {
if (fdmap.includes (i)) if (fdmap.includes (i))
{ {
bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; 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); 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); privateDictInfos.push (privInfo);
final_size += privInfo.size; final_size += privInfo.size;
@@ -415,23 +415,23 @@ struct cff2_subset_plan {
unsigned int get_final_size () const { return final_size; } unsigned int get_final_size () const { return final_size; }
unsigned int final_size; unsigned int final_size;
CFF2SubTableOffsets offsets; cff2_sub_table_offsets_t offsets;
unsigned int orig_fdcount; unsigned int orig_fdcount;
unsigned int subset_fdcount; unsigned int subset_fdcount;
unsigned int subset_fdselect_format; unsigned int subset_fdselect_format;
hb_vector_t<code_pair> subset_fdselect_ranges; hb_vector_t<code_pair_t> subset_fdselect_ranges;
Remap fdmap; remap_t fdmap;
StrBuffArray subset_charstrings; str_buff_vec_t subset_charstrings;
StrBuffArray subset_globalsubrs; str_buff_vec_t subset_globalsubrs;
hb_vector_t<StrBuffArray> subset_localsubrs; hb_vector_t<str_buff_vec_t> subset_localsubrs;
hb_vector_t<TableInfo> privateDictInfos; hb_vector_t<table_info_t> privateDictInfos;
bool drop_hints; bool drop_hints;
bool desubroutinize; bool desubroutinize;
CFF2SubrSubsetter subr_subsetter; cff2_subr_subsetter_t subr_subsetter;
}; };
static inline bool _write_cff2 (const cff2_subset_plan &plan, 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 */ /* top dict */
{ {
assert (cff2->topDict == c.head - c.start); assert (cff2->topDict == (unsigned) (c.head - c.start));
cff2->topDictSize.set (plan.offsets.topDictInfo.size); cff2->topDictSize.set (plan.offsets.topDictInfo.size);
TopDict &dict = cff2 + cff2->topDict; 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))) if (unlikely (!dict.serialize (&c, acc.topDict, topSzr, plan.offsets)))
{ {
DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 top dict"); 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 */ /* 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 <CFF2Subrs> (); CFF2Subrs *dest = c.start_embed <CFF2Subrs> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs))) 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 */ /* variation store */
if (acc.varStore != &Null(CFF2VariationStore)) 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<CFF2VariationStore> (); CFF2VariationStore *dest = c.start_embed<CFF2VariationStore> ();
if (unlikely (!dest->serialize (&c, acc.varStore))) if (unlikely (!dest->serialize (&c, acc.varStore)))
{ {
@@ -491,9 +491,9 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
/* FDSelect */ /* FDSelect */
if (acc.fdSelect != &Null(CFF2FDSelect)) 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_format, plan.offsets.FDSelectInfo.size,
plan.subset_fdselect_ranges))) plan.subset_fdselect_ranges)))
{ {
@@ -504,10 +504,10 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
/* FDArray (FD Index) */ /* 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<CFF2FDArray> (); CFF2FDArray *fda = c.start_embed<CFF2FDArray> ();
if (unlikely (fda == nullptr)) return false; 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, if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
acc.fontDicts, plan.subset_fdcount, plan.fdmap, acc.fontDicts, plan.subset_fdcount, plan.fdmap,
fontSzr, plan.privateDictInfos))) fontSzr, plan.privateDictInfos)))
@@ -519,7 +519,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
/* CharStrings */ /* 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<CFF2CharStrings> (); CFF2CharStrings *cs = c.start_embed<CFF2CharStrings> ();
if (unlikely (cs == nullptr)) return false; if (unlikely (cs == nullptr)) return false;
if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) 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 */ /* private dicts & local subrs */
assert (plan.offsets.privateDictsOffset == c.head - c.start); assert (plan.offsets.privateDictsOffset == (unsigned) (c.head - c.start));
for (unsigned int i = 0; i < acc.privateDicts.len; i++) for (unsigned int i = 0; i < acc.privateDicts.length; i++)
{ {
if (plan.fdmap.includes (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; if (unlikely (pd == nullptr)) return false;
unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size; unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size;
bool result; 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 */ /* 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; unsigned int subroffset = (plan.offsets.localSubrsInfos[i].size > 0)? priv_size: 0;
result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset);

View File

@@ -39,17 +39,17 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
hb_vector_t<unsigned int> *instruction_ranges /* OUT */) hb_vector_t<unsigned int> *instruction_ranges /* OUT */)
{ {
unsigned int total = 0; 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]; 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."); DEBUG_MSG(SUBSET, nullptr, "Failed to resize instruction_ranges.");
return false; 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; *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; *instruction_end = 0;
unsigned int start_offset, end_offset; 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; *glyf_size = total;
*use_short_loca = (total <= 131070); *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)); * (*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", 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; char *glyf_prime_data_next = glyf_prime_data;
bool success = true; 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; unsigned int start_offset, end_offset;
if (unlikely (!(glyf.get_offsets (glyph_ids[i], &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. 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, glyf_prime_data_next - glyf_prime_data,
use_short_loca, use_short_loca,
loca_prime_data, loca_prime_data,

Some files were not shown because too many files have changed in this diff Show More