diff options
| author | Geoff Voelker | 1998-10-20 22:12:51 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-10-20 22:12:51 +0000 |
| commit | 30a231e64dddc201b698a69ab1e59a181bf1eb0c (patch) | |
| tree | 4b8b775151bd16f3a6ea46b43a928ce0f9471a4c | |
| parent | 67c2a40ffd69d6df609b0dfbfd4277740ce8b37a (diff) | |
| download | emacs-30a231e64dddc201b698a69ab1e59a181bf1eb0c.tar.gz emacs-30a231e64dddc201b698a69ab1e59a181bf1eb0c.zip | |
Update comments referring to obsolete structs.
(allocate_face, copy_face, face_eql, load_font,
Fpixmap_spec_p, free_frame_faces, new_computed_face,
frame_update_line_height, merge_faces, compute_base_face,
Fset_face_attribute_internal): Use fontset support based on xfaces.c.
| -rw-r--r-- | src/w32faces.c | 120 |
1 files changed, 90 insertions, 30 deletions
diff --git a/src/w32faces.c b/src/w32faces.c index cc61c5017ec..3763b600a55 100644 --- a/src/w32faces.c +++ b/src/w32faces.c | |||
| @@ -33,6 +33,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 33 | #include "blockinput.h" | 33 | #include "blockinput.h" |
| 34 | #include "window.h" | 34 | #include "window.h" |
| 35 | #include "intervals.h" | 35 | #include "intervals.h" |
| 36 | #include "charset.h" | ||
| 37 | #include "fontset.h" | ||
| 36 | 38 | ||
| 37 | 39 | ||
| 38 | /* An explanation of the face data structures. */ | 40 | /* An explanation of the face data structures. */ |
| @@ -50,7 +52,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 50 | ID is the face ID, an integer used internally by the C code to identify | 52 | ID is the face ID, an integer used internally by the C code to identify |
| 51 | the face, | 53 | the face, |
| 52 | FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors | 54 | FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors |
| 53 | to use with the face, | 55 | to use with the face, FONT may name fontsets, |
| 54 | BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't | 56 | BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't |
| 55 | use right now, and | 57 | use right now, and |
| 56 | UNDERLINE-P is non-nil if the face should be underlined. | 58 | UNDERLINE-P is non-nil if the face should be underlined. |
| @@ -62,13 +64,13 @@ Boston, MA 02111-1307, USA. */ | |||
| 62 | (assq FACE-NAME global-face-data) returns a vector describing the | 64 | (assq FACE-NAME global-face-data) returns a vector describing the |
| 63 | global parameters for that face. | 65 | global parameters for that face. |
| 64 | 66 | ||
| 65 | Let PARAM-FACE be FRAME->display.x->param_faces[Faref (FACE-VECTOR, 2)]. | 67 | Let PARAM-FACE be FRAME->output_data.w32->param_faces[Faref(FACE-VECTOR,2)]. |
| 66 | PARAM_FACE is a struct face whose members are the Xlib analogues of | 68 | PARAM_FACE is a struct face whose members are the Xlib analogues of |
| 67 | the parameters in FACE-VECTOR. If an element of FACE-VECTOR is | 69 | the parameters in FACE-VECTOR. If an element of FACE-VECTOR is |
| 68 | nil, then the corresponding member of PARAM_FACE is FACE_DEFAULT. | 70 | nil, then the corresponding member of PARAM_FACE is FACE_DEFAULT. |
| 69 | These faces are called "parameter faces", because they're the ones | 71 | These faces are called "parameter faces", because they're the ones |
| 70 | lisp manipulates to control what gets displayed. Elements 0 and 1 | 72 | lisp manipulates to control what gets displayed. Elements 0 and 1 |
| 71 | of FRAME->display.x->param_faces are special - they describe the | 73 | of FRAME->output_data.w32->param_faces are special - they describe the |
| 72 | default and mode line faces. None of the faces in param_faces have | 74 | default and mode line faces. None of the faces in param_faces have |
| 73 | GC's. (See src/dispextern.h for the definition of struct face. | 75 | GC's. (See src/dispextern.h for the definition of struct face. |
| 74 | lisp/faces.el maintains the isomorphism between face_alist and | 76 | lisp/faces.el maintains the isomorphism between face_alist and |
| @@ -79,9 +81,9 @@ Boston, MA 02111-1307, USA. */ | |||
| 79 | properties. The resulting faces are called "computed faces"; none | 81 | properties. The resulting faces are called "computed faces"; none |
| 80 | of their members are FACE_DEFAULT; they are completely specified. | 82 | of their members are FACE_DEFAULT; they are completely specified. |
| 81 | They then call intern_compute_face to search | 83 | They then call intern_compute_face to search |
| 82 | FRAME->display.x->computed_faces for a matching face, add one if | 84 | FRAME->output_data.x->computed_faces for a matching face, add one if |
| 83 | none is found, and return the index into | 85 | none is found, and return the index into |
| 84 | FRAME->display.x->computed_faces. FRAME's glyph matrices use these | 86 | FRAME->output_data.x->computed_faces. FRAME's glyph matrices use these |
| 85 | indices to record the faces of the matrix characters, and the X | 87 | indices to record the faces of the matrix characters, and the X |
| 86 | display hooks consult compute_faces to decide how to display these | 88 | display hooks consult compute_faces to decide how to display these |
| 87 | characters. Elements 0 and 1 of computed_faces always describe the | 89 | characters. Elements 0 and 1 of computed_faces always describe the |
| @@ -96,6 +98,9 @@ Boston, MA 02111-1307, USA. */ | |||
| 96 | This is done from time to time so that we don't hold on to | 98 | This is done from time to time so that we don't hold on to |
| 97 | lots of GCs that are no longer needed. | 99 | lots of GCs that are no longer needed. |
| 98 | 100 | ||
| 101 | If a computed face has 0 as its font, | ||
| 102 | it is unused, and can be reused by new_computed_face. | ||
| 103 | |||
| 99 | Constraints: | 104 | Constraints: |
| 100 | 105 | ||
| 101 | Symbols naming faces must have associations on all frames; for any | 106 | Symbols naming faces must have associations on all frames; for any |
| @@ -152,6 +157,7 @@ allocate_face () | |||
| 152 | struct face *result = (struct face *) xmalloc (sizeof (struct face)); | 157 | struct face *result = (struct face *) xmalloc (sizeof (struct face)); |
| 153 | bzero (result, sizeof (struct face)); | 158 | bzero (result, sizeof (struct face)); |
| 154 | result->font = (XFontStruct *) FACE_DEFAULT; | 159 | result->font = (XFontStruct *) FACE_DEFAULT; |
| 160 | result->fontset = -1; | ||
| 155 | result->foreground = FACE_DEFAULT; | 161 | result->foreground = FACE_DEFAULT; |
| 156 | result->background = FACE_DEFAULT; | 162 | result->background = FACE_DEFAULT; |
| 157 | result->stipple = FACE_DEFAULT; | 163 | result->stipple = FACE_DEFAULT; |
| @@ -166,6 +172,7 @@ copy_face (face) | |||
| 166 | struct face *result = allocate_face (); | 172 | struct face *result = allocate_face (); |
| 167 | 173 | ||
| 168 | result->font = face->font; | 174 | result->font = face->font; |
| 175 | result->fontset = face->fontset; | ||
| 169 | result->foreground = face->foreground; | 176 | result->foreground = face->foreground; |
| 170 | result->background = face->background; | 177 | result->background = face->background; |
| 171 | result->stipple = face->stipple; | 178 | result->stipple = face->stipple; |
| @@ -181,6 +188,7 @@ face_eql (face1, face2) | |||
| 181 | struct face *face1, *face2; | 188 | struct face *face1, *face2; |
| 182 | { | 189 | { |
| 183 | return ( face1->font == face2->font | 190 | return ( face1->font == face2->font |
| 191 | && face1->fontset == face2->fontset | ||
| 184 | && face1->foreground == face2->foreground | 192 | && face1->foreground == face2->foreground |
| 185 | && face1->background == face2->background | 193 | && face1->background == face2->background |
| 186 | && face1->stipple == face2->stipple | 194 | && face1->stipple == face2->stipple |
| @@ -223,15 +231,18 @@ load_font (f, name) | |||
| 223 | struct frame *f; | 231 | struct frame *f; |
| 224 | Lisp_Object name; | 232 | Lisp_Object name; |
| 225 | { | 233 | { |
| 226 | XFontStruct *font; | 234 | struct font_info *fontinf; |
| 235 | XFontStruct *font = NULL; | ||
| 227 | 236 | ||
| 228 | if (NILP (name)) | 237 | if (NILP (name)) |
| 229 | return (XFontStruct *) FACE_DEFAULT; | 238 | return (XFontStruct *) FACE_DEFAULT; |
| 230 | 239 | ||
| 231 | CHECK_STRING (name, 0); | 240 | CHECK_STRING (name, 0); |
| 232 | BLOCK_INPUT; | 241 | BLOCK_INPUT; |
| 233 | font = w32_load_font (FRAME_W32_DISPLAY_INFO (f), (char *) XSTRING (name)->data); | 242 | fontinf = w32_load_font (f, (char *) XSTRING (name)->data, 0); |
| 234 | UNBLOCK_INPUT; | 243 | UNBLOCK_INPUT; |
| 244 | if (fontinf) | ||
| 245 | font = (XFontStruct *)fontinf->font; | ||
| 235 | 246 | ||
| 236 | if (! font) | 247 | if (! font) |
| 237 | Fsignal (Qerror, Fcons (build_string ("undefined font"), | 248 | Fsignal (Qerror, Fcons (build_string ("undefined font"), |
| @@ -281,24 +292,24 @@ unload_color (f, pixel) | |||
| 281 | } | 292 | } |
| 282 | 293 | ||
| 283 | DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0, | 294 | DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0, |
| 284 | "Return t if ARG is a valid pixmap specification.") | 295 | "Return t if OBJECT is a valid pixmap specification.") |
| 285 | (arg) | 296 | (object) |
| 286 | Lisp_Object arg; | 297 | Lisp_Object object; |
| 287 | { | 298 | { |
| 288 | Lisp_Object height, width; | 299 | Lisp_Object height, width; |
| 289 | 300 | ||
| 290 | return ((STRINGP (arg) | 301 | return ((STRINGP (object) |
| 291 | || (CONSP (arg) | 302 | || (CONSP (object) |
| 292 | && CONSP (XCONS (arg)->cdr) | 303 | && CONSP (XCONS (object)->cdr) |
| 293 | && CONSP (XCONS (XCONS (arg)->cdr)->cdr) | 304 | && CONSP (XCONS (XCONS (object)->cdr)->cdr) |
| 294 | && NILP (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->cdr) | 305 | && NILP (XCONS (XCONS (XCONS (object)->cdr)->cdr)->cdr) |
| 295 | && (width = XCONS (arg)->car, INTEGERP (width)) | 306 | && (width = XCONS (object)->car, INTEGERP (width)) |
| 296 | && (height = XCONS (XCONS (arg)->cdr)->car, INTEGERP (height)) | 307 | && (height = XCONS (XCONS (object)->cdr)->car, INTEGERP (height)) |
| 297 | && STRINGP (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->car) | 308 | && STRINGP (XCONS (XCONS (XCONS (object)->cdr)->cdr)->car) |
| 298 | && XINT (width) > 0 | 309 | && XINT (width) > 0 |
| 299 | && XINT (height) > 0 | 310 | && XINT (height) > 0 |
| 300 | /* The string must have enough bits for width * height. */ | 311 | /* The string must have enough bits for width * height. */ |
| 301 | && ((XSTRING (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->car)->size | 312 | && ((XSTRING (XCONS (XCONS (XCONS (object)->cdr)->cdr)->car)->size |
| 302 | * (BITS_PER_INT / sizeof (int))) | 313 | * (BITS_PER_INT / sizeof (int))) |
| 303 | >= XFASTINT (width) * XFASTINT (height)))) | 314 | >= XFASTINT (width) * XFASTINT (height)))) |
| 304 | ? Qt : Qnil); | 315 | ? Qt : Qnil); |
| @@ -422,6 +433,7 @@ free_frame_faces (f) | |||
| 422 | struct face *face = FRAME_PARAM_FACES (f) [i]; | 433 | struct face *face = FRAME_PARAM_FACES (f) [i]; |
| 423 | if (face) | 434 | if (face) |
| 424 | { | 435 | { |
| 436 | if (face->fontset < 0) | ||
| 425 | unload_font (f, face->font); | 437 | unload_font (f, face->font); |
| 426 | unload_color (f, face->foreground); | 438 | unload_color (f, face->foreground); |
| 427 | unload_color (f, face->background); | 439 | unload_color (f, face->background); |
| @@ -458,7 +470,19 @@ new_computed_face (f, new_face) | |||
| 458 | struct frame *f; | 470 | struct frame *f; |
| 459 | struct face *new_face; | 471 | struct face *new_face; |
| 460 | { | 472 | { |
| 461 | int i = FRAME_N_COMPUTED_FACES (f); | 473 | int len = FRAME_N_COMPUTED_FACES (f); |
| 474 | int i; | ||
| 475 | |||
| 476 | /* Search for an unused computed face in the middle of the table. */ | ||
| 477 | for (i = 0; i < len; i++) | ||
| 478 | { | ||
| 479 | struct face *face = FRAME_COMPUTED_FACES (f)[i]; | ||
| 480 | if (face->font == 0) | ||
| 481 | { | ||
| 482 | FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face); | ||
| 483 | return i; | ||
| 484 | } | ||
| 485 | } | ||
| 462 | 486 | ||
| 463 | if (i >= FRAME_SIZE_COMPUTED_FACES (f)) | 487 | if (i >= FRAME_SIZE_COMPUTED_FACES (f)) |
| 464 | { | 488 | { |
| @@ -549,21 +573,28 @@ frame_update_line_height (f) | |||
| 549 | FRAME_PTR f; | 573 | FRAME_PTR f; |
| 550 | { | 574 | { |
| 551 | int i; | 575 | int i; |
| 552 | int biggest = FONT_HEIGHT (f->output_data.w32->font); | 576 | int fontset = FRAME_FONTSET (f); |
| 577 | int biggest = (fontset > 0 | ||
| 578 | ? FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height | ||
| 579 | : FONT_HEIGHT (FRAME_FONT (f))); | ||
| 553 | 580 | ||
| 554 | for (i = 0; i < f->output_data.w32->n_param_faces; i++) | 581 | for (i = 0; i < FRAME_N_PARAM_FACES (f); i++) |
| 555 | if (f->output_data.w32->param_faces[i] != 0 | 582 | if (FRAME_PARAM_FACES (f)[i] != 0 |
| 556 | && f->output_data.w32->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT) | 583 | && FRAME_PARAM_FACES (f)[i]->font != (XFontStruct *) FACE_DEFAULT) |
| 557 | { | 584 | { |
| 558 | int height = FONT_HEIGHT (f->output_data.w32->param_faces[i]->font); | 585 | int height = ((fontset = |
| 586 | FRAME_PARAM_FACES (f)[i]->fontset) > 0 | ||
| 587 | ? FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height | ||
| 588 | : FONT_HEIGHT | ||
| 589 | (FRAME_PARAM_FACES (f)[i]->font)); | ||
| 559 | if (height > biggest) | 590 | if (height > biggest) |
| 560 | biggest = height; | 591 | biggest = height; |
| 561 | } | 592 | } |
| 562 | 593 | ||
| 563 | if (biggest == f->output_data.w32->line_height) | 594 | if (biggest == FRAME_LINE_HEIGHT (f)) |
| 564 | return 0; | 595 | return 0; |
| 565 | 596 | ||
| 566 | f->output_data.w32->line_height = biggest; | 597 | FRAME_LINE_HEIGHT (f) = biggest; |
| 567 | return 1; | 598 | return 1; |
| 568 | } | 599 | } |
| 569 | 600 | ||
| @@ -579,6 +610,8 @@ merge_faces (from, to) | |||
| 579 | if (from->font != (XFontStruct *) FACE_DEFAULT | 610 | if (from->font != (XFontStruct *) FACE_DEFAULT |
| 580 | && same_size_fonts (from->font, to->font)) | 611 | && same_size_fonts (from->font, to->font)) |
| 581 | to->font = from->font; | 612 | to->font = from->font; |
| 613 | if (from->fontset != -1) | ||
| 614 | to->fontset = from->fontset; | ||
| 582 | if (from->foreground != FACE_DEFAULT) | 615 | if (from->foreground != FACE_DEFAULT) |
| 583 | to->foreground = from->foreground; | 616 | to->foreground = from->foreground; |
| 584 | if (from->background != FACE_DEFAULT) | 617 | if (from->background != FACE_DEFAULT) |
| @@ -605,6 +638,7 @@ compute_base_face (f, face) | |||
| 605 | face->foreground = FRAME_FOREGROUND_PIXEL (f); | 638 | face->foreground = FRAME_FOREGROUND_PIXEL (f); |
| 606 | face->background = FRAME_BACKGROUND_PIXEL (f); | 639 | face->background = FRAME_BACKGROUND_PIXEL (f); |
| 607 | face->font = FRAME_FONT (f); | 640 | face->font = FRAME_FONT (f); |
| 641 | face->fontset = -1; | ||
| 608 | face->stipple = 0; | 642 | face->stipple = 0; |
| 609 | face->underline = 0; | 643 | face->underline = 0; |
| 610 | } | 644 | } |
| @@ -927,7 +961,7 @@ DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal, | |||
| 927 | if (id < 0 || id >= next_face_id) | 961 | if (id < 0 || id >= next_face_id) |
| 928 | error ("Face id out of range"); | 962 | error ("Face id out of range"); |
| 929 | 963 | ||
| 930 | if (! FRAME_W32_P (f)) | 964 | if (! FRAME_WINDOW_P (f)) |
| 931 | return Qnil; | 965 | return Qnil; |
| 932 | 966 | ||
| 933 | ensure_face_ready (f, id); | 967 | ensure_face_ready (f, id); |
| @@ -935,10 +969,36 @@ DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal, | |||
| 935 | 969 | ||
| 936 | if (EQ (attr_name, intern ("font"))) | 970 | if (EQ (attr_name, intern ("font"))) |
| 937 | { | 971 | { |
| 938 | XFontStruct *font = load_font (f, attr_value); | 972 | XFontStruct *font = NULL; |
| 939 | if (face->font != f->output_data.w32->font) | 973 | int fontset; |
| 974 | |||
| 975 | if (NILP (attr_value)) | ||
| 976 | { | ||
| 977 | font = (XFontStruct *) FACE_DEFAULT; | ||
| 978 | fontset = -1; | ||
| 979 | } | ||
| 980 | else | ||
| 981 | { | ||
| 982 | CHECK_STRING (attr_value, 0); | ||
| 983 | fontset = fs_query_fontset (f, XSTRING (attr_value)->data); | ||
| 984 | if (fontset >= 0) | ||
| 985 | { | ||
| 986 | struct font_info *fontp; | ||
| 987 | |||
| 988 | if (!(fontp = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), | ||
| 989 | CHARSET_ASCII, NULL, fontset))) | ||
| 990 | Fsignal (Qerror, | ||
| 991 | Fcons (build_string ("ASCII font can't be loaded"), | ||
| 992 | Fcons (attr_value, Qnil))); | ||
| 993 | font = (XFontStruct *) (fontp->font); | ||
| 994 | } | ||
| 995 | else | ||
| 996 | font = load_font (f, attr_value); | ||
| 997 | } | ||
| 998 | if (face->fontset == -1 && face->font != f->output_data.w32->font) | ||
| 940 | unload_font (f, face->font); | 999 | unload_font (f, face->font); |
| 941 | face->font = font; | 1000 | face->font = font; |
| 1001 | face->fontset = fontset; | ||
| 942 | if (frame_update_line_height (f)) | 1002 | if (frame_update_line_height (f)) |
| 943 | x_set_window_size (f, 0, f->width, f->height); | 1003 | x_set_window_size (f, 0, f->width, f->height); |
| 944 | /* Must clear cache, since it might contain the font | 1004 | /* Must clear cache, since it might contain the font |