From 94f9c2c282b24c68403b8456279b09f5f05d37fc Mon Sep 17 00:00:00 2001 From: jgrocho Date: Wed, 30 Nov 2022 06:07:50 +0000 Subject: Adds DPI configuration (#660) Adds a new DPI configuration, especially useful for HiDPI displays. This changes the scaling factor for fonts as displayed by Pango. It defaults to 96.0 which corresponds to an average screen and is the default in [Cairo](https://hackage.haskell.org/package/pango-0.13.5.0/docs/Graphics-Rendering-Pango-Cairo.html#v:cairoFontMapGetDefault). It's also possible to supply a zero or negative value to use the default scaling factor, but I felt setting the default to 96.0 makes it more explicit. It also adds a matching command line option. I haven't tested it too thoroughly, but in my limited use it appears to be working as intended. One thing this does not do is scale XBM and XPM bitmap files which I'm unsure how to do or if that should even be our concern (instead leaving it up to the user to supply appropriate bitmaps). Co-authored-by: Jonathan Grochowski Reviewed-on: https://codeberg.org/xmobar/xmobar/pulls/660 Co-authored-by: jgrocho Co-committed-by: jgrocho --- src/Xmobar/Config/Parse.hs | 5 +++-- src/Xmobar/Config/Types.hs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Xmobar/Config') diff --git a/src/Xmobar/Config/Parse.hs b/src/Xmobar/Config/Parse.hs index 23de4db..0b41267 100644 --- a/src/Xmobar/Config/Parse.hs +++ b/src/Xmobar/Config/Parse.hs @@ -72,7 +72,7 @@ parseConfig defaultConfig = <|?> pAllDesktops <|?> pOverrideRedirect <|?> pPickBroadest <|?> pLowerOnStart <|?> pPersistent <|?> pIconRoot <|?> pCommands <|?> pSepChar <|?> pAlignSep <|?> pTemplate - <|?> pVerbose <|?> pSignal + <|?> pVerbose <|?> pSignal <|?> pDpi fields = [ "font", "additionalFonts", "bgColor", "fgColor" , "wmClass", "wmName", "sepChar" @@ -81,7 +81,7 @@ parseConfig defaultConfig = , "allDesktops", "overrideRedirect", "pickBroadest" , "hideOnStart", "lowerOnStart", "persistent", "iconRoot" , "alpha", "commands", "verbose", "signal", "textOutput" - , "textOutputFormat" + , "textOutputFormat", "dpi" ] pTextOutput = readField textOutput "textOutput" @@ -112,6 +112,7 @@ parseConfig defaultConfig = pIconRoot = readField iconRoot "iconRoot" pAlpha = readField alpha "alpha" pVerbose = readField verbose "verbose" + pDpi = readField dpi "dpi" pSignal = field signal "signal" $ fail "signal is meant for use with Xmobar as a library.\n It is not meant for use in the configuration file." diff --git a/src/Xmobar/Config/Types.hs b/src/Xmobar/Config/Types.hs index ea7b958..785b55b 100644 --- a/src/Xmobar/Config/Types.hs +++ b/src/Xmobar/Config/Types.hs @@ -85,6 +85,7 @@ data Config = , template :: String -- ^ The output template , verbose :: Bool -- ^ Emit additional debug messages , signal :: SignalChan -- ^ Channel to send signals to xmobar + , dpi :: Double -- ^ DPI scaling factor for fonts } deriving (Read, Show) -- | The position datatype -- cgit v1.2.3