summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixFont.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-19 12:56:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-19 12:56:55 (GMT)
commit2ff5fda0fe162179358a1fdd26adefa380b72286 (patch)
tree329065a2785c3d6196bc67333bacb15c8379cce9 /unix/tkUnixFont.c
parent107e2400ee9876bbfd0b4712307f642290498194 (diff)
parent033e66e96af33c0ea2ee90e7a6eb6a63b9424f01 (diff)
downloadtk-2ff5fda0fe162179358a1fdd26adefa380b72286.zip
tk-2ff5fda0fe162179358a1fdd26adefa380b72286.tar.gz
tk-2ff5fda0fe162179358a1fdd26adefa380b72286.tar.bz2
Change internal field TkFontAttributes.size from type integer to double. This causes less roundings overall in various font calculations.
Hopefully this fixes bug [434d294df], still to be confirmed, and makes Tk work again on modern Linux Mint/Fedora systems.
Diffstat (limited to 'unix/tkUnixFont.c')
-rw-r--r--unix/tkUnixFont.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 0c663a3..b361e83 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -1535,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;
@@ -1642,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;
@@ -2453,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;
@@ -2536,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;
@@ -2665,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.
@@ -2679,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;
@@ -2773,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;