[hitori] Reduce the font size of painted cells



commit e04e7a6190f3e1c50831b022c6374a15a87d69ef
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Oct 31 11:54:07 2010 +0000

    Reduce the font size of painted cells
    
    This makes the game more accessible, as the paint state of cells is no longer
    purely indicated by the cells' text colour. It also makes the board easier to
    read.

 src/interface.c |   17 ++++++++++++++---
 src/main.c      |    5 +++++
 src/main.h      |    3 +++
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/interface.c b/src/interface.c
index 56c3c3c..a1497ec 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -27,7 +27,8 @@
 #include "interface.h"
 #include "rules.h"
 
-#define FONT_SCALE 0.9
+#define NORMAL_FONT_SCALE 0.9
+#define PAINTED_FONT_SCALE 0.6
 #define TAG_OFFSET 0.75
 #define TAG_RADIUS 0.25
 #define HINT_FLASHES 6
@@ -51,6 +52,7 @@ hitori_create_interface (Hitori *hitori)
 {
 	GError *error = NULL;
 	GtkBuilder *builder;
+	GtkStyle *style;
 
 	builder = gtk_builder_new ();
 
@@ -86,6 +88,11 @@ hitori_create_interface (Hitori *hitori)
 
 	g_object_unref (builder);
 
+	/* Set up font descriptions for the drawing area */
+	style = gtk_widget_get_style (hitori->drawing_area);
+	hitori->normal_font_desc = pango_font_description_copy (style->font_desc);
+	hitori->painted_font_desc = pango_font_description_copy (style->font_desc);
+
 	/* Reset the timer */
 	hitori_reset_timer (hitori);
 
@@ -117,7 +124,8 @@ hitori_draw_cb (GtkWidget *drawing_area, cairo_t *cr, Hitori *hitori)
 
 	/* Work out the cell size and scale all text accordingly */
 	cell_size = board_width / hitori->board_size;
-	pango_font_description_set_absolute_size (style->font_desc, cell_size * FONT_SCALE * 0.8 * PANGO_SCALE);
+	pango_font_description_set_absolute_size (hitori->normal_font_desc, cell_size * NORMAL_FONT_SCALE * 0.8 * PANGO_SCALE);
+	pango_font_description_set_absolute_size (hitori->painted_font_desc, cell_size * PAINTED_FONT_SCALE * 0.8 * PANGO_SCALE);
 
 	/* Centre the board */
 	hitori->drawing_area_x_offset = (area_width - board_width) / 2;
@@ -183,7 +191,10 @@ hitori_draw_cb (GtkWidget *drawing_area, cairo_t *cr, Hitori *hitori)
 			layout = pango_cairo_create_layout (cr);
 
 			pango_layout_set_text (layout, text, -1);
-			pango_layout_set_font_description (layout, style->font_desc);
+			if (hitori->board[iter.x][iter.y].status & CELL_PAINTED)
+				pango_layout_set_font_description (layout, hitori->painted_font_desc);
+			else
+				pango_layout_set_font_description (layout, hitori->normal_font_desc);
 
 			pango_layout_get_pixel_size (layout, &text_width, &text_height);
 			cairo_move_to (cr,
diff --git a/src/main.c b/src/main.c
index d64e5f0..69074f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -201,6 +201,11 @@ hitori_quit (Hitori *hitori)
 	if (hitori->window != NULL)
 		gtk_widget_destroy (hitori->window);
 
+	if (hitori->normal_font_desc != NULL)
+		pango_font_description_free (hitori->normal_font_desc);
+	if (hitori->painted_font_desc != NULL)
+		pango_font_description_free (hitori->painted_font_desc);
+
 	if (gtk_main_level () > 0)
 		gtk_main_quit ();
 
diff --git a/src/main.h b/src/main.h
index c8fe02d..c487874 100644
--- a/src/main.h
+++ b/src/main.h
@@ -73,6 +73,9 @@ typedef struct {
 	guint drawing_area_x_offset;
 	guint drawing_area_y_offset;
 
+	PangoFontDescription *normal_font_desc;
+	PangoFontDescription *painted_font_desc;
+
 	guchar board_size;
 	HitoriCell **board;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]