From 2e9c554f2c044cb34758139375203e2fdf3296c1 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sat, 20 Feb 2021 13:24:02 -0500 Subject: [PATCH] Revised the wrapper script to use the Tk command "font measure" to get the pixel size of the default font, and scale the window glyphs and scrollbars to match, so that the display is automatically adjusted for screen resolution and does not require manual intervention to correct for high resolution displays. --- VERSION | 2 +- tcltk/wrapper.tcl | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a82d6cf7..c11794e5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.130 +8.3.131 diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index 5bba211a..4b327c80 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -554,7 +554,6 @@ set Opts(crosshair) 0 set Opts(hidelocked) 0 set Opts(hidespecial) 0 set Opts(toolbar) 0 -set Opts(scale) 1.0 set Opts(toolscale) 1.0 set Opts(drc) 1 set Opts(autobuttontext) 1 @@ -1135,6 +1134,16 @@ proc magic::openwrapper {{cell ""} {framename ""}} { toplevel $framename tkwait visibility $framename + # Get scale from the TkDefaultFont size, unless Opts(scale) is already + # set. On standard displays, an "M" in the Sans font is usually 10 + # pixels wide, and 22 on high resolution displays, so this maps to + # a scale of 1 on standard displays and a scale of 2 on high resolution + # displays. + + if [catch {set Opts(scale)}] { + set Opts(scale) [expr {int([font measure TkDefaultFont M] / 10)}] + } + # Resize the window if {[catch {wm geometry ${framename} $Winopts(${framename},geometry)}]} { catch {wm geometry ${framename} $Opts(geometry)}