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

[ot] Factor out code between cmap sutable format 12 and 13

上级 94759e82
...@@ -196,7 +196,8 @@ struct CmapSubtableTrimmed ...@@ -196,7 +196,8 @@ struct CmapSubtableTrimmed
struct CmapSubtableFormat6 : CmapSubtableTrimmed<USHORT> {}; struct CmapSubtableFormat6 : CmapSubtableTrimmed<USHORT> {};
struct CmapSubtableFormat10 : CmapSubtableTrimmed<ULONG > {}; struct CmapSubtableFormat10 : CmapSubtableTrimmed<ULONG > {};
struct CmapSubtableFormat12 template <typename T>
struct CmapSubtableLongSegmented
{ {
friend struct CmapSubtable; friend struct CmapSubtable;
...@@ -206,8 +207,7 @@ struct CmapSubtableFormat12 ...@@ -206,8 +207,7 @@ struct CmapSubtableFormat12
int i = groups.search (codepoint); int i = groups.search (codepoint);
if (i == -1) if (i == -1)
return false; return false;
const CmapSubtableLongGroup &group = groups[i]; *glyph = T::group_get_glyph (groups[i], codepoint);
*glyph = group.glyphID + (codepoint - group.startCharCode);
return true; return true;
} }
...@@ -227,35 +227,18 @@ struct CmapSubtableFormat12 ...@@ -227,35 +227,18 @@ struct CmapSubtableFormat12
DEFINE_SIZE_ARRAY (16, groups); DEFINE_SIZE_ARRAY (16, groups);
}; };
struct CmapSubtableFormat13 struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
{ {
friend struct CmapSubtable; static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group,
hb_codepoint_t u)
private: { return group.glyphID + (u - group.startCharCode); }
inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const };
{
int i = groups.search (codepoint);
if (i == -1)
return false;
const CmapSubtableLongGroup &group = groups[i];
*glyph = group.glyphID;
return true;
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);
return TRACE_RETURN (c->check_struct (this) && groups.sanitize (c));
}
protected: struct CmapSubtableFormat13 : CmapSubtableLongSegmented<CmapSubtableFormat13>
USHORT format; /* Subtable format; set to 13. */ {
USHORT reserved; /* Reserved; set to 0. */ static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group,
ULONG length; /* Byte length of this subtable. */ hb_codepoint_t u HB_UNUSED)
ULONG language; /* Ignore. */ { return group.glyphID; }
LongArrayOf<CmapSubtableLongGroup>
groups; /* Groupings. */
public:
DEFINE_SIZE_ARRAY (16, groups);
}; };
struct CmapSubtable struct CmapSubtable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册