diff options
| author | Karl Heuer | 1997-02-20 06:57:46 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-02-20 06:57:46 +0000 |
| commit | a851706636c64d487d6983fae54c4a74cb22c3af (patch) | |
| tree | 05209adbba364b4468de6e5d327de452298ae692 | |
| parent | a4decb7fcd7b8d63b3526afc596e5ea972202d7e (diff) | |
| download | emacs-a851706636c64d487d6983fae54c4a74cb22c3af.tar.gz emacs-a851706636c64d487d6983fae54c4a74cb22c3af.zip | |
Include charset.h.
(allocate_face, copy_face, face_eq1): Handle member `fontset' of
struct face, i.e. initialize, copy, and check it.
(intern_face, clear_face_cache): Handle member `non_ascii_gc' of
struct face, i.e. initialize and free it.
(free_frame_faces): Unload font only when fontset is not used.
Free non_ascii_gc.
(frame_update_line_height, merge_faces, compute_base_face): Handle
fontset.
(recompute_base_faces): Free non_ascii_gc.
(Fset_face_attribute_internal): Handle fontset.
| -rw-r--r-- | src/xfaces.c | 81 |
1 files changed, 70 insertions, 11 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 6e34bf4b24f..c033911e1de 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -26,10 +26,13 @@ Boston, MA 02111-1307, USA. */ | |||
| 26 | #include <config.h> | 26 | #include <config.h> |
| 27 | #include "lisp.h" | 27 | #include "lisp.h" |
| 28 | 28 | ||
| 29 | #include "charset.h" | ||
| 30 | |||
| 29 | #ifdef HAVE_FACES | 31 | #ifdef HAVE_FACES |
| 30 | 32 | ||
| 31 | #ifdef HAVE_X_WINDOWS | 33 | #ifdef HAVE_X_WINDOWS |
| 32 | #include "xterm.h" | 34 | #include "xterm.h" |
| 35 | #include "fontset.h" | ||
| 33 | #endif | 36 | #endif |
| 34 | #ifdef MSDOS | 37 | #ifdef MSDOS |
| 35 | #include "dosfns.h" | 38 | #include "dosfns.h" |
| @@ -76,7 +79,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 76 | ID is the face ID, an integer used internally by the C code to identify | 79 | ID is the face ID, an integer used internally by the C code to identify |
| 77 | the face, | 80 | the face, |
| 78 | FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors | 81 | FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors |
| 79 | to use with the face, | 82 | to use with the face, FONT may name fontsets, |
| 80 | BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't | 83 | BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't |
| 81 | use right now, and | 84 | use right now, and |
| 82 | UNDERLINE-P is non-nil if the face should be underlined. | 85 | UNDERLINE-P is non-nil if the face should be underlined. |
| @@ -178,6 +181,7 @@ allocate_face () | |||
| 178 | struct face *result = (struct face *) xmalloc (sizeof (struct face)); | 181 | struct face *result = (struct face *) xmalloc (sizeof (struct face)); |
| 179 | bzero (result, sizeof (struct face)); | 182 | bzero (result, sizeof (struct face)); |
| 180 | result->font = (XFontStruct *) FACE_DEFAULT; | 183 | result->font = (XFontStruct *) FACE_DEFAULT; |
| 184 | result->fontset = -1; | ||
| 181 | result->foreground = FACE_DEFAULT; | 185 | result->foreground = FACE_DEFAULT; |
| 182 | result->background = FACE_DEFAULT; | 186 | result->background = FACE_DEFAULT; |
| 183 | result->stipple = FACE_DEFAULT; | 187 | result->stipple = FACE_DEFAULT; |
| @@ -192,6 +196,7 @@ copy_face (face) | |||
| 192 | struct face *result = allocate_face (); | 196 | struct face *result = allocate_face (); |
| 193 | 197 | ||
| 194 | result->font = face->font; | 198 | result->font = face->font; |
| 199 | result->fontset = face->fontset; | ||
| 195 | result->foreground = face->foreground; | 200 | result->foreground = face->foreground; |
| 196 | result->background = face->background; | 201 | result->background = face->background; |
| 197 | result->stipple = face->stipple; | 202 | result->stipple = face->stipple; |
| @@ -207,6 +212,7 @@ face_eql (face1, face2) | |||
| 207 | struct face *face1, *face2; | 212 | struct face *face1, *face2; |
| 208 | { | 213 | { |
| 209 | return ( face1->font == face2->font | 214 | return ( face1->font == face2->font |
| 215 | && face1->fontset == face2->fontset | ||
| 210 | && face1->foreground == face2->foreground | 216 | && face1->foreground == face2->foreground |
| 211 | && face1->background == face2->background | 217 | && face1->background == face2->background |
| 212 | && face1->stipple == face2->stipple | 218 | && face1->stipple == face2->stipple |
| @@ -261,6 +267,10 @@ intern_face (f, face) | |||
| 261 | mask, &xgcv); | 267 | mask, &xgcv); |
| 262 | 268 | ||
| 263 | face->gc = gc; | 269 | face->gc = gc; |
| 270 | /* We used the following GC for all non-ASCII characters by changing | ||
| 271 | only GCfont each time. */ | ||
| 272 | face->non_ascii_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 273 | mask, &xgcv); | ||
| 264 | 274 | ||
| 265 | UNBLOCK_INPUT; | 275 | UNBLOCK_INPUT; |
| 266 | 276 | ||
| @@ -290,7 +300,10 @@ clear_face_cache () | |||
| 290 | { | 300 | { |
| 291 | struct face *face = FRAME_COMPUTED_FACES (f) [i]; | 301 | struct face *face = FRAME_COMPUTED_FACES (f) [i]; |
| 292 | if (face->gc) | 302 | if (face->gc) |
| 293 | XFreeGC (dpy, face->gc); | 303 | { |
| 304 | XFreeGC (dpy, face->gc); | ||
| 305 | XFreeGC (dpy, face->non_ascii_gc); | ||
| 306 | } | ||
| 294 | face->gc = 0; | 307 | face->gc = 0; |
| 295 | } | 308 | } |
| 296 | } | 309 | } |
| @@ -607,7 +620,8 @@ free_frame_faces (f) | |||
| 607 | struct face *face = FRAME_PARAM_FACES (f) [i]; | 620 | struct face *face = FRAME_PARAM_FACES (f) [i]; |
| 608 | if (face) | 621 | if (face) |
| 609 | { | 622 | { |
| 610 | unload_font (f, face->font); | 623 | if (face->fontset < 0) |
| 624 | unload_font (f, face->font); | ||
| 611 | unload_color (f, face->foreground); | 625 | unload_color (f, face->foreground); |
| 612 | unload_color (f, face->background); | 626 | unload_color (f, face->background); |
| 613 | x_destroy_bitmap (f, face->stipple); | 627 | x_destroy_bitmap (f, face->stipple); |
| @@ -627,7 +641,10 @@ free_frame_faces (f) | |||
| 627 | if (face) | 641 | if (face) |
| 628 | { | 642 | { |
| 629 | if (face->gc) | 643 | if (face->gc) |
| 630 | XFreeGC (dpy, face->gc); | 644 | { |
| 645 | XFreeGC (dpy, face->gc); | ||
| 646 | XFreeGC (dpy, face->non_ascii_gc); | ||
| 647 | } | ||
| 631 | xfree (face); | 648 | xfree (face); |
| 632 | } | 649 | } |
| 633 | } | 650 | } |
| @@ -752,13 +769,19 @@ frame_update_line_height (f) | |||
| 752 | FRAME_PTR f; | 769 | FRAME_PTR f; |
| 753 | { | 770 | { |
| 754 | int i; | 771 | int i; |
| 755 | int biggest = FONT_HEIGHT (f->output_data.x->font); | 772 | int fontset = f->output_data.x->fontset; |
| 773 | int biggest = (fontset > 0 | ||
| 774 | ? FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height | ||
| 775 | : FONT_HEIGHT (f->output_data.x->font)); | ||
| 756 | 776 | ||
| 757 | for (i = 0; i < f->output_data.x->n_param_faces; i++) | 777 | for (i = 0; i < f->output_data.x->n_param_faces; i++) |
| 758 | if (f->output_data.x->param_faces[i] != 0 | 778 | if (f->output_data.x->param_faces[i] != 0 |
| 759 | && f->output_data.x->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT) | 779 | && f->output_data.x->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT) |
| 760 | { | 780 | { |
| 761 | int height = FONT_HEIGHT (f->output_data.x->param_faces[i]->font); | 781 | int height = ((fontset = f->output_data.x->param_faces[i]->fontset) > 0 |
| 782 | ? FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height | ||
| 783 | : FONT_HEIGHT (f->output_data.x->param_faces[i]->font)); | ||
| 784 | |||
| 762 | if (height > biggest) | 785 | if (height > biggest) |
| 763 | biggest = height; | 786 | biggest = height; |
| 764 | } | 787 | } |
| @@ -783,6 +806,8 @@ merge_faces (from, to) | |||
| 783 | if (from->font != (XFontStruct *) FACE_DEFAULT | 806 | if (from->font != (XFontStruct *) FACE_DEFAULT |
| 784 | && same_size_fonts (from->font, to->font)) | 807 | && same_size_fonts (from->font, to->font)) |
| 785 | to->font = from->font; | 808 | to->font = from->font; |
| 809 | if (from->fontset != -1) | ||
| 810 | to->fontset = from->fontset; | ||
| 786 | if (from->foreground != FACE_DEFAULT) | 811 | if (from->foreground != FACE_DEFAULT) |
| 787 | to->foreground = from->foreground; | 812 | to->foreground = from->foreground; |
| 788 | if (from->background != FACE_DEFAULT) | 813 | if (from->background != FACE_DEFAULT) |
| @@ -809,6 +834,7 @@ compute_base_face (f, face) | |||
| 809 | face->foreground = FRAME_FOREGROUND_PIXEL (f); | 834 | face->foreground = FRAME_FOREGROUND_PIXEL (f); |
| 810 | face->background = FRAME_BACKGROUND_PIXEL (f); | 835 | face->background = FRAME_BACKGROUND_PIXEL (f); |
| 811 | face->font = FRAME_FONT (f); | 836 | face->font = FRAME_FONT (f); |
| 837 | face->fontset = -1; | ||
| 812 | face->stipple = 0; | 838 | face->stipple = 0; |
| 813 | face->underline = 0; | 839 | face->underline = 0; |
| 814 | } | 840 | } |
| @@ -1065,10 +1091,15 @@ recompute_basic_faces (f) | |||
| 1065 | BLOCK_INPUT; | 1091 | BLOCK_INPUT; |
| 1066 | 1092 | ||
| 1067 | if (FRAME_DEFAULT_FACE (f)->gc) | 1093 | if (FRAME_DEFAULT_FACE (f)->gc) |
| 1068 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_DEFAULT_FACE (f)->gc); | 1094 | { |
| 1095 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_DEFAULT_FACE (f)->gc); | ||
| 1096 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_DEFAULT_FACE (f)->non_ascii_gc); | ||
| 1097 | } | ||
| 1069 | if (FRAME_MODE_LINE_FACE (f)->gc) | 1098 | if (FRAME_MODE_LINE_FACE (f)->gc) |
| 1070 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_MODE_LINE_FACE (f)->gc); | 1099 | { |
| 1071 | 1100 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_MODE_LINE_FACE (f)->gc); | |
| 1101 | XFreeGC (FRAME_X_DISPLAY (f), FRAME_MODE_LINE_FACE (f)->non_ascii_gc); | ||
| 1102 | } | ||
| 1072 | compute_base_face (f, FRAME_DEFAULT_FACE (f)); | 1103 | compute_base_face (f, FRAME_DEFAULT_FACE (f)); |
| 1073 | compute_base_face (f, FRAME_MODE_LINE_FACE (f)); | 1104 | compute_base_face (f, FRAME_MODE_LINE_FACE (f)); |
| 1074 | 1105 | ||
| @@ -1159,10 +1190,38 @@ DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal, | |||
| 1159 | is taken to mean an unused face nowadays). */ | 1190 | is taken to mean an unused face nowadays). */ |
| 1160 | face->font = (XFontStruct *)1 ; | 1191 | face->font = (XFontStruct *)1 ; |
| 1161 | #else | 1192 | #else |
| 1162 | XFontStruct *font = load_font (f, attr_value); | 1193 | XFontStruct *font; |
| 1163 | if (face->font != f->output_data.x->font) | 1194 | int fontset; |
| 1195 | |||
| 1196 | if (NILP (attr_value)) | ||
| 1197 | { | ||
| 1198 | font = (XFontStruct *) FACE_DEFAULT; | ||
| 1199 | fontset = -1; | ||
| 1200 | } | ||
| 1201 | else | ||
| 1202 | { | ||
| 1203 | CHECK_STRING (attr_value, 0); | ||
| 1204 | fontset = fs_query_fontset (f, XSTRING (attr_value)->data); | ||
| 1205 | if (fontset >= 0) | ||
| 1206 | { | ||
| 1207 | struct font_info *fontp; | ||
| 1208 | |||
| 1209 | if (!(fontp = fs_load_font (f, FRAME_X_FONT_TABLE (f), | ||
| 1210 | CHARSET_ASCII, NULL, fontset))) | ||
| 1211 | Fsignal (Qerror, | ||
| 1212 | Fcons (build_string ("ASCII font can't be loaded"), | ||
| 1213 | Fcons (attr_value, Qnil))); | ||
| 1214 | font = (XFontStruct *) (fontp->font); | ||
| 1215 | } | ||
| 1216 | else | ||
| 1217 | font = load_font (f, attr_value); | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | if (face->fontset == -1 && face->font != f->output_data.x->font) | ||
| 1164 | unload_font (f, face->font); | 1221 | unload_font (f, face->font); |
| 1222 | |||
| 1165 | face->font = font; | 1223 | face->font = font; |
| 1224 | face->fontset = fontset; | ||
| 1166 | if (frame_update_line_height (f)) | 1225 | if (frame_update_line_height (f)) |
| 1167 | x_set_window_size (f, 0, f->width, f->height); | 1226 | x_set_window_size (f, 0, f->width, f->height); |
| 1168 | /* Must clear cache, since it might contain the font | 1227 | /* Must clear cache, since it might contain the font |