REF fonts

This commit is contained in:
Nathan Dwarshuis 2020-04-01 21:03:00 -04:00
parent 8818c376ae
commit 16bea08957
1 changed files with 12 additions and 20 deletions

View File

@ -1,5 +1,3 @@
{-# LANGUAGE LambdaCase #-}
module XMonad.Internal.Theme module XMonad.Internal.Theme
( baseColor ( baseColor
, bgColor , bgColor
@ -24,11 +22,10 @@ module XMonad.Internal.Theme
, promptTheme , promptTheme
) where ) where
import Data.Char
import Data.Char
import Data.Colour import Data.Colour
import Data.Colour.SRGB import Data.Colour.SRGB
import Data.List import Data.List
import qualified XMonad.Layout.Decoration as D import qualified XMonad.Layout.Decoration as D
@ -82,9 +79,6 @@ darken' wt = sRGB24show . darken wt . sRGB24read
-- Fonts -- Fonts
-- TODO use the font package from contrib
-- https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Util-Font.html
data Slant = Roman data Slant = Roman
| Italic | Italic
| Oblique | Oblique
@ -108,25 +102,23 @@ data ThemeFont = ThemeFont
fmtFontXFT :: ThemeFont -> String fmtFontXFT :: ThemeFont -> String
fmtFontXFT ThemeFont fmtFontXFT ThemeFont
-- TODO there should be a better way to do this...
{ family = f { family = f
, weight = w , weight = w
, slant = l , slant = l
, size = s , size = s
, pixelsize = i , pixelsize = p
, antialias = a , antialias = a
} = "xft:" ++ intercalate ":" (filter (not . null) elems) } = intercalate ":" $ ["xft", f] ++ elems
where where
elems = [ f elems = [ k ++ "=" ++ v | (k, Just v) <- [ ("weight", showLower w)
, fmt "weight" w , ("slant", showLower l)
, fmt "slant" l , ("size", showLower s)
, fmt "size" s , ("pixelsize", showLower p)
, fmt "pixelsize" i , ("antialias", showLower a)
, fmt "antialias" a] ]
fmt :: Show a => String -> Maybe a -> String ]
fmt e = \case showLower :: Show a => Maybe a -> Maybe String
Just d -> e ++ "=" ++ map toLower (show d) showLower = fmap (fmap toLower . show)
Nothing -> ""
font :: ThemeFont font :: ThemeFont
font = ThemeFont font = ThemeFont