[os2] Get defined lower/upper optical size

This commit is contained in:
Ebrahim Byagowi 2019-08-07 23:23:06 +04:30 committed by GitHub
parent 321d5588d4
commit 60485ab047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -81,6 +81,23 @@ struct OS2V2Tail
struct OS2V5Tail
{
inline bool get_optical_size (unsigned int *lower, unsigned int *upper) const
{
unsigned int lower_optical_size = usLowerOpticalPointSize;
unsigned int upper_optical_size = usUpperOpticalPointSize;
/* Per https://docs.microsoft.com/en-us/typography/opentype/spec/os2#lps */
if (lower_optical_size < upper_optical_size &&
lower_optical_size >= 1 && lower_optical_size <= 0xFFFE &&
upper_optical_size >= 2 && upper_optical_size <= 0xFFFF)
{
*lower = lower_optical_size;
*upper = upper_optical_size;
return true;
}
return false;
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);