summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Text/Pango.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-02-07 03:58:14 +0000
committerjao <jao@gnu.org>2022-02-07 19:46:22 +0000
commitc75f31c0887b12c1e9fd63a05a494d703c43576a (patch)
tree6d431f390f92152fdf16efb6abff1cc46dfd5b53 /src/Xmobar/Text/Pango.hs
parent5768a50352f2e0fc4e56b48faf09a71cc8b8e9fc (diff)
downloadxmobar-c75f31c0887b12c1e9fd63a05a494d703c43576a.tar.gz
xmobar-c75f31c0887b12c1e9fd63a05a494d703c43576a.tar.bz2
swaybar-protocol: additionalFonts via pango markup
Diffstat (limited to 'src/Xmobar/Text/Pango.hs')
-rw-r--r--src/Xmobar/Text/Pango.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Xmobar/Text/Pango.hs b/src/Xmobar/Text/Pango.hs
index b8205ef..38d1b5b 100644
--- a/src/Xmobar/Text/Pango.hs
+++ b/src/Xmobar/Text/Pango.hs
@@ -15,9 +15,10 @@
--
------------------------------------------------------------------------------
-module Xmobar.Text.Pango (withPangoColor) where
+module Xmobar.Text.Pango (withPangoColor, withPangoFont) where
import Text.Printf (printf)
+import Data.List (isPrefixOf)
replaceAll :: (Eq a) => a -> [a] -> [a] -> [a]
replaceAll c s = concatMap (\x -> if x == c then s else [x])
@@ -33,3 +34,8 @@ withPangoColor :: (String, String) -> String -> String
withPangoColor (fg, bg) s =
printf fmt (xmlEscape fg) (xmlEscape bg) (xmlEscape s)
where fmt = "<span foreground=\"%s\" background=\"%s\">%s</span>"
+
+withPangoFont :: String -> String -> String
+withPangoFont font txt = printf fmt pfn (xmlEscape txt)
+ where fmt = "<span font=\"%s\">%s</span>"
+ pfn = if "xft:" `isPrefixOf` font then drop 4 font else font