aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2004-04-14 05:17:00 +0000
committerKenichi Handa2004-04-14 05:17:00 +0000
commitfb78e2ed238e3dd0dde710f5c06bbdfa76dd75d4 (patch)
treebdb9817b702c16cf4c24bad1f44d5345f8044e69 /src
parent3662d9e761ad6b87d71fcf970b7d2d8776ec9ef4 (diff)
downloademacs-fb78e2ed238e3dd0dde710f5c06bbdfa76dd75d4.tar.gz
emacs-fb78e2ed238e3dd0dde710f5c06bbdfa76dd75d4.zip
(find_font_encoding): Return `ascii' for unknown
encoding. (load_font_get_repertory): Delete unnecessary check of ENCODING of FONT_DEF. (font_def_arg, add_arg, from_arg, to_arg): New args. (set_fontset_font): Argument changed. (Fset_fontset_font): Fix for the case that TARGET is a script name and charset name. (new_fontset_from_font_name): Fix argument to Fnew_fontset.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c93
1 files changed, 62 insertions, 31 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 368ad5a9db8..e6dcc088a97 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -483,10 +483,7 @@ load_font_get_repertory (f, face, font_def, fontset)
483 int charset; 483 int charset;
484 484
485 font_name = choose_face_font (f, face->lface, AREF (font_def, 0), NULL); 485 font_name = choose_face_font (f, face->lface, AREF (font_def, 0), NULL);
486 if (NATNUMP (AREF (font_def, 1))) 486 charset = XINT (AREF (font_def, 1));
487 charset = XINT (AREF (font_def, 1));
488 else
489 charset = -1;
490 if (! (font_info = fs_load_font (f, font_name, charset))) 487 if (! (font_info = fs_load_font (f, font_name, charset)))
491 return -1; 488 return -1;
492 489
@@ -1031,8 +1028,8 @@ find_font_encoding (fontname)
1031 : CONSP (XCDR (elt)) && CHARSETP (XCAR (XCDR (elt))))) 1028 : CONSP (XCDR (elt)) && CHARSETP (XCAR (XCDR (elt)))))
1032 return (XCDR (elt)); 1029 return (XCDR (elt));
1033 } 1030 }
1034 /* We don't know the encoding of this font. */ 1031 /* We don't know the encoding of this font. Let's assume `ascii'. */
1035 return Qnil; 1032 return Qascii;
1036} 1033}
1037 1034
1038 1035
@@ -1300,17 +1297,46 @@ generate_ascii_font_name (name, ascii_spec)
1300 return build_font_name_from_vector (vec); 1297 return build_font_name_from_vector (vec);
1301} 1298}
1302 1299
1300/* Variables referred in set_fontset_font. They are set before
1301 map_charset_chars is called in Fset_fontset_font. */
1302static Lisp_Object font_def_arg, add_arg;
1303static int from_arg, to_arg;
1304
1305/* Callback function for map_charset_chars in Fset_fontset_font. In
1306 FONTSET, set font_def_arg in a fashion specified by add_arg for
1307 characters in RANGE while ignoring the range between from_arg and
1308 to_arg. */
1309
1303static void 1310static void
1304set_fontset_font (arg, range) 1311set_fontset_font (fontset, range)
1305 Lisp_Object arg, range; 1312 Lisp_Object fontset, range;
1306{ 1313{
1307 Lisp_Object fontset, font_def, add; 1314 if (from_arg < to_arg)
1315 {
1316 int from = XINT (XCAR (range)), to = XINT (XCDR (range));
1308 1317
1309 fontset = XCAR (arg); 1318 if (from < from_arg)
1310 font_def = XCAR (XCDR (arg)); 1319 {
1311 add = XCAR (XCDR (XCDR (arg))); 1320 if (to > to_arg)
1312 FONTSET_ADD (fontset, range, font_def, add); 1321 {
1313 free_realized_fontsets (fontset); 1322 Lisp_Object range2;
1323
1324 range2 = Fcons (make_number (to_arg), XCDR (range));
1325 FONTSET_ADD (fontset, range, font_def_arg, add_arg);
1326 to = to_arg;
1327 }
1328 if (to > from_arg)
1329 range = Fcons (XCAR (range), make_number (from_arg));
1330 }
1331 else if (to <= to_arg)
1332 return;
1333 else
1334 {
1335 if (from < to_arg)
1336 range = Fcons (make_number (to_arg), XCDR (range));
1337 }
1338 }
1339 FONTSET_ADD (fontset, range, font_def_arg, add_arg);
1314} 1340}
1315 1341
1316 1342
@@ -1353,6 +1379,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1353 Lisp_Object font_def, registry; 1379 Lisp_Object font_def, registry;
1354 Lisp_Object encoding, repertory; 1380 Lisp_Object encoding, repertory;
1355 Lisp_Object range_list; 1381 Lisp_Object range_list;
1382 struct charset *charset = NULL;
1356 1383
1357 fontset = check_fontset_name (name); 1384 fontset = check_fontset_name (name);
1358 1385
@@ -1410,9 +1437,6 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1410 encoding = find_font_encoding ((char *) SDATA (font_spec)); 1437 encoding = find_font_encoding ((char *) SDATA (font_spec));
1411 else 1438 else
1412 encoding = find_font_encoding ((char *) SDATA (registry)); 1439 encoding = find_font_encoding ((char *) SDATA (registry));
1413 if (NILP (encoding))
1414 /* We don't know how to use this font. */
1415 return Qnil;
1416 if (SYMBOLP (encoding)) 1440 if (SYMBOLP (encoding))
1417 { 1441 {
1418 CHECK_CHARSET (encoding); 1442 CHECK_CHARSET (encoding);
@@ -1460,11 +1484,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1460 val); 1484 val);
1461 range_list = XCDR (val); 1485 range_list = XCDR (val);
1462 } 1486 }
1463 else if (CHARSETP (target)) 1487 if (CHARSETP (target))
1464 { 1488 {
1465 struct charset *charset;
1466
1467 CHECK_CHARSET_GET_CHARSET (target, charset);
1468 if (EQ (target, Qascii)) 1489 if (EQ (target, Qascii))
1469 { 1490 {
1470 if (VECTORP (font_spec)) 1491 if (VECTORP (font_spec))
@@ -1476,15 +1497,10 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1476 } 1497 }
1477 else 1498 else
1478 { 1499 {
1479 map_charset_chars (set_fontset_font, Qnil, 1500 CHECK_CHARSET_GET_CHARSET (target, charset);
1480 list3 (fontset, font_def, add), charset,
1481 CHARSET_MIN_CODE (charset),
1482 CHARSET_MAX_CODE (charset));
1483 return Qnil;
1484 } 1501 }
1485 } 1502 }
1486 1503 else if (NILP (range_list))
1487 if (NILP (range_list))
1488 error ("Invalid script or charset name: %s", 1504 error ("Invalid script or charset name: %s",
1489 SDATA (SYMBOL_NAME (target))); 1505 SDATA (SYMBOL_NAME (target)));
1490 } 1506 }
@@ -1493,6 +1509,21 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1493 else 1509 else
1494 error ("Invalid target for setting a font"); 1510 error ("Invalid target for setting a font");
1495 1511
1512
1513 if (charset)
1514 {
1515 font_def_arg = font_def;
1516 add_arg = add;
1517 if (NILP (range_list))
1518 from_arg = to_arg = 0;
1519 else
1520 from_arg = XINT (XCAR (XCAR (range_list))),
1521 to_arg = XINT (XCDR (XCAR (range_list)));
1522
1523 map_charset_chars (set_fontset_font, Qnil, fontset, charset,
1524 CHARSET_MIN_CODE (charset),
1525 CHARSET_MAX_CODE (charset));
1526 }
1496 for (; CONSP (range_list); range_list = XCDR (range_list)) 1527 for (; CONSP (range_list); range_list = XCDR (range_list))
1497 FONTSET_ADD (fontset, XCAR (range_list), font_def, add); 1528 FONTSET_ADD (fontset, XCAR (range_list), font_def, add);
1498 1529
@@ -1605,10 +1636,10 @@ new_fontset_from_font_name (Lisp_Object fontname)
1605 ASET (vec, 13, build_string (temp)); 1636 ASET (vec, 13, build_string (temp));
1606 name = build_font_name_from_vector (vec); 1637 name = build_font_name_from_vector (vec);
1607 } 1638 }
1608 name = Fnew_fontset (name, Fcons (Fcons (Fcons (make_number (0), 1639 name = Fnew_fontset (name, list2 (list2 (Qascii, fontname),
1640 list2 (Fcons (make_number (0),
1609 make_number (MAX_CHAR)), 1641 make_number (MAX_CHAR)),
1610 Fcons (fontname, Qnil)), 1642 fontname)));
1611 Qnil));
1612 id = fs_query_fontset (name, 0); 1643 id = fs_query_fontset (name, 0);
1613 auto_fontset_alist 1644 auto_fontset_alist
1614 = Fcons (Fcons (fontname, make_number (id)), auto_fontset_alist); 1645 = Fcons (Fcons (fontname, make_number (id)), auto_fontset_alist);