Mercurial > emacs
comparison src/font.c @ 106085:cd4cbab8bb21
Handle system default font and changing font parameters.
* xterm.h (struct x_display_info): Add atoms and Window for xsettings.
* xterm.c (handle_one_xevent): Call xft_settings_event for
ClientMessage, PropertyNotify and DestroyNotify.
(x_term_init): If we have XFT, get DPI from Xft.dpi.
Call xsettings_initialize.
* xftfont.c (xftfont_fix_match): New function.
(xftfont_open): Call XftDefaultSubstitute before XftFontMatch.
Call xftfont_fix_match after XftFontMatch.
* xfont.c (xfont_driver): Initialize all members.
* xfns.c (x_default_font_parameter): Try font from Ffont_get_system_font.
Do not get font from x_default_parameter if we got one from
Ffont_get_system_font.
(Fx_select_font): Get the defaut font name from :name of FRAME_FONT (f).
* w32font.c (w32font_driver): Initialize all members.
* termhooks.h (enum event_kind): CONFIG_CHANGED_EVENT is new.
* lisp.h: Declare syms_of_xsettings.
* keyboard.c (kbd_buffer_get_event, make_lispy_event): Handle
CONFIG_CHANGED_EVENT.
* ftfont.c (ftfont_filter_properties): New function.
* frame.c (x_set_font): Remove unused variable lval.
* font.h (struct font_driver): filter_properties is new.
* font.c (font_put_extra): Don't return if val is nil, it means
boolean option is off.
(font_parse_fcname): Collect all extra properties in extra_props
and call filter_properties for all drivers with extra_props and
font as parameter.
(font_open_entity): Do not use cache, it does not pick up new fontconfig
settings like hinting.
(font_load_for_lface): If spec had a name in it, store it in entity.
* emacs.c (main): Call syms_of_xsettings
* config.in: HAVE_GCONF is new.
* Makefile.in (GCONF_CFLAGS, GCONF_LIBS): New variables for HAVE_GCONF.
xsettings.o is new.
* menu-bar.el: Put "Use system font" in Option-menu.
* loadup.el: If feature system-font-setting or font-render-setting is
there, load font-setting.
* Makefile.in (ELCFILES): font-settings.el is new.
* font-setting.el: New file.
* NEWS: Mention dynamic font changes (font-use-system-font).
* configure.in: New option: --with(out)-gconf.
Set HAVE_GCONF if we find gconf.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Tue, 17 Nov 2009 08:21:23 +0000 |
parents | 21bdda3ded62 |
children | f2cea199b0c4 |
comparison
equal
deleted
inserted
replaced
106084:f03048d6d95a | 106085:cd4cbab8bb21 |
---|---|
716 | 716 |
717 if (NILP (slot)) | 717 if (NILP (slot)) |
718 { | 718 { |
719 Lisp_Object prev = Qnil; | 719 Lisp_Object prev = Qnil; |
720 | 720 |
721 if (NILP (val)) | |
722 return val; | |
723 while (CONSP (extra) | 721 while (CONSP (extra) |
724 && NILP (Fstring_lessp (prop, XCAR (XCAR (extra))))) | 722 && NILP (Fstring_lessp (prop, XCAR (XCAR (extra))))) |
725 prev = extra, extra = XCDR (extra); | 723 prev = extra, extra = XCDR (extra); |
726 if (NILP (prev)) | 724 if (NILP (prev)) |
727 ASET (font, FONT_EXTRA_INDEX, Fcons (Fcons (prop, val), extra)); | 725 ASET (font, FONT_EXTRA_INDEX, Fcons (Fcons (prop, val), extra)); |
1429 } | 1427 } |
1430 } | 1428 } |
1431 | 1429 |
1432 if (family_end) | 1430 if (family_end) |
1433 { | 1431 { |
1432 Lisp_Object extra_props = Qnil; | |
1433 | |
1434 /* A fontconfig name with size and/or property data. */ | 1434 /* A fontconfig name with size and/or property data. */ |
1435 if (family_end > name) | 1435 if (family_end > name) |
1436 { | 1436 { |
1437 Lisp_Object family; | 1437 Lisp_Object family; |
1438 family = font_intern_prop (name, family_end - name, 1); | 1438 family = font_intern_prop (name, family_end - name, 1); |
1502 for (q = p; *q && *q != ':'; q++); | 1502 for (q = p; *q && *q != ':'; q++); |
1503 val = font_intern_prop (p, q - p, 0); | 1503 val = font_intern_prop (p, q - p, 0); |
1504 | 1504 |
1505 if (prop >= FONT_FOUNDRY_INDEX | 1505 if (prop >= FONT_FOUNDRY_INDEX |
1506 && prop < FONT_EXTRA_INDEX) | 1506 && prop < FONT_EXTRA_INDEX) |
1507 ASET (font, prop, font_prop_validate (prop, Qnil, val)); | 1507 ASET (font, prop, font_prop_validate (prop, Qnil, val)); |
1508 else | 1508 else |
1509 Ffont_put (font, key, val); | 1509 { |
1510 extra_props = nconc2 (extra_props, | |
1511 Fcons (Fcons (key, val), Qnil)); | |
1512 } | |
1510 } | 1513 } |
1511 p = q; | 1514 p = q; |
1512 } | 1515 } |
1513 } | 1516 } |
1517 | |
1518 if (! NILP (extra_props)) | |
1519 { | |
1520 struct font_driver_list *driver_list = font_driver_list; | |
1521 for ( ; driver_list; driver_list = driver_list->next) | |
1522 if (driver_list->driver->filter_properties) | |
1523 (*driver_list->driver->filter_properties) (font, extra_props); | |
1524 } | |
1525 | |
1514 } | 1526 } |
1515 else | 1527 else |
1516 { | 1528 { |
1517 /* Either a fontconfig-style name with no size and property | 1529 /* Either a fontconfig-style name with no size and property |
1518 data, or a GTK-style name. */ | 1530 data, or a GTK-style name. */ |
2973 if (XINT (size) != 0) | 2985 if (XINT (size) != 0) |
2974 scaled_pixel_size = pixel_size = XINT (size); | 2986 scaled_pixel_size = pixel_size = XINT (size); |
2975 else if (CONSP (Vface_font_rescale_alist)) | 2987 else if (CONSP (Vface_font_rescale_alist)) |
2976 scaled_pixel_size = pixel_size * font_rescale_ratio (entity); | 2988 scaled_pixel_size = pixel_size * font_rescale_ratio (entity); |
2977 | 2989 |
2990 #if 0 | |
2991 /* This doesn't work if you have changed hinting or any other parameter. | |
2992 We need to make a new object in every case to be sure. */ | |
2978 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | 2993 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); |
2979 objlist = XCDR (objlist)) | 2994 objlist = XCDR (objlist)) |
2980 if (! NILP (AREF (XCAR (objlist), FONT_TYPE_INDEX)) | 2995 if (! NILP (AREF (XCAR (objlist), FONT_TYPE_INDEX)) |
2981 && XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) | 2996 && XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) |
2982 return XCAR (objlist); | 2997 return XCAR (objlist); |
2998 #endif | |
2983 | 2999 |
2984 val = AREF (entity, FONT_TYPE_INDEX); | 3000 val = AREF (entity, FONT_TYPE_INDEX); |
2985 for (driver_list = f->font_driver_list; | 3001 for (driver_list = f->font_driver_list; |
2986 driver_list && ! EQ (driver_list->driver->type, val); | 3002 driver_list && ! EQ (driver_list->driver->type, val); |
2987 driver_list = driver_list->next); | 3003 driver_list = driver_list->next); |
3153 { | 3169 { |
3154 Lisp_Object font = attrs[LFACE_FONT_INDEX]; | 3170 Lisp_Object font = attrs[LFACE_FONT_INDEX]; |
3155 | 3171 |
3156 if (! FONTP (font)) | 3172 if (! FONTP (font)) |
3157 return; | 3173 return; |
3174 #if 0 | |
3158 if (! NILP (Ffont_get (font, QCname))) | 3175 if (! NILP (Ffont_get (font, QCname))) |
3159 { | 3176 { |
3160 font = Fcopy_font_spec (font); | 3177 font = Fcopy_font_spec (font); |
3161 font_put_extra (font, QCname, Qnil); | 3178 font_put_extra (font, QCname, Qnil); |
3162 } | 3179 } |
3163 | 3180 |
3181 #endif | |
3164 if (NILP (AREF (font, prop)) | 3182 if (NILP (AREF (font, prop)) |
3165 && prop != FONT_FAMILY_INDEX | 3183 && prop != FONT_FAMILY_INDEX |
3166 && prop != FONT_FOUNDRY_INDEX | 3184 && prop != FONT_FOUNDRY_INDEX |
3167 && prop != FONT_WIDTH_INDEX | 3185 && prop != FONT_WIDTH_INDEX |
3168 && prop != FONT_SIZE_INDEX) | 3186 && prop != FONT_SIZE_INDEX) |
3436 if (! NILP (entities)) | 3454 if (! NILP (entities)) |
3437 { | 3455 { |
3438 val = font_select_entity (frame, entities, | 3456 val = font_select_entity (frame, entities, |
3439 attrs, pixel_size, c); | 3457 attrs, pixel_size, c); |
3440 if (! NILP (val)) | 3458 if (! NILP (val)) |
3441 return val; | 3459 return val; |
3442 } | 3460 } |
3443 } | 3461 } |
3444 } | 3462 } |
3445 } | 3463 } |
3446 } | 3464 } |
3498 Lisp_Object | 3516 Lisp_Object |
3499 font_load_for_lface (f, attrs, spec) | 3517 font_load_for_lface (f, attrs, spec) |
3500 FRAME_PTR f; | 3518 FRAME_PTR f; |
3501 Lisp_Object *attrs, spec; | 3519 Lisp_Object *attrs, spec; |
3502 { | 3520 { |
3503 Lisp_Object entity; | 3521 Lisp_Object entity, name; |
3504 | 3522 |
3505 entity = font_find_for_lface (f, attrs, spec, -1); | 3523 entity = font_find_for_lface (f, attrs, spec, -1); |
3506 if (NILP (entity)) | 3524 if (NILP (entity)) |
3507 { | 3525 { |
3508 /* No font is listed for SPEC, but each font-backend may have | 3526 /* No font is listed for SPEC, but each font-backend may have |
3510 it. */ | 3528 it. */ |
3511 entity = font_matching_entity (f, attrs, spec); | 3529 entity = font_matching_entity (f, attrs, spec); |
3512 if (NILP (entity)) | 3530 if (NILP (entity)) |
3513 return Qnil; | 3531 return Qnil; |
3514 } | 3532 } |
3515 return font_open_for_lface (f, entity, attrs, spec); | 3533 /* Don't loose the original name that was put in initially. We need |
3534 it to re-apply the font when font parameters (like hinting or dpi) have | |
3535 changed. */ | |
3536 entity = font_open_for_lface (f, entity, attrs, spec); | |
3537 name = Ffont_get (spec, QCname); | |
3538 if (STRINGP (name)) font_put_extra (entity, QCname, name); | |
3539 return entity; | |
3516 } | 3540 } |
3517 | 3541 |
3518 | 3542 |
3519 /* Make FACE on frame F ready to use the font opened for FACE. */ | 3543 /* Make FACE on frame F ready to use the font opened for FACE. */ |
3520 | 3544 |