Mercurial > dwindows
changeset 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 | 7ec60b650e5b |
children | 459426f31fb4 |
files | gtk/dw.c gtk3/dw.c |
diffstat | 2 files changed, 42 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/gtk/dw.c Tue Oct 18 08:39:31 2011 +0000 +++ b/gtk/dw.c Wed Oct 19 02:41:55 2011 +0000 @@ -2848,6 +2848,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: @@ -2863,7 +2881,6 @@ #endif GtkWidget *handle2 = handle; char *font = strdup(fontname); - char *name = strchr(font, '.'); int _locked_by_me = FALSE; gpointer data; @@ -2892,26 +2909,15 @@ gdkfont = gdk_font_load("fixed"); gtk_object_set_data(GTK_OBJECT(handle2), "_dw_gdkfont", (gpointer)gdkfont); #else - - /* 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); #endif /* Free old font name if one is allocated */ data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname"); + gtk_object_set_data(GTK_OBJECT(handle2), "_dw_fontname", (gpointer)font); if(data) free(data); - gtk_object_set_data(GTK_OBJECT(handle2), "_dw_fontname", (gpointer)font); #if GTK_MAJOR_VERSION > 1 pfont = pango_font_description_from_string(fontname); @@ -8554,6 +8560,7 @@ { char *oldfont = pixmap->font; pixmap->font = strdup(fontname); + _convert_font(pixmap->font); if(oldfont) free(oldfont); return DW_ERROR_NONE;
--- 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;