diff options
Diffstat (limited to 'src/xfns.c')
-rw-r--r-- | src/xfns.c | 107 |
1 files changed, 46 insertions, 61 deletions
diff --git a/src/xfns.c b/src/xfns.c index 9ee459680aa..f8829562174 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */ #include "keyboard.h" #include "blockinput.h" #include <epaths.h> +#include "character.h" #include "charset.h" #include "coding.h" #include "fontset.h" @@ -1518,49 +1519,28 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp) int *text_bytes, *stringp; int selectionp; { - unsigned char *str = SDATA (string); - int chars = SCHARS (string); - int bytes = SBYTES (string); - int charset_info; - int bufsize; - unsigned char *buf; + int result = string_xstring_p (string); struct coding_system coding; - extern Lisp_Object Qcompound_text_with_extensions; - charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil); - if (charset_info == 0) + if (result == 0) { /* No multibyte character in OBJ. We need not encode it. */ - *text_bytes = bytes; + *text_bytes = SBYTES (string); *stringp = 1; - return str; + return SDATA (string); } setup_coding_system (coding_system, &coding); - if (selectionp - && SYMBOLP (coding.pre_write_conversion) - && !NILP (Ffboundp (coding.pre_write_conversion))) - { - string = run_pre_post_conversion_on_str (string, &coding, 1); - str = SDATA (string); - chars = SCHARS (string); - bytes = SBYTES (string); - } - coding.src_multibyte = 1; - coding.dst_multibyte = 0; - coding.mode |= CODING_MODE_LAST_BLOCK; - if (coding.type == coding_type_iso2022) - coding.flags |= CODING_FLAG_ISO_SAFE; + coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); /* We suppress producing escape sequences for composition. */ - coding.composing = COMPOSITION_DISABLED; - bufsize = encoding_buffer_size (&coding, bytes); - buf = (unsigned char *) xmalloc (bufsize); - encode_coding (&coding, str, buf, bytes, bufsize); + coding.common_flags &= ~CODING_ANNOTATION_MASK; + coding.dst_bytes = SCHARS (string) * 2; + coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); + encode_coding_object (&coding, string, 0, 0, + SCHARS (string), SBYTES (string), Qnil); *text_bytes = coding.produced; - *stringp = (charset_info == 1 - || (!EQ (coding_system, Qcompound_text) - && !EQ (coding_system, Qcompound_text_with_extensions))); - return buf; + *stringp = (result == 1 || !EQ (coding_system, Qcompound_text)); + return coding.destination; } @@ -3052,35 +3032,39 @@ This function is an internal primitive--use `make-frame' instead. */) font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING); - BLOCK_INPUT; - /* First, try whatever font the caller has specified. */ - if (STRINGP (font)) + /* If the caller has specified no font, try out fonts which we + hope have bold and italic variations. */ + if (!STRINGP (font)) { - tem = Fquery_fontset (font, Qnil); - if (STRINGP (tem)) - font = x_new_fontset (f, SDATA (tem)); - else - font = x_new_font (f, SDATA (font)); + char *names[] + = { "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1", + "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1", + "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1", + /* This was formerly the first thing tried, but it finds + too many fonts and takes too long. */ + "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1", + /* If those didn't work, look for something which will + at least work. */ + "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1", + NULL }; + int i; + + BLOCK_INPUT; + for (i = 0; names[i]; i++) + { + Lisp_Object list; + + list = x_list_fonts (f, build_string (names[i]), 0, 1); + if (CONSP (list)) + { + font = XCAR (list); + break; + } + } + UNBLOCK_INPUT; + if (! STRINGP (font)) + font = build_string ("fixed"); } - - /* Try out a font which we hope has bold and italic variations. */ - if (!STRINGP (font)) - font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); - if (!STRINGP (font)) - font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); - if (! STRINGP (font)) - font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); - if (! STRINGP (font)) - /* This was formerly the first thing tried, but it finds too many fonts - and takes too long. */ - font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1"); - /* If those didn't work, look for something which will at least work. */ - if (! STRINGP (font)) - font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1"); - UNBLOCK_INPUT; - if (! STRINGP (font)) - font = build_string ("fixed"); - x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING); } @@ -4586,7 +4570,7 @@ x_create_tip_frame (dpyinfo, parms, text) { tem = Fquery_fontset (font, Qnil); if (STRINGP (tem)) - font = x_new_fontset (f, SDATA (tem)); + font = x_new_fontset (f, tem); else font = x_new_font (f, SDATA (font)); } @@ -5667,6 +5651,7 @@ variable `use-file-dialog'. */); find_ccl_program_func = x_find_ccl_program; query_font_func = x_query_font; set_frame_fontset_func = x_set_font; + get_font_repertory_func = x_get_font_repertory; check_window_system_func = check_x; hourglass_atimer = NULL; |