emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1267e12: Define internal-char-font even if --withou


From: Paul Eggert
Subject: [Emacs-diffs] master 1267e12: Define internal-char-font even if --without-x
Date: Wed, 09 Sep 2015 17:48:35 +0000

branch: master
commit 1267e12ba716734195a3bb6667f7ef5807ea0567
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/font.c    |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/fontset.c |  102 ---------------------------------------------------------
 2 files changed, 101 insertions(+), 102 deletions(-)

diff --git a/src/font.c b/src/font.c
index 50b966e..8e06532 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4472,6 +4472,106 @@ where
   return val;
 }
 
+/* Return a description of the font at POSITION in the current buffer.
+   If the 2nd optional arg CH is non-nil, it is a character to check
+   the font instead of the character at POSITION.
+
+   For a graphical display, return a cons (FONT-OBJECT . GLYPH-CODE).
+   FONT-OBJECT is the font for the character at POSITION in the current
+   buffer.  This is computed from all the text properties and overlays
+   that apply to POSITION.  POSITION may be nil, in which case,
+   FONT-SPEC is the font for displaying the character CH with the
+   default face.  GLYPH-CODE is the glyph code in the font to use for
+   the character.
+
+   For a text terminal, return a nonnegative integer glyph code for
+   the character, or a negative integer if the character is not
+   displayable.  Terminal glyph codes are system-dependent integers
+   that represent displayable characters: for example, on a Linux x86
+   console they represent VGA code points.
+
+   It returns nil in the following cases:
+
+   (1) The window system doesn't have a font for the character (thus
+   it is displayed by an empty box).
+
+   (2) The character code is invalid.
+
+   (3) If POSITION is not nil, and the current buffer is not displayed
+   in any window.
+
+   (4) For a text terminal, the terminal does not report glyph codes.
+
+   In addition, the returned font name may not take into account of
+   such redisplay engine hooks as what used in jit-lock-mode if
+   POSITION is currently not visible.  */
+
+
+DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
+       doc: /* For internal use only.  */)
+  (Lisp_Object position, Lisp_Object ch)
+{
+  ptrdiff_t pos, pos_byte, dummy;
+  int face_id;
+  int c;
+  struct frame *f;
+
+  if (NILP (position))
+    {
+      CHECK_CHARACTER (ch);
+      c = XINT (ch);
+      f = XFRAME (selected_frame);
+      face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
+      pos = -1;
+    }
+  else
+    {
+      Lisp_Object window;
+      struct window *w;
+
+      CHECK_NUMBER_COERCE_MARKER (position);
+      if (! (BEGV <= XINT (position) && XINT (position) < ZV))
+       args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
+      pos = XINT (position);
+      pos_byte = CHAR_TO_BYTE (pos);
+      if (NILP (ch))
+       c = FETCH_CHAR (pos_byte);
+      else
+       {
+         CHECK_NATNUM (ch);
+         c = XINT (ch);
+       }
+      window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
+      if (NILP (window))
+       return Qnil;
+      w = XWINDOW (window);
+      f = XFRAME (w->frame);
+      face_id = face_at_buffer_position (w, pos, &dummy,
+                                        pos + 100, false, -1);
+    }
+  if (! CHAR_VALID_P (c))
+    return Qnil;
+
+  if (! FRAME_WINDOW_P (f))
+    return terminal_glyph_code (FRAME_TERMINAL (f), c);
+
+  /* We need the basic faces to be valid below, so recompute them if
+     some code just happened to clear the face cache.  */
+  if (FRAME_FACE_CACHE (f)->used == 0)
+    recompute_basic_faces (f);
+
+  face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
+  struct face *face = FACE_FROM_ID (f, face_id);
+  if (! face->font)
+    return Qnil;
+  unsigned code = face->font->driver->encode_char (face->font, c);
+  if (code == FONT_INVALID_CODE)
+    return Qnil;
+  Lisp_Object font_object;
+  XSETFONT (font_object, face->font);
+  return Fcons (font_object, INTEGER_TO_CONS (code));
+}
+
 #if 0
 
 DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0,
@@ -5229,6 +5329,7 @@ syms_of_font (void)
   defsubr (&Sclear_font_cache);
   defsubr (&Sfont_shape_gstring);
   defsubr (&Sfont_variation_glyphs);
+  defsubr (&Sinternal_char_font);
 #if 0
   defsubr (&Sfont_drive_otf);
   defsubr (&Sfont_otf_alternates);
diff --git a/src/fontset.c b/src/fontset.c
index f8334f1..e735989 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1786,107 +1786,6 @@ update_auto_fontset_alist (Lisp_Object font_object, 
Lisp_Object fontset)
       }
 }
 
-/* Return a description of the font at POSITION in the current buffer.
-   If the 2nd optional arg CH is non-nil, it is a character to check
-   the font instead of the character at POSITION.
-
-   For a graphical display, return a cons (FONT-OBJECT . GLYPH-CODE).
-   FONT-OBJECT is the font for the character at POSITION in the current
-   buffer.  This is computed from all the text properties and overlays
-   that apply to POSITION.  POSITION may be nil, in which case,
-   FONT-SPEC is the font for displaying the character CH with the
-   default face.  GLYPH-CODE is the glyph code in the font to use for
-   the character.
-
-   For a text terminal, return a nonnegative integer glyph code for
-   the character, or a negative integer if the character is not
-   displayable.  Terminal glyph codes are system-dependent integers
-   that represent displayable characters: for example, on a Linux x86
-   console they represent VGA code points.
-
-   It returns nil in the following cases:
-
-   (1) The window system doesn't have a font for the character (thus
-   it is displayed by an empty box).
-
-   (2) The character code is invalid.
-
-   (3) If POSITION is not nil, and the current buffer is not displayed
-   in any window.
-
-   (4) For a text terminal, the terminal does not report glyph codes.
-
-   In addition, the returned font name may not take into account of
-   such redisplay engine hooks as what used in jit-lock-mode if
-   POSITION is currently not visible.  */
-
-
-DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
-       doc: /* For internal use only.  */)
-  (Lisp_Object position, Lisp_Object ch)
-{
-  ptrdiff_t pos, pos_byte, dummy;
-  int face_id;
-  int c;
-  struct frame *f;
-  struct face *face;
-
-  if (NILP (position))
-    {
-      CHECK_CHARACTER (ch);
-      c = XINT (ch);
-      f = XFRAME (selected_frame);
-      face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
-      pos = -1;
-    }
-  else
-    {
-      Lisp_Object window;
-      struct window *w;
-
-      CHECK_NUMBER_COERCE_MARKER (position);
-      if (! (BEGV <= XINT (position) && XINT (position) < ZV))
-       args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
-      pos = XINT (position);
-      pos_byte = CHAR_TO_BYTE (pos);
-      if (NILP (ch))
-       c = FETCH_CHAR (pos_byte);
-      else
-       {
-         CHECK_NATNUM (ch);
-         c = XINT (ch);
-       }
-      window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
-      if (NILP (window))
-       return Qnil;
-      w = XWINDOW (window);
-      f = XFRAME (w->frame);
-      face_id = face_at_buffer_position (w, pos, &dummy,
-                                        pos + 100, false, -1);
-    }
-  if (! CHAR_VALID_P (c))
-    return Qnil;
-  if (!FRAME_WINDOW_P (f))
-    return terminal_glyph_code (FRAME_TERMINAL (f), c);
-  /* We need the basic faces to be valid below, so recompute them if
-     some code just happened to clear the face cache.  */
-  if (FRAME_FACE_CACHE (f)->used == 0)
-    recompute_basic_faces (f);
-  face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
-  face = FACE_FROM_ID (f, face_id);
-  if (face->font)
-    {
-      unsigned code = face->font->driver->encode_char (face->font, c);
-      Lisp_Object font_object;
-
-      if (code == FONT_INVALID_CODE)
-       return Qnil;
-      XSETFONT (font_object, face->font);
-      return Fcons (font_object, INTEGER_TO_CONS (code));
-    }
-  return Qnil;
-}
-
 
 DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0,
        doc: /* Return information about a fontset FONTSET on frame FRAME.
@@ -2254,7 +2153,6 @@ at the vertical center of lines.  */);
   defsubr (&Squery_fontset);
   defsubr (&Snew_fontset);
   defsubr (&Sset_fontset_font);
-  defsubr (&Sinternal_char_font);
   defsubr (&Sfontset_info);
   defsubr (&Sfontset_font);
   defsubr (&Sfontset_list);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]