aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-05-25 06:59:12 +0000
committerJim Blandy1993-05-25 06:59:12 +0000
commit1d9fd7feaaca672cffca01645c2f8dcd64fd1058 (patch)
treeeb81380291f987b155394d9c08634774a2876bb8 /src
parented61592a799cf82479d157dca0fa1d6f6216990d (diff)
downloademacs-1d9fd7feaaca672cffca01645c2f8dcd64fd1058.tar.gz
emacs-1d9fd7feaaca672cffca01645c2f8dcd64fd1058.zip
* xfns.c (Fx_list_fonts): New function.
(same_size_fonts): Function moved here from xfaces.c. (face_name_id_number): Add extern declaration for this. * xfaces.c (same_size_fonts): Moved to xfns.c. Left an extern declaration behind. (face_name_id_number): Make this externally visible, and make the FRAME argument a FRAME_PTR, not a Lisp_Object. (compute_char_face): Call face_name_id_number properly. * xfaces.c (unload_color): Don't free the pixel for now. * xfaces.c (merge_faces): You can't tell if a font is a character-cell font or not by testing whether or not it has a per_char table. They all do.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 5aec6907c0c..9b301e35b79 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -136,6 +136,10 @@ int next_face_id;
136/* The number of the face to use to indicate the region. */ 136/* The number of the face to use to indicate the region. */
137int region_face; 137int region_face;
138 138
139/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
140 We assume that they're both character-cell fonts. */
141extern int same_size_fonts ();
142
139/* This is what appears in a slot in a face to signify that the face 143/* This is what appears in a slot in a face to signify that the face
140 does not specify that display aspect. */ 144 does not specify that display aspect. */
141#define FACE_DEFAULT (~0) 145#define FACE_DEFAULT (~0)
@@ -143,7 +147,7 @@ int region_face;
143Lisp_Object Qface, Qwindow, Qpriority; 147Lisp_Object Qface, Qwindow, Qpriority;
144 148
145static void build_face (); 149static void build_face ();
146static Lisp_Object face_name_id_number (); 150int face_name_id_number ();
147 151
148struct face *intern_face (); 152struct face *intern_face ();
149static void ensure_face_ready (); 153static void ensure_face_ready ();
@@ -406,6 +410,13 @@ unload_color (f, pixel)
406 struct frame *f; 410 struct frame *f;
407 Pixel pixel; 411 Pixel pixel;
408{ 412{
413 /* Since faces get built by copying parameters from other faces, the
414 allocation counts for the colors get all screwed up. I don't see
415 any solution that will take less than 10 minutes, and it's better
416 to have a color leak than a crash, so I'm just dyking this out.
417 This isn't really a color leak, anyway - if we ask for it again,
418 we'll get the same pixel. */
419#if 0
409 Colormap cmap; 420 Colormap cmap;
410 Display *dpy = x_current_display; 421 Display *dpy = x_current_display;
411 if (pixel == FACE_DEFAULT 422 if (pixel == FACE_DEFAULT
@@ -416,6 +427,7 @@ unload_color (f, pixel)
416 BLOCK_INPUT; 427 BLOCK_INPUT;
417 XFreeColors (dpy, cmap, &pixel, 1, 0); 428 XFreeColors (dpy, cmap, &pixel, 1, 0);
418 UNBLOCK_INPUT; 429 UNBLOCK_INPUT;
430#endif
419} 431}
420 432
421/* Initializing face arrays for frames. */ 433/* Initializing face arrays for frames. */
@@ -552,21 +564,6 @@ ensure_face_ready (f, id)
552 564
553/* Computing faces appropriate for a given piece of text in a buffer. */ 565/* Computing faces appropriate for a given piece of text in a buffer. */
554 566
555/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
556 We assume that they're both character-cell fonts. */
557static int
558same_size_fonts (font1, font2)
559 XFontStruct *font1, *font2;
560{
561 XCharStruct *bounds1 = &font1->min_bounds;
562 XCharStruct *bounds2 = &font2->min_bounds;
563
564 return (bounds1->width == bounds2->width
565 && bounds1->ascent == bounds2->ascent
566 && bounds1->descent == bounds2->descent);
567}
568
569
570/* Modify face TO by copying from FROM all properties which have 567/* Modify face TO by copying from FROM all properties which have
571 nondefault settings. */ 568 nondefault settings. */
572static void 569static void
@@ -575,7 +572,6 @@ merge_faces (from, to)
575{ 572{
576 /* Only merge the font if it's the same size as the base font. */ 573 /* Only merge the font if it's the same size as the base font. */
577 if (from->font != (XFontStruct *) FACE_DEFAULT 574 if (from->font != (XFontStruct *) FACE_DEFAULT
578 && ! from->font->per_char
579 && same_size_fonts (from->font, to->font)) 575 && same_size_fonts (from->font, to->font))
580 to->font = from->font; 576 to->font = from->font;
581 if (from->foreground != FACE_DEFAULT) 577 if (from->foreground != FACE_DEFAULT)
@@ -689,7 +685,7 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr)
689 685
690 if (!NILP (prop)) 686 if (!NILP (prop))
691 { 687 {
692 facecode = face_name_id_number (frame, prop); 688 facecode = face_name_id_number (f, prop);
693 if (facecode >= 0 && facecode < FRAME_N_FACES (f) 689 if (facecode >= 0 && facecode < FRAME_N_FACES (f)
694 && FRAME_FACES (f) [facecode] != 0) 690 && FRAME_FACES (f) [facecode] != 0)
695 merge_faces (FRAME_FACES (f) [facecode], &face); 691 merge_faces (FRAME_FACES (f) [facecode], &face);
@@ -746,7 +742,7 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr)
746 Lisp_Object oend; 742 Lisp_Object oend;
747 int oendpos; 743 int oendpos;
748 744
749 facecode = face_name_id_number (frame, prop); 745 facecode = face_name_id_number (f, prop);
750 if (facecode >= 0 && facecode < FRAME_N_FACES (f) 746 if (facecode >= 0 && facecode < FRAME_N_FACES (f)
751 && FRAME_FACES (f) [facecode] != 0) 747 && FRAME_FACES (f) [facecode] != 0)
752 merge_faces (FRAME_FACES (f) [facecode], &face); 748 merge_faces (FRAME_FACES (f) [facecode], &face);
@@ -949,14 +945,14 @@ DEFUN ("internal-next-face-id", Finternal_next_face_id, Sinternal_next_face_id,
949 but it's as easy to use the "right" frame to look it up 945 but it's as easy to use the "right" frame to look it up
950 as to use any other one.) */ 946 as to use any other one.) */
951 947
952static Lisp_Object 948int
953face_name_id_number (frame, name) 949face_name_id_number (f, name)
954 Lisp_Object frame, name; 950 FRAME_PTR f;
951 Lisp_Object name;
955{ 952{
956 Lisp_Object tem; 953 Lisp_Object tem;
957 954
958 CHECK_FRAME (frame, 0); 955 tem = Fcdr (Fassq (name, f->face_alist));
959 tem = Fcdr (Fassq (name, XFRAME (frame)->face_alist));
960 if (NILP (tem)) 956 if (NILP (tem))
961 return 0; 957 return 0;
962 CHECK_VECTOR (tem, 0); 958 CHECK_VECTOR (tem, 0);