2016-08-25 10:47:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Igalia S.L.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Igalia Author(s): Frédéric Wang
|
|
|
|
*/
|
|
|
|
|
2017-01-10 06:11:00 +01:00
|
|
|
#ifndef HB_OT_MATH_TABLE_HH
|
|
|
|
#define HB_OT_MATH_TABLE_HH
|
2016-08-25 10:47:15 +02:00
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-open-type.hh"
|
|
|
|
#include "hb-ot-layout-common.hh"
|
2016-08-25 11:06:41 +02:00
|
|
|
#include "hb-ot-math.h"
|
2016-08-25 10:47:15 +02:00
|
|
|
|
|
|
|
namespace OT {
|
|
|
|
|
2016-08-25 11:06:41 +02:00
|
|
|
|
|
|
|
struct MathValueRecord
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_x_value (hb_font_t *font, const void *base) const
|
2016-09-26 12:15:59 +02:00
|
|
|
{ return font->em_scale_x (value) + (base+deviceTable).get_x_delta (font); }
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_y_value (hb_font_t *font, const void *base) const
|
2016-09-26 12:15:59 +02:00
|
|
|
{ return font->em_scale_y (value) + (base+deviceTable).get_y_delta (font); }
|
2016-08-25 11:06:41 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
2016-08-25 11:06:41 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) && deviceTable.sanitize (c, base));
|
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
HBINT16 value; /* The X or Y value in design units */
|
2016-09-26 12:47:05 +02:00
|
|
|
OffsetTo<Device> deviceTable; /* Offset to the device table - from the
|
2018-10-13 12:30:05 +02:00
|
|
|
* beginning of parent table. May be NULL.
|
2016-09-26 12:47:05 +02:00
|
|
|
* Suggested format for device table is 1. */
|
2016-08-25 11:06:41 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:15:59 +02:00
|
|
|
DEFINE_SIZE_STATIC (4);
|
2016-08-25 11:06:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathConstants
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_math_value_records (hb_sanitize_context_t *c) const
|
2016-08-25 11:06:41 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
2016-09-26 12:47:05 +02:00
|
|
|
|
2016-09-26 12:24:39 +02:00
|
|
|
unsigned int count = ARRAY_LENGTH (mathValueRecords);
|
2016-08-25 11:06:41 +02:00
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2016-09-26 12:47:05 +02:00
|
|
|
if (!mathValueRecords[i].sanitize (c, this))
|
|
|
|
return_trace (false);
|
|
|
|
|
2016-08-25 11:06:41 +02:00
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:06:41 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
2018-11-15 20:40:49 +01:00
|
|
|
return_trace (c->check_struct (this) && sanitize_math_value_records (c));
|
2016-08-25 11:06:41 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_value (hb_ot_math_constant_t constant,
|
2016-09-26 12:56:40 +02:00
|
|
|
hb_font_t *font) const
|
2016-08-25 11:06:41 +02:00
|
|
|
{
|
|
|
|
switch (constant) {
|
2016-09-26 12:24:39 +02:00
|
|
|
|
|
|
|
case HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN:
|
|
|
|
return percentScaleDown[constant - HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN];
|
|
|
|
|
2016-08-25 11:06:41 +02:00
|
|
|
case HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT:
|
|
|
|
case HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT:
|
|
|
|
return font->em_scale_y (minHeight[constant - HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT]);
|
|
|
|
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE:
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE:
|
|
|
|
case HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT:
|
2018-11-15 20:40:49 +01:00
|
|
|
return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_x_value (font, this);
|
2016-08-25 11:06:41 +02:00
|
|
|
|
|
|
|
case HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT:
|
|
|
|
case HB_OT_MATH_CONSTANT_AXIS_HEIGHT:
|
|
|
|
case HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS:
|
|
|
|
case HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_MATH_LEADING:
|
|
|
|
case HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER:
|
|
|
|
case HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS:
|
|
|
|
case HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER:
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS:
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP:
|
|
|
|
case HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED:
|
|
|
|
case HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER:
|
|
|
|
case HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS:
|
|
|
|
case HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP:
|
|
|
|
case HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN:
|
|
|
|
case HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN:
|
2018-11-15 20:40:49 +01:00
|
|
|
return mathValueRecords[constant - HB_OT_MATH_CONSTANT_MATH_LEADING].get_y_value (font, this);
|
2016-08-25 11:06:41 +02:00
|
|
|
|
|
|
|
case HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT:
|
|
|
|
return radicalDegreeBottomRaisePercent;
|
2016-09-26 12:24:39 +02:00
|
|
|
|
2016-09-26 12:15:59 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
2016-08-25 11:06:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 percentScaleDown[2];
|
|
|
|
HBUINT16 minHeight[2];
|
2016-09-26 12:24:39 +02:00
|
|
|
MathValueRecord mathValueRecords[51];
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 radicalDegreeBottomRaisePercent;
|
2016-08-25 11:06:41 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:24:39 +02:00
|
|
|
DEFINE_SIZE_STATIC (214);
|
2016-08-25 11:06:41 +02:00
|
|
|
};
|
|
|
|
|
2016-08-25 11:15:31 +02:00
|
|
|
struct MathItalicsCorrectionInfo
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
coverage.sanitize (c, this) &&
|
|
|
|
italicsCorrection.sanitize (c, this));
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_value (hb_codepoint_t glyph,
|
|
|
|
hb_font_t *font) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
unsigned int index = (this+coverage).get_coverage (glyph);
|
2016-09-26 13:12:41 +02:00
|
|
|
return italicsCorrection[index].get_x_value (font, this);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2016-09-26 12:47:05 +02:00
|
|
|
OffsetTo<Coverage> coverage; /* Offset to Coverage table -
|
|
|
|
* from the beginning of
|
|
|
|
* MathItalicsCorrectionInfo
|
|
|
|
* table. */
|
|
|
|
ArrayOf<MathValueRecord> italicsCorrection; /* Array of MathValueRecords
|
|
|
|
* defining italics correction
|
|
|
|
* values for each
|
|
|
|
* covered glyph. */
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:47:05 +02:00
|
|
|
DEFINE_SIZE_ARRAY (4, italicsCorrection);
|
2016-08-25 11:15:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathTopAccentAttachment
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
topAccentCoverage.sanitize (c, this) &&
|
|
|
|
topAccentAttachment.sanitize (c, this));
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_value (hb_codepoint_t glyph,
|
|
|
|
hb_font_t *font) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
unsigned int index = (this+topAccentCoverage).get_coverage (glyph);
|
2016-09-26 13:18:32 +02:00
|
|
|
if (index == NOT_COVERED)
|
|
|
|
return font->get_glyph_h_advance (glyph) / 2;
|
2018-11-15 20:40:49 +01:00
|
|
|
return topAccentAttachment[index].get_x_value (font, this);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2016-08-25 11:15:31 +02:00
|
|
|
OffsetTo<Coverage> topAccentCoverage; /* Offset to Coverage table -
|
2016-09-26 12:47:05 +02:00
|
|
|
* from the beginning of
|
|
|
|
* MathTopAccentAttachment
|
|
|
|
* table. */
|
2016-08-25 11:15:31 +02:00
|
|
|
ArrayOf<MathValueRecord> topAccentAttachment; /* Array of MathValueRecords
|
2016-09-26 12:47:05 +02:00
|
|
|
* defining top accent
|
|
|
|
* attachment points for each
|
|
|
|
* covered glyph. */
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-08-25 11:15:31 +02:00
|
|
|
DEFINE_SIZE_ARRAY (2 + 2, topAccentAttachment);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MathKern
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_math_value_records (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
unsigned int count = 2 * heightCount + 1;
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2018-09-10 23:29:26 +02:00
|
|
|
if (!mathValueRecordsZ.arrayZ[i].sanitize (c, this)) return_trace (false);
|
2016-08-25 11:15:31 +02:00
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2018-09-10 23:29:26 +02:00
|
|
|
c->check_array (mathValueRecordsZ.arrayZ, 2 * heightCount + 1) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
sanitize_math_value_records (c));
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
2018-09-10 23:29:26 +02:00
|
|
|
const MathValueRecord* correctionHeight = mathValueRecordsZ.arrayZ;
|
|
|
|
const MathValueRecord* kernValue = mathValueRecordsZ.arrayZ + heightCount;
|
2016-09-26 14:39:58 +02:00
|
|
|
int sign = font->y_scale < 0 ? -1 : +1;
|
|
|
|
|
|
|
|
/* The description of the MathKern table is a ambiguous, but interpreting
|
|
|
|
* "between the two heights found at those indexes" for 0 < i < len as
|
|
|
|
*
|
|
|
|
* correctionHeight[i-1] < correction_height <= correctionHeight[i]
|
|
|
|
*
|
|
|
|
* makes the result consistent with the limit cases and we can just use the
|
|
|
|
* binary search algorithm of std::upper_bound:
|
|
|
|
*/
|
2016-08-25 11:15:31 +02:00
|
|
|
unsigned int i = 0;
|
2016-09-26 14:39:58 +02:00
|
|
|
unsigned int count = heightCount;
|
|
|
|
while (count > 0)
|
|
|
|
{
|
2016-08-25 11:15:31 +02:00
|
|
|
unsigned int half = count / 2;
|
2018-11-15 20:40:49 +01:00
|
|
|
hb_position_t height = correctionHeight[i + half].get_y_value (font, this);
|
2016-09-26 14:39:58 +02:00
|
|
|
if (sign * height < sign * correction_height)
|
|
|
|
{
|
2016-09-26 12:47:05 +02:00
|
|
|
i += half + 1;
|
|
|
|
count -= half + 1;
|
2016-08-25 11:15:31 +02:00
|
|
|
} else
|
2016-09-26 12:47:05 +02:00
|
|
|
count = half;
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
2018-11-15 20:40:49 +01:00
|
|
|
return kernValue[i].get_x_value (font, this);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2018-09-10 23:29:26 +02:00
|
|
|
HBUINT16 heightCount;
|
|
|
|
UnsizedArrayOf<MathValueRecord>
|
2020-04-24 21:15:17 +02:00
|
|
|
mathValueRecordsZ;
|
|
|
|
/* Array of correction heights at
|
|
|
|
* which the kern value changes.
|
|
|
|
* Sorted by the height value in
|
|
|
|
* design units (heightCount entries),
|
|
|
|
* Followed by:
|
|
|
|
* Array of kern values corresponding
|
|
|
|
* to heights. (heightCount+1 entries).
|
|
|
|
*/
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2018-09-10 23:29:26 +02:00
|
|
|
DEFINE_SIZE_ARRAY (2, mathValueRecordsZ);
|
2016-08-25 11:15:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathKernInfoRecord
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
|
2016-09-26 12:47:05 +02:00
|
|
|
unsigned int count = ARRAY_LENGTH (mathKern);
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
if (unlikely (!mathKern[i].sanitize (c, base)))
|
|
|
|
return_trace (false);
|
|
|
|
|
|
|
|
return_trace (true);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
2016-09-26 12:47:05 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_kerning (hb_ot_math_kern_t kern,
|
|
|
|
hb_position_t correction_height,
|
|
|
|
hb_font_t *font,
|
|
|
|
const void *base) const
|
2016-09-26 12:47:05 +02:00
|
|
|
{
|
|
|
|
unsigned int idx = kern;
|
2016-09-26 14:31:47 +02:00
|
|
|
if (unlikely (idx >= ARRAY_LENGTH (mathKern))) return 0;
|
|
|
|
return (base+mathKern[idx]).get_value (correction_height, font);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2016-08-25 11:15:31 +02:00
|
|
|
/* Offset to MathKern table for each corner -
|
2018-10-13 12:30:05 +02:00
|
|
|
* from the beginning of MathKernInfo table. May be NULL. */
|
2016-09-26 12:47:05 +02:00
|
|
|
OffsetTo<MathKern> mathKern[4];
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:47:05 +02:00
|
|
|
DEFINE_SIZE_STATIC (8);
|
2016-08-25 11:15:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathKernInfo
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
mathKernCoverage.sanitize (c, this) &&
|
|
|
|
mathKernInfoRecords.sanitize (c, this));
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_kerning (hb_codepoint_t glyph,
|
|
|
|
hb_ot_math_kern_t kern,
|
|
|
|
hb_position_t correction_height,
|
|
|
|
hb_font_t *font) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
unsigned int index = (this+mathKernCoverage).get_coverage (glyph);
|
2016-09-26 14:31:47 +02:00
|
|
|
return mathKernInfoRecords[index].get_kerning (kern, correction_height, font, this);
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
mathKernCoverage;
|
|
|
|
/* Offset to Coverage table -
|
|
|
|
* from the beginning of the
|
|
|
|
* MathKernInfo table. */
|
|
|
|
ArrayOf<MathKernInfoRecord>
|
|
|
|
mathKernInfoRecords;
|
|
|
|
/* Array of MathKernInfoRecords,
|
|
|
|
* per-glyph information for
|
|
|
|
* mathematical positioning
|
|
|
|
* of subscripts and
|
|
|
|
* superscripts. */
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:47:05 +02:00
|
|
|
DEFINE_SIZE_ARRAY (4, mathKernInfoRecords);
|
2016-08-25 11:15:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathGlyphInfo
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:15:31 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
mathItalicsCorrectionInfo.sanitize (c, this) &&
|
|
|
|
mathTopAccentAttachment.sanitize (c, this) &&
|
|
|
|
extendedShapeCoverage.sanitize (c, this) &&
|
2018-11-15 20:40:49 +01:00
|
|
|
mathKernInfo.sanitize (c, this));
|
2016-08-25 11:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t
|
2016-09-26 13:18:32 +02:00
|
|
|
get_italics_correction (hb_codepoint_t glyph, hb_font_t *font) const
|
|
|
|
{ return (this+mathItalicsCorrectionInfo).get_value (glyph, font); }
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t
|
2016-09-26 13:18:32 +02:00
|
|
|
get_top_accent_attachment (hb_codepoint_t glyph, hb_font_t *font) const
|
|
|
|
{ return (this+mathTopAccentAttachment).get_value (glyph, font); }
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool is_extended_shape (hb_codepoint_t glyph) const
|
2016-09-26 13:18:32 +02:00
|
|
|
{ return (this+extendedShapeCoverage).get_coverage (glyph) != NOT_COVERED; }
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_kerning (hb_codepoint_t glyph,
|
|
|
|
hb_ot_math_kern_t kern,
|
|
|
|
hb_position_t correction_height,
|
|
|
|
hb_font_t *font) const
|
2016-09-26 14:31:47 +02:00
|
|
|
{ return (this+mathKernInfo).get_kerning (glyph, kern, correction_height, font); }
|
2016-08-25 11:15:31 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2016-08-25 11:15:31 +02:00
|
|
|
/* Offset to MathItalicsCorrectionInfo table -
|
2016-09-26 12:47:05 +02:00
|
|
|
* from the beginning of MathGlyphInfo table. */
|
2016-08-25 11:15:31 +02:00
|
|
|
OffsetTo<MathItalicsCorrectionInfo> mathItalicsCorrectionInfo;
|
|
|
|
|
|
|
|
/* Offset to MathTopAccentAttachment table -
|
2016-09-26 12:47:05 +02:00
|
|
|
* from the beginning of MathGlyphInfo table. */
|
2016-08-25 11:15:31 +02:00
|
|
|
OffsetTo<MathTopAccentAttachment> mathTopAccentAttachment;
|
|
|
|
|
|
|
|
/* Offset to coverage table for Extended Shape glyphs -
|
2016-09-26 12:47:05 +02:00
|
|
|
* from the beginning of MathGlyphInfo table. When the left or right glyph of
|
|
|
|
* a box is an extended shape variant, the (ink) box (and not the default
|
|
|
|
* position defined by values in MathConstants table) should be used for
|
2018-10-13 12:30:05 +02:00
|
|
|
* vertical positioning purposes. May be NULL.. */
|
2016-08-25 11:15:31 +02:00
|
|
|
OffsetTo<Coverage> extendedShapeCoverage;
|
|
|
|
|
|
|
|
/* Offset to MathKernInfo table -
|
2016-09-26 12:47:05 +02:00
|
|
|
* from the beginning of MathGlyphInfo table. */
|
2016-08-25 11:15:31 +02:00
|
|
|
OffsetTo<MathKernInfo> mathKernInfo;
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 12:47:05 +02:00
|
|
|
DEFINE_SIZE_STATIC (8);
|
2016-08-25 11:15:31 +02:00
|
|
|
};
|
|
|
|
|
2016-08-25 11:17:50 +02:00
|
|
|
struct MathGlyphVariantRecord
|
|
|
|
{
|
2016-09-26 21:22:48 +02:00
|
|
|
friend struct MathGlyphConstruction;
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this));
|
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2019-09-14 08:06:29 +02:00
|
|
|
HBGlyphID variantGlyph; /* Glyph ID for the variant. */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 advanceMeasurement; /* Advance width/height, in design units, of the
|
2018-11-15 20:40:49 +01:00
|
|
|
* variant, in the direction of requested
|
|
|
|
* glyph extension. */
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 17:10:08 +02:00
|
|
|
DEFINE_SIZE_STATIC (4);
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
2018-01-10 03:07:30 +01:00
|
|
|
struct PartFlags : HBUINT16
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
enum Flags {
|
2016-09-26 21:46:05 +02:00
|
|
|
Extender = 0x0001u, /* If set, the part can be skipped or repeated. */
|
|
|
|
|
|
|
|
Defined = 0x0001u, /* All defined flags. */
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-08-25 11:17:50 +02:00
|
|
|
DEFINE_SIZE_STATIC (2);
|
|
|
|
};
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
struct MathGlyphPartRecord
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this));
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void extract (hb_ot_math_glyph_part_t &out,
|
2019-07-05 22:56:45 +02:00
|
|
|
int64_t mult,
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_font_t *font) const
|
2016-09-26 21:46:05 +02:00
|
|
|
{
|
|
|
|
out.glyph = glyph;
|
|
|
|
|
2019-07-05 22:56:45 +02:00
|
|
|
out.start_connector_length = font->em_mult (startConnectorLength, mult);
|
|
|
|
out.end_connector_length = font->em_mult (endConnectorLength, mult);
|
|
|
|
out.full_advance = font->em_mult (fullAdvance, mult);
|
2016-09-26 21:46:05 +02:00
|
|
|
|
2019-05-30 17:26:17 +02:00
|
|
|
static_assert ((unsigned int) HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER ==
|
2018-09-16 19:33:48 +02:00
|
|
|
(unsigned int) PartFlags::Extender, "");
|
2016-09-26 21:46:05 +02:00
|
|
|
|
2016-09-27 16:44:22 +02:00
|
|
|
out.flags = (hb_ot_math_glyph_part_flags_t)
|
2016-09-26 21:46:05 +02:00
|
|
|
(unsigned int)
|
|
|
|
(partFlags & PartFlags::Defined);
|
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
HBGlyphID glyph; /* Glyph ID for the part. */
|
|
|
|
HBUINT16 startConnectorLength;
|
|
|
|
/* Advance width/ height of the straight bar
|
|
|
|
* connector material, in design units, is at
|
|
|
|
* the beginning of the glyph, in the
|
|
|
|
* direction of the extension. */
|
|
|
|
HBUINT16 endConnectorLength;
|
|
|
|
/* Advance width/ height of the straight bar
|
|
|
|
* connector material, in design units, is at
|
|
|
|
* the end of the glyph, in the direction of
|
|
|
|
* the extension. */
|
|
|
|
HBUINT16 fullAdvance; /* Full advance width/height for this part,
|
|
|
|
* in the direction of the extension.
|
|
|
|
* In design units. */
|
|
|
|
PartFlags partFlags; /* Part qualifiers. */
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 17:10:08 +02:00
|
|
|
DEFINE_SIZE_STATIC (10);
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
struct MathGlyphAssembly
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2018-11-15 20:40:49 +01:00
|
|
|
italicsCorrection.sanitize (c, this) &&
|
|
|
|
partRecords.sanitize (c));
|
2016-08-25 11:17:50 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
unsigned int get_parts (hb_direction_t direction,
|
|
|
|
hb_font_t *font,
|
|
|
|
unsigned int start_offset,
|
|
|
|
unsigned int *parts_count, /* IN/OUT */
|
|
|
|
hb_ot_math_glyph_part_t *parts /* OUT */,
|
|
|
|
hb_position_t *italics_correction /* OUT */) const
|
2016-09-26 21:46:05 +02:00
|
|
|
{
|
|
|
|
if (parts_count)
|
|
|
|
{
|
2019-07-05 22:56:45 +02:00
|
|
|
int64_t mult = font->dir_mult (direction);
|
2020-06-19 22:01:46 +02:00
|
|
|
+ hb_zip (partRecords.sub_array (start_offset, parts_count), hb_array (parts, *parts_count))
|
|
|
|
| hb_apply ([&] (hb_pair_t<const MathGlyphPartRecord &, hb_ot_math_glyph_part_t &> _)
|
|
|
|
{ _.first.extract (_.second, mult, font); })
|
|
|
|
;
|
2016-09-26 21:46:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (italics_correction)
|
|
|
|
*italics_correction = italicsCorrection.get_x_value (font, this);
|
|
|
|
|
|
|
|
return partRecords.len;
|
|
|
|
}
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
MathValueRecord
|
|
|
|
italicsCorrection;
|
|
|
|
/* Italics correction of this
|
|
|
|
* MathGlyphAssembly. Should not
|
|
|
|
* depend on the assembly size. */
|
|
|
|
ArrayOf<MathGlyphPartRecord>
|
|
|
|
partRecords; /* Array of part records, from
|
|
|
|
* left to right and bottom to
|
|
|
|
* top. */
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 17:10:08 +02:00
|
|
|
DEFINE_SIZE_ARRAY (6, partRecords);
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathGlyphConstruction
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
2018-11-15 20:40:49 +01:00
|
|
|
glyphAssembly.sanitize (c, this) &&
|
|
|
|
mathGlyphVariantRecord.sanitize (c));
|
2016-08-25 11:17:50 +02:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const MathGlyphAssembly &get_assembly () const { return this+glyphAssembly; }
|
2016-09-26 21:46:05 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
unsigned int get_variants (hb_direction_t direction,
|
|
|
|
hb_font_t *font,
|
|
|
|
unsigned int start_offset,
|
|
|
|
unsigned int *variants_count, /* IN/OUT */
|
|
|
|
hb_ot_math_glyph_variant_t *variants /* OUT */) const
|
2016-09-26 21:22:48 +02:00
|
|
|
{
|
|
|
|
if (variants_count)
|
|
|
|
{
|
2019-07-05 22:56:45 +02:00
|
|
|
int64_t mult = font->dir_mult (direction);
|
2020-06-19 22:01:46 +02:00
|
|
|
+ hb_zip (mathGlyphVariantRecord.sub_array (start_offset, variants_count),
|
|
|
|
hb_array (variants, *variants_count))
|
|
|
|
| hb_apply ([&] (hb_pair_t<const MathGlyphVariantRecord &, hb_ot_math_glyph_variant_t &> _)
|
|
|
|
{ _.second = {_.first.variantGlyph, font->em_mult (_.first.advanceMeasurement, mult)}; })
|
|
|
|
;
|
2016-09-26 21:22:48 +02:00
|
|
|
}
|
|
|
|
return mathGlyphVariantRecord.len;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* Offset to MathGlyphAssembly table for this shape - from the beginning of
|
2018-10-13 12:30:05 +02:00
|
|
|
MathGlyphConstruction table. May be NULL. */
|
2016-09-26 21:22:48 +02:00
|
|
|
OffsetTo<MathGlyphAssembly> glyphAssembly;
|
2016-08-25 11:17:50 +02:00
|
|
|
|
|
|
|
/* MathGlyphVariantRecords for alternative variants of the glyphs. */
|
|
|
|
ArrayOf<MathGlyphVariantRecord> mathGlyphVariantRecord;
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 17:10:08 +02:00
|
|
|
DEFINE_SIZE_ARRAY (4, mathGlyphVariantRecord);
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MathVariants
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_offsets (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
unsigned int count = vertGlyphCount + horizGlyphCount;
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2018-09-10 23:29:26 +02:00
|
|
|
if (!glyphConstruction.arrayZ[i].sanitize (c, this)) return_trace (false);
|
2016-08-25 11:17:50 +02:00
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 11:17:50 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
vertGlyphCoverage.sanitize (c, this) &&
|
|
|
|
horizGlyphCoverage.sanitize (c, this) &&
|
2018-09-10 23:29:26 +02:00
|
|
|
c->check_array (glyphConstruction.arrayZ, vertGlyphCount + horizGlyphCount) &&
|
2016-08-25 11:17:50 +02:00
|
|
|
sanitize_offsets (c));
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_min_connector_overlap (hb_direction_t direction,
|
2016-09-26 18:51:47 +02:00
|
|
|
hb_font_t *font) const
|
|
|
|
{ return font->em_scale_dir (minConnectorOverlap, direction); }
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
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_ot_math_glyph_variant_t *variants /* OUT */) const
|
2016-09-26 21:22:48 +02:00
|
|
|
{ return get_glyph_construction (glyph, direction, font)
|
|
|
|
.get_variants (direction, font, start_offset, variants_count, variants); }
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
unsigned int get_glyph_parts (hb_codepoint_t glyph,
|
2016-09-26 21:46:05 +02:00
|
|
|
hb_direction_t direction,
|
|
|
|
hb_font_t *font,
|
|
|
|
unsigned int start_offset,
|
|
|
|
unsigned int *parts_count, /* IN/OUT */
|
2016-09-27 16:44:22 +02:00
|
|
|
hb_ot_math_glyph_part_t *parts /* OUT */,
|
2016-09-26 21:46:05 +02:00
|
|
|
hb_position_t *italics_correction /* OUT */) const
|
|
|
|
{ return get_glyph_construction (glyph, direction, font)
|
|
|
|
.get_assembly ()
|
|
|
|
.get_parts (direction, font,
|
|
|
|
start_offset, parts_count, parts,
|
|
|
|
italics_correction); }
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
private:
|
2018-12-16 20:08:10 +01:00
|
|
|
const MathGlyphConstruction &
|
|
|
|
get_glyph_construction (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_font_t *font HB_UNUSED) const
|
2016-09-26 21:22:48 +02:00
|
|
|
{
|
|
|
|
bool vertical = HB_DIRECTION_IS_VERTICAL (direction);
|
|
|
|
unsigned int count = vertical ? vertGlyphCount : horizGlyphCount;
|
|
|
|
const OffsetTo<Coverage> &coverage = vertical ? vertGlyphCoverage
|
|
|
|
: horizGlyphCoverage;
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
unsigned int index = (this+coverage).get_coverage (glyph);
|
2018-11-15 20:40:49 +01:00
|
|
|
if (unlikely (index >= count)) return Null (MathGlyphConstruction);
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
if (!vertical)
|
2016-08-25 11:17:50 +02:00
|
|
|
index += vertGlyphCount;
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
return this+glyphConstruction[index];
|
2016-08-25 11:17:50 +02:00
|
|
|
}
|
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
HBUINT16 minConnectorOverlap;
|
|
|
|
/* Minimum overlap of connecting
|
|
|
|
* glyphs during glyph construction,
|
|
|
|
* in design units. */
|
|
|
|
OffsetTo<Coverage> vertGlyphCoverage;
|
|
|
|
/* Offset to Coverage table -
|
|
|
|
* from the beginning of MathVariants
|
|
|
|
* table. */
|
|
|
|
OffsetTo<Coverage> horizGlyphCoverage;
|
|
|
|
/* Offset to Coverage table -
|
|
|
|
* from the beginning of MathVariants
|
|
|
|
* table. */
|
|
|
|
HBUINT16 vertGlyphCount; /* Number of glyphs for which
|
|
|
|
* information is provided for
|
|
|
|
* vertically growing variants. */
|
|
|
|
HBUINT16 horizGlyphCount;/* Number of glyphs for which
|
|
|
|
* information is provided for
|
|
|
|
* horizontally growing variants. */
|
2016-08-25 11:17:50 +02:00
|
|
|
|
|
|
|
/* Array of offsets to MathGlyphConstruction tables - from the beginning of
|
|
|
|
the MathVariants table, for shapes growing in vertical/horizontal
|
|
|
|
direction. */
|
2019-04-30 22:05:10 +02:00
|
|
|
UnsizedArrayOf<OffsetTo<MathGlyphConstruction>>
|
2019-12-31 13:23:02 +01:00
|
|
|
glyphConstruction;
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-09-26 17:10:08 +02:00
|
|
|
DEFINE_SIZE_ARRAY (10, glyphConstruction);
|
2016-08-25 11:17:50 +02:00
|
|
|
};
|
|
|
|
|
2016-09-26 12:47:05 +02:00
|
|
|
|
2016-08-25 10:47:15 +02:00
|
|
|
/*
|
2018-04-12 11:08:19 +02:00
|
|
|
* MATH -- Mathematical typesetting
|
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/math
|
2016-08-25 10:47:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct MATH
|
|
|
|
{
|
2019-01-22 12:08:57 +01:00
|
|
|
static constexpr hb_tag_t tableTag = HB_OT_TAG_MATH;
|
2016-08-25 10:47:15 +02:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
bool has_data () const { return version.to_int (); }
|
2018-08-06 15:30:12 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2016-08-25 10:47:15 +02:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (version.sanitize (c) &&
|
2016-09-26 12:47:05 +02:00
|
|
|
likely (version.major == 1) &&
|
|
|
|
mathConstants.sanitize (c, this) &&
|
2016-08-25 11:17:50 +02:00
|
|
|
mathGlyphInfo.sanitize (c, this) &&
|
|
|
|
mathVariants.sanitize (c, this));
|
2016-08-25 11:06:41 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_constant (hb_ot_math_constant_t constant,
|
2016-08-25 11:17:50 +02:00
|
|
|
hb_font_t *font) const
|
2016-09-26 12:56:40 +02:00
|
|
|
{ return (this+mathConstants).get_value (constant, font); }
|
2016-08-25 10:47:15 +02:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const MathGlyphInfo &get_glyph_info () const { return this+mathGlyphInfo; }
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const MathVariants &get_variants () const { return this+mathVariants; }
|
2016-08-25 11:17:50 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
protected:
|
2020-04-24 21:15:17 +02:00
|
|
|
FixedVersion<>version; /* Version of the MATH table
|
|
|
|
* initially set to 0x00010000u */
|
|
|
|
OffsetTo<MathConstants>
|
|
|
|
mathConstants; /* MathConstants table */
|
|
|
|
OffsetTo<MathGlyphInfo>
|
|
|
|
mathGlyphInfo; /* MathGlyphInfo table */
|
|
|
|
OffsetTo<MathVariants>
|
|
|
|
mathVariants; /* MathVariants table */
|
2016-08-25 11:06:41 +02:00
|
|
|
|
2016-09-26 21:22:48 +02:00
|
|
|
public:
|
2016-08-25 11:17:50 +02:00
|
|
|
DEFINE_SIZE_STATIC (10);
|
2016-08-25 10:47:15 +02:00
|
|
|
};
|
|
|
|
|
2017-01-10 00:49:08 +01:00
|
|
|
} /* namespace OT */
|
2016-08-25 10:47:15 +02:00
|
|
|
|
|
|
|
|
2017-01-10 06:11:00 +01:00
|
|
|
#endif /* HB_OT_MATH_TABLE_HH */
|