提交 3ec0092c 编写于 作者: B Behdad Esfahbod

[HB] Simplify more

上级 6ad8d5f3
...@@ -475,24 +475,7 @@ struct OpenTypeFontFile ...@@ -475,24 +475,7 @@ struct OpenTypeFontFile
STATIC_DEFINE_GET_FOR_DATA (OpenTypeFontFile); STATIC_DEFINE_GET_FOR_DATA (OpenTypeFontFile);
DEFINE_ARRAY_INTERFACE (OpenTypeFontFace, face); /* get_face_count(), get_face(i) */ unsigned int get_face_count (void) const
/* This is how you get a table */
inline const char* get_table_data (const OpenTypeTable& table) const { return (*this)[table]; }
private:
inline const char* operator[] (const OpenTypeTable& table) const
{
if (HB_UNLIKELY (table.offset == 0)) return NULL;
return ((const char*)this) + table.offset;
}
inline char* operator[] (const OpenTypeTable& table)
{
if (HB_UNLIKELY (table.offset == 0)) return NULL;
return ((char*)this) + table.offset;
}
unsigned int get_len (void) const
{ {
switch (tag) { switch (tag) {
default: return 0; default: return 0;
...@@ -500,9 +483,9 @@ struct OpenTypeFontFile ...@@ -500,9 +483,9 @@ struct OpenTypeFontFile
case TTCTag: return TTCHeader::get_for_data ((const char *) this).table.len; case TTCTag: return TTCHeader::get_for_data ((const char *) this).table.len;
} }
} }
const OpenTypeFontFace& operator[] (unsigned int i) const const OpenTypeFontFace& get_face (unsigned int i) const
{ {
if (HB_UNLIKELY (i >= get_len ())) return Null(OpenTypeFontFace); if (HB_UNLIKELY (i >= get_face_count ())) return Null(OpenTypeFontFace);
switch (tag) { switch (tag) {
default: /* Never happens because of the if above */ default: /* Never happens because of the if above */
case TrueTypeTag: case CFFTag: return (const OffsetTable&)*this; case TrueTypeTag: case CFFTag: return (const OffsetTable&)*this;
...@@ -510,7 +493,13 @@ struct OpenTypeFontFile ...@@ -510,7 +493,13 @@ struct OpenTypeFontFile
} }
} }
public: /* This is how you get a table */
inline const char* get_table_data (const OpenTypeTable& table) const
{
if (HB_UNLIKELY (table.offset == 0)) return NULL;
return ((const char*) this) + table.offset;
}
Tag tag; /* 4-byte identifier. */ Tag tag; /* 4-byte identifier. */
}; };
ASSERT_SIZE (OpenTypeFontFile, 4); ASSERT_SIZE (OpenTypeFontFile, 4);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册