[HB] Add get_attach_points()
This commit is contained in:
parent
855720ca47
commit
79420ad9ca
@ -6,7 +6,7 @@ INCLUDES = \
|
|||||||
-I $(srcdir) \
|
-I $(srcdir) \
|
||||||
$(FREETYPE_CFLAGS) \
|
$(FREETYPE_CFLAGS) \
|
||||||
$(GLIB_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
|
noinst_LTLIBRARIES = libharfbuzz-1.la
|
||||||
|
|
||||||
|
@ -50,10 +50,18 @@ ASSERT_SIZE (AttachPoint, 2);
|
|||||||
|
|
||||||
struct AttachList
|
struct AttachList
|
||||||
{
|
{
|
||||||
/* XXX We need enumeration API here */
|
inline void get_attach_points (hb_codepoint_t glyph_id,
|
||||||
inline const AttachPoint& get_attach_points (hb_codepoint_t glyph)
|
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:
|
private:
|
||||||
@ -164,9 +172,10 @@ struct LigCaretList
|
|||||||
friend struct GDEF;
|
friend struct GDEF;
|
||||||
|
|
||||||
private:
|
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:
|
private:
|
||||||
@ -198,14 +207,20 @@ struct GDEF
|
|||||||
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
|
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
|
||||||
|
|
||||||
inline bool has_glyph_classes () const { return glyphClassDef != 0; }
|
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 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_points () const { return attachList != 0; }
|
||||||
inline bool has_attach_list () const { return attachList != 0; }
|
inline void get_attach_points (hb_codepoint_t glyph_id,
|
||||||
inline bool has_lig_caret_list () const { return ligCaretList != 0; }
|
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:
|
private:
|
||||||
FixedVersion version; /* Version of the GDEF table--initially
|
FixedVersion version; /* Version of the GDEF table--initially
|
||||||
|
@ -52,9 +52,7 @@ struct ValueFormat : USHORT
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline unsigned int get_len () const
|
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 void apply_value (hb_ot_layout_t *layout,
|
||||||
const char *base,
|
const char *base,
|
||||||
@ -1138,9 +1136,7 @@ struct ContextPos : Context
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const
|
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);
|
ASSERT_SIZE (ContextPos, 2);
|
||||||
|
|
||||||
@ -1150,9 +1146,7 @@ struct ChainContextPos : ChainContext
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const
|
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);
|
ASSERT_SIZE (ChainContextPos, 2);
|
||||||
|
|
||||||
@ -1225,9 +1219,7 @@ ASSERT_SIZE (PosLookupSubTable, 2);
|
|||||||
struct PosLookup : Lookup
|
struct PosLookup : Lookup
|
||||||
{
|
{
|
||||||
inline const PosLookupSubTable& get_subtable (unsigned int i) const
|
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.
|
/* Like get_type(), but looks through extension lookups.
|
||||||
* Never returns Extension */
|
* Never returns Extension */
|
||||||
@ -1315,22 +1307,16 @@ struct GPOS : GSUBGPOS
|
|||||||
static const hb_tag_t Tag = HB_TAG ('G','P','O','S');
|
static const hb_tag_t Tag = HB_TAG ('G','P','O','S');
|
||||||
|
|
||||||
static inline const GPOS& get_for_data (const char *data)
|
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
|
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,
|
inline bool position_lookup (hb_ot_layout_t *layout,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
unsigned int lookup_index,
|
unsigned int lookup_index,
|
||||||
hb_ot_layout_feature_mask_t mask) const
|
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);
|
ASSERT_SIZE (GPOS, 10);
|
||||||
|
@ -455,9 +455,7 @@ struct ContextSubst : Context
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const
|
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);
|
ASSERT_SIZE (ContextSubst, 2);
|
||||||
|
|
||||||
@ -467,9 +465,7 @@ struct ChainContextSubst : ChainContext
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const
|
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);
|
ASSERT_SIZE (ChainContextSubst, 2);
|
||||||
|
|
||||||
@ -614,9 +610,7 @@ ASSERT_SIZE (SubstLookupSubTable, 2);
|
|||||||
struct SubstLookup : Lookup
|
struct SubstLookup : Lookup
|
||||||
{
|
{
|
||||||
inline const SubstLookupSubTable& get_subtable (unsigned int i) const
|
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.
|
/* Like get_type(), but looks through extension lookups.
|
||||||
* Never returns Extension */
|
* Never returns Extension */
|
||||||
@ -639,9 +633,7 @@ struct SubstLookup : Lookup
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_reverse (void) const
|
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,
|
inline bool apply_once (hb_ot_layout_t *layout,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
@ -721,22 +713,16 @@ struct GSUB : GSUBGPOS
|
|||||||
static const hb_tag_t Tag = HB_TAG ('G','S','U','B');
|
static const hb_tag_t Tag = HB_TAG ('G','S','U','B');
|
||||||
|
|
||||||
static inline const GSUB& get_for_data (const char *data)
|
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
|
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,
|
inline bool substitute_lookup (hb_ot_layout_t *layout,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
unsigned int lookup_index,
|
unsigned int lookup_index,
|
||||||
hb_ot_layout_feature_mask_t mask) const
|
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);
|
ASSERT_SIZE (GSUB, 10);
|
||||||
|
@ -322,9 +322,7 @@ struct ArrayOf
|
|||||||
return array[i];
|
return array[i];
|
||||||
}
|
}
|
||||||
inline unsigned int get_size () const
|
inline unsigned int get_size () const
|
||||||
{
|
{ return sizeof (len) + len * sizeof (array[0]); }
|
||||||
return sizeof (len) + len * sizeof (array[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
USHORT len;
|
USHORT len;
|
||||||
Type array[];
|
Type array[];
|
||||||
@ -341,9 +339,7 @@ struct HeadlessArrayOf
|
|||||||
return array[i-1];
|
return array[i-1];
|
||||||
}
|
}
|
||||||
inline unsigned int get_size () const
|
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;
|
USHORT len;
|
||||||
Type array[];
|
Type array[];
|
||||||
@ -359,9 +355,7 @@ struct LongArrayOf
|
|||||||
return array[i];
|
return array[i];
|
||||||
}
|
}
|
||||||
inline unsigned int get_size () const
|
inline unsigned int get_size () const
|
||||||
{
|
{ return sizeof (len) + len * sizeof (array[0]); }
|
||||||
return sizeof (len) + len * sizeof (array[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG len;
|
ULONG len;
|
||||||
Type array[];
|
Type array[];
|
||||||
|
@ -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]);
|
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
|
* GSUB/GPOS
|
||||||
*/
|
*/
|
||||||
|
@ -99,6 +99,12 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
|
|||||||
unsigned char *klasses,
|
unsigned char *klasses,
|
||||||
uint16_t count);
|
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
|
* GSUB/GPOS
|
||||||
*/
|
*/
|
||||||
|
@ -155,10 +155,10 @@ main (int argc, char **argv)
|
|||||||
gdef.has_glyph_classes () ? "" : "no ");
|
gdef.has_glyph_classes () ? "" : "no ");
|
||||||
printf (" Has %smark attachment types\n",
|
printf (" Has %smark attachment types\n",
|
||||||
gdef.has_mark_attachment_types () ? "" : "no ");
|
gdef.has_mark_attachment_types () ? "" : "no ");
|
||||||
printf (" Has %sattach list\n",
|
printf (" Has %sattach points\n",
|
||||||
gdef.has_attach_list () ? "" : "no ");
|
gdef.has_attach_points () ? "" : "no ");
|
||||||
printf (" Has %slig caret list\n",
|
printf (" Has %slig carets\n",
|
||||||
gdef.has_lig_caret_list () ? "" : "no ");
|
gdef.has_lig_carets () ? "" : "no ");
|
||||||
|
|
||||||
for (int glyph = 0; glyph < 1; glyph++)
|
for (int glyph = 0; glyph < 1; glyph++)
|
||||||
printf (" glyph %d has class %d and mark attachment type %d\n",
|
printf (" glyph %d has class %d and mark attachment type %d\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user