#include "harfbuzz-open-private.h"
-struct GDEFHeader {
- /* TODO */
-
- private:
- Fixed version; /* Version of the GDEF table--initially
- * 0x00010000 */
- Offset glyphClassDef; /* Offset to class definition table
- * for glyph type--from beginning of
- * GDEF header (may be NULL) */
- Offset attachList; /* Offset to list of glyphs with
- * attachment points--from beginning
- * of GDEF header (may be NULL) */
- Offset ligCaretList; /* Offset to list of positioning points
- * for ligature carets--from beginning
- * of GDEF header (may be NULL) */
- Offset markAttachClassDef; /* Offset to class definition table for
- * mark attachment type--from beginning
- * of GDEF header (may be NULL) */
-};
-ASSERT_SIZE (GDEFHeader, 12);
-
struct GlyphClassDef : ClassDef {
static const uint16_t BaseGlyph = 0x0001u;
static const uint16_t LigatureGlyph = 0x0002u;
} u;
};
+
+#define DEFINE_ACCESSOR0(const, Type, name, Name) \
+ inline const Type* name (void) const { \
+ if (!Name) return NULL; \
+ return (const Type *)((const char*)this + Name); \
+ }
+#define DEFINE_ACCESSOR(Type, name, Name) \
+ DEFINE_ACCESSOR0(const, Type, name, Name) \
+ DEFINE_ACCESSOR0( , Type, name, Name)
+
+struct GDEFHeader {
+
+ DEFINE_ACCESSOR (ClassDef, get_glyph_class_def, glyphClassDef);
+ DEFINE_ACCESSOR (AttachList, get_attach_list, attachList);
+ DEFINE_ACCESSOR (LigCaretList, get_lig_caret_list, ligCaretList);
+ DEFINE_ACCESSOR (ClassDef, get_mark_attach_class_def, markAttachClassDef);
+
+ /* Returns 0 if not found. */
+ inline int get_glyph_class (uint16_t glyph_id) const {
+ const ClassDef *class_def = get_glyph_class_def ();
+ if (!class_def) return 0;
+ return class_def->get_class (glyph_id);
+ }
+
+ /* Returns 0 if not found. */
+ inline int get_mark_attachment_type (uint16_t glyph_id) const {
+ const ClassDef *class_def = get_mark_attach_class_def ();
+ if (!class_def) return 0;
+ return class_def->get_class (glyph_id);
+ }
+
+ /* TODO get_attach and get_lig_caret */
+
+ private:
+ Fixed version; /* Version of the GDEF table--initially
+ * 0x00010000 */
+ Offset glyphClassDef; /* Offset to class definition table
+ * for glyph type--from beginning of
+ * GDEF header (may be NULL) */
+ Offset attachList; /* Offset to list of glyphs with
+ * attachment points--from beginning
+ * of GDEF header (may be NULL) */
+ Offset ligCaretList; /* Offset to list of positioning points
+ * for ligature carets--from beginning
+ * of GDEF header (may be NULL) */
+ Offset markAttachClassDef; /* Offset to class definition table for
+ * mark attachment type--from beginning
+ * of GDEF header (may be NULL) */
+};
+ASSERT_SIZE (GDEFHeader, 12);
+
#endif /* HARFBUZZ_GDEF_PRIVATE_H */
inline Tag (const char *c) { v[0] = c[0]; v[1] = c[1]; v[2] = c[2]; v[3] = c[3]; }
inline bool operator== (Tag o) const { return v[0]==o.v[0]&&v[1]==o.v[1]&&v[2]==o.v[2]&&v[3]==o.v[3]; }
inline bool operator== (const char *c) const { return v[0]==c[0]&&v[1]==c[1]&&v[2]==c[2]&&v[3]==c[3]; }
+ inline bool operator== (uint32_t i) const { return i == (uint32_t) *this; }
inline operator uint32_t(void) const { return (v[0]<<24)+(v[1]<<16) +(v[2]<<8)+v[3]; }
/* What the char* converters return is NOT nul-terminated. Print using "%.4s" */
inline operator const char* (void) const { return (const char *)this; }
return (LangSys *)((char*)this + defaultLangSys);
}
+ /* TODO implement find_language_system based on find_tag */
+
private:
Offset defaultLangSys; /* Offset to DefaultLangSys table--from
* beginning of Script table--may be NULL */
return reqFeatureIndex;;
}
+ /* TODO implement find_feature */
+
private:
Offset lookupOrder; /* = NULL (reserved for an offset to a
* reordering table) */
/* Returns 0 if not found. */
inline int get_class (uint16_t glyph_id) const {
switch (u.classFormat) {
- case 1: u.format1.get_class(glyph_id);
- case 2: u.format2.get_class(glyph_id);
+ case 1: return u.format1.get_class(glyph_id);
+ case 2: return u.format2.get_class(glyph_id);
default:return 0;
}
}
assert (name##List); \
return (const Type##List *)((const char*)this + name##List); \
} \
- inline const Type& name (unsigned int i) const { \
+ inline const Type& get_##name (unsigned int i) const { \
return (*get_##name##_list())[i]; \
}
#define DEFINE_LIST_ACCESSOR(Type, name) \
struct GSUBGPOSHeader {
-/*
- inline unsigned int get_size (void) const {
- return offsetof (GSUBGPOSHeader, padding);
- }
- */
+ DEFINE_LIST_ACCESSOR(Script, script); /* get_script_list, get_script(i) */
+ DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list, get_feature(i) */
+ DEFINE_LIST_ACCESSOR(Lookup, lookup); /* get_lookup_list, get_lookup(i) */
- DEFINE_LIST_ACCESSOR(Script, script); /* get_script_list and script(i) */
- DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list and feature(i) */
- DEFINE_LIST_ACCESSOR(Lookup, lookup); /* get_lookup_list and lookup(i) */
+ /* TODO implement find_script */
private:
Fixed_Version version; /* Version of the GSUB/GPOS table--initially set