Make beautiful fallback properly if Xft.dpi is missing
As documented in <https://keithp.com/~keithp/talks/xtc2001/paper/xft.html#sec-editing>, the fallback value for Xft.dpi should be the vertical DPI reported by X. On Xorg, this will generally be 96, unless the user has overridden the value by either forcing Xorg to report the EDID-derived DPI, or by setting the DPI themselves (via configuration, command line, or xrandr). The 96 value is kept as ultimate fallback if anything goes wrong.
This commit is contained in:
parent
f7d8233466
commit
f22ef5014d
|
@ -83,6 +83,22 @@ function xresources.get_dpi(s)
|
||||||
if awesome and awesome.xrdb_get_value then
|
if awesome and awesome.xrdb_get_value then
|
||||||
xresources.dpi = tonumber(awesome.xrdb_get_value("", "Xft.dpi"))
|
xresources.dpi = tonumber(awesome.xrdb_get_value("", "Xft.dpi"))
|
||||||
end
|
end
|
||||||
|
-- Following Keith Packard's whitepaper on Xft,
|
||||||
|
-- https://keithp.com/~keithp/talks/xtc2001/paper/xft.html#sec-editing
|
||||||
|
-- the proper fallback for Xft.dpi is the vertical DPI reported by
|
||||||
|
-- the X server. This will generally be 96 on Xorg, unless the user
|
||||||
|
-- has configured it differently
|
||||||
|
if not xresources.dpi then
|
||||||
|
if root then
|
||||||
|
local mm_to_inch = 25.4
|
||||||
|
_, h = root.size()
|
||||||
|
_, hmm = root.size_mm()
|
||||||
|
if hmm ~= 0 then
|
||||||
|
xresources.dpi = round(h*mm_to_inch/hmm)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- ultimate fallback
|
||||||
if not xresources.dpi then
|
if not xresources.dpi then
|
||||||
xresources.dpi = 96
|
xresources.dpi = 96
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue