GDEF completely working now
This commit is contained in:
parent
6f425b1179
commit
54e5aac5e2
|
@ -27,6 +27,10 @@
|
||||||
#ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H
|
#ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H
|
||||||
#define 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"
|
#include "hb-ot-layout-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@
|
||||||
return &(*this)[i]; \
|
return &(*this)[i]; \
|
||||||
return NULL; \
|
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++) \
|
for (unsigned int i = 0; i < this->get_len (); i++) \
|
||||||
if (tag == (*this)[i].tag) \
|
if (tag == (*this)[i].tag) \
|
||||||
return (*this)[i]; \
|
return (*this)[i]; \
|
||||||
|
@ -158,6 +162,7 @@
|
||||||
private: inline Type() {} /* cannot be instantiated */ \
|
private: inline Type() {} /* cannot be instantiated */ \
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/* TODO use a global nul-array for most Null's */
|
||||||
/* defines Null##Type as a safe nil instance of Type */
|
/* defines Null##Type as a safe nil instance of Type */
|
||||||
#define DEFINE_NULL_DATA(Type, size, data) \
|
#define DEFINE_NULL_DATA(Type, size, data) \
|
||||||
static const unsigned char Null##Type##Data[size] = data; \
|
static const unsigned char Null##Type##Data[size] = data; \
|
||||||
|
@ -170,11 +175,11 @@
|
||||||
ASSERT_SIZE (Type, size); \
|
ASSERT_SIZE (Type, size); \
|
||||||
DEFINE_NULL_DATA (Type, size, data)
|
DEFINE_NULL_DATA (Type, size, data)
|
||||||
#define DEFINE_NULL_ALIAS(NewType, OldType) \
|
#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
|
/* 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
|
* 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) \
|
#define STATIC_DEFINE_GET_FOR_DATA(Type) \
|
||||||
static inline const Type& get_for_data (const char *data) { \
|
static inline const Type& get_for_data (const char *data) { \
|
||||||
extern const Type &Null##Type; \
|
extern const Type &Null##Type; \
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
#ifndef HB_OT_LAYOUT_PRIVATE_H
|
#ifndef HB_OT_LAYOUT_PRIVATE_H
|
||||||
#define 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-private.h"
|
||||||
#include "hb-ot-layout.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 uint16_t hb_ot_layout_lookup_flags_t;
|
||||||
typedef int hb_ot_layout_coverage_t; /* -1 is not covered, >= 0 otherwise */
|
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();
|
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);
|
_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_ot_layout_get_glyph_properties (HB_OT_Layout *layout,
|
||||||
hb_glyph_t glyph);
|
hb_glyph_t glyph);
|
||||||
|
|
||||||
static bool
|
HB_OT_LAYOUT_INTERNAL hb_bool_t
|
||||||
_hb_ot_layout_check_glyph_properties (HB_OT_Layout *layout,
|
_hb_ot_layout_check_glyph_properties (HB_OT_Layout *layout,
|
||||||
HB_GlyphItem gitem,
|
HB_GlyphItem gitem,
|
||||||
hb_ot_layout_lookup_flags_t lookup_flags,
|
hb_ot_layout_lookup_flags_t lookup_flags,
|
||||||
|
|
|
@ -61,9 +61,9 @@ hb_ot_layout_create (const char *font_data,
|
||||||
const OpenTypeFontFile &font = OpenTypeFontFile::get_for_data (font_data);
|
const OpenTypeFontFile &font = OpenTypeFontFile::get_for_data (font_data);
|
||||||
const OpenTypeFontFace &face = font.get_face (face_index);
|
const OpenTypeFontFace &face = font.get_face (face_index);
|
||||||
|
|
||||||
layout->gdef = &GDEF::get_for_data (font.get_table_data (face.get_table (GDEF::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 (GSUB::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 (GPOS::Tag)));
|
//layout->gpos = &GPOS::get_for_data (font.get_table_data (face.get_table_by_tag (GPOS::Tag)));
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
@ -84,13 +84,13 @@ hb_ot_layout_has_font_glyph_classes (HB_OT_Layout *layout)
|
||||||
return layout->gdef->has_glyph_classes ();
|
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)
|
_hb_ot_layout_has_new_glyph_classes (HB_OT_Layout *layout)
|
||||||
{
|
{
|
||||||
return layout->new_gdef.len > 0;
|
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_ot_layout_get_glyph_properties (HB_OT_Layout *layout,
|
||||||
hb_glyph_t glyph)
|
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_ot_layout_check_glyph_properties (HB_OT_Layout *layout,
|
||||||
HB_GlyphItem gitem,
|
HB_GlyphItem gitem,
|
||||||
hb_ot_layout_lookup_flags_t lookup_flags,
|
hb_ot_layout_lookup_flags_t lookup_flags,
|
||||||
hb_ot_layout_glyph_properties_t *property)
|
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_class_t basic_glyph_class;
|
||||||
hb_ot_layout_glyph_properties_t desired_attachment_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)
|
if (gitem->gproperties == HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED)
|
||||||
return false;
|
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);
|
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_MARK;
|
||||||
|
|
||||||
return (hb_ot_layout_glyph_class_t) properties;
|
return (hb_ot_layout_glyph_class_t) properties;
|
||||||
|
|
|
@ -52,4 +52,11 @@
|
||||||
|
|
||||||
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
|
#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* buffer
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
|
||||||
|
|
||||||
#endif /* HB_PRIVATE_H */
|
#endif /* HB_PRIVATE_H */
|
||||||
|
|
12
src/main.cc
12
src/main.cc
|
@ -63,21 +63,21 @@ main (int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_fonts = ot.get_len ();
|
int num_fonts = ot.get_face_count ();
|
||||||
printf ("%d font(s) found in file\n", num_fonts);
|
printf ("%d font(s) found in file\n", num_fonts);
|
||||||
for (int n_font = 0; n_font < num_fonts; n_font++) {
|
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);
|
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);
|
printf (" %d table(s) found in font\n", num_tables);
|
||||||
for (int n_table = 0; n_table < num_tables; n_table++) {
|
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,
|
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());
|
(const char *)table.get_tag(), table.get_offset(), table.get_length());
|
||||||
|
|
||||||
if (table.get_tag() == "GSUB" || table.get_tag() == "GPOS") {
|
if (table.get_tag() == GSUBGPOS::GSUBTag || table.get_tag() == GSUBGPOS::GPOSTag) {
|
||||||
const GSUBGPOS &g = GSUBGPOS::get_for_data (ot[table]);
|
const GSUBGPOS &g = GSUBGPOS::get_for_data (ot.get_table_data (table));
|
||||||
|
|
||||||
const ScriptList &scripts = g.get_script_list();
|
const ScriptList &scripts = g.get_script_list();
|
||||||
int num_scripts = scripts.get_len ();
|
int num_scripts = scripts.get_len ();
|
||||||
|
|
Loading…
Reference in New Issue