From f64d07b592ecb66269eb4dfadf2c0ad0ae6b1572 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Oct 2023 21:00:32 +0000 Subject: Fix [61550f38bf]: font actual returns wrong font size with Xft. --- tests/font.test | 2 +- unix/tkUnixRFont.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/font.test b/tests/font.test index 69d3b15..f112d16 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2339,7 +2339,7 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body { } -result [font actual {times 0} -family] -test font-44.1 {TkFontGetPixels: size < 0} -constraints failsOnUbuntu -setup { +test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { tk scaling 0.5 diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index a295173..dee9abc 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -178,6 +178,7 @@ GetFont( static void GetTkFontAttributes( + Tk_Window tkwin, XftFont *ftFont, TkFontAttributes *faPtr) { @@ -187,12 +188,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; @@ -214,7 +215,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; @@ -350,7 +351,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) { @@ -675,7 +676,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 */ @@ -687,7 +688,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; } -- cgit v0.12 From 928492bc23de4707f0a37f1abffcdf86a7d3058c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Oct 2023 21:02:08 +0000 Subject: Backout useless [8271b8d2]. --- unix/tkUnixRFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index dee9abc..2c017e2 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -507,7 +507,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); } -- cgit v0.12 From 48bb53847a299aebf81f84707d3d53005080f695 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Oct 2023 21:04:33 +0000 Subject: Let this bugfix branch build and test at Github Actions. --- .github/workflows/linux-build.yml | 1 + .github/workflows/mac-build.yml | 1 + .github/workflows/win-build.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index d594c0c..d332349 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -4,6 +4,7 @@ on: branches: - "main" - "core-8-6-branch" + - "bug-61550f38bf" tags: - "core-**" permissions: diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 6c06a55..0698ea9 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -4,6 +4,7 @@ on: branches: - "main" - "core-8-6-branch" + - "bug-61550f38bf" tags: - "core-**" permissions: diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 75f3a99..a8ee77b 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -4,6 +4,7 @@ on: branches: - "main" - "core-8-6-branch" + - "bug-61550f38bf" tags: - "core-**" permissions: -- cgit v0.12