diff options
| author | Gerd Moellmann | 2001-01-17 15:46:49 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-17 15:46:49 +0000 |
| commit | 9c11f79e2d17431a6dcb3f5b406e4bc91577ca06 (patch) | |
| tree | e4b4adca668429c9f4615e585398540962a31820 /src | |
| parent | 9eaf396bd1a606f2d5cf73ef90125c4ca5682232 (diff) | |
| download | emacs-9c11f79e2d17431a6dcb3f5b406e4bc91577ca06.tar.gz emacs-9c11f79e2d17431a6dcb3f5b406e4bc91577ca06.zip | |
(x_list_fonts): Allow scalable fonts if SIZE is < 0,
In the cache, use a key containing the information if scalable
fonts are included.
(x_load_font): Adapt to change of keys in the font cache.
(x_list_fonts): Ensure caching font information when
called for a null frame, which is the case frequently when Emacs
starts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/xterm.c | 79 |
2 files changed, 63 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 165f6749c5f..ef20fc4426f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2001-01-17 Gerd Moellmann <gerd@gnu.org> | 1 | 2001-01-17 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * xterm.c (x_list_fonts): Allow scalable fonts if SIZE is < 0, | ||
| 4 | In the cache, use a key containing the information if scalable | ||
| 5 | fonts are included. | ||
| 6 | (x_load_font): Adapt to change of keys in the font cache. | ||
| 7 | |||
| 8 | 2001-01-17 Kim F. Storm <storm@filanet.dk> | ||
| 9 | |||
| 10 | * xterm.c (x_list_fonts): Ensure caching font information when | ||
| 11 | called for a null frame, which is the case frequently when Emacs | ||
| 12 | starts. | ||
| 13 | |||
| 14 | 2001-01-17 Gerd Moellmann <gerd@gnu.org> | ||
| 15 | |||
| 3 | * xfns.c (QCconversion): Replaces QCalgorithm. | 16 | * xfns.c (QCconversion): Replaces QCalgorithm. |
| 4 | 17 | ||
| 5 | * w32fns.c (QCconversion): Replaces QCalgorithm. Update copyright. | 18 | * w32fns.c (QCconversion): Replaces QCalgorithm. Update copyright. |
diff --git a/src/xterm.c b/src/xterm.c index 1ad1fd4d1f9..a951e9ead5c 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -12780,24 +12780,38 @@ x_get_font_info (f, font_idx) | |||
| 12780 | } | 12780 | } |
| 12781 | 12781 | ||
| 12782 | 12782 | ||
| 12783 | /* Return a list of names of available fonts matching PATTERN on frame | 12783 | /* Return a list of names of available fonts matching PATTERN on frame F. |
| 12784 | F. If SIZE is not 0, it is the size (maximum bound width) of fonts | 12784 | |
| 12785 | to be listed. Frame F NULL means we have not yet created any | 12785 | If SIZE is > 0, it is the size (maximum bounds width) of fonts |
| 12786 | frame on X, and consult the first display in x_display_list. | 12786 | to be listed. |
| 12787 | MAXNAMES sets a limit on how many fonts to match. */ | 12787 | |
| 12788 | SIZE < 0 means include scalable fonts. | ||
| 12789 | |||
| 12790 | Frame F null means we have not yet created any frame on X, and | ||
| 12791 | consult the first display in x_display_list. MAXNAMES sets a limit | ||
| 12792 | on how many fonts to match. */ | ||
| 12788 | 12793 | ||
| 12789 | Lisp_Object | 12794 | Lisp_Object |
| 12790 | x_list_fonts (f, pattern, size, maxnames) | 12795 | x_list_fonts (f, pattern, size, maxnames) |
| 12791 | FRAME_PTR f; | 12796 | struct frame *f; |
| 12792 | Lisp_Object pattern; | 12797 | Lisp_Object pattern; |
| 12793 | int size; | 12798 | int size; |
| 12794 | int maxnames; | 12799 | int maxnames; |
| 12795 | { | 12800 | { |
| 12796 | Lisp_Object list = Qnil, patterns, newlist = Qnil, key = Qnil; | 12801 | Lisp_Object list = Qnil, patterns, newlist = Qnil, key = Qnil; |
| 12797 | Lisp_Object tem, second_best; | 12802 | Lisp_Object tem, second_best; |
| 12798 | Display *dpy = f != NULL ? FRAME_X_DISPLAY (f) : x_display_list->display; | 12803 | struct x_display_info *dpyinfo |
| 12804 | = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list; | ||
| 12805 | Display *dpy = dpyinfo->display; | ||
| 12799 | int try_XLoadQueryFont = 0; | 12806 | int try_XLoadQueryFont = 0; |
| 12800 | int count; | 12807 | int count; |
| 12808 | int allow_scalable_fonts_p = 0; | ||
| 12809 | |||
| 12810 | if (size < 0) | ||
| 12811 | { | ||
| 12812 | allow_scalable_fonts_p = 1; | ||
| 12813 | size = 0; | ||
| 12814 | } | ||
| 12801 | 12815 | ||
| 12802 | patterns = Fassoc (pattern, Valternate_fontname_alist); | 12816 | patterns = Fassoc (pattern, Valternate_fontname_alist); |
| 12803 | if (NILP (patterns)) | 12817 | if (NILP (patterns)) |
| @@ -12815,11 +12829,12 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 12815 | pattern = XCAR (patterns); | 12829 | pattern = XCAR (patterns); |
| 12816 | /* See if we cached the result for this particular query. | 12830 | /* See if we cached the result for this particular query. |
| 12817 | The cache is an alist of the form: | 12831 | The cache is an alist of the form: |
| 12818 | (((PATTERN . MAXNAMES) (FONTNAME . WIDTH) ...) ...) | 12832 | ((((PATTERN . MAXNAMES) . SCALABLE) (FONTNAME . WIDTH) ...) ...) */ |
| 12819 | */ | 12833 | tem = XCDR (dpyinfo->name_list_element); |
| 12820 | if (f && (tem = XCDR (FRAME_X_DISPLAY_INFO (f)->name_list_element), | 12834 | key = Fcons (Fcons (pattern, make_number (maxnames)), |
| 12821 | key = Fcons (pattern, make_number (maxnames)), | 12835 | allow_scalable_fonts_p ? Qt : Qnil); |
| 12822 | !NILP (list = Fassoc (key, tem)))) | 12836 | list = Fassoc (key, tem); |
| 12837 | if (!NILP (list)) | ||
| 12823 | { | 12838 | { |
| 12824 | list = Fcdr_safe (list); | 12839 | list = Fcdr_safe (list); |
| 12825 | /* We have a cashed list. Don't have to get the list again. */ | 12840 | /* We have a cashed list. Don't have to get the list again. */ |
| @@ -12906,10 +12921,10 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 12906 | int average_width = -1, dashes = 0; | 12921 | int average_width = -1, dashes = 0; |
| 12907 | 12922 | ||
| 12908 | /* Count the number of dashes in NAMES[I]. If there are | 12923 | /* Count the number of dashes in NAMES[I]. If there are |
| 12909 | 14 dashes, and the field value following 12th dash | 12924 | 14 dashes, and the field value following 12th dash |
| 12910 | (AVERAGE_WIDTH) is 0, this is a auto-scaled font which | 12925 | (AVERAGE_WIDTH) is 0, this is a auto-scaled font which |
| 12911 | is usually too ugly to be used for editing. Let's | 12926 | is usually too ugly to be used for editing. Let's |
| 12912 | ignore it. */ | 12927 | ignore it. */ |
| 12913 | while (*p) | 12928 | while (*p) |
| 12914 | if (*p++ == '-') | 12929 | if (*p++ == '-') |
| 12915 | { | 12930 | { |
| @@ -12919,7 +12934,9 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 12919 | else if (dashes == 12) /* AVERAGE_WIDTH field */ | 12934 | else if (dashes == 12) /* AVERAGE_WIDTH field */ |
| 12920 | average_width = atoi (p); | 12935 | average_width = atoi (p); |
| 12921 | } | 12936 | } |
| 12922 | if (dashes < 14 || average_width != 0) | 12937 | |
| 12938 | if (allow_scalable_fonts_p | ||
| 12939 | || dashes < 14 || average_width != 0) | ||
| 12923 | { | 12940 | { |
| 12924 | tem = build_string (names[i]); | 12941 | tem = build_string (names[i]); |
| 12925 | if (NILP (Fassoc (tem, list))) | 12942 | if (NILP (Fassoc (tem, list))) |
| @@ -12942,10 +12959,8 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 12942 | } | 12959 | } |
| 12943 | 12960 | ||
| 12944 | /* Now store the result in the cache. */ | 12961 | /* Now store the result in the cache. */ |
| 12945 | if (f != NULL) | 12962 | XCDR (dpyinfo->name_list_element) |
| 12946 | XCDR (FRAME_X_DISPLAY_INFO (f)->name_list_element) | 12963 | = Fcons (Fcons (key, list), XCDR (dpyinfo->name_list_element)); |
| 12947 | = Fcons (Fcons (key, list), | ||
| 12948 | XCDR (FRAME_X_DISPLAY_INFO (f)->name_list_element)); | ||
| 12949 | 12964 | ||
| 12950 | label_cached: | 12965 | label_cached: |
| 12951 | if (NILP (list)) continue; /* Try the remaining alternatives. */ | 12966 | if (NILP (list)) continue; /* Try the remaining alternatives. */ |
| @@ -12969,7 +12984,7 @@ x_list_fonts (f, pattern, size, maxnames) | |||
| 12969 | if (!INTEGERP (XCDR (tem))) | 12984 | if (!INTEGERP (XCDR (tem))) |
| 12970 | { | 12985 | { |
| 12971 | /* Since we have not yet known the size of this font, we | 12986 | /* Since we have not yet known the size of this font, we |
| 12972 | must try slow function call XLoadQueryFont. */ | 12987 | must try slow function call XLoadQueryFont. */ |
| 12973 | XFontStruct *thisinfo; | 12988 | XFontStruct *thisinfo; |
| 12974 | 12989 | ||
| 12975 | BLOCK_INPUT; | 12990 | BLOCK_INPUT; |
| @@ -13261,20 +13276,26 @@ x_load_font (f, fontname, size) | |||
| 13261 | the cache for x_list_fonts. */ | 13276 | the cache for x_list_fonts. */ |
| 13262 | Lisp_Object lispy_name = build_string (fontname); | 13277 | Lisp_Object lispy_name = build_string (fontname); |
| 13263 | Lisp_Object lispy_full_name = build_string (fontp->full_name); | 13278 | Lisp_Object lispy_full_name = build_string (fontp->full_name); |
| 13279 | Lisp_Object key = Fcons (Fcons (lispy_name, make_number (256)), | ||
| 13280 | Qnil); | ||
| 13264 | 13281 | ||
| 13265 | XCDR (dpyinfo->name_list_element) | 13282 | XCDR (dpyinfo->name_list_element) |
| 13266 | = Fcons (Fcons (Fcons (lispy_name, make_number (256)), | 13283 | = Fcons (Fcons (key, |
| 13267 | Fcons (Fcons (lispy_full_name, | 13284 | Fcons (Fcons (lispy_full_name, |
| 13268 | make_number (fontp->size)), | 13285 | make_number (fontp->size)), |
| 13269 | Qnil)), | 13286 | Qnil)), |
| 13270 | XCDR (dpyinfo->name_list_element)); | 13287 | XCDR (dpyinfo->name_list_element)); |
| 13271 | if (full_name) | 13288 | if (full_name) |
| 13272 | XCDR (dpyinfo->name_list_element) | 13289 | { |
| 13273 | = Fcons (Fcons (Fcons (lispy_full_name, make_number (256)), | 13290 | key = Fcons (Fcons (lispy_full_name, make_number (256)), |
| 13274 | Fcons (Fcons (lispy_full_name, | 13291 | Qnil); |
| 13275 | make_number (fontp->size)), | 13292 | XCDR (dpyinfo->name_list_element) |
| 13276 | Qnil)), | 13293 | = Fcons (Fcons (key, |
| 13277 | XCDR (dpyinfo->name_list_element)); | 13294 | Fcons (Fcons (lispy_full_name, |
| 13295 | make_number (fontp->size)), | ||
| 13296 | Qnil)), | ||
| 13297 | XCDR (dpyinfo->name_list_element)); | ||
| 13298 | } | ||
| 13278 | } | 13299 | } |
| 13279 | 13300 | ||
| 13280 | /* The slot `encoding' specifies how to map a character | 13301 | /* The slot `encoding' specifies how to map a character |