summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2010-11-04 14:18:57 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2010-11-16 15:11:51 (GMT)
commite45c4387ae16627d61e30a58ae901d888d375aa7 (patch)
tree84a24d9650b5310ca0437c63979855b19e3ccdeb /src/gui/text
parent5803bf9c714bbfc9ecdee8b4fa8ebf87d9bfc4f4 (diff)
downloadQt-e45c4387ae16627d61e30a58ae901d888d375aa7.zip
Qt-e45c4387ae16627d61e30a58ae901d888d375aa7.tar.gz
Qt-e45c4387ae16627d61e30a58ae901d888d375aa7.tar.bz2
Fix bidi PDF mark support in Core Text shaper
When Core Text shaping a string like LRE ... PDF, it won't leave a zero width glyph for the PDF mark, it is not consistent with HarfBuzz and will cause issues in our text engine (the last glyph of the string will be considered as a ligature). This hack appended such a zero width glyph to fix that. Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontengine_mac.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 51e18ec..3c6f3b2 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -252,6 +252,11 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
continue;
Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
+ CFRange stringRange = CTRunGetStringRange(run);
+ UniChar endGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location + stringRange.length - 1);
+ bool endWithPDF = QChar::direction(endGlyph) == QChar::DirPDF;
+ if (endWithPDF)
+ glyphCount++;
if (!outOBounds && outGlyphs + glyphCount - initialGlyph > *nglyphs) {
outOBounds = true;
@@ -264,6 +269,9 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
const uint fontIndex = (fontIndexForFont(runFont) << 24);
//NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
+ if (endWithPDF)
+ glyphCount--;
+
QVarLengthArray<CGGlyph, 512> cgglyphs(0);
const CGGlyph *tmpGlyphs = CTRunGetGlyphsPtr(run);
if (!tmpGlyphs) {
@@ -331,6 +339,16 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
(fontDef.styleStrategy & QFont::ForceIntegerMetrics)
? QFixed::fromReal(lastGlyphAdvance.width).round()
: QFixed::fromReal(lastGlyphAdvance.width);
+
+ if (endWithPDF) {
+ logClusters[stringRange.location + stringRange.length - 1] = glyphCount;
+ outGlyphs[glyphCount] = 0xFFFF;
+ outAdvances_x[glyphCount] = 0;
+ outAdvances_y[glyphCount] = 0;
+ outAttributes[glyphCount].clusterStart = true;
+ outAttributes[glyphCount].dontPrint = true;
+ glyphCount++;
+ }
}
outGlyphs += glyphCount;
outAttributes += glyphCount;