summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh97
1 files changed, 57 insertions, 40 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh b/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh
index 02fe14fa06..a23b6377d1 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh
+++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-base-table.hh
@@ -41,12 +41,15 @@ namespace OT {
struct BaseCoordFormat1
{
- hb_position_t get_coord () const { return coordinate; }
+ hb_position_t get_coord (hb_font_t *font, hb_direction_t direction) const
+ {
+ return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_y (coordinate) : font->em_scale_x (coordinate);
+ }
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this)));
+ return_trace (c->check_struct (this));
}
protected:
@@ -58,10 +61,10 @@ struct BaseCoordFormat1
struct BaseCoordFormat2
{
- hb_position_t get_coord () const
+ hb_position_t get_coord (hb_font_t *font, hb_direction_t direction) const
{
/* TODO */
- return coordinate;
+ return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_y (coordinate) : font->em_scale_x (coordinate);
}
bool sanitize (hb_sanitize_context_t *c) const
@@ -73,7 +76,7 @@ struct BaseCoordFormat2
protected:
HBUINT16 format; /* Format identifier--format = 2 */
FWORD coordinate; /* X or Y value, in design units */
- HBGlyphID referenceGlyph; /* Glyph ID of control glyph */
+ HBGlyphID16 referenceGlyph; /* Glyph ID of control glyph */
HBUINT16 coordPoint; /* Index of contour point on the
* reference glyph */
public:
@@ -87,9 +90,10 @@ struct BaseCoordFormat3
hb_direction_t direction) const
{
const Device &device = this+deviceTable;
- return coordinate + (HB_DIRECTION_IS_VERTICAL (direction) ?
- device.get_y_delta (font, var_store) :
- device.get_x_delta (font, var_store));
+
+ return HB_DIRECTION_IS_HORIZONTAL (direction)
+ ? font->em_scale_y (coordinate) + device.get_y_delta (font, var_store)
+ : font->em_scale_x (coordinate) + device.get_x_delta (font, var_store);
}
@@ -103,7 +107,7 @@ struct BaseCoordFormat3
protected:
HBUINT16 format; /* Format identifier--format = 3 */
FWORD coordinate; /* X or Y value, in design units */
- OffsetTo<Device>
+ Offset16To<Device>
deviceTable; /* Offset to Device table for X or
* Y value, from beginning of
* BaseCoord table (may be NULL). */
@@ -120,8 +124,8 @@ struct BaseCoord
hb_direction_t direction) const
{
switch (u.format) {
- case 1: return u.format1.get_coord ();
- case 2: return u.format2.get_coord ();
+ case 1: return u.format1.get_coord (font, direction);
+ case 2: return u.format2.get_coord (font, direction);
case 3: return u.format3.get_coord (font, var_store, direction);
default:return 0;
}
@@ -131,6 +135,7 @@ struct BaseCoord
{
TRACE_SANITIZE (this);
if (unlikely (!u.format.sanitize (c))) return_trace (false);
+ hb_barrier ();
switch (u.format) {
case 1: return_trace (u.format1.sanitize (c));
case 2: return_trace (u.format2.sanitize (c));
@@ -166,24 +171,23 @@ struct FeatMinMaxRecord
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- minCoord.sanitize (c, this) &&
- maxCoord.sanitize (c, this)));
+ minCoord.sanitize (c, base) &&
+ maxCoord.sanitize (c, base)));
}
protected:
Tag tag; /* 4-byte feature identification tag--must
* match feature tag in FeatureList */
- OffsetTo<BaseCoord>
+ Offset16To<BaseCoord>
minCoord; /* Offset to BaseCoord table that defines
* the minimum extent value, from beginning
* of MinMax table (may be NULL) */
- OffsetTo<BaseCoord>
+ Offset16To<BaseCoord>
maxCoord; /* Offset to BaseCoord table that defines
* the maximum extent value, from beginning
* of MinMax table (may be NULL) */
public:
DEFINE_SIZE_STATIC (8);
-
};
struct MinMax
@@ -212,15 +216,15 @@ struct MinMax
}
protected:
- OffsetTo<BaseCoord>
+ Offset16To<BaseCoord>
minCoord; /* Offset to BaseCoord table that defines
* minimum extent value, from the beginning
* of MinMax table (may be NULL) */
- OffsetTo<BaseCoord>
+ Offset16To<BaseCoord>
maxCoord; /* Offset to BaseCoord table that defines
* maximum extent value, from the beginning
* of MinMax table (may be NULL) */
- SortedArrayOf<FeatMinMaxRecord>
+ SortedArray16Of<FeatMinMaxRecord>
featMinMaxRecords;
/* Array of FeatMinMaxRecords, in alphabetical
* order by featureTableTag */
@@ -247,7 +251,7 @@ struct BaseValues
Index defaultIndex; /* Index number of default baseline for this
* script — equals index position of baseline tag
* in baselineTags array of the BaseTagList */
- OffsetArrayOf<BaseCoord>
+ Array16OfOffset16To<BaseCoord>
baseCoords; /* Number of BaseCoord tables defined — should equal
* baseTagCount in the BaseTagList
*
@@ -270,12 +274,12 @@ struct BaseLangSysRecord
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- minMax.sanitize (c, this)));
+ minMax.sanitize (c, base)));
}
protected:
Tag baseLangSysTag; /* 4-byte language system identification tag */
- OffsetTo<MinMax>
+ Offset16To<MinMax>
minMax; /* Offset to MinMax table, from beginning
* of BaseScript table */
public:
@@ -293,7 +297,8 @@ struct BaseScript
const BaseCoord &get_base_coord (int baseline_tag_index) const
{ return (this+baseValues).get_base_coord (baseline_tag_index); }
- bool has_data () const { return baseValues; }
+ bool has_values () const { return baseValues; }
+ bool has_min_max () const { return defaultMinMax; /* TODO What if only per-language is present? */ }
bool sanitize (hb_sanitize_context_t *c) const
{
@@ -305,13 +310,13 @@ struct BaseScript
}
protected:
- OffsetTo<BaseValues>
+ Offset16To<BaseValues>
baseValues; /* Offset to BaseValues table, from beginning
* of BaseScript table (may be NULL) */
- OffsetTo<MinMax>
+ Offset16To<MinMax>
defaultMinMax; /* Offset to MinMax table, from beginning of
* BaseScript table (may be NULL) */
- SortedArrayOf<BaseLangSysRecord>
+ SortedArray16Of<BaseLangSysRecord>
baseLangSysRecords;
/* Number of BaseLangSysRecords
* defined — may be zero (0) */
@@ -339,7 +344,7 @@ struct BaseScriptRecord
protected:
Tag baseScriptTag; /* 4-byte script identification tag */
- OffsetTo<BaseScript>
+ Offset16To<BaseScript>
baseScript; /* Offset to BaseScript table, from beginning
* of BaseScriptList */
@@ -364,7 +369,7 @@ struct BaseScriptList
}
protected:
- SortedArrayOf<BaseScriptRecord>
+ SortedArray16Of<BaseScriptRecord>
baseScriptRecords;
public:
@@ -379,12 +384,20 @@ struct Axis
const BaseCoord **coord) const
{
const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag);
- if (!base_script.has_data ()) return false;
+ if (!base_script.has_values ())
+ {
+ *coord = nullptr;
+ return false;
+ }
if (likely (coord))
{
unsigned int tag_index = 0;
- (this+baseTagList).bfind (baseline_tag, &tag_index);
+ if (!(this+baseTagList).bfind (baseline_tag, &tag_index))
+ {
+ *coord = nullptr;
+ return false;
+ }
*coord = &base_script.get_base_coord (tag_index);
}
@@ -398,7 +411,11 @@ struct Axis
const BaseCoord **max_coord) const
{
const BaseScript &base_script = (this+baseScriptList).get_base_script (script_tag);
- if (!base_script.has_data ()) return false;
+ if (!base_script.has_min_max ())
+ {
+ *min_coord = *max_coord = nullptr;
+ return false;
+ }
base_script.get_min_max (language_tag).get_min_max (feature_tag, min_coord, max_coord);
@@ -409,17 +426,17 @@ struct Axis
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
- (this+baseTagList).sanitize (c) &&
- (this+baseScriptList).sanitize (c)));
+ baseTagList.sanitize (c, this) &&
+ baseScriptList.sanitize (c, this)));
}
protected:
- OffsetTo<SortedArrayOf<Tag>>
+ Offset16To<SortedArray16Of<Tag>>
baseTagList; /* Offset to BaseTagList table, from beginning
* of Axis table (may be NULL)
* Array of 4-byte baseline identification tags — must
* be in alphabetical order */
- OffsetTo<BaseScriptList>
+ Offset16To<BaseScriptList>
baseScriptList; /* Offset to BaseScriptList table, from beginning
* of Axis table
* Array of BaseScriptRecords, in alphabetical order
@@ -457,14 +474,13 @@ struct BASE
return true;
}
- /* TODO: Expose this separately sometime? */
bool get_min_max (hb_font_t *font,
hb_direction_t direction,
hb_tag_t script_tag,
hb_tag_t language_tag,
hb_tag_t feature_tag,
hb_position_t *min,
- hb_position_t *max)
+ hb_position_t *max) const
{
const BaseCoord *min_coord, *max_coord;
if (!get_axis (direction).get_min_max (script_tag, language_tag, feature_tag,
@@ -481,6 +497,7 @@ struct BASE
{
TRACE_SANITIZE (this);
return_trace (likely (c->check_struct (this) &&
+ hb_barrier () &&
likely (version.major == 1) &&
hAxis.sanitize (c, this) &&
vAxis.sanitize (c, this) &&
@@ -489,11 +506,11 @@ struct BASE
protected:
FixedVersion<>version; /* Version of the BASE table */
- OffsetTo<Axis>hAxis; /* Offset to horizontal Axis table, from beginning
+ Offset16To<Axis>hAxis; /* Offset to horizontal Axis table, from beginning
* of BASE table (may be NULL) */
- OffsetTo<Axis>vAxis; /* Offset to vertical Axis table, from beginning
+ Offset16To<Axis>vAxis; /* Offset to vertical Axis table, from beginning
* of BASE table (may be NULL) */
- LOffsetTo<VariationStore>
+ Offset32To<VariationStore>
varStore; /* Offset to the table of Item Variation
* Store--from beginning of BASE
* header (may be NULL). Introduced