summaryrefslogtreecommitdiff
path: root/gtk/gtkfontsel.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>1999-09-30 16:59:08 +0000
committerTor Lillqvist <tml@src.gnome.org>1999-09-30 16:59:08 +0000
commit74d88d870aea60625b8f1ed522e86faa223ca487 (patch)
tree4cfa8e1dcd0a1cd4a29a4f55f416de1577378bbb /gtk/gtkfontsel.c
parent41be586333346e3aa3e75922d8e4de49501df9a6 (diff)
downloadgtk+-74d88d870aea60625b8f1ed522e86faa223ca487.tar.gz
On Win32, expand possible hex escapes in the font family (put there by
1999-09-30 Tor Lillqvist <tml@iki.fi> * gtk/gtkfontsel.c (gtk_font_selection_get_xlfd_field): On Win32, expand possible hex escapes in the font family (put there by logfont_to_xlfd if the font name isn't a legal XLFD font family, mainly if it contains slashes). (gtk_font_selection_create_xlfd): On Win32, add hex escapes here, too.
Diffstat (limited to 'gtk/gtkfontsel.c')
-rw-r--r--gtk/gtkfontsel.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index 9fbf067870..1171c6eb1a 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -2666,7 +2666,8 @@ logfont_to_xlfd (const LOGFONT *lfp,
int point_size;
static int logpixelsy = 0;
gchar facename[LF_FACESIZE*3];
- gchar *p, *q;
+ gchar *p;
+ const gchar *q;
if (logpixelsy == 0)
{
@@ -3575,6 +3576,9 @@ gtk_font_selection_get_xlfd_field (const gchar *fontname,
{
const gchar *t1, *t2;
gint countdown, len, num_dashes;
+#ifdef GDK_WINDOWING_WIN32
+ gchar *p;
+#endif
if (!fontname)
return NULL;
@@ -3605,6 +3609,23 @@ gtk_font_selection_get_xlfd_field (const gchar *fontname,
#ifdef GDK_WINDOWING_X11
/* Convert to lower case. */
g_strdown (buffer);
+#elif defined (GDK_WINDOWING_WIN32)
+ /* Check for hex escapes in font family */
+ if (field_num == XLFD_FAMILY)
+ {
+ p = buffer;
+ while (*p)
+ {
+ if (*p == '%' && isxdigit (p[1]) && isxdigit (p[2]))
+ {
+ guint c;
+ sscanf (p+1, "%2x", &c);
+ *p = c;
+ strcpy (p+1, p+3);
+ }
+ p++;
+ }
+ }
#endif
}
else
@@ -3630,7 +3651,11 @@ gtk_font_selection_create_xlfd (gint size,
{
gchar buffer[16];
gchar *pixel_size = "*", *point_size = "*", *fontname;
-
+ gchar *fam = family;
+#ifdef GDK_WINDOWING_WIN32
+ gchar *p, *q;
+#endif
+
if (size <= 0)
return NULL;
@@ -3640,10 +3665,27 @@ gtk_font_selection_create_xlfd (gint size,
else
point_size = buffer;
+#ifdef GDK_WINDOWING_WIN32
+ fam = g_malloc (strlen (family) * 3 + 1);
+ p = fam;
+ q = family;
+ while (*q)
+ {
+ if (*q == '-' || *q == '*' || *q == '?' || *q == '%')
+ p += sprintf (p, "%%%.02x", *q);
+ else
+ *p++ = *q;
+ q++;
+ }
+ *p = '\0';
+#endif
fontname = g_strdup_printf ("-%s-%s-%s-%s-%s-*-%s-%s-*-*-%s-*-%s",
- foundry, family, weight, slant,
+ foundry, fam, weight, slant,
set_width, pixel_size, point_size,
spacing, charset);
+#ifdef GDK_WINDOWING_WIN32
+ g_free (fam);
+#endif
return fontname;
}