[HB] Add get_attach_points()

This commit is contained in:
Behdad Esfahbod 2009-05-26 12:24:16 -04:00
parent 855720ca47
commit 79420ad9ca
8 changed files with 62 additions and 66 deletions

View File

@ -6,7 +6,7 @@ INCLUDES = \
-I $(srcdir) \
$(FREETYPE_CFLAGS) \
$(GLIB_CFLAGS)
CXX = gcc $(GCCOPTS) -g -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
CXX = gcc -g -O2 -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
noinst_LTLIBRARIES = libharfbuzz-1.la

View File

@ -50,10 +50,18 @@ ASSERT_SIZE (AttachPoint, 2);
struct AttachList
{
/* XXX We need enumeration API here */
inline const AttachPoint& get_attach_points (hb_codepoint_t glyph)
inline void get_attach_points (hb_codepoint_t glyph_id,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */) const
{
return this+attachPoint[(this+coverage) (glyph)];
unsigned int index = (this+coverage) (glyph_id);
const AttachPoint &points = this+attachPoint[index];
unsigned int count = MIN (points.len, *point_count);
for (unsigned int i = 0; i < count; i++)
point_array[i] = points[i];
*point_count = points.len;
}
private:
@ -164,9 +172,10 @@ struct LigCaretList
friend struct GDEF;
private:
inline const LigGlyph& get_lig_glyph (hb_codepoint_t glyph)
inline const LigGlyph& get_lig_glyph (hb_codepoint_t glyph_id)
{
return this+ligGlyph[(this+coverage) (glyph)];
unsigned int index = (this+coverage) (glyph_id);
return this+ligGlyph[index];
}
private:
@ -198,14 +207,20 @@ struct GDEF
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
inline bool has_glyph_classes () const { return glyphClassDef != 0; }
inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); }
inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
{ return (this+glyphClassDef).get_class (glyph); }
inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const { return (this+markAttachClassDef).get_class (glyph); }
inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
{ return (this+markAttachClassDef).get_class (glyph); }
/* TODO get_attach and get_lig_caret */
inline bool has_attach_list () const { return attachList != 0; }
inline bool has_lig_caret_list () const { return ligCaretList != 0; }
inline bool has_attach_points () const { return attachList != 0; }
inline void get_attach_points (hb_codepoint_t glyph_id,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */) const
{ (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
inline bool has_lig_carets () const { return ligCaretList != 0; }
private:
FixedVersion version; /* Version of the GDEF table--initially

View File

@ -52,9 +52,7 @@ struct ValueFormat : USHORT
};
inline unsigned int get_len () const
{
return _hb_popcount32 ((unsigned int) *this);
}
{ return _hb_popcount32 ((unsigned int) *this); }
const void apply_value (hb_ot_layout_t *layout,
const char *base,
@ -1138,9 +1136,7 @@ struct ContextPos : Context
private:
inline bool apply (APPLY_ARG_DEF) const
{
return Context::apply (APPLY_ARG, position_lookup);
}
{ return Context::apply (APPLY_ARG, position_lookup); }
};
ASSERT_SIZE (ContextPos, 2);
@ -1150,9 +1146,7 @@ struct ChainContextPos : ChainContext
private:
inline bool apply (APPLY_ARG_DEF) const
{
return ChainContext::apply (APPLY_ARG, position_lookup);
}
{ return ChainContext::apply (APPLY_ARG, position_lookup); }
};
ASSERT_SIZE (ChainContextPos, 2);
@ -1225,9 +1219,7 @@ ASSERT_SIZE (PosLookupSubTable, 2);
struct PosLookup : Lookup
{
inline const PosLookupSubTable& get_subtable (unsigned int i) const
{
return (const PosLookupSubTable&) Lookup::get_subtable (i);
}
{ return (const PosLookupSubTable&) Lookup::get_subtable (i); }
/* Like get_type(), but looks through extension lookups.
* Never returns Extension */
@ -1315,22 +1307,16 @@ struct GPOS : GSUBGPOS
static const hb_tag_t Tag = HB_TAG ('G','P','O','S');
static inline const GPOS& get_for_data (const char *data)
{
return (const GPOS&) GSUBGPOS::get_for_data (data);
}
{ return (const GPOS&) GSUBGPOS::get_for_data (data); }
inline const PosLookup& get_lookup (unsigned int i) const
{
return (const PosLookup&) GSUBGPOS::get_lookup (i);
}
{ return (const PosLookup&) GSUBGPOS::get_lookup (i); }
inline bool position_lookup (hb_ot_layout_t *layout,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const
{
return get_lookup (lookup_index).apply_string (layout, buffer, mask);
}
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
};
ASSERT_SIZE (GPOS, 10);

View File

@ -455,9 +455,7 @@ struct ContextSubst : Context
private:
inline bool apply (APPLY_ARG_DEF) const
{
return Context::apply (APPLY_ARG, substitute_lookup);
}
{ return Context::apply (APPLY_ARG, substitute_lookup); }
};
ASSERT_SIZE (ContextSubst, 2);
@ -467,9 +465,7 @@ struct ChainContextSubst : ChainContext
private:
inline bool apply (APPLY_ARG_DEF) const
{
return ChainContext::apply (APPLY_ARG, substitute_lookup);
}
{ return ChainContext::apply (APPLY_ARG, substitute_lookup); }
};
ASSERT_SIZE (ChainContextSubst, 2);
@ -614,9 +610,7 @@ ASSERT_SIZE (SubstLookupSubTable, 2);
struct SubstLookup : Lookup
{
inline const SubstLookupSubTable& get_subtable (unsigned int i) const
{
return (const SubstLookupSubTable&) Lookup::get_subtable (i);
}
{ return (const SubstLookupSubTable&) Lookup::get_subtable (i); }
/* Like get_type(), but looks through extension lookups.
* Never returns Extension */
@ -639,9 +633,7 @@ struct SubstLookup : Lookup
}
inline bool is_reverse (void) const
{
return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle);
}
{ return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); }
inline bool apply_once (hb_ot_layout_t *layout,
hb_buffer_t *buffer,
@ -721,22 +713,16 @@ struct GSUB : GSUBGPOS
static const hb_tag_t Tag = HB_TAG ('G','S','U','B');
static inline const GSUB& get_for_data (const char *data)
{
return (const GSUB&) GSUBGPOS::get_for_data (data);
}
{ return (const GSUB&) GSUBGPOS::get_for_data (data); }
inline const SubstLookup& get_lookup (unsigned int i) const
{
return (const SubstLookup&) GSUBGPOS::get_lookup (i);
}
{ return (const SubstLookup&) GSUBGPOS::get_lookup (i); }
inline bool substitute_lookup (hb_ot_layout_t *layout,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const
{
return get_lookup (lookup_index).apply_string (layout, buffer, mask);
}
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
};
ASSERT_SIZE (GSUB, 10);

View File

@ -322,9 +322,7 @@ struct ArrayOf
return array[i];
}
inline unsigned int get_size () const
{
return sizeof (len) + len * sizeof (array[0]);
}
{ return sizeof (len) + len * sizeof (array[0]); }
USHORT len;
Type array[];
@ -341,9 +339,7 @@ struct HeadlessArrayOf
return array[i-1];
}
inline unsigned int get_size () const
{
return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]);
}
{ return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]); }
USHORT len;
Type array[];
@ -359,9 +355,7 @@ struct LongArrayOf
return array[i];
}
inline unsigned int get_size () const
{
return sizeof (len) + len * sizeof (array[0]);
}
{ return sizeof (len) + len * sizeof (array[0]); }
ULONG len;
Type array[];

View File

@ -302,6 +302,15 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
hb_ot_layout_set_glyph_class (layout, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]);
}
void
hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
hb_codepoint_t glyph,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */)
{
layout->gdef->get_attach_points (glyph, point_count, point_array);
}
/*
* GSUB/GPOS
*/

View File

@ -99,6 +99,12 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
unsigned char *klasses,
uint16_t count);
void
hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
hb_codepoint_t glyph,
unsigned int *point_count /* IN/OUT */,
unsigned int *point_array /* OUT */);
/*
* GSUB/GPOS
*/

View File

@ -155,10 +155,10 @@ main (int argc, char **argv)
gdef.has_glyph_classes () ? "" : "no ");
printf (" Has %smark attachment types\n",
gdef.has_mark_attachment_types () ? "" : "no ");
printf (" Has %sattach list\n",
gdef.has_attach_list () ? "" : "no ");
printf (" Has %slig caret list\n",
gdef.has_lig_caret_list () ? "" : "no ");
printf (" Has %sattach points\n",
gdef.has_attach_points () ? "" : "no ");
printf (" Has %slig carets\n",
gdef.has_lig_carets () ? "" : "no ");
for (int glyph = 0; glyph < 1; glyph++)
printf (" glyph %d has class %d and mark attachment type %d\n",