diff options
Diffstat (limited to 'src/platformsupport/fontdatabases/mac')
5 files changed, 56 insertions, 86 deletions
diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri index 2a9b32f65a..af75aa3281 100644 --- a/src/platformsupport/fontdatabases/mac/coretext.pri +++ b/src/platformsupport/fontdatabases/mac/coretext.pri @@ -18,18 +18,4 @@ macos: \ else: \ LIBS_PRIVATE += -framework UIKit -# CoreText is documented to be available on watchOS, but the headers aren't present -# in the watchOS Simulator SDK like they are supposed to be. Work around the problem -# by adding the device SDK's headers to the search path as a fallback. -# rdar://25314492, rdar://27844864 -watchos:simulator { - simulator_system_frameworks = $$xcodeSDKInfo(Path, $${simulator.sdk})/System/Library/Frameworks - device_system_frameworks = $$xcodeSDKInfo(Path, $${device.sdk})/System/Library/Frameworks - for (arch, QMAKE_APPLE_SIMULATOR_ARCHS) { - QMAKE_CXXFLAGS += \ - -Xarch_$${arch} \ - -F$$simulator_system_frameworks \ - -Xarch_$${arch} \ - -F$$device_system_frameworks - } -} +CONFIG += watchos_coretext diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 722a53ac20..5eb5cd8a30 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -687,9 +687,11 @@ static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f) return kCTFontUIFontWindowTitle; case QPlatformTheme::MdiSubWindowTitleFont: - case QPlatformTheme::DockWidgetTitleFont: return kCTFontUIFontSystem; + case QPlatformTheme::DockWidgetTitleFont: + return kCTFontUIFontSmallSystem; + case QPlatformTheme::PushButtonFont: return kCTFontUIFontPushButton; diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index e14d1d6e6e..05f6ed641c 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -57,12 +57,8 @@ #include <qpa/qplatformtheme.h> #include <private/qcore_mac_p.h> -#ifdef Q_OS_OSX -#include <ApplicationServices/ApplicationServices.h> -#else -#include <CoreText/CoreText.h> -#include <CoreGraphics/CoreGraphics.h> -#endif +Q_FORWARD_DECLARE_CF_TYPE(CTFontDescriptor); +Q_FORWARD_DECLARE_CF_TYPE(CTFont); Q_DECLARE_METATYPE(QCFType<CGFontRef>); Q_DECLARE_METATYPE(QCFType<CFURLRef>); @@ -74,18 +70,18 @@ class QCoreTextFontDatabase : public QPlatformFontDatabase public: QCoreTextFontDatabase(); ~QCoreTextFontDatabase(); - void populateFontDatabase() Q_DECL_OVERRIDE; + void populateFontDatabase() override; bool populateFamilyAliases() override; - void populateFamily(const QString &familyName) Q_DECL_OVERRIDE; + void populateFamily(const QString &familyName) override; void invalidate() override; - QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE; - QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE; - void releaseHandle(void *handle) Q_DECL_OVERRIDE; - bool isPrivateFontFamily(const QString &family) const Q_DECL_OVERRIDE; - QFont defaultFont() const Q_DECL_OVERRIDE; - bool fontsAlwaysScalable() const Q_DECL_OVERRIDE; - QList<int> standardSizes() const Q_DECL_OVERRIDE; + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override; + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) override; + void releaseHandle(void *handle) override; + bool isPrivateFontFamily(const QString &family) const override; + QFont defaultFont() const override; + bool fontsAlwaysScalable() const override; + QList<int> standardSizes() const override; // For iOS and OS X platform themes QFont *themeFont(QPlatformTheme::Font) const; diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index d96158d8f6..25ff69d877 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -47,28 +47,18 @@ #include <cmath> -#if defined(Q_OS_OSX) && !QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_11) +#if defined(Q_OS_MACOS) #import <AppKit/AppKit.h> #endif -#if defined(QT_PLATFORM_UIKIT) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2) +#if defined(QT_PLATFORM_UIKIT) #import <UIKit/UIKit.h> #endif // These are available cross platform, exported as kCTFontWeightXXX from CoreText.framework, // but they are not documented and are not in public headers so are private API and exposed // only through the NSFontWeightXXX and UIFontWeightXXX aliases in AppKit and UIKit (rdar://26109857) -#if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_11, __IPHONE_8_2) -#define kCTFontWeightUltraLight -0.8 -#define kCTFontWeightThin -0.6 -#define kCTFontWeightLight -0.4 -#define kCTFontWeightRegular 0 -#define kCTFontWeightMedium 0.23 -#define kCTFontWeightSemibold 0.3 -#define kCTFontWeightBold 0.4 -#define kCTFontWeightHeavy 0.56 -#define kCTFontWeightBlack 0.62 -#elif defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) #define kCTFontWeightUltraLight NSFontWeightUltraLight #define kCTFontWeightThin NSFontWeightThin #define kCTFontWeightLight NSFontWeightLight @@ -673,11 +663,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition if (!im.width() || !im.height()) return im; -#ifdef Q_OS_OSX - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); -#else - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); -#endif + CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); uint cgflags = isColorGlyph ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version cgflags |= kCGBitmapByteOrder32Host; diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index d4c5e70cc1..b77aaa27c1 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -70,53 +70,53 @@ public: QCoreTextFontEngine(CGFontRef font, const QFontDef &def); ~QCoreTextFontEngine(); - glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE; - bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; - void recalcAdvances(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE; + glyph_t glyphIndex(uint ucs4) const override; + bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override; + void recalcAdvances(QGlyphLayout *, ShaperFlags) const override; - glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE; - glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; + glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override; + glyph_metrics_t boundingBox(glyph_t glyph) override; - QFixed ascent() const Q_DECL_OVERRIDE; - QFixed capHeight() const Q_DECL_OVERRIDE; - QFixed descent() const Q_DECL_OVERRIDE; - QFixed leading() const Q_DECL_OVERRIDE; - QFixed xHeight() const Q_DECL_OVERRIDE; - qreal maxCharWidth() const Q_DECL_OVERRIDE; - QFixed averageCharWidth() const Q_DECL_OVERRIDE; + QFixed ascent() const override; + QFixed capHeight() const override; + QFixed descent() const override; + QFixed leading() const override; + QFixed xHeight() const override; + qreal maxCharWidth() const override; + QFixed averageCharWidth() const override; void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, - QPainterPath *path, QTextItem::RenderFlags) Q_DECL_OVERRIDE; + QPainterPath *path, QTextItem::RenderFlags) override; - bool canRender(const QChar *string, int len) const Q_DECL_OVERRIDE; + bool canRender(const QChar *string, int len) const override; - int synthesized() const Q_DECL_OVERRIDE { return synthesisFlags; } - bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return true; } + int synthesized() const override { return synthesisFlags; } + bool supportsSubPixelPositions() const override { return true; } - QFixed lineThickness() const Q_DECL_OVERRIDE; - QFixed underlinePosition() const Q_DECL_OVERRIDE; + QFixed lineThickness() const override; + QFixed underlinePosition() const override; void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight); - FaceId faceId() const Q_DECL_OVERRIDE; - bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const Q_DECL_OVERRIDE; - void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE; - QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition) Q_DECL_OVERRIDE; - QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; - QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; - glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat) Q_DECL_OVERRIDE; - QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; - QFixed emSquareSize() const Q_DECL_OVERRIDE; - void doKerning(QGlyphLayout *g, ShaperFlags flags) const Q_DECL_OVERRIDE; - - bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE; - bool expectsGammaCorrectedBlending() const Q_DECL_OVERRIDE; - - QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; - Qt::HANDLE handle() const Q_DECL_OVERRIDE; - int glyphMargin(QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE { Q_UNUSED(format); return 0; } - - QFontEngine::Properties properties() const Q_DECL_OVERRIDE; + FaceId faceId() const override; + bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const override; + void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override; + QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition) override; + QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) override; + QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) override; + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat) override; + QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) override; + QFixed emSquareSize() const override; + void doKerning(QGlyphLayout *g, ShaperFlags flags) const override; + + bool supportsTransformation(const QTransform &transform) const override; + bool expectsGammaCorrectedBlending() const override; + + QFontEngine *cloneWithSize(qreal pixelSize) const override; + Qt::HANDLE handle() const override; + int glyphMargin(QFontEngine::GlyphFormat format) override { Q_UNUSED(format); return 0; } + + QFontEngine::Properties properties() const override; static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length); static QFont::Weight qtWeightFromCFWeight(float value); |