aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-12-03 13:51:16 +0000
committerKenichi Handa2007-12-03 13:51:16 +0000
commit7ff614edaafe2865d9241bdda96866c01b358029 (patch)
tree2ce70e6f542f8751d5fa70916780f6e60a03ff50 /src
parent2d477dcab8a141abcf05c8313dbae92b6a181dda (diff)
downloademacs-7ff614edaafe2865d9241bdda96866c01b358029.tar.gz
emacs-7ff614edaafe2865d9241bdda96866c01b358029.zip
Include "font.h" unconditionally.
(generate_ascii_font_name): Use font_parse_xlfd and font_unparse_xlfd. (Fset_fontset_font): Accept a font-spec object.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c87
1 files changed, 30 insertions, 57 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 58b5ee621d0..85e9254e765 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -57,9 +57,7 @@ Boston, MA 02110-1301, USA. */
57#endif 57#endif
58#include "termhooks.h" 58#include "termhooks.h"
59 59
60#ifdef USE_FONT_BACKEND
61#include "font.h" 60#include "font.h"
62#endif /* USE_FONT_BACKEND */
63 61
64#undef xassert 62#undef xassert
65#ifdef FONTSET_DEBUG 63#ifdef FONTSET_DEBUG
@@ -96,14 +94,11 @@ EXFUN (Fclear_face_cache, 1);
96 An element of a base fontset is a vector of FONT-DEFs which itself 94 An element of a base fontset is a vector of FONT-DEFs which itself
97 is a vector [ FONT-SPEC ENCODING REPERTORY ]. 95 is a vector [ FONT-SPEC ENCODING REPERTORY ].
98 96
99 FONT-SPEC is: 97 FONT-SPEC is a font-spec created by `font-spec' or
100 [ FAMILY WEIGHT SLANT SWIDTH ADSTYLE REGISTRY ] 98 ( FAMILY . REGISTRY )
101 or 99 or
102 FONT-NAME 100 FONT-NAME
103 where FAMILY, WEIGHT, SLANT, SWIDTH, ADSTYLE, REGISTRY, and 101 where FAMILY, REGISTRY, and FONT-NAME are strings.
104 FONT-NAME are strings.
105
106 Note: Currently WEIGHT through ADSTYLE are ignored.
107 102
108 ENCODING is a charset ID that can convert characters to glyph codes 103 ENCODING is a charset ID that can convert characters to glyph codes
109 of the corresponding font. 104 of the corresponding font.
@@ -1505,24 +1500,26 @@ accumulate_script_ranges (arg, range, val)
1505 1500
1506 1501
1507/* Return an ASCII font name generated from fontset name NAME and 1502/* Return an ASCII font name generated from fontset name NAME and
1508 ASCII font specification ASCII_SPEC. NAME is a string conforming 1503 font-spec ASCII_SPEC. NAME is a string conforming to XLFD. */
1509 to XLFD. ASCII_SPEC is a vector:
1510 [FAMILY WEIGHT SLANT SWIDTH ADSTYLE REGISTRY]. */
1511 1504
1512static INLINE Lisp_Object 1505static INLINE Lisp_Object
1513generate_ascii_font_name (name, ascii_spec) 1506generate_ascii_font_name (name, ascii_spec)
1514 Lisp_Object name, ascii_spec; 1507 Lisp_Object name, ascii_spec;
1515{ 1508{
1509 Lisp_Object font_spec = Ffont_spec (0, NULL);
1516 Lisp_Object vec; 1510 Lisp_Object vec;
1517 int i; 1511 int i;
1512 char xlfd[256];
1518 1513
1519 vec = split_font_name_into_vector (name); 1514 if (font_parse_xlfd (SDATA (name), font_spec) < 0)
1520 for (i = FONT_SPEC_FAMILY_INDEX; i <= FONT_SPEC_ADSTYLE_INDEX; i++) 1515 error ("Not an XLFD font name: %s", SDATA (name));
1516 for (i = FONT_FOUNDRY_INDEX; i <= FONT_WIDTH_INDEX; i++)
1521 if (! NILP (AREF (ascii_spec, i))) 1517 if (! NILP (AREF (ascii_spec, i)))
1522 ASET (vec, 1 + i, AREF (ascii_spec, i)); 1518 ASET (font_spec, i, AREF (ascii_spec, i));
1523 if (! NILP (AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX))) 1519 i = font_unparse_xlfd (font_spec, 0, xlfd, 256);
1524 ASET (vec, 12, AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX)); 1520 if (i < 0)
1525 return build_font_name_from_vector (vec); 1521 error ("Not an XLFD font name: %s", SDATA (name));
1522 return make_unibyte_string (xlfd, i);
1526} 1523}
1527 1524
1528/* Variables referred in set_fontset_font. They are set before 1525/* Variables referred in set_fontset_font. They are set before
@@ -1617,57 +1614,33 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1617 1614
1618 if (VECTORP (font_spec)) 1615 if (VECTORP (font_spec))
1619 { 1616 {
1620#ifdef USE_FONT_BACKEND 1617 if (! FONT_SPEC_P (font_spec))
1621 if (enable_font_backend && FONT_SPEC_P (font_spec)) 1618 Fsignal (Qfont, list2 (build_string ("invalid font-spec"), font_spec));
1622 { 1619 family = Ffont_get (font_spec, QCfamily);
1623 family = Ffont_get (font_spec, QCfamily); 1620 if (! NILP (family) && SYMBOLP (family))
1624 if (! NILP (family)) 1621 family = SYMBOL_NAME (family);
1625 family = SYMBOL_NAME (family); 1622 registry = Ffont_get (font_spec, QCregistry);
1626 registry = Ffont_get (font_spec, QCregistry); 1623 if (! NILP (registry) && SYMBOLP (registry))
1627 if (! NILP (registry)) 1624 registry = SYMBOL_NAME (registry);
1628 registry = SYMBOL_NAME (registry);
1629 }
1630 else
1631#endif
1632 {
1633 /* FONT_SPEC should have this form:
1634 [ FAMILY WEIGHT SLANT WIDTH ADSTYLE REGISTRY ]
1635 This is a feature not yet documented because WEIGHT thru
1636 ADSTYLE are ignored for the moment. */
1637 int j;
1638
1639 if (ASIZE (font_spec) != FONT_SPEC_MAX_INDEX)
1640 args_out_of_range (make_number (FONT_SPEC_MAX_INDEX),
1641 make_number (ASIZE (font_spec)));
1642
1643 font_spec = Fcopy_sequence (font_spec);
1644 for (j = 0; j < FONT_SPEC_MAX_INDEX - 1; j++)
1645 if (! NILP (AREF (font_spec, j)))
1646 {
1647 CHECK_STRING (AREF (font_spec, j));
1648 ASET (font_spec, j, Fdowncase (AREF (font_spec, j)));
1649 }
1650 family = AREF (font_spec, FONT_SPEC_FAMILY_INDEX);
1651 /* REGISTRY should not be omitted. */
1652 CHECK_STRING (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX));
1653 registry = AREF (font_spec, FONT_SPEC_REGISTRY_INDEX);
1654 }
1655 } 1625 }
1656 else if (CONSP (font_spec)) 1626 else if (CONSP (font_spec))
1657 { 1627 {
1628 Lisp_Object args[4];
1629 int i= 0;
1630
1658 family = XCAR (font_spec); 1631 family = XCAR (font_spec);
1659 registry = XCDR (font_spec); 1632 registry = XCDR (font_spec);
1660 1633
1661 if (! NILP (family)) 1634 if (! NILP (family))
1662 { 1635 {
1663 CHECK_STRING (family); 1636 CHECK_STRING (family);
1664 family = Fdowncase (family); 1637 args[i++] = QCfamily;
1638 args[i++] = family;
1665 } 1639 }
1666 CHECK_STRING (registry); 1640 CHECK_STRING (registry);
1667 registry = Fdowncase (registry); 1641 args[i++] = QCregistry;
1668 font_spec = Fmake_vector (make_number (FONT_SPEC_MAX_INDEX), Qnil); 1642 args[i++] = registry;
1669 ASET (font_spec, FONT_SPEC_FAMILY_INDEX, family); 1643 font_spec = Ffont_spec (i, args);
1670 ASET (font_spec, FONT_SPEC_REGISTRY_INDEX, registry);
1671 } 1644 }
1672 else 1645 else
1673 { 1646 {