/[emacs]/emacs/src/fontset.c
ViewVC logotype

Diff of /emacs/src/fontset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.78 by miles, Mon Sep 1 15:45:52 2003 UTC revision 1.79 by handa, Sun Sep 28 23:17:47 2003 UTC
# Line 36  Boston, MA 02111-1307, USA.  */ Line 36  Boston, MA 02111-1307, USA.  */
36  #include "dispextern.h"  #include "dispextern.h"
37  #include "fontset.h"  #include "fontset.h"
38  #include "window.h"  #include "window.h"
39    #ifdef HAVE_X_WINDOWS
40    #include "xterm.h"
41    #endif
42    #ifdef WINDOWSNT
43    #include "w32term.h"
44    #endif
45    #ifdef MAC_OS
46    #include "macterm.h"
47    #endif
48    
49  #ifdef FONTSET_DEBUG  #ifdef FONTSET_DEBUG
50  #undef xassert  #undef xassert
# Line 1139  If the named font is not yet loaded, ret Line 1148  If the named font is not yet loaded, ret
1148  }  }
1149    
1150    
1151  /* Return the font name for the character at POSITION in the current  /* Return a cons (FONT-NAME . GLYPH-CODE).
1152       FONT-NAME is the font name for the character at POSITION in the current
1153     buffer.  This is computed from all the text properties and overlays     buffer.  This is computed from all the text properties and overlays
1154     that apply to POSITION.  It returns nil in the following cases:     that apply to POSITION.
1155       GLYPH-CODE is the glyph code in the font to use for the character.
1156    
1157       If the 2nd optional arg CH is non-nil, it is a character to check
1158       the font instead of the character at POSITION.
1159    
1160       It returns nil in the following cases:
1161    
1162     (1) The window system doesn't have a font for the character (thus     (1) The window system doesn't have a font for the character (thus
1163     it is displayed by an empty box).     it is displayed by an empty box).
# Line 1155  If the named font is not yet loaded, ret Line 1171  If the named font is not yet loaded, ret
1171     POSITION is currently not visible.  */     POSITION is currently not visible.  */
1172    
1173    
1174  DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 1, 0,  DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1175         doc: /* For internal use only.  */)         doc: /* For internal use only.  */)
1176       (position)       (position, ch)
1177       Lisp_Object position;       Lisp_Object position, ch;
1178  {  {
1179    int pos, pos_byte, dummy;    int pos, pos_byte, dummy;
1180    int face_id;    int face_id;
1181    int c;    int c, code;
1182    Lisp_Object window;    Lisp_Object window;
1183    struct window *w;    struct window *w;
1184    struct frame *f;    struct frame *f;
# Line 1173  DEFUN ("internal-char-font", Finternal_c Line 1189  DEFUN ("internal-char-font", Finternal_c
1189    if (pos < BEGV || pos >= ZV)    if (pos < BEGV || pos >= ZV)
1190      args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));      args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
1191    pos_byte = CHAR_TO_BYTE (pos);    pos_byte = CHAR_TO_BYTE (pos);
1192    c = FETCH_CHAR (pos_byte);    if (NILP (ch))
1193        c = FETCH_CHAR (pos_byte);
1194      else
1195        {
1196          CHECK_NATNUM (ch);
1197          c = XINT (ch);
1198        }
1199    if (! CHAR_VALID_P (c, 0))    if (! CHAR_VALID_P (c, 0))
1200      return Qnil;      return Qnil;
1201    window = Fget_buffer_window (Fcurrent_buffer (), Qnil);    window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
# Line 1184  DEFUN ("internal-char-font", Finternal_c Line 1206  DEFUN ("internal-char-font", Finternal_c
1206    face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0);    face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0);
1207    face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c);    face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c);
1208    face = FACE_FROM_ID (f, face_id);    face = FACE_FROM_ID (f, face_id);
1209    return (face->font && face->font_name    if (! face->font || ! face->font_name)
1210            ? build_string (face->font_name)      return Qnil;
1211            : Qnil);  
1212      {
1213        struct font_info *fontp = (*get_font_info_func) (f, face->font_info_id);
1214        XChar2b char2b;
1215        int c1, c2, charset;
1216    
1217        SPLIT_CHAR (c, charset, c1, c2);
1218        if (c2 > 0)
1219          STORE_XCHAR2B (&char2b, c1, c2);
1220        else
1221          STORE_XCHAR2B (&char2b, 0, c1);
1222        rif->encode_char (c, &char2b, fontp, NULL);
1223        code = (XCHAR2B_BYTE1 (&char2b) << 8) | XCHAR2B_BYTE2 (&char2b);
1224      }
1225      return Fcons (build_string (face->font_name), make_number (code));
1226  }  }
1227    
1228    

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26