Here is how gnome-terminal (libvte9) determines the width of an
xft font with pango in vtepangocairo.c:

 367 static void
 368 font_info_measure_font (struct font_info *info)
 369 {
 370         PangoRectangle logical;
 371 
 372         /* Estimate for ASCII characters. */
 373         pango_layout_set_text (info->layout, 
VTE_DRAW_SINGLE_WIDE_CHARACTERS, -1);
 374         pango_layout_get_extents (info->layout, NULL, &logical);
 375         /* We don't do CEIL for width since we are averaging;
 376          * rounding is more accurate */
 377         info->width  = PANGO_PIXELS (howmany (logical.width, 
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS)));
 378         info->height = PANGO_PIXELS_CEIL (logical.height);
 379         info->ascent = PANGO_PIXELS_CEIL (pango_layout_get_baseline 
(info->layout));

Here is the definition of VTE_DRAW_SINGLE_WIDE_CHARACTERS in
vtedraw.h:

 33 #define VTE_DRAW_SINGLE_WIDE_CHARACTERS \
 34                                         " !\"#$%&'()*+,-./" \
 35                                         "0123456789" \
 36                                         ":;<=>?@" \
 37                                         "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
 38                                         "[\\]^_`" \
 39                                         "abcdefghijklmnopqrstuvwxyz" \
 40                                         "{|}~" \
 41                                         ""

and here is the definition of PANGO_PIXELS from
/usr/include/pango-1.0/pango/pango-types.h:

 48 #define PANGO_PIXELS(d) (((int)(d) + 512) >> 10)
 49 #define PANGO_PIXELS_FLOOR(d) (((int)(d)) >> 10)
 50 #define PANGO_PIXELS_CEIL(d) (((int)(d) + 1023) >> 10)

Note this is different from rxvt-unicode which includes
double-width fonts in the rendering test, despite the comment in
rxvtfont.C:

 152 // these characters are used to guess the font height and width
 153 // pango uses a similar algorithm and doesn't trust the font either.
 154 static uint16_t extent_test_chars[] = {
 155   '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
 156   0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643,       // ÍÕĔŷﻙ
 157   0x304c, 0x672c,                               // が本
 158 };

I would test changing this but frankly, it's already working
properly on my one system (Debian).  On my other system (Ubuntu
Jaunty) I can't figure out the correspondance between the font
sizes I request in gnome-terminal and the font sizes I request
with size= or pixelsize= in urxvt. :-(

Aron

_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to