From 3fa79ef5e10ff7ef2ac160a4c591f469ad307fcb Mon Sep 17 00:00:00 2001 From: jenglish Date: Sat, 31 May 2003 18:32:20 +0000 Subject: Experimental support for antialiased text under X11 [Patch#535541] --- ChangeLog | 8 ++++++++ unix/Makefile.in | 21 +++++++++++++++++---- unix/configure | 47 ++++++++++++++++++++++++++++++++++++++++++++++- unix/configure.in | 34 +++++++++++++++++++++++++++++++++- unix/tkUnixDefault.h | 39 ++++++++++++++++++++++++++++----------- 5 files changed, 132 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57e99f9..eba510a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-05-31 Joe English + * unix/tkUnixRFont.c: New file + * unix/tkUnixDefault.h: Use different default fonts if HAVE_XFT + * unix/Makefile.in: + * unix/configure.in: Add --enable-xft flag + * unix/configure: regen + Experimental support for antialiased text under X11 [Patch#535541] + 2003-05-30 Vince Darley * generic/tkMenu.c diff --git a/unix/Makefile.in b/unix/Makefile.in index ca362a7..7a1d360 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -5,7 +5,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.88 2003/04/04 19:29:38 mdejong Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.89 2003/05/31 18:32:20 jenglish Exp $ # Current Tk version; used in various names. @@ -129,7 +129,7 @@ X11_INCLUDES = @XINCLUDES@ # Linker switch(es) to use to link with the X11 library archive (the # configure script will try to set this value automatically, but you # can override it). -X11_LIB_SWITCHES = @XLIBSW@ +X11_LIB_SWITCHES = @XLIBSW@ $(XFT_LIBS) # To turn off the security checks that disallow incoming sends when @@ -247,6 +247,10 @@ LD_SEARCH_FLAGS = @LD_SEARCH_FLAGS@ # support for embedded libraries on Darwin / Mac OS X DYLIB_INSTALL_DIR = ${LIB_RUNTIME_DIR} +# support for Xft: +XFT_CFLAGS = @XFT_CFLAGS@ +XFT_LIBS = @XFT_LIBS@ + #---------------------------------------------------------------- # The information below is modified by the configure script when # Makefile is generated from Makefile.in. You shouldn't normally @@ -306,9 +310,13 @@ IMAGEOBJS = tkImage.o tkImgBmap.o tkImgGIF.o tkImgPPM.o tkImgPhoto.o TEXTOBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o \ tkTextMark.o tkTextTag.o tkTextWind.o +# either tkUnixFont.o (default) or tkUnixRFont.o (if --enable-xft) +# +FONTOBJS = @UNIX_FONT_OBJS@ + UNIXOBJS = tkUnix.o tkUnix3d.o tkUnixButton.o tkUnixColor.o tkUnixConfig.o \ tkUnixCursor.o tkUnixDraw.o tkUnixEmbed.o tkUnixEvent.o \ - tkUnixFocus.o tkUnixFont.o tkUnixInit.o tkUnixKey.o tkUnixMenu.o \ + tkUnixFocus.o tkUnixInit.o tkUnixKey.o tkUnixMenu.o \ tkUnixMenubu.o tkUnixScale.o tkUnixScrlbr.o tkUnixSelect.o \ tkUnixSend.o tkUnixWm.o tkUnixXId.o tkStubInit.o tkStubLib.o @@ -319,7 +327,7 @@ OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkClipboard.o tkCmds.o \ tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o tkGrid.o \ tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPlace.o \ tkSelect.o tkStyle.o tkUndo.o tkUtil.o tkVisual.o tkWindow.o \ - $(UNIXOBJS) $(WIDGOBJS) $(CANVOBJS) $(IMAGEOBJS) $(TEXTOBJS) + $(UNIXOBJS) $(FONTOBJS) $(WIDGOBJS) $(CANVOBJS) $(IMAGEOBJS) $(TEXTOBJS) TK_DECLS = \ $(GENERIC_DIR)/tk.decls \ @@ -372,6 +380,7 @@ SRCS = \ $(UNIX_DIR)/tkUnixDraw.c \ $(UNIX_DIR)/tkUnixEmbed.c $(UNIX_DIR)/tkUnixEvent.c \ $(UNIX_DIR)/tkUnixFocus.c \ + $(UNIX_DIR)/tkUnixRFont.c \ $(UNIX_DIR)/tkUnixFont.c $(UNIX_DIR)/tkUnixInit.c \ $(UNIX_DIR)/tkUnixKey.c \ $(UNIX_DIR)/tkUnixMenu.c $(UNIX_DIR)/tkUnixMenubu.c \ @@ -952,6 +961,10 @@ tkUnixFocus.o: $(UNIX_DIR)/tkUnixFocus.c tkUnixFont.o: $(UNIX_DIR)/tkUnixFont.c $(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkUnixFont.c +# NB: tkUnixRFont.o uses nondefault CFLAGS +tkUnixRFont.o: $(UNIX_DIR)/tkUnixRFont.c + $(CC) -c $(CC_SWITCHES) $(XFT_CFLAGS) $(UNIX_DIR)/tkUnixRFont.c + tkUnixInit.o: $(UNIX_DIR)/tkUnixInit.c $(GENERIC_DIR)/tkInitScript.h tkConfig.sh $(CC) -c $(CC_SWITCHES) -DTK_LIBRARY=\"${TK_LIBRARY}\" \ $(UNIX_DIR)/tkUnixInit.c diff --git a/unix/configure b/unix/configure index 05c2721..e667a63 100755 --- a/unix/configure +++ b/unix/configure @@ -308,7 +308,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MKLINKS_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_VERSION TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC RANLIB ac_ct_RANLIB AR LIBOBJS TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING EXTRA_CFLAGS LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_FLAGS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_DBGX TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_BUILD_STUB_LIB_SPEC TK_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_STUB_LIB_PATH TK_STUB_FLAGS TK_BUILD_EXP_FILE TK_EXP_FILE TCL_STUB_FLAGS LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_SRC_DIR XINCLUDES XLIBSW TK_SHARED_BUILD LOCALES LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MKLINKS_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_VERSION TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC RANLIB ac_ct_RANLIB AR LIBOBJS TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING EXTRA_CFLAGS LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_FLAGS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT XFT_CFLAGS XFT_LIBS UNIX_FONT_OBJS TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_DBGX TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_BUILD_STUB_LIB_SPEC TK_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_STUB_LIB_PATH TK_STUB_FLAGS TK_BUILD_EXP_FILE TK_EXP_FILE TCL_STUB_FLAGS LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_SRC_DIR XINCLUDES XLIBSW TK_SHARED_BUILD LOCALES LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -851,6 +851,7 @@ Optional Features: --enable-64bit-vis enable 64bit Sparc VIS support --disable-load disallow dynamic loading and "load" command --enable-symbols build with debugging symbols --disable-symbols + --enable-xft Use freetype/fontconfig/xft --disable-xft Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -6931,6 +6932,47 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi #-------------------------------------------------------------------- +# Check for freetype / fontconfig / Xft support. +#-------------------------------------------------------------------- + +# Check whether --enable-xft or --disable-xft was given. +if test "${enable_xft+set}" = set; then + enableval="$enable_xft" + enable_xft=$enableval +else + enable_xft="no" +fi; + +XFT_CFLAGS="" +XFT_LIBS="" +if test "$enable_xft" = "yes" ; then + echo "$as_me:$LINENO: checking for xft configuration" >&5 +echo $ECHO_N "checking for xft configuration... $ECHO_C" >&6 + XFT_CFLAGS=`pkg-config --cflags xft` || enable_xft="no" + XFT_LIBS=`pkg-config --libs xft` || enable_xft="no" + if test "$enable_xft" = "yes" ; then + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 + else + { echo "$as_me:$LINENO: WARNING: Can't find xft configuration" >&5 +echo "$as_me: WARNING: Can't find xft configuration" >&2;} + fi +fi +if test enable_xft="yes" ; then + UNIX_FONT_OBJS=tkUnixRFont.o + cat >>confdefs.h <<\_ACEOF +#define HAVE_XFT 1 +_ACEOF + +else + UNIX_FONT_OBJS=tkUnixFont.o +fi + + + + + +#-------------------------------------------------------------------- # Figure out whether "char" is unsigned. If so, set a # #define for __CHAR_UNSIGNED__. #-------------------------------------------------------------------- @@ -7941,6 +7983,9 @@ s,@INSTALL_LIB@,$INSTALL_LIB,;t t s,@INSTALL_STUB_LIB@,$INSTALL_STUB_LIB,;t t s,@CFLAGS_DEFAULT@,$CFLAGS_DEFAULT,;t t s,@LDFLAGS_DEFAULT@,$LDFLAGS_DEFAULT,;t t +s,@XFT_CFLAGS@,$XFT_CFLAGS,;t t +s,@XFT_LIBS@,$XFT_LIBS,;t t +s,@UNIX_FONT_OBJS@,$UNIX_FONT_OBJS,;t t s,@TK_VERSION@,$TK_VERSION,;t t s,@TK_MAJOR_VERSION@,$TK_MAJOR_VERSION,;t t s,@TK_MINOR_VERSION@,$TK_MINOR_VERSION,;t t diff --git a/unix/configure.in b/unix/configure.in index 01feb46..e1d74ea 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tk installation dnl to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.86 2003/04/04 19:29:48 mdejong Exp $ +# RCS: @(#) $Id: configure.in,v 1.87 2003/05/31 18:32:21 jenglish Exp $ AC_INIT(../generic/tk.h) AC_PREREQ(2.57) @@ -282,6 +282,38 @@ if test -d /usr/include/mit ; then fi #-------------------------------------------------------------------- +# Check for freetype / fontconfig / Xft support. +#-------------------------------------------------------------------- + +AC_ARG_ENABLE(xft, + [ --enable-xft Use freetype/fontconfig/xft [--disable-xft]], + [enable_xft=$enableval], + [enable_xft="no"]) + +XFT_CFLAGS="" +XFT_LIBS="" +if test "$enable_xft" = "yes" ; then + AC_MSG_CHECKING([for xft configuration]) + XFT_CFLAGS=`pkg-config --cflags xft` || enable_xft="no" + XFT_LIBS=`pkg-config --libs xft` || enable_xft="no" + if test "$enable_xft" = "yes" ; then + AC_MSG_RESULT([ok]) + else + AC_MSG_WARN([Can't find xft configuration]) + fi +fi +if test enable_xft="yes" ; then + UNIX_FONT_OBJS=tkUnixRFont.o + AC_DEFINE(HAVE_XFT) +else + UNIX_FONT_OBJS=tkUnixFont.o +fi + +AC_SUBST(XFT_CFLAGS) +AC_SUBST(XFT_LIBS) +AC_SUBST(UNIX_FONT_OBJS) + +#-------------------------------------------------------------------- # Figure out whether "char" is unsigned. If so, set a # #define for __CHAR_UNSIGNED__. #-------------------------------------------------------------------- diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index f8af12d..db8ba93 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixDefault.h,v 1.16 2002/06/21 23:09:54 hobbs Exp $ + * RCS: @(#) $Id: tkUnixDefault.h,v 1.17 2003/05/31 18:32:21 jenglish Exp $ */ #ifndef _TKUNIXDEFAULT @@ -37,6 +37,23 @@ #define DISABLED "#a3a3a3" /* + * The definitions below provide symbolic names for the default fonts. + * NORMAL_FONT - Normal font + * BOLD_FONT - Bold font + * FIXED_FONT - Fixed-width font + */ + +#if HAVE_XFT +# define NORMAL_FONT "sans-serif -12" +# define BOLD_FONT "sans-serif -12 bold" +# define FIXED_FONT "monospace -12" +#else +# define NORMAL_FONT "Helvetica -12" +# define BOLD_FONT "Helvetica -12 bold" +# define FIXED_FONT "Courier -12" +#endif + +/* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ @@ -58,7 +75,7 @@ #define DEF_BUTTON_DISABLED_FG_MONO "" #define DEF_BUTTON_FG BLACK #define DEF_CHKRAD_FG DEF_BUTTON_FG -#define DEF_BUTTON_FONT "Helvetica -12 bold" +#define DEF_BUTTON_FONT BOLD_FONT #define DEF_BUTTON_HEIGHT "0" #define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR #define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO @@ -141,7 +158,7 @@ #define DEF_ENTRY_DISABLED_BG_MONO WHITE #define DEF_ENTRY_DISABLED_FG DISABLED #define DEF_ENTRY_EXPORT_SELECTION "1" -#define DEF_ENTRY_FONT "Helvetica -12" +#define DEF_ENTRY_FONT NORMAL_FONT #define DEF_ENTRY_FG BLACK #define DEF_ENTRY_HIGHLIGHT_BG NORMAL_BG #define DEF_ENTRY_HIGHLIGHT BLACK @@ -200,7 +217,7 @@ #define DEF_LABELFRAME_CLASS "Labelframe" #define DEF_LABELFRAME_RELIEF "groove" #define DEF_LABELFRAME_FG BLACK -#define DEF_LABELFRAME_FONT "Helvetica -12 bold" +#define DEF_LABELFRAME_FONT BOLD_FONT #define DEF_LABELFRAME_TEXT "" #define DEF_LABELFRAME_LABELANCHOR "nw" @@ -215,7 +232,7 @@ #define DEF_LISTBOX_CURSOR "" #define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" -#define DEF_LISTBOX_FONT "Helvetica -12 bold" +#define DEF_LISTBOX_FONT BOLD_FONT #define DEF_LISTBOX_FG BLACK #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG @@ -279,7 +296,7 @@ #define DEF_MENU_CURSOR "arrow" #define DEF_MENU_DISABLED_FG_COLOR DISABLED #define DEF_MENU_DISABLED_FG_MONO "" -#define DEF_MENU_FONT "Helvetica -12 bold" +#define DEF_MENU_FONT BOLD_FONT #define DEF_MENU_FG BLACK #define DEF_MENU_POST_COMMAND "" #define DEF_MENU_RELIEF "raised" @@ -308,7 +325,7 @@ #define DEF_MENUBUTTON_DIRECTION "below" #define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED #define DEF_MENUBUTTON_DISABLED_FG_MONO "" -#define DEF_MENUBUTTON_FONT "Helvetica -12 bold" +#define DEF_MENUBUTTON_FONT BOLD_FONT #define DEF_MENUBUTTON_FG BLACK #define DEF_MENUBUTTON_HEIGHT "0" #define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR @@ -341,7 +358,7 @@ #define DEF_MESSAGE_BORDER_WIDTH "2" #define DEF_MESSAGE_CURSOR "" #define DEF_MESSAGE_FG BLACK -#define DEF_MESSAGE_FONT "Helvetica -12 bold" +#define DEF_MESSAGE_FONT BOLD_FONT #define DEF_MESSAGE_HIGHLIGHT_BG NORMAL_BG #define DEF_MESSAGE_HIGHLIGHT BLACK #define DEF_MESSAGE_HIGHLIGHT_WIDTH "0" @@ -401,7 +418,7 @@ #define DEF_SCALE_COMMAND "" #define DEF_SCALE_CURSOR "" #define DEF_SCALE_DIGITS "0" -#define DEF_SCALE_FONT "Helvetica -12 bold" +#define DEF_SCALE_FONT BOLD_FONT #define DEF_SCALE_FG_COLOR BLACK #define DEF_SCALE_FG_MONO BLACK #define DEF_SCALE_FROM "0" @@ -465,7 +482,7 @@ #define DEF_TEXT_CURSOR "xterm" #define DEF_TEXT_FG BLACK #define DEF_TEXT_EXPORT_SELECTION "1" -#define DEF_TEXT_FONT "Courier -12" +#define DEF_TEXT_FONT FIXED_FONT #define DEF_TEXT_HEIGHT "24" #define DEF_TEXT_HIGHLIGHT_BG NORMAL_BG #define DEF_TEXT_HIGHLIGHT BLACK @@ -504,7 +521,7 @@ * Defaults for canvas text: */ -#define DEF_CANVTEXT_FONT "Helvetica -12" +#define DEF_CANVTEXT_FONT NORMAL_FONT /* * Defaults for toplevels (most of the defaults for frames also apply -- cgit v0.12