changeset 379:2e5f3cb38d19

Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent are determined even if the string to be rendered doesn't have an ascent/descent.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 29 Apr 2003 10:52:47 +0000
parents 12b3980a41a2
children fcb52d773ed2
files gtk/dw.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sun Apr 27 23:01:55 2003 +0000
+++ b/gtk/dw.c	Tue Apr 29 10:52:47 2003 +0000
@@ -5422,10 +5422,16 @@
 			font = gdk_font_load("fixed");
 		if(font)
 		{
-			gint ascent, descent, width;
+			gint ascent, descent, width, junk_ascent, junk_descent, junk_width;
 			int index = _find_thread_index(dw_thread_id());
 
-			gdk_text_extents(font, text, strlen(text), NULL, NULL, &width, &ascent, &descent);
+			/* gdk_text_extents() calculates ascent and descent based on the string, so
+			 * a string without a character with a descent or without an ascent will have
+			 * incorrect ascent/descent values
+			 */
+			gdk_text_extents(font, text, strlen(text), NULL, NULL, &width, &junk_ascent, &junk_descent);
+			/* force ascent/descent to be maximum values */
+			gdk_text_extents(font, "Xg", 2, NULL, NULL, &junk_width, &ascent, &descent);
 			if(!_transparent[index])
 			{
 				GdkGC *gc2 = NULL;