370 |
int force; |
int force; |
371 |
{ |
{ |
372 |
Lisp_Object family, registry; |
Lisp_Object family, registry; |
373 |
char *p = XSTRING (fontname)->data; |
const char *p = SDATA (fontname); |
374 |
char *sep[15]; |
const char *sep[15]; |
375 |
int i = 0; |
int i = 0; |
376 |
|
|
377 |
while (*p && i < 15) |
while (*p && i < 15) |
557 |
font name. */ |
font name. */ |
558 |
elt = XCDR (elt); |
elt = XCDR (elt); |
559 |
xassert (STRINGP (elt)); |
xassert (STRINGP (elt)); |
560 |
fontp = FS_LOAD_FONT (f, c, XSTRING (elt)->data, -1); |
fontp = FS_LOAD_FONT (f, c, SDATA (elt), -1); |
561 |
if (!fontp) |
if (!fontp) |
562 |
return Qnil; |
return Qnil; |
563 |
|
|
616 |
if (!fontname && charset == CHARSET_ASCII) |
if (!fontname && charset == CHARSET_ASCII) |
617 |
{ |
{ |
618 |
elt = FONTSET_ASCII (fontset); |
elt = FONTSET_ASCII (fontset); |
619 |
fontname = XSTRING (XCDR (elt))->data; |
fontname = SDATA (XCDR (elt)); |
620 |
} |
} |
621 |
} |
} |
622 |
|
|
705 |
the corresponding regular expression. */ |
the corresponding regular expression. */ |
706 |
static Lisp_Object Vcached_fontset_data; |
static Lisp_Object Vcached_fontset_data; |
707 |
|
|
708 |
#define CACHED_FONTSET_NAME (XSTRING (XCAR (Vcached_fontset_data))->data) |
#define CACHED_FONTSET_NAME (SDATA (XCAR (Vcached_fontset_data))) |
709 |
#define CACHED_FONTSET_REGEX (XCDR (Vcached_fontset_data)) |
#define CACHED_FONTSET_REGEX (XCDR (Vcached_fontset_data)) |
710 |
|
|
711 |
/* If fontset name PATTERN contains any wild card, return regular |
/* If fontset name PATTERN contains any wild card, return regular |
715 |
fontset_pattern_regexp (pattern) |
fontset_pattern_regexp (pattern) |
716 |
Lisp_Object pattern; |
Lisp_Object pattern; |
717 |
{ |
{ |
718 |
if (!index (XSTRING (pattern)->data, '*') |
if (!index (SDATA (pattern), '*') |
719 |
&& !index (XSTRING (pattern)->data, '?')) |
&& !index (SDATA (pattern), '?')) |
720 |
/* PATTERN does not contain any wild cards. */ |
/* PATTERN does not contain any wild cards. */ |
721 |
return Qnil; |
return Qnil; |
722 |
|
|
723 |
if (!CONSP (Vcached_fontset_data) |
if (!CONSP (Vcached_fontset_data) |
724 |
|| strcmp (XSTRING (pattern)->data, CACHED_FONTSET_NAME)) |
|| strcmp (SDATA (pattern), CACHED_FONTSET_NAME)) |
725 |
{ |
{ |
726 |
/* We must at first update the cached data. */ |
/* We must at first update the cached data. */ |
727 |
char *regex = (char *) alloca (XSTRING (pattern)->size * 2 + 3); |
char *regex = (char *) alloca (SCHARS (pattern) * 2 + 3); |
728 |
char *p0, *p1 = regex; |
char *p0, *p1 = regex; |
729 |
|
|
730 |
/* Convert "*" to ".*", "?" to ".". */ |
/* Convert "*" to ".*", "?" to ".". */ |
731 |
*p1++ = '^'; |
*p1++ = '^'; |
732 |
for (p0 = (char *) XSTRING (pattern)->data; *p0; p0++) |
for (p0 = (char *) SDATA (pattern); *p0; p0++) |
733 |
{ |
{ |
734 |
if (*p0 == '*') |
if (*p0 == '*') |
735 |
{ |
{ |
744 |
*p1++ = '$'; |
*p1++ = '$'; |
745 |
*p1++ = 0; |
*p1++ = 0; |
746 |
|
|
747 |
Vcached_fontset_data = Fcons (build_string (XSTRING (pattern)->data), |
Vcached_fontset_data = Fcons (build_string (SDATA (pattern)), |
748 |
build_string (regex)); |
build_string (regex)); |
749 |
} |
} |
750 |
|
|
782 |
for (i = 0; i < ASIZE (Vfontset_table); i++) |
for (i = 0; i < ASIZE (Vfontset_table); i++) |
783 |
{ |
{ |
784 |
Lisp_Object fontset; |
Lisp_Object fontset; |
785 |
unsigned char *this_name; |
const unsigned char *this_name; |
786 |
|
|
787 |
fontset = FONTSET_FROM_ID (i); |
fontset = FONTSET_FROM_ID (i); |
788 |
if (NILP (fontset) |
if (NILP (fontset) |
789 |
|| !BASE_FONTSET_P (fontset)) |
|| !BASE_FONTSET_P (fontset)) |
790 |
continue; |
continue; |
791 |
|
|
792 |
this_name = XSTRING (FONTSET_NAME (fontset))->data; |
this_name = SDATA (FONTSET_NAME (fontset)); |
793 |
if (regexpp |
if (regexpp |
794 |
? fast_c_string_match_ignore_case (name, this_name) >= 0 |
? fast_c_string_match_ignore_case (name, this_name) >= 0 |
795 |
: !strcmp (XSTRING (name)->data, this_name)) |
: !strcmp (SDATA (name), this_name)) |
796 |
return i; |
return i; |
797 |
} |
} |
798 |
return -1; |
return -1; |
815 |
|
|
816 |
CHECK_STRING (pattern); |
CHECK_STRING (pattern); |
817 |
|
|
818 |
if (XSTRING (pattern)->size == 0) |
if (SCHARS (pattern) == 0) |
819 |
return Qnil; |
return Qnil; |
820 |
|
|
821 |
id = fs_query_fontset (pattern, !NILP (regexpp)); |
id = fs_query_fontset (pattern, !NILP (regexpp)); |
847 |
for (id = 0; id < ASIZE (Vfontset_table); id++) |
for (id = 0; id < ASIZE (Vfontset_table); id++) |
848 |
{ |
{ |
849 |
Lisp_Object fontset; |
Lisp_Object fontset; |
850 |
unsigned char *name; |
const unsigned char *name; |
851 |
|
|
852 |
fontset = FONTSET_FROM_ID (id); |
fontset = FONTSET_FROM_ID (id); |
853 |
if (NILP (fontset) |
if (NILP (fontset) |
854 |
|| !BASE_FONTSET_P (fontset) |
|| !BASE_FONTSET_P (fontset) |
855 |
|| !EQ (frame, FONTSET_FRAME (fontset))) |
|| !EQ (frame, FONTSET_FRAME (fontset))) |
856 |
continue; |
continue; |
857 |
name = XSTRING (FONTSET_NAME (fontset))->data; |
name = SDATA (FONTSET_NAME (fontset)); |
858 |
|
|
859 |
if (!NILP (regexp) |
if (!NILP (regexp) |
860 |
? (fast_c_string_match_ignore_case (regexp, name) < 0) |
? (fast_c_string_match_ignore_case (regexp, name) < 0) |
861 |
: strcmp (XSTRING (pattern)->data, name)) |
: strcmp (SDATA (pattern), name)) |
862 |
continue; |
continue; |
863 |
|
|
864 |
if (size) |
if (size) |
892 |
tem = Fquery_fontset (name, Qnil); |
tem = Fquery_fontset (name, Qnil); |
893 |
if (!NILP (tem)) |
if (!NILP (tem)) |
894 |
error ("Fontset `%s' matches the existing fontset `%s'", |
error ("Fontset `%s' matches the existing fontset `%s'", |
895 |
XSTRING (name)->data, XSTRING (tem)->data); |
SDATA (name), SDATA (tem)); |
896 |
|
|
897 |
/* Check the validity of FONTLIST while creating a template for |
/* Check the validity of FONTLIST while creating a template for |
898 |
fontset elements. */ |
fontset elements. */ |
955 |
|
|
956 |
/* Check validity of NAME as a fontset name and return the |
/* Check validity of NAME as a fontset name and return the |
957 |
corresponding fontset. If not valid, signal an error. |
corresponding fontset. If not valid, signal an error. |
958 |
If NAME is t, return Vdefault_fontset. */ |
If NAME is nil, return Vdefault_fontset. */ |
959 |
|
|
960 |
static Lisp_Object |
static Lisp_Object |
961 |
check_fontset_name (name) |
check_fontset_name (name) |
963 |
{ |
{ |
964 |
int id; |
int id; |
965 |
|
|
966 |
if (EQ (name, Qt)) |
if (EQ (name, Qnil)) |
967 |
return Vdefault_fontset; |
return Vdefault_fontset; |
968 |
|
|
969 |
CHECK_STRING (name); |
CHECK_STRING (name); |
970 |
id = fs_query_fontset (name, 0); |
id = fs_query_fontset (name, 0); |
971 |
if (id < 0) |
if (id < 0) |
972 |
error ("Fontset `%s' does not exist", XSTRING (name)->data); |
error ("Fontset `%s' does not exist", SDATA (name)); |
973 |
return FONTSET_FROM_ID (id); |
return FONTSET_FROM_ID (id); |
974 |
} |
} |
975 |
|
|
976 |
DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 4, 0, |
DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 4, 0, |
977 |
doc: /* Modify fontset NAME to use FONTNAME for CHARACTER. |
doc: /* Modify fontset NAME to use FONTNAME for CHARACTER. |
978 |
|
|
979 |
|
If NAME is nil, modify the default fontset. |
980 |
CHARACTER may be a cons; (FROM . TO), where FROM and TO are |
CHARACTER may be a cons; (FROM . TO), where FROM and TO are |
981 |
non-generic characters. In that case, use FONTNAME |
non-generic characters. In that case, use FONTNAME |
982 |
for all characters in the range FROM and TO (inclusive). |
for all characters in the range FROM and TO (inclusive). |
983 |
CHARACTER may be a charset. In that case, use FONTNAME |
CHARACTER may be a charset. In that case, use FONTNAME |
984 |
for all character in the charsets. |
for all character in the charsets. |
985 |
|
|
986 |
FONTNAME may be a cons; (FAMILY . REGISTRY), where FAMILY is a family |
FONTNAME may be a cons; (FAMILY . REGISTRY), where FAMILY is a family |
1014 |
{ |
{ |
1015 |
elt = Fget (character, Qcharset); |
elt = Fget (character, Qcharset); |
1016 |
if (!VECTORP (elt) || ASIZE (elt) < 1 || !NATNUMP (AREF (elt, 0))) |
if (!VECTORP (elt) || ASIZE (elt) < 1 || !NATNUMP (AREF (elt, 0))) |
1017 |
error ("Invalid charset: %s", (XSTRING (SYMBOL_NAME (character)))->data); |
error ("Invalid charset: %s", SDATA (SYMBOL_NAME (character))); |
1018 |
from = MAKE_CHAR (XINT (AREF (elt, 0)), 0, 0); |
from = MAKE_CHAR (XINT (AREF (elt, 0)), 0, 0); |
1019 |
to = from; |
to = from; |
1020 |
} |
} |
1121 |
if (!query_font_func) |
if (!query_font_func) |
1122 |
error ("Font query function is not supported"); |
error ("Font query function is not supported"); |
1123 |
|
|
1124 |
fontp = (*query_font_func) (f, XSTRING (name)->data); |
fontp = (*query_font_func) (f, SDATA (name)); |
1125 |
if (!fontp) |
if (!fontp) |
1126 |
return Qnil; |
return Qnil; |
1127 |
|
|
1191 |
|
|
1192 |
|
|
1193 |
/* Called from Ffontset_info via map_char_table on each leaf of |
/* Called from Ffontset_info via map_char_table on each leaf of |
1194 |
|
fontset. ARG is a copy of the default fontset. The current leaf |
1195 |
|
is indexed by CHARACTER and has value ELT. This function override |
1196 |
|
the copy by ELT if ELT is not nil. */ |
1197 |
|
|
1198 |
|
static void |
1199 |
|
override_font_info (fontset, character, elt) |
1200 |
|
Lisp_Object fontset, character, elt; |
1201 |
|
{ |
1202 |
|
if (! NILP (elt)) |
1203 |
|
Faset (fontset, character, elt); |
1204 |
|
} |
1205 |
|
|
1206 |
|
/* Called from Ffontset_info via map_char_table on each leaf of |
1207 |
fontset. ARG is a list (LAST FONT-INFO ...), where LAST is `(last |
fontset. ARG is a list (LAST FONT-INFO ...), where LAST is `(last |
1208 |
ARG)' and FONT-INFOs have this form: |
ARG)' and FONT-INFOs have this form: |
1209 |
(CHAR FONT-SPEC) or ((FROM . TO) FONT-SPEC) |
(CHAR FONT-SPEC) or ((FROM . TO) FONT-SPEC) |
1210 |
The current leaf is indexed by CHARACTER and has value ELT. This |
The current leaf is indexed by CHARACTER and has value ELT. This |
1211 |
function add the information of the current leaf to ARG by |
function add the information of the current leaf to ARG by |
1212 |
appending a new element or modifying the last element.. */ |
appending a new element or modifying the last element. */ |
1213 |
|
|
1214 |
static void |
static void |
1215 |
accumulate_font_info (arg, character, elt) |
accumulate_font_info (arg, character, elt) |
1252 |
|
|
1253 |
DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0, |
DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0, |
1254 |
doc: /* Return information about a fontset named NAME on frame FRAME. |
doc: /* Return information about a fontset named NAME on frame FRAME. |
1255 |
|
If NAME is nil, return information about the default fontset. |
1256 |
The value is a vector: |
The value is a vector: |
1257 |
[ SIZE HEIGHT ((CHARSET-OR-RANGE FONT-SPEC OPENED ...) ...) ], |
[ SIZE HEIGHT ((CHARSET-OR-RANGE FONT-SPEC OPENED ...) ...) ], |
1258 |
where, |
where, |
1301 |
realized[n_realized++] = elt; |
realized[n_realized++] = elt; |
1302 |
} |
} |
1303 |
|
|
1304 |
|
if (! EQ (fontset, Vdefault_fontset)) |
1305 |
|
{ |
1306 |
|
/* Merge FONTSET onto the default fontset. */ |
1307 |
|
val = Fcopy_sequence (Vdefault_fontset); |
1308 |
|
map_char_table (override_font_info, Qnil, fontset, val, 0, indices); |
1309 |
|
fontset = val; |
1310 |
|
} |
1311 |
|
|
1312 |
/* Accumulate information of the fontset in VAL. The format is |
/* Accumulate information of the fontset in VAL. The format is |
1313 |
(LAST FONT-INFO FONT-INFO ...), where FONT-INFO is (CHAR-OR-RANGE |
(LAST FONT-INFO FONT-INFO ...), where FONT-INFO is (CHAR-OR-RANGE |
1314 |
FONT-SPEC). See the comment for accumulate_font_info for the |
FONT-SPEC). See the comment for accumulate_font_info for the |
1361 |
if (CONSP (elt)) |
if (CONSP (elt)) |
1362 |
{ |
{ |
1363 |
elt = XCAR (elt); |
elt = XCAR (elt); |
1364 |
fontp = (*query_font_func) (f, XSTRING (elt)->data); |
fontp = (*query_font_func) (f, SDATA (elt)); |
1365 |
} |
} |
1366 |
val = Fmake_vector (make_number (3), val); |
val = Fmake_vector (make_number (3), val); |
1367 |
AREF (val, 0) = fontp ? make_number (fontp->size) : make_number (0); |
AREF (val, 0) = fontp ? make_number (fontp->size) : make_number (0); |
1371 |
|
|
1372 |
DEFUN ("fontset-font", Ffontset_font, Sfontset_font, 2, 2, 0, |
DEFUN ("fontset-font", Ffontset_font, Sfontset_font, 2, 2, 0, |
1373 |
doc: /* Return a font name pattern for character CH in fontset NAME. |
doc: /* Return a font name pattern for character CH in fontset NAME. |
1374 |
If NAME is t, find a font name pattern in the default fontset. */) |
If NAME is nil, find a font name pattern in the default fontset. */) |
1375 |
(name, ch) |
(name, ch) |
1376 |
Lisp_Object name, ch; |
Lisp_Object name, ch; |
1377 |
{ |
{ |
1436 |
#if defined (MAC_OS) |
#if defined (MAC_OS) |
1437 |
FONTSET_ASCII (Vdefault_fontset) |
FONTSET_ASCII (Vdefault_fontset) |
1438 |
= Fcons (make_number (0), |
= Fcons (make_number (0), |
1439 |
build_string ("-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1")); |
build_string ("-apple-monaco-medium-r-*--*-120-*-*-*-*-mac-roman")); |
1440 |
#elif defined (WINDOWSNT) |
#elif defined (WINDOWSNT) |
1441 |
FONTSET_ASCII (Vdefault_fontset) |
FONTSET_ASCII (Vdefault_fontset) |
1442 |
= Fcons (make_number (0), |
= Fcons (make_number (0), |
1459 |
2: code points 0x20A0..0x7FFF are used, |
2: code points 0x20A0..0x7FFF are used, |
1460 |
3: code points 0xA020..0xFF7F are used. */); |
3: code points 0xA020..0xFF7F are used. */); |
1461 |
Vfont_encoding_alist = Qnil; |
Vfont_encoding_alist = Qnil; |
1462 |
|
Vfont_encoding_alist |
1463 |
|
= Fcons (Fcons (build_string ("JISX0201"), |
1464 |
|
Fcons (Fcons (intern ("latin-jisx0201"), make_number (0)), |
1465 |
|
Qnil)), |
1466 |
|
Vfont_encoding_alist); |
1467 |
|
Vfont_encoding_alist |
1468 |
|
= Fcons (Fcons (build_string ("ISO8859-1"), |
1469 |
|
Fcons (Fcons (intern ("ascii"), make_number (0)), |
1470 |
|
Qnil)), |
1471 |
|
Vfont_encoding_alist); |
1472 |
|
|
1473 |
DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent, |
DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent, |
1474 |
doc: /* Char table of characters whose ascent values should be ignored. |
doc: /* Char table of characters whose ascent values should be ignored. |