From: Behdad Esfahbod Date: Mon, 28 Jan 2008 02:19:51 +0000 (-0500) Subject: GDEF completely working now X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54e5aac5e2947d4e2864c6f2987e4d275da73100;p=platform%2Fupstream%2FlibHarfBuzzSharp.git GDEF completely working now --- diff --git a/src/hb-ot-layout-open-private.h b/src/hb-ot-layout-open-private.h index 94ff209..482cf14 100644 --- a/src/hb-ot-layout-open-private.h +++ b/src/hb-ot-layout-open-private.h @@ -27,6 +27,10 @@ #ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H #define HB_OT_LAYOUT_OPEN_PRIVATE_H +#ifndef HB_OT_LAYOUT_CC +#error "This file should only be included from hb-ot-layout.c" +#endif + #include "hb-ot-layout-private.h" @@ -127,7 +131,7 @@ return &(*this)[i]; \ return NULL; \ } \ - inline const Type& get_##name_by_tag (hb_tag_t tag) const { \ + 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]; \ @@ -158,6 +162,7 @@ private: inline Type() {} /* cannot be instantiated */ \ public: +/* TODO use a global nul-array for most Null's */ /* defines Null##Type as a safe nil instance of Type */ #define DEFINE_NULL_DATA(Type, size, data) \ static const unsigned char Null##Type##Data[size] = data; \ @@ -170,11 +175,11 @@ ASSERT_SIZE (Type, size); \ DEFINE_NULL_DATA (Type, size, data) #define DEFINE_NULL_ALIAS(NewType, OldType) \ - static const NewType &Null##NewType = *(NewType *)Null##OldType##Data + /* XXX static */ const NewType &Null##NewType = *(NewType *)Null##OldType##Data /* 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! */ + * fancy, NULL-safe, cast! */ #define STATIC_DEFINE_GET_FOR_DATA(Type) \ static inline const Type& get_for_data (const char *data) { \ extern const Type &Null##Type; \ diff --git a/src/hb-ot-layout-private.h b/src/hb-ot-layout-private.h index e0b7be0..607ee26 100644 --- a/src/hb-ot-layout-private.h +++ b/src/hb-ot-layout-private.h @@ -27,10 +27,6 @@ #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" @@ -43,17 +39,23 @@ typedef uint16_t hb_ot_layout_glyph_properties_t; typedef uint16_t hb_ot_layout_lookup_flags_t; typedef int hb_ot_layout_coverage_t; /* -1 is not covered, >= 0 otherwise */ +/* XXX #define HB_OT_LAYOUT_INTERNAL static */ +#define HB_OT_LAYOUT_INTERNAL HB_BEGIN_DECLS(); -static hb_bool_t +/* + * GDEF + */ + +HB_OT_LAYOUT_INTERNAL hb_bool_t _hb_ot_layout_has_new_glyph_classes (HB_OT_Layout *layout); -static hb_ot_layout_glyph_properties_t +HB_OT_LAYOUT_INTERNAL hb_ot_layout_glyph_properties_t _hb_ot_layout_get_glyph_properties (HB_OT_Layout *layout, hb_glyph_t glyph); -static bool +HB_OT_LAYOUT_INTERNAL hb_bool_t _hb_ot_layout_check_glyph_properties (HB_OT_Layout *layout, HB_GlyphItem gitem, hb_ot_layout_lookup_flags_t lookup_flags, diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index faad280..ab3ac93 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -61,9 +61,9 @@ hb_ot_layout_create (const char *font_data, const OpenTypeFontFile &font = OpenTypeFontFile::get_for_data (font_data); const OpenTypeFontFace &face = font.get_face (face_index); - 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))); + layout->gdef = &GDEF::get_for_data (font.get_table_data (face.get_table_by_tag (GDEF::Tag))); + layout->gsub = &GSUB::get_for_data (font.get_table_data (face.get_table_by_tag (GSUB::Tag))); +//layout->gpos = &GPOS::get_for_data (font.get_table_data (face.get_table_by_tag (GPOS::Tag))); return layout; } @@ -84,13 +84,13 @@ hb_ot_layout_has_font_glyph_classes (HB_OT_Layout *layout) return layout->gdef->has_glyph_classes (); } -static hb_bool_t +HB_OT_LAYOUT_INTERNAL hb_bool_t _hb_ot_layout_has_new_glyph_classes (HB_OT_Layout *layout) { return layout->new_gdef.len > 0; } -static hb_ot_layout_glyph_properties_t +HB_OT_LAYOUT_INTERNAL hb_ot_layout_glyph_properties_t _hb_ot_layout_get_glyph_properties (HB_OT_Layout *layout, hb_glyph_t glyph) { @@ -117,19 +117,18 @@ _hb_ot_layout_get_glyph_properties (HB_OT_Layout *layout, } } -static bool +HB_OT_LAYOUT_INTERNAL hb_bool_t _hb_ot_layout_check_glyph_properties (HB_OT_Layout *layout, HB_GlyphItem gitem, hb_ot_layout_lookup_flags_t lookup_flags, hb_ot_layout_glyph_properties_t *property) { - /* TODO ugh, clean this mess up */ hb_ot_layout_glyph_class_t basic_glyph_class; hb_ot_layout_glyph_properties_t desired_attachment_class; - if (gitem->gproperties == HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED) + if (gitem->gproperties == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) { - gitem->gproperties = _hb_ot_layout_get_glyph_properties (layout, gitem->gindex); + gitem->gproperties = *property = _hb_ot_layout_get_glyph_properties (layout, gitem->gindex); if (gitem->gproperties == HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED) return false; } @@ -177,7 +176,7 @@ hb_ot_layout_get_glyph_class (HB_OT_Layout *layout, properties = _hb_ot_layout_get_glyph_properties (layout, glyph); - if (properties & 0xFF) + if (properties & 0xFF00) return HB_OT_LAYOUT_GLYPH_CLASS_MARK; return (hb_ot_layout_glyph_class_t) properties; diff --git a/src/hb-private.h b/src/hb-private.h index f67bd57..3dca049 100644 --- a/src/hb-private.h +++ b/src/hb-private.h @@ -52,4 +52,11 @@ #define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size)) +/* + * buffer + */ + +/* XXX */ +#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF + #endif /* HB_PRIVATE_H */ diff --git a/src/main.cc b/src/main.cc index 41a70c7..5a3da55 100644 --- a/src/main.cc +++ b/src/main.cc @@ -63,21 +63,21 @@ main (int argc, char **argv) break; } - int num_fonts = ot.get_len (); + int num_fonts = ot.get_face_count (); printf ("%d font(s) found in file\n", num_fonts); for (int n_font = 0; n_font < num_fonts; n_font++) { - const OpenTypeFontFace &font = ot[n_font]; + const OpenTypeFontFace &font = ot.get_face (n_font); printf ("Font %d of %d:\n", n_font+1, num_fonts); - int num_tables = font.get_len (); + int num_tables = font.get_table_count (); printf (" %d table(s) found in font\n", num_tables); for (int n_table = 0; n_table < num_tables; n_table++) { - const OpenTypeTable &table = font[n_table]; + const OpenTypeTable &table = font.get_table (n_table); printf (" Table %2d of %2d: %.4s (0x%08lx+0x%08lx)\n", n_table+1, num_tables, (const char *)table.get_tag(), table.get_offset(), table.get_length()); - if (table.get_tag() == "GSUB" || table.get_tag() == "GPOS") { - const GSUBGPOS &g = GSUBGPOS::get_for_data (ot[table]); + if (table.get_tag() == GSUBGPOS::GSUBTag || table.get_tag() == GSUBGPOS::GPOSTag) { + const GSUBGPOS &g = GSUBGPOS::get_for_data (ot.get_table_data (table)); const ScriptList &scripts = g.get_script_list(); int num_scripts = scripts.get_len ();