nemethi <
csaba....@t-online.de> wrote:
> Am 21.10.20 um 23:41 schrieb Rich:
>> The reference to
>>
>> "if the DPI scaling factor is 100 %. It gets wider
>> (3.75 cm if the DPI scaling is set to 125 %, 4.5 cm if the DPI scaling
>> is 150 %"
>>
>> also implies Windows 10 and the preset choices of scaling factors
>> present in the Windows 10 equivalent of the control panel. If my
>> supposition is correct (these are Windows 10 systems) then what MS did
>> for W10 was cheat by lying to applications about the actual DPI
>> resolution of the physical screen in order to build those "100%, 125%,
>> and 150%" selections. If Tk on W10 is assuming the reported DPI value
>> of the screen from the OS is accurate (and I assume Tk believes the OS
>> to accurately report the screen resolution), and the OS is lying about
>> the screens DPI value, then the result will be exactly what you found,
>> a "measurement" value in Tk will not produce that same measurement on
>> the physical screen (and it should, asking for 1inch should give 1inch
>> on screen if nothing in the OS is lying about the screen resolution).
>>
>> The fact that 100% is off implies that W10 may also be lying about the
>> physical screen resolution even when you tell it to use 100% (under the
>> assumption this was a W10 system, given the size factors presented).
>>
>
> As already mentioned, the goal of my original posting was to clarify the
> misunderstanding that specifying a width of 5c will (or at least should)
> result in a physical width of 5 cm on all screens of the same resolution
> (e.g. full HD). Your above lines confirm that this myth is quite
> widespread.
Well, if I tell a system to produce a 5cm line, and it produces
something other than 5cm +- whatever minimum resolution it is capable
of producing, then it has not correctly honored my request. The fact
that many systems may be failing to honor the request to the limits of
their accuracy does not make their behavior correct, just common.
Requesting 5cm should, provided no bugs or miss-configurations, result
in 5cm.
> On my 14" notebook I have not only Windows 10 but also three different
> Linux distributions. On Windows, if the DPI scaling is set to 100 %
> then [tk scaling] will be 1.333.... You stated that this is because
> "W10 may also be lying about the physical screen resolution". Please
> note that I get the same [tk scaling] value on Linux, too.
> Consequently, not only Windows, but also Linux (more precisely, X11) is
> "lying about the physical screen resolution". Indeed, [winfo
> screenmmwidth .] is 508 both on my 24" display and on the 14" notebook
> screen, *not only on Windows, but also on Linux*. This value, together
> with [winfo screenwidth .], which is 1920 on both displays, regardless
> of the windowing system, explains why we get the same initial [tk
> scaling] value of 1.333... on both Windows and Linux.
I've subsequently found this
https://bugs.freedesktop.org/show_bug.cgi?id=23705 which while somewhat
rambling, seems to indicate that at some point, X11 was modified to
assume 96dpi /unless/ the user provides a DisplaySize parameter in
one's xorg.conf file, and to ignore the EDID resoluton values reported
from monitors. It also implies that ignoring the EDID was intentional
because, according to a few comments inside, manufactures often provide
incorrect EDID values, resulting in bogus DPI computations. So, yes,
it does appear that later X releases have begun /lying/ about the
screen's DPI value, unless the owner knows that they need to tell X
their screens physical size in the xorg.conf file.
I got the result of 1c == 1c on my screen because as it happens, it is
just shy of the default 96dpi that X chooses (actual DPI is a few
hundredths less than 94dpi). So I got 1c == 1c with Brad's example.
I then used xrandr to adjust my dpi settings and tested again. First,
I told X to use a dpi of 96*2 (192 dpi). Running the test, I got a 1c
wide box, and these tk scaling factors:
a: 2.6687680588389804
b: 4.003152088258471
Then, I told X the screen dpi was 96/2 (48 dpi). Running the test I
got a 0.5c wide box, and these tk scaling factors:
a: 0.6667979261009384
b: 4.003152088258471
So, for at least X11 (I don't have windows installed anywhere to test
with), if the dpi of the monitor is set properly, Tk computes a correct
scaling factor to give a real 5cm line when asking for a 5cm line.
However, it also seems that for any monitor resolution other than
96dpi, unless the owner knows to give X11 a DisplaySize parameter, the
result will be X11 returning the incorrect resolution value to apps
(yes, it is lying about the actual resolution).
> As indicated by Brad, one can make sure that a width of 5c will
> result in a physical width of 5 cm by setting [tk scaling] to a value
> which can be determined with the aid of an appropriate Tcl script and
> a ruler. While this is possible (and works as expected), I don't
> think that it could be the general solution to the problem that
> apparently both Windows and Linux are "lying about the physical
> screen resolution".
Agreed, with both of them reporting incorrect DPI values, there is no
guarantee that asking for 5c will return anything close to 5cm, except
in those situations where the Tk app is running on a monitor that
happens to also be 96dpi (or close thereto) or a user has configured
their system to report the true screen DPI resolution.
> It appears much more realistic to me to accept the fact that the
> initial values of [tk scaling] and [winfo screenmmwidth .] are based
> on a *reference screen* having a resolution density of 96
> pixels/inch.
This seems to be the case, but it seems that the "based upon a
reference screen" aspect is at the X11 and/or Windows OS level, not
within Tk. Tk appears to be correctly computing a scaling factor that
/would/ work in all cases if the OS reported the screen DPI accurately
as opposed to reporting the /reference dpi/ value. So in those rare
instances where a user configures their OS to report the real monitor
DPI value, Tk will compute a correct scale factor to produce real world
measurements from its m, c, and i values. But I suspect that the
instances of a screen with a resolution other than 96dpi being
correctly configured to report its true resolution by the owner are few
in number.
So the takeaway here is if one is creating a Tk app. that needs to
display correct measurement values on screen, one will have to also
walk a user through tweaking their tk scaling factor to be certain to
produce correct display sizes.
I also expect that if you calculate the resolution of your laptop
screen, and tell X11 the real world resolution (xrandr --dpi #) that
Brad's example will give you a 1cm sized red box on the laptop.