From 9a2dfb067ccecb1d94a07ebb490652f5fd142666 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Tue, 24 Feb 2009 17:52:03 -0800 Subject: [PATCH] Default to use standard bitmap fonts, with builtins as fallback The builtin-fonts configure option was removed, as it at best should have been a runtime option. Instead, now it always register all "font path element" backends, and adds built-ins fonts at the end of the default font path. This should be a more reasonable solution, to "correct" the most common Xorg FAQ (could not open default font 'fixed'), and also don't break by default applications that use only the standard/historical X Font rendering. (cherry picked from commit 49b93df8a3002db7196aa3fc1fd8dca1c12a55d6) Signed-off-by: Keith Packard (cherry picked from commit 69a2728891e92da6a674d7313f3bb47c629b38dc) --- configure.ac | 8 --- dix/dixfonts.c | 3 - hw/xfree86/common/xf86Config.c | 125 ++++++++++++--------------------- include/dixfont.h | 43 ++++++++++++ 4 files changed, 87 insertions(+), 92 deletions(-) diff --git a/configure.ac b/configure.ac index 869cc522b..9178cdc11 100644 --- a/configure.ac +++ b/configure.ac @@ -489,9 +489,6 @@ AC_ARG_ENABLE(install-libxf86config, [Install libxf86config (default: disabled)]), [INSTALL_LIBXF86CONFIG=$enableval], [INSTALL_LIBXF86CONFIG=no]) -AC_ARG_ENABLE(builtin-fonts, AS_HELP_STRING([--enable-builtin-fonts], [Use only built-in fonts (default: use external)]), - [BUILTIN_FONTS=$enableval], - [BUILTIN_FONTS=no]) AC_ARG_ENABLE(null-root-cursor, AS_HELP_STRING([--enable-null-root-cursor], [Use an empty root cursor (default: use core cursor)]), [NULL_ROOT_CURSOR=$enableval], [NULL_ROOT_CURSOR=no]) @@ -904,11 +901,6 @@ if test "x$DPMSExtension" = xyes; then AC_DEFINE(DPMSExtension, 1, [Support DPMS extension]) fi -if test "x$BUILTIN_FONTS" = xyes; then - AC_DEFINE(BUILTIN_FONTS, 1, [Use only built-in fonts]) - FONTPATH="built-ins" -fi - if test "x$XCALIBRATE" = xyes && test "$KDRIVE" = yes; then AC_DEFINE(XCALIBRATE, 1, [Build XCalibrate extension]) REQUIRED_MODULES="$REQUIRED_MODULES xcalibrateproto" diff --git a/dix/dixfonts.c b/dix/dixfonts.c index c9374c330..afb15de50 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1891,12 +1891,9 @@ InitFonts (void) { patternCache = MakeFontPatternCache(); -#ifdef BUILTIN_FONTS BuiltinRegisterFpeFunctions(); -#else FontFileRegisterFpeFunctions(); fs_register_fpe_functions(); -#endif } int diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 3c29497e3..59fbc03db 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -112,8 +112,6 @@ extern DeviceAssocRec mouse_assoc; #define PROJECTROOT "/usr/X11R6" #endif -static char *fontPath = NULL; - /* Forward declarations */ static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, MessageType from); @@ -586,89 +584,55 @@ xf86ConfigError(char *msg, ...) static void configFiles(XF86ConfFilesPtr fileconf) { - MessageType pathFrom = X_DEFAULT; - int countDirs; - char *temp_path; - char *log_buf; + MessageType pathFrom; + Bool must_copy; + int size, countDirs; + char *temp_path, *log_buf, *start, *end; - /* FontPath */ - /* Try XF86Config FontPath first */ - if (!xf86fpFlag) { - if (fileconf) { - if (fileconf->file_fontpath) { - char *f = xf86ValidateFontPath(fileconf->file_fontpath); - pathFrom = X_CONFIG; - if (*f) { - if (xf86Info.useDefaultFontPath) { - xf86Msg(X_DEFAULT, "Including the default font path %s.\n", defaultFontPath); - char *g = xnfalloc(strlen(defaultFontPath) + strlen(f) + 3); - strcpy(g, f); - strcat(g, ","); - defaultFontPath = strcat(g, defaultFontPath); - xfree(f); - } else { - defaultFontPath = f; - } - } else { - xf86Msg(X_WARNING, - "FontPath is completely invalid. Using compiled-in default.\n"); - fontPath = NULL; - pathFrom = X_DEFAULT; - } - } - } else { - xf86Msg(X_DEFAULT, - "No FontPath specified. Using compiled-in default.\n"); - pathFrom = X_DEFAULT; - } - } else { - /* Use fontpath specified with '-fp' */ - if (fontPath) - { - fontPath = NULL; + /* FontPath */ + must_copy = TRUE; + + temp_path = defaultFontPath ? defaultFontPath : ""; + if (xf86fpFlag) + pathFrom = X_CMDLINE; + else if (fileconf && fileconf->file_fontpath) { + pathFrom = X_CONFIG; + if (xf86Info.useDefaultFontPath) { + defaultFontPath = Xprintf("%s%s%s", + fileconf->file_fontpath, + *temp_path ? "," : "", temp_path); + must_copy = FALSE; + } + else + defaultFontPath = fileconf->file_fontpath; } - pathFrom = X_CMDLINE; - } - if (!fileconf) { - /* xf86ValidateFontPath will write into it's arg, but defaultFontPath - could be static, so we make a copy. */ - char *f = xnfalloc(strlen(defaultFontPath) + 1); - f[0] = '\0'; - strcpy (f, defaultFontPath); - defaultFontPath = xf86ValidateFontPath(f); - xfree(f); - } else { - if (fileconf) { - if (!fileconf->file_fontpath) { - /* xf86ValidateFontPath will write into it's arg, but defaultFontPath - could be static, so we make a copy. */ - char *f = xnfalloc(strlen(defaultFontPath) + 1); - f[0] = '\0'; - strcpy (f, defaultFontPath); - defaultFontPath = xf86ValidateFontPath(f); - xfree(f); + else + pathFrom = X_DEFAULT; + temp_path = defaultFontPath ? defaultFontPath : ""; + + /* ensure defaultFontPath contains "built-ins" */ + start = strstr(temp_path, "built-ins"); + end = start + strlen("built-ins"); + if (start == NULL || + !((start == temp_path || start[-1] == ',') && (!*end || *end == ','))) { + defaultFontPath = Xprintf("%s%sbuilt-ins", + temp_path, *temp_path ? "," : ""); + must_copy = FALSE; } - } - } + /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */ + temp_path = must_copy ? XNFstrdup(defaultFontPath) : defaultFontPath; + defaultFontPath = xf86ValidateFontPath(temp_path); + free(temp_path); - /* If defaultFontPath is still empty, exit here */ + /* make fontpath more readable in the logfiles */ + countDirs = 1; + temp_path = defaultFontPath; + while ((temp_path = index(temp_path, ',')) != NULL) { + countDirs++; + temp_path++; + } - if (! *defaultFontPath) - FatalError("No valid FontPath could be found."); - - /* make fontpath more readable in the logfiles */ - countDirs = 1; - temp_path = defaultFontPath; - while((temp_path = index(temp_path, ',')) != NULL) { - countDirs++; - temp_path++; - } - log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1); - if(!log_buf) /* fallback to old method */ - xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath); - else { - char *start, *end; - int size; + log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1); temp_path = log_buf; start = defaultFontPath; while((end = index(start, ',')) != NULL) { @@ -684,7 +648,6 @@ configFiles(XF86ConfFilesPtr fileconf) strcpy(temp_path, start); xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf); xfree(log_buf); - } /* RgbPath */ diff --git a/include/dixfont.h b/include/dixfont.h index 9cc2f41c1..d12f5259b 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -140,4 +140,47 @@ extern void InitGlyphCaching(void); extern void SetGlyphCachingMode(int /*newmode*/); +/* + * libXfont/src/builtins/builtin.h + */ +extern void BuiltinRegisterFpeFunctions(void); + +/* + * libXfont stubs. + */ +extern int client_auth_generation(ClientPtr client); + +extern void DeleteFontClientID(Font id); + +extern FontResolutionPtr GetClientResolutions(int *num); + +extern int GetDefaultPointSize(void); + +extern Font GetNewFontClientID(void); + +extern int init_fs_handlers(FontPathElementPtr fpe, + BlockHandlerProcPtr block_handler); + +extern int RegisterFPEFunctions(NameCheckFunc name_func, + InitFpeFunc init_func, + FreeFpeFunc free_func, + ResetFpeFunc reset_func, + OpenFontFunc open_func, + CloseFontFunc close_func, + ListFontsFunc list_func, + StartLfwiFunc start_lfwi_func, + NextLfwiFunc next_lfwi_func, + WakeupFpeFunc wakeup_func, + ClientDiedFunc client_died, + LoadGlyphsFunc load_glyphs, + StartLaFunc start_list_alias_func, + NextLaFunc next_list_alias_func, + SetPathFunc set_path_func); + +extern void remove_fs_handlers(FontPathElementPtr fpe, + BlockHandlerProcPtr blockHandler, + Bool all); + +extern int StoreFontClientFont(FontPtr pfont, Font id); + #endif /* DIXFONT_H */