Skip to content

Commit

Permalink
Merge 8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Mar 16, 2024
2 parents 5c8108b + b0966ec commit c5b9cd5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 45 deletions.
66 changes: 32 additions & 34 deletions macosx/tkMacOSXFont.c
Expand Up @@ -171,10 +171,8 @@ static int CreateNamedSystemFont(Tcl_Interp *interp,
return _ds;
}

#ifndef __clang__
@synthesize UTF8String = _UTF8String;
@synthesize DString = _ds;
#endif
@end

#define GetNSFontTraitsFromTkFontAttributes(faPtr) \
Expand Down Expand Up @@ -907,7 +905,7 @@ void
TkpGetFontAttrsForChar(
TCL_UNUSED(Tk_Window), /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
int c, /* Character of interest */
int c, /* Character of interest */
TkFontAttributes* faPtr) /* Output: Font attributes */
{
MacFont *fontPtr = (MacFont *) tkfont;
Expand Down Expand Up @@ -1084,9 +1082,9 @@ TkpMeasureCharsInContext(
double maxWidth = maxLength + offset;
NSCharacterSet *cs;

/*
* Get a line breakpoint in the source string.
*/
/*
* Get a line breakpoint in the source string.
*/

index = start;
if (flags & TK_WHOLE_WORDS) {
Expand All @@ -1099,9 +1097,9 @@ TkpMeasureCharsInContext(
index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth);
}

/*
* Trim right whitespace/lineending characters.
*/
/*
* Trim right whitespace/lineending characters.
*/

cs = (index <= len && (flags & TK_WHOLE_WORDS)) ?
whitespaceCharacterSet : lineendingCharacterSet;
Expand All @@ -1110,29 +1108,29 @@ TkpMeasureCharsInContext(
index--;
}

/*
* If there is no line breakpoint in the source string between its
* start and the index position that fits in maxWidth, then
* CTTypesetterSuggestLineBreak() returns that very last index.
* However if the TK_WHOLE_WORDS flag is set, we want to break at a
* word boundary. In this situation, unless TK_AT_LEAST_ONE is set, we
* must report that zero chars actually fit (in other words the
* smallest word of the source string is still larger than maxWidth).
*/

if ((index >= start) && (index < len) &&
(flags & TK_WHOLE_WORDS) && !(flags & TK_AT_LEAST_ONE) &&
![cs characterIsMember:[string characterAtIndex:index]]) {
index = start;
}
/*
* If there is no line breakpoint in the source string between its
* start and the index position that fits in maxWidth, then
* CTTypesetterSuggestLineBreak() returns that very last index.
* However if the TK_WHOLE_WORDS flag is set, we want to break at a
* word boundary. In this situation, unless TK_AT_LEAST_ONE is set, we
* must report that zero chars actually fit (in other words the
* smallest word of the source string is still larger than maxWidth).
*/

if ((index >= start) && (index < len) &&
(flags & TK_WHOLE_WORDS) && !(flags & TK_AT_LEAST_ONE) &&
![cs characterIsMember:[string characterAtIndex:index]]) {
index = start;
}

if (index <= start && (flags & TK_AT_LEAST_ONE)) {
index = start + 1;
}

/*
* Now measure the string width in pixels.
*/
/*
* Now measure the string width in pixels.
*/

if (index > 0) {
range.length = index;
Expand All @@ -1149,7 +1147,7 @@ TkpMeasureCharsInContext(
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.
Expand Down Expand Up @@ -1330,9 +1328,9 @@ TkpDrawAngledCharsInContext(
CGAffineTransform t;
CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;

if (rangeStart < 0 || rangeLength <= 0 ||
rangeStart + rangeLength > numBytes ||
!TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) {
if (rangeStart < 0 || rangeLength <= 0
|| rangeStart + rangeLength > numBytes
|| !TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) {
return;
}
string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes];
Expand Down Expand Up @@ -1362,9 +1360,9 @@ TkpDrawAngledCharsInContext(
t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height);
if (angle != 0.0) {
t = CGAffineTransformTranslate(
CGAffineTransformRotate(
CGAffineTransformTranslate(t, textX, textY), angle*PI/180.0),
-textX, -textY);
CGAffineTransformRotate(
CGAffineTransformTranslate(t, textX, textY), angle*PI/180.0),
-textX, -textY);
}
CGContextConcatCTM(context, t);
start = Tcl_NumUtfChars(source, rangeStart);
Expand Down
13 changes: 2 additions & 11 deletions tests/send.test
Expand Up @@ -442,23 +442,14 @@ test send-10.8 {SendEventProc procedure, exceptional return} {secureserver tests
"c\n-n tktest\n-r $id 62\n-s break\n"
update
testsend prop [winfo id .f] Comm
} {
r
-s 62
-r
-c 3
}
} "\nr\n-s 62\n-r \n-c 3\n"
test send-10.9 {SendEventProc procedure, empty return} {secureserver testsend} {
testsend prop [winfo id .f] Comm {}
testsend prop comm Comm \
"c\n-n tktest\n-r $id 62\n-s concat\n"
update
testsend prop [winfo id .f] Comm
} {
r
-s 62
-r
}
} "\nr\n-s 62\n-r \n"
test send-10.10 {SendEventProc procedure, asynchronous calls} {secureserver testsend} {
testsend prop [winfo id .f] Comm {}
testsend prop comm Comm \
Expand Down

0 comments on commit c5b9cd5

Please sign in to comment.