Add ligature support
parent
a3321c680c
commit
fc0c03da7c
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = st.c x.c
|
SRC = st.c x.c hb.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: options st
|
all: options st
|
||||||
|
@ -22,7 +22,8 @@ config.h:
|
||||||
$(CC) $(STCFLAGS) -c $<
|
$(CC) $(STCFLAGS) -c $<
|
||||||
|
|
||||||
st.o: config.h st.h win.h
|
st.o: config.h st.h win.h
|
||||||
x.o: arg.h config.h st.h win.h
|
x.o: arg.h config.h st.h win.h hb.h
|
||||||
|
hb.o: st.h
|
||||||
|
|
||||||
$(OBJ): config.h config.mk
|
$(OBJ): config.h config.mk
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,12 @@ PKG_CONFIG = pkg-config
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I$(X11INC) \
|
INCS = -I$(X11INC) \
|
||||||
`$(PKG_CONFIG) --cflags fontconfig` \
|
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||||
`$(PKG_CONFIG) --cflags freetype2`
|
`$(PKG_CONFIG) --cflags freetype2` \
|
||||||
|
`$(PKG_CONFIG) --cflags harfbuzz`
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||||
`$(PKG_CONFIG) --libs fontconfig` \
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
`$(PKG_CONFIG) --libs freetype2`
|
`$(PKG_CONFIG) --libs freetype2` \
|
||||||
|
`$(PKG_CONFIG) --libs harfbuzz`
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||||
|
|
BIN
.suckless/st/st
BIN
.suckless/st/st
Binary file not shown.
|
@ -2660,7 +2660,8 @@ draw(void)
|
||||||
drawregion(0, 0, term.col, term.row);
|
drawregion(0, 0, term.col, term.row);
|
||||||
if (term.scr == 0)
|
if (term.scr == 0)
|
||||||
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
|
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
|
||||||
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx],
|
||||||
|
term.line[term.ocy], term.col);
|
||||||
term.ocx = cx;
|
term.ocx = cx;
|
||||||
term.ocy = term.c.y;
|
term.ocy = term.c.y;
|
||||||
xfinishdraw();
|
xfinishdraw();
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
||||||
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
||||||
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
||||||
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
|
#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) != ((b).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) || \
|
||||||
|
(a).fg != (b).fg || \
|
||||||
(a).bg != (b).bg)
|
(a).bg != (b).bg)
|
||||||
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
||||||
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
||||||
|
@ -33,6 +34,7 @@ enum glyph_attribute {
|
||||||
ATTR_WRAP = 1 << 8,
|
ATTR_WRAP = 1 << 8,
|
||||||
ATTR_WIDE = 1 << 9,
|
ATTR_WIDE = 1 << 9,
|
||||||
ATTR_WDUMMY = 1 << 10,
|
ATTR_WDUMMY = 1 << 10,
|
||||||
|
ATTR_LIGA = 1 << 11,
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ enum win_mode {
|
||||||
|
|
||||||
void xbell(void);
|
void xbell(void);
|
||||||
void xclipcopy(void);
|
void xclipcopy(void);
|
||||||
void xdrawcursor(int, int, Glyph, int, int, Glyph);
|
void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
|
||||||
void xdrawline(Line, int, int, int);
|
void xdrawline(Line, int, int, int);
|
||||||
void xfinishdraw(void);
|
void xfinishdraw(void);
|
||||||
void xloadcols(void);
|
void xloadcols(void);
|
||||||
|
|
|
@ -19,6 +19,7 @@ char *argv0;
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
#include "hb.h"
|
||||||
|
|
||||||
/* types used in config.h */
|
/* types used in config.h */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1031,6 +1032,9 @@ xunloadfont(Font *f)
|
||||||
void
|
void
|
||||||
xunloadfonts(void)
|
xunloadfonts(void)
|
||||||
{
|
{
|
||||||
|
/* Clear Harfbuzz font cache. */
|
||||||
|
hbunloadfonts();
|
||||||
|
|
||||||
/* Free the loaded fonts in the font cache. */
|
/* Free the loaded fonts in the font cache. */
|
||||||
while (frclen > 0)
|
while (frclen > 0)
|
||||||
XftFontClose(xw.dpy, frc[--frclen].font);
|
XftFontClose(xw.dpy, frc[--frclen].font);
|
||||||
|
@ -1230,7 +1234,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
||||||
mode = glyphs[i].mode;
|
mode = glyphs[i].mode;
|
||||||
|
|
||||||
/* Skip dummy wide-character spacing. */
|
/* Skip dummy wide-character spacing. */
|
||||||
if (mode == ATTR_WDUMMY)
|
if (mode & ATTR_WDUMMY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Determine font for glyph if different from previous glyph. */
|
/* Determine font for glyph if different from previous glyph. */
|
||||||
|
@ -1337,6 +1341,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
||||||
numspecs++;
|
numspecs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Harfbuzz transformation for ligatures. */
|
||||||
|
hbtransform(specs, glyphs, len, x, y);
|
||||||
|
|
||||||
return numspecs;
|
return numspecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1486,14 +1493,17 @@ xdrawglyph(Glyph g, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
Color drawcol;
|
||||||
|
|
||||||
/* remove the old cursor */
|
/* remove the old cursor */
|
||||||
if (selected(ox, oy))
|
if (selected(ox, oy))
|
||||||
og.mode ^= ATTR_REVERSE;
|
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))
|
if (IS_SET(MODE_HIDE))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue