]>
Commit | Line | Data |
---|---|---|
31988621 JR |
1 | |
2 | The following patch fixes a problem in _XomGenericTextEscapement(). | |
3 | The problem is that the font used when | |
4 | ||
5 | To reproduce the bug, load the following fontset: | |
6 | ||
7 | "-*-helvetica-bold-r-normal--10-*-*-*-p-*-*-*," \ | |
8 | "-*-*-bold-r-normal-*-10-*-*-*-*-*-*-*,*" | |
9 | ||
10 | And then (in a Latin-1 locale) compare the results of measuring the | |
11 | string with actually drawing the font on the screen. Though helvetica | |
12 | is drawn on the screen, the width will not be the width from the | |
13 | helvetica font, but from a different font from matching on the '*'. | |
14 | ||
15 | The patch below fixes selecting the font for measuring the text | |
16 | escapement to work the same way as selecting the font for drawing. | |
17 | ||
18 | I've added another comment in a different portion of code that appears | |
19 | somewhat dubious to me; the entries in font_set->font_data are getting | |
20 | filled in with bogus fonts. Loading these fonts is unecessary | |
21 | overhead, and having them there is likely to produce odd bugs like | |
22 | this one. | |
23 | ||
24 | (I have to say that reading this code makes me more and more happy | |
25 | that I decided to ignore and bypass it for Pango.) | |
26 | ||
27 | Regards, | |
28 | Owen | |
29 | ||
30 | --- xc/lib/X11/omGeneric.c.ots Wed Jul 12 12:02:04 2000 | |
31 | +++ xc/lib/X11/omGeneric.c Wed Jul 12 12:09:15 2000 | |
32 | @@ -1031,6 +1031,15 @@ | |
33 | ||
34 | found_num++; | |
35 | is_found = True; | |
36 | + /* We almost certainly should have 'break' here and should ignore | |
37 | + * the rest of the patterns. The problem is that we'll overwrite | |
38 | + * font_data->font and font_data->xlfd_name with later matches. | |
39 | + * But the general expectation would be that font_data->xlfd_name | |
40 | + * would correspond to to the returned value. (It's not clear | |
41 | + * why this routine modifies font_data and has a font_data_return...) | |
42 | + * | |
43 | + * Owen Taylor <otaylor@redhat.com> 12 Jul 2000 | |
44 | + */ | |
45 | } | |
46 | ||
47 | switch(class) { | |
48 | --- xc/lib/X11/omTextEsc.c.ots Wed Jul 12 11:57:58 2000 | |
49 | +++ xc/lib/X11/omTextEsc.c Wed Jul 12 12:07:41 2000 | |
50 | @@ -151,10 +151,27 @@ | |
51 | is_xchar2b, FONTSCOPE); | |
52 | if(ptr_len <= 0) | |
53 | break; | |
54 | + | |
55 | + /* First, see if the "Best Match" font for the FontSet was set. | |
56 | + * If it was, use that font. If it was not set, then use the | |
57 | + * font defined by font_set->font_data[0] (which is what | |
58 | + * _XomGetFontDataFromFontSet() always seems to return for | |
59 | + * non-VW text). Note that given the new algorithm in | |
60 | + * parse_fontname() and parse_fontdata(), fs->font will | |
61 | + * *always* contain good data. We should probably remove | |
62 | + * the check for "fd->font", but we won't :-) -- jjw/pma (HP) | |
63 | + * | |
64 | + * Above comment and way this is done propagated from omText.c | |
65 | + * Note that fd->font is junk so using the result of the | |
66 | + * above call /needs/ to be ignored. | |
67 | + * | |
68 | + * Owen Taylor <otaylor@redhat.com> 12 Jul 2000 | |
69 | + * | |
70 | + */ | |
71 | if(fd == (FontData) NULL || | |
72 | - (font = fd->font) == (XFontStruct *) NULL) { | |
73 | + (font = font_set->font) == (XFontStruct *) NULL) { | |
74 | ||
75 | - if((font = font_set->font) == (XFontStruct *) NULL) | |
76 | + if((font = fd->font) == (XFontStruct *) NULL) | |
77 | break; | |
78 | } | |
79 |