aboutsummaryrefslogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
authorShivesh Mandalia <mail@shivesh.org>2021-09-22 20:30:34 +0100
committerShivesh Mandalia <mail@shivesh.org>2021-09-22 20:30:34 +0100
commit3964320a731def870e1c28bc8bae05310decc949 (patch)
treefdd660d368bafa25e6084453866e3032b90da78d /x.c
parent2467e2824fb6a2bc2bf76883f8a2c7561d7af4a4 (diff)
downloadst-3964320a731def870e1c28bc8bae05310decc949.tar.gz
st-3964320a731def870e1c28bc8bae05310decc949.zip
Proper drawing of ligatures
- Patch st-ligatures-scrollback-0.8.4 <https://st.suckless.org/patches/ligatures/>
Diffstat (limited to 'x.c')
-rw-r--r--x.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/x.c b/x.c
index 10382f3..310e8de 100644
--- a/x.c
+++ b/x.c
@@ -19,6 +19,7 @@ char *argv0;
#include "arg.h"
#include "st.h"
#include "win.h"
+#include "hb.h"
/* types used in config.h */
typedef struct {
@@ -1036,6 +1037,9 @@ xunloadfont(Font *f)
void
xunloadfonts(void)
{
+ /* Clear Harfbuzz font cache. */
+ hbunloadfonts();
+
/* Free the loaded fonts in the font cache. */
while (frclen > 0)
XftFontClose(xw.dpy, frc[--frclen].font);
@@ -1235,7 +1239,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
mode = glyphs[i].mode;
/* Skip dummy wide-character spacing. */
- if (mode == ATTR_WDUMMY)
+ if (mode & ATTR_WDUMMY)
continue;
/* Determine font for glyph if different from previous glyph. */
@@ -1342,6 +1346,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
numspecs++;
}
+ /* Harfbuzz transformation for ligatures. */
+ hbtransform(specs, glyphs, len, x, y);
+
return numspecs;
}
@@ -1491,14 +1498,17 @@ xdrawglyph(Glyph g, int x, int y)
}
void
-xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
+xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len)
{
Color drawcol;
/* remove the old cursor */
if (selected(ox, oy))
og.mode ^= ATTR_REVERSE;
- xdrawglyph(og, ox, oy);
+
+ /* Redraw the line where cursor was previously.
+ * It will restore the ligatures broken by the cursor. */
+ xdrawline(line, 0, oy, len);
if (IS_SET(MODE_HIDE))
return;