diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-03-17 10:00:38 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-03-22 10:17:45 +0100 |
commit | 107d14825ae7a4f3ca2a99724bbb8a1d5c13b399 (patch) | |
tree | f5aac7fa7c5a0854fb7487dcd1ac231a7104f574 /src | |
parent | dde0c0a45c3a2b2835b5ae165dc8c04d8e1dd604 (diff) |
Disable Harfbuzz/CoreText hotfix on older macOS/iOS versions
Since the new default font on macOS 11 and iOS 14 does not have the
AAT tables we usually check for, we added a check for TRAK as well,
otherwise we would end up applying the wrong kerning rules to the
font in these newer versions of the operating systems.
However, this introduced a regression on older versions when letter
spacing was set. This basically just disables the ligature features
when shaping, so the reason is not fully understood, but the
assumption is that it exposes a bug in the CoreText shaper backend
in Harfbuzz which was previously hidden.
The pragmatic fix for this is a second hotfix which disables the
previous one on older OS versions, since:
A. The original bug does not occur on older versions.
B. Newer versions of Harfbuzz (and therefore Qt) does not exhibit
the problem since this code path is no longer used.
To do this we also need to rename the hb-coretext.cc file to .mm
to enable using the Objective-C APIs.
This is all pretty ugly, but it is not upstreamed anywhere and has
limited lifespan.
[ChangeLog][macOS/iOS] Fixed a regression when combining letter
spacing with the default font on macOS 10.15 and lower or iOS 13
or lower.
Fixes: QTBUG-91764
Change-Id: I50c8ad08d51899635418aeaa38230bbeab5c5ef7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro | 2 | ||||
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-coretext.mm (renamed from src/3rdparty/harfbuzz-ng/src/hb-coretext.cc) | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro index 332955e2be..1969938932 100644 --- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro +++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro @@ -169,7 +169,7 @@ contains(SHAPERS, coretext) { DEFINES += HAVE_CORETEXT SOURCES += \ - $$PWD/src/hb-coretext.cc + $$PWD/src/hb-coretext.mm HEADERS += \ $$PWD/src/hb-coretext.h diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.mm index 11b6deee04..185f73cd68 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.mm @@ -35,6 +35,7 @@ #include "hb-coretext.h" #include <math.h> +#include <Foundation/Foundation.h> typedef bool (*qt_get_font_table_func_t) (void *user_data, unsigned int tag, unsigned char *buffer, unsigned int *length); @@ -1324,7 +1325,21 @@ _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) { static const hb_tag_t tags[] = {HB_CORETEXT_TAG_MORX, HB_CORETEXT_TAG_MORT, HB_CORETEXT_TAG_KERX, HB_CORETEXT_TAG_TRAK}; - for (unsigned int i = 0; i < ARRAY_LENGTH (tags); i++) + // Disable macOS 11 / iOS 14 specific hotfix for Qt on older versions, since it caused a + // regression. (Note: This code should not been upstreamed and is only applicable to Qt 5.15.x). + NSInteger majorVersion = NSProcessInfo.processInfo.operatingSystemVersion.majorVersion; + NSInteger hotfixMinimumVersion; +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE + hotfixMinimumVersion = 14; +#else + hotfixMinimumVersion = 11; +#endif + + unsigned int arrayLength = ARRAY_LENGTH (tags); + if (majorVersion < hotfixMinimumVersion) + arrayLength--; + + for (unsigned int i = 0; i < arrayLength; i++) { hb_blob_t *blob = face->reference_table (tags[i]); if (hb_blob_get_length (blob)) |