From 2e6b8b4734710377e25c199e3ff7865628e7d723 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 22 May 2012 12:29:54 +0200 Subject: Disable GSUB feature when text contains surrogates This is a work-around for a feature missing in Harfbuzz that can make a text run that contains a surrogate and a ligature crash. This will potentially cause the ligatures to break up if you combine them with a surrogate, causing visual changes to the text, but the scripts that require GSUB should not be affected by this, since they will not use surrogates. Still, it's not a permanent fix, but will serve as a bandaid for the crash until the underlying problem has been fixed. Task-number: QTBUG-22275 Change-Id: I90c37fba76bc7d1f369f3afddd1bd0dc306f5750 Reviewed-by: Jiang Jiang --- src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/3rdparty') diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index 2e1b5322d2..6f663d5f9b 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -882,6 +882,17 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe return true; } +static HB_Bool containsSurrogates(HB_ShaperItem *item) +{ + for (hb_uint32 i=0; istringLength; ++i) { + HB_UChar16 ucs = item->string[i]; + if ( HB_IsHighSurrogate(ucs) || HB_IsLowSurrogate(ucs) ) + return true; + } + + return false; +} + HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties) { HB_GlyphAttributes *tmpAttributes; @@ -921,7 +932,7 @@ HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties) #endif face->glyphs_substituted = false; - if (face->gsub) { + if (face->gsub && !containsSurrogates(item)) { unsigned int error = HB_GSUB_Apply_String(face->gsub, face->buffer); if (error && error != HB_Err_Not_Covered) return false; -- cgit v1.2.3