summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cao <nickcao@nichi.co>2023-03-23 13:33:22 +0800
committerGitHub <noreply@github.com>2023-03-23 13:33:22 +0800
commit72a8c4941580f6fb4540a736b39c907b1b8949f4 (patch)
tree449f4f9231d617b6ff45c2484c1a208e1edb0e12
parent165a7c6ea2d74514cf41021e936ffb818e938c5b (diff)
parentf4385d6010a6de5e78f495436917431654d09410 (diff)
downloadnixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar.gz
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar.bz2
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar.lz
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar.xz
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.tar.zst
nixpkgs-72a8c4941580f6fb4540a736b39c907b1b8949f4.zip
Merge pull request #222311 from NickCao/qt6-vf
qt6.qtbase: add patch to fix handling of variable fonts
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/noto-fonts-cjk-qt-default-weight.nix30
-rw-r--r--pkgs/development/libraries/qt-6/default.nix1
-rw-r--r--pkgs/development/libraries/qt-6/patches/qtbase-variable-fonts.patch26
4 files changed, 58 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index d767408ed16..2c34a3996d0 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -488,6 +488,7 @@ in {
   nomad = handleTest ./nomad.nix {};
   non-default-filesystems = handleTest ./non-default-filesystems.nix {};
   noto-fonts = handleTest ./noto-fonts.nix {};
+  noto-fonts-cjk-qt-default-weight = handleTest ./noto-fonts-cjk-qt-default-weight.nix {};
   novacomd = handleTestOn ["x86_64-linux"] ./novacomd.nix {};
   nscd = handleTest ./nscd.nix {};
   nsd = handleTest ./nsd.nix {};
diff --git a/nixos/tests/noto-fonts-cjk-qt-default-weight.nix b/nixos/tests/noto-fonts-cjk-qt-default-weight.nix
new file mode 100644
index 00000000000..678013cf3ab
--- /dev/null
+++ b/nixos/tests/noto-fonts-cjk-qt-default-weight.nix
@@ -0,0 +1,30 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
+  name = "noto-fonts-cjk-qt";
+  meta.maintainers = with lib.maintainers; [ oxalica ];
+
+  nodes.machine = {
+    imports = [ ./common/x11.nix ];
+    fonts = {
+      enableDefaultFonts = false;
+      fonts = [ pkgs.noto-fonts-cjk-sans ];
+    };
+  };
+
+  testScript =
+    let
+      script = pkgs.writers.writePython3 "qt-default-weight" {
+        libraries = [ pkgs.python3Packages.pyqt6 ];
+      } ''
+        from PyQt6.QtWidgets import QApplication
+        from PyQt6.QtGui import QFont, QRawFont
+
+        app = QApplication([])
+        f = QRawFont.fromFont(QFont("Noto Sans CJK SC", 20))
+
+        assert f.styleName() == "Regular", f.styleName()
+      '';
+    in ''
+      machine.wait_for_x()
+      machine.succeed("${script}")
+    '';
+})
diff --git a/pkgs/development/libraries/qt-6/default.nix b/pkgs/development/libraries/qt-6/default.nix
index 2577806b5c4..f0cfc91ac01 100644
--- a/pkgs/development/libraries/qt-6/default.nix
+++ b/pkgs/development/libraries/qt-6/default.nix
@@ -59,6 +59,7 @@ let
           ./patches/qtbase-qmake-mkspecs-mac.patch
           ./patches/qtbase-qmake-pkg-config.patch
           ./patches/qtbase-tzdir.patch
+          ./patches/qtbase-variable-fonts.patch
           # Remove symlink check causing build to bail out and fail.
           # https://gitlab.kitware.com/cmake/cmake/-/issues/23251
           (fetchpatch {
diff --git a/pkgs/development/libraries/qt-6/patches/qtbase-variable-fonts.patch b/pkgs/development/libraries/qt-6/patches/qtbase-variable-fonts.patch
new file mode 100644
index 00000000000..96952d1ad16
--- /dev/null
+++ b/pkgs/development/libraries/qt-6/patches/qtbase-variable-fonts.patch
@@ -0,0 +1,26 @@
+From 9ba9c690fb16188ff524b53def104e68e45cf5c3 Mon Sep 17 00:00:00 2001
+From: Nick Cao <nickcao@nichi.co>
+Date: Tue, 21 Mar 2023 15:48:49 +0800
+Subject: [PATCH] Deal with a font face at index 0 as Regular for Variable
+ fonts
+
+Reference: https://bugreports.qt.io/browse/QTBUG-111994
+---
+ src/gui/text/unix/qfontconfigdatabase.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp
+index 9b60cf2963..5a42ef6a68 100644
+--- a/src/gui/text/unix/qfontconfigdatabase.cpp
++++ b/src/gui/text/unix/qfontconfigdatabase.cpp
+@@ -554,6 +554,7 @@ void QFontconfigDatabase::populateFontDatabase()
+             FcObjectSetAdd(os, *p);
+             ++p;
+         }
++        FcPatternAddBool(pattern, FC_VARIABLE, FcFalse);
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
+-- 
+2.39.2
+