提交 bf94b3ad 编写于 作者: B Behdad Esfahbod

Move some more code around

上级 6334658f
...@@ -374,6 +374,27 @@ struct GDEF ...@@ -374,6 +374,27 @@ struct GDEF
&& (version < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this)); && (version < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this));
} }
/* glyph_props is a 16-bit integer where the lower 8-bit have bits representing
* glyph class and other bits, and high 8-bit gthe mark attachment type (if any).
* Not to be confused with lookup_props which is very similar. */
inline unsigned int get_glyph_props (hb_codepoint_t glyph) const
{
unsigned int klass = get_glyph_class (glyph);
switch (klass) {
default:
case UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
case BaseGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
case LigatureGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
case ComponentGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
case MarkGlyph:
klass = get_mark_attachment_type (glyph);
return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
}
}
private: private:
FixedVersion version; /* Version of the GDEF table--currently FixedVersion version; /* Version of the GDEF table--currently
* 0x00010002 */ * 0x00010002 */
......
...@@ -46,11 +46,11 @@ HB_BEGIN_DECLS ...@@ -46,11 +46,11 @@ HB_BEGIN_DECLS
#define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */ #define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */
typedef enum { typedef enum {
HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0001,
HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002, HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002,
HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004, HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004,
HB_OT_LAYOUT_GLYPH_CLASS_MARK = 0x0008, HB_OT_LAYOUT_GLYPH_CLASS_MARK = 0x0008,
HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 0x0010, HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 0x0010
HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0020
} hb_ot_layout_glyph_class_t; } hb_ot_layout_glyph_class_t;
...@@ -94,17 +94,36 @@ _hb_ot_layout_free (hb_ot_layout_t *layout); ...@@ -94,17 +94,36 @@ _hb_ot_layout_free (hb_ot_layout_t *layout);
* GDEF * GDEF
*/ */
HB_INTERNAL unsigned int
_hb_ot_layout_get_glyph_property (hb_face_t *face,
hb_glyph_info_t *info);
HB_INTERNAL hb_bool_t HB_INTERNAL hb_bool_t
_hb_ot_layout_check_glyph_property (hb_face_t *face, _hb_ot_layout_check_glyph_property (hb_face_t *face,
hb_glyph_info_t *ginfo, hb_glyph_info_t *ginfo,
unsigned int lookup_props, unsigned int lookup_props,
unsigned int *property); unsigned int *property);
HB_INTERNAL hb_bool_t static inline hb_bool_t
_hb_ot_layout_skip_mark (hb_face_t *face, _hb_ot_layout_skip_mark (hb_face_t *face,
hb_glyph_info_t *ginfo, hb_glyph_info_t *ginfo,
unsigned int lookup_props, unsigned int lookup_props,
unsigned int *property); unsigned int *property_out)
{
unsigned int property;
property = _hb_ot_layout_get_glyph_property (face, ginfo);
if (property_out)
*property_out = property;
/* If it's a mark, skip it we don't accept it. */
if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
return !_hb_ot_layout_check_glyph_property (face, ginfo, lookup_props, NULL);
/* If not a mark, don't skip. */
return false;
}
HB_END_DECLS HB_END_DECLS
......
...@@ -73,19 +73,19 @@ _hb_ot_layout_free (hb_ot_layout_t *layout) ...@@ -73,19 +73,19 @@ _hb_ot_layout_free (hb_ot_layout_t *layout)
free (layout); free (layout);
} }
static const GDEF& static inline const GDEF&
_get_gdef (hb_face_t *face) _get_gdef (hb_face_t *face)
{ {
return likely (face->ot_layout && face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF); return likely (face->ot_layout && face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF);
} }
static const GSUB& static inline const GSUB&
_get_gsub (hb_face_t *face) _get_gsub (hb_face_t *face)
{ {
return likely (face->ot_layout && face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB); return likely (face->ot_layout && face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB);
} }
static const GPOS& static inline const GPOS&
_get_gpos (hb_face_t *face) _get_gpos (hb_face_t *face)
{ {
return likely (face->ot_layout && face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS); return likely (face->ot_layout && face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS);
...@@ -102,35 +102,15 @@ hb_ot_layout_has_glyph_classes (hb_face_t *face) ...@@ -102,35 +102,15 @@ hb_ot_layout_has_glyph_classes (hb_face_t *face)
return _get_gdef (face).has_glyph_classes (); return _get_gdef (face).has_glyph_classes ();
} }
static unsigned int unsigned int
_hb_ot_layout_get_glyph_property_from_gdef (hb_face_t *face,
hb_glyph_info_t *info)
{
hb_codepoint_t glyph = info->codepoint;
unsigned int klass;
const GDEF &gdef = _get_gdef (face);
klass = gdef.get_glyph_class (glyph);
switch (klass) {
default:
case GDEF::UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
case GDEF::BaseGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
case GDEF::LigatureGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
case GDEF::ComponentGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
case GDEF::MarkGlyph:
klass = gdef.get_mark_attachment_type (glyph);
return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
}
}
static inline unsigned int
_hb_ot_layout_get_glyph_property (hb_face_t *face, _hb_ot_layout_get_glyph_property (hb_face_t *face,
hb_glyph_info_t *info) hb_glyph_info_t *info)
{ {
if (!info->gproperty()) if (!info->gproperty())
info->gproperty() = _hb_ot_layout_get_glyph_property_from_gdef (face, info); {
const GDEF &gdef = _get_gdef (face);
info->gproperty() = gdef.get_glyph_props (info->codepoint);
}
return info->gproperty(); return info->gproperty();
} }
...@@ -172,26 +152,6 @@ _hb_ot_layout_check_glyph_property (hb_face_t *face, ...@@ -172,26 +152,6 @@ _hb_ot_layout_check_glyph_property (hb_face_t *face,
return true; return true;
} }
hb_bool_t
_hb_ot_layout_skip_mark (hb_face_t *face,
hb_glyph_info_t *ginfo,
unsigned int lookup_props,
unsigned int *property_out)
{
unsigned int property;
property = _hb_ot_layout_get_glyph_property (face, ginfo);
if (property_out)
*property_out = property;
/* If it's a mark, skip it we don't accept it. */
if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
return !_hb_ot_layout_check_glyph_property (face, ginfo, lookup_props, NULL);
/* If not a mark, don't skip. */
return false;
}
unsigned int unsigned int
hb_ot_layout_get_attach_points (hb_face_t *face, hb_ot_layout_get_attach_points (hb_face_t *face,
hb_codepoint_t glyph, hb_codepoint_t glyph,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册