[MATH] Start fleshing out glyph variant API

This commit is contained in:
Behdad Esfahbod 2016-09-26 17:51:47 +01:00
parent 1f3327f210
commit 7fe0e28c22
5 changed files with 72 additions and 55 deletions

View File

@ -118,6 +118,10 @@ struct hb_font_t {
/* Convert from font-space to user-space */
inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); }
inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
{ return em_scale (v,
HB_DIRECTION_IS_VERTICAL(direction) ?
this->y_scale : this->x_scale); }
/* Convert from parent-font user-space to our user-space */
inline hb_position_t parent_scale_x_distance (hb_position_t v) {

View File

@ -582,13 +582,9 @@ struct MathVariants
sanitize_offsets (c));
}
inline hb_position_t get_min_connector_overlap (hb_font_t *font,
bool horizontal) const
{
return horizontal ?
font->em_scale_x (minConnectorOverlap) :
font->em_scale_y (minConnectorOverlap);
}
inline hb_position_t get_min_connector_overlap (hb_direction_t direction,
hb_font_t *font) const
{ return font->em_scale_dir (minConnectorOverlap, direction); }
inline bool
get_glyph_construction (hb_codepoint_t glyph,

View File

@ -1279,7 +1279,7 @@ hb_ot_layout_get_math_constant (hb_font_t *font,
*
* Since: 1.4
**/
HB_EXTERN hb_position_t
hb_position_t
hb_ot_layout_get_math_italics_correction (hb_font_t *font,
hb_codepoint_t glyph)
{
@ -1297,7 +1297,7 @@ hb_ot_layout_get_math_italics_correction (hb_font_t *font,
*
* Since: 1.4
**/
HB_EXTERN hb_position_t
hb_position_t
hb_ot_layout_get_math_top_accent_attachment (hb_font_t *font,
hb_codepoint_t glyph)
{
@ -1315,7 +1315,7 @@ hb_ot_layout_get_math_top_accent_attachment (hb_font_t *font,
*
* Since: 1.4
**/
HB_EXTERN hb_bool_t
hb_bool_t
hb_ot_layout_is_math_extended_shape (hb_face_t *face,
hb_codepoint_t glyph)
{
@ -1351,56 +1351,35 @@ hb_ot_layout_get_math_kerning (hb_font_t *font,
return math.get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
}
#if 0
/**
* hb_ot_layout_get_math_italic_correction_for_glyph_assembly:
* @font: an #hb_font_t with an OpenType MATH table
* @base_glyph: index of the glyph to stretch
* @horizontal: direction of the stretching
*
* This function tries and get the italic correction associated to the glyph
* assembly used to stretch the base glyph in the specified direction.
*
* Return value: the italic correction of the glyph assembly or 0
*
* Since: ????
**/
HB_EXTERN hb_position_t
hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font_t *font,
hb_codepoint_t base_glyph,
hb_bool_t horizontal)
HB_EXTERN unsigned int
hb_ot_layout_get_math_glyph_variants (hb_font_t *font,
hb_codepoint_t glyph,
hb_direction_t direction,
unsigned int start_offset,
unsigned int *variant_count, /* IN/OUT */
hb_math_glyph_variant_t *variants /* OUT */)
{
const OT::MATH &math = _get_math (font->face);
if (math.has_math_variants()) {
const OT::MathGlyphConstruction* glyph_construction;
if (math.get_math_variants().
get_glyph_construction(base_glyph, horizontal, glyph_construction) &&
glyph_construction->has_glyph_assembly())
return glyph_construction->
get_glyph_assembly().get_italic_correction(font);
}
return 0;
}
HB_INTERNAL hb_bool_t
hb_ot_layout_get_math_glyph_construction (hb_font_t *font,
hb_codepoint_t glyph,
hb_bool_t horizontal,
hb_position_t &minConnectorOverlap,
const OT::MathGlyphConstruction *&glyph_construction)
hb_position_t
hb_ot_layout_get_math_min_connector_overlap (hb_font_t *font,
hb_direction_t direction)
{
const OT::MATH &math = _get_math (font->face);
if (!math.has_math_variants()) return false;
const OT::MathVariants &mathVariants = math.get_math_variants();
if (!mathVariants.get_glyph_construction(glyph, horizontal,
glyph_construction)) return false;
minConnectorOverlap = mathVariants.get_min_connector_overlap(font, horizontal);
return true;
return math.get_math_variants().get_min_connector_overlap (direction, font);
}
HB_EXTERN unsigned int
hb_ot_layout_get_math_glyph_assembly_parts (hb_font_t *font,
hb_codepoint_t glyph,
hb_direction_t direction,
unsigned int start_offset,
unsigned int *parts_count, /* IN/OUT */
hb_math_glyph_part_t *parts, /* OUT */
hb_position_t *italic_correction /* OUT */)
{
const OT::MATH &math = _get_math (font->face);
return 0;
}
#endif

View File

@ -328,6 +328,26 @@ hb_ot_layout_get_math_kerning (hb_font_t *font,
hb_ot_math_kern_t kern,
hb_position_t correction_height);
HB_EXTERN unsigned int
hb_ot_layout_get_math_glyph_variants (hb_font_t *font,
hb_codepoint_t glyph,
hb_direction_t direction,
unsigned int start_offset,
unsigned int *variant_count, /* IN/OUT */
hb_math_glyph_variant_t *variants /* OUT */);
HB_EXTERN hb_position_t
hb_ot_layout_get_math_min_connector_overlap (hb_font_t *font,
hb_direction_t direction);
HB_EXTERN unsigned int
hb_ot_layout_get_math_glyph_assembly_parts (hb_font_t *font,
hb_codepoint_t glyph,
hb_direction_t direction,
unsigned int start_offset,
unsigned int *parts_count, /* IN/OUT */
hb_math_glyph_part_t *parts, /* OUT */
hb_position_t *italic_correction /* OUT */);
HB_END_DECLS

View File

@ -102,6 +102,24 @@ typedef enum {
HB_OT_MATH_KERN_BOTTOM_LEFT = 3
} hb_ot_math_kern_t;
typedef struct hb_math_glyph_variant_t {
hb_codepoint_t glyph;
hb_position_t advance;
} hb_math_glyph_variant_t;
typedef enum { /*< flags >*/
HB_MATH_GLYPH_PART_FLAG_EXTENDER = 0x00000001u /* Extender glyph */
} hb_math_glyph_part_flags_t;
typedef struct hb_math_glyph_part_t {
hb_codepoint_t glyph;
hb_position_t start_connector_length;
hb_position_t end_connector_length;
hb_position_t full_advance;
hb_math_glyph_part_flags_t flags;
} hb_math_glyph_part_t;
HB_END_DECLS
#endif /* HB_OT_MATH_H */