[gtk/pango2-windows: 2/5] gdk/win32: WIP Port to Pango2




commit c3b9938174cfa3885ec859d1ef0405051690f024
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 5 17:28:48 2022 +0800

    gdk/win32: WIP Port to Pango2

 gdk/win32/gdkkeys-win32.c     |  8 ++++----
 gdk/win32/gdkproperty-win32.c | 36 +++++++++++++++++++++++-------------
 2 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c
index 9c70eee483..092d6c23cd 100644
--- a/gdk/win32/gdkkeys-win32.c
+++ b/gdk/win32/gdkkeys-win32.c
@@ -732,10 +732,10 @@ get_hkl_direction (HKL hkl)
 #endif
     case LANG_FARSI:
       /* Others? */
-      return PANGO_DIRECTION_RTL;
+      return PANGO2_DIRECTION_RTL;
 
     default:
-      return PANGO_DIRECTION_LTR;
+      return PANGO2_DIRECTION_LTR;
     }
 }
 
@@ -745,7 +745,7 @@ gdk_win32_keymap_get_direction (GdkKeymap *gdk_keymap)
   GdkWin32Keymap *keymap;
   HKL             active_hkl;
   
-  g_return_val_if_fail (GDK_IS_KEYMAP (gdk_keymap), PANGO_DIRECTION_LTR);
+  g_return_val_if_fail (GDK_IS_KEYMAP (gdk_keymap), PANGO2_DIRECTION_LTR);
 
   keymap = GDK_WIN32_KEYMAP (gdk_keymap);
 
@@ -777,7 +777,7 @@ gdk_win32_keymap_have_bidi_layouts (GdkKeymap *gdk_keymap)
   for (group = 0; group < keymap->layout_handles->len; group++)
     {
       if (get_hkl_direction (g_array_index (keymap->layout_handles, HKL,
-                             group)) == PANGO_DIRECTION_RTL)
+                             group)) == PANGO2_DIRECTION_RTL)
         have_rtl = TRUE;
       else
         have_ltr = TRUE;
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index 0debd4dacb..f2526d60b0 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -27,12 +27,28 @@
 #include <string.h>
 #include <stdlib.h>
 #include <glib/gprintf.h>
-#include <pango/pangowin32.h>
+#include <pango2/pangodwrite-fontmap.h>
 
 #include "gdkdisplayprivate.h"
 #include "gdkprivate-win32.h"
 #include "gdkwin32.h"
 
+static Pango2FontDescription *
+_get_font_description_from_logfontw (LOGFONTW *lfw)
+{
+  Pango2FontDescription *desc;
+
+  desc = pango2_font_description_new ();
+
+  if (lfw->lfWeight == FW_DONTCARE)
+    pango2_font_description_set_weight (desc, PANGO2_WEIGHT_NORMAL);
+  else
+    /* The PangoWeight values PANGO_WEIGHT_* map exactly to Windows FW_*. */
+    pango2_font_description_set_weight (desc, (Pango2Weight)lfw->lfWeight);
+
+  return desc;
+}
+
 static char *
 _get_system_font_name (HDC hdc)
 {
@@ -41,15 +57,18 @@ _get_system_font_name (HDC hdc)
   char *result, *font_desc_string;
   int logpixelsy;
   int font_size;
+  Pango2FontMap *font_map;
 
   ncm.cbSize = sizeof(NONCLIENTMETRICSW);
   if (!SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0))
     return NULL;
 
+  font_map = PANGO2_FONT_MAP (pango2_direct_write_font_map_new ());
   logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
-  font_desc = pango_win32_font_description_from_logfontw (&ncm.lfMessageFont);
-  font_desc_string = pango_font_description_to_string (font_desc);
-  pango_font_description_free (font_desc);
+  font_desc = pango2_direct_write_font_map_get_font_description_from_logfontw (font_map,
+                                                                              &ncm.lfMessageFont);
+  font_desc_string = pango2_font_description_to_string (font_desc);
+  pango2_font_description_free (font_desc);
 
   /* https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogfonta */
   font_size = -MulDiv (ncm.lfMessageFont.lfHeight, 72, logpixelsy);
@@ -192,15 +211,6 @@ _gdk_win32_get_setting (const char *name,
 
       if (font_name)
         {
-          /* The pango font fallback list got fixed during 1.43, before that
-           * using anything but "Segoe UI" would lead to a poor glyph coverage */
-          if (pango_version_check (1, 43, 0) != NULL &&
-              g_ascii_strncasecmp (font_name, "Segoe UI", strlen ("Segoe UI")) != 0)
-            {
-              g_free (font_name);
-              return FALSE;
-            }
-
           GDK_NOTE(MISC, g_print("gdk_screen_get_setting(\"%s\") : %s\n", name, font_name));
           g_value_take_string (value, font_name);
           return TRUE;


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