aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-09-09 10:47:53 -0700
committerPaul Eggert2015-09-09 10:48:31 -0700
commit1267e12ba716734195a3bb6667f7ef5807ea0567 (patch)
tree4aab322ca0a5c8321f00029c7ea8c51f5c0cc404 /src
parent88694fb65887ebc2fde9dea18c817e08be26b564 (diff)
downloademacs-1267e12ba716734195a3bb6667f7ef5807ea0567.tar.gz
emacs-1267e12ba716734195a3bb6667f7ef5807ea0567.zip
Define internal-char-font even if --without-x
The function is used now even in non-graphical environments. Problem reported by Glenn Morris in: http://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00401.html * src/font.c (Finternal_char_font): Move here ... * src/fontset.c (Finternal_char_font): ... from here.
Diffstat (limited to 'src')
-rw-r--r--src/font.c101
-rw-r--r--src/fontset.c102
2 files changed, 101 insertions, 102 deletions
diff --git a/src/font.c b/src/font.c
index 50b966ec83e..8e06532ac0a 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4472,6 +4472,106 @@ where
4472 return val; 4472 return val;
4473} 4473}
4474 4474
4475/* Return a description of the font at POSITION in the current buffer.
4476 If the 2nd optional arg CH is non-nil, it is a character to check
4477 the font instead of the character at POSITION.
4478
4479 For a graphical display, return a cons (FONT-OBJECT . GLYPH-CODE).
4480 FONT-OBJECT is the font for the character at POSITION in the current
4481 buffer. This is computed from all the text properties and overlays
4482 that apply to POSITION. POSITION may be nil, in which case,
4483 FONT-SPEC is the font for displaying the character CH with the
4484 default face. GLYPH-CODE is the glyph code in the font to use for
4485 the character.
4486
4487 For a text terminal, return a nonnegative integer glyph code for
4488 the character, or a negative integer if the character is not
4489 displayable. Terminal glyph codes are system-dependent integers
4490 that represent displayable characters: for example, on a Linux x86
4491 console they represent VGA code points.
4492
4493 It returns nil in the following cases:
4494
4495 (1) The window system doesn't have a font for the character (thus
4496 it is displayed by an empty box).
4497
4498 (2) The character code is invalid.
4499
4500 (3) If POSITION is not nil, and the current buffer is not displayed
4501 in any window.
4502
4503 (4) For a text terminal, the terminal does not report glyph codes.
4504
4505 In addition, the returned font name may not take into account of
4506 such redisplay engine hooks as what used in jit-lock-mode if
4507 POSITION is currently not visible. */
4508
4509
4510DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
4511 doc: /* For internal use only. */)
4512 (Lisp_Object position, Lisp_Object ch)
4513{
4514 ptrdiff_t pos, pos_byte, dummy;
4515 int face_id;
4516 int c;
4517 struct frame *f;
4518
4519 if (NILP (position))
4520 {
4521 CHECK_CHARACTER (ch);
4522 c = XINT (ch);
4523 f = XFRAME (selected_frame);
4524 face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
4525 pos = -1;
4526 }
4527 else
4528 {
4529 Lisp_Object window;
4530 struct window *w;
4531
4532 CHECK_NUMBER_COERCE_MARKER (position);
4533 if (! (BEGV <= XINT (position) && XINT (position) < ZV))
4534 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
4535 pos = XINT (position);
4536 pos_byte = CHAR_TO_BYTE (pos);
4537 if (NILP (ch))
4538 c = FETCH_CHAR (pos_byte);
4539 else
4540 {
4541 CHECK_NATNUM (ch);
4542 c = XINT (ch);
4543 }
4544 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
4545 if (NILP (window))
4546 return Qnil;
4547 w = XWINDOW (window);
4548 f = XFRAME (w->frame);
4549 face_id = face_at_buffer_position (w, pos, &dummy,
4550 pos + 100, false, -1);
4551 }
4552 if (! CHAR_VALID_P (c))
4553 return Qnil;
4554
4555 if (! FRAME_WINDOW_P (f))
4556 return terminal_glyph_code (FRAME_TERMINAL (f), c);
4557
4558 /* We need the basic faces to be valid below, so recompute them if
4559 some code just happened to clear the face cache. */
4560 if (FRAME_FACE_CACHE (f)->used == 0)
4561 recompute_basic_faces (f);
4562
4563 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
4564 struct face *face = FACE_FROM_ID (f, face_id);
4565 if (! face->font)
4566 return Qnil;
4567 unsigned code = face->font->driver->encode_char (face->font, c);
4568 if (code == FONT_INVALID_CODE)
4569 return Qnil;
4570 Lisp_Object font_object;
4571 XSETFONT (font_object, face->font);
4572 return Fcons (font_object, INTEGER_TO_CONS (code));
4573}
4574
4475#if 0 4575#if 0
4476 4576
4477DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0, 4577DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0,
@@ -5229,6 +5329,7 @@ syms_of_font (void)
5229 defsubr (&Sclear_font_cache); 5329 defsubr (&Sclear_font_cache);
5230 defsubr (&Sfont_shape_gstring); 5330 defsubr (&Sfont_shape_gstring);
5231 defsubr (&Sfont_variation_glyphs); 5331 defsubr (&Sfont_variation_glyphs);
5332 defsubr (&Sinternal_char_font);
5232#if 0 5333#if 0
5233 defsubr (&Sfont_drive_otf); 5334 defsubr (&Sfont_drive_otf);
5234 defsubr (&Sfont_otf_alternates); 5335 defsubr (&Sfont_otf_alternates);
diff --git a/src/fontset.c b/src/fontset.c
index f8334f16e55..e735989bcbf 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1786,107 +1786,6 @@ update_auto_fontset_alist (Lisp_Object font_object, Lisp_Object fontset)
1786 } 1786 }
1787} 1787}
1788 1788
1789/* Return a description of the font at POSITION in the current buffer.
1790 If the 2nd optional arg CH is non-nil, it is a character to check
1791 the font instead of the character at POSITION.
1792
1793 For a graphical display, return a cons (FONT-OBJECT . GLYPH-CODE).
1794 FONT-OBJECT is the font for the character at POSITION in the current
1795 buffer. This is computed from all the text properties and overlays
1796 that apply to POSITION. POSITION may be nil, in which case,
1797 FONT-SPEC is the font for displaying the character CH with the
1798 default face. GLYPH-CODE is the glyph code in the font to use for
1799 the character.
1800
1801 For a text terminal, return a nonnegative integer glyph code for
1802 the character, or a negative integer if the character is not
1803 displayable. Terminal glyph codes are system-dependent integers
1804 that represent displayable characters: for example, on a Linux x86
1805 console they represent VGA code points.
1806
1807 It returns nil in the following cases:
1808
1809 (1) The window system doesn't have a font for the character (thus
1810 it is displayed by an empty box).
1811
1812 (2) The character code is invalid.
1813
1814 (3) If POSITION is not nil, and the current buffer is not displayed
1815 in any window.
1816
1817 (4) For a text terminal, the terminal does not report glyph codes.
1818
1819 In addition, the returned font name may not take into account of
1820 such redisplay engine hooks as what used in jit-lock-mode if
1821 POSITION is currently not visible. */
1822
1823
1824DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1825 doc: /* For internal use only. */)
1826 (Lisp_Object position, Lisp_Object ch)
1827{
1828 ptrdiff_t pos, pos_byte, dummy;
1829 int face_id;
1830 int c;
1831 struct frame *f;
1832 struct face *face;
1833
1834 if (NILP (position))
1835 {
1836 CHECK_CHARACTER (ch);
1837 c = XINT (ch);
1838 f = XFRAME (selected_frame);
1839 face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
1840 pos = -1;
1841 }
1842 else
1843 {
1844 Lisp_Object window;
1845 struct window *w;
1846
1847 CHECK_NUMBER_COERCE_MARKER (position);
1848 if (! (BEGV <= XINT (position) && XINT (position) < ZV))
1849 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
1850 pos = XINT (position);
1851 pos_byte = CHAR_TO_BYTE (pos);
1852 if (NILP (ch))
1853 c = FETCH_CHAR (pos_byte);
1854 else
1855 {
1856 CHECK_NATNUM (ch);
1857 c = XINT (ch);
1858 }
1859 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
1860 if (NILP (window))
1861 return Qnil;
1862 w = XWINDOW (window);
1863 f = XFRAME (w->frame);
1864 face_id = face_at_buffer_position (w, pos, &dummy,
1865 pos + 100, false, -1);
1866 }
1867 if (! CHAR_VALID_P (c))
1868 return Qnil;
1869 if (!FRAME_WINDOW_P (f))
1870 return terminal_glyph_code (FRAME_TERMINAL (f), c);
1871 /* We need the basic faces to be valid below, so recompute them if
1872 some code just happened to clear the face cache. */
1873 if (FRAME_FACE_CACHE (f)->used == 0)
1874 recompute_basic_faces (f);
1875 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
1876 face = FACE_FROM_ID (f, face_id);
1877 if (face->font)
1878 {
1879 unsigned code = face->font->driver->encode_char (face->font, c);
1880 Lisp_Object font_object;
1881
1882 if (code == FONT_INVALID_CODE)
1883 return Qnil;
1884 XSETFONT (font_object, face->font);
1885 return Fcons (font_object, INTEGER_TO_CONS (code));
1886 }
1887 return Qnil;
1888}
1889
1890 1789
1891DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0, 1790DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0,
1892 doc: /* Return information about a fontset FONTSET on frame FRAME. 1791 doc: /* Return information about a fontset FONTSET on frame FRAME.
@@ -2254,7 +2153,6 @@ at the vertical center of lines. */);
2254 defsubr (&Squery_fontset); 2153 defsubr (&Squery_fontset);
2255 defsubr (&Snew_fontset); 2154 defsubr (&Snew_fontset);
2256 defsubr (&Sset_fontset_font); 2155 defsubr (&Sset_fontset_font);
2257 defsubr (&Sinternal_char_font);
2258 defsubr (&Sfontset_info); 2156 defsubr (&Sfontset_info);
2259 defsubr (&Sfontset_font); 2157 defsubr (&Sfontset_font);
2260 defsubr (&Sfontset_list); 2158 defsubr (&Sfontset_list);