Adding ligatures patch as requested in #4

This commit is contained in:
bakkeby 2020-06-05 13:43:14 +02:00
parent ff5f26cc3b
commit e0169edec9
10 changed files with 222 additions and 8 deletions

27
x.c
View file

@ -19,6 +19,9 @@ char *argv0;
#include "arg.h"
#include "st.h"
#include "win.h"
#if LIGATURES_PATCH
#include "hb.h"
#endif // LIGATURES_PATCH
#if THEMED_CURSOR_PATCH
#include <X11/Xcursor/Xcursor.h>
@ -1216,6 +1219,11 @@ xunloadfont(Font *f)
void
xunloadfonts(void)
{
#if LIGATURES_PATCH
/* Clear Harfbuzz font cache. */
hbunloadfonts();
#endif // LIGATURES_PATCH
/* Free the loaded fonts in the font cache. */
while (frclen > 0)
XftFontClose(xw.dpy, frc[--frclen].font);
@ -1449,7 +1457,11 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
mode = glyphs[i].mode;
/* Skip dummy wide-character spacing. */
#if LIGATURES_PATCH
if (mode & ATTR_WDUMMY)
#else
if (mode == ATTR_WDUMMY)
#endif // LIGATURES_PATCH
continue;
/* Determine font for glyph if different from previous glyph. */
@ -1570,6 +1582,11 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
numspecs++;
}
#if LIGATURES_PATCH
/* Harfbuzz transformation for ligatures. */
hbtransform(specs, glyphs, len, x, y);
#endif // LIGATURES_PATCH
return numspecs;
}
@ -1780,14 +1797,24 @@ xdrawglyph(Glyph g, int x, int y)
}
void
#if LIGATURES_PATCH
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len)
#else
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
#endif // LIGATURES_PATCH
{
Color drawcol;
/* remove the old cursor */
if (selected(ox, oy))
og.mode ^= ATTR_REVERSE;
#if LIGATURES_PATCH
/* Redraw the line where cursor was previously.
* It will restore the ligatures broken by the cursor. */
xdrawline(line, 0, oy, len);
#else
xdrawglyph(og, ox, oy);
#endif // LIGATURES_PATCH
if (IS_SET(MODE_HIDE))
return;