Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12197) set the city descriptions font size
Home

[Freeciv-Dev] (PR#12197) set the city descriptions font size

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12197) set the city descriptions font size
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 9 Feb 2005 20:35:20 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12197 >

This patch allows the city descriptions font size to be set from the 
tileset.  This replaces the useless old xaw-specific font strings, and 
allows the tilesets to actually change the font (which is needed for 
larger and perhaps for smaller tilesets).

It seems the current values are 10 for both fonts in gui-gtk-2.0 so 
that's what the defaults are.  For the rest it's up to the GUI authors 
to implement the changes.  I wrote a simple implementation for gui-gtk-2.0.

-jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.233
diff -u -r1.233 tilespec.c
--- client/tilespec.c   9 Feb 2005 23:17:46 -0000       1.233
+++ client/tilespec.c   10 Feb 2005 04:35:00 -0000
@@ -44,6 +44,7 @@
 
 #include "dialogs_g.h"
 #include "graphics_g.h"
+#include "gui_main_g.h"
 #include "mapview_g.h"         /* for update_map_canvas_visible */
 
 #include "civclient.h"         /* for get_client_state() */
@@ -79,8 +80,7 @@
 bool is_isometric;
 int hex_width, hex_height;
 
-char *city_names_font;
-char *city_productions_font_name;
+static int city_names_font_size, city_productions_font_size;
 
 int num_tiles_explode_unit=0;
 
@@ -385,14 +385,6 @@
 ***********************************************************************/
 static void tilespec_free_toplevel(void)
 {
-  if (city_names_font) {
-    free(city_names_font);
-    city_names_font = NULL;
-  }
-  if (city_productions_font_name) {
-    free(city_productions_font_name);
-    city_productions_font_name = NULL;
-  }
   if (main_intro_filename) {
     free(main_intro_filename);
     main_intro_filename = NULL;
@@ -895,13 +887,14 @@
   unit_offset_y = secfile_lookup_int_default(file, 0,
                                             "tilespec.unit_offset_y");
 
-  c = secfile_lookup_str_default(file, "10x20", "tilespec.city_names_font");
-  city_names_font = mystrdup(c);
+  city_names_font_size
+    = secfile_lookup_int_default(file, 10, "tilespec.city_names_font_size");
 
-  c =
-      secfile_lookup_str_default(file, "8x16",
-                                "tilespec.city_productions_font");
-  city_productions_font_name = mystrdup(c);
+  city_productions_font_size
+    = secfile_lookup_int_default(file, 10,
+                                "tilespec.city_productions_font_size");
+  set_city_names_font_sizes(city_names_font_size,
+                           city_productions_font_size);
 
   c = secfile_lookup_str(file, "tilespec.main_intro_file");
   main_intro_filename = tilespec_gfx_filename(c);
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.101
diff -u -r1.101 tilespec.h
--- client/tilespec.h   6 Feb 2005 22:11:11 -0000       1.101
+++ client/tilespec.h   10 Feb 2005 04:35:00 -0000
@@ -377,14 +377,6 @@
 extern bool is_isometric;
 extern int hex_width, hex_height;
 
-/* name of font to use to draw city names on main map */
-
-extern char *city_names_font;
-
-/* name of font to use to draw city productions on main map */
-
-extern char *city_productions_font_name;
-
 extern int num_tiles_explode_unit;
 
 struct Sprite *load_sprite(const char *tag_name);
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.159
diff -u -r1.159 gui_main.c
--- client/gui-gtk/gui_main.c   22 Jan 2005 19:45:40 -0000      1.159
+++ client/gui-gtk/gui_main.c   10 Feb 2005 04:35:00 -0000
@@ -168,6 +168,17 @@
                                         gpointer data);
 static gint timer_callback(gpointer data);
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 /**************************************************************************
   Print extra usage information, including one line help on each option,
   to stderr. 
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.107
diff -u -r1.107 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       5 Feb 2005 19:46:32 -0000       1.107
+++ client/gui-gtk-2.0/gui_main.c       10 Feb 2005 04:35:01 -0000
@@ -96,6 +96,7 @@
 GtkWidget *top_vbox;
 GtkWidget *top_notebook, *bottom_notebook;
 
+int city_names_font_size = 0, city_productions_font_size = 0;
 PangoFontDescription *main_font;
 PangoFontDescription *city_productions_font;
 
@@ -216,6 +217,26 @@
 gboolean show_conn_popup(GtkWidget *view, GdkEventButton *ev, gpointer data);
 static gboolean quit_dialog_callback(void);
 
+
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  /* This function may be called before the fonts are allocated.  So we
+   * save the values for later. */
+  city_names_font_size = my_city_names_font_size;
+  city_productions_font_size = my_city_productions_font_size;
+  if (main_font) {
+    pango_font_description_set_size(main_font,
+                                   PANGO_SCALE * city_names_font_size);
+    pango_font_description_set_size(city_productions_font,
+                                   PANGO_SCALE * city_productions_font_size);
+  }
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -1122,6 +1143,8 @@
   g_object_ref(style);
   city_productions_font = style->font_desc;
 
+  set_city_names_font_sizes(city_names_font_size, city_productions_font_size);
+
   fill_bg_gc = gdk_gc_new(root_window);
 
   /* for isometric view. always create. the tileset can change at run time. */
Index: client/gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.88
diff -u -r1.88 gui_main.c
--- client/gui-mui/gui_main.c   22 Nov 2004 07:54:46 -0000      1.88
+++ client/gui-mui/gui_main.c   10 Feb 2005 04:35:01 -0000
@@ -98,6 +98,17 @@
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 /**************************************************************************
   Print extra usage information, including one line help on each option,
   to stderr.
Index: client/gui-sdl/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_main.c,v
retrieving revision 1.47
diff -u -r1.47 gui_main.c
--- client/gui-sdl/gui_main.c   20 Nov 2004 21:27:17 -0000      1.47
+++ client/gui-sdl/gui_main.c   10 Feb 2005 04:35:01 -0000
@@ -144,6 +144,17 @@
 
 /* =========================================================== */
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 /**************************************************************************
   Print extra usage information, including one line help on each option,
   to stderr. 
Index: client/gui-stub/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/gui_main.c,v
retrieving revision 1.14
diff -u -r1.14 gui_main.c
--- client/gui-stub/gui_main.c  5 Dec 2004 04:23:19 -0000       1.14
+++ client/gui-stub/gui_main.c  10 Feb 2005 04:35:02 -0000
@@ -35,6 +35,17 @@
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 /**************************************************************************
   Do any necessary pre-initialization of the UI, if necessary.
 **************************************************************************/
Index: client/gui-win32/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/gui_main.c,v
retrieving revision 1.37
diff -u -r1.37 gui_main.c
--- client/gui-win32/gui_main.c 21 Jan 2005 02:14:08 -0000      1.37
+++ client/gui-win32/gui_main.c 10 Feb 2005 04:35:02 -0000
@@ -108,6 +108,17 @@
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 /**************************************************************************
 
 **************************************************************************/
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.99
diff -u -r1.99 gui_main.c
--- client/gui-xaw/gui_main.c   1 Dec 2004 22:15:23 -0000       1.99
+++ client/gui-xaw/gui_main.c   10 Feb 2005 04:35:02 -0000
@@ -206,6 +206,17 @@
 XtIntervalId x_interval_id;
 Atom wm_delete_window;
 
+/****************************************************************************
+  Called by the tileset code to set the font size that should be used to
+  draw the city names and productions.
+****************************************************************************/
+void set_city_names_font_sizes(int my_city_names_font_size,
+                              int my_city_productions_font_size)
+{
+  freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
+  /* PORTME */
+}
+
 #ifdef UNUSED
 /**************************************************************************
 ...
Index: client/include/gui_main_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/gui_main_g.h,v
retrieving revision 1.10
diff -u -r1.10 gui_main_g.h
--- client/include/gui_main_g.h 3 Sep 2004 04:22:36 -0000       1.10
+++ client/include/gui_main_g.h 10 Feb 2005 04:35:02 -0000
@@ -17,6 +17,9 @@
 
 #include "fc_types.h"
 
+void set_city_names_font_sizes(int city_names_font_size,
+                              int city_productions_font_size);
+
 void ui_init(void);
 void ui_main(int argc, char *argv[]);
 void update_conn_list_dialog(void);
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.27
diff -u -r1.27 isotrident.tilespec
--- data/isotrident.tilespec    6 Feb 2005 22:11:11 -0000       1.27
+++ data/isotrident.tilespec    10 Feb 2005 04:35:02 -0000
@@ -35,11 +35,9 @@
 unit_offset_x = 21
 unit_offset_y = 13
 
-; Font to use to draw city names:
-city_names_font = "9x15bold"
-
-; Font to use to draw city productions:
-city_productions_font = "6x13"
+; Fonts to use to draw city names and productions:
+city_names_font_size = 10
+city_productions_font_size = 10
 
 ; These are special because they get freed and reloaded
 ; as required:
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.29
diff -u -r1.29 trident.tilespec
--- data/trident.tilespec       6 Feb 2005 22:11:11 -0000       1.29
+++ data/trident.tilespec       10 Feb 2005 04:35:02 -0000
@@ -31,11 +31,9 @@
 flag_offset_x = 0
 flag_offset_y = 0
 
-; Font to use to draw city names:
-city_names_font = "9x15bold"
-
-; Font to use to draw city productions:
-city_productions_font = "6x13"
+; Fonts to use to draw city names and productions:
+city_names_font_size = 10
+city_productions_font_size = 10
 
 ; These are special because they get freed and reloaded
 ; as required:
Index: data/trident_shields.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident_shields.tilespec,v
retrieving revision 1.19
diff -u -r1.19 trident_shields.tilespec
--- data/trident_shields.tilespec       8 Feb 2005 18:16:53 -0000       1.19
+++ data/trident_shields.tilespec       10 Feb 2005 04:35:02 -0000
@@ -34,11 +34,9 @@
 ; Use darkness style 3 (15 sprites)
 darkness_style = 4
 
-; Font to use to draw city names:
-city_names_font = "9x15bold"
-
-; Font to use to draw city productions:
-city_productions_font = "6x13"
+; Fonts to use to draw city names and productions:
+city_names_font_size = 10
+city_productions_font_size = 10
 
 ; These are special because they get freed and reloaded
 ; as required:

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12197) set the city descriptions font size, Jason Short <=