From 09bc8e2cb8238d8dee79a0f22b26efcc05ce6a52 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sun, 10 Jun 2012 18:30:10 +0300 Subject: QFontMetrics/QRawFont: Optimize SMP code points handling a bit Calling QString::fromUcs4() for the single UCS-4 -encoded character is quite suboptimal since the BOM detections and the resulting QString aren't really used; all we need is to split the UCS-4 code point into the UCS-2 surrogate pair. Change-Id: Ia5b68312909bf551cf2493d9e2752a7d7d837fb9 Reviewed-by: Lars Knoll --- src/gui/text/qfontengine_p.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui/text/qfontengine_p.h') diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 4741de3000..bcf763d5d9 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -225,6 +225,18 @@ public: virtual const char *name() const = 0; virtual bool canRender(const QChar *string, int len) = 0; + inline bool canRender(uint ucs4) { + QChar utf16[2]; + int utf16len = 1; + if (QChar::requiresSurrogates(ucs4)) { + utf16[0] = QChar::highSurrogate(ucs4); + utf16[1] = QChar::lowSurrogate(ucs4); + ++utf16len; + } else { + utf16[0] = QChar(ucs4); + } + return canRender(utf16, utf16len); + } virtual Type type() const = 0; -- cgit v1.2.3