aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1993-05-25 14:04:12 +0000
committerJim Blandy1993-05-25 14:04:12 +0000
commitb5cf7a0ea5d7664539487b6bb743695bbd1e715f (patch)
tree2bb6d83779296be34f24b2ee647d7c35f90a9f49
parentea96210c357f58dfd5cbfa9cfd1247bfbe82c306 (diff)
downloademacs-b5cf7a0ea5d7664539487b6bb743695bbd1e715f.tar.gz
emacs-b5cf7a0ea5d7664539487b6bb743695bbd1e715f.zip
Arrange for font names to get fully resolved - no wildcards.
* xfns.c (x_set_frame_parameters): Store the value in the frame parameter alist before we call the setter function, so the setter function can touch up the value if it chooses. (x_set_foreground_color, x_set_background_color): Call recompute_basic_faces, so their GC's will reflect the changes. (x_new_font): Add extern declaration - this returns a Lisp_Object now, the fully resolved font name. (x_set_font): Accept the fully resolved name from x_new_font, and put it in the frame's parameter alist. Call recompute_basic_faces. * xterm.c (x_new_font): Return the fully resolved font name, Qnil (if no match), or Qt (match, but unacceptable metrics). * xterm.c (x_new_font): Don't call init_frame_faces. * xterm.h: New section for declarations for xfaces.c. (init_frame_faces, free_frame_faces, intern_face, face_name_id_number, same_size_fonts, recompute_basic_faces, compute_char_face, compute_glyph_face): Declare these here. * xfaces.c (same_size_fonts): We can now remove this extern declaration. * xfns.c (face_name_id_number): Likewise. * xterm.c (intern_face): Likewise. * xterm.c (dumpglyphs): Remember that the default faces can have null fonts, too.
-rw-r--r--src/xterm.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 8f61d79d287..6959d904e4c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -423,8 +423,6 @@ dumpglyphs (f, left, top, gp, n, hl)
423 register Lisp_Object *tbase = GLYPH_TABLE_BASE; 423 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
424 Window window = FRAME_X_WINDOW (f); 424 Window window = FRAME_X_WINDOW (f);
425 425
426 extern struct face *intern_face (/* FRAME_PTR, struct face * */);
427
428 while (n > 0) 426 while (n > 0)
429 { 427 {
430 /* Get the face-code of the next GLYPH. */ 428 /* Get the face-code of the next GLYPH. */
@@ -492,31 +490,38 @@ dumpglyphs (f, left, top, gp, n, hl)
492#define FACE_DEFAULT (~0) 490#define FACE_DEFAULT (~0)
493 491
494 /* Now override that if the cursor's on this character. */ 492 /* Now override that if the cursor's on this character. */
495 if (hl == 2 && (defaulted 493 if (hl == 2)
496 || !(face->font && (int) face->font != FACE_DEFAULT)))
497 {
498 gc = f->display.x->cursor_gc;
499 }
500 /* Cursor on non-default face: must merge. */
501 else if (hl == 2)
502 { 494 {
503 XGCValues xgcv; 495 if (defaulted
504 unsigned long mask; 496 || !face->font
505 497 || (int) face->font == FACE_DEFAULT)
506 xgcv.background = f->display.x->cursor_pixel; 498 {
507 xgcv.foreground = f->display.x->cursor_foreground_pixel; 499 gc = f->display.x->cursor_gc;
508 xgcv.font = face->font->fid; 500 }
509 xgcv.graphics_exposures = 0; 501 /* Cursor on non-default face: must merge. */
510 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; 502 else
511 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), 503 {
512 mask, &xgcv); 504 XGCValues xgcv;
505 unsigned long mask;
506
507 xgcv.background = f->display.x->cursor_pixel;
508 xgcv.foreground = f->display.x->cursor_foreground_pixel;
509 xgcv.font = face->font->fid;
510 xgcv.graphics_exposures = 0;
511 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
512 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
513 mask, &xgcv);
513#if 0 514#if 0
514 if (face->stipple && face->stipple != FACE_DEFAULT) 515 if (face->stipple && face->stipple != FACE_DEFAULT)
515 XSetStipple (x_current_display, gc, face->stipple); 516 XSetStipple (x_current_display, gc, face->stipple);
516#endif 517#endif
517 gc_temporary = 1; 518 gc_temporary = 1;
519 }
518 } 520 }
519 521
522 if ((int) font == FACE_DEFAULT)
523 font = f->display.x->font;
524
520 XDrawImageString (x_current_display, window, gc, 525 XDrawImageString (x_current_display, window, gc,
521 left, top + FONT_BASE (font), buf, len); 526 left, top + FONT_BASE (font), buf, len);
522 527
@@ -3891,11 +3896,11 @@ static int x_font_table_size;
3891 0 <= n_fonts <= x_font_table_size. */ 3896 0 <= n_fonts <= x_font_table_size. */
3892static int n_fonts; 3897static int n_fonts;
3893 3898
3899Lisp_Object
3894x_new_font (f, fontname) 3900x_new_font (f, fontname)
3895 struct frame *f; 3901 struct frame *f;
3896 register char *fontname; 3902 register char *fontname;
3897{ 3903{
3898 XFontStruct *temp;
3899 int already_loaded; 3904 int already_loaded;
3900 int n_matching_fonts; 3905 int n_matching_fonts;
3901 XFontStruct *font_info; 3906 XFontStruct *font_info;
@@ -3911,7 +3916,7 @@ x_new_font (f, fontname)
3911 /* If the server couldn't find any fonts whose named matched fontname, 3916 /* If the server couldn't find any fonts whose named matched fontname,
3912 return an error code. */ 3917 return an error code. */
3913 if (n_matching_fonts == 0) 3918 if (n_matching_fonts == 0)
3914 return 1; 3919 return Qnil;
3915 3920
3916 /* See if we've already loaded a matching font. */ 3921 /* See if we've already loaded a matching font. */
3917 { 3922 {
@@ -3923,6 +3928,7 @@ x_new_font (f, fontname)
3923 if (x_font_table[i]->fid == font_info[j].fid) 3928 if (x_font_table[i]->fid == font_info[j].fid)
3924 { 3929 {
3925 already_loaded = i; 3930 already_loaded = i;
3931 fontname = font_names[j];
3926 goto found_font; 3932 goto found_font;
3927 } 3933 }
3928 } 3934 }
@@ -3949,13 +3955,13 @@ x_new_font (f, fontname)
3949#endif 3955#endif
3950 3956
3951 if (i >= n_matching_fonts) 3957 if (i >= n_matching_fonts)
3952 return 2; 3958 return Qt;
3953 else 3959 else
3954 fontname = font_names[i]; 3960 fontname = font_names[i];
3955 3961
3956 font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); 3962 font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname);
3957 if (! font) 3963 if (! font)
3958 return 1; 3964 return Qnil;
3959 3965
3960 /* Do we need to create the table? */ 3966 /* Do we need to create the table? */
3961 if (x_font_table_size == 0) 3967 if (x_font_table_size == 0)
@@ -3978,10 +3984,6 @@ x_new_font (f, fontname)
3978 f->display.x->font = x_font_table[n_fonts++] = font; 3984 f->display.x->font = x_font_table[n_fonts++] = font;
3979 } 3985 }
3980 3986
3981 /* Free the information from XListFontsWithInfo. The data
3982 we actually retain comes from XLoadQueryFont. */
3983 XFreeFontInfo (font_names, font_info, n_matching_fonts);
3984
3985 /* Now make the frame display the given font. */ 3987 /* Now make the frame display the given font. */
3986 if (FRAME_X_WINDOW (f) != 0) 3988 if (FRAME_X_WINDOW (f) != 0)
3987 { 3989 {
@@ -3991,12 +3993,20 @@ x_new_font (f, fontname)
3991 f->display.x->font->fid); 3993 f->display.x->font->fid);
3992 XSetFont (x_current_display, f->display.x->cursor_gc, 3994 XSetFont (x_current_display, f->display.x->cursor_gc,
3993 f->display.x->font->fid); 3995 f->display.x->font->fid);
3994 init_frame_faces (f);
3995 3996
3996 x_set_window_size (f, f->width, f->height); 3997 x_set_window_size (f, f->width, f->height);
3997 } 3998 }
3998 3999
3999 return 0; 4000 {
4001 Lisp_Object lispy_name = build_string (fontname);
4002
4003
4004 /* Free the information from XListFontsWithInfo. The data
4005 we actually retain comes from XLoadQueryFont. */
4006 XFreeFontInfo (font_names, font_info, n_matching_fonts);
4007
4008 return lispy_name;
4009 }
4000} 4010}
4001#else /* ! defined (HAVE_X11) */ 4011#else /* ! defined (HAVE_X11) */
4002x_new_font (f, newname) 4012x_new_font (f, newname)