aboutsummaryrefslogtreecommitdiff
path: root/gtk.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-04-27 19:44:34 +0000
committerSimon Tatham <anakin@pobox.com>2005-04-27 19:44:34 +0000
commit3d4f276f1fabeea8a2d94e8a72db765f1dcc4316 (patch)
treea1f5797adbbce469986046120a5e5875c36985e8 /gtk.c
parent37a0c1af6a8b6d4f9ab2ab2adb3218b44bc64a04 (diff)
downloadpuzzles-3d4f276f1fabeea8a2d94e8a72db765f1dcc4316.zip
puzzles-3d4f276f1fabeea8a2d94e8a72db765f1dcc4316.tar.gz
puzzles-3d4f276f1fabeea8a2d94e8a72db765f1dcc4316.tar.bz2
puzzles-3d4f276f1fabeea8a2d94e8a72db765f1dcc4316.tar.xz
Fix inconsistent vertical centring of text in GTK (and update Solo's
todo list, which complained about this because Solo was the only puzzle noticeably affected). [originally from svn r5694]
Diffstat (limited to 'gtk.c')
-rw-r--r--gtk.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gtk.c b/gtk.c
index 1a74d87..5690eae 100644
--- a/gtk.c
+++ b/gtk.c
@@ -219,11 +219,24 @@ void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
{
int lb, rb, wid, asc, desc;
- gdk_string_extents(fe->fonts[i].font, text,
+ /*
+ * Measure vertical string extents with respect to the same
+ * string always...
+ */
+ gdk_string_extents(fe->fonts[i].font,
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
&lb, &rb, &wid, &asc, &desc);
if (align & ALIGN_VCENTRE)
y += asc - (asc+desc)/2;
+ /*
+ * ... but horizontal extents with respect to the provided
+ * string. This means that multiple pieces of text centred
+ * on the same y-coordinate don't have different baselines.
+ */
+ gdk_string_extents(fe->fonts[i].font, text,
+ &lb, &rb, &wid, &asc, &desc);
+
if (align & ALIGN_HCENTRE)
x -= wid / 2;
else if (align & ALIGN_HRIGHT)