diff options
Diffstat (limited to 'src/fontset.c')
| -rw-r--r-- | src/fontset.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/src/fontset.c b/src/fontset.c index 4212a40541e..016c62f0e50 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -1712,7 +1712,10 @@ If the named font is not yet loaded, return nil. */) | |||
| 1712 | /* Return a cons (FONT-NAME . GLYPH-CODE). | 1712 | /* Return a cons (FONT-NAME . GLYPH-CODE). |
| 1713 | FONT-NAME is the font name for the character at POSITION in the current | 1713 | FONT-NAME is the font name for the character at POSITION in the current |
| 1714 | buffer. This is computed from all the text properties and overlays | 1714 | buffer. This is computed from all the text properties and overlays |
| 1715 | that apply to POSITION. | 1715 | that apply to POSITION. POSTION may be nil, in which case, |
| 1716 | FONT-NAME is the font name for display the character CH with the | ||
| 1717 | default face. | ||
| 1718 | |||
| 1716 | GLYPH-CODE is the glyph code in the font to use for the character. | 1719 | GLYPH-CODE is the glyph code in the font to use for the character. |
| 1717 | 1720 | ||
| 1718 | If the 2nd optional arg CH is non-nil, it is a character to check | 1721 | If the 2nd optional arg CH is non-nil, it is a character to check |
| @@ -1725,7 +1728,8 @@ If the named font is not yet loaded, return nil. */) | |||
| 1725 | 1728 | ||
| 1726 | (2) The character code is invalid. | 1729 | (2) The character code is invalid. |
| 1727 | 1730 | ||
| 1728 | (3) The current buffer is not displayed in any window. | 1731 | (3) If POSITION is not nil, and the current buffer is not displayed |
| 1732 | in any window. | ||
| 1729 | 1733 | ||
| 1730 | In addition, the returned font name may not take into account of | 1734 | In addition, the returned font name may not take into account of |
| 1731 | such redisplay engine hooks as what used in jit-lock-mode if | 1735 | such redisplay engine hooks as what used in jit-lock-mode if |
| @@ -1740,39 +1744,53 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, | |||
| 1740 | int pos, pos_byte, dummy; | 1744 | int pos, pos_byte, dummy; |
| 1741 | int face_id; | 1745 | int face_id; |
| 1742 | int c; | 1746 | int c; |
| 1743 | Lisp_Object window; | ||
| 1744 | struct window *w; | ||
| 1745 | struct frame *f; | 1747 | struct frame *f; |
| 1746 | struct face *face; | 1748 | struct face *face; |
| 1747 | Lisp_Object charset, rfont_def; | 1749 | Lisp_Object charset, rfont_def; |
| 1748 | int charset_id; | 1750 | int id; |
| 1749 | 1751 | ||
| 1750 | CHECK_NUMBER_COERCE_MARKER (position); | 1752 | if (NILP (position)) |
| 1751 | pos = XINT (position); | ||
| 1752 | if (pos < BEGV || pos >= ZV) | ||
| 1753 | args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | ||
| 1754 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1755 | if (NILP (ch)) | ||
| 1756 | c = FETCH_CHAR (pos_byte); | ||
| 1757 | else | ||
| 1758 | { | 1753 | { |
| 1759 | CHECK_CHARACTER (ch); | 1754 | CHECK_CHARACTER (ch); |
| 1760 | c = XINT (ch); | 1755 | c = XINT (ch); |
| 1756 | f = XFRAME (selected_frame); | ||
| 1757 | face_id = DEFAULT_FACE_ID; | ||
| 1758 | pos = -1; | ||
| 1759 | } | ||
| 1760 | else | ||
| 1761 | { | ||
| 1762 | Lisp_Object window; | ||
| 1763 | struct window *w; | ||
| 1764 | |||
| 1765 | CHECK_NUMBER_COERCE_MARKER (position); | ||
| 1766 | pos = XINT (position); | ||
| 1767 | if (pos < BEGV || pos >= ZV) | ||
| 1768 | args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | ||
| 1769 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1770 | if (NILP (ch)) | ||
| 1771 | c = FETCH_CHAR (pos_byte); | ||
| 1772 | else | ||
| 1773 | { | ||
| 1774 | CHECK_NATNUM (ch); | ||
| 1775 | c = XINT (ch); | ||
| 1776 | } | ||
| 1777 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | ||
| 1778 | if (NILP (window)) | ||
| 1779 | return Qnil; | ||
| 1780 | w = XWINDOW (window); | ||
| 1781 | f = XFRAME (w->frame); | ||
| 1782 | face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); | ||
| 1761 | } | 1783 | } |
| 1762 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | 1784 | if (! CHAR_VALID_P (c, 0)) |
| 1763 | if (NILP (window)) | ||
| 1764 | return Qnil; | 1785 | return Qnil; |
| 1765 | w = XWINDOW (window); | 1786 | face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil); |
| 1766 | f = XFRAME (w->frame); | ||
| 1767 | face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); | ||
| 1768 | face = FACE_FROM_ID (f, face_id); | 1787 | face = FACE_FROM_ID (f, face_id); |
| 1769 | charset = Fget_char_property (position, Qcharset, Qnil); | 1788 | charset = Fget_char_property (position, Qcharset, Qnil); |
| 1770 | if (CHARSETP (charset)) | 1789 | if (CHARSETP (charset)) |
| 1771 | charset_id = XINT (CHARSET_SYMBOL_ID (charset)); | 1790 | id = XINT (CHARSET_SYMBOL_ID (charset)); |
| 1772 | else | 1791 | else |
| 1773 | charset_id = -1; | 1792 | id = -1; |
| 1774 | rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), | 1793 | rfont_def = fontset_font (FONTSET_FROM_ID (face->fontset), c, face, id); |
| 1775 | c, face, charset_id); | ||
| 1776 | if (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3))) | 1794 | if (VECTORP (rfont_def) && STRINGP (AREF (rfont_def, 3))) |
| 1777 | { | 1795 | { |
| 1778 | Lisp_Object font_def; | 1796 | Lisp_Object font_def; |