Mercurial > emacs
comparison src/fontset.c @ 52654:2e5944e29aa0
(Finternal_char_font): Change return value to
cons (FONT-NAME . GLYPH-CODE).
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sun, 28 Sep 2003 23:17:47 +0000 |
parents | 695cf19ef79e |
children | 124a3516f4db |
comparison
equal
deleted
inserted
replaced
52653:d4af4cfdc701 | 52654:2e5944e29aa0 |
---|---|
34 #include "keyboard.h" | 34 #include "keyboard.h" |
35 #include "frame.h" | 35 #include "frame.h" |
36 #include "dispextern.h" | 36 #include "dispextern.h" |
37 #include "fontset.h" | 37 #include "fontset.h" |
38 #include "window.h" | 38 #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 | |
39 | 48 |
40 #ifdef FONTSET_DEBUG | 49 #ifdef FONTSET_DEBUG |
41 #undef xassert | 50 #undef xassert |
42 #define xassert(X) do {if (!(X)) abort ();} while (0) | 51 #define xassert(X) do {if (!(X)) abort ();} while (0) |
43 #undef INLINE | 52 #undef INLINE |
1137 | 1146 |
1138 return info; | 1147 return info; |
1139 } | 1148 } |
1140 | 1149 |
1141 | 1150 |
1142 /* Return the font name for the character at POSITION in the current | 1151 /* Return a cons (FONT-NAME . GLYPH-CODE). |
1152 FONT-NAME is the font name for the character at POSITION in the current | |
1143 buffer. This is computed from all the text properties and overlays | 1153 buffer. This is computed from all the text properties and overlays |
1144 that apply to POSITION. It returns nil in the following cases: | 1154 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: | |
1145 | 1161 |
1146 (1) The window system doesn't have a font for the character (thus | 1162 (1) The window system doesn't have a font for the character (thus |
1147 it is displayed by an empty box). | 1163 it is displayed by an empty box). |
1148 | 1164 |
1149 (2) The character code is invalid. | 1165 (2) The character code is invalid. |
1153 In addition, the returned font name may not take into account of | 1169 In addition, the returned font name may not take into account of |
1154 such redisplay engine hooks as what used in jit-lock-mode if | 1170 such redisplay engine hooks as what used in jit-lock-mode if |
1155 POSITION is currently not visible. */ | 1171 POSITION is currently not visible. */ |
1156 | 1172 |
1157 | 1173 |
1158 DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 1, 0, | 1174 DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, |
1159 doc: /* For internal use only. */) | 1175 doc: /* For internal use only. */) |
1160 (position) | 1176 (position, ch) |
1161 Lisp_Object position; | 1177 Lisp_Object position, ch; |
1162 { | 1178 { |
1163 int pos, pos_byte, dummy; | 1179 int pos, pos_byte, dummy; |
1164 int face_id; | 1180 int face_id; |
1165 int c; | 1181 int c, code; |
1166 Lisp_Object window; | 1182 Lisp_Object window; |
1167 struct window *w; | 1183 struct window *w; |
1168 struct frame *f; | 1184 struct frame *f; |
1169 struct face *face; | 1185 struct face *face; |
1170 | 1186 |
1171 CHECK_NUMBER_COERCE_MARKER (position); | 1187 CHECK_NUMBER_COERCE_MARKER (position); |
1172 pos = XINT (position); | 1188 pos = XINT (position); |
1173 if (pos < BEGV || pos >= ZV) | 1189 if (pos < BEGV || pos >= ZV) |
1174 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | 1190 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); |
1175 pos_byte = CHAR_TO_BYTE (pos); | 1191 pos_byte = CHAR_TO_BYTE (pos); |
1176 c = FETCH_CHAR (pos_byte); | 1192 if (NILP (ch)) |
1193 c = FETCH_CHAR (pos_byte); | |
1194 else | |
1195 { | |
1196 CHECK_NATNUM (ch); | |
1197 c = XINT (ch); | |
1198 } | |
1177 if (! CHAR_VALID_P (c, 0)) | 1199 if (! CHAR_VALID_P (c, 0)) |
1178 return Qnil; | 1200 return Qnil; |
1179 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | 1201 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); |
1180 if (NILP (window)) | 1202 if (NILP (window)) |
1181 return Qnil; | 1203 return Qnil; |
1182 w = XWINDOW (window); | 1204 w = XWINDOW (window); |
1183 f = XFRAME (w->frame); | 1205 f = XFRAME (w->frame); |
1184 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); | 1206 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); |
1185 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c); | 1207 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c); |
1186 face = FACE_FROM_ID (f, face_id); | 1208 face = FACE_FROM_ID (f, face_id); |
1187 return (face->font && face->font_name | 1209 if (! face->font || ! face->font_name) |
1188 ? build_string (face->font_name) | 1210 return Qnil; |
1189 : Qnil); | 1211 |
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)); | |
1190 } | 1226 } |
1191 | 1227 |
1192 | 1228 |
1193 /* Called from Ffontset_info via map_char_table on each leaf of | 1229 /* Called from Ffontset_info via map_char_table on each leaf of |
1194 fontset. ARG is a copy of the default fontset. The current leaf | 1230 fontset. ARG is a copy of the default fontset. The current leaf |