Jason Tackaberry wrote:
On Fri, 2005-12-30 at 17:31 +0100, Kim Woelders wrote:
I think you are right that something is wrong somewhere around here.
However, this patch breaks stuff for certain fonts (w becomes too small,
IIRC).
Ok. I have to plead a bit of ignorance when it comes to font metrics.
But if your problem is with the width, and my original problem is with
the height, then the naive assumption is that if we take the horizontal
advance and the height as returned by imlib_font_query_size(), we should
be ok.
I've coded this up and it looks ok on all of my tests. Some review and
testing is clearly needed. The patch is attached.
Regards,
Jason.
------------------------------------------------------------------------
--- imlib2-1.2.1.009.orig/src/lib/font_draw.c 2005-12-30 10:49:31.000000000
-0500
+++ imlib2-1.2.1.009/src/lib/font_draw.c 2005-12-30 11:42:11.000000000
-0500
@@ -78,7 +78,8 @@
DATA32 *data, col;
int nx, ny;
- imlib_font_query_advance(fn, text, &w, &h);
+ imlib_font_query_advance(fn, text, &w, NULL);
+ imlib_font_query_size(fn, text, NULL, &h);
data = malloc(w * h * sizeof(DATA32));
if (!data)
I have committed attached patch. It does the same thing as your patch #2
but avoids recalculating the width.
It is possibly also equivalent to rasters original fix if "inset" were
subtracted in stead of added.
I think there are some more or less related bugs in the imlib2 font
metrics department.
imlib_get_font_descent (imlib_font_descent_get) returns a positive
value, whereas imlib_get_maximum_font_descent
(imlib_font_max_descent_get) returns a negative value.
I doubt this is intentional.
imlib_get_text_size (imlib_font_query_size) -
What is it supposed to do?
If it should return the ink size of the given text string I think the
height is wrong (currently font max ascent +(-?) font max descent).
If it should return some overall bounding box size I think the width is
wrong (currently ~= ink width?).
imlib_text_draw_with_return_metrics probably doesn't return the intended
values in width_return and height_return.
Unfortunately, changing any of this may cause breakage in existing apps.
/Kim
--- /mnt/src/E/e17-cvs.clean/libs/imlib2/src/lib/font_draw.c 2005-10-16 15:06:07.000000000 +0200
+++ src/lib/font_draw.c 2005-12-31 00:22:06.000000000 +0100
@@ -78,7 +78,8 @@
DATA32 *data, col;
int nx, ny;
- imlib_font_query_advance(fn, text, &w, &h);
+ imlib_font_query_advance(fn, text, &w, NULL);
+ h = imlib_font_max_ascent_get(fn) - imlib_font_max_descent_get(fn);
data = malloc(w * h * sizeof(DATA32));
if (!data)