[HB] Support parsing MarkFilteringSets introduced in OpenType 1.6

This commit is contained in:
Behdad Esfahbod 2009-05-26 15:38:53 -04:00
parent 515ce4ceb2
commit e4b92b85a7
3 changed files with 51 additions and 11 deletions

View File

@ -213,6 +213,39 @@ struct LigCaretList
}; };
ASSERT_SIZE (LigCaretList, 4); ASSERT_SIZE (LigCaretList, 4);
struct MarkGlyphSetsFormat1
{
inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
private:
USHORT format; /* Format identifier--format = 1 */
LongOffsetArrayOf<Coverage>
coverage; /* Array of long offsets to mark set
* coverage tables */
};
ASSERT_SIZE (MarkGlyphSetsFormat1, 4);
struct MarkGlyphSets
{
inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{
switch (u.format) {
case 1: return u.format1->covers (set_index, glyph_id);
default:return false;
}
}
private:
union {
USHORT format; /* Format identifier */
MarkGlyphSetsFormat1 format1[];
} u;
};
ASSERT_SIZE (MarkGlyphSets, 2);
/* /*
* GDEF * GDEF
*/ */
@ -232,18 +265,15 @@ struct GDEF
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1); STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
inline bool has_glyph_classes () const { return glyphClassDef != 0; } inline bool has_glyph_classes () const { return glyphClassDef != 0; }
inline hb_ot_layout_class_t get_glyph_class (hb_ot_layout_t *layout, inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
hb_codepoint_t glyph) const
{ return (this+glyphClassDef).get_class (glyph); } { return (this+glyphClassDef).get_class (glyph); }
inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; } inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
inline hb_ot_layout_class_t get_mark_attachment_type (hb_ot_layout_t *layout, inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
hb_codepoint_t glyph) const
{ return (this+markAttachClassDef).get_class (glyph); } { return (this+markAttachClassDef).get_class (glyph); }
inline bool has_attach_points () const { return attachList != 0; } inline bool has_attach_points () const { return attachList != 0; }
inline bool get_attach_points (hb_ot_layout_t *layout, inline bool get_attach_points (hb_codepoint_t glyph_id,
hb_codepoint_t glyph_id,
unsigned int *point_count /* IN/OUT */, unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */) const unsigned int *point_array /* OUT */) const
{ return (this+attachList).get_attach_points (glyph_id, point_count, point_array); } { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
@ -255,9 +285,13 @@ struct GDEF
int *caret_array /* OUT */) const int *caret_array /* OUT */) const
{ return (this+ligCaretList).get_lig_carets (layout, glyph_id, caret_count, caret_array); } { return (this+ligCaretList).get_lig_carets (layout, glyph_id, caret_count, caret_array); }
inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
private: private:
FixedVersion version; /* Version of the GDEF table--initially FixedVersion version; /* Version of the GDEF table--currently
* 0x00010000 */ * 0x00010002 */
OffsetTo<ClassDef> OffsetTo<ClassDef>
glyphClassDef; /* Offset to class definition table glyphClassDef; /* Offset to class definition table
* for glyph type--from beginning of * for glyph type--from beginning of
@ -274,6 +308,11 @@ struct GDEF
markAttachClassDef; /* Offset to class definition table for markAttachClassDef; /* Offset to class definition table for
* mark attachment type--from beginning * mark attachment type--from beginning
* of GDEF header (may be Null) */ * of GDEF header (may be Null) */
OffsetTo<MarkGlyphSets>
markGlyphSetsDef[0]; /* Offset to the table of mark set
* definitions--from beginning of GDEF
* header (may be NULL). Introduced
* in version 00010002. */
}; };
ASSERT_SIZE (GDEF, 12); ASSERT_SIZE (GDEF, 12);

View File

@ -48,6 +48,7 @@ struct ValueFormat : USHORT
yPlaDevice = 0x0020, /* Includes vertical Device table for placement */ yPlaDevice = 0x0020, /* Includes vertical Device table for placement */
xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */ xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */
yAdvDevice = 0x0080, /* Includes vertical Device table for advance */ yAdvDevice = 0x0080, /* Includes vertical Device table for advance */
ignored = 0x0F00, /* Was used in TrueType Open for MM fonts */
reserved = 0xF000, /* For future use */ reserved = 0xF000, /* For future use */
}; };

View File

@ -140,11 +140,11 @@ _hb_ot_layout_get_glyph_property (hb_ot_layout_t *layout,
/* TODO old harfbuzz doesn't always parse mark attachments as it says it was /* TODO old harfbuzz doesn't always parse mark attachments as it says it was
* introduced without a version bump, so it may not be safe */ * introduced without a version bump, so it may not be safe */
klass = layout->gdef->get_mark_attachment_type (layout, glyph); klass = layout->gdef->get_mark_attachment_type (glyph);
if (klass) if (klass)
return klass << 8; return klass << 8;
klass = layout->gdef->get_glyph_class (layout, glyph); klass = layout->gdef->get_glyph_class (glyph);
if (!klass && glyph < layout->new_gdef.len) if (!klass && glyph < layout->new_gdef.len)
klass = layout->new_gdef.klasses[glyph]; klass = layout->new_gdef.klasses[glyph];
@ -308,7 +308,7 @@ hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
unsigned int *point_count /* IN/OUT */, unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */) unsigned int *point_array /* OUT */)
{ {
return layout->gdef->get_attach_points (layout, glyph, point_count, point_array); return layout->gdef->get_attach_points (glyph, point_count, point_array);
} }
hb_bool_t hb_bool_t