Import Tk 8.6.8

This commit is contained in:
Cheryl Sabella
2018-02-22 14:31:15 -05:00
parent b1c28856bb
commit 8e57feeeb9
193 changed files with 6172 additions and 4033 deletions

View File

@@ -406,7 +406,7 @@ ControlUtfProc(
{
const char *srcStart, *srcEnd;
char *dstStart, *dstEnd;
Tcl_UniChar ch;
int ch;
int result;
static char hexChars[] = "0123456789abcdef";
static char mapChars[] = {
@@ -427,9 +427,9 @@ ControlUtfProc(
result = TCL_CONVERT_NOSPACE;
break;
}
src += Tcl_UtfToUniChar(src, &ch);
src += TkUtfToUniChar(src, &ch);
dst[0] = '\\';
if ((ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
if (((size_t) ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
dst[1] = mapChars[ch];
dst += 2;
} else if (ch < 256) {
@@ -437,13 +437,21 @@ ControlUtfProc(
dst[2] = hexChars[(ch >> 4) & 0xf];
dst[3] = hexChars[ch & 0xf];
dst += 4;
} else {
} else if (ch < 0x10000) {
dst[1] = 'u';
dst[2] = hexChars[(ch >> 12) & 0xf];
dst[3] = hexChars[(ch >> 8) & 0xf];
dst[4] = hexChars[(ch >> 4) & 0xf];
dst[5] = hexChars[ch & 0xf];
dst += 6;
} else {
/* TODO we can do better here */
dst[1] = 'u';
dst[2] = 'f';
dst[3] = 'f';
dst[4] = 'f';
dst[5] = 'd';
dst += 6;
}
}
*srcReadPtr = src - srcStart;
@@ -946,7 +954,7 @@ void
TkpGetFontAttrsForChar(
Tk_Window tkwin, /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
Tcl_UniChar c, /* Character of interest */
int c, /* Character of interest */
TkFontAttributes *faPtr) /* Output: Font attributes */
{
FontAttributes atts;
@@ -1028,7 +1036,7 @@ Tk_MeasureChars(
curByte = 0;
} else if (maxLength < 0) {
const char *p, *end, *next;
Tcl_UniChar ch;
int ch;
SubFont *thisSubFontPtr;
FontFamily *familyPtr;
Tcl_DString runString;
@@ -1044,7 +1052,7 @@ Tk_MeasureChars(
curX = 0;
end = source + numBytes;
for (p = source; p < end; ) {
next = p + Tcl_UtfToUniChar(p, &ch);
next = p + TkUtfToUniChar(p, &ch);
thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
if (thisSubFontPtr != lastSubFontPtr) {
familyPtr = lastSubFontPtr->familyPtr;
@@ -1406,10 +1414,13 @@ TkpDrawCharsInContext(
* whole (not just the range) string when
* drawing. */
{
int widthUntilStart;
(void) numBytes; /*unused*/
Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
rangeLength, x, y);
rangeLength, x+widthUntilStart, y);
}
/*
@@ -1524,7 +1535,7 @@ CreateClosestFont(
continue;
}
IdentifySymbolEncodings(&got);
scalable = (got.fa.size == 0);
scalable = (got.fa.size == 0.0);
score = RankAttributes(&want, &got);
if (score < bestScore[scalable]) {
bestIdx[scalable] = nameIdx;
@@ -1631,7 +1642,7 @@ InitFont(
fmPtr->fixed = fixed;
fontPtr->display = display;
fontPtr->pixelSize = TkFontGetPixels(tkwin, fa.fa.size);
fontPtr->pixelSize = (int)(TkFontGetPixels(tkwin, fa.fa.size) + 0.5);
fontPtr->xa = fa.xa;
fontPtr->numSubFonts = 1;
@@ -2442,7 +2453,7 @@ CanUseFallback(
want.xa = fontPtr->xa;
want.fa.family = Tk_GetUid(faceName);
want.fa.size = -fontPtr->pixelSize;
want.fa.size = (double)-fontPtr->pixelSize;
hateFoundry = NULL;
hateCharset = NULL;
@@ -2525,7 +2536,7 @@ CanUseFallback(
* D. Rank each name and pick the best match.
*/
scalable = (got.fa.size == 0);
scalable = (got.fa.size == 0.0);
score = RankAttributes(&want, &got);
if (score < bestScore[scalable]) {
bestIdx[scalable] = nameIdx;
@@ -2654,7 +2665,7 @@ RankAttributes(
penalty += 1000;
}
if (gotPtr->fa.size == 0) {
if (gotPtr->fa.size == 0.0) {
/*
* A scalable font is almost always acceptable, but the corresponding
* bitmapped font would be better.
@@ -2668,14 +2679,14 @@ RankAttributes(
* It's worse to be too large than to be too small.
*/
diff = (-gotPtr->fa.size - -wantPtr->fa.size);
diff = (int) (150 * (-gotPtr->fa.size - -wantPtr->fa.size));
if (diff > 0) {
penalty += 600;
} else if (diff < 0) {
penalty += 150;
diff = -diff;
}
penalty += 150 * diff;
penalty += diff;
}
if (gotPtr->xa.charset != wantPtr->xa.charset) {
int i;
@@ -2762,7 +2773,7 @@ GetScreenFont(
}
*str = '\0';
sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
-wantPtr->fa.size, rest);
(int)(-wantPtr->fa.size+0.5), rest);
*str = '-';
fontStructPtr = XLoadQueryFont(display, buf);
bestScore[1] = INT_MAX;