Skip to content

Commit

Permalink
Use XFT fonts if available
Browse files Browse the repository at this point in the history
The silent error `user error (createFontSet)` would break certain
modules (like the prompt) by simply not showing anything.

Pango 1.44 dropped support for FreeType in favor of HarfBuzz, losing
support for traditional BDF/PCF bitmap fonts.  Hence, some distributions
don't ship `xorg-fonts-misc` anymore.

Fixes xmonad#348
  • Loading branch information
sergeykish authored and slotThe committed Mar 24, 2021
1 parent cb86dd3 commit 619d081
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

### Breaking Changes

* All modules that export bitmap fonts as their default

- If xmonad is compiled with XFT support (the default), use an XFT
font instead. The previous default expected an X11 misc font
(PCF), which is not supported in pango 1.44 anymore and thus some
distributions have stopped shipping these.

This fixes the silent `user error (createFontSet)`; this would
break the respective modules.

* `XMonad.Prompt`

- Now `mkComplFunFromList` and `mkComplFunFromList'` take an
Expand Down
5 changes: 5 additions & 0 deletions XMonad/Actions/ShowText.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.ShowText
Expand Down Expand Up @@ -74,7 +75,11 @@ data ShowTextConfig =

instance Default ShowTextConfig where
def =
#ifdef XFT
STC { st_font = "xft:monospace-20"
#else
STC { st_font = "-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*"
#endif
, st_bg = "black"
, st_fg = "white"
}
Expand Down
12 changes: 11 additions & 1 deletion XMonad/Layout/Decoration.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, PatternGuards, TypeSynonymInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Layout.Decoration
Expand Down Expand Up @@ -104,7 +110,11 @@ instance Default Theme where
, activeTextColor = "#FFFFFF"
, inactiveTextColor = "#BFBFBF"
, urgentTextColor = "#FF0000"
#ifdef XFT
, fontName = "xft:monospace"
#else
, fontName = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
#endif
, decoWidth = 200
, decoHeight = 20
, windowTitleAddons = []
Expand Down
9 changes: 8 additions & 1 deletion XMonad/Layout/ShowWName.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE PatternGuards, FlexibleInstances, MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Layout.ShowWName
Expand Down Expand Up @@ -62,7 +65,11 @@ data SWNConfig =

instance Default SWNConfig where
def =
#ifdef XFT
SWNC { swn_font = "xft:monospace-20"
#else
SWNC { swn_font = "-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*"
#endif
, swn_bgcolor = "black"
, swn_color = "white"
, swn_fade = 1
Expand Down
5 changes: 5 additions & 0 deletions XMonad/Prompt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Prompt
Expand Down Expand Up @@ -310,7 +311,11 @@ instance Default XPColor where

instance Default XPConfig where
def =
#ifdef XFT
XPC { font = "xft:monospace-12"
#else
XPC { font = "-misc-fixed-*-*-*-*-12-*-*-*-*-*-*-*"
#endif
, bgColor = bgNormal def
, fgColor = fgNormal def
, bgHLight = bgHighlight def
Expand Down

0 comments on commit 619d081

Please sign in to comment.