comparison src/xftfont.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 68dd71358159
children b40edfe3e412
comparison
equal deleted inserted replaced
106084:f03048d6d95a 106085:cd4cbab8bb21
181 extern Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object)); 181 extern Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object));
182 extern FcCharSet *ftfont_get_fc_charset P_ ((Lisp_Object)); 182 extern FcCharSet *ftfont_get_fc_charset P_ ((Lisp_Object));
183 extern Lisp_Object QCantialias; 183 extern Lisp_Object QCantialias;
184 184
185 static FcChar8 ascii_printable[95]; 185 static FcChar8 ascii_printable[95];
186
187 static void
188 xftfont_fix_match (pat, match)
189 FcPattern *pat, *match;
190 {
191 /* These values are not used for matching (except antialias), but for
192 rendering, so make sure they are carried over to the match.
193 We also put antialias here because most fonts are antialiased, so
194 the match will have antialias true. */
195
196 FcBool b = FcTrue;
197 int i;
198 double dpi;
199
200 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &b);
201 if (! b)
202 {
203 FcPatternDel (match, FC_ANTIALIAS);
204 FcPatternAddBool (match, FC_ANTIALIAS, FcFalse);
205 }
206 FcPatternGetBool (pat, FC_HINTING, 0, &b);
207 if (! b)
208 {
209 FcPatternDel (match, FC_HINTING);
210 FcPatternAddBool (match, FC_HINTING, FcFalse);
211 }
212 if (FcResultMatch == FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &i))
213 {
214 FcPatternDel (match, FC_HINT_STYLE);
215 FcPatternAddInteger (match, FC_HINT_STYLE, i);
216 }
217 if (FcResultMatch == FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &i))
218 {
219 FcPatternDel (match, FC_LCD_FILTER);
220 FcPatternAddInteger (match, FC_LCD_FILTER, i);
221 }
222 if (FcResultMatch == FcPatternGetInteger (pat, FC_RGBA, 0, &i))
223 {
224 FcPatternDel (match, FC_RGBA);
225 FcPatternAddInteger (match, FC_RGBA, i);
226 }
227 if (FcResultMatch == FcPatternGetDouble (pat, FC_DPI, 0, &dpi))
228 {
229 FcPatternDel (match, FC_DPI);
230 FcPatternAddDouble (match, FC_DPI, dpi);
231 }
232 }
186 233
187 static Lisp_Object 234 static Lisp_Object
188 xftfont_open (f, entity, pixel_size) 235 xftfont_open (f, entity, pixel_size)
189 FRAME_PTR f; 236 FRAME_PTR f;
190 Lisp_Object entity; 237 Lisp_Object entity;
247 { 294 {
248 Lisp_Object key, val; 295 Lisp_Object key, val;
249 296
250 key = XCAR (XCAR (tail)), val = XCDR (XCAR (tail)); 297 key = XCAR (XCAR (tail)), val = XCDR (XCAR (tail));
251 if (EQ (key, QCantialias)) 298 if (EQ (key, QCantialias))
252 FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue); 299 FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue);
253 else if (EQ (key, QChinting)) 300 else if (EQ (key, QChinting))
254 FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue); 301 FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue);
255 else if (EQ (key, QCautohint)) 302 else if (EQ (key, QCautohint))
256 FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue); 303 FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue);
257 else if (EQ (key, QChintstyle)) 304 else if (EQ (key, QChintstyle))
283 (Bug#1696) */ 330 (Bug#1696) */
284 { 331 {
285 int event_base, error_base; 332 int event_base, error_base;
286 XRenderQueryExtension (display, &event_base, &error_base); 333 XRenderQueryExtension (display, &event_base, &error_base);
287 } 334 }
335
336 /* Substitute in values from X resources and XftDefaultSet. */
337 XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
288 match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result); 338 match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result);
339 xftfont_fix_match (pat, match);
340
289 FcPatternDestroy (pat); 341 FcPatternDestroy (pat);
290 xftfont = XftFontOpenPattern (display, match); 342 xftfont = XftFontOpenPattern (display, match);
291 if (!xftfont) 343 if (!xftfont)
292 { 344 {
293 UNBLOCK_INPUT; 345 UNBLOCK_INPUT;