summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh69
1 files changed, 47 insertions, 22 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh b/src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh
index 5b017d56a6..97d18b9d75 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh
+++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-os2-table.hh
@@ -30,6 +30,7 @@
#include "hb-open-type.hh"
#include "hb-ot-os2-unicode-ranges.hh"
+#include "hb-ot-var-mvar-table.hh"
#include "hb-set.hh"
@@ -62,6 +63,7 @@ struct OS2V2Tail
bool has_data () const { return sxHeight || sCapHeight; }
const OS2V2Tail * operator -> () const { return this; }
+ OS2V2Tail * operator -> () { return this; }
bool sanitize (hb_sanitize_context_t *c) const
{
@@ -213,20 +215,51 @@ struct OS2
OS2 *os2_prime = c->serializer->embed (this);
if (unlikely (!os2_prime)) return_trace (false);
- if (c->plan->user_axes_location->has (HB_TAG ('w','g','h','t')) &&
+#ifndef HB_NO_VAR
+ if (c->plan->normalized_coords)
+ {
+ auto &MVAR = *c->plan->source->table.MVAR;
+ auto *table = os2_prime;
+
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, sTypoAscender);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, sTypoDescender);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP, sTypoLineGap);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT, usWinAscent);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_DESCENT, usWinDescent);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_SIZE, ySubscriptXSize);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE, ySubscriptYSize);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_OFFSET, ySubscriptXOffset);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET, ySubscriptYOffset);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_SIZE, ySuperscriptXSize);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE, ySuperscriptYSize);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET, ySuperscriptXOffset);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_OFFSET, ySuperscriptYOffset);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_STRIKEOUT_SIZE, yStrikeoutSize);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, yStrikeoutPosition);
+
+ if (os2_prime->version >= 2)
+ {
+ auto *table = & const_cast<OS2V2Tail &> (os2_prime->v2 ());
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_X_HEIGHT, sxHeight);
+ HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_CAP_HEIGHT, sCapHeight);
+ }
+ }
+#endif
+
+ if (c->plan->user_axes_location.has (HB_TAG ('w','g','h','t')) &&
!c->plan->pinned_at_default)
{
- float weight_class = c->plan->user_axes_location->get (HB_TAG ('w','g','h','t'));
+ float weight_class = c->plan->user_axes_location.get (HB_TAG ('w','g','h','t'));
if (!c->serializer->check_assign (os2_prime->usWeightClass,
roundf (hb_clamp (weight_class, 1.0f, 1000.0f)),
HB_SERIALIZE_ERROR_INT_OVERFLOW))
return_trace (false);
}
- if (c->plan->user_axes_location->has (HB_TAG ('w','d','t','h')) &&
+ if (c->plan->user_axes_location.has (HB_TAG ('w','d','t','h')) &&
!c->plan->pinned_at_default)
{
- float width = c->plan->user_axes_location->get (HB_TAG ('w','d','t','h'));
+ float width = c->plan->user_axes_location.get (HB_TAG ('w','d','t','h'));
if (!c->serializer->check_assign (os2_prime->usWidthClass,
roundf (map_wdth_to_widthclass (width)),
HB_SERIALIZE_ERROR_INT_OVERFLOW))
@@ -236,14 +269,10 @@ struct OS2
if (c->plan->flags & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES)
return_trace (true);
- /* when --gids option is not used, no need to do collect_mapping that is
- * iterating all codepoints in each subtable, which is not efficient */
- uint16_t min_cp, max_cp;
- find_min_and_max_codepoint (c->plan->unicodes, &min_cp, &max_cp);
- os2_prime->usFirstCharIndex = min_cp;
- os2_prime->usLastCharIndex = max_cp;
+ os2_prime->usFirstCharIndex = hb_min (0xFFFFu, c->plan->unicodes.get_min ());
+ os2_prime->usLastCharIndex = hb_min (0xFFFFu, c->plan->unicodes.get_max ());
- _update_unicode_ranges (c->plan->unicodes, os2_prime->ulUnicodeRange);
+ _update_unicode_ranges (&c->plan->unicodes, os2_prime->ulUnicodeRange);
return_trace (true);
}
@@ -251,12 +280,16 @@ struct OS2
void _update_unicode_ranges (const hb_set_t *codepoints,
HBUINT32 ulUnicodeRange[4]) const
{
- HBUINT32 newBits[4];
+ HBUINT32 newBits[4];
for (unsigned int i = 0; i < 4; i++)
newBits[i] = 0;
- hb_codepoint_t cp = HB_SET_VALUE_INVALID;
- while (codepoints->next (&cp)) {
+ /* This block doesn't show up in profiles. If it ever did,
+ * we can rewrite it to iterate over OS/2 ranges and use
+ * set iteration to check if the range matches. */
+ for (hb_codepoint_t cp = HB_SET_VALUE_INVALID;
+ codepoints->next (&cp);)
+ {
unsigned int bit = _hb_ot_os2_get_unicode_range_bit (cp);
if (bit < 128)
{
@@ -278,14 +311,6 @@ struct OS2
ulUnicodeRange[i] = ulUnicodeRange[i] & newBits[i]; // set bits only if set in the original
}
- static void find_min_and_max_codepoint (const hb_set_t *codepoints,
- uint16_t *min_cp, /* OUT */
- uint16_t *max_cp /* OUT */)
- {
- *min_cp = hb_min (0xFFFFu, codepoints->get_min ());
- *max_cp = hb_min (0xFFFFu, codepoints->get_max ());
- }
-
/* https://github.com/Microsoft/Font-Validator/blob/520aaae/OTFontFileVal/val_OS2.cs#L644-L681
* https://docs.microsoft.com/en-us/typography/legacy/legacy_arabic_fonts */
enum font_page_t