1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
Index: xine-ui-0.99.4/src/xitk/xine-toolkit/font.c
===================================================================
--- xine-ui-0.99.4.orig/src/xitk/xine-toolkit/font.c
+++ xine-ui-0.99.4/src/xitk/xine-toolkit/font.c
@@ -321,7 +321,8 @@ static char * xitk_font_core_string_to_x
|| strncmp(old_name, "-", 1) == 0 || strncmp(old_name, "*", 1) == 0) {
char font[50];
char style[15];
- char *psize = "*", size[5], ptsize[5], pxsize[5];
+ char ptsize[5], pxsize[5];
+ int xft_pxsize;
if( old_name[0] == '-' )
old_name++;
@@ -331,27 +332,18 @@ static char * xitk_font_core_string_to_x
sscanf( old_name, "%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%[^-]", pxsize);
sscanf( old_name, "%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%[^-]", ptsize);
- /* Xft doesn't have lucida, which is a small font;
- * thus we make whatever is chosen 2 sizes smaller */
- if(strlen(pxsize) && strcmp(pxsize, "*"))
- psize = pxsize;
- else if(strlen(ptsize) && strcmp(ptsize, "*"))
- psize = ptsize;
+ if (!strcmp(style, "*"))
+ style[0] = 0;
- if( strcmp( font, "lucida" ) == 0 ) {
- int sz = strtol(psize, &psize, 10);
+ if(strlen(pxsize) && strcmp(pxsize, "*")) {
+ /* Xft fonts usually come out looking slightly smaller at a given pixel
+ * size, so bump the px size up by 1 to get a more consistent appearance.
+ */
+ xft_pxsize = atoi(pxsize) + 1;
+ snprintf(new_name, sizeof(new_name)-5, "%s:pixelsize=%d:%s", font, xft_pxsize, style);
+ } else if(strlen(ptsize) && strcmp(ptsize, "*"))
+ snprintf(new_name, sizeof(new_name)-5, "%s-%s:%s", font, ptsize, style);
- sz -= 2;
- snprintf(size , sizeof(size), "%i", sz);
- }
- else
- snprintf(size, sizeof(size), "%s", psize);
-
- if( strcmp( style , "bold" ) != 0 )
- snprintf( new_name, sizeof(new_name), "%s-%s", font, size );
- else
- snprintf( new_name, sizeof(new_name), "%s-%s:%s", font, size, style );
-
return new_name;
}
@@ -1097,8 +1089,11 @@ void xitk_font_text_extent(xitk_font_t *
XUNLOCK(xtfs->display);
free(encoded_text);
+ /* Note: the fact that we have to fudge ascent so much means we're doing
+ * something wrong somewhere. I don't have time to figure it out right now,
+ * and this makes everything look about right onscreen, at least... --AS */
if (width) *width = xft_extents.width;
- if (ascent) *ascent = xtfs->font->ascent - 1;
+ if (ascent) *ascent = xtfs->font->ascent - 4;
if (descent) *descent = xtfs->font->descent;
if (lbearing) *lbearing = 0;
if (rbearing) *rbearing = 0;
|