mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Better typography for ppd paper names
These often contain a <num>x<num> string, which we can display nicer by rendering it as <num>×<num>.
This commit is contained in:
parent
63efdca223
commit
558c6ea6b5
@ -271,6 +271,28 @@ gtk_paper_size_new (const gchar *name)
|
||||
return size;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
improve_displayname (const gchar *name)
|
||||
{
|
||||
gchar *p, *p1, *p2, *s;
|
||||
|
||||
p = strrchr (name, 'x');
|
||||
if (p && p != name &&
|
||||
g_ascii_isdigit (*(p - 1)) &&
|
||||
g_ascii_isdigit (*(p + 1)))
|
||||
{
|
||||
p1 = g_strndup (name, p - name);
|
||||
p2 = g_strdup (p + 1);
|
||||
s = g_strconcat (p1, "×", p2, NULL);
|
||||
g_free (p1);
|
||||
g_free (p2);
|
||||
}
|
||||
else
|
||||
s = g_strdup (name);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_paper_size_new_from_ppd:
|
||||
* @ppd_name: a PPD paper name
|
||||
@ -301,6 +323,7 @@ gtk_paper_size_new_from_ppd (const gchar *ppd_name,
|
||||
char *freeme;
|
||||
GtkPaperSize *size;
|
||||
int i;
|
||||
char *display_name;
|
||||
|
||||
lookup_ppd_name = ppd_name;
|
||||
|
||||
@ -332,7 +355,9 @@ gtk_paper_size_new_from_ppd (const gchar *ppd_name,
|
||||
}
|
||||
|
||||
name = g_strconcat ("ppd_", ppd_name, NULL);
|
||||
size = gtk_paper_size_new_custom (name, ppd_display_name, width, height, GTK_UNIT_POINTS);
|
||||
display_name = improve_displayname (ppd_display_name);
|
||||
size = gtk_paper_size_new_custom (name, display_name, width, height, GTK_UNIT_POINTS);
|
||||
g_free (display_name);
|
||||
g_free (name);
|
||||
|
||||
out:
|
||||
|
Loading…
Reference in New Issue
Block a user