summarylogtreecommitdiffstats
path: root/0020-Use-a-more-reasonable-fallback-directory-for-fonts-o.patch
blob: d3a154629ac72a6537016b3239e653d972790ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 52d66d60b0b8b7083a87a1b229efc9248789cd90 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Mon, 1 Dec 2025 11:26:18 +0100
Subject: [PATCH 20/24] Use a more reasonable fallback directory for fonts on
 Windows

The existing fallback points to a directory that no longer exists by default
which causes warnings like the following on run-time:

```
QFontDatabase: Cannot find font directory C:/msys64/mingw64/qt6/libs/fonts.
Note that Qt no longer ships fonts. Deploy some (from
https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
```

From MINGW-packages commit 6fa4cbd657c7853d664247636675192be74b281d.

Change-Id: Ia5789b64e06952875e4efa014e92a61bcb50b394
---
 src/gui/text/qplatformfontdatabase.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 85c7438d9f6..f1745d66f2f 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -362,9 +362,17 @@ QString QPlatformFontDatabase::fontDir() const
 {
     QString fontpath = qEnvironmentVariable("QT_QPA_FONTDIR");
     if (fontpath.isEmpty()) {
+#ifdef Q_OS_WIN
+        QString windir = qEnvironmentVariable("WINDIR");
+        if (windir.isEmpty())
+            fontpath = "C:/Windows/Fonts"_L1;
+        else
+            fontpath = windir + "/Fonts"_L1;
+#else
         QStringList paths = QLibraryInfo::paths(QLibraryInfo::LibrariesPath);
         if (!paths.isEmpty())
             fontpath = paths.takeFirst() + "/fonts"_L1;
+#endif
     }
 
     return fontpath;
-- 
2.56.0