summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-12 13:47:35 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-12 13:47:35 +0200
commitf413648183c90e454ba42aa3f1c8794f1d4fa729 (patch)
tree9377f5bfcd7d328c5a2a1f5feced18d70fa6ae61 /app
parent27d773e746ecbaffd0304da7adbb90a9e1b3c0e0 (diff)
fix: fix placement of font's baseline
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs4
-rw-r--r--app/Ui.hs7
2 files changed, 7 insertions, 4 deletions
diff --git a/app/Main.hs b/app/Main.hs
index b8fa0e2..7d499d8 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -147,7 +147,9 @@ createWindow args = do
wspac = args.spacing
wleft = wspac
fnt <- X.xftFontOpen dpy scr "IosevkaTerm Nerd Font:size=14"
- wheight <- X.xftfont_height fnt
+ ascent <- X.xftfont_ascent fnt
+ descent <- X.xftfont_descent fnt
+ let wheight = ascent + descent
cmap <- X.createColormap dpy root vis X.allocNone
win <- X.allocaSetWindowAttributes $ \attr -> do
X.set_colormap attr cmap
diff --git a/app/Ui.hs b/app/Ui.hs
index 808c3c1..34fa101 100644
--- a/app/Ui.hs
+++ b/app/Ui.hs
@@ -97,12 +97,13 @@ layOut env@Env {..} (Ui' cs) = do
extents :: Env -> C -> IO Rect
extents Env {..} (C {..}) = do
glyphInfo <- X.xftTextExtents dpy fnt string
+ ascent <- X.xftfont_ascent fnt
pure
( Rect
- { top = 0,
- left = 0,
+ { top = X.xglyphinfo_y glyphInfo,
+ left = X.xglyphinfo_x glyphInfo,
width = X.xglyphinfo_xOff glyphInfo,
- height = X.xglyphinfo_height glyphInfo
+ height = ascent
}
)