Skip to content

Commit e4230c3

Browse files
committed
Xft: Change xftfont_min_descent to return max descent
Like the font's ascent, its descent is also always positive. That means for the common use-case of getting the greatest descent for a list of fonts, one can simply return the maximum of all descents. In this way, it is possible to center text that's using multiple fonts by simply calculating the maximum ascent and descent. This is also done in xmobar's MinXft library[1], which this part of the code is modeled after. Fixes: 0cc513a Related: xmonad/xmonad-contrib#646 [1]: https://github.com/jaor/xmobar/blob/master/src/Xmobar/X11/MinXft.hsc#L94
1 parent 537c762 commit e4230c3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
possibly uses different fonts for different parts of the string and
1212
returns the accumulative extents.
1313

14-
* Added the functions `xftfont_max_ascent`, `xftfont_min_descent`, and
14+
* Added the functions `xftfont_max_ascent`, `xftfont_max_descent`, and
1515
`xftfont_max_height` to gain information about a non-empty list of
1616
`XftFont`s.
1717

Graphics/X11/Xft.hsc

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Graphics.X11.Xft ( XftColor
2828
, xftfont_ascent
2929
, xftfont_max_ascent
3030
, xftfont_descent
31-
, xftfont_min_descent
31+
, xftfont_max_descent
3232
, xftfont_height
3333
, xftfont_max_height
3434
, xftfont_max_advance_width
@@ -197,8 +197,8 @@ foreign import ccall "XftFontClose"
197197
xftfont_max_ascent :: NonEmpty XftFont -> IO Int
198198
xftfont_max_ascent = fmap maximum . mapM xftfont_ascent
199199

200-
xftfont_min_descent :: NonEmpty XftFont -> IO Int
201-
xftfont_min_descent = fmap minimum . mapM xftfont_descent
200+
xftfont_max_descent :: NonEmpty XftFont -> IO Int
201+
xftfont_max_descent = fmap maximum . mapM xftfont_descent
202202

203203
xftfont_max_height :: NonEmpty XftFont -> IO Int
204204
xftfont_max_height = fmap maximum . mapM xftfont_height

0 commit comments

Comments
 (0)