/* Make the frame F use font backends listed in NEW_DRIVERS (list of
symbols, e.g. xft, x). If NEW_DRIVERS is t, make F use all
- available font drivers. If NEW_DRIVERS is nil, finalize all drivers.
+ available font drivers that are not superseded by another driver.
+ (A font driver SYMBOL is superseded by the driver specified by
+ SYMBOL's 'font-driver-superseded-by property if it is a non-nil
+ symbol.) If NEW_DRIVERS is nil, finalize all drivers.
A caller must free all realized faces if any in advance. The
return value is a list of font backends actually made used on
Lisp_Object
font_update_drivers (struct frame *f, Lisp_Object new_drivers)
{
- Lisp_Object active_drivers = Qnil;
+ Lisp_Object active_drivers = Qnil, default_drivers = Qnil;
struct font_driver_list *list;
+ /* Collect all unsuperseded driver symbols into
+ `default_drivers'. */
+ Lisp_Object all_drivers = Qnil;
+ for (list = f->font_driver_list; list; list = list->next)
+ all_drivers = Fcons (list->driver->type, all_drivers);
+ for (Lisp_Object rest = all_drivers; CONSP (rest); rest = XCDR (rest))
+ {
+ Lisp_Object superseded_by
+ = Fget (XCAR (rest), Qfont_driver_superseded_by);
+
+ if (NILP (superseded_by)
+ || NILP (Fmemq (superseded_by, all_drivers)))
+ default_drivers = Fcons (XCAR (rest), default_drivers);
+ }
+
+ if (EQ (new_drivers, Qt))
+ new_drivers = default_drivers;
+
/* At first, turn off non-requested drivers, and turn on requested
drivers. */
for (list = f->font_driver_list; list; list = list->next)
{
struct font_driver const *driver = list->driver;
- if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers)))
- != list->on)
+ if ((! NILP (Fmemq (driver->type, new_drivers))) != list->on)
{
if (list->on)
{
if (NILP (new_drivers))
return Qnil;
-
- if (! EQ (new_drivers, Qt))
+ else
{
/* Re-order the driver list according to new_drivers. */
struct font_driver_list **list_table, **next;
{
struct font_driver const *driver = list->driver;
eassert (! list->on);
+ if (NILP (Fmemq (driver->type, default_drivers)))
+ continue;
if (! driver->start_for_frame
|| driver->start_for_frame (f) == 0)
{
DEFSYM (QL2R, "L2R");
DEFSYM (QR2L, "R2L");
+ DEFSYM (Qfont_driver_superseded_by, "font-driver-superseded-by");
+
scratch_font_spec = Ffont_spec (0, NULL);
staticpro (&scratch_font_spec);
scratch_font_prefer = Ffont_spec (0, NULL);
specbind (Qx_resource_name, name);
}
- bool register_uniscribe = uniscribe_available;
#ifdef HAVE_HARFBUZZ
- /* Register Uniscribe only if HarfBuzz is not available or if
- explicitly requested. If Uniscribe is registered, register
- HarfBuzz only if explicitly requested. */
- bool register_harfbuzz = harfbuzz_available;
- if (register_harfbuzz)
- register_uniscribe = false;
- Lisp_Object dflt_backends
- = gui_display_get_arg (dpyinfo, parameters, Qfont_backend,
- "fontBackend", "FontBackend", RES_TYPE_STRING);
- if (!EQ (dflt_backends, Qunbound))
- {
- bool harfbuzz_requested = false, uniscribe_requested = false;
- if (CONSP (dflt_backends))
- {
- if (!NILP (Fmemq (Quniscribe, dflt_backends)))
- uniscribe_requested = true;
- if (!NILP (Fmemq (Qharfbuzz, dflt_backends)))
- harfbuzz_requested = true;
- }
- else if (STRINGP (dflt_backends))
- {
- if (strcmp (SSDATA (dflt_backends), "uniscribe") == 0)
- uniscribe_requested = true;
- else if (strcmp (SSDATA (dflt_backends), "harfbuzz") == 0)
- harfbuzz_requested = true;
- }
- if (uniscribe_requested)
- {
- register_uniscribe = uniscribe_available;
- if (!harfbuzz_requested)
- register_harfbuzz = false;
- }
- }
- if (register_harfbuzz)
- register_font_driver (&harfbuzz_font_driver, f);
+ register_font_driver (&harfbuzz_font_driver, f);
#endif
- if (register_uniscribe)
- register_font_driver (&uniscribe_font_driver, f);
+ register_font_driver (&uniscribe_font_driver, f);
register_font_driver (&w32font_driver, f);
gui_default_parameter (f, parameters, Qfont_backend, Qnil,
specbind (Qx_resource_name, name);
}
- bool register_uniscribe = uniscribe_available;
#ifdef HAVE_HARFBUZZ
- /* Register Uniscribe only if HarfBuzz is not available or if
- explicitly requested. If Uniscribe is registered, register
- HarfBuzz only if explicitly requested. */
- bool register_harfbuzz = harfbuzz_available;
- if (register_harfbuzz)
- register_uniscribe = false;
- Lisp_Object dflt_backends
- = gui_display_get_arg (dpyinfo, parms, Qfont_backend,
- "fontBackend", "FontBackend", RES_TYPE_STRING);
- if (!EQ (dflt_backends, Qunbound))
- {
- bool harfbuzz_requested = false, uniscribe_requested = false;
- if (CONSP (dflt_backends))
- {
- if (!NILP (Fmemq (Quniscribe, dflt_backends)))
- uniscribe_requested = true;
- if (!NILP (Fmemq (Qharfbuzz, dflt_backends)))
- harfbuzz_requested = true;
- }
- else if (STRINGP (dflt_backends))
- {
- if (strcmp (SSDATA (dflt_backends), "uniscribe") == 0)
- uniscribe_requested = true;
- else if (strcmp (SSDATA (dflt_backends), "harfbuzz") == 0)
- harfbuzz_requested = true;
- }
- if (uniscribe_requested)
- {
- register_uniscribe = uniscribe_available;
- if (!harfbuzz_requested)
- register_harfbuzz = false;
- }
- }
- if (register_harfbuzz)
- register_font_driver (&harfbuzz_font_driver, f);
+ register_font_driver (&harfbuzz_font_driver, f);
#endif
- if (register_uniscribe)
- register_font_driver (&uniscribe_font_driver, f);
+ register_font_driver (&uniscribe_font_driver, f);
register_font_driver (&w32font_driver, f);
gui_default_parameter (f, parms, Qfont_backend, Qnil,