More public api

This commit is contained in:
Behdad Esfahbod 2008-01-24 03:54:09 -05:00
parent fd92a3dde3
commit ead428d7a0
4 changed files with 39 additions and 25 deletions

View File

@ -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 @@ struct TTCHeader;
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 @@ struct OpenTypeFontFile {
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 @@ struct OpenTypeFontFile {
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 @@ struct ClassDefFormat1 {
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 @@ struct ClassDef {
}
}
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);

View File

@ -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 @@ struct GPOS;
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();

View File

@ -41,12 +41,12 @@ hb_ot_layout_create (const char *font_data,
{
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_destroy (HB_OT_Layout *layout)
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)
{
}

View File

@ -40,8 +40,6 @@ typedef uint32_t hb_tag_t;
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;