changeset 2260:cb24daa675a2

GTK3: Hopefully the last commit of the CSS font code changes. Clean up the code, so the CSS doesn't have any extra text or spaces. Also add some fonts with combinations of Italic and Bold for testing.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 27 Jan 2021 09:15:45 +0000
parents 5f1677cc32e9
children 281e2df2c022
files dwtest.c gtk3/dw.c
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Wed Jan 27 01:27:46 2021 +0000
+++ b/dwtest.c	Wed Jan 27 09:15:45 2021 +0000
@@ -1399,6 +1399,10 @@
         dw_listbox_append(fontname, "Helvetica");
         dw_listbox_append(fontname, "DejaVu Sans");
         dw_listbox_append(fontname, "New Times Roman");
+        dw_listbox_append(fontname, "New Times Roman Bold");
+        dw_listbox_append(fontname, "New Times Roman Italic");
+        dw_listbox_append(fontname, "New Times Roman Italic Bold");
+        dw_listbox_append(fontname, "New Times Roman Bold Italic");
         dw_box_pack_start(hbox, fontname, 150, -1, TRUE, FALSE, 1);
         dw_box_pack_start(notebookbox4, hbox, -1, -1, TRUE, FALSE, 1);
 
--- a/gtk3/dw.c	Wed Jan 27 01:27:46 2021 +0000
+++ b/gtk3/dw.c	Wed Jan 27 09:15:45 2021 +0000
@@ -2710,8 +2710,14 @@
       {
           int size = atoi(font);
 #if GTK_CHECK_VERSION(3,20,0)
-          newfont = g_strdup_printf("%s normal %s %dpx \"%s\"", Italic ? "italic " : "normal",
-                                    Bold ? "bold " : "normal", size, name);
+          int len = (Italic ? (Bold ? (Italic > Bold ? (Bold - name) : (Italic - name)) : (Italic - name)) : (Bold ? (Bold - name) : strlen(name)));
+          char *newname = alloca(len+1);
+          
+          memset(newname, 0, len+1);
+          strncpy(newname, name, len);
+          
+          newfont = g_strdup_printf("%s normal %s %dpx \"%s\"", Italic ? "italic" : "normal",
+                                    Bold ? "bold" : "normal", size, newname);
 #else
           newfont = g_strdup_printf("%s %d", name, size);
 #endif