From 36fce82447349391ad8b5d8f6b3d16ad1847bfee Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Nov 2023 20:46:00 +0000 Subject: [PATCH 01/11] Redo [c306fdd1]. --- 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 69d3b15d6..f112d1622 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 a29517335..dee9abc57 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; } From 4275dd5c1890953223d6e85f5b1c0f77d38690c4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Nov 2023 20:46:41 +0000 Subject: [PATCH 02/11] Redo [4ac7d975]. --- unix/tkUnixRFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index dee9abc57..2c017e2f5 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); } From 41f60ae2ae84d13e88e2355fdc039c2518aeb0d7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Nov 2023 20:49:40 +0000 Subject: [PATCH 03/11] Make font-44.1 more independent of the actual font size available by still checking the same thing (doubling of the font size). --- tests/font.test | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/font.test b/tests/font.test index f112d1622..80a0420f6 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2342,11 +2342,12 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body { test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { + set oldsize [expr {[font actual {times -12} -size] * $oldscale}] tk scaling 0.5 - font actual {times -12} -size + expr {[font actual {times -12} -size] == $oldsize / 0.5} } -cleanup { tk scaling $oldscale -} -result 24 +} -result 1 test font-44.2 {TkFontGetPoints: size >= 0} -constraints {noExceed haveTimes12Font} -setup { set oldscale [tk scaling] } -body { From 8ce8c470662389474feee053d57e13b0cc8efafa Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Nov 2023 20:52:47 +0000 Subject: [PATCH 04/11] Redo [f61a66d8]. --- .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 d594c0ca8..d332349a0 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 6c06a5533..0698ea9d0 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 75f3a9905..a8ee77bef 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: From e7086b7d4c5351378c88424e43a74aa1b3db2916 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Nov 2023 20:48:50 +0000 Subject: [PATCH 05/11] Pixel sizes in font-44.1 must match as integers, therefore round computations. --- tests/font.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/font.test b/tests/font.test index 80a0420f6..588433458 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2342,9 +2342,9 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body { test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { - set oldsize [expr {[font actual {times -12} -size] * $oldscale}] + set oldsize [expr {round([font actual {times -12} -size] * $oldscale)}] tk scaling 0.5 - expr {[font actual {times -12} -size] == $oldsize / 0.5} + expr {round([font actual {times -12} -size] - $oldsize / 0.5) == 0} } -cleanup { tk scaling $oldscale } -result 1 From 803981c7b99b5a3d3bb5f988a66b09f149efed18 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Nov 2023 20:39:31 +0000 Subject: [PATCH 06/11] Add temporary debug output to font-44.1 --- tests/font.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/font.test b/tests/font.test index 588433458..45d8af6f1 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2339,15 +2339,21 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body { } -result [font actual {times 0} -family] +puts ">>>>>>>>>> font-44.1 starts" test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { +puts "oldscale: $oldscale" set oldsize [expr {round([font actual {times -12} -size] * $oldscale)}] +puts "font actual {times -12}: [font actual {times -12}]" +puts "oldsize: $oldsize" tk scaling 0.5 +puts "font actual {times -12}: [font actual {times -12}]" expr {round([font actual {times -12} -size] - $oldsize / 0.5) == 0} } -cleanup { tk scaling $oldscale } -result 1 +puts " font-44.1 ends <<<<<<<<<<" test font-44.2 {TkFontGetPoints: size >= 0} -constraints {noExceed haveTimes12Font} -setup { set oldscale [tk scaling] } -body { From a417a924de5d80940b31da2856b812f3ab10eead Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 12 Nov 2023 09:39:34 +0000 Subject: [PATCH 07/11] Switch to a floating point approach in font-44.1 --- tests/font.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/font.test b/tests/font.test index 45d8af6f1..d260dce11 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2344,12 +2344,12 @@ test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { puts "oldscale: $oldscale" - set oldsize [expr {round([font actual {times -12} -size] * $oldscale)}] + set oldsize [expr {-(-12.0 / $oldscale)}] puts "font actual {times -12}: [font actual {times -12}]" puts "oldsize: $oldsize" tk scaling 0.5 puts "font actual {times -12}: [font actual {times -12}]" - expr {round([font actual {times -12} -size] - $oldsize / 0.5) == 0} + expr {([font actual {times -12} -size] / $oldscale * 0.5 - $oldsize) < 0.001} } -cleanup { tk scaling $oldscale } -result 1 From f0844f86778394bb001df716ca5dea9aee95abec Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Nov 2023 06:40:07 +0000 Subject: [PATCH 08/11] Forgot abs() in previous commit. --- tests/font.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/font.test b/tests/font.test index d260dce11..a7082422a 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2349,7 +2349,7 @@ puts "font actual {times -12}: [font actual {times -12}]" puts "oldsize: $oldsize" tk scaling 0.5 puts "font actual {times -12}: [font actual {times -12}]" - expr {([font actual {times -12} -size] / $oldscale * 0.5 - $oldsize) < 0.001} + expr {abs([font actual {times -12} -size] / $oldscale * 0.5 - $oldsize) < 0.001} } -cleanup { tk scaling $oldscale } -result 1 From 29377ce482568009ea57aa8c29955df95e9c066a Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 13 Nov 2023 21:52:13 +0000 Subject: [PATCH 09/11] Reintroduce rounding in font-44.1 --- tests/font.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/font.test b/tests/font.test index a7082422a..a1bf9b832 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2349,7 +2349,7 @@ puts "font actual {times -12}: [font actual {times -12}]" puts "oldsize: $oldsize" tk scaling 0.5 puts "font actual {times -12}: [font actual {times -12}]" - expr {abs([font actual {times -12} -size] / $oldscale * 0.5 - $oldsize) < 0.001} + expr {abs(round([font actual {times -12} -size] / $oldscale * 0.5) - round($oldsize)) == 0} } -cleanup { tk scaling $oldscale } -result 1 From 37887ffb2c8e05dd5c9f04ae5deb8e9e4cf6ce89 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 14 Nov 2023 04:44:32 +0000 Subject: [PATCH 10/11] Remove useless abs() in font-44.1 --- tests/font.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/font.test b/tests/font.test index a1bf9b832..ece49d7c3 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2349,7 +2349,7 @@ puts "font actual {times -12}: [font actual {times -12}]" puts "oldsize: $oldsize" tk scaling 0.5 puts "font actual {times -12}: [font actual {times -12}]" - expr {abs(round([font actual {times -12} -size] / $oldscale * 0.5) - round($oldsize)) == 0} + expr {round([font actual {times -12} -size] / $oldscale * 0.5) - round($oldsize) == 0} } -cleanup { tk scaling $oldscale } -result 1 From 26f4d2bf8b589ae78776a8228188384588ffd24c Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 15 Nov 2023 19:54:27 +0000 Subject: [PATCH 11/11] Remove debug outputs. --- tests/font.test | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/font.test b/tests/font.test index ece49d7c3..d57b99824 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2339,21 +2339,15 @@ test font-43.1 {FieldSpecified procedure: specified vs. non-specified} -body { } -result [font actual {times 0} -family] -puts ">>>>>>>>>> font-44.1 starts" test font-44.1 {TkFontGetPixels: size < 0} -setup { set oldscale [tk scaling] } -body { -puts "oldscale: $oldscale" set oldsize [expr {-(-12.0 / $oldscale)}] -puts "font actual {times -12}: [font actual {times -12}]" -puts "oldsize: $oldsize" tk scaling 0.5 -puts "font actual {times -12}: [font actual {times -12}]" expr {round([font actual {times -12} -size] / $oldscale * 0.5) - round($oldsize) == 0} } -cleanup { tk scaling $oldscale } -result 1 -puts " font-44.1 ends <<<<<<<<<<" test font-44.2 {TkFontGetPoints: size >= 0} -constraints {noExceed haveTimes12Font} -setup { set oldscale [tk scaling] } -body {