[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1037256: debian-installer: GUI font for Japanese was incorrectly rendered



FYI: I've updated a PoC patch. Mainly the explanation of patch was updated.

0001-frontend-avoid-han-unification-for-Japanese-take2.patch

>From b388a793b19a0afeb9110a6dd7633b1734ffb759 Mon Sep 17 00:00:00 2001
From: Kentaro Hayashi <kenhys@gmail.com>
Date: Wed, 7 Jun 2023 17:50:40 +0900
Subject: [PATCH] frontend: avoid han-unification for Japanese

Because of Han unification, wrong font typefaces are
rendered by default when you choose Japanese language
using GUI installer.

Most of typefaces are correct, but there are wrong
typefaces (Simplified Chinese) which is used for widget rendering.

This issue [1] will not be solved by using DroidSansFallback.ttf
(which is shipped by fonts-android udeb) for Japanese.

It means that we need to switch font itself which contains Japanese
typeface to fix this issue.

Prerequisite for verifying issue:

  Step1: Make fonts-motoya-l-cedar-udeb
         which ships MotoyaLCedar (MTLc3m.ttf)
  Step2: Install fonts-motoya-l-cedar with listing it
         in installer/build/pkg-lists/gtk-common.
  Step3: Apply this patch for cdebconf package

[1] Your Code Displays Japanese Wrong
https://heistak.github.io/your-code-displays-japanese-wrong/

Signed-off-by: Kentaro Hayashi <kenhys@gmail.com>
---
 src/modules/frontend/gtk/di.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/modules/frontend/gtk/di.c b/src/modules/frontend/gtk/di.c
index a6cb38f1..4c036cd5 100644
--- a/src/modules/frontend/gtk/di.c
+++ b/src/modules/frontend/gtk/di.c
@@ -355,6 +355,30 @@ static GtkTextDirection get_text_direction(struct frontend * fe)
     return direction;
 }
 
+/** Set language specific gtk-font-name explicitly
+ *
+ * @param fe
+ */
+static void set_language_specific_font_name(struct frontend *fe)
+{
+    char * language = cdebconf_gtk_get_text(fe, "debconf/language",
+                                            "Current language for installer");
+    if (language && strcmp(language, "ja") == 0) {
+        /* font-android-udeb is used for CJK, but because of Han unification,
+         * some of font typefaces are rendered as Simplified Chinese, not
+         * Japanese.
+         * This issue is not solved by using DroidSansFallback.ttf
+         * (fonts-android-udeb), thus another font which contains
+         * Japanese font typeface must be used for Japanese.
+         *
+         * MotoyaLCedar is suitable font which can be bundled as
+         * fonts-motoya-l-cedar-udeb.
+         * [1] https://wiki.debian.org/DebianInstaller/GUIFonts
+         */
+        gtk_rc_parse_string('gtk-font-name = "MotoyaLCedar"');
+    }
+}
+
 /** Update various settings with the current language settings.
  *
  * @param fe cdebconf frontend
@@ -365,6 +389,9 @@ static void refresh_language(struct frontend * fe)
     gtk_rc_reparse_all();
     /* Adapt text direction. */
     gtk_widget_set_default_direction(get_text_direction(fe));
+
+    /* Override specific font name */
+    set_language_specific_font_name(fe);
 }
 
 /** Update what needs to be updated on a new user interaction.
-- 
2.40.1


Reply to: