summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2006-04-11 10:19:51 (GMT)
committerdas <das>2006-04-11 10:19:51 (GMT)
commit8b2a7970be6635f07774f94a31f95fb7e01c4034 (patch)
treebb7a13ca16a0674f11054c45a1bdeb183fbda82a
parent070434c182c27254deaee167b8933d75caa88f07 (diff)
downloadtk-8b2a7970be6635f07774f94a31f95fb7e01c4034.zip
tk-8b2a7970be6635f07774f94a31f95fb7e01c4034.tar.gz
tk-8b2a7970be6635f07774f94a31f95fb7e01c4034.tar.bz2
* macosx/tkMacOSXFont.c: remove #ifdef'd text measuring codepaths now
* macosx/tkMacOSXInit.c: known to be incorrect, cleanup obsolete text * macosx/README: antialiasing control code, document ATSUI text antialiasing changes.
-rw-r--r--macosx/README9
-rw-r--r--macosx/tkMacOSXFont.c184
-rw-r--r--macosx/tkMacOSXInit.c4
3 files changed, 32 insertions, 165 deletions
diff --git a/macosx/README b/macosx/README
index 008024c..15b9a12 100644
--- a/macosx/README
+++ b/macosx/README
@@ -1,7 +1,7 @@
Tcl/Tk Mac OS X README
----------------------
-RCS: @(#) $Id: README,v 1.16 2005/12/01 05:47:17 das Exp $
+RCS: @(#) $Id: README,v 1.17 2006/04/11 10:19:51 das Exp $
This is the README file for the Mac OS X/Darwin version of Tcl/Tk.
@@ -110,9 +110,10 @@ putting:
in your script before drawing, in which case only lines thinner that <limit>
pixels will not be antialiased.
-- Quickdraw text antialiasing is enabled by default when available (from 10.1.5
-onwards). Changing the global boolean variable '::tk::mac::antialiasedtext'
-allows to dis/enable antialiasing on the fly from Tcl (even for existing text).
+- ATSUI text antialiasing by default uses the standard OS antialising settings.
+Setting the global variable '::tk::mac::antialiasedtext' allows to control text
+antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores
+the default behaviour of respecting the OS settings.
- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The
normal scrollbar has a small dimension of 16, the small variant 12. Access to
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 1f01c3d..49ed451 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -35,7 +35,7 @@
* that such fonts can not be used for controls, because controls
* definitely require a family id (this assertion needs testing).
*
- * RCS: @(#) $Id: tkMacOSXFont.c,v 1.16 2006/04/11 05:42:02 das Exp $
+ * RCS: @(#) $Id: tkMacOSXFont.c,v 1.17 2006/04/11 10:19:51 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -47,18 +47,21 @@
#endif
*/
-typedef TkMacOSXFont MacFont;
-typedef TkMacOSXFontDrawingContext DrawingContext;
-
/*
- * Features that we still may want to disable again. See first occurrance of
- * these macros in #if statements for respective general discussions.
+ * Problem: The sum of two parts is not the same as the whole. In particular
+ * the width of two separately measured strings will usually be larger than
+ * the width of them pasted together. Tk has a design bug here, because it
+ * generally assumes that this kind of arithmetic works.
+ * To workaround this, #define TK_MAC_COALESCE_LINE to 1 below, we then avoid
+ * lines that tremble and shiver while the cursor passes through them by
+ * undercutting the system and behind the scenes pasting strings together that
+ * look like they are on the same line and adjacent and that are drawn with
+ * the same font. To do this we need some global data.
*/
+#define TK_MAC_COALESCE_LINE 0
-/* #define TK_MAC_COALESCE_LINE 1 */
-/* #define TK_MAC_USE_MEASURETEXTIMAGE 1 */
-#define TK_MAC_USE_GETGLYPHBOUNDS 1
-
+typedef TkMacOSXFont MacFont;
+typedef TkMacOSXFontDrawingContext DrawingContext;
/*
* Information about font families, initialized at startup time. Font
@@ -104,18 +107,6 @@ static StringBlock * stringMemory = NULL;
#if TK_MAC_COALESCE_LINE
-
-/*
- * Problem: The sum of two parts is not the same as the whole. In particular
- * the width of two separately measured strings will usually be larger than
- * the width of them pasted together. Tk has a design bug here, because it
- * generally assumes that this kind of arithmetic works. To avoid lines that
- * tremble and shiver while the cursor passes through them, we undercut the
- * system and behind the scenes paste strings together that look like they
- * are on the same line and adjacent and that are drawn with the same font.
- * To do this we need some global data.
- */
-
static Tcl_DString currentLine; /* The current line as seen so far. This
* contains a Tcl_UniChar DString. */
static int
@@ -127,10 +118,9 @@ static int
* line. */
static const MacFont * currentFontPtr = NULL;
/* The font of the current line. */
-
#endif /* TK_MAC_COALESCE_LINE */
-static int TkMacOSXAntialiasedTextEnabled = -1;
+static int antialiasedTextEnabled;
/*
* The names for our two "native" fonts.
@@ -223,15 +213,7 @@ static void SortFontFamilies(void);
static int CompareFontFamilies(const void * vp1, const void * vp2);
static const char * AddString(const char * in);
-/*
- * Trace interface for configuring anti-aliasing through a global variable.
- */
-
-static char * TkMacOSXAntialiasedTextVariableProc(
- ClientData clientData, Tcl_Interp * interp,
- const char * name1, const char * name2,
- int flag);
-
+
/*
*-------------------------------------------------------------------------
*
@@ -265,7 +247,6 @@ TkpFontPkgInit(
"(" __TIME__ ")\n");
#endif
}
-
/*
*---------------------------------------------------------------------------
@@ -1314,43 +1295,6 @@ MeasureStringWidth(
int start, int end) /* Start and end positions to measure in that
* string. */
{
-#if TK_MAC_USE_MEASURETEXTIMAGE
-
- /*
- * This implementation of measuring via ATSUMeasureTextImage() does not
- * quite conform with the specification given for [font measure]:
- *
- * The return value is the total width in pixels of text, not
- * including the extra pixels used by highly exagerrated characters
- * such as cursive "f".
- *
- * Instead ATSUMeasureTextImage() *does* include these "extra pixels."
- * Also ATSUMeasureTextImage() has the important property that it will
- * measure 'a' and 'a-umlaut' the same, even when expressed as decomposed
- * characters, while the other implementations use some strange
- * interpolation instead, possibly to generate some cute intermediate
- * cursor positions automatically.
- */
-
- OSStatus err;
- Rect size;
-
- size.left = size.right = 0;
- err = ATSUMeasureTextImage(
- fontPtr->atsuLayout,
- start, end-start,
- 0, 0,
- &size);
-#ifdef TK_MAC_DEBUG_FONTS
- if (err != noErr) {
- fprintf(stderr, "ATSUMeasureTextImage(): Error %d\n", (int) err);
- }
-#endif
-
- return size.right - size.left;
-
-#elif TK_MAC_USE_GETGLYPHBOUNDS
-
/*
* This implementation of measuring via ATSUGetGlyphBounds() does not
* quite conform with the specification given for [font measure]:
@@ -1359,11 +1303,8 @@ MeasureStringWidth(
* including the extra pixels used by highly exagerrated characters
* such as cursive "f".
*
- * Instead I would assume that ATSUGetGlyphBounds() *does* include these
- * "extra pixels." Still this implementation works slightly better with
- * the main page of demos/widgets than the one via
- * ATSUOffsetToPosition(), so I prefer this one if we use
- * TK_MAC_COALESCE_LINE locally.
+ * Instead the result of ATSUGetGlyphBounds() *does* include these
+ * "extra pixels".
*/
ATSTrapezoid bounds;
@@ -1392,54 +1333,6 @@ MeasureStringWidth(
#endif
return FixedToInt(bounds.upperRight.x - bounds.upperLeft.x);
-
-#else /* ! TK_MAC_USE_GETGLYPHBOUNDS */
-
- /*
- * This implementation via ATSUOffsetToPosition() is in principle the
- * right thing to do. But with TK_MAC_COALESCE_LINE and this, the
- * "tremble and shiver" (see discussion of TK_MAC_COALESCE_LINE at the
- * top) on the main page of demos/widgets is quite a bit more noticable
- * than with the ATSUGetGlyphBounds() implementation.
- */
-
- ATSUCaret mainCaretStart, secCaretStart, mainCaretEnd, secCaretEnd;
- Boolean isSplit;
- OSStatus err;
-
- if (end <= start) {
- return 0;
- }
-
- mainCaretStart.fX = mainCaretEnd.fX = 0;
-
- if (start != 0) {
- err = ATSUOffsetToPosition(
- fontPtr->atsuLayout,
- start, false,
- &mainCaretStart, &secCaretStart, &isSplit);
-#ifdef TK_MAC_DEBUG_FONTS
- if (err != noErr) {
- fprintf(stderr, "ATSUOffsetToPosition(): Error %d\n", (int) err);
- }
-#endif
- }
-
- if (end != 0) {
- err = ATSUOffsetToPosition(
- fontPtr->atsuLayout,
- end, false,
- &mainCaretEnd, &secCaretEnd, &isSplit);
-#ifdef TK_MAC_DEBUG_FONTS
- if (err != noErr) {
- fprintf(stderr, "ATSUOffsetToPosition(): Error %d\n", (int) err);
- }
-#endif
- }
-
- return FixedToInt(mainCaretEnd.fX - mainCaretStart.fX);
-
-#endif /* ? TK_MAC_USE_GETGLYPHBOUNDS */
}
#if TK_MAC_COALESCE_LINE
@@ -1744,9 +1637,9 @@ InitATSUStyle(
isItalic = (qdStyles&italic) != 0;
ATSStyleRenderingOptions options =
- TkMacOSXAntialiasedTextEnabled == -1 ? kATSStyleNoOptions :
- TkMacOSXAntialiasedTextEnabled == 0 ? kATSStyleNoAntiAliasing :
- kATSStyleApplyAntiAliasing;
+ antialiasedTextEnabled == -1 ? kATSStyleNoOptions :
+ antialiasedTextEnabled == 0 ? kATSStyleNoAntiAliasing :
+ kATSStyleApplyAntiAliasing;
static const ATSUAttributeTag styleTags[] = {
kATSUFontTag, kATSUSizeTag,
@@ -2676,23 +2569,15 @@ TkMacOSXInitControlFontStyle(
* TkMacOSXUseAntialiasedText --
*
* Enables or disables application-wide use of antialiased text (where
- * available). Sets up a linked Tcl global boolean variable with write
- * trace to allow disabling of antialiased text from tcl. The possible
- * values for this variable are:
+ * available). Sets up a linked Tcl global variable to allow
+ * disabling of antialiased text from tcl.
+ * The possible values for this variable are:
*
* -1 - Use system default as configurable in "System Preferences" ->
* "General".
* 0 - Unconditionally disable antialiasing.
* 1 - Unconditionally enable antialiasing.
*
- * This function is also called once from tkMacOSXInit.c:TkpInit() to
- * install the trace in an interpreter. The value given in TkpInit()
- * determines the actual default value.
- *
- * FIXME: Initialization should be a separate function, so that the
- * default given here (see variable declaration above) remains the real
- * default.
- *
* Results:
*
* TCL_OK.
@@ -2718,31 +2603,12 @@ TkMacOSXUseAntialiasedText(
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,
+ (char *) &antialiasedTextEnabled,
TCL_LINK_INT) != TCL_OK) {
Tcl_ResetResult(interp);
}
}
-
- TkMacOSXAntialiasedTextEnabled = enable;
-
+ antialiasedTextEnabled = enable;
return TCL_OK;
}
-
-static char *
-TkMacOSXAntialiasedTextVariableProc(
- ClientData clientData,
- Tcl_Interp * interp,
- const char * name1,
- const char * name2,
- int flags)
-{
- TkMacOSXUseAntialiasedText(interp, TkMacOSXAntialiasedTextEnabled);
- return NULL;
-}
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 12c3a6f..269dce0 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.19 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInit.c,v 1.20 2006/04/11 10:19:51 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -135,7 +135,7 @@ TkpInit(interp)
TkMacOSXInitAppleEvents(interp);
TkMacOSXInitCarbonEvents(interp);
TkMacOSXInitMenus(interp);
- TkMacOSXUseAntialiasedText(interp, TRUE);
+ TkMacOSXUseAntialiasedText(interp, -1);
TkMacOSXInitCGDrawing(interp, TRUE, 3);
encoding = CFStringGetSystemEncoding();