From 60485ab0473630c585bb96fcdc14dbe415edf4f2 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 7 Aug 2019 23:23:06 +0430 Subject: [PATCH] [os2] Get defined lower/upper optical size --- src/hb-ot-os2-table.hh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index 67f21eb34..9868bbff9 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -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);