summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-03-14 11:04:31 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-03-14 11:48:20 (GMT)
commit4d104eb33542b78e233abb9a0d6d4a0ee1495868 (patch)
tree2b4a8774af156e7cc407c2118f877e487fd53298 /src/gui/text
parenta12d39fddf615a7d75e56403525a64847e4ba5a6 (diff)
downloadQt-4d104eb33542b78e233abb9a0d6d4a0ee1495868.zip
Qt-4d104eb33542b78e233abb9a0d6d4a0ee1495868.tar.gz
Qt-4d104eb33542b78e233abb9a0d6d4a0ee1495868.tar.bz2
Add RightToLeft direction forcing to Core Text shaper
So that setting Qt::TextForceRightToLeft flag on QTextLayout can work. Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontengine_coretext.mm15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 0209689..4b65cf5 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -119,14 +119,25 @@ uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef id) const
return engines.count() - 1;
}
-bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags,
+bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
unsigned short *logClusters, const HB_CharAttributes *) const
{
QCFType<CFStringRef> cfstring = CFStringCreateWithCharactersNoCopy(0,
reinterpret_cast<const UniChar *>(str),
len, kCFAllocatorNull);
QCFType<CFAttributedStringRef> attributedString = CFAttributedStringCreate(0, cfstring, attributeDict);
- QCFType<CTTypesetterRef> typeSetter = CTTypesetterCreateWithAttributedString(attributedString);
+ QCFType<CTTypesetterRef> typeSetter;
+
+ if (flags & QTextEngine::RightToLeft) {
+ const void *optionKeys[] = { kCTTypesetterOptionForcedEmbeddingLevel };
+ const short rtlForcedEmbeddingLevelValue = 1;
+ const void *rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) };
+ QCFType<CFDictionaryRef> options = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, 1,
+ &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ typeSetter = CTTypesetterCreateWithAttributedStringAndOptions(attributedString, options);
+ } else
+ typeSetter = CTTypesetterCreateWithAttributedString(attributedString);
+
CFRange range = {0, 0};
QCFType<CTLineRef> line = CTTypesetterCreateLine(typeSetter, range);
CFArrayRef array = CTLineGetGlyphRuns(line);