float get_width () const
{ switch (usWidthClass) { case FWIDTH_ULTRA_CONDENSED:return 50.f; case FWIDTH_EXTRA_CONDENSED:return 62.5f; case FWIDTH_CONDENSED: return 75.f; case FWIDTH_SEMI_CONDENSED: return 87.5f; default: case FWIDTH_NORMAL: return 100.f; case FWIDTH_SEMI_EXPANDED: return 112.5f; case FWIDTH_EXPANDED: return 125.f; case FWIDTH_EXTRA_EXPANDED: return 150.f; case FWIDTH_ULTRA_EXPANDED: return 200.f;
}
}
float map_wdth_to_widthclass(float width) const
{ if (width < 50) return 1.0f; if (width > 200) return 9.0f;
float ratio = (width - 50) / 12.5f; int a = (int) floorf (ratio); int b = (int) ceilf (ratio);
/* follow this maping: * https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass
*/ if (b <= 6) // 50-125
{ if (a == b) return a + 1.0f;
} elseif (b == 7) // no mapping for 137.5
{
a = 6;
b = 8;
} elseif (b == 8)
{ if (a == b) return 8.0f; // 150
a = 6;
} else
{ if (a == b && a == 12) return 9.0f; //200
b = 12;
a = 8;
}
float va = 50 + a * 12.5f; float vb = 50 + b * 12.5f;
float ret = a + (width - va) / (vb - va); if (a <= 6) ret += 1.0f; return ret;
}
void _update_unicode_ranges (const hb_set_t *codepoints,
HBUINT32 ulUnicodeRange[4]) const
{
HBUINT32 newBits[4]; for (unsignedint i = 0; i < 4; i++)
newBits[i] = 0;
/* 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 (auto cp : *codepoints)
{ unsignedint bit = _hb_ot_os2_get_unicode_range_bit (cp); if (bit < 128)
{ unsignedint block = bit / 32; unsignedint bit_in_block = bit % 32; unsignedint mask = 1 << bit_in_block;
newBits[block] = newBits[block] | mask;
} if (cp >= 0x10000 && cp <= 0x110000)
{ /* the spec says that bit 57 ("Non Plane 0") implies that there's at least one codepoint beyond the BMP; so I also include all
the non-BMP codepoints here */
newBits[1] = newBits[1] | (1 << 25);
}
}
for (unsignedint i = 0; i < 4; i++)
ulUnicodeRange[i] = ulUnicodeRange[i] & newBits[i]; // set bits only if set in the original
}
/* 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
{
FONT_PAGE_NONE = 0,
FONT_PAGE_HEBREW = 0xB100, /* Hebrew Windows 3.1 font page */
FONT_PAGE_SIMP_ARABIC = 0xB200, /* Simplified Arabic Windows 3.1 font page */
FONT_PAGE_TRAD_ARABIC = 0xB300, /* Traditional Arabic Windows 3.1 font page */
FONT_PAGE_OEM_ARABIC = 0xB400, /* OEM Arabic Windows 3.1 font page */
FONT_PAGE_SIMP_FARSI = 0xBA00, /* Simplified Farsi Windows 3.1 font page */
FONT_PAGE_TRAD_FARSI = 0xBB00, /* Traditional Farsi Windows 3.1 font page */
FONT_PAGE_THAI = 0xDE00 /* Thai Windows 3.1 font page */
};
font_page_t get_font_page () const
{ return (font_page_t) (version == 0 ? fsSelection & 0xFF00 : 0); }
unsigned get_size () const
{ unsigned result = min_size; if (version >= 1) result += v1X.get_size (); if (version >= 2) result += v2X.get_size (); if (version >= 5) result += v5X.get_size (); return result;
}
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.