Author: cazfi
Date: Sat Oct 15 07:17:41 2016
New Revision: 34141

URL: http://svn.gna.org/viewcvs/freeciv?rev=34141&view=rev
Log:
Corrections to the way gtk3-clients produce font css
- Size is considered pixels, not points
- Handle font style and weight

Reported by Jacob Nevins <jtn>

See patch #7162

Modified:
    branches/S2_6/client/gui-gtk-3.0/gui_stuff.c
    branches/S2_6/client/gui-gtk-3.22/gui_stuff.c

Modified: branches/S2_6/client/gui-gtk-3.0/gui_stuff.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/gui_stuff.c?rev=34141&r1=34140&r2=34141&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/gui_stuff.c        (original)
+++ branches/S2_6/client/gui-gtk-3.0/gui_stuff.c        Sat Oct 15 07:17:41 2016
@@ -1013,6 +1013,8 @@
   PangoFontDescription *desc;
   int size;
   const char *fam;
+  const char *style;
+  const char *weight;
 
   desc = pango_font_description_from_string(font_value);
 
@@ -1026,14 +1028,26 @@
     return;
   }
 
+  if (pango_font_description_get_style(desc) == PANGO_STYLE_ITALIC) {
+    style = "\n font-style: italic;";
+  } else {
+    style = "";
+  }
+
+  if (pango_font_description_get_weight(desc) >= 700) {
+    weight = "\n font-style: bold;";
+  } else {
+    weight = "";
+  }
+
   size = pango_font_description_get_size(desc);
 
   if (size != 0) {
-    str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpt;}",
-                          font_name, fam, size / PANGO_SCALE);
+    str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: 
%dpx;%s%s}",
+                          font_name, fam, size / PANGO_SCALE, style, weight);
   } else {
-    str = g_strdup_printf("#Freeciv #%s { font-family: %s; }",
-                          font_name, fam);
+    str = g_strdup_printf("#Freeciv #%s { font-family: %s;%s%s}",
+                          font_name, fam, style, weight);
   }
 
   pango_font_description_free(desc);

Modified: branches/S2_6/client/gui-gtk-3.22/gui_stuff.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/gui_stuff.c?rev=34141&r1=34140&r2=34141&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/gui_stuff.c       (original)
+++ branches/S2_6/client/gui-gtk-3.22/gui_stuff.c       Sat Oct 15 07:17:41 2016
@@ -1031,6 +1031,8 @@
   PangoFontDescription *desc;
   int size;
   const char *fam;
+  const char *style;
+  const char *weight;
 
   desc = pango_font_description_from_string(font_value);
 
@@ -1044,14 +1046,26 @@
     return;
   }
 
+  if (pango_font_description_get_style(desc) == PANGO_STYLE_ITALIC) {
+    style = "\n font-style: italic;";
+  } else {
+    style = "";
+  }
+
+  if (pango_font_description_get_weight(desc) >= 700) {
+    weight = "\n font-style: bold;";
+  } else {
+    weight = "";
+  }
+
   size = pango_font_description_get_size(desc);
 
   if (size != 0) {
-    str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpt;}",
-                          font_name, fam, size / PANGO_SCALE);
+    str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: 
%dpx;%s%s}",
+                          font_name, fam, size / PANGO_SCALE, style, weight);
   } else {
-    str = g_strdup_printf("#Freeciv #%s { font-family: %s; }",
-                          font_name, fam);
+    str = g_strdup_printf("#Freeciv #%s { font-family: %s;%s%s}",
+                          font_name, fam, style, weight);
   }
 
   pango_font_description_free(desc);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to