From 625678436c29100eef82d87e635b251030a18f60 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 5 Aug 2013 22:44:18 -0400 Subject: [PATCH] Fix glyph closure with class==0 As reported by cibu. Untested. --- src/hb-ot-layout-common-private.hh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 5196e60ac..86224a15e 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -955,6 +955,19 @@ struct ClassDefFormat1 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { unsigned int count = classValue.len; + if (klass == 0) + { + /* Match if there's any glyph that is not listed! */ + hb_codepoint_t g = -1; + if (!hb_set_next (glyphs, &g)) + return false; + if (g < startGlyph) + return true; + g = startGlyph + count - 1; + if (hb_set_next (glyphs, &g)) + return true; + /* Fall through. */ + } for (unsigned int i = 0; i < count; i++) if (classValue[i] == klass && glyphs->has (startGlyph + i)) return true; @@ -998,6 +1011,22 @@ struct ClassDefFormat2 inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const { unsigned int count = rangeRecord.len; + if (klass == 0) + { + /* Match if there's any glyph that is not listed! */ + hb_codepoint_t g = -1; + for (unsigned int i = 0; i < count; i++) + { + if (!hb_set_next (glyphs, &g)) + break; + if (g < rangeRecord[i].start) + return true; + g = rangeRecord[i].end; + } + if (g != -1 && hb_set_next (glyphs, &g)) + return true; + /* Fall through. */ + } for (unsigned int i = 0; i < count; i++) if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs)) return true;