Imported Tk 8.6.9
This commit is contained in:
@@ -14,19 +14,11 @@
|
||||
|
||||
#include "tkMacOSXPrivate.h"
|
||||
#include "tkMacOSXFont.h"
|
||||
#include "tkMacOSXConstants.h"
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
|
||||
#define defaultOrientation kCTFontDefaultOrientation
|
||||
#define verticalOrientation kCTFontVerticalOrientation
|
||||
#else
|
||||
#define defaultOrientation kCTFontOrientationDefault
|
||||
#define verticalOrientation kCTFontOrientationVertical
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100
|
||||
#define fixedPitch kCTFontUserFixedPitchFontType
|
||||
#else
|
||||
#define fixedPitch kCTFontUIFontUserFixedPitch
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef TK_MAC_DEBUG
|
||||
@@ -259,7 +251,7 @@ InitFont(
|
||||
}
|
||||
fontPtr->nsFont = nsFont;
|
||||
// some don't like antialiasing on fixed-width even if bigger than limit
|
||||
// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10;
|
||||
// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10;
|
||||
if (antialiasedTextEnabled >= 0/* || dontAA*/) {
|
||||
renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ?
|
||||
NSFontIntegerAdvancementsRenderingMode :
|
||||
@@ -819,15 +811,6 @@ TkpMeasureCharsInContext(
|
||||
*lengthPtr = 0;
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
/* Back-compatibility with ATSUI renderer, appears not to be needed */
|
||||
if (rangeStart == 0 && maxLength == 1 && (flags & TK_ISOLATE_END) &&
|
||||
!(flags & TK_AT_LEAST_ONE)) {
|
||||
length = 0;
|
||||
fit = 0;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
if (maxLength > 32767) {
|
||||
maxLength = 32767;
|
||||
}
|
||||
@@ -860,6 +843,10 @@ TkpMeasureCharsInContext(
|
||||
double maxWidth = maxLength + offset;
|
||||
NSCharacterSet *cs;
|
||||
|
||||
/*
|
||||
* Get a line breakpoint in the source string.
|
||||
*/
|
||||
|
||||
index = start;
|
||||
if (flags & TK_WHOLE_WORDS) {
|
||||
index = CTTypesetterSuggestLineBreak(typesetter, start, maxWidth);
|
||||
@@ -870,15 +857,43 @@ TkpMeasureCharsInContext(
|
||||
if (index <= start && !(flags & TK_WHOLE_WORDS)) {
|
||||
index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth);
|
||||
}
|
||||
|
||||
/*
|
||||
* Trim right whitespace/lineending characters.
|
||||
*/
|
||||
|
||||
cs = (index <= len && (flags & TK_WHOLE_WORDS)) ?
|
||||
whitespaceCharacterSet : lineendingCharacterSet;
|
||||
while (index > start &&
|
||||
[cs characterIsMember:[string characterAtIndex:(index - 1)]]) {
|
||||
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 (index <= start && (flags & TK_AT_LEAST_ONE)) {
|
||||
index = start + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now measure the string width in pixels.
|
||||
*/
|
||||
|
||||
if (index > 0) {
|
||||
range.length = index;
|
||||
line = CTTypesetterCreateLine(typesetter, range);
|
||||
@@ -921,7 +936,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user