Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Patch for font metrics and colorspace provided by Adrian Robert |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tk-cocoa-8-5-backport |
Files: | files | file ages | folders |
SHA1: |
e5be09bc6724ccccd39c190c822e623b |
User & Date: | kevin_walzer 2012-02-22 23:00:21 |
Context
2012-03-10
| ||
14:47 | Backport fix for disabled images in ttk buttons for Tk-Cocoa check-in: 457a6a8b user: kevin_walzer tags: tk-cocoa-8-5-backport | |
2012-02-22
| ||
23:00 | Patch for font metrics and colorspace provided by Adrian Robert check-in: e5be09bc user: kevin_walzer tags: tk-cocoa-8-5-backport | |
2012-02-10
| ||
00:00 | Fix for minor typos provided by Andreas Kupries check-in: 48e380fe user: kevin_walzer tags: tk-cocoa-8-5-backport | |
Changes
Changes to macosx/tkMacOSXColor.c.
︙ | ︙ | |||
264 265 266 267 268 269 270 | break; } case TRANSPARENT_PIXEL: rgba[3] = 0.0; break; } | > | > | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | break; } case TRANSPARENT_PIXEL: rgba[3] = 0.0; break; } // this attempts to find something roughly fitting for any display // *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); // 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 ); } return err; } /* *---------------------------------------------------------------------- * |
︙ | ︙ |
Changes to macosx/tkMacOSXFont.c.
︙ | ︙ | |||
227 228 229 230 231 232 233 | { TkFontAttributes *faPtr; TkFontMetrics *fmPtr; NSDictionary *nsAttributes; NSRect bounds; CGFloat kern = 0.0; NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode; | | > | | | | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | { TkFontAttributes *faPtr; TkFontMetrics *fmPtr; NSDictionary *nsAttributes; NSRect bounds; CGFloat kern = 0.0; NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode; 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)) CGGlyph glyphs[nCh]; CGRect boundingRects[nCh]; fontPtr->font.fid = (Font) fontPtr; faPtr = &fontPtr->font.fa; if (reqFaPtr) { *faPtr = *reqFaPtr; } else { TkInitFontAttributes(faPtr); } fontPtr->nsFont = nsFont; // 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; } nsFont = [nsFont screenFontWithRenderingMode:renderingMode]; GetTkFontAttributesForNSFont(nsFont, faPtr); fmPtr = &fontPtr->font.fm; fmPtr->ascent = floor([nsFont ascender] + [nsFont leading] + 0.5); |
︙ | ︙ | |||
826 827 828 829 830 831 832 | goto done; } attributedString = [[NSAttributedString alloc] initWithString:string attributes:fontPtr->nsAttributes]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); start = Tcl_NumUtfChars(source, rangeStart); | | | | | 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | goto done; } attributedString = [[NSAttributedString alloc] initWithString:string attributes:fontPtr->nsAttributes]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); start = Tcl_NumUtfChars(source, rangeStart); len = Tcl_NumUtfChars(source + rangeStart, rangeLength); if (start > 0) { range.length = start; line = CTTypesetterCreateLine(typesetter, range); offset = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } if (maxLength < 0) { index = len; range.length = len; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } else { double maxWidth = maxLength + offset; NSCharacterSet *cs; index = start; if (flags & TK_WHOLE_WORDS) { 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, start, maxWidth); } cs = (index < len || (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { index--; } |
︙ | ︙ | |||
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | } if (width < maxWidth && (flags & TK_PARTIAL_OK) && index < len) { range.length = ++index; line = CTTypesetterCreateLine(typesetter, range); width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } } CFRelease(typesetter); [attributedString release]; [string release]; length = ceil(width - offset); fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart; done: #ifdef TK_MAC_DEBUG_FONTS TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d " "flags='%s%s%s%s' -> width=%d bytesFit=%d\n", source, rangeLength, source+rangeStart, maxLength, flags & TK_PARTIAL_OK ? "partialOk " : "", flags & TK_WHOLE_WORDS ? "wholeWords " : "", flags & TK_AT_LEAST_ONE ? "atLeastOne " : "", flags & TK_ISOLATE_END ? "isolateEnd " : "", length, fit); #endif *lengthPtr = length; return fit; } /* *--------------------------------------------------------------------------- | > > > > > > > > > > > > | 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | } if (width < maxWidth && (flags & TK_PARTIAL_OK) && index < len) { range.length = ++index; line = CTTypesetterCreateLine(typesetter, range); 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]; [string release]; length = ceil(width - offset); fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart; done: #ifdef TK_MAC_DEBUG_FONTS TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d " "flags='%s%s%s%s' -> width=%d bytesFit=%d\n", source, rangeLength, source+rangeStart, maxLength, flags & TK_PARTIAL_OK ? "partialOk " : "", flags & TK_WHOLE_WORDS ? "wholeWords " : "", 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; } /* *--------------------------------------------------------------------------- |
︙ | ︙ |