This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: (getting correct DPI from windows for) cygwinX xwin resolution

Eliot Moss wrote:
As I mentioned, it is clear the XWin itself
has a notion of resolution, but most applications
do not seem to be coded to take it into account.
The main ones that I use don't, anyway, and so
I needed to adjust things in my .Xdefaults, as
I described and gave examples of in my previous
posting ...
Xwin has had the notion of "dpi" in it since before windows
was created.  Windows programming took people backwards, in
that it specified sizes in pixels.

The new HTML5 standard has artificially defined a "software pixel",
that is supposed to be 1/96th of an inch -- independent of the
rendering device, but in HTML4, pixels were still pixels.

One way that can help on XWindows The fonts were The fixed width fonts (100dpi/75dpi) are created to work
under those resolutions only.  If the programs you are using use
Truetype fonts those should resize automatically if you
start the Xwin server using the "-dpi" switch and give it the value
for your screen -- it doesn't support multiple dpi-values for different
screen types though (neither does windows, AFAIK).

A shell script way to get windows DPI:
#!/bin/bash -u
shopt -s expand_aliases alias my=declare
alias int=my\ -i

ord () { printf "%d\n" "'$1"

get_dpi () {
 my mskey='/proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft'
 my dpi_k='Windows NT/CurrentVersion/FontDPI/LogPixels'
 read val<"$mskey/$dpi_k"
 int dpi=$(ord "$val")
 # check for insane values
 ((dpi<50||dpi>>400)) && dpi=96
 echo "$dpi"


My check for 'insane' values may be out of date in the not so
distant future.  Adjust as necessary, if your screens are really
out of this range, and set a default to something near your screen's
listed resolution.  To get that use your screen's listed size
in inches.  Example: using a 20 inch screen, and your display's
listed resolution from:

"Control Panel\All Control Panel Items\Display\Screen Resolution",
(you said 3200x1800 a 16:9 ratio), calculate the following: (example in shell+perl)
(or use a calculator).

X=3200 Y=1800   #or whatever your screen size is in dots
let Z="$X*$X+$Y*$Y"; echo $Z
perl -e 'printf "%d\n", 13480000**.5'

above is diagonal dots.  to get DPI in shell
(using the 20" screensize):

let actual_dpi="(3671+$S-1)/$S"; echo $actual_dpi

(so use 184 for Windows DPI, and X "-dpi").

NOTE: if you let windows resize your entire screen, instead of
just the text, then magnification is already applied to your X
display, so use "-dpi 100" (or more precisely, "-dpi $[100*184/96]").

Hope this helps and isn't too confusing...

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]