diff options
author | fvogel <fvogelnew1@free.fr> | 2023-11-05 17:08:47 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-11-05 17:08:47 (GMT) |
commit | 94b740e60870af67ff2a0268c39d8bc05f25b699 (patch) | |
tree | 24a0dd687cf515c44f828b6b8a8c100644aa1047 /unix | |
parent | f95f48d2b52861ddf0d58ba9a78ba761461dcc28 (diff) | |
parent | 983a3bff1c058ce65ce0b714965a3efca1de5fd7 (diff) | |
download | tk-94b740e60870af67ff2a0268c39d8bc05f25b699.zip tk-94b740e60870af67ff2a0268c39d8bc05f25b699.tar.gz tk-94b740e60870af67ff2a0268c39d8bc05f25b699.tar.bz2 |
Fix [61550f38bf]: font actual returns wrong font size with Xft.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tkUnixRFont.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 6d826ea..72692fc 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -185,6 +185,7 @@ GetFont( static void GetTkFontAttributes( + Tk_Window tkwin, XftFont *ftFont, TkFontAttributes *faPtr) { @@ -194,12 +195,12 @@ GetTkFontAttributes( double size, ptsize; (void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr); - if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0, - &ptsize) == XftResultMatch) { - size = ptsize; - } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, + if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, &ptsize) == XftResultMatch) { size = -ptsize; + } else if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0, + &ptsize) == XftResultMatch) { + size = ptsize; } else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0, &pxsize) == XftResultMatch) { size = (double)-pxsize; @@ -221,7 +222,7 @@ GetTkFontAttributes( #endif /* DEBUG_FONTSEL */ faPtr->family = Tk_GetUid(family); - faPtr->size = size; + faPtr->size = TkFontGetPoints(tkwin, size); faPtr->weight = (weight > XFT_WEIGHT_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (slant > XFT_SLANT_ROMAN) ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = 0; @@ -357,7 +358,7 @@ InitFont( return NULL; } fontPtr->font.fid = XLoadFont(Tk_Display(tkwin), "fixed"); - GetTkFontAttributes(ftFont, &fontPtr->font.fa); + GetTkFontAttributes(tkwin, ftFont, &fontPtr->font.fa); GetTkFontMetrics(ftFont, &fontPtr->font.fm); Tk_DeleteErrorHandler(handler); if (errorFlag) { @@ -513,7 +514,7 @@ TkpGetFontFromAttributes( if (faPtr->size > 0.0) { XftPatternAddDouble(pattern, XFT_SIZE, faPtr->size); } else if (faPtr->size < 0.0) { - XftPatternAddDouble(pattern, XFT_SIZE, TkFontGetPoints(tkwin, faPtr->size)); + XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, -faPtr->size); } else { XftPatternAddDouble(pattern, XFT_SIZE, 12.0); } @@ -682,7 +683,7 @@ TkpGetSubFonts( void TkpGetFontAttrsForChar( - TCL_UNUSED(Tk_Window), /* Window on the font's display */ + Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ int c, /* Character of interest */ TkFontAttributes *faPtr) /* Output: Font attributes */ @@ -694,7 +695,7 @@ TkpGetFontAttrsForChar( XftFont *ftFont = GetFont(fontPtr, ucs4, 0.0); /* Actual font used to render the character */ - GetTkFontAttributes(ftFont, faPtr); + GetTkFontAttributes(tkwin, ftFont, faPtr); faPtr->underline = fontPtr->font.fa.underline; faPtr->overstrike = fontPtr->font.fa.overstrike; } |