[OTLayout] Implement 'size' feature
This commit is contained in:
parent
2dc1141d7d
commit
f54cce3c6a
|
@ -248,6 +248,33 @@ struct Script
|
|||
|
||||
typedef RecordListOf<Script> ScriptList;
|
||||
|
||||
struct FeatureParamsSize
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE (this);
|
||||
return TRACE_RETURN (c->check_struct (this));
|
||||
}
|
||||
|
||||
USHORT params[5];
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
struct FeatureParams
|
||||
{
|
||||
/* Note: currently the only feature with params is 'size', so we hardcode
|
||||
* the length of the table to that of the FeatureParamsSize. */
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE (this);
|
||||
return TRACE_RETURN (c->check_struct (this));
|
||||
}
|
||||
|
||||
union {
|
||||
FeatureParamsSize size;
|
||||
} u;
|
||||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
struct Feature
|
||||
{
|
||||
|
@ -260,12 +287,17 @@ struct Feature
|
|||
unsigned int *lookup_tags /* OUT */) const
|
||||
{ return lookupIndex.get_indexes (start_index, lookup_count, lookup_tags); }
|
||||
|
||||
inline const FeatureParams &get_feature_params (void) const
|
||||
{ return this+featureParams; }
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE (this);
|
||||
return TRACE_RETURN (c->check_struct (this) && lookupIndex.sanitize (c));
|
||||
return TRACE_RETURN (c->check_struct (this) && lookupIndex.sanitize (c) &&
|
||||
featureParams.sanitize (c, this));
|
||||
}
|
||||
|
||||
Offset featureParams; /* Offset to Feature Parameters table (if one
|
||||
OffsetTo<FeatureParams>
|
||||
featureParams; /* Offset to Feature Parameters table (if one
|
||||
* has been defined for the feature), relative
|
||||
* to the beginning of the Feature Table; = Null
|
||||
* if not required */
|
||||
|
|
|
@ -639,3 +639,34 @@ hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t ze
|
|||
{
|
||||
OT::GPOS::position_finish (font, buffer, zero_width_attached_marks);
|
||||
}
|
||||
|
||||
hb_bool_t
|
||||
hb_ot_layout_position_get_size (hb_face_t *face,
|
||||
uint16_t *data /* OUT, 5 items */)
|
||||
{
|
||||
const OT::GPOS &gpos = _get_gpos (face);
|
||||
unsigned int script_index;
|
||||
gpos.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, &script_index);
|
||||
const OT::LangSys &l = gpos.get_script (script_index).get_lang_sys (HB_OT_TAG_DEFAULT_LANGUAGE);
|
||||
|
||||
unsigned int num_features = l.get_feature_count ();
|
||||
for (unsigned int i = 0; i < num_features; i++) {
|
||||
unsigned int f_index = l.get_feature_index (i);
|
||||
|
||||
if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (f_index))
|
||||
{
|
||||
const OT::Feature &f = gpos.get_feature (f_index);
|
||||
const OT::FeatureParams ¶ms = f.get_feature_params ();
|
||||
|
||||
for (unsigned int i = 0; i < 5; i++)
|
||||
data[i] = params.u.size.params[i];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 5; i++)
|
||||
data[i] = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -277,6 +277,11 @@ Xhb_ot_layout_lookup_position (hb_font_t *font,
|
|||
hb_glyph_position_t *positions /* IN / OUT */);
|
||||
#endif
|
||||
|
||||
/* Optical 'size' feature info. Returns true if found. */
|
||||
hb_bool_t
|
||||
hb_ot_layout_position_get_size (hb_face_t *face,
|
||||
uint16_t *data /* OUT, 5 items */);
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue