From ff6a1ec7eaa5b8dab045068c4321868cf1865e38 Mon Sep 17 00:00:00 2001 From: das Date: Wed, 16 Oct 2002 19:44:03 +0000 Subject: * macosx/Wish.pbproj/project.pbxproj: added TEXT document type to plist so that files can be dragged onto Wish Shell. * macosx/tkMacOSXInt.h: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXFont.c: added private proc TkMacOSXUseAntialiasedText() to enable/disable quickdraw text antialiasing where available, default is enabled. Added a linked boolean ::tk::mac::antialiasedtext with write trace to allow control of antialiasing from tcl. --- ChangeLog | 13 ++++++ macosx/Wish.pbproj/project.pbxproj | 17 +++++++ macosx/tkMacOSXFont.c | 90 +++++++++++++++++++++++++++++++++++++- macosx/tkMacOSXInit.c | 5 ++- macosx/tkMacOSXInt.h | 4 +- 5 files changed, 125 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6ebdfe..c1e36ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2002-10-17 Daniel Steffen + + * macosx/Wish.pbproj/project.pbxproj: added TEXT document + type to plist so that files can be dragged onto Wish Shell. + + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXFont.c: added private proc + TkMacOSXUseAntialiasedText() to enable/disable quickdraw + text antialiasing where available, default is enabled. + Added a linked boolean ::tk::mac::antialiasedtext with + write trace to allow control of antialiasing from tcl. + 2002-10-16 Vince Darley * macosx/tkMacOSXMenu.c: fix to accelerators shown in menus diff --git a/macosx/Wish.pbproj/project.pbxproj b/macosx/Wish.pbproj/project.pbxproj index dfe39a7..45ab708 100644 --- a/macosx/Wish.pbproj/project.pbxproj +++ b/macosx/Wish.pbproj/project.pbxproj @@ -2776,6 +2776,23 @@ MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright CFBundleDevelopmentRegion English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + NSStringPboardType + CFBundleTypeOSTypes + + TEXT + + CFBundleTypeRole + Viewer + + CFBundleExecutable Wish Shell CFBundleGetInfoString diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 40e637d..1a6556c 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -11,10 +11,12 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXFont.c,v 1.2 2002/08/31 06:12:29 das Exp $ + * RCS: @(#) $Id: tkMacOSXFont.c,v 1.3 2002/10/16 19:44:05 das Exp $ */ #include +#include "tclInt.h" + #include "tkMacOSXInt.h" #include "tkFont.h" @@ -2189,3 +2191,89 @@ TkMacOSXInitControlFontStyle(Tk_Font tkfont, ControlFontStylePtr fsPtr) fsPtr->style = fontPtr->style; fsPtr->just = teCenter; } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXUseAntialiasedText -- + * + * Enables or disables application-wide use of quickdraw + * antialiased text (where available). + * Sets up a linked tcl global boolean variable with write trace + * to allow disabling of antialiased text from tcl. + * + * Results: + * TCL_OK if facility was sucessfully enabled/disabled. + * TCL_ERROR if an error occurred or if facility is not available. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +#include + +/* define constants from 10.2 Quickdraw.h to enable compilation in 10.1 */ +#define kQDUseTrueTypeScalerGlyphs (1 << 0) +#define kQDUseCGTextRendering (1 << 1) +#define kQDUseCGTextMetrics (1 << 2) + +static int TkMacOSXAntialiasedTextEnabled = FALSE; + +static char * +TkMacOSXAntialiasedTextVariableProc(clientData, interp, name1, name2, flags) + ClientData clientData; + Tcl_Interp *interp; + CONST char *name1; + CONST char *name2; + int flags; +{ + TkMacOSXUseAntialiasedText(interp, TkMacOSXAntialiasedTextEnabled); + return (char *) NULL; +} + +int TkMacOSXUseAntialiasedText(interp, enable) + Tcl_Interp *interp; + int enable; +{ + static Boolean initialized = FALSE; + static UInt32 (*swaptextflags)(UInt32) = NULL; + + if(!initialized) { + NSSymbol nsSymbol=NULL; + if(NSIsSymbolNameDefinedWithHint("_QDSwapTextFlags", "QD")) { + nsSymbol = NSLookupAndBindSymbolWithHint("_QDSwapTextFlags", "QD"); + } else if(NSIsSymbolNameDefinedWithHint("_SwapQDTextFlags", "QD")) { + nsSymbol = NSLookupAndBindSymbolWithHint("_SwapQDTextFlags", "QD"); + } + if(nsSymbol) { + swaptextflags = NSAddressOfSymbol(nsSymbol); + } + initialized = TRUE; + + TkMacOSXAntialiasedTextEnabled = (swaptextflags ? enable : FALSE); + if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) { + Tcl_ResetResult(interp); + } + if (Tcl_TraceVar(interp, "::tk::mac::antialiasedtext", + TCL_GLOBAL_ONLY | TCL_TRACE_WRITES, + TkMacOSXAntialiasedTextVariableProc, NULL) != TCL_OK) { + Tcl_ResetResult(interp); + } + if (Tcl_LinkVar(interp, "::tk::mac::antialiasedtext", + (char *) &TkMacOSXAntialiasedTextEnabled, + TCL_LINK_BOOLEAN) != TCL_OK) { + Tcl_ResetResult(interp); + } + } + if(swaptextflags) { + swaptextflags(enable ? kQDUseCGTextRendering | kQDUseCGTextMetrics + : kQDUseTrueTypeScalerGlyphs); + TkMacOSXAntialiasedTextEnabled = enable; + return TCL_OK; + } else { + TkMacOSXAntialiasedTextEnabled = FALSE; + return TCL_ERROR; + } +} diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index ffcab99..2180769 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -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: tkMacOSXInit.c,v 1.2 2002/08/31 06:12:30 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3 2002/10/16 19:44:05 das Exp $ */ #include "tkInt.h" @@ -72,7 +72,7 @@ static Map scriptMap[] = { Tcl_Encoding TkMacOSXCarbonEncoding = NULL; - + /* *---------------------------------------------------------------------- * @@ -111,6 +111,7 @@ TkpInit(interp) Tk_MacOSXSetupTkNotifier(); TkMacOSXInitAppleEvents(interp); TkMacOSXInitMenus(interp); + TkMacOSXUseAntialiasedText(interp, TRUE); } if (carbonEncodingInitialized == false) { diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index b609d6e..4d7b840 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInt.h,v 1.2 2002/08/31 06:12:30 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3 2002/10/16 19:44:05 das Exp $ */ #ifndef _TKMACINT @@ -150,6 +150,8 @@ extern TkMacOSXWindowList *tkMacOSXWindowListPtr; extern Tcl_Encoding TkMacOSXCarbonEncoding; +extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); + #include "tkIntPlatDecls.h" #endif /* _TKMACINT */ -- cgit v0.12