From ec7a1dce2ed0766e7681598c17a80468794a249e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 15 Aug 2011 09:31:15 +0200 Subject: Use CoreText for font rendering on uikit. --- src/gui/painting/qpaintengine_raster.cpp | 4 +- src/gui/text/qfontengine_coretext.mm | 12 +- src/gui/text/qfontengine_coretext_p.h | 6 + src/gui/text/text.pri | 9 +- .../examples/flickrdemo/flickrdemo-Info.plist | 8 ++ .../flickrdemo.xcodeproj/project.pbxproj | 14 +- .../uikit/examples/qmltest/qmltest-Info.plist | 8 ++ .../qmltest/qmltest.xcodeproj/project.pbxproj | 16 +-- src/plugins/platforms/uikit/platform.pro | 12 +- .../platforms/uikit/qcoretextfontdatabase.cpp | 156 +++++++++++++++++++++ .../platforms/uikit/qcoretextfontdatabase.h | 58 ++++++++ src/plugins/platforms/uikit/quikitintegration.mm | 14 +- src/plugins/platforms/uikit/quikitscreen.mm | 5 +- 13 files changed, 280 insertions(+), 42 deletions(-) create mode 100644 src/plugins/platforms/uikit/qcoretextfontdatabase.cpp create mode 100644 src/plugins/platforms/uikit/qcoretextfontdatabase.h diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 76d7316..9826689 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3098,7 +3098,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte ensurePen(); ensureState(); -#if defined (Q_WS_WIN) || defined(Q_WS_MAC) +#if defined (Q_WS_WIN) || defined(Q_WS_MAC) || (defined(Q_OS_MAC) && defined(Q_WS_QPA)) if (!supportsTransformations(ti.fontEngine)) { QVarLengthArray positions; @@ -3438,7 +3438,7 @@ bool QRasterPaintEngine::supportsTransformations(const QFontEngine *fontEngine) bool QRasterPaintEngine::supportsTransformations(qreal pixelSize, const QTransform &m) const { -#if defined(Q_WS_MAC) +#if defined(Q_WS_MAC) || (defined(Q_OS_MAC) && defined(Q_WS_QPA)) // Mac font engines don't support scaling and rotation if (m.type() > QTransform::TxTranslate) #else diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 64d4a24..153451e 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -135,7 +135,7 @@ void QCoreTextFontEngineMulti::init(bool kerning) attributeDict = CFDictionaryCreateMutable(0, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont); + CFDictionaryAddValue(attributeDict, kCTFontAttributeName, ctfont); if (!kerning) { float zero = 0.0; QCFType noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero); @@ -257,7 +257,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay //NSLog(@"Dictionary %@", runAttribs); if (!runAttribs) runAttribs = attributeDict; - CTFontRef runFont = static_cast(CFDictionaryGetValue(runAttribs, NSFontAttributeName)); + CTFontRef runFont = static_cast(CFDictionaryGetValue(runAttribs, kCTFontAttributeName)); uint fontIndex = fontIndexForFont(runFont); const QFontEngine *engine = engineAt(fontIndex); fontIndex <<= 24; @@ -547,7 +547,6 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph) ret.xoff = ret.xoff.round(); ret.yoff = ret.yoff.round(); } - return ret; } @@ -723,7 +722,12 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition QImage im(qRound(br.width) + 2, qRound(br.height) + 2, QImage::Format_RGB32); im.fill(0); - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + CGColorSpaceRef colorspace = +#ifdef Q_WS_MAC + CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); +#else + CGColorSpaceCreateDeviceRGB(); +#endif uint cgflags = kCGImageAlphaNoneSkipFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version cgflags |= kCGBitmapByteOrder32Host; diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index efe8295..0a2ae1f 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -44,6 +44,12 @@ #include +#ifdef QT_NO_CORESERVICES +#include +#include +#include +#endif + #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) class QRawFontPrivate; diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index b6cdc52..1cfacf7 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -106,14 +106,17 @@ unix:x11 { !embedded:!qpa:!x11:mac { HEADERS += \ text/qfontengine_mac_p.h - OBJECTIVE_HEADERS += \ - text/qfontengine_coretext_p.h SOURCES += \ text/qfont_mac.cpp \ text/qrawfont_mac.cpp OBJECTIVE_SOURCES += \ - text/qfontengine_coretext.mm \ text/qfontengine_mac.mm +} +!embedded:!x11:mac { + OBJECTIVE_HEADERS += \ + text/qfontengine_coretext_p.h + OBJECTIVE_SOURCES += \ + text/qfontengine_coretext.mm contains(QT_CONFIG, harfbuzz) { DEFINES += QT_ENABLE_HARFBUZZ_FOR_MAC } diff --git a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo-Info.plist b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo-Info.plist index 5bc1ac9..3c45823 100644 --- a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo-Info.plist +++ b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo-Info.plist @@ -6,6 +6,8 @@ English CFBundleDisplayName ${PRODUCT_NAME} + CFBundleDocumentTypes + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile @@ -20,6 +22,8 @@ APPL CFBundleSignature ???? + CFBundleURLTypes + CFBundleVersion 1.0 LSRequiresIPhoneOS @@ -37,5 +41,9 @@ UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown + UTExportedTypeDeclarations + + UTImportedTypeDeclarations + diff --git a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj index b564ef9..68237ae 100755 --- a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj @@ -17,13 +17,14 @@ D307DEB213EBCF5500399BD4 /* libQtOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEA913EBCF5500399BD4 /* libQtOpenGL.a */; }; D307DEB313EBCF5500399BD4 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEAA13EBCF5500399BD4 /* libQtScript.a */; }; D307DEB413EBCF5500399BD4 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEAB13EBCF5500399BD4 /* libQtSql.a */; }; - D307DEB513EBCF5500399BD4 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEAC13EBCF5500399BD4 /* libQtXml.a */; }; D307DEB613EBCF5500399BD4 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEAD13EBCF5500399BD4 /* libQtXmlPatterns.a */; }; D307DEB813EBCF6400399BD4 /* libquikit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DEB713EBCF6400399BD4 /* libquikit.a */; }; D333CCF213B88A4D0070E08E /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCEF13B88A4D0070E08E /* moc_qmlapplicationviewer.cpp */; }; D333CCF313B88A4D0070E08E /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCEF13B88A4D0070E08E /* moc_qmlapplicationviewer.cpp */; }; D333CCF413B88A4D0070E08E /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF013B88A4D0070E08E /* qmlapplicationviewer.cpp */; }; D333CCF513B88A4D0070E08E /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF013B88A4D0070E08E /* qmlapplicationviewer.cpp */; }; + D36D346513F3CD7E00EC5A41 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D36D346413F3CD7E00EC5A41 /* CoreText.framework */; }; + D36D346613F3CD8800EC5A41 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D36D346413F3CD7E00EC5A41 /* CoreText.framework */; }; D3A51610134B03DE00E30E2F /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3A5160F134B03DE00E30E2F /* OpenGLES.framework */; }; D3A51612134B03E900E30E2F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3A51611134B03E900E30E2F /* QuartzCore.framework */; }; D3A51615134B041500E30E2F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3A51611134B03E900E30E2F /* QuartzCore.framework */; }; @@ -46,7 +47,6 @@ D3D8175B132A184300CDE422 /* libQtNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D81755132A184300CDE422 /* libQtNetwork.a */; }; D3D8175C132A184300CDE422 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D81756132A184300CDE422 /* libQtScript.a */; }; D3D8175D132A184300CDE422 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D81757132A184300CDE422 /* libQtSql.a */; }; - D3D81760132A185A00CDE422 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D8175E132A185A00CDE422 /* libQtXml.a */; }; D3D81761132A185A00CDE422 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D8175F132A185A00CDE422 /* libQtXmlPatterns.a */; }; D3D81763132A186B00CDE422 /* libquikit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D81762132A186B00CDE422 /* libquikit.a */; }; /* End PBXBuildFile section */ @@ -65,12 +65,12 @@ D307DEA913EBCF5500399BD4 /* libQtOpenGL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtOpenGL.a"; sourceTree = ""; }; D307DEAA13EBCF5500399BD4 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtScript.a"; sourceTree = ""; }; D307DEAB13EBCF5500399BD4 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtSql.a"; sourceTree = ""; }; - D307DEAC13EBCF5500399BD4 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXml.a"; sourceTree = ""; }; D307DEAD13EBCF5500399BD4 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXmlPatterns.a"; sourceTree = ""; }; D307DEB713EBCF6400399BD4 /* libquikit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit.a; path = "../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms/libquikit.a"; sourceTree = ""; }; D333CCEF13B88A4D0070E08E /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = ../share/qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = ""; }; D333CCF013B88A4D0070E08E /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = ../share/qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = ""; }; D333CCF113B88A4D0070E08E /* qmlapplicationviewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qmlapplicationviewer.h; path = ../share/qmlapplicationviewer/qmlapplicationviewer.h; sourceTree = ""; }; + D36D346413F3CD7E00EC5A41 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; D3A5160F134B03DE00E30E2F /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D3A51611134B03E900E30E2F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; D3A51617134B042A00E30E2F /* libQtOpenGL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtOpenGL.a"; sourceTree = ""; }; @@ -85,7 +85,6 @@ D3D81755132A184300CDE422 /* libQtNetwork.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtNetwork.a"; sourceTree = SOURCE_ROOT; }; D3D81756132A184300CDE422 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtScript.a"; sourceTree = SOURCE_ROOT; }; D3D81757132A184300CDE422 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtSql.a"; sourceTree = SOURCE_ROOT; }; - D3D8175E132A185A00CDE422 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXml.a"; sourceTree = SOURCE_ROOT; }; D3D8175F132A185A00CDE422 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXmlPatterns.a"; sourceTree = SOURCE_ROOT; }; D3D81762132A186B00CDE422 /* libquikit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit.a; path = "../../../../../../../qt-lighthouse-ios-device/plugins/platforms/libquikit.a"; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -95,6 +94,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D36D346613F3CD8800EC5A41 /* CoreText.framework in Frameworks */, D3A51612134B03E900E30E2F /* QuartzCore.framework in Frameworks */, D3A51610134B03DE00E30E2F /* OpenGLES.framework in Frameworks */, 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, @@ -108,7 +108,6 @@ D307DEB213EBCF5500399BD4 /* libQtOpenGL.a in Frameworks */, D307DEB313EBCF5500399BD4 /* libQtScript.a in Frameworks */, D307DEB413EBCF5500399BD4 /* libQtSql.a in Frameworks */, - D307DEB513EBCF5500399BD4 /* libQtXml.a in Frameworks */, D307DEB613EBCF5500399BD4 /* libQtXmlPatterns.a in Frameworks */, D307DEB813EBCF6400399BD4 /* libquikit.a in Frameworks */, ); @@ -118,6 +117,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D36D346513F3CD7E00EC5A41 /* CoreText.framework in Frameworks */, D3A51618134B042A00E30E2F /* libQtOpenGL.a in Frameworks */, D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */, D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */, @@ -131,7 +131,6 @@ D3D8175B132A184300CDE422 /* libQtNetwork.a in Frameworks */, D3D8175C132A184300CDE422 /* libQtScript.a in Frameworks */, D3D8175D132A184300CDE422 /* libQtSql.a in Frameworks */, - D3D81760132A185A00CDE422 /* libQtXml.a in Frameworks */, D3D81761132A185A00CDE422 /* libQtXmlPatterns.a in Frameworks */, D3D81763132A186B00CDE422 /* libquikit.a in Frameworks */, ); @@ -190,6 +189,7 @@ 288765A40DF7441C002DB57D /* CoreGraphics.framework */, D3A51611134B03E900E30E2F /* QuartzCore.framework */, D3A5160F134B03DE00E30E2F /* OpenGLES.framework */, + D36D346413F3CD7E00EC5A41 /* CoreText.framework */, D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */, ); name = Frameworks; @@ -216,7 +216,6 @@ D3A51617134B042A00E30E2F /* libQtOpenGL.a */, D3D81756132A184300CDE422 /* libQtScript.a */, D3D81757132A184300CDE422 /* libQtSql.a */, - D3D8175E132A185A00CDE422 /* libQtXml.a */, D3D8175F132A185A00CDE422 /* libQtXmlPatterns.a */, ); name = Device; @@ -233,7 +232,6 @@ D307DEA913EBCF5500399BD4 /* libQtOpenGL.a */, D307DEAA13EBCF5500399BD4 /* libQtScript.a */, D307DEAB13EBCF5500399BD4 /* libQtSql.a */, - D307DEAC13EBCF5500399BD4 /* libQtXml.a */, D307DEAD13EBCF5500399BD4 /* libQtXmlPatterns.a */, ); name = Simulator; diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist index 1566585..531d93d 100644 --- a/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist +++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist @@ -6,6 +6,8 @@ English CFBundleDisplayName ${PRODUCT_NAME} + CFBundleDocumentTypes + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile @@ -20,9 +22,15 @@ APPL CFBundleSignature ???? + CFBundleURLTypes + CFBundleVersion 1.0 LSRequiresIPhoneOS + UTExportedTypeDeclarations + + UTImportedTypeDeclarations + diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj index afebcba..1dd9b35 100755 --- a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj @@ -18,12 +18,13 @@ D307DED313EBD05900399BD4 /* libQtOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DECA13EBD05900399BD4 /* libQtOpenGL.a */; }; D307DED413EBD05900399BD4 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DECB13EBD05900399BD4 /* libQtScript.a */; }; D307DED513EBD05900399BD4 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DECC13EBD05900399BD4 /* libQtSql.a */; }; - D307DED613EBD05900399BD4 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DECD13EBD05900399BD4 /* libQtXml.a */; }; D307DED713EBD05900399BD4 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D307DECE13EBD05900399BD4 /* libQtXmlPatterns.a */; }; D333CCF913B88A690070E08E /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF613B88A690070E08E /* moc_qmlapplicationviewer.cpp */; }; D333CCFA13B88A690070E08E /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF613B88A690070E08E /* moc_qmlapplicationviewer.cpp */; }; D333CCFB13B88A690070E08E /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF713B88A690070E08E /* qmlapplicationviewer.cpp */; }; D333CCFC13B88A690070E08E /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D333CCF713B88A690070E08E /* qmlapplicationviewer.cpp */; }; + D34F290413F29AF400E4F9AC /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D34F290313F29AF400E4F9AC /* CoreText.framework */; }; + D34F290713F29B0A00E4F9AC /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D34F290613F29B0300E4F9AC /* CoreText.framework */; }; D35784261345D9940046D202 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784251345D9940046D202 /* OpenGLES.framework */; }; D35784281345D9E00046D202 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784271345D9E00046D202 /* QuartzCore.framework */; }; D3578436134A09990046D202 /* libQtOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3578435134A09990046D202 /* libQtOpenGL.a */; }; @@ -46,7 +47,6 @@ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */; }; D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AE132A2CFD00CDE422 /* libQtScript.a */; }; D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AF132A2CFD00CDE422 /* libQtSql.a */; }; - D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B0132A2CFD00CDE422 /* libQtXml.a */; }; D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */; }; D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817BA132A2D0E00CDE422 /* libquikit.a */; }; /* End PBXBuildFile section */ @@ -66,11 +66,12 @@ D307DECA13EBD05900399BD4 /* libQtOpenGL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtOpenGL.a"; sourceTree = ""; }; D307DECB13EBD05900399BD4 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtScript.a"; sourceTree = ""; }; D307DECC13EBD05900399BD4 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtSql.a"; sourceTree = ""; }; - D307DECD13EBD05900399BD4 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXml.a"; sourceTree = ""; }; D307DECE13EBD05900399BD4 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXmlPatterns.a"; sourceTree = ""; }; D333CCF613B88A690070E08E /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = ../share/qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = ""; }; D333CCF713B88A690070E08E /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = ../share/qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = ""; }; D333CCF813B88A690070E08E /* qmlapplicationviewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qmlapplicationviewer.h; path = ../share/qmlapplicationviewer/qmlapplicationviewer.h; sourceTree = ""; }; + D34F290313F29AF400E4F9AC /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; + D34F290613F29B0300E4F9AC /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; D35784251345D9940046D202 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D35784271345D9E00046D202 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; D3578435134A09990046D202 /* libQtOpenGL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtOpenGL.a"; sourceTree = ""; }; @@ -85,7 +86,6 @@ D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtNetwork.a"; sourceTree = SOURCE_ROOT; }; D3D817AE132A2CFD00CDE422 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtScript.a"; sourceTree = SOURCE_ROOT; }; D3D817AF132A2CFD00CDE422 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtSql.a"; sourceTree = SOURCE_ROOT; }; - D3D817B0132A2CFD00CDE422 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXml.a"; sourceTree = SOURCE_ROOT; }; D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXmlPatterns.a"; sourceTree = SOURCE_ROOT; }; D3D817BA132A2D0E00CDE422 /* libquikit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit.a; path = "../../../../../../../qt-lighthouse-ios-device/plugins/platforms/libquikit.a"; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -95,6 +95,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D34F290413F29AF400E4F9AC /* CoreText.framework in Frameworks */, D35784281345D9E00046D202 /* QuartzCore.framework in Frameworks */, 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, @@ -108,7 +109,6 @@ D307DED313EBD05900399BD4 /* libQtOpenGL.a in Frameworks */, D307DED413EBD05900399BD4 /* libQtScript.a in Frameworks */, D307DED513EBD05900399BD4 /* libQtSql.a in Frameworks */, - D307DED613EBD05900399BD4 /* libQtXml.a in Frameworks */, D307DED713EBD05900399BD4 /* libQtXmlPatterns.a in Frameworks */, D307DEC513EBD04100399BD4 /* libquikit.a in Frameworks */, ); @@ -118,6 +118,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D34F290713F29B0A00E4F9AC /* CoreText.framework in Frameworks */, D357843A134A0AB10046D202 /* QuartzCore.framework in Frameworks */, D3578439134A0AAE0046D202 /* OpenGLES.framework in Frameworks */, D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */, @@ -130,7 +131,6 @@ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */, D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */, D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */, - D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */, D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */, D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */, D3578436134A09990046D202 /* libQtOpenGL.a in Frameworks */, @@ -152,6 +152,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + D34F290313F29AF400E4F9AC /* CoreText.framework */, 29B97315FDCFA39411CA2CEA /* Other Sources */, 29B97317FDCFA39411CA2CEA /* Resources */, D3CAA7E213264E8C008BB877 /* QMLApplicationViewer */, @@ -190,6 +191,7 @@ 288765A40DF7441C002DB57D /* CoreGraphics.framework */, D35784251345D9940046D202 /* OpenGLES.framework */, D35784271345D9E00046D202 /* QuartzCore.framework */, + D34F290613F29B0300E4F9AC /* CoreText.framework */, D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */, ); name = Frameworks; @@ -216,7 +218,6 @@ D3578435134A09990046D202 /* libQtOpenGL.a */, D3D817AE132A2CFD00CDE422 /* libQtScript.a */, D3D817AF132A2CFD00CDE422 /* libQtSql.a */, - D3D817B0132A2CFD00CDE422 /* libQtXml.a */, D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */, ); name = Device; @@ -233,7 +234,6 @@ D307DECA13EBD05900399BD4 /* libQtOpenGL.a */, D307DECB13EBD05900399BD4 /* libQtScript.a */, D307DECC13EBD05900399BD4 /* libQtSql.a */, - D307DECD13EBD05900399BD4 /* libQtXml.a */, D307DECE13EBD05900399BD4 /* libQtXmlPatterns.a */, ); name = Simulator; diff --git a/src/plugins/platforms/uikit/platform.pro b/src/plugins/platforms/uikit/platform.pro index 726da06..b5ff62f 100644 --- a/src/plugins/platforms/uikit/platform.pro +++ b/src/plugins/platforms/uikit/platform.pro @@ -17,11 +17,19 @@ OBJECTIVE_HEADERS = quikitintegration.h \ quikiteventloop.h \ quikitwindowsurface.h -HEADERS = quikitsoftwareinputhandler.h +HEADERS = quikitsoftwareinputhandler.h \ + qcoretextfontdatabase.h + +SOURCES += \ + qcoretextfontdatabase.cpp + +#needed for qcoretextfontengine even if it's not used +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src #add libz for freetype. LIBS += -lz -include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target + + diff --git a/src/plugins/platforms/uikit/qcoretextfontdatabase.cpp b/src/plugins/platforms/uikit/qcoretextfontdatabase.cpp new file mode 100644 index 0000000..76ad936 --- /dev/null +++ b/src/plugins/platforms/uikit/qcoretextfontdatabase.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcoretextfontdatabase.h" + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +void QCoreTextFontDatabase::populateFontDatabase() +{ + QCFType collection = CTFontCollectionCreateFromAvailableFonts(0); + if(!collection) + return; + QCFType fonts = CTFontCollectionCreateMatchingFontDescriptors(collection); + if(!fonts) + return; + QSupportedWritingSystems supportedWritingSystems; + for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) + supportedWritingSystems.setSupported((QFontDatabase::WritingSystem)i, true); + QString foundry_name = "CoreText"; + const int numFonts = CFArrayGetCount(fonts); + for(int i = 0; i < numFonts; ++i) { + CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i); + + QCFString family_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute); +// QCFString style_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute); + + QFont::Weight fontWeight = QFont::Normal; + QFont::Style fontStyle = QFont::StyleNormal; + if(QCFType styles = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute)) { + if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontWeightTrait)) { + Q_ASSERT(CFNumberIsFloatType(weight)); + double d; + if(CFNumberGetValue(weight, kCFNumberDoubleType, &d)) { + if (d > 0.0) + fontWeight = QFont::Bold; + } + } + if(CFNumberRef italic = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontSlantTrait)) { + Q_ASSERT(CFNumberIsFloatType(italic)); + double d; + if(CFNumberGetValue(italic, kCFNumberDoubleType, &d)) { + if (d > 0.0) + fontStyle = QFont::StyleItalic; + } + } + } + + int pixelSize = 0; + if(QCFType size = (CFNumberRef)CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute)) { + if(CFNumberIsFloatType(size)) { + double d; + CFNumberGetValue(size, kCFNumberDoubleType, &d); + pixelSize = d; + } else { + CFNumberGetValue(size, kCFNumberIntType, &pixelSize); + } + } + registerFont(QString(family_name), + foundry_name, + fontWeight, + fontStyle, + QFont::Unstretched, + true, + true, + pixelSize, + supportedWritingSystems, + 0); + } +} + +QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle) +{ + Q_UNUSED(script) + Q_UNUSED(handle) + CTFontSymbolicTraits symbolicTraits = 0; + if (fontDef.weight >= QFont::Bold) + symbolicTraits |= kCTFontBoldTrait; + switch (fontDef.style) { + case QFont::StyleNormal: + break; + case QFont::StyleItalic: + case QFont::StyleOblique: + symbolicTraits |= kCTFontItalicTrait; + break; + } + + CGAffineTransform transform = CGAffineTransformIdentity; + if (fontDef.stretch != 100) { + transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); + } + + QCFType baseFont = CTFontCreateWithName(QCFString(fontDef.family), fontDef.pixelSize, &transform); + QCFType ctFont = NULL; + // There is a side effect in Core Text: if we apply 0 as symbolic traits to a font in normal weight, + // we will get the light version of that font (while the way supposed to work doesn't: + // setting kCTFontWeightTrait to some value between -1.0 to 0.0 has no effect on font selection) + if (fontDef.weight != QFont::Normal || symbolicTraits) + ctFont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); + + // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does + // not exist for the given font. (for example italic) + if (ctFont == 0) { + ctFont = baseFont; + } + + if (ctFont) + return new QCoreTextFontEngine(ctFont, fontDef); + return 0; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/qcoretextfontdatabase.h b/src/plugins/platforms/uikit/qcoretextfontdatabase.h new file mode 100644 index 0000000..f4fcb20 --- /dev/null +++ b/src/plugins/platforms/uikit/qcoretextfontdatabase.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCORETEXTFONTDATABASE_H +#define QCORETEXTFONTDATABASE_H + +#include + +QT_BEGIN_NAMESPACE + +class QCoreTextFontDatabase : public QPlatformFontDatabase +{ +public: + void populateFontDatabase(); + QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); +}; + +QT_END_NAMESPACE + +#endif // QCORETEXTFONTDATABASE_H diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm index ca020c9..02da97c 100644 --- a/src/plugins/platforms/uikit/quikitintegration.mm +++ b/src/plugins/platforms/uikit/quikitintegration.mm @@ -44,7 +44,7 @@ #include "quikitwindowsurface.h" #include "quikitscreen.h" #include "quikiteventloop.h" -#include "qgenericunixfontdatabase.h" +#include "qcoretextfontdatabase.h" #include @@ -56,16 +56,6 @@ QT_BEGIN_NAMESPACE -class QUIKitFontDatabase : public QGenericUnixFontDatabase -{ -public: - virtual QString fontDir() const - { - return QString( [[[[NSBundle mainBundle] bundlePath] - stringByAppendingPathComponent:@"fonts"] UTF8String] ); - } -}; - static QUIKitIntegration *m_instance = 0; QUIKitIntegration * QUIKitIntegration::instance() @@ -74,7 +64,7 @@ QUIKitIntegration * QUIKitIntegration::instance() } QUIKitIntegration::QUIKitIntegration() - :mFontDb(new QUIKitFontDatabase() ) + :mFontDb(new QCoreTextFontDatabase) { if (!m_instance) m_instance = this; diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm index 3c1e360..6d24193 100644 --- a/src/plugins/platforms/uikit/quikitscreen.mm +++ b/src/plugins/platforms/uikit/quikitscreen.mm @@ -63,7 +63,6 @@ QUIKitScreen::QUIKitScreen(int screenIndex) const qreal inch = 25.4; qreal dpi = 160.; int dragDistance = 12; - int defaultFontPixelSize = 14; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { dpi = 132.; dragDistance = 10; @@ -71,8 +70,8 @@ QUIKitScreen::QUIKitScreen(int screenIndex) m_physicalSize = QSize(qRound(bounds.size.width * inch / dpi), qRound(bounds.size.height * inch / dpi)); qApp->setStartDragDistance(dragDistance); - QFont font(QLatin1String("Bitstream Vera Sans")); - font.setPixelSize(defaultFontPixelSize); + QFont font; // system font is helvetica, so that is fine already + font.setPixelSize([UIFont systemFontSize]); qApp->setFont(font); [pool release]; -- cgit v0.12 From 2b6b6acec2f659f50416c7d6f369a266de19373b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 24 Aug 2011 09:26:07 +0200 Subject: uikit: fix examples to no longer ship the custom fonts --- .../uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj | 6 ------ .../uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj index 68237ae..dedc462 100755 --- a/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/flickrdemo/flickrdemo.xcodeproj/project.pbxproj @@ -37,8 +37,6 @@ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; }; D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; }; - D3CAA88A132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; }; - D3CAA88B132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; }; D3D815F31329339300CDE422 /* flickr in Resources */ = {isa = PBXBuildFile; fileRef = D3D815D31329339300CDE422 /* flickr */; }; D3D815F4132933AB00CDE422 /* flickr in Resources */ = {isa = PBXBuildFile; fileRef = D3D815D31329339300CDE422 /* flickr */; }; D3D81758132A184300CDE422 /* libQtCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D81752132A184300CDE422 /* libQtCore.a */; }; @@ -77,7 +75,6 @@ D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; D3CAA7F613264F52008BB877 /* flickrdemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = flickrdemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.3.dylib; path = usr/lib/libz.1.2.3.dylib; sourceTree = SDKROOT; }; - D3CAA836132652E5008BB877 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fonts; path = ../../../../../../lib/fonts; sourceTree = SOURCE_ROOT; }; D3D815D31329339300CDE422 /* flickr */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flickr; path = ../../../../../../demos/declarative/flickr; sourceTree = SOURCE_ROOT; }; D3D81752132A184300CDE422 /* libQtCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtCore.a"; sourceTree = SOURCE_ROOT; }; D3D81753132A184300CDE422 /* libQtDeclarative.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtDeclarative.a"; sourceTree = SOURCE_ROOT; }; @@ -173,7 +170,6 @@ isa = PBXGroup; children = ( D3D815D31329339300CDE422 /* flickr */, - D3CAA836132652E5008BB877 /* fonts */, 8D1107310486CEB800E47090 /* flickrdemo-Info.plist */, ); name = Resources; @@ -304,7 +300,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D3CAA88A132652E5008BB877 /* fonts in Resources */, D3D815F31329339300CDE422 /* flickr in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -313,7 +308,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D3CAA88B132652E5008BB877 /* fonts in Resources */, D3D815F4132933AB00CDE422 /* flickr in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj index 1dd9b35..021eed2 100755 --- a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj @@ -37,8 +37,6 @@ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; }; D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; }; - D3CAA88A132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; }; - D3CAA88B132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; }; D3CAA89113265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; }; D3CAA89213265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; }; D3D817B2132A2CFD00CDE422 /* libQtCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AA132A2CFD00CDE422 /* libQtCore.a */; }; @@ -78,7 +76,6 @@ D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; D3CAA7F613264F52008BB877 /* qmltest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = qmltest.app; sourceTree = BUILT_PRODUCTS_DIR; }; D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.3.dylib; path = usr/lib/libz.1.2.3.dylib; sourceTree = SDKROOT; }; - D3CAA836132652E5008BB877 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fonts; path = ../../../../../../lib/fonts; sourceTree = SOURCE_ROOT; }; D3CAA88E13265310008BB877 /* qml */ = {isa = PBXFileReference; lastKnownFileType = folder; path = qml; sourceTree = SOURCE_ROOT; }; D3D817AA132A2CFD00CDE422 /* libQtCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtCore.a"; sourceTree = SOURCE_ROOT; }; D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtDeclarative.a"; sourceTree = SOURCE_ROOT; }; @@ -175,7 +172,6 @@ isa = PBXGroup; children = ( D3CAA88E13265310008BB877 /* qml */, - D3CAA836132652E5008BB877 /* fonts */, 8D1107310486CEB800E47090 /* qmltest-Info.plist */, ); name = Resources; @@ -306,7 +302,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D3CAA88A132652E5008BB877 /* fonts in Resources */, D3CAA89113265310008BB877 /* qml in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -315,7 +310,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D3CAA88B132652E5008BB877 /* fonts in Resources */, D3CAA89213265310008BB877 /* qml in Resources */, ); runOnlyForDeploymentPostprocessing = 0; -- cgit v0.12 From 1a8a36eb6b6df9e2550b5eaa4606f2d411fd4294 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 24 Aug 2011 09:13:45 +0200 Subject: Fix justification of RTL text Since the trailing space is included in the QScriptLine, it may affect the positions of preceding script items when the text is RTL. The best solution for this would be to disregard the trailing space in the layout process, or somehow make it have an advance of 0 so it doesn't affect the layout. However, to minimize the impact of the change, and to be consistent with previous work arounds such as bf992df6434fc37715f728ca09601c5567dd83c9, we simply include the trailing (visually leading) space in the justification pass for now. Task-number: QTBUG-20920 Reviewed-by: Lars --- src/gui/text/qtextengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 9f148ee..aa4a20d 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2087,7 +2087,8 @@ void QTextEngine::justify(const QScriptLine &line) } } - QFixed need = line.width - line.textWidth; + QFixed leading = leadingSpaceWidth(line); + QFixed need = line.width - line.textWidth - leading; if (need < 0) { // line overflows already! const_cast(line).justified = true; -- cgit v0.12 From 00561c990b6a55de616267637fd3e772d4f10efe Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 24 Aug 2011 09:41:29 +0200 Subject: Revert "Include trailing space width in RTL text line width" This reverts commit 2fa986aa670bee0fafb30241f40bb3556594e32b. The fix was wrong. Use the IncludeTrailingSpaces flag if you want to include the trailing spaces in the text width. Reviewed-by: Jiang Jiang --- src/gui/text/qtextlayout.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 515915a..4fd6ddf 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1928,12 +1928,8 @@ found: if (line.textWidth > 0 && item < eng->layoutData->items.size()) eng->maxWidth += lbh.spaceData.textWidth; - // In the latter case, text are drawn with trailing spaces at the beginning - // of a line, so the naturalTextWidth should contain the space width - if ((eng->option.flags() & QTextOption::IncludeTrailingSpaces) || - (line.width == QFIXED_MAX && eng->isRightToLeft())) { + if (eng->option.flags() & QTextOption::IncludeTrailingSpaces) line.textWidth += lbh.spaceData.textWidth; - } if (lbh.spaceData.length) { line.length += lbh.spaceData.length; line.hasTrailingSpaces = true; -- cgit v0.12 From f9a2b1618ef67f6be0f986b24e75d138d20ee6c7 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 22 Aug 2011 12:12:59 +0200 Subject: Fix QGLGlyphCache for Open GL ES (1). When resizing the font texture the code was using glGetTexImage which is not available on Open GL ES. We need to cache the font texture data, and draw the glyphs on it in addition, so we can copy the data when resizing the texture size. --- src/opengl/qpaintengine_opengl.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 71ed690..0f33cab 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -4536,11 +4536,14 @@ struct QGLGlyphCoord { }; struct QGLFontTexture { + QGLFontTexture() : data(0) { } + ~QGLFontTexture() { free(data); } int x_offset; // glyph offset within the int y_offset; GLuint texture; int width; int height; + uchar *data; }; typedef QHash QGLGlyphHash; @@ -4563,7 +4566,7 @@ public: QGLGlyphCoord *lookup(QFontEngine *, glyph_t); void cacheGlyphs(QGLContext *, QFontEngine *, glyph_t *glyphs, int numGlyphs); void cleanCache(); - void allocTexture(int width, int height, GLuint texture); + void allocTexture(QGLFontTexture *); public slots: void cleanupContext(const QGLContext *); @@ -4681,19 +4684,18 @@ void QGLGlyphCache::cleanCache() qt_context_cache.clear(); } -void QGLGlyphCache::allocTexture(int width, int height, GLuint texture) +void QGLGlyphCache::allocTexture(QGLFontTexture *font_tex) { - uchar *tex_data = (uchar *) malloc(width*height*2); - memset(tex_data, 0, width*height*2); - glBindTexture(GL_TEXTURE_2D, texture); + font_tex->data = (uchar *) malloc(font_tex->width*font_tex->height*2); + memset(font_tex->data, 0, font_tex->width*font_tex->height*2); + glBindTexture(GL_TEXTURE_2D, font_tex->texture); #ifndef QT_OPENGL_ES glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, - width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, tex_data); + font_tex->width, font_tex->height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, font_tex->data); #else glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, - width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, tex_data); + font_tex->width, font_tex->height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, font_tex->data); #endif - free(tex_data); } #if 0 @@ -4777,13 +4779,13 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, Q_ASSERT(max_tex_size > 0); if (tex_width > max_tex_size) tex_width = max_tex_size; - allocTexture(tex_width, tex_height, font_texture); font_tex = new QGLFontTexture; font_tex->texture = font_texture; font_tex->x_offset = x_margin; font_tex->y_offset = y_margin; font_tex->width = tex_width; font_tex->height = tex_height; + allocTexture(font_tex); // qDebug() << "new font tex - width:" << tex_width << "height:"<< tex_height // << hex << "tex id:" << font_tex->texture << "key:" << font_key << "num cached:" << qt_font_textures.size(); qt_font_textures.insert(font_key, font_tex); @@ -4806,21 +4808,19 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, font_tex->y_offset += strip_height; if (font_tex->y_offset >= font_tex->height) { // get hold of the old font texture - uchar *old_tex_data = (uchar *) malloc(font_tex->width*font_tex->height*2); + uchar *old_tex_data = font_tex->data; int old_tex_height = font_tex->height; -#ifndef QT_OPENGL_ES - glGetTexImage(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, old_tex_data); -#endif // realloc a larger texture glDeleteTextures(1, &font_tex->texture); glGenTextures(1, &font_tex->texture); font_tex->height = qt_next_power_of_two(font_tex->height + strip_height); - allocTexture(font_tex->width, font_tex->height, font_tex->texture); + allocTexture(font_tex); // write back the old texture data glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, font_tex->width, old_tex_height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, old_tex_data); + memcpy(font_tex->data, old_tex_data, font_tex->width*old_tex_height*2); free(old_tex_data); // update the texture coords and the y offset for the existing glyphs in @@ -4868,8 +4868,10 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, } #endif glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); + int cacheLineStart = (font_tex->x_offset + font_tex->y_offset*font_tex->width)*2; for (int y=0; ydata+cacheLineStart, tex_data+lineStart, glyph_width*2); + cacheLineStart += font_tex->width*2; } glTexSubImage2D(GL_TEXTURE_2D, 0, font_tex->x_offset, font_tex->y_offset, glyph_width, glyph_im.height(), @@ -4950,7 +4955,7 @@ void QOpenGLPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); bool antialias = !(textItem->fontEngine()->fontDef.styleStrategy & QFont::NoAntialias) - && (d->matrix.type() > QTransform::TxTranslate); + && (d->matrix.type() > QTransform::TxTranslate); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, antialias ? GL_LINEAR : GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, antialias ? GL_LINEAR : GL_NEAREST); -- cgit v0.12