[MATH] Wire up get_glyph_variants()
This commit is contained in:
parent
7fe0e28c22
commit
353f455af7
|
@ -116,12 +116,12 @@ 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 int dir_scale (hb_direction_t direction)
|
||||
{ return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; }
|
||||
inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); }
|
||||
inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, 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); }
|
||||
{ return em_scale (v, dir_scale (direction)); }
|
||||
|
||||
/* Convert from parent-font user-space to our user-space */
|
||||
inline hb_position_t parent_scale_x_distance (hb_position_t v) {
|
||||
|
@ -508,7 +508,6 @@ struct hb_font_t {
|
|||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
inline hb_position_t em_scale (int16_t v, int scale)
|
||||
{
|
||||
int upem = face->get_upem ();
|
||||
|
|
|
@ -415,21 +415,14 @@ public:
|
|||
|
||||
struct MathGlyphVariantRecord
|
||||
{
|
||||
friend struct MathGlyphConstruction;
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
hb_codepoint_t get_glyph() const { return variantGlyph; }
|
||||
inline hb_position_t get_advance_measurement (hb_font_t *font,
|
||||
bool horizontal) const
|
||||
{
|
||||
return horizontal ?
|
||||
font->em_scale_x (advanceMeasurement) :
|
||||
font->em_scale_y (advanceMeasurement);
|
||||
}
|
||||
|
||||
protected:
|
||||
GlyphID variantGlyph; /* Glyph ID for the variant. */
|
||||
USHORT advanceMeasurement; /* Advance width/height, in design units, of the
|
||||
|
@ -450,44 +443,16 @@ public:
|
|||
DEFINE_SIZE_STATIC (2);
|
||||
};
|
||||
|
||||
struct GlyphPartRecord
|
||||
struct MathGlyphPartRecord
|
||||
{
|
||||
friend struct MathGlyphAssembly;
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
hb_codepoint_t get_glyph() const { return glyph; }
|
||||
|
||||
inline hb_position_t
|
||||
get_start_connector_length (hb_font_t *font, bool horizontal) const
|
||||
{
|
||||
return horizontal ?
|
||||
font->em_scale_x (startConnectorLength) :
|
||||
font->em_scale_y (startConnectorLength);
|
||||
}
|
||||
|
||||
inline hb_position_t
|
||||
get_end_connector_length (hb_font_t *font, bool horizontal) const
|
||||
{
|
||||
return horizontal ?
|
||||
font->em_scale_x (endConnectorLength) :
|
||||
font->em_scale_y (endConnectorLength);
|
||||
}
|
||||
|
||||
inline hb_position_t
|
||||
get_full_advance (hb_font_t *font, bool horizontal) const
|
||||
{
|
||||
return horizontal ?
|
||||
font->em_scale_x (fullAdvance) :
|
||||
font->em_scale_y (fullAdvance);
|
||||
}
|
||||
|
||||
inline bool is_extender() const {
|
||||
return partFlags & PartFlags::Flags::Extender;
|
||||
}
|
||||
|
||||
protected:
|
||||
GlyphID glyph; /* Glyph ID for the part. */
|
||||
USHORT startConnectorLength; /* Advance width/ height of the straight bar
|
||||
|
@ -507,7 +472,7 @@ public:
|
|||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
struct GlyphAssembly
|
||||
struct MathGlyphAssembly
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
|
@ -520,16 +485,11 @@ struct GlyphAssembly
|
|||
inline hb_position_t get_italic_correction (hb_font_t *font) const
|
||||
{ return italicsCorrection.get_x_value(font, this); }
|
||||
|
||||
inline unsigned int part_record_count() const { return partRecords.len; }
|
||||
inline const GlyphPartRecord &get_part_record(unsigned int i) const {
|
||||
return partRecords[i];
|
||||
}
|
||||
|
||||
protected:
|
||||
MathValueRecord italicsCorrection; /* Italics correction of this
|
||||
* GlyphAssembly. Should not
|
||||
* MathGlyphAssembly. Should not
|
||||
* depend on the assembly size. */
|
||||
ArrayOf<GlyphPartRecord> partRecords; /* Array of part records, from
|
||||
ArrayOf<MathGlyphPartRecord> partRecords; /* Array of part records, from
|
||||
* left to right and bottom to
|
||||
* top. */
|
||||
|
||||
|
@ -547,10 +507,31 @@ struct MathGlyphConstruction
|
|||
mathGlyphVariantRecord.sanitize(c));
|
||||
}
|
||||
|
||||
inline unsigned int get_variants (hb_direction_t direction,
|
||||
hb_font_t *font,
|
||||
unsigned int start_offset,
|
||||
unsigned int *variants_count, /* IN/OUT */
|
||||
hb_math_glyph_variant_t *variants /* OUT */) const
|
||||
{
|
||||
if (variants_count)
|
||||
{
|
||||
int scale = font->dir_scale (direction);
|
||||
const MathGlyphVariantRecord *arr =
|
||||
mathGlyphVariantRecord.sub_array (start_offset, variants_count);
|
||||
unsigned int count = *variants_count;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
variants[i].glyph = arr[i].variantGlyph;
|
||||
variants[i].advance = font->em_scale (arr[i].advanceMeasurement, scale);
|
||||
}
|
||||
}
|
||||
return mathGlyphVariantRecord.len;
|
||||
}
|
||||
|
||||
protected:
|
||||
/* Offset to GlyphAssembly table for this shape - from the beginning of
|
||||
/* Offset to MathGlyphAssembly table for this shape - from the beginning of
|
||||
MathGlyphConstruction table. May be NULL. */
|
||||
OffsetTo<GlyphAssembly> glyphAssembly;
|
||||
OffsetTo<MathGlyphAssembly> glyphAssembly;
|
||||
|
||||
/* MathGlyphVariantRecords for alternative variants of the glyphs. */
|
||||
ArrayOf<MathGlyphVariantRecord> mathGlyphVariantRecord;
|
||||
|
@ -586,24 +567,33 @@ struct MathVariants
|
|||
hb_font_t *font) const
|
||||
{ return font->em_scale_dir (minConnectorOverlap, direction); }
|
||||
|
||||
inline bool
|
||||
inline unsigned int get_glyph_variants (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_font_t *font,
|
||||
unsigned int start_offset,
|
||||
unsigned int *variants_count, /* IN/OUT */
|
||||
hb_math_glyph_variant_t *variants /* OUT */) const
|
||||
{ return get_glyph_construction (glyph, direction, font)
|
||||
.get_variants (direction, font, start_offset, variants_count, variants); }
|
||||
|
||||
private:
|
||||
inline const MathGlyphConstruction &
|
||||
get_glyph_construction (hb_codepoint_t glyph,
|
||||
hb_bool_t horizontal,
|
||||
const MathGlyphConstruction *&glyph_construction) const {
|
||||
unsigned int index =
|
||||
horizontal ?
|
||||
(this+horizGlyphCoverage).get_coverage (glyph) :
|
||||
(this+vertGlyphCoverage).get_coverage (glyph);
|
||||
if (likely (index == NOT_COVERED)) return false;
|
||||
hb_direction_t direction,
|
||||
hb_font_t *font) const
|
||||
{
|
||||
bool vertical = HB_DIRECTION_IS_VERTICAL (direction);
|
||||
unsigned int count = vertical ? vertGlyphCount : horizGlyphCount;
|
||||
const OffsetTo<Coverage> &coverage = vertical ? vertGlyphCoverage
|
||||
: horizGlyphCoverage;
|
||||
|
||||
USHORT glyphCount = horizontal ? horizGlyphCount : vertGlyphCount;
|
||||
if (unlikely (index >= glyphCount)) return false;
|
||||
unsigned int index = (this+coverage).get_coverage (glyph);
|
||||
if (unlikely (index >= count)) return Null(MathGlyphConstruction);
|
||||
|
||||
if (horizontal)
|
||||
if (!vertical)
|
||||
index += vertGlyphCount;
|
||||
|
||||
glyph_construction = &(this + glyphConstruction[index]);
|
||||
return true;
|
||||
return this+glyphConstruction[index];
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1356,11 +1356,14 @@ 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 */
|
||||
unsigned int *variants_count, /* IN/OUT */
|
||||
hb_math_glyph_variant_t *variants /* OUT */)
|
||||
{
|
||||
const OT::MATH &math = _get_math (font->face);
|
||||
return 0;
|
||||
return math.get_math_variants().get_glyph_variants (glyph, direction, font,
|
||||
start_offset,
|
||||
variants_count,
|
||||
variants);
|
||||
}
|
||||
|
||||
hb_position_t
|
||||
|
|
|
@ -333,7 +333,7 @@ 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 */
|
||||
unsigned int *variants_count, /* IN/OUT */
|
||||
hb_math_glyph_variant_t *variants /* OUT */);
|
||||
|
||||
HB_EXTERN hb_position_t
|
||||
|
|
Loading…
Reference in New Issue