aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-06-18 10:19:40 +0900
committerYAMAMOTO Mitsuharu2019-06-18 10:21:06 +0900
commit64767008f70af88d193d36eb6d2c27e4bc95ea8e (patch)
tree6bb91be06a2c8e09b2b4b07450dede39dd59a659 /src/font.c
parent56a90c4234afb41b6d41a356ab4a35e71923552c (diff)
downloademacs-64767008f70af88d193d36eb6d2c27e4bc95ea8e.tar.gz
emacs-64767008f70af88d193d36eb6d2c27e4bc95ea8e.zip
Support font driver supersession
* src/font.c (font_update_drivers): If argument NEW_DRIVERS is t, then don't use superseded drivers. (syms_of_font) <Qfont_driver_superseded_by>: New DEFSYM. * src/ftfont.c (syms_of_ftfont) [HAVE_HARFBUZZ]: * src/ftcrfont.c (syms_of_ftcrfont) [HAVE_HARFBUZZ]: * src/w32font.c (syms_of_w32font) [HAVE_HARFBUZZ]: * src/xftfont.c (syms_of_xftfont) [HAVE_HARFBUZZ]: Make Harfbuzz variants supersede non-Harfbuzz ones. * src/w32fns.c (Fx_create_frame, w32_create_tip_frame): Remove font backend determination code.
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/font.c b/src/font.c
index 5705758b99f..964028ccf00 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3518,7 +3518,10 @@ free_font_driver_list (struct frame *f)
3518 3518
3519/* Make the frame F use font backends listed in NEW_DRIVERS (list of 3519/* Make the frame F use font backends listed in NEW_DRIVERS (list of
3520 symbols, e.g. xft, x). If NEW_DRIVERS is t, make F use all 3520 symbols, e.g. xft, x). If NEW_DRIVERS is t, make F use all
3521 available font drivers. If NEW_DRIVERS is nil, finalize all drivers. 3521 available font drivers that are not superseded by another driver.
3522 (A font driver SYMBOL is superseded by the driver specified by
3523 SYMBOL's 'font-driver-superseded-by property if it is a non-nil
3524 symbol.) If NEW_DRIVERS is nil, finalize all drivers.
3522 3525
3523 A caller must free all realized faces if any in advance. The 3526 A caller must free all realized faces if any in advance. The
3524 return value is a list of font backends actually made used on 3527 return value is a list of font backends actually made used on
@@ -3527,16 +3530,33 @@ free_font_driver_list (struct frame *f)
3527Lisp_Object 3530Lisp_Object
3528font_update_drivers (struct frame *f, Lisp_Object new_drivers) 3531font_update_drivers (struct frame *f, Lisp_Object new_drivers)
3529{ 3532{
3530 Lisp_Object active_drivers = Qnil; 3533 Lisp_Object active_drivers = Qnil, default_drivers = Qnil;
3531 struct font_driver_list *list; 3534 struct font_driver_list *list;
3532 3535
3536 /* Collect all unsuperseded driver symbols into
3537 `default_drivers'. */
3538 Lisp_Object all_drivers = Qnil;
3539 for (list = f->font_driver_list; list; list = list->next)
3540 all_drivers = Fcons (list->driver->type, all_drivers);
3541 for (Lisp_Object rest = all_drivers; CONSP (rest); rest = XCDR (rest))
3542 {
3543 Lisp_Object superseded_by
3544 = Fget (XCAR (rest), Qfont_driver_superseded_by);
3545
3546 if (NILP (superseded_by)
3547 || NILP (Fmemq (superseded_by, all_drivers)))
3548 default_drivers = Fcons (XCAR (rest), default_drivers);
3549 }
3550
3551 if (EQ (new_drivers, Qt))
3552 new_drivers = default_drivers;
3553
3533 /* At first, turn off non-requested drivers, and turn on requested 3554 /* At first, turn off non-requested drivers, and turn on requested
3534 drivers. */ 3555 drivers. */
3535 for (list = f->font_driver_list; list; list = list->next) 3556 for (list = f->font_driver_list; list; list = list->next)
3536 { 3557 {
3537 struct font_driver const *driver = list->driver; 3558 struct font_driver const *driver = list->driver;
3538 if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers))) 3559 if ((! NILP (Fmemq (driver->type, new_drivers))) != list->on)
3539 != list->on)
3540 { 3560 {
3541 if (list->on) 3561 if (list->on)
3542 { 3562 {
@@ -3559,8 +3579,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
3559 3579
3560 if (NILP (new_drivers)) 3580 if (NILP (new_drivers))
3561 return Qnil; 3581 return Qnil;
3562 3582 else
3563 if (! EQ (new_drivers, Qt))
3564 { 3583 {
3565 /* Re-order the driver list according to new_drivers. */ 3584 /* Re-order the driver list according to new_drivers. */
3566 struct font_driver_list **list_table, **next; 3585 struct font_driver_list **list_table, **next;
@@ -3599,6 +3618,8 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers)
3599 { 3618 {
3600 struct font_driver const *driver = list->driver; 3619 struct font_driver const *driver = list->driver;
3601 eassert (! list->on); 3620 eassert (! list->on);
3621 if (NILP (Fmemq (driver->type, default_drivers)))
3622 continue;
3602 if (! driver->start_for_frame 3623 if (! driver->start_for_frame
3603 || driver->start_for_frame (f) == 0) 3624 || driver->start_for_frame (f) == 0)
3604 { 3625 {
@@ -5359,6 +5380,8 @@ syms_of_font (void)
5359 DEFSYM (QL2R, "L2R"); 5380 DEFSYM (QL2R, "L2R");
5360 DEFSYM (QR2L, "R2L"); 5381 DEFSYM (QR2L, "R2L");
5361 5382
5383 DEFSYM (Qfont_driver_superseded_by, "font-driver-superseded-by");
5384
5362 scratch_font_spec = Ffont_spec (0, NULL); 5385 scratch_font_spec = Ffont_spec (0, NULL);
5363 staticpro (&scratch_font_spec); 5386 staticpro (&scratch_font_spec);
5364 scratch_font_prefer = Ffont_spec (0, NULL); 5387 scratch_font_prefer = Ffont_spec (0, NULL);