diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-15 14:56:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-15 14:56:05 (GMT) |
commit | bb089fa3ae014082fd1642a5c932f8c0c7422924 (patch) | |
tree | e917ce2bb4fc8961d0de782ce87d967679bb4de5 /unix | |
parent | c257b74035bb102d5860b77c9484c8e7e5ee833c (diff) | |
download | tk-bb089fa3ae014082fd1642a5c932f8c0c7422924.zip tk-bb089fa3ae014082fd1642a5c932f8c0c7422924.tar.gz tk-bb089fa3ae014082fd1642a5c932f8c0c7422924.tar.bz2 |
Another attempt to fix [434d294df8b053246ee86e7898d06bc3a6d1d771|434d294df8], this time (hopefully) suitable for 8.6. (less changes than the original attempt)
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tkUnixFont.c | 4 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 21 |
2 files changed, 14 insertions, 11 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 0c663a3..a447ec7 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -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; @@ -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; diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 41cd096..b818a70 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; } 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); } |