From a6da9b9415bae43c58f12a8e43b77ba31dd432a6 Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Fri, 16 Nov 2018 17:29:03 -0800 Subject: [PATCH] fixed Charset format selection --- src/hb-subset-cff1.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 459da5c46..2ffbdc91c 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -335,15 +335,19 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet struct RangeList : hb_vector_t { /* replace the first glyph ID in the "glyph" field each range with a nLeft value */ - inline void finalize (unsigned int last_glyph) + inline bool finalize (unsigned int last_glyph) { + bool two_byte = false; for (unsigned int i = (*this).len; i > 0; i--) { code_pair &pair = (*this)[i - 1]; unsigned int nLeft = last_glyph - pair.glyph - 1; + if (nLeft >= 0x100) + two_byte = true; last_glyph = pair.glyph; pair.glyph = nLeft; } + return two_byte; } }; @@ -529,7 +533,6 @@ struct cff_subset_plan { { unsigned int size0, size_ranges; hb_codepoint_t sid, last_sid = CFF_UNDEF_CODE; - bool two_byte = false; subset_charset_ranges.resize (0); unsigned int glyph; @@ -549,7 +552,7 @@ struct cff_subset_plan { last_sid = sid; } - subset_charset_ranges.finalize (glyph); + bool two_byte = subset_charset_ranges.finalize (glyph); size0 = Charset0::min_size + HBUINT16::static_size * (plan->glyphs.len - 1); if (!two_byte)