#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
#define HB_OT_LAYOUT_GDEF_PRIVATE_H
-#include "hb-private.h"
-#include "hb-ot-layout.h"
+#include "hb-ot-layout-private.h"
#include "hb-ot-layout-open-private.h"
#define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
- inline const Type& name (uint16_t glyph_id) { \
+ inline const Type& name (hb_ot_layout_glyph_t glyph_id) { \
const Coverage &c = get_coverage (); \
- int c_index = c.get_coverage (glyph_id); \
+ hb_ot_layout_coverage_t c_index = c.get_coverage (glyph_id); \
return (*this)[c_index]; \
}
friend struct GDEF;
private:
- /* const AttachPoint& get_attach_points (uint16_t glyph_id); */
+ /* const AttachPoint& get_attach_points (hb_ot_layout_glyph_t glyph_id); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (AttachPoint, get_attach_points);
private:
friend struct GDEF;
private:
- /* const LigGlyph& get_lig_glyph (uint16_t glyph_id); */
+ /* const LigGlyph& get_lig_glyph (hb_ot_layout_glyph_t glyph_id); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (LigGlyph, get_lig_glyph);
private:
DEFINE_ACCESSOR (ClassDef, get_mark_attach_class_def, markAttachClassDef);
/* Returns 0 if not found. */
- inline int get_glyph_class (uint16_t glyph_id) const {
+ inline int get_glyph_class (hb_ot_layout_glyph_t glyph_id) const {
return get_glyph_class_def ().get_class (glyph_id);
}
/* Returns 0 if not found. */
- inline int get_mark_attachment_type (uint16_t glyph_id) const {
+ inline int get_mark_attachment_type (hb_ot_layout_glyph_t glyph_id) const {
return get_mark_attach_class_def ().get_class (glyph_id);
}
- /* TODO get_glyph_property */
-
/* TODO get_attach and get_lig_caret */
private:
#ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H
#define HB_OT_LAYOUT_OPEN_PRIVATE_H
-#include "hb-private.h"
-#include "hb-ot-layout.h"
+#include "hb-ot-layout-private.h"
/*
return *(const Type *)((const char*)this + array[i]); \
}
+/* A record array type is like an array type, but it contains a table
+ * of records to the objects. Each record has a tag, and an offset
+ * relative to the beginning of the current object. */
#define DEFINE_RECORD_ARRAY_TYPE(Type, array, num) \
DEFINE_RECORD_ACCESSOR(Type, array, num) \
DEFINE_LEN_AND_SIZE(Record, array, num)
} \
/* TODO: implement find_tag() */
+
+#define DEFINE_ARRAY_INTERFACE(Type, name) \
+ inline const Type& get_##name (unsigned int i) const { \
+ return (*this)[i]; \
+ } \
+ inline unsigned int get_##name##_count (void) const { \
+ return this->get_len (); \
+ }
+#define DEFINE_INDEX_ARRAY_INTERFACE(name) \
+ inline unsigned int get_##name##_index (unsigned int i) const { \
+ return (*this)[i]; \
+ } \
+ inline unsigned int get_##name##_count (void) const { \
+ return this->get_len (); \
+ }
+
+#define DEFINE_FIND_TAG_INTERFACE(Type, name) \
+ inline const Type* find_##name (hb_tag_t tag) const { \
+ for (unsigned int i = 0; i < this->get_len (); i++) \
+ if (tag == (*this)[i].tag) \
+ return &(*this)[i]; \
+ return NULL; \
+ } \
+ inline const Type& get_##name_by_tag (hb_tag_t tag) const { \
+ for (unsigned int i = 0; i < this->get_len (); i++) \
+ if (tag == (*this)[i].tag) \
+ return (*this)[i]; \
+ return Null##Type; \
+ }
+
+
/*
* List types
*/
/* get_for_data() is a static class method returning a reference to an
* instance of Type located at the input data location. It's just a
* fancy cast! */
-#define STATIC_DEFINE_GET_FOR_DATA0(const, Type) \
+#define STATIC_DEFINE_GET_FOR_DATA(Type) \
static inline const Type& get_for_data (const char *data) { \
+ extern const Type &Null##Type; \
+ if (HB_UNLIKELY (data == NULL)) return Null##Type; \
return *(const Type*)data; \
+ } \
+ static inline Type& get_for_data (char *data) { \
+ return *(Type*)data; \
}
-#define STATIC_DEFINE_GET_FOR_DATA(Type) \
- STATIC_DEFINE_GET_FOR_DATA0(const, Type) \
- STATIC_DEFINE_GET_FOR_DATA0( , Type)
#define DEFINE_ACCESSOR(Type, name, Name) \
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 unsigned long get_checksum (void) const { return checkSum; }
inline unsigned long get_offset (void) const { return offset; }
ULONG length; /* Length of this table. */
} OpenTypeTable;
DEFINE_NULL_ASSERT_SIZE (TableDirectory, 16);
+DEFINE_NULL_ALIAS (OpenTypeTable, TableDirectory);
typedef struct OffsetTable {
friend struct OpenTypeFontFile;
friend struct TTCHeader;
- // XXX private:
- // Add get_num_tables and get_table...
+ DEFINE_ARRAY_INTERFACE (OpenTypeTable, table);
+ DEFINE_FIND_TAG_INTERFACE (OpenTypeTable, table);
+
+ private:
/* OpenTypeTables, in no particular order */
DEFINE_ARRAY_TYPE (TableDirectory, tableDir, numTables);
- // TODO: Implement find_table
private:
Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */
DEFINE_NULL_ASSERT_SIZE (Record, 6);
struct LangSys {
- /* Feature indices, in no particular order */
- DEFINE_ARRAY_TYPE (USHORT, featureIndex, featureCount);
-
+
+ DEFINE_INDEX_ARRAY_INTERFACE (feature);
+
/* Returns -1 if none */
inline int get_required_feature_index (void) const {
if (reqFeatureIndex == 0xffff)
return reqFeatureIndex;;
}
- /* TODO implement find_feature */
+ private:
+ /* Feature indices, in no particular order */
+ DEFINE_ARRAY_TYPE (USHORT, featureIndex, featureCount);
private:
Offset lookupOrder; /* = Null (reserved for an offset to a
DEFINE_NULL_ASSERT_SIZE (ScriptList, 2);
struct Feature {
+
+ DEFINE_INDEX_ARRAY_INTERFACE (lookup);
+
+ private:
/* LookupList indices, in no particular order */
DEFINE_ARRAY_TYPE (USHORT, lookupIndex, lookupCount);
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE (GlyphID, glyphArray, glyphCount);
- inline int get_coverage (uint16_t glyph_id) const {
+ inline hb_ot_layout_coverage_t get_coverage (hb_ot_layout_glyph_t glyph_id) const {
GlyphID gid;
gid = glyph_id;
// TODO: bsearch
friend struct CoverageFormat2;
private:
- inline int get_coverage (uint16_t glyph_id) const {
+ inline hb_ot_layout_coverage_t get_coverage (hb_ot_layout_glyph_t glyph_id) const {
if (glyph_id >= start && glyph_id <= end)
return startCoverageIndex + (glyph_id - start);
return -1;
/* CoverageRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE (CoverageRangeRecord, rangeRecord, rangeCount);
- inline int get_coverage (uint16_t glyph_id) const {
+ inline hb_ot_layout_coverage_t get_coverage (hb_ot_layout_glyph_t glyph_id) const {
// TODO: bsearch
for (unsigned int i = 0; i < rangeCount; i++) {
int coverage = rangeRecord[i].get_coverage (glyph_id);
}
}
- /* Returns -1 if not covered. */
- int get_coverage (uint16_t glyph_id) const {
+ hb_ot_layout_coverage_t get_coverage (hb_ot_layout_glyph_t glyph_id) const {
switch (u.coverageFormat) {
case 1: return u.format1.get_coverage(glyph_id);
case 2: return u.format2.get_coverage(glyph_id);
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE (USHORT, classValueArray, glyphCount);
- inline int get_class (uint16_t glyph_id) const {
+ inline hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
if (glyph_id >= startGlyph && glyph_id < startGlyph + glyphCount)
return classValueArray[glyph_id - startGlyph];
return 0;
friend struct ClassDefFormat2;
private:
- inline int get_class (uint16_t glyph_id) const {
+ inline hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
if (glyph_id >= start && glyph_id <= end)
return classValue;
return 0;
/* ClassRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE (ClassRangeRecord, rangeRecord, rangeCount);
- inline int get_class (uint16_t glyph_id) const {
+ inline hb_ot_layout_class_t get_class (hb_ot_layout_glyph_t glyph_id) const {
// TODO: bsearch
for (int i = 0; i < rangeCount; i++) {
int classValue = rangeRecord[i].get_class (glyph_id);
}
}
- /* Returns 0 if not found. */
- int get_class (uint16_t glyph_id) const {
+ 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);
DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list, get_feature(i) */
DEFINE_LIST_ACCESSOR(Lookup, lookup); /* get_lookup_list, get_lookup(i) */
- /* TODO implement find_script */
-
private:
Fixed_Version version; /* Version of the GSUB/GPOS table--initially set
* to 0x00010000 */
--- /dev/null
+/*
+ * Copyright (C) 2007,2008 Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_OT_LAYOUT_PRIVATE_H
+#define HB_OT_LAYOUT_PRIVATE_H
+
+#ifndef HB_OT_LAYOUT_CC
+#error "This file should only be included from hb-ot-layout.c"
+#endif
+
+#include "hb-private.h"
+#include "hb-ot-layout.h"
+
+struct GDEF;
+struct GSUB;
+struct GPOS;
+
+HB_BEGIN_DECLS();
+
+struct _HB_OT_Layout {
+ GDEF *gdef;
+ GSUB *gsub;
+ GPOS *gpos;
+};
+
+HB_END_DECLS();
+
+#endif /* HB_OT_LAYOUT_PRIVATE_H */
--- /dev/null
+/*
+ * Copyright (C) 2007,2008 Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#define HB_OT_LAYOUT_CC
+
+#include "hb-ot-layout.h"
+#include "hb-ot-layout-private.h"
+
+#include "hb-ot-layout-open-private.h"
+#include "hb-ot-layout-gdef-private.h"
+#include "hb-ot-layout-gsub-private.h"
+
+#include <stdlib.h>
+
+HB_OT_Layout *
+hb_ot_layout_create (const char *font_data,
+ int face_index)
+{
+ 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];
+
+ layout->gdef = font.find_table (GDEF::Tag);
+ layout->gsub = font.find_table (GSUB::Tag);
+ layout->gpos = font.find_table (GPOS::Tag);
+
+ return layout;
+}
+
+void
+hb_ot_layout_destroy (HB_OT_Layout *layout)
+{
+ free (layout);
+}
+
+hb_ot_layout_glyph_properties_t
+hb_ot_layout_get_glyph_properties (HB_OT_Layout *layout,
+ 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);