commit bff21a4d8ca57b5428d3b7f5be58562b5ae3267e
Author: Máximo Castañeda <antiswen@yahoo.es>
Date:   Tue Oct 8 18:01:57 2024 +0200

    Qt5: support for variable fonts

diff --git a/dev-qt/qt5/patches/qtbase-5.15.16.patchset b/dev-qt/qt5/patches/qtbase-5.15.16.patchset
index 54fc4373e..8304565ba 100644
--- a/dev-qt/qt5/patches/qtbase-5.15.16.patchset
+++ b/dev-qt/qt5/patches/qtbase-5.15.16.patchset
@@ -1,4 +1,4 @@
-From 162eebac0d16049549b138401c9ba2a76bf3dd79 Mon Sep 17 00:00:00 2001
+From 2d9c956043963c98559ce78b3187bd1a66546efd Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
 Date: Mon, 11 Feb 2019 15:53:49 +1000
 Subject: Make sure libs are searched in the develop/ dir by CMake
@@ -23,7 +23,7 @@ index 64639f1..42ad698 100644
 2.45.2
 
 
-From 83f98bb3eeb34cca31d33a971dd3c5d8660c8481 Mon Sep 17 00:00:00 2001
+From 95fa9ba69ae8e85a0be6b97b7b7898de0fc3b2e8 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 11 Feb 2019 15:55:08 +1000
 Subject: Disable built-in haiku QPA plugin
@@ -48,7 +48,7 @@ index 23f838a..8ef1812 100644
 2.45.2
 
 
-From fae20ebc004c913a5a99411715b89acffbab748a Mon Sep 17 00:00:00 2001
+From 1161f60192ac7368ac5eb49d44d8cc988e4829b6 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 11 Feb 2019 15:56:12 +1000
 Subject: Fix QStandartPaths for Haiku
@@ -111,7 +111,7 @@ index 044d69f..1f255a9 100644
 2.45.2
 
 
-From eef708ff70cf863c17938ab0c034fa4ea4b4410f Mon Sep 17 00:00:00 2001
+From 61b51aed5c0c0d01be73482acf59e5ffec0c782b Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 11 Feb 2019 15:56:39 +1000
 Subject: QSslSocketPrivate::unixRootCertDirectories(): add ssl path for Haiku.
@@ -133,14 +133,14 @@ index 2a0b3a4..e0a1d6f 100644
 2.45.2
 
 
-From 56a4693f5855f2967256c8246e492c63dc7329c2 Mon Sep 17 00:00:00 2001
+From cbea7150c37ffadda60a0ab6aca0813ee0ca7f8a Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 11 Feb 2019 15:56:59 +1000
 Subject: Fix build for Haiku platform
 
 
 diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
-index 0c505fc..38fbe4f 100644
+index c70f279..15e5ad5 100644
 --- a/mkspecs/features/toolchain.prf
 +++ b/mkspecs/features/toolchain.prf
 @@ -263,7 +263,7 @@ isEmpty($${target_prefix}.INCDIRS) {
@@ -156,7 +156,7 @@ index 0c505fc..38fbe4f 100644
 2.45.2
 
 
-From caa7088f601f85ccf9657c6a4e76d18552cabff2 Mon Sep 17 00:00:00 2001
+From 68fec79096ab8130033fcae423ffc38881b9dc52 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 11 Feb 2019 15:57:54 +1000
 Subject: Fix endian detection
@@ -183,7 +183,7 @@ index 9bb306e..9f0ea58 100644
 2.45.2
 
 
-From 42d5ca1bb1bf9a8ac6af68855f4b3e73b8306dac Mon Sep 17 00:00:00 2001
+From 59a8ee4eb32955b1ce40ed8b4bd47b382f393a72 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Sat, 27 Apr 2019 17:47:23 +1000
 Subject: Add dnslookup query function for Haiku
@@ -271,7 +271,7 @@ index 0000000..0b387df
 2.45.2
 
 
-From b12bf7f7635d6d19e5ab3c8702d5de8ad6e29a42 Mon Sep 17 00:00:00 2001
+From c80f2aa2f2aa23f70190e72622013dbc5abe2481 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Wed, 27 May 2020 19:54:30 +1000
 Subject: Disable LibResolv for Haiku
@@ -294,7 +294,7 @@ index 73679c9..73ce64c 100644
 2.45.2
 
 
-From a5369dfc5f06af29695bfceaec19d38688a40259 Mon Sep 17 00:00:00 2001
+From 3d8f2f9dac4d44698902bf77f1ce078f6d7776c1 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Sun, 8 Sep 2019 00:17:19 +1000
 Subject: Don't use ifaddrs for Haiku
@@ -317,7 +317,7 @@ index e7889b6..1036ead 100644
 2.45.2
 
 
-From 263eb1866affb5d20dff84da8127678cc08887f7 Mon Sep 17 00:00:00 2001
+From 01acbb3f1fe2d7ed2de8a972b05a8cb179c1e927 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Sun, 8 Sep 2019 18:32:05 +1000
 Subject: Add platform plugins installer
@@ -383,7 +383,7 @@ index c7ff2a6..4d83bdc 100644
 2.45.2
 
 
-From d29dcbdeff35fb4bbf7b4098dd974b5298799738 Mon Sep 17 00:00:00 2001
+From 4780a01ff0427690b2d89b5ba7394b5b5aaf4ff4 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Wed, 27 May 2020 19:54:58 +1000
 Subject: Disable sharedmemory feature for bootstrap
@@ -407,7 +407,7 @@ index 24862a0..0d6df52 100644
 2.45.2
 
 
-From 6f413c134e7cd49c37bedafaba19b275ff6c10b2 Mon Sep 17 00:00:00 2001
+From e5d57d173397b0511cc169cb838d897a826c3f82 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Sun, 29 Dec 2019 18:13:19 +1000
 Subject: Fix build for x86_gcc2
@@ -430,7 +430,7 @@ index b663b8a..5ad2b12 100644
 2.45.2
 
 
-From bf11f042898f8e98d74ace015d8f18859dbf0f2b Mon Sep 17 00:00:00 2001
+From 6ad16a101367c2910217d7df9b5a86fc417e5868 Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Thu, 4 Jun 2020 23:11:17 +1000
 Subject: Implement QFilesystemWatcher for Haiku
@@ -826,7 +826,7 @@ index 0000000..8a8d75a
 2.45.2
 
 
-From 3609bcacf7af5d7f0f15f9a29999b2188deb2865 Mon Sep 17 00:00:00 2001
+From 0aa02cee41a02c57e869a6f36b79babb548c23ca Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Tue, 16 Jun 2020 18:06:57 +1000
 Subject: Don't use AF_INET6 for new sockets
@@ -853,7 +853,7 @@ index feb102b..07b65cc 100644
 2.45.2
 
 
-From 52ddd48661bf19773ebb1a43d9696cc32ca21c60 Mon Sep 17 00:00:00 2001
+From 2458f4b1cb0ff793326d71dd0a452a106703029e Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Mon, 5 Oct 2020 19:40:40 +1000
 Subject: Disable Haswell CPU feature for plugins
@@ -876,7 +876,7 @@ index 5cd21b6..2de224d 100644
 2.45.2
 
 
-From dfb96d82878f846fed5d90448122fe5a55fde6fc Mon Sep 17 00:00:00 2001
+From fc0f044c310122767189e31bba35fe07d3b50cce Mon Sep 17 00:00:00 2001
 From: Gerasim Troeglazov <3dEyes@gmail.com>
 Date: Sat, 9 Oct 2021 18:33:27 +1000
 Subject: QSharedMemory implementation for Haiku
@@ -1166,7 +1166,7 @@ index 0c13375..172ca95 100644
 2.45.2
 
 
-From 17e4477201bf92163c76078a0f999eaf155872cd Mon Sep 17 00:00:00 2001
+From cc806a0c5564fee06367ae829f8c1fcff480dbcc Mon Sep 17 00:00:00 2001
 From: PulkoMandy <pulkomandy@pulkomandy.tk>
 Date: Sat, 10 Aug 2024 17:05:17 +0200
 Subject: Fix build on Haiku R1/beta5
@@ -1203,7 +1203,7 @@ index 0159636..7ca58a4 100644
 2.45.2
 
 
-From 15e10a741f4254fa99ab6861edd3d3f627fce2a8 Mon Sep 17 00:00:00 2001
+From 38d0026c85df5f6af1b1f61cc4c267b174ce3aac Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
 Date: Fri, 23 Aug 2024 20:30:08 +0200
 Subject: SSL: try opening with OPENSSL_SHLIB_VERSION version number
@@ -1236,3 +1236,175 @@ index 6a9a3ef..6a24bfc 100644
 -- 
 2.45.2
 
+
+From b3957bc56c571228091f1f82942e157711404438 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= <antiswen@yahoo.es>
+Date: Thu, 3 Oct 2024 16:50:04 +0200
+Subject: FT Font db: load named styles of variable fonts
+
+
+diff --git a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
+index 56dcc61..0f453df 100644
+--- a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
++++ b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <ft2build.h>
+ #include FT_TRUETYPE_TABLES_H
++#include FT_MULTIPLE_MASTERS_H
+ #include FT_ERRORS_H
+ 
+ QT_BEGIN_NAMESPACE
+@@ -111,6 +112,85 @@ void QFreeTypeFontDatabase::releaseHandle(void *handle)
+ 
+ extern FT_Library qt_getFreetype();
+ 
++static FT_Error loadFace(FT_Library library, const QByteArray &fontData, const QByteArray &file, int index, FT_Face *face)
++{
++    FT_Error error;
++
++    if (!fontData.isEmpty()) {
++        error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, face);
++    } else {
++        error = FT_New_Face(library, file.constData(), index, face);
++    }
++
++    if (error != FT_Err_Ok) {
++        qDebug() << "FT_New_Face failed with index" << index << ':' << Qt::hex << error;
++    }
++    return error;
++}
++
++class AxisData
++{
++
++public:
++	AxisData(FT_Face face) : count(0), axis(nullptr)
++	{
++		FT_MM_Var* mm;
++		if (FT_Get_MM_Var(face, &mm) != 0)
++			return;
++
++		count = mm->num_axis;
++		if (count == 0) {
++			FT_Done_MM_Var(qt_getFreetype(), mm);
++			return;
++		}
++		axis = new quint32[count];
++
++		for (FT_UInt i = 0; i < count; i++) {
++			axis[i] = mm->axis[i].tag;
++		}
++
++		FT_Done_MM_Var(qt_getFreetype(), mm);
++	}
++
++	~AxisData() {
++		delete[] axis;
++	}
++
++    void Coordinates(FT_Face face, QFont::Weight& weight, QFont::Stretch& stretch, QFont::Style& style) {
++        if (count == 0)
++            return;
++
++        FT_Fixed coords[count];
++        FT_Get_Var_Design_Coordinates(face, count, coords);
++        for (unsigned int i = 0; i < count; i++) {
++            if (axis[i] == tagWeight) {
++                weight = QPlatformFontDatabase::weightFromInteger(coords[i] >> 16);
++            } else if (axis[i] == tagStretch) {
++                stretch = QFont::Stretch(coords[i] >> 16);
++            } else if (axis[i] == tagItalics) {
++                if (coords[i] > 0x8000)
++                    style = QFont::StyleItalic;
++                else
++                    style = QFont::StyleNormal;
++            } else if (axis[i] == tagSlant) {
++                if (coords[i] == 0)
++                    style = QFont::StyleNormal;
++                else
++                    style = QFont::StyleOblique;
++            }
++        }
++    }
++
++private:
++    static const int tagWeight = 'wght';
++    static const int tagStretch = 'wdth';
++    static const int tagItalics = 'ital';
++    static const int tagSlant = 'slnt';
++
++    unsigned int count;
++    quint32* axis;
++};
++
+ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
+ {
+     FT_Library library = qt_getFreetype();
+@@ -118,19 +198,29 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
+     int index = 0;
+     int numFaces = 0;
+     QStringList families;
++
++    FT_Face face;
++    if (loadFace(library, fontData, file, -1, &face) != FT_Err_Ok) {
++        return families;
++    }
++    numFaces = face->num_faces;
++    FT_Done_Face(face);
++
+     do {
+-        FT_Face face;
+-        FT_Error error;
+-        if (!fontData.isEmpty()) {
+-            error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
+-        } else {
+-            error = FT_New_Face(library, file.constData(), index, &face);
+-        }
+-        if (error != FT_Err_Ok) {
+-            qDebug() << "FT_New_Face failed with index" << index << ':' << Qt::hex << error;
++      if (loadFace(library, fontData, file, index, &face) != FT_Err_Ok) {
++          break;
++      }
++
++      AxisData variableData(face);
++      int variableCount = (face->style_flags & 0x7fff0000) >> 16;
++      FT_Done_Face(face);
++
++      int namedStyle = variableCount == 0 ? 0 : 1;
++      do {
++        int faceIndex = index | (namedStyle << 16);
++        if (loadFace(library, fontData, file, faceIndex, &face) != FT_Err_Ok) {
+             break;
+         }
+-        numFaces = face->num_faces;
+ 
+         QFont::Weight weight = QFont::Normal;
+ 
+@@ -225,9 +315,11 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
+         }
+ 
+         QString family = QString::fromLatin1(face->family_name);
++        if (namedStyle > 0)
++            variableData.Coordinates(face, weight, stretch, style);
+         FontFile *fontFile = new FontFile;
+         fontFile->fileName = QFile::decodeName(file);
+-        fontFile->indexValue = index;
++        fontFile->indexValue = faceIndex;
+ 
+ 
+         registerFont(family,QString::fromLatin1(face->style_name),QString(),weight,style,stretch,true,true,0,fixedPitch,writingSystems,fontFile);
+@@ -235,7 +327,9 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
+         families.append(family);
+ 
+         FT_Done_Face(face);
+-        ++index;
++        ++namedStyle;
++      } while (namedStyle <= variableCount);
++      ++index;
+     } while (index < numFaces);
+     return families;
+ }
+-- 
+2.45.2
+
diff --git a/dev-qt/qt5/qt5-5.15.16.recipe b/dev-qt/qt5/qt5-5.15.16.recipe
index 1d61ecc62..97db3307b 100644
--- a/dev-qt/qt5/qt5-5.15.16.recipe
+++ b/dev-qt/qt5/qt5-5.15.16.recipe
@@ -8,7 +8,7 @@ COPYRIGHT="2015-2020 The Qt Company Ltd."
 LICENSE="GNU LGPL v2.1
 	GNU LGPL v3
 	FDL"
-REVISION="1"
+REVISION="2"
 #baseURL="https://download.qt.io/official_releases/qt/${portVersion%.*}/$portVersion/submodules"
 baseURL="http://qt-mirror.dannhauer.de/official_releases/qt/${portVersion%.*}/$portVersion/submodules/"
 SOURCE_URI="https://github.com/qt/qt5/archive/v$portVersion-lts-lgpl.tar.gz"
