Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] fontconfig: fix subpixel rendering in GTK applications
@ 2020-07-30 21:59 andry-dev
  2020-07-30 23:34 ` [PR REVIEW] " ahesford
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: andry-dev @ 2020-07-30 21:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1712 bytes --]

There is a new pull request by andry-dev against master on the void-packages repository

https://github.com/andry-dev/void-packages fontconfig
https://github.com/void-linux/void-packages/pull/23962

fontconfig: fix subpixel rendering in GTK applications
This PR hopefully closes #21429.

The first commit converts the freetype's ClearType patch to a build option; while it is not necessary for the fix, @ericonr suggested it and it seems helpful.

The second commit provides a `fontconfig` configuration file that sets `lcdfilter` to `lcddefault`, fixing the issue.
The config file provides a system-wide default without enforcing it, so the user/desktop environment can override the option in `~/.config/fontconfig/fonts.conf`. This doesn't break existing users: if they set the option anywhere then that is respected, if they didn't then subpixel rendering will work as intended.
Setting `lcdfilter` to `lcdlight` in `fonts.conf` is equivalent to the default "Harmony" engine, so it's the same as not having the patch in the first place.

## Why is this needed anyway?

A year ago I opened #13296, which enables ClearType in `freetype`. When testing it I had `lcdfilter` already set to `lcddefault` in my own `fonts.conf` and I didn't think about setting the option by default system-wide, so I never noticed any regression. Sorry for that.

I wrote the patch because without it I couldn't read text effortlessly, the font wasn't "right" for me. Major distros (Ubuntu, Debian and Fedora from the top of my head) have it enabled by default because, _generally speaking_, font rendering feels better with it.

A patch file from https://github.com/void-linux/void-packages/pull/23962.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-fontconfig-23962.patch --]
[-- Type: text/x-diff, Size: 4567 bytes --]

From 0c1b063a4ebb12cde8b8badfbc632f1821bc1e1b Mon Sep 17 00:00:00 2001
From: andry-dev <peketribal2@gmail.com>
Date: Thu, 30 Jul 2020 22:24:53 +0000
Subject: [PATCH 1/2] freetype: move ClearType patch to a build option

---
 .../freetype/patches/enable-subpixel-rendering.patch  | 11 -----------
 srcpkgs/freetype/template                             | 11 ++++++++++-
 2 files changed, 10 insertions(+), 12 deletions(-)
 delete mode 100644 srcpkgs/freetype/patches/enable-subpixel-rendering.patch

diff --git a/srcpkgs/freetype/patches/enable-subpixel-rendering.patch b/srcpkgs/freetype/patches/enable-subpixel-rendering.patch
deleted file mode 100644
index 5cba955ca2c..00000000000
--- a/srcpkgs/freetype/patches/enable-subpixel-rendering.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- include/freetype/config/ftoption.h
-+++ include/freetype/config/ftoption.h
-@@ -126,7 +126,7 @@
-    * macro is not defined, FreeType offers alternative LCD rendering
-    * technology that produces excellent output without LCD filtering.
-    */
--/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-+#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
-
-   /**************************************************************************
diff --git a/srcpkgs/freetype/template b/srcpkgs/freetype/template
index f279908c442..fa0fe0afb6a 100644
--- a/srcpkgs/freetype/template
+++ b/srcpkgs/freetype/template
@@ -1,7 +1,7 @@
 # Template file for 'freetype'
 pkgname=freetype
 version=2.10.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-freetype-config"
 hostmakedepends="pkg-config"
@@ -12,6 +12,15 @@ license="GPL-2.0-or-later, FTL"
 homepage="https://www.freetype.org/"
 distfiles="${NONGNU_SITE}/${pkgname}/${pkgname}-${version}.tar.xz"
 checksum=1543d61025d2e6312e0a1c563652555f17378a204a61e99928c9fcef030a2d8b
+build_options="cleartype"
+desc_option_cleartype="Enable Microsoft's subpixel rendering (ClearType)"
+build_options_default="cleartype"
+
+pre_build() {
+	if [ yes = "$(vopt_if cleartype yes)" ]; then
+		vsed -i ${wrksrc}/include/freetype/config/ftoption.h -e 's@/\* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING \*/@#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING@'
+	fi
+}
 
 post_install() {
 	vlicense docs/LICENSE.TXT docs/FTL.TXT

From b3b494b6493c17833a94918eb77fbbe733696a4b Mon Sep 17 00:00:00 2001
From: andry-dev <peketribal2@gmail.com>
Date: Thu, 30 Jul 2020 22:30:33 +0000
Subject: [PATCH 2/2] fontconfig: set lcdfilter by default

---
 .../files/11-lcdfilter-default.conf           | 21 +++++++++++++++++++
 srcpkgs/fontconfig/template                   |  4 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/fontconfig/files/11-lcdfilter-default.conf

diff --git a/srcpkgs/fontconfig/files/11-lcdfilter-default.conf b/srcpkgs/fontconfig/files/11-lcdfilter-default.conf
new file mode 100644
index 00000000000..712d141d068
--- /dev/null
+++ b/srcpkgs/fontconfig/files/11-lcdfilter-default.conf
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+  <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+    <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
+  </its:rules>
+
+  <description>Use lcddefault as default for LCD filter</description>
+<!--  Use lcddefault as default for LCD filter -->
+  <match target="pattern">
+    <!--
+      This configuration is available on the major desktop environments.
+      We shouldn't overwrite it with "assign" unconditionally.
+      Most clients may picks up the first value only. so using "append"
+      may simply works to avoid it.
+    -->
+    <edit mode="append" name="lcdfilter">
+      <const>lcddefault</const>
+    </edit>
+  </match>
+</fontconfig> 
diff --git a/srcpkgs/fontconfig/template b/srcpkgs/fontconfig/template
index 18504e4503f..12284db10a3 100644
--- a/srcpkgs/fontconfig/template
+++ b/srcpkgs/fontconfig/template
@@ -1,7 +1,7 @@
 # Template file for 'fontconfig'
 pkgname=fontconfig
 version=2.13.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--enable-static --enable-docs --with-cache-dir=/var/cache/${pkgname}"
 hostmakedepends="gperf pkg-config"
@@ -23,6 +23,8 @@ post_install() {
 	if [ "$CROSS_BUILD" ]; then
 		sed -i 's,\(Cflags: -I${includedir}\).*,\1,g' ${DESTDIR}/usr/lib/pkgconfig/fontconfig.pc
 	fi
+	vinstall ${FILESDIR}/11-lcdfilter-default.conf 644 usr/share/fontconfig/conf.avail
+	ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf ${DESTDIR}/etc/fonts/conf.d/
 	vlicense COPYING
 }
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-07-20 19:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 21:59 [PR PATCH] fontconfig: fix subpixel rendering in GTK applications andry-dev
2020-07-30 23:34 ` [PR REVIEW] " ahesford
2020-07-30 23:34 ` ahesford
2020-07-30 23:34 ` ahesford
2020-07-30 23:34 ` ahesford
2020-07-30 23:34 ` ahesford
2020-07-30 23:34 ` ahesford
2020-07-30 23:34 ` ahesford
2020-07-31  0:05 ` ericonr
2020-07-31  0:06 ` ericonr
2020-07-31  0:15 ` ahesford
2020-07-31  8:17 ` [PR PATCH] [Updated] " andry-dev
2021-03-23 15:57 ` prez
2021-03-23 21:46 ` [PR PATCH] [Updated] " andry-dev
2021-03-23 21:49 ` andry-dev
2022-04-18  2:11 ` github-actions
2022-07-18  2:13 ` github-actions
2022-07-18 13:19 ` prez
2022-07-19 20:30 ` leahneukirchen
2022-07-20 19:01 ` the-maldridge
2022-07-20 19:01 ` [PR PATCH] [Closed]: " the-maldridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).