diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 265 |
1 files changed, 190 insertions, 75 deletions
diff --git a/src/fontset.c b/src/fontset.c index a9a6ce522f9..209d699b84e 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -113,7 +113,7 @@ EXFUN (Fclear_face_cache, 1); | |||
| 113 | range of characters. | 113 | range of characters. |
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | A fontset has 5 extra slots. | 116 | A fontset has 8 extra slots. |
| 117 | 117 | ||
| 118 | The 1st slot: the ID number of the fontset | 118 | The 1st slot: the ID number of the fontset |
| 119 | 119 | ||
| @@ -122,7 +122,7 @@ EXFUN (Fclear_face_cache, 1); | |||
| 122 | realized: nil | 122 | realized: nil |
| 123 | 123 | ||
| 124 | The 3rd slot: | 124 | The 3rd slot: |
| 125 | base: nli | 125 | base: nil |
| 126 | realized: the base fontset | 126 | realized: the base fontset |
| 127 | 127 | ||
| 128 | The 4th slot: | 128 | The 4th slot: |
| @@ -143,6 +143,10 @@ EXFUN (Fclear_face_cache, 1); | |||
| 143 | realized: Alist of font index vs the corresponding repertory | 143 | realized: Alist of font index vs the corresponding repertory |
| 144 | char-table. | 144 | char-table. |
| 145 | 145 | ||
| 146 | The 8th slot: | ||
| 147 | base: nil | ||
| 148 | realized: If the base is not the default fontset, a fontset | ||
| 149 | realized from the default fontset, else nil. | ||
| 146 | 150 | ||
| 147 | All fontsets are recorded in the vector Vfontset_table. | 151 | All fontsets are recorded in the vector Vfontset_table. |
| 148 | 152 | ||
| @@ -169,7 +173,8 @@ EXFUN (Fclear_face_cache, 1); | |||
| 169 | /********** VARIABLES and FUNCTION PROTOTYPES **********/ | 173 | /********** VARIABLES and FUNCTION PROTOTYPES **********/ |
| 170 | 174 | ||
| 171 | extern Lisp_Object Qfont; | 175 | extern Lisp_Object Qfont; |
| 172 | Lisp_Object Qfontset; | 176 | static Lisp_Object Qfontset; |
| 177 | static Lisp_Object Qfontset_info; | ||
| 173 | static Lisp_Object Qprepend, Qappend; | 178 | static Lisp_Object Qprepend, Qappend; |
| 174 | 179 | ||
| 175 | /* Vector containing all fontsets. */ | 180 | /* Vector containing all fontsets. */ |
| @@ -271,6 +276,7 @@ fontset_id_valid_p (id) | |||
| 271 | #define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] | 276 | #define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] |
| 272 | #define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] | 277 | #define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] |
| 273 | #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] | 278 | #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] |
| 279 | #define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[7] | ||
| 274 | 280 | ||
| 275 | 281 | ||
| 276 | /* Return the element of FONTSET for the character C. If FONTSET is a | 282 | /* Return the element of FONTSET for the character C. If FONTSET is a |
| @@ -483,23 +489,24 @@ fontset_face (fontset, c, face) | |||
| 483 | int c; | 489 | int c; |
| 484 | struct face *face; | 490 | struct face *face; |
| 485 | { | 491 | { |
| 486 | Lisp_Object elt, vec; | 492 | Lisp_Object base_fontset, elt, vec; |
| 487 | int i, from, to; | 493 | int i, from, to; |
| 488 | int font_idx; | 494 | int font_idx; |
| 489 | FRAME_PTR f = XFRAME (FONTSET_FRAME (fontset)); | 495 | FRAME_PTR f = XFRAME (FONTSET_FRAME (fontset)); |
| 490 | 496 | ||
| 497 | base_fontset = FONTSET_BASE (fontset); | ||
| 491 | elt = CHAR_TABLE_REF (fontset, c); | 498 | elt = CHAR_TABLE_REF (fontset, c); |
| 492 | 499 | ||
| 493 | if (EQ (elt, Qt)) | 500 | if (EQ (elt, Qt)) |
| 494 | goto font_not_found; | 501 | goto try_default; |
| 502 | |||
| 495 | if (NILP (elt)) | 503 | if (NILP (elt)) |
| 496 | { | 504 | { |
| 497 | /* We have not yet decided a face for C. */ | 505 | /* We have not yet decided a face for C. */ |
| 498 | Lisp_Object base_fontset, range; | 506 | Lisp_Object range; |
| 499 | 507 | ||
| 500 | if (! face) | 508 | if (! face) |
| 501 | return -1; | 509 | return -1; |
| 502 | base_fontset = FONTSET_BASE (fontset); | ||
| 503 | elt = FONTSET_REF_AND_RANGE (base_fontset, c, from, to); | 510 | elt = FONTSET_REF_AND_RANGE (base_fontset, c, from, to); |
| 504 | range = Fcons (make_number (from), make_number (to)); | 511 | range = Fcons (make_number (from), make_number (to)); |
| 505 | if (NILP (elt)) | 512 | if (NILP (elt)) |
| @@ -507,7 +514,7 @@ fontset_face (fontset, c, face) | |||
| 507 | /* Record that we have no font for characters of this | 514 | /* Record that we have no font for characters of this |
| 508 | range. */ | 515 | range. */ |
| 509 | FONTSET_SET (fontset, range, Qt); | 516 | FONTSET_SET (fontset, range, Qt); |
| 510 | goto font_not_found; | 517 | goto try_default; |
| 511 | } | 518 | } |
| 512 | elt = Fcopy_sequence (elt); | 519 | elt = Fcopy_sequence (elt); |
| 513 | /* Now ELT is a vector of FONT-DEFs. We at first change it to | 520 | /* Now ELT is a vector of FONT-DEFs. We at first change it to |
| @@ -556,7 +563,7 @@ fontset_face (fontset, c, face) | |||
| 556 | = CHARSET_FROM_ID (XINT (AREF (font_def, 2))); | 563 | = CHARSET_FROM_ID (XINT (AREF (font_def, 2))); |
| 557 | 564 | ||
| 558 | if (! CHAR_CHARSET_P (c, charset)) | 565 | if (! CHAR_CHARSET_P (c, charset)) |
| 559 | /* This fond can't display C. */ | 566 | /* This font can't display C. */ |
| 560 | continue; | 567 | continue; |
| 561 | } | 568 | } |
| 562 | else | 569 | else |
| @@ -609,6 +616,10 @@ fontset_face (fontset, c, face) | |||
| 609 | return XINT (AREF (elt, 0)); | 616 | return XINT (AREF (elt, 0)); |
| 610 | } | 617 | } |
| 611 | 618 | ||
| 619 | try_default: | ||
| 620 | if (! EQ (base_fontset, Vdefault_fontset)) | ||
| 621 | return fontset_face (FONTSET_FALLBACK (fontset), c, face); | ||
| 622 | |||
| 612 | font_not_found: | 623 | font_not_found: |
| 613 | /* We have tried all the fonts for C, but none of them can be opened | 624 | /* We have tried all the fonts for C, but none of them can be opened |
| 614 | nor can display C. */ | 625 | nor can display C. */ |
| @@ -672,6 +683,8 @@ make_fontset (frame, name, base) | |||
| 672 | 683 | ||
| 673 | ASET (Vfontset_table, id, fontset); | 684 | ASET (Vfontset_table, id, fontset); |
| 674 | next_fontset_id = id + 1; | 685 | next_fontset_id = id + 1; |
| 686 | if (! NILP (base) && ! EQ (base, Vdefault_fontset)) | ||
| 687 | FONTSET_FALLBACK (fontset) = make_fontset (frame, Qnil, Vdefault_fontset); | ||
| 675 | return fontset; | 688 | return fontset; |
| 676 | } | 689 | } |
| 677 | 690 | ||
| @@ -1130,6 +1143,28 @@ accumulate_script_ranges (arg, range, val) | |||
| 1130 | } | 1143 | } |
| 1131 | 1144 | ||
| 1132 | 1145 | ||
| 1146 | /* Return an ASCII font name generated from fontset name NAME and | ||
| 1147 | ASCII font specification ASCII_SPEC. NAME is a string conforming | ||
| 1148 | to XLFD. ASCII_SPEC is a vector: | ||
| 1149 | [FAMILY WEIGHT SLANT SWIDTH ADSTYLE REGISTRY]. */ | ||
| 1150 | |||
| 1151 | static INLINE Lisp_Object | ||
| 1152 | generate_ascii_font_name (name, ascii_spec) | ||
| 1153 | Lisp_Object name, ascii_spec; | ||
| 1154 | { | ||
| 1155 | Lisp_Object vec; | ||
| 1156 | int i; | ||
| 1157 | |||
| 1158 | vec = split_font_name_into_vector (name); | ||
| 1159 | for (i = FONT_SPEC_FAMILY_INDEX; i <= FONT_SPEC_ADSTYLE_INDEX; i++) | ||
| 1160 | if (! NILP (AREF (ascii_spec, i))) | ||
| 1161 | ASET (vec, 1 + i, AREF (ascii_spec, i)); | ||
| 1162 | if (! NILP (AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX))) | ||
| 1163 | ASET (vec, 12, AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX)); | ||
| 1164 | return build_font_name_from_vector (vec); | ||
| 1165 | } | ||
| 1166 | |||
| 1167 | |||
| 1133 | DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0, | 1168 | DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0, |
| 1134 | doc: /* | 1169 | doc: /* |
| 1135 | Modify fontset NAME to use FONT-SPEC for CHARACTER. | 1170 | Modify fontset NAME to use FONT-SPEC for CHARACTER. |
| @@ -1180,21 +1215,21 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1180 | { | 1215 | { |
| 1181 | int j; | 1216 | int j; |
| 1182 | 1217 | ||
| 1183 | if (ASIZE (font_spec) != 6) | 1218 | if (ASIZE (font_spec) != FONT_SPEC_MAX_INDEX) |
| 1184 | args_out_of_range (make_number (6), | 1219 | args_out_of_range (make_number (FONT_SPEC_MAX_INDEX), |
| 1185 | make_number (ASIZE (font_spec))); | 1220 | make_number (ASIZE (font_spec))); |
| 1186 | 1221 | ||
| 1187 | font_spec = Fcopy_sequence (font_spec); | 1222 | font_spec = Fcopy_sequence (font_spec); |
| 1188 | for (j = 0; j < 5; j++) | 1223 | for (j = 0; j < FONT_SPEC_MAX_INDEX - 1; j++) |
| 1189 | if (! NILP (AREF (font_spec, j))) | 1224 | if (! NILP (AREF (font_spec, j))) |
| 1190 | { | 1225 | { |
| 1191 | CHECK_STRING (AREF (font_spec, j)); | 1226 | CHECK_STRING (AREF (font_spec, j)); |
| 1192 | ASET (font_spec, j, Fdowncase (AREF (font_spec, j))); | 1227 | ASET (font_spec, j, Fdowncase (AREF (font_spec, j))); |
| 1193 | } | 1228 | } |
| 1194 | /* REGISTRY should not be omitted. */ | 1229 | /* REGISTRY should not be omitted. */ |
| 1195 | CHECK_STRING (AREF (font_spec, 5)); | 1230 | CHECK_STRING (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX)); |
| 1196 | registry = Fdowncase (AREF (font_spec, 5)); | 1231 | registry = Fdowncase (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX)); |
| 1197 | ASET (font_spec, 5, registry); | 1232 | ASET (font_spec, FONT_SPEC_REGISTRY_INDEX, registry); |
| 1198 | 1233 | ||
| 1199 | } | 1234 | } |
| 1200 | else if (CONSP (font_spec)) | 1235 | else if (CONSP (font_spec)) |
| @@ -1211,17 +1246,22 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1211 | } | 1246 | } |
| 1212 | CHECK_STRING (registry); | 1247 | CHECK_STRING (registry); |
| 1213 | registry = Fdowncase (registry); | 1248 | registry = Fdowncase (registry); |
| 1214 | font_spec = Fmake_vector (make_number (6), Qnil); | 1249 | font_spec = Fmake_vector (make_number (FONT_SPEC_MAX_INDEX), Qnil); |
| 1215 | ASET (font_spec, 0, family); | 1250 | ASET (font_spec, FONT_SPEC_FAMILY_INDEX, family); |
| 1216 | ASET (font_spec, 5, registry); | 1251 | ASET (font_spec, FONT_SPEC_REGISTRY_INDEX, registry); |
| 1217 | } | 1252 | } |
| 1218 | else | 1253 | else |
| 1219 | { | 1254 | { |
| 1220 | CHECK_STRING (font_spec); | 1255 | CHECK_STRING (font_spec); |
| 1221 | font_spec = Fdowncase (font_spec); | 1256 | font_spec = Fdowncase (font_spec); |
| 1222 | registry = font_name_registry (font_spec); | 1257 | registry = split_font_name_into_vector (font_spec); |
| 1223 | if (NILP (registry)) | 1258 | if (NILP (registry)) |
| 1224 | error ("No XLFD: %s", XSTRING (font_spec)->data); | 1259 | error ("No XLFD: %s", XSTRING (font_spec)->data); |
| 1260 | if (NILP (AREF (registry, 12)) | ||
| 1261 | || NILP (AREF (registry, 13))) | ||
| 1262 | error ("Registry must be specified"); | ||
| 1263 | registry = concat2 (concat2 (AREF (registry, 12), build_string ("-")), | ||
| 1264 | AREF (registry, 13)); | ||
| 1225 | } | 1265 | } |
| 1226 | 1266 | ||
| 1227 | if (STRINGP (font_spec)) | 1267 | if (STRINGP (font_spec)) |
| @@ -1278,7 +1318,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1278 | range_list); | 1318 | range_list); |
| 1279 | if (EQ (character, Qascii)) | 1319 | if (EQ (character, Qascii)) |
| 1280 | { | 1320 | { |
| 1281 | if (! STRINGP (font_spec)) | 1321 | if (VECTORP (font_spec)) |
| 1282 | font_spec = generate_ascii_font_name (FONTSET_NAME (fontset), | 1322 | font_spec = generate_ascii_font_name (FONTSET_NAME (fontset), |
| 1283 | font_spec); | 1323 | font_spec); |
| 1284 | FONTSET_ASCII (fontset) = font_spec; | 1324 | FONTSET_ASCII (fontset) = font_spec; |
| @@ -1306,10 +1346,12 @@ DEFUN ("new-fontset", Fnew_fontset, Snew_fontset, 2, 2, 0, | |||
| 1306 | doc: /* Create a new fontset NAME from font information in FONTLIST. | 1346 | doc: /* Create a new fontset NAME from font information in FONTLIST. |
| 1307 | 1347 | ||
| 1308 | FONTLIST is an alist of scripts vs the corresponding font specification list. | 1348 | FONTLIST is an alist of scripts vs the corresponding font specification list. |
| 1309 | Each element of FONTLIST has the form (SCRIPT FONT-SPEC ...), where | 1349 | Each element of FONTLIST has the form (SCRIPT FONT-SPEC ...), where a |
| 1310 | a character of SCRIPT is displayed by a font that matches FONT-SPEC. | 1350 | character of SCRIPT is displayed by a font that matches one of |
| 1351 | FONT-SPEC. | ||
| 1311 | 1352 | ||
| 1312 | SCRIPT is a symbol that appears in the variable `script-alist'. | 1353 | SCRIPT is a symbol that appears in the first extra slot of the |
| 1354 | char-table `char-script-table'. | ||
| 1313 | 1355 | ||
| 1314 | FONT-SPEC is a vector, a cons, or a string. See the documentation of | 1356 | FONT-SPEC is a vector, a cons, or a string. See the documentation of |
| 1315 | `set-fontset-font' for the meaning. */) | 1357 | `set-fontset-font' for the meaning. */) |
| @@ -1323,14 +1365,24 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of | |||
| 1323 | CHECK_STRING (name); | 1365 | CHECK_STRING (name); |
| 1324 | CHECK_LIST (fontlist); | 1366 | CHECK_LIST (fontlist); |
| 1325 | 1367 | ||
| 1326 | /* Check if an ASCII font is specified in FONTLIST. */ | ||
| 1327 | val = Fcar (Fcdr (Fassq (Qascii, fontlist))); | ||
| 1328 | if (NILP (val)) | ||
| 1329 | error ("No ascii font specified"); | ||
| 1330 | |||
| 1331 | id = fs_query_fontset (name, 0); | 1368 | id = fs_query_fontset (name, 0); |
| 1332 | if (id < 0) | 1369 | if (id < 0) |
| 1333 | fontset = make_fontset (Qnil, Fdowncase (name), Qnil); | 1370 | { |
| 1371 | name = Fdowncase (name); | ||
| 1372 | val = split_font_name_into_vector (name); | ||
| 1373 | if (NILP (val)) | ||
| 1374 | error ("Fontset name must be in XLFD format"); | ||
| 1375 | if (strcmp (XSTRING (AREF (val, 12))->data, "fontset")) | ||
| 1376 | error ("Registry field of fontset name must be \"fontset\""); | ||
| 1377 | Vfontset_alias_alist | ||
| 1378 | = Fcons (Fcons (name, | ||
| 1379 | concat2 (concat2 (AREF (val, 12), build_string ("-")), | ||
| 1380 | AREF (val, 13))), | ||
| 1381 | Vfontset_alias_alist); | ||
| 1382 | ASET (val, 12, build_string ("iso8859-1")); | ||
| 1383 | fontset = make_fontset (Qnil, name, Qnil); | ||
| 1384 | FONTSET_ASCII (fontset) = build_font_name_from_vector (val); | ||
| 1385 | } | ||
| 1334 | else | 1386 | else |
| 1335 | { | 1387 | { |
| 1336 | fontset = FONTSET_FROM_ID (id);; | 1388 | fontset = FONTSET_FROM_ID (id);; |
| @@ -1344,15 +1396,51 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of | |||
| 1344 | 1396 | ||
| 1345 | elt = Fcar (fontlist); | 1397 | elt = Fcar (fontlist); |
| 1346 | script = Fcar (elt); | 1398 | script = Fcar (elt); |
| 1347 | elt = Fcdr (elt); | ||
| 1348 | Fset_fontset_font (name, script, Fcar (elt), Qnil, Qnil); | ||
| 1349 | for (elt = Fcdr (elt); ! NILP (elt); elt = Fcdr (elt)) | 1399 | for (elt = Fcdr (elt); ! NILP (elt); elt = Fcdr (elt)) |
| 1350 | Fset_fontset_font (name, script, XCAR (elt), Qnil, Qappend); | 1400 | Fset_fontset_font (name, script, Fcar (elt), Qnil, Qappend); |
| 1351 | } | 1401 | } |
| 1352 | return name; | 1402 | return name; |
| 1353 | } | 1403 | } |
| 1354 | 1404 | ||
| 1355 | 1405 | ||
| 1406 | /* Number of fontsets created from a fontname automatically. */ | ||
| 1407 | static int n_auto_fontsets; | ||
| 1408 | |||
| 1409 | int | ||
| 1410 | new_fontset_from_font_name (Lisp_Object fontname) | ||
| 1411 | { | ||
| 1412 | Lisp_Object name; | ||
| 1413 | Lisp_Object vec; | ||
| 1414 | |||
| 1415 | fontname = Fdowncase (fontname); | ||
| 1416 | vec = split_font_name_into_vector (fontname); | ||
| 1417 | if ( NILP (vec)) | ||
| 1418 | vec = Fmake_vector (make_number (14), build_string ("")); | ||
| 1419 | ASET (vec, 12, build_string ("fontset")); | ||
| 1420 | if (n_auto_fontsets == 0) | ||
| 1421 | { | ||
| 1422 | ASET (vec, 13, build_string ("startup")); | ||
| 1423 | name = build_font_name_from_vector (vec); | ||
| 1424 | n_auto_fontsets++; | ||
| 1425 | } | ||
| 1426 | else | ||
| 1427 | { | ||
| 1428 | char temp[20]; | ||
| 1429 | |||
| 1430 | do { | ||
| 1431 | sprintf (temp, "auto%d", n_auto_fontsets); | ||
| 1432 | ASET (vec, 13, build_string (temp)); | ||
| 1433 | name = build_font_name_from_vector (vec); | ||
| 1434 | n_auto_fontsets++; | ||
| 1435 | } while (fs_query_fontset (name, 0) >= 0); | ||
| 1436 | } | ||
| 1437 | name = Fnew_fontset (name, | ||
| 1438 | Fcons (Fcons (Qascii, Fcons (fontname, Qnil)), Qnil)); | ||
| 1439 | Vfontset_alias_alist = Fcons (Fcons (name, fontname), Vfontset_alias_alist); | ||
| 1440 | return fs_query_fontset (name, 0); | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | |||
| 1356 | DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, | 1444 | DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, |
| 1357 | doc: /* Return information about a font named NAME on frame FRAME. | 1445 | doc: /* Return information about a font named NAME on frame FRAME. |
| 1358 | If FRAME is omitted or nil, use the selected frame. | 1446 | If FRAME is omitted or nil, use the selected frame. |
| @@ -1465,7 +1553,11 @@ FONT-PATTERN is a vector: | |||
| 1465 | 1553 | ||
| 1466 | or a string of font name pattern. | 1554 | or a string of font name pattern. |
| 1467 | 1555 | ||
| 1468 | OPENED-FONT is a name of a font actually opened. */) | 1556 | OPENED-FONT is a name of a font actually opened. |
| 1557 | |||
| 1558 | The char-table has one extra slot. The value is a char-table | ||
| 1559 | containing the information about the derived fonts from the default | ||
| 1560 | fontset. The format is the same as abobe. */) | ||
| 1469 | (fontset, frame) | 1561 | (fontset, frame) |
| 1470 | Lisp_Object fontset, frame; | 1562 | Lisp_Object fontset, frame; |
| 1471 | { | 1563 | { |
| @@ -1473,6 +1565,7 @@ OPENED-FONT is a name of a font actually opened. */) | |||
| 1473 | Lisp_Object table, val, elt; | 1565 | Lisp_Object table, val, elt; |
| 1474 | Lisp_Object *realized; | 1566 | Lisp_Object *realized; |
| 1475 | int n_realized = 0; | 1567 | int n_realized = 0; |
| 1568 | int fallback; | ||
| 1476 | int c, i, j; | 1569 | int c, i, j; |
| 1477 | 1570 | ||
| 1478 | (*check_window_system_func) (); | 1571 | (*check_window_system_func) (); |
| @@ -1498,57 +1591,77 @@ OPENED-FONT is a name of a font actually opened. */) | |||
| 1498 | } | 1591 | } |
| 1499 | 1592 | ||
| 1500 | 1593 | ||
| 1501 | table = Fmake_char_table (Qnil, Qnil); | 1594 | table = Fmake_char_table (Qfontset_info, Qnil); |
| 1595 | XCHAR_TABLE (table)->extras[0] = Fmake_char_table (Qnil, Qnil); | ||
| 1502 | /* Accumulate information of the fontset in TABLE. The format of | 1596 | /* Accumulate information of the fontset in TABLE. The format of |
| 1503 | each element is ((FONT-SPEC OPENED-FONT ...) ...). */ | 1597 | each element is ((FONT-SPEC OPENED-FONT ...) ...). */ |
| 1504 | for (c = 0; c <= MAX_CHAR; ) | 1598 | for (fallback = 0; fallback <= 1; fallback++) |
| 1505 | { | 1599 | { |
| 1506 | int from, to; | 1600 | Lisp_Object this_fontset, this_table; |
| 1507 | 1601 | ||
| 1508 | val = FONTSET_REF_AND_RANGE (fontset, c, from, to); | 1602 | if (! fallback) |
| 1509 | if (VECTORP (val)) | ||
| 1510 | { | 1603 | { |
| 1511 | Lisp_Object alist; | 1604 | this_fontset = fontset; |
| 1512 | 1605 | this_table = table; | |
| 1513 | /* At first, set ALIST to ((FONT-SPEC) ...). */ | 1606 | } |
| 1514 | for (alist = Qnil, i = 0; i < ASIZE (val); i++) | 1607 | else |
| 1515 | alist = Fcons (Fcons (AREF (AREF (val, i), 0), Qnil), alist); | 1608 | { |
| 1516 | alist = Fnreverse (alist); | 1609 | this_fontset = Vdefault_fontset; |
| 1517 | 1610 | this_table = XCHAR_TABLE (table)->extras[0]; | |
| 1518 | /* Then store opend font names to cdr of each elements. */ | ||
| 1519 | for (i = 0; i < n_realized; i++) | 1611 | for (i = 0; i < n_realized; i++) |
| 1612 | realized[i] = FONTSET_FALLBACK (realized[i]); | ||
| 1613 | } | ||
| 1614 | for (c = 0; c <= MAX_5_BYTE_CHAR; ) | ||
| 1615 | { | ||
| 1616 | int from, to; | ||
| 1617 | |||
| 1618 | val = char_table_ref_and_range (this_fontset, c, &from, &to); | ||
| 1619 | if (VECTORP (val)) | ||
| 1520 | { | 1620 | { |
| 1521 | val = FONTSET_REF (realized[i], c); | 1621 | Lisp_Object alist; |
| 1522 | if (NILP (val)) | 1622 | |
| 1523 | continue; | 1623 | /* At first, set ALIST to ((FONT-SPEC) ...). */ |
| 1524 | val = XCDR (val); | 1624 | for (alist = Qnil, i = 0; i < ASIZE (val); i++) |
| 1525 | /* Now VAL is [[FACE-ID FONT-INDEX FONT-DEF] ...]. | 1625 | alist = Fcons (Fcons (AREF (AREF (val, i), 0), Qnil), alist); |
| 1526 | If a font of an element is already opened, | 1626 | alist = Fnreverse (alist); |
| 1527 | FONT-INDEX of the element is integer. */ | 1627 | |
| 1528 | for (j = 0; j < ASIZE (val); j++) | 1628 | /* Then store opend font names to cdr of each elements. */ |
| 1529 | if (INTEGERP (AREF (AREF (val, j), 0))) | 1629 | for (i = 0; i < n_realized; i++) |
| 1630 | { | ||
| 1631 | if (NILP (realized[i])) | ||
| 1632 | continue; | ||
| 1633 | val = FONTSET_REF (realized[i], c); | ||
| 1634 | if (NILP (val)) | ||
| 1635 | continue; | ||
| 1636 | val = XCDR (val); | ||
| 1637 | /* Now VAL is [[FACE-ID FONT-INDEX FONT-DEF] ...]. | ||
| 1638 | If a font of an element is already opened, | ||
| 1639 | FONT-INDEX of the element is integer. */ | ||
| 1640 | for (j = 0; j < ASIZE (val); j++) | ||
| 1641 | if (INTEGERP (AREF (AREF (val, j), 0))) | ||
| 1642 | { | ||
| 1643 | Lisp_Object font_idx; | ||
| 1644 | |||
| 1645 | font_idx = AREF (AREF (val, j), 1); | ||
| 1646 | elt = Fassq (AREF (AREF (AREF (val, j), 2), 0), alist); | ||
| 1647 | if (CONSP (elt) | ||
| 1648 | && NILP (Fmemq (font_idx, XCDR(elt)))) | ||
| 1649 | nconc2 (elt, Fcons (font_idx, Qnil)); | ||
| 1650 | } | ||
| 1651 | } | ||
| 1652 | for (val = alist; CONSP (val); val = XCDR (val)) | ||
| 1653 | for (elt = XCDR (XCAR (val)); CONSP (elt); elt = XCDR (elt)) | ||
| 1530 | { | 1654 | { |
| 1531 | Lisp_Object font_idx; | 1655 | struct font_info *font_info |
| 1532 | 1656 | = (*get_font_info_func) (f, XINT (XCAR (elt))); | |
| 1533 | font_idx = AREF (AREF (val, j), 1); | 1657 | XSETCAR (elt, build_string (font_info->full_name)); |
| 1534 | elt = Fassq (AREF (AREF (AREF (val, j), 2), 0), alist); | ||
| 1535 | if (CONSP (elt) | ||
| 1536 | && NILP (Fmemq (font_idx, XCDR(elt)))) | ||
| 1537 | nconc2 (elt, Fcons (font_idx, Qnil)); | ||
| 1538 | } | 1658 | } |
| 1659 | |||
| 1660 | /* Store ALIST in TBL for characters C..TO. */ | ||
| 1661 | char_table_set_range (this_table, c, to, alist); | ||
| 1539 | } | 1662 | } |
| 1540 | for (val = alist; CONSP (val); val = XCDR (val)) | 1663 | c = to + 1; |
| 1541 | for (elt = XCDR (XCAR (val)); CONSP (elt); elt = XCDR (elt)) | ||
| 1542 | { | ||
| 1543 | struct font_info *font_info | ||
| 1544 | = (*get_font_info_func) (f, XINT (XCAR (elt))); | ||
| 1545 | XSETCAR (elt, build_string (font_info->full_name)); | ||
| 1546 | } | ||
| 1547 | |||
| 1548 | /* Store ALIST in TABLE for characters C..TO. */ | ||
| 1549 | char_table_set_range (table, c, to, alist); | ||
| 1550 | } | 1664 | } |
| 1551 | c = to + 1; | ||
| 1552 | } | 1665 | } |
| 1553 | 1666 | ||
| 1554 | return table; | 1667 | return table; |
| @@ -1599,7 +1712,9 @@ syms_of_fontset () | |||
| 1599 | abort (); | 1712 | abort (); |
| 1600 | 1713 | ||
| 1601 | DEFSYM (Qfontset, "fontset"); | 1714 | DEFSYM (Qfontset, "fontset"); |
| 1602 | Fput (Qfontset, Qchar_table_extra_slots, make_number (7)); | 1715 | Fput (Qfontset, Qchar_table_extra_slots, make_number (8)); |
| 1716 | DEFSYM (Qfontset_info, "fontset-info"); | ||
| 1717 | Fput (Qfontset_info, Qchar_table_extra_slots, make_number (1)); | ||
| 1603 | 1718 | ||
| 1604 | DEFSYM (Qprepend, "prepend"); | 1719 | DEFSYM (Qprepend, "prepend"); |
| 1605 | DEFSYM (Qappend, "append"); | 1720 | DEFSYM (Qappend, "append"); |