On Sun, Jan 20, 2008 at 05:41:20PM +0100, Janek Kozicki wrote: > Andrea Vettorello said: (by the date of Sun, 20 Jan 2008 15:10:04 +0100) > > > > Janek Kozicki said: (by the date of Sat, 19 Jan 2008 21:18:50 +0100) > > > > > > this screenshot sets a record - selected font is different by about 20 > > > pixels in size from the one used. > > > > > > I'm testing this on a debian etch fresh install. > > > > Same on Debian Sid. > > > > As it happens only with bitmap fonts, the first thing i thought was > > the screen DPI, but starting Xorg with different DPI lead to the same > > behaviour. I've searched if it's a Pango known bug but found nothing. > > As this doesn't happen with TTF fonts, i suspect we need to manage > > bitmap fonts differently from scalable fonts or we are missing > > something trivial. > > ok. Thanks for testing. > > So I think that better we will wait with this patch until this > problem will be solved, and apply it in next sawfish release. I've uploaded a new version of the patch to the wiki. I think the font sizing problems are gone, but I'm not completely positive, since I don't have the exact fonts that the screenshots display. Please test, I'd like it if we could add this patch for 1.3.3. That would make me feel less bad about having a "Fix Rodrigo's bugs" release. Patch attached for your convenience, although the canonical location is the wiki.
diff --git a/src/fonts.c b/src/fonts.c
index d4f05d7..3fb7258 100644
--- a/src/fonts.c
+++ b/src/fonts.c
@@ -459,24 +459,29 @@ pango_load (Lisp_Font *f)
pango_context_set_font_description (pango_context, fontdesc);
font = pango_context_load_font (pango_context, fontdesc);
- if (!font)
+ if (!font) {
+ pango_font_description_free(fontdesc);
return FALSE;
+ }
metrics = pango_font_get_metrics (font, language);
- f->font = font;
f->ascent = metrics->ascent / PANGO_SCALE;
f->descent = metrics->descent / PANGO_SCALE;
pango_font_metrics_unref (metrics);
+ f->font = fontdesc; // We save the font description, not the font itself!
+ // That's because it seems we can't recover it perfectly
+ // later, and the layout routines want a description
+
return TRUE;
}
static void
pango_finalize (Lisp_Font *f)
{
- g_object_unref (f->font);
+ pango_font_description_free (f->font);
}
static int
@@ -486,6 +491,7 @@ pango_measure (Lisp_Font *f, u_char *string, size_t length)
PangoRectangle rect;
layout = pango_layout_new (pango_context);
+ pango_layout_set_font_description(layout, f->font);
pango_layout_set_text (layout, string, length);
pango_layout_get_extents (layout, NULL, &rect);
@@ -541,6 +547,7 @@ pango_draw (Lisp_Font *f, u_char *string, size_t length,
xft_color.color.alpha = fg->alpha;
layout = pango_layout_new (pango_context);
+ pango_layout_set_font_description(layout, f->font);
pango_layout_set_text (layout, string, length);
iter = pango_layout_get_iter (layout);
Attachment:
signature.asc
Description: Digital signature