diff gtk3/dw.c @ 1240:3bc6244279c0

Attempt at converting DW style font names on GTK for dw_pixmap_set_font().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 19 Oct 2011 02:41:55 +0000
parents db21c0081387
children 3a2ffe3a7eae
line wrap: on
line diff
--- a/gtk3/dw.c	Tue Oct 18 08:39:31 2011 +0000
+++ b/gtk3/dw.c	Wed Oct 19 02:41:55 2011 +0000
@@ -2506,6 +2506,24 @@
 {
 }
 
+/* Convert DW style font to pango style */
+void _convert_font(char *font)
+{
+   char *name = strchr(font, '.');
+
+   /* Detect Dynamic Windows style font name...
+    * Format: ##.Fontname
+    * and convert to a Pango name
+    */
+   if(name && isdigit(*font))
+   {
+       int size = atoi(font);
+       *name = 0;
+       name++;
+       sprintf(font, "%s %d", name, size);
+   }
+}
+
 /*
  * Sets the font used by a specified window (widget) handle.
  * Parameters:
@@ -2517,7 +2535,6 @@
    PangoFontDescription *pfont;
    GtkWidget *handle2 = handle;
    char *font = strdup(fontname);
-   char *name = strchr(font, '.');
    int _locked_by_me = FALSE;
    gpointer data;
 
@@ -2536,24 +2553,14 @@
          handle2 = tmp;
    }
 
-   /* Detect Dynamic Windows style font name...
-    * Format: ##.Fontname
-    * and convert to a Pango name
-    */
-   if(name && isdigit(*font))
-   {
-       int size = atoi(font);
-       *name = 0;
-       name++;
-       sprintf(font, "%s %d", name, size);
-   }
+   _convert_font(font);
 
    /* Free old font name if one is allocated */
    data = g_object_get_data(G_OBJECT(handle2), "_dw_fontname");
+   g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font);
    if(data)
       free(data);
 
-   g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font);
    pfont = pango_font_description_from_string(fontname);
 
    if(pfont)
@@ -7270,6 +7277,7 @@
     {
          char *oldfont = pixmap->font;
          pixmap->font = strdup(fontname);
+         _convert_font(pixmap->font);
          if(oldfont)
              free(oldfont);
          return DW_ERROR_NONE;