summarylogtreecommitdiffstats
path: root/0020-Use-a-more-reasonable-fallback-directory-for-fonts-o.patch
blob: 82a78051e246a5710531f6c09864f09d3cc29bfd (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
48
From 65d3e1750a83aa8cc61587fb7a83288fc8b9c33a 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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 314df8152c6..9be468f5077 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -361,8 +361,17 @@ void QPlatformFontDatabase::releaseHandle(void *handle)
 QString QPlatformFontDatabase::fontDir() const
 {
     QString fontpath = qEnvironmentVariable("QT_QPA_FONTDIR");
-    if (fontpath.isEmpty())
+    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
         fontpath = QLibraryInfo::path(QLibraryInfo::LibrariesPath) + "/fonts"_L1;
+#endif
+    }
 
     return fontpath;
 }
-- 
2.54.0