summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/mac
Commit message (Collapse)AuthorAgeFilesLines
* Move CoreText font engine/database to QtGuiTor Arne Vestbø2020-05-275-2152/+0
| | | | | | Task-number: QTBUG-83255 Change-Id: Id34ed1759fdebbb1d09e51009f0370736002167c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move FreeType font engine/database to QtGuiTor Arne Vestbø2020-05-272-1/+5
| | | | | | Task-number: QTBUG-83255 Change-Id: If6be7057d6bd25b34acd99e18658744161985ed0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix font height metrics with embedded bitmapsEskil Abrahamsen Blomfeldt2020-05-042-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | For fonts with embedded bitmaps, we cannot trust the HHEA and OS/2 tables, since there are a different set of font metrics in the EBLC/CBLC tables for each of the predefined bitmap sizes. In this case, we can safely fall back to the metrics returned by the system, as the inconsistency we were originally fixing was only between OS/2 and HHEA and will not matter for the bitmap fonts. This patch also simplifies the code path through the font engines a bit. Instead of setting the system metrics in the processHheaTable() function when the table cannot be found, we instead always fetch the system metrics at the very start of initializeHeightMetrics() and then override if there are no embedded bitmaps, and if the HHEA and OS/2 tables are available. This also reduces the number of virtual functions needed to sort out the height metrics. Fixes: QTBUG-83754 Change-Id: Ib9dc6fc6cf972e48209a4a272469d2b4bd1ebffe Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Use consistent vertical metrics on all platformsEskil Abrahamsen Blomfeldt2020-04-222-30/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt assumes that ascent+descent is the bounding height of the text, but for historical reasons, the ascent for some fonts will not contain the diacritics. On Windows, the preference is to use data from the OS/2 table which were explicitly invented to work around this, but on other platforms we are not respecting this table. This causes a text layout that looks fine on Windows to have overlapping characters on e.g. macOS. To make vertical metrics (ascent, descent, leading) consistent across all platforms, we don't blindly trust the values we get from the underlying font system, but apply in the following order: 1. If OS/2 table exists and USE_TYPO_METRICS flag is set, we use the typo metrics from OS/2 table 2. If OS/2 table exists and USE_TYPO_METRICS flag is not set, we use winAscent/winDescent from OS/2 and the line gap from HHEA table. 3. If no OS/2 table exists, we try to get ascent, descent and line gap from the HHEA table. 4. If the HHEA table does not exist (not an SFNT), we fall back to the system-provided metrics. (on macOS, we know the system-provided metrics will match the data in HHEA, so we skip parsing that table and use the data from CoreText if there is no OS/2 table). Task-number: QTBUG-80554 Change-Id: I41e6561a99513698c8e42451b4ec98bd5eb6892f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-082-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * macOS: Remove all use of deprecated Q_OS_OSX defineTor Arne Vestbø2020-04-032-2/+2
| | | | | | | | | | Change-Id: I49c285604694c93d37c9d1c7cd6d3b1509858319 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Darwin: get rid of Harfbuzz/CoreText specific codeKonstantin Ritt2020-03-241-5/+0
| | | | | | | | | | | | | | | | | | | | once CoreText shaper in Harfbuzz has been disabled, we do not need the hack-ish enablers to support it Follows-up 21c242f9fd27523d0016b821d0a962231c4bafa6 Change-Id: I40d598b2c9b57ca7953716a56e4e119b2fc06a9b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-111-0/+1
|\| | | | | | | Change-Id: Ibee5acec72a1a1769d4bc5f23f56c7dc8d4cf3cb
| * Add default arguments to QPainterPath methods using transformJarek Kobus2020-03-061-0/+1
| | | | | | | | | | | | | | Fixes: QTBUG-82602 Change-Id: Id82f145ffb33e6d4ef9b81282ad14657b1c8fbd0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Enabler: Store more properties of application fontsEskil Abrahamsen Blomfeldt2020-03-062-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The family name of a font is ambiguous and without additional information there is no way to separate one font from another inside that family. In order to make it possible to expose more info about application fonts from FontLoader in Qt Quick, we need to store them in the font database. Task-number: QTBUG-68829 Change-Id: I931e1c2c004437ac0a21d4d88e55d176de676f34 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | DirectWrite font db: Fix writing system detectionEskil Abrahamsen Blomfeldt2020-02-201-11/+1
|/ | | | | | | | | | The implementation here was accidentally missing from the first commit. We use the OS/2 table for determining the writing system support as intended by the font designer, and fall back to actually checking the Unicode ranges if the table should be missing. Change-Id: Ibfdf76c27f3a94eda2142b3e269a1ca30d4bc045 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Suppress deprecation warnings for QFont::ForceIntegerMetricsEskil Abrahamsen Blomfeldt2020-02-031-0/+30
| | | | | | | | | This flag has been deprecated, but until we remove it completely we need to continue supporting it, so we just suppress the warnings for now. Change-Id: I464e1cce42f78af76d46ec12eeb3e8d53d64d6a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CoreText: Fix getting system fonts on recent macOS/iOS versionsEskil Abrahamsen Blomfeldt2019-11-281-11/+0
| | | | | | | | | | | | | | | | | | | | | | We introduced a work-around for iOS 11 which breaks on more recent OS versions because we try to request meta-fonts by name instead of using the special system font descriptors. This would cause warnings on the console and Times New Roman when requesting e.g. the system fixed width font. When testing on iOS 12 without the work-around, we are no longer able to reproduce the original issue, so the assumption is that this problem has been resolved. Since iOS 11 is not a supported target for Qt 5.14 we can remove the work-around entirely. [ChangeLog][macOS/iOS] Fixed a bug where QFontDatabase::systemFont() would return the wrong fonts on macOS 10.15 and iOS 13. Fixes: QTBUG-79900 Change-Id: Ie375c8c2ab877d6d66e3696662c4939f639a6e9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-11-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf mkspecs/features/mac/default_post.prf src/corelib/tools/qsimd_p.h src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm util/qfloat16-tables/gen_qfloat16_tables.cpp Change-Id: If48fa8a3bc3c983706b609a6d3822cb67c1352a4
| * macOS: Fix regression with some characters in non-bundle appsEskil Abrahamsen Blomfeldt2019-10-161-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | .Noto Sans Univeral is a system-generated font, but for some undiscovered reason, it has different content when the app has a valid Info.plist versus when it does not. When there is no valid Info.plist, the font will act as a last-resort font and return a question mark glyph (index 4) for all characters it does not support. This was discovered with emojis, but I also verified that the font returns index 4 for a random character in the Cherokee range, in order to check if this was specific for emojis or not. This causes the font to take precedence over anything that follows it in the fallback list in apps that do not have a valid Info.plist, so it has to be at the end of the list. Note that in these apps, it will act as a last-resort font, so the glyphs returned for missing characters will be different from in a regular app bundle. But this seems safer than to exclude the font entirely, given that Noto Sans cover a large range of characters and might be needed. This font also refactors the look up of fonts to push to the end to avoid doing lots of unnecessary looping over the list. Fixes: QTBUG-78833 Change-Id: I38bec5d5941681c4b4586072f7811d31561e1051 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| * iOS: Fix showing emoji charactersEskil Abrahamsen Blomfeldt2019-10-161-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In d5abda313dab0f83873d34b7c4ddbe8d8a06dacf, we started populating meta-fallback-fonts in the font database because some that are returned as fallbacks are not in the main list of fonts on the system, so we would exclude them, thinking they were non-existent. But populating these fonts by name does not always work, as the system explicitly forbids requesting meta-fonts by name for some cases. One of these was the emoji font, which would resolve to a incompatible font descriptor and support for emojis would be broken. The fix is to retain the font descriptors we get from the system instead, since these are guaranteed to be refer to the correct font. This also saves us an unnecessary round-trip. Task-number: QTBUG-78821 Task-number: QTBUG-77467 Change-Id: Icb17ccc75811eebf03919437828ba71f3ef08938 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| * Fix vertical advance for printing on macOSAllan Sandfeld Jensen2019-10-111-1/+1
| | | | | | | | | | | | | | | | The Y coordinate needed to be reversed to produce expected results. Fixes: QTBUG-69803 Change-Id: If349912cd078d17ce69d207c2ed35cf781c1a14d Reviewed-by: Michael Brüning <michael.bruning@qt.io>
* | CoreText: Preserve font descriptors when resolving fallback familiesTor Arne Vestbø2019-10-142-75/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | From macOS 10.15 and iOS 13 forward it's not possible to create font descriptors for system fonts such as .AppleSystemUIFont based on the family name. This means we have to preserve the font descriptors we get from CoreText for fallback fonts, so that we can populate them along with the family name. Task-number: QTBUG-78821 Task-number: QTBUG-77467 Change-Id: Ifce01da65f90afb7dc2bc3005c3c5870b9c116de Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | CoreText: Use StyleHint as fallback when family is not foundTor Arne Vestbø2019-10-141-0/+17
| | | | | | | | | | | | Change-Id: I11fb6cafe9d41c38eac6ca0695c89f30f998f257 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | CoreText: Warn the user when family alias lookup slows down the applicationTor Arne Vestbø2019-10-082-6/+46
| | | | | | | | | | | | | | | | | | | | | | If the user specifies a font family in their application that doesn't exist in the system, or one that uses the localized family name, we will end up resolving the family alias for all fonts in the system, which typically adds 600-800ms of startup time. Let the user know when this happens. Change-Id: Id8d6f55028e37f681ec4a686df25d33240b5a30f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | CoreText: Use categorized loggingTor Arne Vestbø2019-10-041-4/+4
| | | | | | | | | | | | Change-Id: I4cfa6b0ef15adb7e600d66f4fe5b3dc17470f1c3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-301-0/+17
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qrandom.cpp src/corelib/io/qfileinfo.cpp src/corelib/kernel/qeventdispatcher_win.cpp src/corelib/kernel/qeventdispatcher_win_p.h src/gui/text/qfontdatabase.cpp src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm src/plugins/platforms/windows/qwindowsglcontext.cpp src/testlib/qtestcase.cpp Done-With: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I4893212471aa24be804c989a581810e2f714545c
| * iOS: Fix fallback fonts on iOS 13+Eskil Abrahamsen Blomfeldt2019-09-261-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since iOS 13, the cascade list for the default UI font contains meta-families for several writing systems, such as CJK. Since these font families were never populated to the database, we ignored them in Qt, and thus got missing glyphs for the characters in question. The fix is to make sure these fonts are populated in the database. It contains a partial backport of 922d195020d54d7e599d135f6a5e0338100e08f1, which adds the qt_isFamilyPopulated() accessor to allow us to check if the family has been populated in the font database. In Qt 5.14, there is public API for this in QPlatformFontDatabase, so this is a temporary resolution until then. Fixes: QTBUG-77467 Change-Id: Ia9ebb8a19ad2367eb764ae1496a52966b465336b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | CoreText: Modernize style hint fallback lookupTor Arne Vestbø2019-09-162-129/+73
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DefaultFontFallbacks.plist system file that we used for looking up style fallbacks does not exists in macOS 10.15, nor did it ever exists on iOS. Instead of relying on this file, we hard-code a set of default families, that we then look up the fallbacks for. The result of QFont::defaultFamily() on macOS is now: QFont::Helvetica --> "Helvetica" QFont::Times --> "Times New Roman" QFont::Courier --> "American Typewriter" QFont::OldEnglish --> "" QFont::System --> "Lucida Grande" QFont::AnyStyle --> "Lucida Grande" QFont::Cursive --> "Apple Chancery" QFont::Monospace --> "Menlo" QFont::Fantasy --> "Zapfino" And on iOS: QFont::Helvetica --> "Helvetica" QFont::Times --> "Times New Roman" QFont::Courier --> "American Typewriter" QFont::OldEnglish --> "" QFont::System --> "Helvetica" QFont::AnyStyle --> "Helvetica" QFont::Cursive --> "" QFont::Monospace --> "Menlo" QFont::Fantasy --> "Zapfino" Fixes: QTBUG-78240 Change-Id: Ie9bc13c9c1031d89f024199e4736a046c568a48d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support pen color with color fontsEskil Abrahamsen Blomfeldt2019-07-052-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Color fonts may also contain regular alphabet characters that should be rendered with the current pen. In Qt, however, these characters were drawn into the cache with a default pen color of black. Since all characters in a font is currently backed by the same cache, and it would require a lot of plumbing to get around this, a step in the right direction is to include the current pen color in the cache as long as it is an RGB cache. This means that drawing text with the color font with different pen colors will create different caches. There is no API to select font color on Freetype currently, but this problem has also not been observed there, as the fonts in question, with both regular and color glyphs, are not being detected as color fonts (so the text color will be correct). So Freetype will be left out for now. [ChangeLog][QtGui][Text] Fixed bug where regular text rendered with a color font would always display in black. Task-number: QTBUG-55096 Task-number: QTBUG-74761 Change-Id: Icc7dbf73241db1e7cc6a0de18c2de927aeecf713 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix stretched fonts with large pixel sizeEirik Aavitsland2019-03-271-9/+12
| | | | | | | | | | The Windows and Cocoa font engines ignored the stretch factor when the pixel size is so large that QPainterPath rendering is used instead of native. Fixes: QTBUG-14315 Change-Id: I93390528ac264452b7d6af7d39f49f4b0dd56279 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* CoreText: Fix inaccurate use of pixelSize when dealing with pointSizeTor Arne Vestbø2019-01-031-7/+9
| | | | | Change-Id: If46fa157bc921efd8145823c806b6b04f49233cf Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Only do gamma-corrected blending for subpixel-antialiased textTor Arne Vestbø2018-12-231-1/+1
| | | | | | | | | | | | | The grayscale font-smoothing doesn't expect to be linearly blended, as first assumed. Amended nativetext manual test to better diagnose the native Core Text behavior. Non-linear blending will result in the magenta text having a dark outline against the green background. Change-Id: I24a5f04eb1bd66fb98d621078d80ee9b80800827 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CoreText: Define font smoothing gamma along with rest of relevant codeTor Arne Vestbø2018-11-302-0/+6
| | | | | Change-Id: I57909603732de6c1a91c744a358968941e64acdf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CoreText: Base glyph fill color logic on font smoothing algorithmTor Arne Vestbø2018-11-301-25/+32
| | | | | Change-Id: I22be1efb1f91048745008ea1b49186b39367d122 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CoreText: Respect QFont::NoSubpixelAntialias when deciding glyph formatTor Arne Vestbø2018-11-301-1/+1
| | | | | | Change-Id: I846758bce2fd7536f9941b11f23fc0e5d5bc6f1b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CoreText: Remove handling of QFontEngineMulti's highByteTor Arne Vestbø2018-11-301-12/+5
| | | | | | | | | | | It's a leftover from when the Cocoa plugin used QFontEngineMulti exclusively. Nowadays QFontEngineMulti will strip out the highByte before calling into the real engine. Left an assert just in case.. Change-Id: I6cb26d20a908d7c3aaf096297fca160805fdb85b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix gamma-correction in QCoreTextFontEngine with MojaveAllan Sandfeld Jensen2018-11-301-2/+1
| | | | | | | | | | | The code was previously assuming font-smoothing was only used with A32 font antialiasing, so the corresponding gamma-correction was not performed. Task-number: QTBUG-71075 Task-number: QTBUG-71946 Change-Id: I68d8304cf18638239d8bfac32c67333f16ccc7bd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CoreText: Store glyphs in linear RGB when needed by blending algorithmTor Arne Vestbø2018-11-291-3/+4
| | | | | | | | | Instead of tying the linear-conversion to a specific function, we move it to imageForGlyph and base it on the premise for needing it. Change-Id: Ib8fc79ad419ef703abcb82785ac15d4c75fb98e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CoreText: Add font antialiasing and smoothing helper functionsTor Arne Vestbø2018-11-292-4/+27
| | | | | | | | | | | | The font smoothing helper in particular now takes into account whether or not we're dealing with color glyphs, in which case we shouldn't (or don't need to) smooth, and also makes sure the QFont::NoSubpixelAntialias style strategy doesn't affect font smoothing when we're dealing with non-subpixel-antialiased font smoothing, as on macOS 10.14. Change-Id: Ibd477158629402c55cafec31576b6d9901d184cf Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CoreText: Remove handling of the AppleAntiAliasingThreshold user defaultTor Arne Vestbø2018-11-292-23/+6
| | | | | | | | | | | | | | | | | | | | | | | The setting is not relevant for modern macOS applications, and none of the applications shipped with macOS today are affected by it. The only code path in macOS that picks it up is +[NSFont initialize] in the UIFoundation framework, storing it for later so that -[NSFont screenFont] and -[NSFont screenFontWithRenderingMode:] can use it, but these APIs are deprecated and we don't use them in Qt. Other NSFont code paths will not hit these APIs unless screen font substitution is enabled, something it hasn't been since OSX 10.7. https://preview.tinyurl.com/yctpfnqp Removing handling of this setting allows us to simplify the reasoning for whether or not antialiasing and font smoothing is enabled for a given engine. Change-Id: Ie2809052a1a0815d9bddedd4a6236eb6c898f993 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CoreText: Rename argument to imageForGlyph to better reflect how it's usedTor Arne Vestbø2018-11-291-2/+4
| | | | | | | | | | The 'aa' argument doesn't unconditionally enabled antialiasing, it just overrides the check that the pointSize is larger than the antialiasing threshold. If the styleStrategy has QFont::NoAntialias we still end up without antialiasing. Change-Id: I7130e7c68d883c2443756242e96790264f583b0f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CoreText: Add helper function to determine if a font has color glyphsTor Arne Vestbø2018-11-292-6/+11
| | | | | | | | Makes for clearer code than looking at the glyph format. Change-Id: Id6dd2a7851aac2a42cc27d9e2fb408ce9a5345d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* CoreText: Modernize font smoothing and antialiasing threshold detectionTor Arne Vestbø2018-11-293-74/+131
| | | | | | | | | | | | | | | The way macOS does font smoothing has changed in Mojave, and we need to take both this new algorithm into account, as well as support users who set legacy preferences to revert back to subpixel font smoothing. As a followup to this patch we will tweak some of the existing logic to take the new font smoothing algorithm into account, so this is just a first step. Change-Id: If37014c18515f406b8bb8194c9df7a75c2eb10fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* macOS: Share code for resolving CGImage bitmapInfor for a QImageTor Arne Vestbø2018-11-281-7/+2
| | | | | | | Removes assumptions about QImage format in a few places. Change-Id: I515701be53190429a48956c31986fa0804806406 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CoreText: Use QCFType instead of manual release/retainTor Arne Vestbø2018-11-281-7/+3
| | | | | Change-Id: I4925ec0e563e784f542fd44706a214771c6abd2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CoreText: Use QCFType to track CoreFoundation member variablesTor Arne Vestbø2018-11-282-14/+9
| | | | | | | | | The operator T() function of QAppleRefCounted should be const so that the underlying type can be accessed from const member functions just like the naked underlying type could. Change-Id: I0819c5795d28442a6ff4db2732e211b183574f9f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CoreText: Share code by using delegate constructorTor Arne Vestbø2018-11-282-6/+10
| | | | | Change-Id: If3d5d533f98552335517ef61cb748d0117fe3053 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CoreText: Simplify and share code for loading glyph advancesTor Arne Vestbø2018-11-282-40/+27
| | | | | | | | | | | | | | | | | | | | The function doesn't need the flags argument, nor does it need the ctfont or fontdef arguments if it's a normal const member function. It can also be used from QCoreTextFontEngine::stringToCMap(), instead of duplicating the code. This was originally the case before b4aa5d97 which improved surrogate pair handling, but for some reason the change introduced the duplicate code instead of just changing the arguments in the function call slightly. The use of 0xff000000 to skip certain glyphs looks dubious, and is probably related to QFontEngineMulti's use of the high byte to indicate which engine the glyph came from, but the multi engine strips this away before calling out to the concrete engine so it could potentially be removed in a later patch. Change-Id: I6c693595616da1b69fdbe3d7a31e392a8443369d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CoreText: Localize getTraitValue helper functionTor Arne Vestbø2018-11-281-11/+10
| | | | | | | | It's only used in a single function (twice), so let's keep it closer to the call site. Change-Id: I7f8ceadc380171237eef3fa6b03ccd6bc89e99af Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-192-6/+14
|\ | | | | | | | | | | | | Conflicts: src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm Change-Id: I66a08c770767a93cd26535689e3e7806486aab06
| * Modernize the "settings" featureLiang Qi2018-11-152-6/+14
| | | | | | | | | | | | Change-Id: I9b8a61ecb1413b513ae5c9e77d3ee1b3e8b6562c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | QtPlatformSupport/macOS: Remove superfluous freetype inclusionFriedemann Kleint2018-11-011-6/+0
| | | | | | | | | | | | | | | | | | | | | | freetype is included depending on configuration by the top level .pro file. Fix build warning: Makefile:1361: warning: ignoring old commands for target `.obj/qfontengine_ft.o' Change-Id: I0a0f111a841b368196633bbc0f9c698197f64bb2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Fix font weights on macOS 10.14Eskil Abrahamsen Blomfeldt2018-09-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On later versions of macOS, the font weight trait of fonts is a 64 bit double, not a 32 bit float, and on macOS 10.14, CFNumberGetValue() started returning false for values when the type conversion is lossy, like it is documented to. Therefore, we would end up without weight information in 10.14. The fix is to ask for a double instead, which works regardless of whether the CFNumber represents a 32-bit or 64-bit value. [ChangeLog][macOS][Text] Fixed font weights on macOS 10.14 Task-number: QTBUG-69955 Change-Id: Ia0577236ddc6b96f9231e6de7b1c49f7f8a837a6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Jason Haslam <jason@scitools.com>
* | macOS: Take application appearance into account when drawing glyphsTor Arne Vestbø2018-08-241-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | macOS 10.14 uses a new font smoothing algorithm that takes the fill color into account. This means our default approach of drawing white on black to produce the alpha map will result in non-native looking text when then drawn as black on white during the final blit. As a workaround we use the application's current appearance to decide whether to draw with white or black fill, and then invert the glyph image in the latter case, producing an alpha map. This covers the most common use-cases, but longer term we should propagate the fill color all the way from the paint engine, and include it in the key for the glyph cache. At the moment we do not react to changes in the application appearance, as that seems to be buggy in general in Qt (palette/style, e.g.), and those bugs need to be weeded before we can react to the theme change with confidence. Task-number: QTBUG-68824 Change-Id: Ibbfd49fcf3a091e454009c08159f46b3499e2bd0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>