More public api
diff --git a/src/hb-ot-layout-open-private.h b/src/hb-ot-layout-open-private.h
index a095c64..3d125d9 100644
--- a/src/hb-ot-layout-open-private.h
+++ b/src/hb-ot-layout-open-private.h
@@ -34,6 +34,8 @@
* Int types
*/
+/* XXX define these as structs of chars on machines that do not allow
+ * unaligned access */
#define DEFINE_INT_TYPE1(NAME, TYPE, BIG_ENDIAN) \
inline NAME& operator = (TYPE i) { v = BIG_ENDIAN(i); return *this; } \
inline operator TYPE(void) const { return BIG_ENDIAN(v); } \
@@ -100,11 +102,7 @@
if (HB_UNLIKELY (!array[i].offset)) return Null##Type; \
return *(const Type *)((const char*)this + array[i].offset); \
} \
- inline const Tag& get_tag (unsigned int i) const { \
- if (HB_UNLIKELY (i >= num)) return NullTag; \
- return array[i].tag; \
- } \
- /* TODO: implement find_tag() */
+ /* TODO: implement find_tag() and get_tag() publicly */
#define DEFINE_ARRAY_INTERFACE(Type, name) \
@@ -332,10 +330,11 @@
typedef struct TableDirectory {
+ friend struct OpenTypeFontFile;
friend struct OffsetTable;
inline bool is_null (void) const { return length == 0; }
- inline const Tag& get_tag (void) const { return tag; }
+ inline hb_tag_t get_tag (void) const { return tag; }
inline unsigned long get_checksum (void) const { return checkSum; }
inline unsigned long get_offset (void) const { return offset; }
inline unsigned long get_length (void) const { return length; }
@@ -409,17 +408,25 @@
STATIC_DEFINE_GET_FOR_DATA (OpenTypeFontFile);
+ DEFINE_ARRAY_INTERFACE (OpenTypeFontFace, face);
+
+ inline hb_tag_t get_tag (void) const { return tag; }
+
/* This is how you get a table */
- inline const char* get_table (const OpenTypeTable& table) const {
- return ((const char*)this) + table.offset;
+ inline const char* get_table_data (const OpenTypeTable& table) const {
+ return (*this)[table];
}
- inline char* get_table (const OpenTypeTable& table) {
- return ((char*)this) + table.offset;
+ inline char* get_table_data (const OpenTypeTable& table) {
+ return (*this)[table];
}
+
+ private:
inline const char* operator[] (const OpenTypeTable& table) const {
+ if (G_UNLIKELY (table.offset == 0)) return NULL;
return ((const char*)this) + table.offset;
}
inline char* operator[] (const OpenTypeTable& table) {
+ if (G_UNLIKELY (table.offset == 0)) return NULL;
return ((char*)this) + table.offset;
}
@@ -438,7 +445,6 @@
case TTCTag: return ((const TTCHeader&)*this)[i];
}
}
- inline const Tag& get_tag (void) const { return tag; }
private:
Tag tag; /* 4-byte identifier. */
@@ -731,7 +737,7 @@
DEFINE_ARRAY_TYPE (USHORT, classValueArray, glyphCount);
inline hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
- if (glyph_id >= startGlyph && glyph_id < startGlyph + glyphCount)
+ if (glyph_id >= startGlyph && glyph_id - startGlyph < glyphCount)
return classValueArray[glyph_id - startGlyph];
return 0;
}
@@ -799,7 +805,7 @@
}
}
- hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
+ inline hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
switch (u.classFormat) {
case 1: return u.format1.get_class(glyph_id);
case 2: return u.format2.get_class(glyph_id);
diff --git a/src/hb-ot-layout-private.h b/src/hb-ot-layout-private.h
index c364b21..8327197 100644
--- a/src/hb-ot-layout-private.h
+++ b/src/hb-ot-layout-private.h
@@ -34,6 +34,9 @@
#include "hb-private.h"
#include "hb-ot-layout.h"
+typedef uint16_t hb_ot_layout_class_t;
+typedef int hb_ot_layout_coverage_t; /* -1 is not covered, >= 0 otherwise */
+
struct GDEF;
struct GSUB;
struct GPOS;
@@ -41,9 +44,9 @@
HB_BEGIN_DECLS();
struct _HB_OT_Layout {
- GDEF *gdef;
- GSUB *gsub;
- GPOS *gpos;
+ const GDEF *gdef;
+ const GSUB *gsub;
+ const GPOS *gpos;
};
HB_END_DECLS();
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index ca3b951..827aa23 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -41,12 +41,12 @@
{
HB_OT_Layout *layout = (HB_OT_Layout *) calloc (1, sizeof (HB_OT_Layout));
- const OpenTypeFontFile &ot = OpenTypeFontFile::get_for_data (font_data);
- const OpenTypeFontFace &font = ot[face_index];
+ const OpenTypeFontFile &font = OpenTypeFontFile::get_for_data (font_data);
+ const OpenTypeFontFace &face = font.get_face (face_index);
- layout->gdef = font.find_table (GDEF::Tag);
- layout->gsub = font.find_table (GSUB::Tag);
- layout->gpos = font.find_table (GPOS::Tag);
+ layout->gdef = &GDEF::get_for_data (font.get_table_data (face.get_table (GDEF::Tag)));
+ layout->gsub = &GSUB::get_for_data (font.get_table_data (face.get_table (GSUB::Tag)));
+//layout->gpos = &GPOS::get_for_data (font.get_table_data (face.get_table (GPOS::Tag)));
return layout;
}
@@ -59,9 +59,16 @@
hb_ot_layout_glyph_properties_t
hb_ot_layout_get_glyph_properties (HB_OT_Layout *layout,
- hb_ot_layout_glyph_t glyph);
+ hb_ot_layout_glyph_t glyph)
+{
+
+}
void
hb_ot_layout_set_glyph_properties (HB_OT_Layout *layout,
hb_ot_layout_glyph_t glyph,
- hb_ot_layout_glyph_properties_t properties);
+ hb_ot_layout_glyph_properties_t properties)
+{
+
+}
+
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 786e4ac..8419d36 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -40,8 +40,6 @@
typedef uint16_t hb_ot_layout_glyph_properties_t;
typedef uint16_t hb_ot_layout_glyph_t;
-typedef uint16_t hb_ot_layout_class_t;
-typedef int hb_ot_layout_coverage_t; /* -1 is not covered, >= 0 otherwise */
typedef struct _HB_OT_Layout HB_OT_Layout;