diff options
| author | Richard M. Stallman | 1993-06-06 03:27:43 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-06 03:27:43 +0000 |
| commit | 5835f8608107136eddace7252219857c920a8c96 (patch) | |
| tree | 04bc9c4c61726587be30338b68926f3313932e8a /src | |
| parent | 30c7817593feb864754c22bff5bc8d161cd3bf22 (diff) | |
| download | emacs-5835f8608107136eddace7252219857c920a8c96.tar.gz emacs-5835f8608107136eddace7252219857c920a8c96.zip | |
(x_new_font): Don't give up right away if XListFontsWithInfo
finds no fonts--try XLoadQueryFont anyway.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/xterm.c b/src/xterm.c index 4c1c79bf444..fc1b995e1a3 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3916,30 +3916,29 @@ x_new_font (f, fontname) | |||
| 3916 | font_names = (char **) XListFontsWithInfo (x_current_display, fontname, | 3916 | font_names = (char **) XListFontsWithInfo (x_current_display, fontname, |
| 3917 | 1024, &n_matching_fonts, | 3917 | 1024, &n_matching_fonts, |
| 3918 | &font_info); | 3918 | &font_info); |
| 3919 | 3919 | /* Don't just give up if n_matching_fonts is 0. | |
| 3920 | /* If the server couldn't find any fonts whose named matched fontname, | 3920 | Apparently there's a bug on Suns: XListFontsWithInfo can |
| 3921 | return an error code. */ | 3921 | fail to find a font, but XLoadQueryFont may still find it. */ |
| 3922 | if (n_matching_fonts == 0) | ||
| 3923 | return Qnil; | ||
| 3924 | 3922 | ||
| 3925 | /* See if we've already loaded a matching font. */ | 3923 | /* See if we've already loaded a matching font. */ |
| 3926 | { | 3924 | already_loaded = -1; |
| 3927 | int i, j; | 3925 | if (n_matching_fonts != 0) |
| 3926 | { | ||
| 3927 | int i, j; | ||
| 3928 | 3928 | ||
| 3929 | already_loaded = 0; | 3929 | for (i = 0; i < n_fonts; i++) |
| 3930 | for (i = 0; i < n_fonts; i++) | 3930 | for (j = 0; j < n_matching_fonts; j++) |
| 3931 | for (j = 0; j < n_matching_fonts; j++) | 3931 | if (x_font_table[i]->fid == font_info[j].fid) |
| 3932 | if (x_font_table[i]->fid == font_info[j].fid) | 3932 | { |
| 3933 | { | 3933 | already_loaded = i; |
| 3934 | already_loaded = i; | 3934 | fontname = font_names[j]; |
| 3935 | fontname = font_names[j]; | 3935 | goto found_font; |
| 3936 | goto found_font; | 3936 | } |
| 3937 | } | 3937 | } |
| 3938 | } | ||
| 3939 | found_font: | 3938 | found_font: |
| 3940 | 3939 | ||
| 3941 | /* If we have, just return it from the table. */ | 3940 | /* If we have, just return it from the table. */ |
| 3942 | if (already_loaded) | 3941 | if (already_loaded > 0) |
| 3943 | f->display.x->font = x_font_table[already_loaded]; | 3942 | f->display.x->font = x_font_table[already_loaded]; |
| 3944 | 3943 | ||
| 3945 | /* Otherwise, load the font and add it to the table. */ | 3944 | /* Otherwise, load the font and add it to the table. */ |
| @@ -3958,14 +3957,18 @@ x_new_font (f, fontname) | |||
| 3958 | i = 0; | 3957 | i = 0; |
| 3959 | #endif | 3958 | #endif |
| 3960 | 3959 | ||
| 3961 | if (i >= n_matching_fonts) | 3960 | /* See comment above. */ |
| 3962 | return Qt; | 3961 | if (n_matching_fonts != 0) |
| 3963 | else | ||
| 3964 | fontname = font_names[i]; | 3962 | fontname = font_names[i]; |
| 3965 | 3963 | ||
| 3966 | font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); | 3964 | font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); |
| 3967 | if (! font) | 3965 | if (! font) |
| 3968 | return Qnil; | 3966 | { |
| 3967 | /* Free the information from XListFontsWithInfo. */ | ||
| 3968 | if (n_matching_fonts) | ||
| 3969 | XFreeFontInfo (font_names, font_info, n_matching_fonts); | ||
| 3970 | return Qnil; | ||
| 3971 | } | ||
| 3969 | 3972 | ||
| 3970 | /* Do we need to create the table? */ | 3973 | /* Do we need to create the table? */ |
| 3971 | if (x_font_table_size == 0) | 3974 | if (x_font_table_size == 0) |