From 81cfe79d65941e4793fdb27ddb7e242fcf4caf00 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 21 Feb 2012 05:38:49 +0000 Subject: _Xconst -> CONST --- generic/tkColor.c | 2 +- generic/tkInt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkColor.c b/generic/tkColor.c index 8893dfe..fcc6581 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -817,7 +817,7 @@ Status TkParseColor(display, map, spec, colorPtr) Display * display; /* The display */ Colormap map; /* Color map */ - _Xconst char* spec; /* String to be parsed */ + CONST char* spec; /* String to be parsed */ XColor * colorPtr; { if (*spec == '#') { diff --git a/generic/tkInt.h b/generic/tkInt.h index c274236..a6e09ee 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1217,7 +1217,7 @@ EXTERN int TkpAlwaysShowSelection _ANSI_ARGS_((Tk_Window tkwin)); #define TkParseColor XParseColor #else EXTERN Status TkParseColor _ANSI_ARGS_((Display * display, - Colormap map, _Xconst char* spec, + Colormap map, CONST char* spec, XColor * colorPtr)); #endif -- cgit v0.12 From 9c889def7246e422c1eb98aa2e5e9e7e66298d44 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 22 Feb 2012 22:58:19 +0000 Subject: Patch for font metrics and colorspace provided by Adrian Robert --- macosx/tkMacOSXColor.c | 8 +++++--- macosx/tkMacOSXFont.c | 27 ++++++++++++++++++++------- macosx/tkMacOSXWm.c | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index ebbaec2..82ed9f8 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -266,13 +266,15 @@ GetThemeColor( break; } - *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); + // this attempts to find something roughly fitting for any display +// *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); - /*static CGColorSpaceRef deviceRGBSpace = NULL; + // may be off for non-main display but in most cases better than prev + static CGColorSpaceRef deviceRGBSpace = NULL; if (!deviceRGBSpace) { deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID()); } - *c = CGColorCreate(deviceRGBSpace, rgba );*/ + *c = CGColorCreate(deviceRGBSpace, rgba ); } return err; } diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 305fe53..e4e4e03 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -229,7 +229,7 @@ InitFont( NSRect bounds; CGFloat kern = 0.0; NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode; - int ascent, descent, dontAA; + int ascent, descent/*, dontAA*/; static const UniChar ch[] = {'.', 'W', ' ', 0xc4, 0xc1, 0xc2, 0xc3, 0xc7}; /* ., W, Space, Auml, Aacute, Acirc, Atilde, Ccedilla */ #define nCh (sizeof(ch) / sizeof(UniChar)) @@ -244,9 +244,10 @@ InitFont( TkInitFontAttributes(faPtr); } fontPtr->nsFont = nsFont; - dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10; - if (antialiasedTextEnabled >= 0 || dontAA) { - renderingMode = (antialiasedTextEnabled == 0 || dontAA) ? + // some don't like antialiasing on fixed-width even if bigger than limit +// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10; + if (antialiasedTextEnabled >= 0/* || dontAA*/) { + renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ? NSFontIntegerAdvancementsRenderingMode : NSFontAntialiasedRenderingMode; } @@ -828,7 +829,7 @@ TkpMeasureCharsInContext( typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); start = Tcl_NumUtfChars(source, rangeStart); - len = Tcl_NumUtfChars(source, rangeStart + rangeLength); + len = Tcl_NumUtfChars(source + rangeStart, rangeLength); if (start > 0) { range.length = start; line = CTTypesetterCreateLine(typesetter, range); @@ -847,13 +848,13 @@ TkpMeasureCharsInContext( index = start; if (flags & TK_WHOLE_WORDS) { - index = CTTypesetterSuggestLineBreak(typesetter, 0, maxWidth); + index = CTTypesetterSuggestLineBreak(typesetter, start, maxWidth); if (index <= start && (flags & TK_AT_LEAST_ONE)) { flags &= ~TK_WHOLE_WORDS; } } if (index <= start && !(flags & TK_WHOLE_WORDS)) { - index = CTTypesetterSuggestClusterBreak(typesetter, 0, maxWidth); + index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } cs = (index < len || (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; @@ -878,6 +879,17 @@ TkpMeasureCharsInContext( width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } + + /* The call to CTTypesetterSuggestClusterBreak above will always + return at least one character regardless of whether it exceeded + it or not. Clean that up now. */ + while (width > maxWidth && !(flags & TK_PARTIAL_OK) && index > start) { + range.length = --index; + line = CTTypesetterCreateLine(typesetter, range); + width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); + CFRelease(line); + } + } CFRelease(typesetter); [attributedString release]; @@ -894,6 +906,7 @@ done: flags & TK_AT_LEAST_ONE ? "atLeastOne " : "", flags & TK_ISOLATE_END ? "isolateEnd " : "", length, fit); +//if (!(rangeLength==1 && rangeStart == 0)) fprintf(stderr, " measure len=%d (max=%d, w=%.0f) from %d (nb=%d): source=\"%s\": index=%d return %d\n",rangeLength,maxLength,width,rangeStart,numBytes, source+rangeStart, index, fit); #endif *lengthPtr = length; return fit; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index b916de3..f2cb572 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6306,7 +6306,7 @@ TkMacOSXMakeFullscreen( wmPtr->flags |= WM_FULLSCREEN; } } else { - wmPtr->flags &= ~WM_FULLSCREEN; + wmPtr->flags &= ~WM_FULLSCREEN; } TkMacOSXEnterExitFullscreen(winPtr, [window isKeyWindow]); if (wasFullscreen && !(wmPtr->flags & WM_FULLSCREEN)) { -- cgit v0.12