diff options
| author | Kenichi Handa | 2004-04-23 02:04:13 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-04-23 02:04:13 +0000 |
| commit | cf14fd6ec4f2a953eb796c9d42917a01a0c97973 (patch) | |
| tree | a9adabaaae42398c4ab799406252072440c67542 /src | |
| parent | d814862aa67a502a014d15c965f353f97500365a (diff) | |
| download | emacs-cf14fd6ec4f2a953eb796c9d42917a01a0c97973.tar.gz emacs-cf14fd6ec4f2a953eb796c9d42917a01a0c97973.zip | |
(Finternal_char_font): If POSITION is nil, return
font for displaying CH with the default face.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/fontset.c b/src/fontset.c index 1a7fdb29041..41c8c807495 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -1212,7 +1212,10 @@ If the named font is not yet loaded, return nil. */) | |||
| 1212 | /* Return a cons (FONT-NAME . GLYPH-CODE). | 1212 | /* Return a cons (FONT-NAME . GLYPH-CODE). |
| 1213 | FONT-NAME is the font name for the character at POSITION in the current | 1213 | FONT-NAME is the font name for the character at POSITION in the current |
| 1214 | buffer. This is computed from all the text properties and overlays | 1214 | buffer. This is computed from all the text properties and overlays |
| 1215 | that apply to POSITION. | 1215 | that apply to POSITION. POSTION may be nil, in which case, |
| 1216 | FONT-NAME is the font name for display the character CH with the | ||
| 1217 | default face. | ||
| 1218 | |||
| 1216 | GLYPH-CODE is the glyph code in the font to use for the character. | 1219 | GLYPH-CODE is the glyph code in the font to use for the character. |
| 1217 | 1220 | ||
| 1218 | If the 2nd optional arg CH is non-nil, it is a character to check | 1221 | If the 2nd optional arg CH is non-nil, it is a character to check |
| @@ -1225,7 +1228,8 @@ If the named font is not yet loaded, return nil. */) | |||
| 1225 | 1228 | ||
| 1226 | (2) The character code is invalid. | 1229 | (2) The character code is invalid. |
| 1227 | 1230 | ||
| 1228 | (3) The current buffer is not displayed in any window. | 1231 | (3) If POSITION is not nil, and the current buffer is not displayed |
| 1232 | in any window. | ||
| 1229 | 1233 | ||
| 1230 | In addition, the returned font name may not take into account of | 1234 | In addition, the returned font name may not take into account of |
| 1231 | such redisplay engine hooks as what used in jit-lock-mode if | 1235 | such redisplay engine hooks as what used in jit-lock-mode if |
| @@ -1240,31 +1244,42 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, | |||
| 1240 | int pos, pos_byte, dummy; | 1244 | int pos, pos_byte, dummy; |
| 1241 | int face_id; | 1245 | int face_id; |
| 1242 | int c, code; | 1246 | int c, code; |
| 1243 | Lisp_Object window; | ||
| 1244 | struct window *w; | ||
| 1245 | struct frame *f; | 1247 | struct frame *f; |
| 1246 | struct face *face; | 1248 | struct face *face; |
| 1247 | 1249 | ||
| 1248 | CHECK_NUMBER_COERCE_MARKER (position); | 1250 | if (NILP (position)) |
| 1249 | pos = XINT (position); | ||
| 1250 | if (pos < BEGV || pos >= ZV) | ||
| 1251 | args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | ||
| 1252 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1253 | if (NILP (ch)) | ||
| 1254 | c = FETCH_CHAR (pos_byte); | ||
| 1255 | else | ||
| 1256 | { | 1251 | { |
| 1257 | CHECK_NATNUM (ch); | 1252 | CHECK_NATNUM (ch); |
| 1258 | c = XINT (ch); | 1253 | c = XINT (ch); |
| 1254 | f = XFRAME (selected_frame); | ||
| 1255 | face_id = DEFAULT_FACE_ID; | ||
| 1256 | } | ||
| 1257 | else | ||
| 1258 | { | ||
| 1259 | Lisp_Object window; | ||
| 1260 | struct window *w; | ||
| 1261 | |||
| 1262 | CHECK_NUMBER_COERCE_MARKER (position); | ||
| 1263 | pos = XINT (position); | ||
| 1264 | if (pos < BEGV || pos >= ZV) | ||
| 1265 | args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); | ||
| 1266 | pos_byte = CHAR_TO_BYTE (pos); | ||
| 1267 | if (NILP (ch)) | ||
| 1268 | c = FETCH_CHAR (pos_byte); | ||
| 1269 | else | ||
| 1270 | { | ||
| 1271 | CHECK_NATNUM (ch); | ||
| 1272 | c = XINT (ch); | ||
| 1273 | } | ||
| 1274 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | ||
| 1275 | if (NILP (window)) | ||
| 1276 | return Qnil; | ||
| 1277 | w = XWINDOW (window); | ||
| 1278 | f = XFRAME (w->frame); | ||
| 1279 | face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); | ||
| 1259 | } | 1280 | } |
| 1260 | if (! CHAR_VALID_P (c, 0)) | 1281 | if (! CHAR_VALID_P (c, 0)) |
| 1261 | return Qnil; | 1282 | return Qnil; |
| 1262 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | ||
| 1263 | if (NILP (window)) | ||
| 1264 | return Qnil; | ||
| 1265 | w = XWINDOW (window); | ||
| 1266 | f = XFRAME (w->frame); | ||
| 1267 | face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0); | ||
| 1268 | face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c); | 1283 | face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c); |
| 1269 | face = FACE_FROM_ID (f, face_id); | 1284 | face = FACE_FROM_ID (f, face_id); |
| 1270 | if (! face->font || ! face->font_name) | 1285 | if (! face->font || ! face->font_name) |