[gtk/master.no-pango-ft] gtkfontchooserwidget.c: Fix builds without PangoFT2




commit c68e5697f3f8ee1d5bfc11471d575db74af0769b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Sep 24 17:37:32 2020 +0800

    gtkfontchooserwidget.c: Fix builds without PangoFT2
    
    We need to build the bits that use PangoFT2 only if PangoFT2 is present, and
    for now since get_language_names() assumes the use of ISO codes and is
    currently only built with PangoFT2 is present, don't use it if PangoFT2
    does not exist.
    
    Add a TODO to add a Windows version of get_language_names() that uses
    Windows APIs instead of using ISO codes.

 gtk/gtkfontchooserwidget.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 171ef5c820..499b1fee4b 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -379,6 +379,7 @@ user_filter_cb (gpointer item,
 
       ret = TRUE;
 
+#ifdef HAVE_PANGOFT
       if (PANGO_IS_FC_FONT (font))
         {
           PangoLanguage **langs;
@@ -396,6 +397,7 @@ user_filter_cb (gpointer item,
                 }
             }
         }
+#endif
 
       g_object_unref (font);
       pango_font_description_free (desc);
@@ -572,6 +574,7 @@ maybe_update_preview_text (GtkFontChooserWidget *self,
   context = gtk_widget_get_pango_context (GTK_WIDGET (self));
   font = pango_context_load_font (context, desc);
 
+#if HAVE_PANGOFT
   if (PANGO_IS_FC_FONT (font))
     {
       PangoLanguage **languages;
@@ -658,6 +661,7 @@ found:
       gtk_font_chooser_widget_set_preview_text (self, sample);
       g_object_set_data (G_OBJECT (face), "gtk-sample-text", (gpointer)sample);
     }
+#endif
 
   g_object_unref (font);
 #endif
@@ -1056,6 +1060,7 @@ add_languages_from_font (GtkFontChooserWidget *self,
   context = gtk_widget_get_pango_context (GTK_WIDGET (self));
   font = pango_context_load_font (context, desc);
 
+#ifdef HAVE_PANGOFT
   if (PANGO_IS_FC_FONT (font))
     {
       GtkSelectionModel *model = gtk_list_view_get_model (GTK_LIST_VIEW (self->language_list));
@@ -1086,6 +1091,7 @@ add_languages_from_font (GtkFontChooserWidget *self,
             }
         }
     }
+#endif
 
   g_object_unref (font);
   pango_font_description_free (desc);
@@ -1181,8 +1187,14 @@ bind_lang_item (GtkSignalListItemFactory *factory,
 
   obj = gtk_list_item_get_item (GTK_LIST_ITEM (item));
   str = gtk_string_object_get_string (GTK_STRING_OBJECT (obj));
+
+  /* TODO: Add something like get_language_name() for Windows using Windows NLS APIs */
+#ifdef HAVE_PANGOFT
   language = pango_language_from_string (str);
   name = get_language_name (language);
+#else
+  name = str;
+#endif
 
   label = gtk_list_item_get_child (GTK_LIST_ITEM (item));
   gtk_label_set_label (GTK_LABEL (label), name);
@@ -1192,7 +1204,12 @@ static char *
 get_lang_name (gpointer    this,
                const char *lang)
 {
+  /* TODO: Add something like get_language_name() for Windows using Windows NLS APIs */
+#ifdef HAVE_PANGOFT
   return g_strdup (get_language_name (pango_language_from_string (lang)));
+#else
+  return g_strdup (lang);
+#endif
 }
 
 static void


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