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