comparison src/xfns.c @ 89483:2f877ed80fa6

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Sep 2003 12:53:41 +0000
parents 375f2633d815 ffa18ef18e45
children 483f5ce6ca7a
comparison
equal deleted inserted replaced
88123:375f2633d815 89483:2f877ed80fa6
40 #include "intervals.h" 40 #include "intervals.h"
41 #include "dispextern.h" 41 #include "dispextern.h"
42 #include "keyboard.h" 42 #include "keyboard.h"
43 #include "blockinput.h" 43 #include "blockinput.h"
44 #include <epaths.h> 44 #include <epaths.h>
45 #include "character.h"
45 #include "charset.h" 46 #include "charset.h"
46 #include "coding.h" 47 #include "coding.h"
47 #include "fontset.h" 48 #include "fontset.h"
48 #include "systime.h" 49 #include "systime.h"
49 #include "termhooks.h" 50 #include "termhooks.h"
1836 x_encode_text (string, coding_system, selectionp, text_bytes, stringp) 1837 x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
1837 Lisp_Object string, coding_system; 1838 Lisp_Object string, coding_system;
1838 int *text_bytes, *stringp; 1839 int *text_bytes, *stringp;
1839 int selectionp; 1840 int selectionp;
1840 { 1841 {
1841 unsigned char *str = SDATA (string); 1842 int result = string_xstring_p (string);
1842 int chars = SCHARS (string);
1843 int bytes = SBYTES (string);
1844 int charset_info;
1845 int bufsize;
1846 unsigned char *buf;
1847 struct coding_system coding; 1843 struct coding_system coding;
1848 extern Lisp_Object Qcompound_text_with_extensions; 1844 extern Lisp_Object Qcompound_text_with_extensions;
1849 1845
1850 charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil); 1846 if (result == 0)
1851 if (charset_info == 0)
1852 { 1847 {
1853 /* No multibyte character in OBJ. We need not encode it. */ 1848 /* No multibyte character in OBJ. We need not encode it. */
1854 *text_bytes = bytes; 1849 *text_bytes = SBYTES (string);
1855 *stringp = 1; 1850 *stringp = 1;
1856 return str; 1851 return SDATA (string);
1857 } 1852 }
1858 1853
1859 setup_coding_system (coding_system, &coding); 1854 setup_coding_system (coding_system, &coding);
1860 if (selectionp 1855 coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
1861 && SYMBOLP (coding.pre_write_conversion)
1862 && !NILP (Ffboundp (coding.pre_write_conversion)))
1863 {
1864 string = run_pre_post_conversion_on_str (string, &coding, 1);
1865 str = SDATA (string);
1866 chars = SCHARS (string);
1867 bytes = SBYTES (string);
1868 }
1869 coding.src_multibyte = 1;
1870 coding.dst_multibyte = 0;
1871 coding.mode |= CODING_MODE_LAST_BLOCK;
1872 if (coding.type == coding_type_iso2022)
1873 coding.flags |= CODING_FLAG_ISO_SAFE;
1874 /* We suppress producing escape sequences for composition. */ 1856 /* We suppress producing escape sequences for composition. */
1875 coding.composing = COMPOSITION_DISABLED; 1857 coding.common_flags &= ~CODING_ANNOTATION_MASK;
1876 bufsize = encoding_buffer_size (&coding, bytes); 1858 coding.dst_bytes = SCHARS (string) * 2;
1877 buf = (unsigned char *) xmalloc (bufsize); 1859 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
1878 encode_coding (&coding, str, buf, bytes, bufsize); 1860 encode_coding_object (&coding, string, 0, 0,
1861 SCHARS (string), SBYTES (string), Qnil);
1879 *text_bytes = coding.produced; 1862 *text_bytes = coding.produced;
1880 *stringp = (charset_info == 1 1863 *stringp = (result == 1 || !EQ (coding_system, Qcompound_text));
1881 || (!EQ (coding_system, Qcompound_text) 1864 return coding.destination;
1882 && !EQ (coding_system, Qcompound_text_with_extensions)));
1883 return buf;
1884 } 1865 }
1885 1866
1886 1867
1887 /* Change the name of frame F to NAME. If NAME is nil, set F's name to 1868 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1888 x_id_name. 1869 x_id_name.
3320 { 3301 {
3321 Lisp_Object font; 3302 Lisp_Object font;
3322 3303
3323 font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING); 3304 font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
3324 3305
3325 BLOCK_INPUT; 3306 /* If the caller has specified no font, try out fonts which we
3326 /* First, try whatever font the caller has specified. */ 3307 hope have bold and italic variations. */
3327 if (STRINGP (font)) 3308 if (!STRINGP (font))
3328 { 3309 {
3329 tem = Fquery_fontset (font, Qnil); 3310 char *names[]
3330 if (STRINGP (tem)) 3311 = { "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1",
3331 font = x_new_fontset (f, SDATA (tem)); 3312 "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
3332 else 3313 "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
3333 font = x_new_font (f, SDATA (font)); 3314 /* This was formerly the first thing tried, but it finds
3315 too many fonts and takes too long. */
3316 "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1",
3317 /* If those didn't work, look for something which will
3318 at least work. */
3319 "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1",
3320 NULL };
3321 int i;
3322
3323 BLOCK_INPUT;
3324 for (i = 0; names[i]; i++)
3325 {
3326 Lisp_Object list;
3327
3328 list = x_list_fonts (f, build_string (names[i]), 0, 1);
3329 if (CONSP (list))
3330 {
3331 font = XCAR (list);
3332 break;
3333 }
3334 }
3335 UNBLOCK_INPUT;
3336 if (! STRINGP (font))
3337 font = build_string ("fixed");
3334 } 3338 }
3335
3336 /* Try out a font which we hope has bold and italic variations. */
3337 if (!STRINGP (font))
3338 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
3339 if (!STRINGP (font))
3340 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3341 if (! STRINGP (font))
3342 font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3343 if (! STRINGP (font))
3344 /* This was formerly the first thing tried, but it finds too many fonts
3345 and takes too long. */
3346 font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3347 /* If those didn't work, look for something which will at least work. */
3348 if (! STRINGP (font))
3349 font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3350 UNBLOCK_INPUT;
3351 if (! STRINGP (font))
3352 font = build_string ("fixed");
3353
3354 x_default_parameter (f, parms, Qfont, font, 3339 x_default_parameter (f, parms, Qfont, font,
3355 "font", "Font", RES_TYPE_STRING); 3340 "font", "Font", RES_TYPE_STRING);
3356 } 3341 }
3357 3342
3358 #ifdef USE_LUCID 3343 #ifdef USE_LUCID
9883 /* First, try whatever font the caller has specified. */ 9868 /* First, try whatever font the caller has specified. */
9884 if (STRINGP (font)) 9869 if (STRINGP (font))
9885 { 9870 {
9886 tem = Fquery_fontset (font, Qnil); 9871 tem = Fquery_fontset (font, Qnil);
9887 if (STRINGP (tem)) 9872 if (STRINGP (tem))
9888 font = x_new_fontset (f, SDATA (tem)); 9873 font = x_new_fontset (f, tem);
9889 else 9874 else
9890 font = x_new_font (f, SDATA (font)); 9875 font = x_new_font (f, SDATA (font));
9891 } 9876 }
9892 9877
9893 /* Try out a font which we hope has bold and italic variations. */ 9878 /* Try out a font which we hope has bold and italic variations. */
10926 10911
10927 load_font_func = x_load_font; 10912 load_font_func = x_load_font;
10928 find_ccl_program_func = x_find_ccl_program; 10913 find_ccl_program_func = x_find_ccl_program;
10929 query_font_func = x_query_font; 10914 query_font_func = x_query_font;
10930 set_frame_fontset_func = x_set_font; 10915 set_frame_fontset_func = x_set_font;
10916 get_font_repertory_func = x_get_font_repertory;
10931 check_window_system_func = check_x; 10917 check_window_system_func = check_x;
10932 10918
10933 /* Images. */ 10919 /* Images. */
10934 Qxbm = intern ("xbm"); 10920 Qxbm = intern ("xbm");
10935 staticpro (&Qxbm); 10921 staticpro (&Qxbm);