提交 e8cbaaf6 编写于 作者: B Behdad Esfahbod

[HB] Add HeadlessArrayTo<>

上级 dcb6b602
...@@ -314,12 +314,10 @@ struct Ligature { ...@@ -314,12 +314,10 @@ struct Ligature {
friend struct LigatureSet; friend struct LigatureSet;
private: private:
DEFINE_ARRAY_TYPE (GlyphID, component, (compCount ? compCount - 1 : 0));
inline bool substitute_ligature (LOOKUP_ARGS_DEF, bool is_mark) const { inline bool substitute_ligature (LOOKUP_ARGS_DEF, bool is_mark) const {
unsigned int i, j; unsigned int i, j;
unsigned int count = compCount; unsigned int count = component.len;
if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length || if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length ||
context_length < count)) context_length < count))
...@@ -336,7 +334,7 @@ struct Ligature { ...@@ -336,7 +334,7 @@ struct Ligature {
property & LookupFlag::MarkAttachmentType)) property & LookupFlag::MarkAttachmentType))
is_mark = FALSE; is_mark = FALSE;
if (HB_LIKELY (IN_GLYPH(j) != (*this)[i - 1])) if (HB_LIKELY (IN_GLYPH(j) != component[i]))
return false; return false;
} }
if ( _hb_ot_layout_has_new_glyph_classes (layout) ) if ( _hb_ot_layout_has_new_glyph_classes (layout) )
...@@ -383,8 +381,8 @@ struct Ligature { ...@@ -383,8 +381,8 @@ struct Ligature {
private: private:
GlyphID ligGlyph; /* GlyphID of ligature to substitute */ GlyphID ligGlyph; /* GlyphID of ligature to substitute */
USHORT compCount; /* Number of components in the ligature */ HeadlessArrayOf<GlyphID>
GlyphID component[]; /* Array of component GlyphIDs--start component; /* Array of component GlyphIDs--start
* with the second component--ordered * with the second component--ordered
* in writing direction */ * in writing direction */
}; };
......
...@@ -362,9 +362,8 @@ struct ChainRule { ...@@ -362,9 +362,8 @@ struct ChainRule {
backtrack; /* Array of backtracking values backtrack; /* Array of backtracking values
* (to be matched before the input * (to be matched before the input
* sequence) */ * sequence) */
USHORT inputCountX; /* Total number of values in the input HeadlessArrayOf<USHORT>
* sequence (includes the first glyph) */ inputX; /* Array of input values (start with
USHORT inputX[]; /* Array of input values (start with
* second glyph) */ * second glyph) */
ArrayOf<USHORT> ArrayOf<USHORT>
lookaheadX; /* Array of lookahead values's (to be lookaheadX; /* Array of lookahead values's (to be
......
...@@ -348,6 +348,25 @@ struct ArrayOf { ...@@ -348,6 +348,25 @@ struct ArrayOf {
if (HB_UNLIKELY (i >= len)) return Null(Type); if (HB_UNLIKELY (i >= len)) return Null(Type);
return array[i]; return array[i];
} }
inline unsigned int get_size () const {
return sizeof (len) + len * sizeof (array[0]);
}
USHORT len;
Type array[];
};
/* An array with a USHORT number of elements,
* starting at second element. */
template <typename Type>
struct HeadlessArrayOf {
inline const Type& operator [] (unsigned int i) const {
if (HB_UNLIKELY (i >= len || !i)) return Null(Type);
return array[i-1];
}
inline unsigned int get_size () const {
return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]);
}
USHORT len; USHORT len;
Type array[]; Type array[];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册