mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.U.Font: Add a fallback font to initXMF
In case a font could not be opened, simply fall back to "xft:monospace" and open that. The initCoreFont and initUtf8Font functions already have mechanisms like this, is was just missing from initXMF. Closes: https://github.com/xmonad/xmonad-contrib/issues/723
This commit is contained in:
parent
b0fc55499d
commit
4a3f8eb032
@ -123,12 +123,15 @@ initXMF s =
|
|||||||
if xftPrefix `isPrefixOf` s then
|
if xftPrefix `isPrefixOf` s then
|
||||||
do dpy <- asks display
|
do dpy <- asks display
|
||||||
let fonts = case wordsBy (== ',') (drop (length xftPrefix) s) of
|
let fonts = case wordsBy (== ',') (drop (length xftPrefix) s) of
|
||||||
[] -> "xft:monospace" :| [] -- NE.singleton only in base 4.15
|
[] -> fallback :| [] -- NE.singleton only in base 4.15
|
||||||
(x : xs) -> x :| xs
|
(x : xs) -> x :| xs
|
||||||
Xft <$> io (traverse (openFont dpy) fonts)
|
fb <- io $ openFont dpy fallback
|
||||||
|
fmap Xft . io $ traverse (\f -> E.catch (openFont dpy f) (econst $ pure fb))
|
||||||
|
fonts
|
||||||
else Utf8 <$> initUtf8Font s
|
else Utf8 <$> initUtf8Font s
|
||||||
where
|
where
|
||||||
xftPrefix = "xft:"
|
xftPrefix = "xft:"
|
||||||
|
fallback = "xft:monospace"
|
||||||
openFont dpy str = xftFontOpen dpy (defaultScreenOfDisplay dpy) str
|
openFont dpy str = xftFontOpen dpy (defaultScreenOfDisplay dpy) str
|
||||||
wordsBy p str = case dropWhile p str of
|
wordsBy p str = case dropWhile p str of
|
||||||
"" -> []
|
"" -> []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user