Mercurial > emacs
comparison src/fontset.c @ 89904:76c449b624ad
Sync to HEAD.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 14 Apr 2004 06:24:18 +0000 |
parents | d1a1970e3dd1 |
children | 713a4f4140ca |
comparison
equal
deleted
inserted
replaced
89903:d529a6280ed6 | 89904:76c449b624ad |
---|---|
40 #include "frame.h" | 40 #include "frame.h" |
41 #include "dispextern.h" | 41 #include "dispextern.h" |
42 #include "intervals.h" | 42 #include "intervals.h" |
43 #include "fontset.h" | 43 #include "fontset.h" |
44 #include "window.h" | 44 #include "window.h" |
45 #ifdef HAVE_X_WINDOWS | |
46 #include "xterm.h" | |
47 #endif | |
48 #ifdef WINDOWSNT | |
49 #include "w32term.h" | |
50 #endif | |
51 #ifdef MAC_OS | |
52 #include "macterm.h" | |
53 #endif | |
45 | 54 |
46 #undef xassert | 55 #undef xassert |
47 #ifdef FONTSET_DEBUG | 56 #ifdef FONTSET_DEBUG |
48 #define xassert(X) do {if (!(X)) abort ();} while (0) | 57 #define xassert(X) do {if (!(X)) abort ();} while (0) |
49 #undef INLINE | 58 #undef INLINE |
1696 | 1705 |
1697 return info; | 1706 return info; |
1698 } | 1707 } |
1699 | 1708 |
1700 | 1709 |
1701 /* Return the font name for the character at POSITION in the current | 1710 /* Return a cons (FONT-NAME . GLYPH-CODE). |
1711 FONT-NAME is the font name for the character at POSITION in the current | |
1702 buffer. This is computed from all the text properties and overlays | 1712 buffer. This is computed from all the text properties and overlays |
1703 that apply to POSITION. It returns nil in the following cases: | 1713 that apply to POSITION. |
1714 GLYPH-CODE is the glyph code in the font to use for the character. | |
1715 | |
1716 If the 2nd optional arg CH is non-nil, it is a character to check | |
1717 the font instead of the character at POSITION. | |
1718 | |
1719 It returns nil in the following cases: | |
1704 | 1720 |
1705 (1) The window system doesn't have a font for the character (thus | 1721 (1) The window system doesn't have a font for the character (thus |
1706 it is displayed by an empty box). | 1722 it is displayed by an empty box). |
1707 | 1723 |
1708 (2) The character code is invalid. | 1724 (2) The character code is invalid. |
1712 In addition, the returned font name may not take into account of | 1728 In addition, the returned font name may not take into account of |
1713 such redisplay engine hooks as what used in jit-lock-mode if | 1729 such redisplay engine hooks as what used in jit-lock-mode if |
1714 POSITION is currently not visible. */ | 1730 POSITION is currently not visible. */ |
1715 | 1731 |
1716 | 1732 |
1717 DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 1, 0, | 1733 DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, |
1718 doc: /* For internal use only. */) | 1734 doc: /* For internal use only. */) |
1719 (position) | 1735 (position, ch) |
1720 Lisp_Object position; | 1736 Lisp_Object position, ch; |
1721 { | 1737 { |
1722 int pos, pos_byte, dummy; | 1738 int pos, pos_byte, dummy; |
1723 int face_id; | 1739 int face_id; |
1724 int c; | 1740 int c; |
1725 Lisp_Object window; | 1741 Lisp_Object window; |
1732 CHECK_NUMBER_COERCE_MARKER (position); | 1748 CHECK_NUMBER_COERCE_MARKER (position); |
1733 pos = XINT (position); | 1749 pos = XINT (position); |
1734 if (pos < BEGV || pos >= ZV) | 1750 if (pos < BEGV || pos >= ZV) |
1735 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | 1751 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); |
1736 pos_byte = CHAR_TO_BYTE (pos); | 1752 pos_byte = CHAR_TO_BYTE (pos); |
1737 c = FETCH_CHAR (pos_byte); | 1753 if (NILP (ch)) |
1754 c = FETCH_CHAR (pos_byte); | |
1755 else | |
1756 { | |
1757 CHECK_CHARACTER (ch); | |
1758 c = XINT (ch); | |
1759 } | |
1738 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | 1760 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); |
1739 if (NILP (window)) | 1761 if (NILP (window)) |
1740 return Qnil; | 1762 return Qnil; |
1741 w = XWINDOW (window); | 1763 w = XWINDOW (window); |
1742 f = XFRAME (w->frame); | 1764 f = XFRAME (w->frame); |
1747 charset_id = XINT (CHARSET_SYMBOL_ID (charset)); | 1769 charset_id = XINT (CHARSET_SYMBOL_ID (charset)); |
1748 else | 1770 else |
1749 charset_id = -1; | 1771 charset_id = -1; |
1750 rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), | 1772 rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), |
1751 c, face, charset_id); | 1773 c, face, charset_id); |
1752 return (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3)) | 1774 if (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3))) |
1753 ? AREF (rfont_def, 3) | 1775 { |
1754 : Qnil); | 1776 Lisp_Object font_def; |
1777 struct font_info *fontp; | |
1778 struct charset *charset; | |
1779 XChar2b char2b; | |
1780 int code; | |
1781 | |
1782 font_def = AREF (rfont_def, 2); | |
1783 charset = CHARSET_FROM_ID (XINT (AREF (font_def, 1))); | |
1784 code = ENCODE_CHAR (charset, c); | |
1785 if (code == CHARSET_INVALID_CODE (charset)) | |
1786 return (Fcons (AREF (rfont_def, 3), Qnil)); | |
1787 STORE_XCHAR2B (&char2b, ((code >> 8) & 0xFF), (code & 0xFF)); | |
1788 fontp = (*get_font_info_func) (f, XINT (AREF (rfont_def, 1))); | |
1789 rif->encode_char (c, &char2b, fontp, charset, NULL); | |
1790 code = (XCHAR2B_BYTE1 (&char2b) << 8) | XCHAR2B_BYTE2 (&char2b); | |
1791 return (Fcons (AREF (rfont_def, 3), make_number (code))); | |
1792 } | |
1793 return Qnil; | |
1755 } | 1794 } |
1756 | 1795 |
1757 | 1796 |
1758 DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0, | 1797 DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0, |
1759 doc: /* Return information about a fontset FONTSET on frame FRAME. | 1798 doc: /* Return information about a fontset FONTSET on frame FRAME. |
2094 defsubr (&Sfontset_list); | 2133 defsubr (&Sfontset_list); |
2095 #ifdef FONTSET_DEBUG | 2134 #ifdef FONTSET_DEBUG |
2096 defsubr (&Sfontset_list_all); | 2135 defsubr (&Sfontset_list_all); |
2097 #endif | 2136 #endif |
2098 } | 2137 } |
2138 | |
2139 /* arch-tag: ea861585-2f5f-4e5b-9849-d04a9c3a3537 | |
2140 (do not change this comment) */ |