protected:
Offset32To<DeltaSetIndexMap> varIdxMap; /* Offset from the beginning of 'avar' table. */
Offset32To<ItemVariationStore> varStore; /* Offset from the beginning of 'avar' table. */
int a_from = a->coords[0].to_int (); int b_from = b->coords[0].to_int (); if (a_from != b_from) return a_from - b_from;
/* this should never be reached. according to the spec, all of the axis *valuemaprecordsforagivenaxismusthavedifferentfromCoordvalues
* */ int a_to = a->coords[1].to_int (); int b_to = b->coords[1].to_int (); return a_to - b_to;
}
/* The following special-cases are not part of OpenType, which requires *thatatleast-1,0,and+1mustbemapped.Butweincludetheseas
* part of a better error recovery scheme. */ if (len < 2)
{ if (!len) return value; else/* len == 1*/ return value - map[0].fromCoord + map[0].toCoord;
}
// At least two mappings now.
/* CoreText is wild... *PingFangUIavarneedsallthisspecial-casing... *Soweimplementanextendedversionofthespechere, *whichismorerobustandmorelikelytobecompatiblewith
* the wild. */
/* Look for exact match first, and do lots of special-casing. */ unsigned i; for (i = start; i < end; i++) if (value == map[i].fromCoord) break; if (i < end)
{ // There's at least one exact match. See if there are more. unsigned j = i; for (; j + 1 < end; j++) if (value != map[j + 1].fromCoord) break;
// [i,j] inclusive are all exact matches:
// If there's only one, return it. This is the only spec-compliant case. if (i == j) return map[i].toCoord; // If there's exactly three, return the middle one. if (i + 2 == j) return map[i + 1].toCoord;
// Ignore the middle ones. Return the one mapping closer to 0. if (value < 0) return map[j].toCoord; if (value > 0) return map[i].toCoord;
// Mapping 0? CoreText seems confused. It seems to prefer 0 here... // So we'll just return the smallest one. lol return fabsf (map[i].toCoord) < fabsf (map[j].toCoord) ? map[i].toCoord : map[j].toCoord;
// Mapping 0? Return one not mapping to 0. if (map[i].toCoord == 0) return map[j].toCoord; else return map[i].toCoord;
}
/* There's at least two and we're not an exact match. Prepare to lerp. */
// Find the segment we're in. for (i = start; i < end; i++) if (value < map[i].fromCoord) break;
if (i == 0)
{ // Value before all segments; Shift. return value - map[0].fromCoord + map[0].toCoord;
} if (i == end)
{ // Value after all segments; Shift. return value - map[end - 1].fromCoord + map[end - 1].toCoord;
}
// Actually interpolate. auto &before = map[i-1]; auto &after = map[i]; float denom = after.fromCoord - before.fromCoord; // Can't be zero by now. return before.toCoord + ((after.toCoord - before.toCoord) * (value - before.fromCoord)) / denom;
/* This function cannot work on avar2 table (and currently doesn't). *Weshouldinsteadkeepthedesigncoordsintheshapeplananduse
* those. unmap_axis_range needs to be killed. */
// axis normalization is done in 2.14 here // TODO: deprecate this API once fonttools is updated to use 16.16 normalization bool map_coords_2_14 (float *coords, unsignedint coords_length) const
{
hb_vector_t<int> coords_2_14; if (!coords_2_14.resize (coords_length)) returnfalse; unsignedint count = hb_min (coords_length, axisCount);
const SegmentMaps *map = &firstAxisSegmentMaps; for (unsignedint i = 0; i < count; i++)
{ int v = roundf (map->map_float (coords[i]) * 16384.f);
coords_2_14[i] = v;
coords[i] = v / 16384.f;
map = &StructAfter<SegmentMaps> (*map);
}
#ifndef HB_NO_AVAR2 if (version.major < 2) returntrue;
hb_barrier ();
for (; count < axisCount; count++)
map = &StructAfter<SegmentMaps> (*map);
const hb_map_t& axes_index_map = c->plan->axes_index_map; const SegmentMaps *map = &firstAxisSegmentMaps; unsigned count = axisCount; for (unsignedint i = 0; i < count; i++)
{ if (axes_index_map.has (i))
{
hb_tag_t *axis_tag; if (!c->plan->axes_old_index_tag_map.has (i, &axis_tag))
return_trace (false); if (!map->subset (c, *axis_tag))
return_trace (false);
}
map = &StructAfter<SegmentMaps> (*map);
}
return_trace (true);
}
protected:
FixedVersion<>version; /* Version of the avar table
* initially set to 0x00010000u */
HBUINT16 reserved; /* This field is permanently reserved. Set to 0. */
HBUINT16 axisCount; /* The number of variation axes in the font. This *mustbethesamenumberasaxisCountinthe
* 'fvar' table. */
SegmentMaps firstAxisSegmentMaps;
public:
DEFINE_SIZE_MIN (8);
};
} /* namespace OT */
#endif/* HB_OT_VAR_AVAR_TABLE_HH */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.