[dfont] Some more

This commit is contained in:
Behdad Esfahbod 2018-09-13 19:19:57 +02:00
parent 0ab0f1e5ac
commit 180a88a96c
1 changed files with 8 additions and 13 deletions

View File

@ -322,7 +322,8 @@ struct ResourceRecord
struct ResourceTypeRecord struct ResourceTypeRecord
{ {
inline unsigned int get_resource_count (void) const { return tag == HB_TAG_sfnt ? resCountM1 + 1 : 0; } inline unsigned int get_resource_count (void) const
{ return tag == HB_TAG_sfnt ? resCountM1 + 1 : 0; }
inline bool is_sfnt (void) const { return tag == HB_TAG_sfnt; } inline bool is_sfnt (void) const { return tag == HB_TAG_sfnt; }
@ -363,14 +364,6 @@ struct ResourceMap
get_type_count ()) [i]; get_type_count ()) [i];
} }
inline unsigned int get_type_count (void) const { return typeCountM1 + 1; }
inline const ResourceRecord &get_resource_record (const ResourceTypeRecord &type,
unsigned int i) const
{
return type.get_resource_record (i, &(this+typeListZ));
}
inline unsigned int get_face_count (void) const inline unsigned int get_face_count (void) const
{ {
unsigned int count = get_type_count (); unsigned int count = get_type_count ();
@ -390,11 +383,10 @@ struct ResourceMap
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
const ResourceTypeRecord& type = get_type_record (i); const ResourceTypeRecord& type = get_type_record (i);
/* The check for idx < count is here because ResourceRecord is NOT null-safe.
* Because an offset of 0 there does NOT mean null. */
if (type.is_sfnt () && idx < type.get_resource_count ()) if (type.is_sfnt () && idx < type.get_resource_count ())
{ return type.get_resource_record (idx, &(this+typeListZ)).get_face (data_base);
const OpenTypeFontFace &face = get_resource_record (type, idx).get_face (data_base);
return face;
}
} }
return Null (OpenTypeFontFace); return Null (OpenTypeFontFace);
} }
@ -410,6 +402,9 @@ struct ResourceMap
data_base)); data_base));
} }
private:
inline unsigned int get_type_count (void) const { return typeCountM1 + 1; }
protected: protected:
HBUINT8 reserved0[16]; /* Reserved for copy of resource header */ HBUINT8 reserved0[16]; /* Reserved for copy of resource header */
HBUINT32 reserved1; /* Reserved for handle to next resource map */ HBUINT32 reserved1; /* Reserved for handle to next resource map */