diff options
| author | Kenichi Handa | 2003-09-28 23:17:47 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-09-28 23:17:47 +0000 |
| commit | e5bc082b291e3af1d48342f111e88ec49993a479 (patch) | |
| tree | 237475d933ddadd5503241ed80b3fb0ac4203314 /src | |
| parent | 40409f0585d49dbcad912d49c7dc467c51b4de9f (diff) | |
| download | emacs-e5bc082b291e3af1d48342f111e88ec49993a479.tar.gz emacs-e5bc082b291e3af1d48342f111e88ec49993a479.zip | |
(Finternal_char_font): Change return value to
cons (FONT-NAME . GLYPH-CODE).
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/src/fontset.c b/src/fontset.c index 608bdec83d4..996631f1a59 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -36,6 +36,15 @@ Boston, MA 02111-1307, USA. */ | |||
| 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 |
| @@ -1139,9 +1148,16 @@ If the named font is not yet loaded, return nil. */) | |||
| 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). |
| @@ -1155,14 +1171,14 @@ If the named font is not yet loaded, return nil. */) | |||
| 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; |
| @@ -1173,7 +1189,13 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 1, 0, | |||
| 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); |
| @@ -1184,9 +1206,23 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 1, 0, | |||
| 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 | ||