From 2c309f71705449607592bb4588bcc56223da897b Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Date: Wed, 15 Jan 2025 15:39:16 +0100
Subject: [PATCH] FontConfig: Fix detection of color fonts

There were two mistakes in the code that intended to detect
if a specific font was a color font in the FontConfig database.

1. The "int n" parameter in FcPatternGet*() is not an array size,
but an index, so it should be 0 and not 1.

2. We need to add FC_COLOR to the list of properties in our pattern
when populating the database, otherwise we will just fail to match
it and none of the system fonts will be listed as color.

Pick-to: 6.9
Fixes: QTBUG-132377
Change-Id: Ib3c112e8a354abacd05679c62283a1f1abfb40ee
---

diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp
index de6618f..20794ed 100644
--- a/src/gui/text/unix/qfontconfigdatabase.cpp
+++ b/src/gui/text/unix/qfontconfigdatabase.cpp
@@ -478,7 +478,7 @@
 
     FcBool colorFont = false;
 #ifdef FC_COLOR
-    FcPatternGetBool(pattern, FC_COLOR, 1, &colorFont);
+    FcPatternGetBool(pattern, FC_COLOR, 0, &colorFont);
 #endif
 
     // Note: stretch should really be an int but registerFont incorrectly uses an enum
@@ -577,6 +577,9 @@
 #if FC_VERSION >= 20297
             FC_CAPABILITY,
 #endif
+#if defined(FC_COLOR)
+            FC_COLOR,
+#endif
             (const char *)nullptr
         };
         const char **p = properties;
