aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2003-10-29 11:51:42 +0000
committerKenichi Handa2003-10-29 11:51:42 +0000
commit452a78e0a94c69ef8c45563689e865edacbf537e (patch)
tree45a5584183cdb7ad228152d73097b22a6ad8da15 /src
parent741caaa7093ecad3e530e93b865e42b37388563f (diff)
downloademacs-452a78e0a94c69ef8c45563689e865edacbf537e.tar.gz
emacs-452a78e0a94c69ef8c45563689e865edacbf537e.zip
(fontset_face): Create a fallback fontset on demand
(make_fontset): Don't create a fallback fontset here. (free_face_fontset): Free a fallback fontset (if any) too. (n_auto_fontsets): Delete this variable. (auto_fontset_alist): New variable. (new_fontset_from_font_name): Check auto_fontset_alist. (dump_fontset) [FONTSET_DEBUG]: Fully re-written. (Ffontset_list_all) [FONTSET_DEBUG]: New function. (syms_of_fontset): Initialize and staticpro auto_fontset_alist. Defsubr Sfontset_list_all.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c138
1 files changed, 98 insertions, 40 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 1f9939e286e..55a07303bbb 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -627,7 +627,12 @@ fontset_face (fontset, c, face)
627 627
628 try_default: 628 try_default:
629 if (! EQ (base_fontset, Vdefault_fontset)) 629 if (! EQ (base_fontset, Vdefault_fontset))
630 return fontset_face (FONTSET_FALLBACK (fontset), c, face); 630 {
631 if (NILP (FONTSET_FALLBACK (fontset)))
632 FONTSET_FALLBACK (fontset)
633 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset);
634 return fontset_face (FONTSET_FALLBACK (fontset), c, face);
635 }
631 636
632 /* We have tried all the fonts for C, but none of them can be opened 637 /* We have tried all the fonts for C, but none of them can be opened
633 nor can display C. */ 638 nor can display C. */
@@ -691,8 +696,6 @@ make_fontset (frame, name, base)
691 696
692 ASET (Vfontset_table, id, fontset); 697 ASET (Vfontset_table, id, fontset);
693 next_fontset_id = id + 1; 698 next_fontset_id = id + 1;
694 if (! NILP (base) && ! EQ (base, Vdefault_fontset))
695 FONTSET_FALLBACK (fontset) = make_fontset (frame, Qnil, Vdefault_fontset);
696 return fontset; 699 return fontset;
697} 700}
698 701
@@ -737,9 +740,25 @@ free_face_fontset (f, face)
737 FRAME_PTR f; 740 FRAME_PTR f;
738 struct face *face; 741 struct face *face;
739{ 742{
743 Lisp_Object fontset;
744
745 fontset = AREF (Vfontset_table, face->fontset);
746 xassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
747 xassert (f == XFRAME (FONTSET_FRAME (fontset)));
740 ASET (Vfontset_table, face->fontset, Qnil); 748 ASET (Vfontset_table, face->fontset, Qnil);
741 if (face->fontset < next_fontset_id) 749 if (face->fontset < next_fontset_id)
742 next_fontset_id = face->fontset; 750 next_fontset_id = face->fontset;
751 if (! NILP (FONTSET_FALLBACK (fontset)))
752 {
753 int id = FONTSET_ID (FONTSET_FALLBACK (fontset));
754
755 fontset = AREF (Vfontset_table, id);
756 xassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
757 xassert (f == XFRAME (FONTSET_FRAME (fontset)));
758 ASET (Vfontset_table, id, Qnil);
759 if (id < next_fontset_id)
760 next_fontset_id = face->fontset;
761 }
743} 762}
744 763
745 764
@@ -1415,41 +1434,47 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
1415} 1434}
1416 1435
1417 1436
1418/* Number of fontsets created from a fontname automatically. */ 1437/* Alist of automatically created fontsets. Each element is a cons
1419static int n_auto_fontsets; 1438 (FONTNAME . FONTSET-ID). */
1439static Lisp_Object auto_fontset_alist;
1420 1440
1421int 1441int
1422new_fontset_from_font_name (Lisp_Object fontname) 1442new_fontset_from_font_name (Lisp_Object fontname)
1423{ 1443{
1444 Lisp_Object val;
1424 Lisp_Object name; 1445 Lisp_Object name;
1425 Lisp_Object vec; 1446 Lisp_Object vec;
1447 int id;
1426 1448
1427 fontname = Fdowncase (fontname); 1449 fontname = Fdowncase (fontname);
1450 val = Fassoc (fontname, auto_fontset_alist);
1451 if (CONSP (val))
1452 return XINT (XCDR (val));
1453
1428 vec = split_font_name_into_vector (fontname); 1454 vec = split_font_name_into_vector (fontname);
1429 if ( NILP (vec)) 1455 if ( NILP (vec))
1430 vec = Fmake_vector (make_number (14), build_string ("")); 1456 vec = Fmake_vector (make_number (14), build_string (""));
1431 ASET (vec, 12, build_string ("fontset")); 1457 ASET (vec, 12, build_string ("fontset"));
1432 if (n_auto_fontsets == 0) 1458 if (NILP (auto_fontset_alist))
1433 { 1459 {
1434 ASET (vec, 13, build_string ("startup")); 1460 ASET (vec, 13, build_string ("startup"));
1435 name = build_font_name_from_vector (vec); 1461 name = build_font_name_from_vector (vec);
1436 n_auto_fontsets++;
1437 } 1462 }
1438 else 1463 else
1439 { 1464 {
1440 char temp[20]; 1465 char temp[20];
1466 int len = Flength (auto_fontset_alist);
1441 1467
1442 do { 1468 sprintf (temp, "auto%d", len);
1443 sprintf (temp, "auto%d", n_auto_fontsets); 1469 ASET (vec, 13, build_string (temp));
1444 ASET (vec, 13, build_string (temp)); 1470 name = build_font_name_from_vector (vec);
1445 name = build_font_name_from_vector (vec);
1446 n_auto_fontsets++;
1447 } while (fs_query_fontset (name, 0) >= 0);
1448 } 1471 }
1449 name = Fnew_fontset (name, 1472 name = Fnew_fontset (name, Fcons (Fcons (Qascii, Fcons (fontname, Qnil)),
1450 Fcons (Fcons (Qascii, Fcons (fontname, Qnil)), Qnil)); 1473 Qnil));
1451 Vfontset_alias_alist = Fcons (Fcons (name, fontname), Vfontset_alias_alist); 1474 id = fs_query_fontset (name, 0);
1452 return fs_query_fontset (name, 0); 1475 auto_fontset_alist
1476 = Fcons (Fcons (fontname, make_number (id)), auto_fontset_alist);
1477 return id;
1453} 1478}
1454 1479
1455 1480
@@ -1718,6 +1743,56 @@ DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0,
1718 return list; 1743 return list;
1719} 1744}
1720 1745
1746
1747#ifdef FONTSET_DEBUG
1748
1749Lisp_Object
1750dump_fontset (fontset)
1751 Lisp_Object fontset;
1752{
1753 Lisp_Object vec;
1754
1755 vec = Fmake_vector (make_number (3), Qnil);
1756 ASET (vec, 0, FONTSET_ID (fontset));
1757
1758 if (BASE_FONTSET_P (fontset))
1759 {
1760 ASET (vec, 1, FONTSET_NAME (fontset));
1761 }
1762 else
1763 {
1764 Lisp_Object frame;
1765
1766 frame = FONTSET_FRAME (fontset);
1767 if (FRAMEP (frame))
1768 {
1769 FRAME_PTR f = XFRAME (frame);
1770
1771 if (FRAME_LIVE_P (f))
1772 ASET (vec, 1, f->name);
1773 else
1774 ASET (vec, 1, Qt);
1775 }
1776 if (!NILP (FONTSET_FALLBACK (fontset)))
1777 ASET (vec, 2, FONTSET_ID (FONTSET_FALLBACK (fontset)));
1778 }
1779 return vec;
1780}
1781
1782DEFUN ("fontset-list-all", Ffontset_list_all, Sfontset_list_all, 0, 0, 0,
1783 doc: /* Return a brief summary of all fontsets for debug use. */)
1784 ()
1785{
1786 Lisp_Object val;
1787 int i;
1788
1789 for (i = 0, val = Qnil; i < ASIZE (Vfontset_table); i++)
1790 if (! NILP (AREF (Vfontset_table, i)))
1791 val = Fcons (dump_fontset (AREF (Vfontset_table, i)), val);
1792 return (Fnreverse (val));
1793}
1794#endif /* FONTSET_DEBUG */
1795
1721void 1796void
1722syms_of_fontset () 1797syms_of_fontset ()
1723{ 1798{
@@ -1762,6 +1837,9 @@ syms_of_fontset ()
1762 AREF (Vfontset_table, 0) = Vdefault_fontset; 1837 AREF (Vfontset_table, 0) = Vdefault_fontset;
1763 next_fontset_id = 1; 1838 next_fontset_id = 1;
1764 1839
1840 auto_fontset_alist = Qnil;
1841 staticpro (&auto_fontset_alist);
1842
1765 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist, 1843 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
1766 doc: /* 1844 doc: /*
1767Alist of fontname patterns vs the corresponding encoding and repertory info. 1845Alist of fontname patterns vs the corresponding encoding and repertory info.
@@ -1827,27 +1905,7 @@ at the vertical center of lines. */);
1827 defsubr (&Sfontset_info); 1905 defsubr (&Sfontset_info);
1828 defsubr (&Sfontset_font); 1906 defsubr (&Sfontset_font);
1829 defsubr (&Sfontset_list); 1907 defsubr (&Sfontset_list);
1830} 1908#ifdef FONTSET_DEBUG
1831 1909 defsubr (&Sfontset_list_all);
1832Lisp_Object 1910#endif
1833dump_fontset (fontset)
1834 Lisp_Object fontset;
1835{
1836 Lisp_Object val;
1837
1838 if (NILP (FONTSET_FALLBACK (fontset)))
1839 val = Fcons (Fcons (intern ("fallback-id"), Qnil), Qnil);
1840 else
1841 val = Fcons (Fcons (intern ("fallback-id"),
1842 FONTSET_ID (FONTSET_FALLBACK (fontset))),
1843 Qnil);
1844 if (NILP (FONTSET_BASE (fontset)))
1845 val = Fcons (Fcons (intern ("base"), Qnil), val);
1846 else
1847 val = Fcons (Fcons (intern ("base"),
1848 FONTSET_NAME (FONTSET_BASE (fontset))),
1849 val);
1850 val = Fcons (Fcons (intern ("name"), FONTSET_NAME (fontset)), val);
1851 val = Fcons (Fcons (intern ("id"), FONTSET_ID (fontset)), val);
1852 return val;
1853} 1911}