gucharmap r1745 - trunk/gucharmap



Author: chpe
Date: Sun Mar 23 13:01:53 2008
New Revision: 1745
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1745&view=rev

Log:
Make --font work again. Bug #506752, based on a patch by Jared Moore.


Modified:
   trunk/gucharmap/gucharmap-mini-fontsel.c
   trunk/gucharmap/main.c

Modified: trunk/gucharmap/gucharmap-mini-fontsel.c
==============================================================================
--- trunk/gucharmap/gucharmap-mini-fontsel.c	(original)
+++ trunk/gucharmap/gucharmap-mini-fontsel.c	Sun Mar 23 13:01:53 2008
@@ -288,10 +288,18 @@
 gucharmap_mini_font_selection_set_font_name (GucharmapMiniFontSelection *fontsel,
                                              const gchar *fontname)
 {
-  pango_font_description_free (fontsel->font_desc);
 
-  fontsel->font_desc = pango_font_description_from_string (fontname);
+  PangoFontDescription *fd = pango_font_description_from_string (fontname);
+  if (pango_font_description_get_family (fd) == NULL)
+    {
+      const gchar *fam = pango_font_description_get_family (fontsel->font_desc);
+      pango_font_description_set_family (fd, fam);
+    }
 
+  pango_font_description_free (fontsel->font_desc);
+  
+  fontsel->font_desc = fd;
+  
   update_font_familiy_combo (fontsel);
     
   /* treat oblique and italic both as italic */

Modified: trunk/gucharmap/main.c
==============================================================================
--- trunk/gucharmap/main.c	(original)
+++ trunk/gucharmap/main.c	Sun Mar 23 13:01:53 2008
@@ -34,6 +34,7 @@
   GdkScreen *screen;
   gint monitor;
   GdkRectangle rect;
+  GucharmapMiniFontSelection *fontsel;
   GError *error = NULL;
   gchar *font = NULL;
   GOptionEntry goptions[] =
@@ -69,33 +70,32 @@
   gdk_screen_get_monitor_geometry (screen, monitor, &rect);
   gtk_window_set_default_size (GTK_WINDOW (window), rect.width * 9/16, rect.height * 9/16);
 
-  gucharmap_settings_add_window (GTK_WINDOW (window));
-
+  /* FIXMEchpe: move all this into gucharmap-window */
   /* make the starting font 50% bigger than the default font */
-  if (font == NULL) /* font could be set by command line option */
-    {
-      GucharmapMiniFontSelection *fontsel = gucharmap_window_get_mini_font_selection (GUCHARMAP_WINDOW (window));
-      gint default_size = PANGO_PIXELS (2.0 * pango_font_description_get_size (window->style->font_desc));
-      gucharmap_mini_font_selection_set_default_font_size (fontsel, default_size);
-
-      font = gucharmap_settings_get_font ();
-      if (font)
-        {
-          PangoFontDescription *fd = pango_font_description_from_string (font);
-
-          /* revert to default font size */
-          if (0 == pango_font_description_get_size (fd))
-            gucharmap_mini_font_selection_reset_font_size (fontsel);
-	  else
-	    gucharmap_mini_font_selection_set_font_name (fontsel, font);
-
-          pango_font_description_free (fd);
-	  g_free (font);
-        }
-      else
-        gucharmap_mini_font_selection_reset_font_size (fontsel);
+  fontsel = gucharmap_window_get_mini_font_selection (GUCHARMAP_WINDOW (window));
+  gucharmap_mini_font_selection_set_default_font_size (fontsel,
+                                                       PANGO_PIXELS (2.0 * pango_font_description_get_size (window->style->font_desc)));
+
+  if (font) {
+    PangoFontDescription *font_desc;
+    int size;
+
+    font_desc = pango_font_description_from_string (font);
+    gucharmap_mini_font_selection_set_font_name (fontsel, font);
+
+    size = pango_font_description_get_size (font_desc);
+    if (0 != size) {
+      gucharmap_mini_font_selection_set_default_font_size (fontsel,
+                                                           PANGO_PIXELS (size));
     }
 
+    pango_font_description_free (font_desc);
+    g_free (font);
+  }
+
+  gucharmap_mini_font_selection_reset_font_size (fontsel);
+
+  gucharmap_settings_add_window (GTK_WINDOW (window));
   gtk_widget_show (window);
 
   gtk_main ();



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