summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-19 12:57:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-19 12:57:59 (GMT)
commit8f56293a6faf629fa90092d966ad634247c76389 (patch)
tree5db13901c256ec3f40b154b0af58944cef02c52c /unix
parentbfa63c7740a0f5a2251012014fd7f2b67d3389b9 (diff)
parent2ff5fda0fe162179358a1fdd26adefa380b72286 (diff)
downloadtk-8f56293a6faf629fa90092d966ad634247c76389.zip
tk-8f56293a6faf629fa90092d966ad634247c76389.tar.gz
tk-8f56293a6faf629fa90092d966ad634247c76389.tar.bz2
merge core-8-6-branch
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixFont.c16
-rw-r--r--unix/tkUnixRFont.c23
2 files changed, 21 insertions, 18 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index e5aceb1..6f37c15 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;
@@ -2452,7 +2452,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;
@@ -2535,7 +2535,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;
@@ -2664,7 +2664,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.
@@ -2678,14 +2678,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) {
size_t i;
@@ -2772,7 +2772,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;
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 36c4540..9c1116d 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -170,18 +170,21 @@ GetTkFontAttributes(
{
const char *family = "Unknown";
const char *const *familyPtr = &family;
- int weight, slant, size, pxsize;
- double ptsize;
+ int weight, slant, pxsize;
+ double size, ptsize;
(void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr);
if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0,
&ptsize) == XftResultMatch) {
- size = (int) ptsize;
+ size = ptsize;
+ } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0,
+ &ptsize) == XftResultMatch) {
+ size = -ptsize;
} else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0,
&pxsize) == XftResultMatch) {
- size = -pxsize;
+ size = (double)-pxsize;
} else {
- size = 12;
+ size = 12.0;
}
if (XftPatternGetInteger(ftFont->pattern, XFT_WEIGHT, 0,
&weight) != XftResultMatch) {
@@ -194,7 +197,7 @@ GetTkFontAttributes(
#if DEBUG_FONTSEL
printf("family %s size %d weight %d slant %d\n",
- family, size, weight, slant);
+ family, (int)size, weight, slant);
#endif /* DEBUG_FONTSEL */
faPtr->family = Tk_GetUid(family);
@@ -441,10 +444,10 @@ TkpGetFontFromAttributes(
if (faPtr->family) {
XftPatternAddString(pattern, XFT_FAMILY, faPtr->family);
}
- if (faPtr->size > 0) {
- XftPatternAddDouble(pattern, XFT_SIZE, (double)faPtr->size);
- } else if (faPtr->size < 0) {
- XftPatternAddInteger(pattern, XFT_PIXEL_SIZE, -faPtr->size);
+ if (faPtr->size > 0.0) {
+ XftPatternAddDouble(pattern, XFT_SIZE, faPtr->size);
+ } else if (faPtr->size < 0.0) {
+ XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, -faPtr->size);
} else {
XftPatternAddDouble(pattern, XFT_SIZE, 12.0);
}