wide glyphs
This commit is contained in:
parent
fa3ca0c2fb
commit
b848164a1c
|
@ -0,0 +1,163 @@
|
||||||
|
From 1635e04d3643dd4caa0c7c2043b585c6d7e4705f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Rizqi Nur Assyaufi <bandithijo@gmail.com>
|
||||||
|
Date: Mon, 18 Jul 2022 01:15:45 +0800
|
||||||
|
Subject: [PATCH] [st][patch][font2] Add patch for st-0.8.5
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 6 +++
|
||||||
|
x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 107 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 91ab8ca..717b2f0 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -6,6 +6,12 @@
|
||||||
|
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||||
|
*/
|
||||||
|
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
|
||||||
|
+/* Spare fonts */
|
||||||
|
+static char *font2[] = {
|
||||||
|
+/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */
|
||||||
|
+/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static int borderpx = 2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
index 8a16faa..220fc4f 100644
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -157,6 +157,8 @@ static void xhints(void);
|
||||||
|
static int xloadcolor(int, const char *, Color *);
|
||||||
|
static int xloadfont(Font *, FcPattern *);
|
||||||
|
static void xloadfonts(const char *, double);
|
||||||
|
+static int xloadsparefont(FcPattern *, int);
|
||||||
|
+static void xloadsparefonts(void);
|
||||||
|
static void xunloadfont(Font *);
|
||||||
|
static void xunloadfonts(void);
|
||||||
|
static void xsetenv(void);
|
||||||
|
@@ -306,6 +308,7 @@ zoomabs(const Arg *arg)
|
||||||
|
{
|
||||||
|
xunloadfonts();
|
||||||
|
xloadfonts(usedfont, arg->f);
|
||||||
|
+ xloadsparefonts();
|
||||||
|
cresize(0, 0);
|
||||||
|
redraw();
|
||||||
|
xhints();
|
||||||
|
@@ -1034,6 +1037,101 @@ xloadfonts(const char *fontstr, double fontsize)
|
||||||
|
FcPatternDestroy(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+xloadsparefont(FcPattern *pattern, int flags)
|
||||||
|
+{
|
||||||
|
+ FcPattern *match;
|
||||||
|
+ FcResult result;
|
||||||
|
+
|
||||||
|
+ match = FcFontMatch(NULL, pattern, &result);
|
||||||
|
+ if (!match) {
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) {
|
||||||
|
+ FcPatternDestroy(match);
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ frc[frclen].flags = flags;
|
||||||
|
+ /* Believe U+0000 glyph will present in each default font */
|
||||||
|
+ frc[frclen].unicodep = 0;
|
||||||
|
+ frclen++;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+xloadsparefonts(void)
|
||||||
|
+{
|
||||||
|
+ FcPattern *pattern;
|
||||||
|
+ double sizeshift, fontval;
|
||||||
|
+ int fc;
|
||||||
|
+ char **fp;
|
||||||
|
+
|
||||||
|
+ if (frclen != 0)
|
||||||
|
+ die("can't embed spare fonts. cache isn't empty");
|
||||||
|
+
|
||||||
|
+ /* Calculate count of spare fonts */
|
||||||
|
+ fc = sizeof(font2) / sizeof(*font2);
|
||||||
|
+ if (fc == 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ /* Allocate memory for cache entries. */
|
||||||
|
+ if (frccap < 4 * fc) {
|
||||||
|
+ frccap += 4 * fc - frccap;
|
||||||
|
+ frc = xrealloc(frc, frccap * sizeof(Fontcache));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (fp = font2; fp - font2 < fc; ++fp) {
|
||||||
|
+
|
||||||
|
+ if (**fp == '-')
|
||||||
|
+ pattern = XftXlfdParse(*fp, False, False);
|
||||||
|
+ else
|
||||||
|
+ pattern = FcNameParse((FcChar8 *)*fp);
|
||||||
|
+
|
||||||
|
+ if (!pattern)
|
||||||
|
+ die("can't open spare font %s\n", *fp);
|
||||||
|
+
|
||||||
|
+ if (defaultfontsize > 0) {
|
||||||
|
+ sizeshift = usedfontsize - defaultfontsize;
|
||||||
|
+ if (sizeshift != 0 &&
|
||||||
|
+ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
|
||||||
|
+ FcResultMatch) {
|
||||||
|
+ fontval += sizeshift;
|
||||||
|
+ FcPatternDel(pattern, FC_PIXEL_SIZE);
|
||||||
|
+ FcPatternDel(pattern, FC_SIZE);
|
||||||
|
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ FcPatternAddBool(pattern, FC_SCALABLE, 1);
|
||||||
|
+
|
||||||
|
+ FcConfigSubstitute(NULL, pattern, FcMatchPattern);
|
||||||
|
+ XftDefaultSubstitute(xw.dpy, xw.scr, pattern);
|
||||||
|
+
|
||||||
|
+ if (xloadsparefont(pattern, FRC_NORMAL))
|
||||||
|
+ die("can't open spare font %s\n", *fp);
|
||||||
|
+
|
||||||
|
+ FcPatternDel(pattern, FC_SLANT);
|
||||||
|
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
|
||||||
|
+ if (xloadsparefont(pattern, FRC_ITALIC))
|
||||||
|
+ die("can't open spare font %s\n", *fp);
|
||||||
|
+
|
||||||
|
+ FcPatternDel(pattern, FC_WEIGHT);
|
||||||
|
+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
|
||||||
|
+ if (xloadsparefont(pattern, FRC_ITALICBOLD))
|
||||||
|
+ die("can't open spare font %s\n", *fp);
|
||||||
|
+
|
||||||
|
+ FcPatternDel(pattern, FC_SLANT);
|
||||||
|
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
|
||||||
|
+ if (xloadsparefont(pattern, FRC_BOLD))
|
||||||
|
+ die("can't open spare font %s\n", *fp);
|
||||||
|
+
|
||||||
|
+ FcPatternDestroy(pattern);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
xunloadfont(Font *f)
|
||||||
|
{
|
||||||
|
@@ -1131,6 +1229,9 @@ xinit(int cols, int rows)
|
||||||
|
usedfont = (opt_font == NULL)? font : opt_font;
|
||||||
|
xloadfonts(usedfont, 0);
|
||||||
|
|
||||||
|
+ /* spare fonts */
|
||||||
|
+ xloadsparefonts();
|
||||||
|
+
|
||||||
|
/* colors */
|
||||||
|
xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
|
||||||
|
xloadcols();
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
|
@ -0,0 +1,206 @@
|
||||||
|
From 68de38fadd04f2f454bceccea0fccc8276b635cb Mon Sep 17 00:00:00 2001
|
||||||
|
From: wael <40663@protonmail.com>
|
||||||
|
Date: Mon, 11 Apr 2022 16:45:49 +0300
|
||||||
|
Subject: [PATCH] add glyph wide support patch
|
||||||
|
|
||||||
|
---
|
||||||
|
st.h | 6 +++
|
||||||
|
x.c | 134 +++++++++++++++++++++++++++++------------------------------
|
||||||
|
2 files changed, 73 insertions(+), 67 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/st.h b/st.h
|
||||||
|
index 519b9bd..4f74621 100644
|
||||||
|
--- a/st.h
|
||||||
|
+++ b/st.h
|
||||||
|
@@ -36,6 +36,12 @@ enum glyph_attribute {
|
||||||
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
|
};
|
||||||
|
|
||||||
|
+enum drawing_mode {
|
||||||
|
+ DRAW_NONE = 0,
|
||||||
|
+ DRAW_BG = 1 << 0,
|
||||||
|
+ DRAW_FG = 1 << 1,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
enum selection_mode {
|
||||||
|
SEL_IDLE = 0,
|
||||||
|
SEL_EMPTY = 1,
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
index 2a3bd38..d60df52 100644
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -142,7 +142,7 @@ typedef struct {
|
||||||
|
|
||||||
|
static inline ushort sixd_to_16bit(int);
|
||||||
|
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
|
||||||
|
-static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
|
||||||
|
+static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int, int);
|
||||||
|
static void xdrawglyph(Glyph, int, int);
|
||||||
|
static void xclear(int, int, int, int);
|
||||||
|
static int xgeommasktogravity(int);
|
||||||
|
@@ -1372,7 +1372,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
-xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
|
||||||
|
+xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y, int dmode)
|
||||||
|
{
|
||||||
|
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
|
||||||
|
int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
|
||||||
|
@@ -1463,47 +1463,40 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
|
if (base.mode & ATTR_INVISIBLE)
|
||||||
|
fg = bg;
|
||||||
|
|
||||||
|
- /* Intelligent cleaning up of the borders. */
|
||||||
|
- if (x == 0) {
|
||||||
|
- xclear(0, (y == 0)? 0 : winy, borderpx,
|
||||||
|
- winy + win.ch +
|
||||||
|
- ((winy + win.ch >= borderpx + win.th)? win.h : 0));
|
||||||
|
- }
|
||||||
|
- if (winx + width >= borderpx + win.tw) {
|
||||||
|
- xclear(winx + width, (y == 0)? 0 : winy, win.w,
|
||||||
|
- ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
|
||||||
|
- }
|
||||||
|
- if (y == 0)
|
||||||
|
- xclear(winx, 0, winx + width, borderpx);
|
||||||
|
- if (winy + win.ch >= borderpx + win.th)
|
||||||
|
- xclear(winx, winy + win.ch, winx + width, win.h);
|
||||||
|
-
|
||||||
|
- /* Clean up the region we want to draw to. */
|
||||||
|
- XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
||||||
|
-
|
||||||
|
- /* Set the clip region because Xft is sometimes dirty. */
|
||||||
|
- r.x = 0;
|
||||||
|
- r.y = 0;
|
||||||
|
- r.height = win.ch;
|
||||||
|
- r.width = width;
|
||||||
|
- XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
|
||||||
|
-
|
||||||
|
- /* Render the glyphs. */
|
||||||
|
- XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
|
||||||
|
-
|
||||||
|
- /* Render underline and strikethrough. */
|
||||||
|
- if (base.mode & ATTR_UNDERLINE) {
|
||||||
|
- XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1,
|
||||||
|
- width, 1);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (base.mode & ATTR_STRUCK) {
|
||||||
|
- XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
|
||||||
|
- width, 1);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Reset clip to none. */
|
||||||
|
- XftDrawSetClip(xw.draw, 0);
|
||||||
|
+ if (dmode & DRAW_BG) {
|
||||||
|
+ /* Intelligent cleaning up of the borders. */
|
||||||
|
+ if (x == 0) {
|
||||||
|
+ xclear(0, (y == 0)? 0 : winy, borderpx,
|
||||||
|
+ winy + win.ch +
|
||||||
|
+ ((winy + win.ch >= borderpx + win.th)? win.h : 0));
|
||||||
|
+ }
|
||||||
|
+ if (winx + width >= borderpx + win.tw) {
|
||||||
|
+ xclear(winx + width, (y == 0)? 0 : winy, win.w,
|
||||||
|
+ ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
|
||||||
|
+ }
|
||||||
|
+ if (y == 0)
|
||||||
|
+ xclear(winx, 0, winx + width, borderpx);
|
||||||
|
+ if (winy + win.ch >= borderpx + win.th)
|
||||||
|
+ xclear(winx, winy + win.ch, winx + width, win.h);
|
||||||
|
+ /* Fill the background */
|
||||||
|
+ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (dmode & DRAW_FG) {
|
||||||
|
+ /* Render the glyphs. */
|
||||||
|
+ XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
|
||||||
|
+
|
||||||
|
+ /* Render underline and strikethrough. */
|
||||||
|
+ if (base.mode & ATTR_UNDERLINE) {
|
||||||
|
+ XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
|
||||||
|
+ width, 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (base.mode & ATTR_STRUCK) {
|
||||||
|
+ XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
|
||||||
|
+ width, 1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -1513,7 +1506,7 @@ xdrawglyph(Glyph g, int x, int y)
|
||||||
|
XftGlyphFontSpec spec;
|
||||||
|
|
||||||
|
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
|
||||||
|
- xdrawglyphfontspecs(&spec, g, numspecs, x, y);
|
||||||
|
+ xdrawglyphfontspecs(&spec, g, numspecs, x, y, DRAW_BG | DRAW_FG);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -1648,32 +1641,39 @@ xstartdraw(void)
|
||||||
|
void
|
||||||
|
xdrawline(Line line, int x1, int y1, int x2)
|
||||||
|
{
|
||||||
|
- int i, x, ox, numspecs;
|
||||||
|
+ int i, x, ox, numspecs, numspecs_cached;
|
||||||
|
Glyph base, new;
|
||||||
|
- XftGlyphFontSpec *specs = xw.specbuf;
|
||||||
|
-
|
||||||
|
- numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
|
||||||
|
- i = ox = 0;
|
||||||
|
- for (x = x1; x < x2 && i < numspecs; x++) {
|
||||||
|
- new = line[x];
|
||||||
|
- if (new.mode == ATTR_WDUMMY)
|
||||||
|
- continue;
|
||||||
|
- if (selected(x, y1))
|
||||||
|
- new.mode ^= ATTR_REVERSE;
|
||||||
|
- if (i > 0 && ATTRCMP(base, new)) {
|
||||||
|
- xdrawglyphfontspecs(specs, base, i, ox, y1);
|
||||||
|
- specs += i;
|
||||||
|
- numspecs -= i;
|
||||||
|
- i = 0;
|
||||||
|
- }
|
||||||
|
- if (i == 0) {
|
||||||
|
- ox = x;
|
||||||
|
- base = new;
|
||||||
|
+ XftGlyphFontSpec *specs;
|
||||||
|
+
|
||||||
|
+ numspecs_cached = xmakeglyphfontspecs(xw.specbuf, &line[x1], x2 - x1, x1, y1);
|
||||||
|
+
|
||||||
|
+ /* Draw line in 2 passes: background and foreground. This way wide glyphs
|
||||||
|
+ won't get truncated (#223) */
|
||||||
|
+ for (int dmode = DRAW_BG; dmode <= DRAW_FG; dmode <<= 1) {
|
||||||
|
+ specs = xw.specbuf;
|
||||||
|
+ numspecs = numspecs_cached;
|
||||||
|
+ i = ox = 0;
|
||||||
|
+ for (x = x1; x < x2 && i < numspecs; x++) {
|
||||||
|
+ new = line[x];
|
||||||
|
+ if (new.mode == ATTR_WDUMMY)
|
||||||
|
+ continue;
|
||||||
|
+ if (selected(x, y1))
|
||||||
|
+ new.mode ^= ATTR_REVERSE;
|
||||||
|
+ if (i > 0 && ATTRCMP(base, new)) {
|
||||||
|
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
||||||
|
+ specs += i;
|
||||||
|
+ numspecs -= i;
|
||||||
|
+ i = 0;
|
||||||
|
+ }
|
||||||
|
+ if (i == 0) {
|
||||||
|
+ ox = x;
|
||||||
|
+ base = new;
|
||||||
|
+ }
|
||||||
|
+ i++;
|
||||||
|
}
|
||||||
|
- i++;
|
||||||
|
+ if (i > 0)
|
||||||
|
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
||||||
|
}
|
||||||
|
- if (i > 0)
|
||||||
|
- xdrawglyphfontspecs(specs, base, i, ox, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
6
st.h
6
st.h
|
@ -36,6 +36,12 @@ enum glyph_attribute {
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum drawing_mode {
|
||||||
|
DRAW_NONE = 0,
|
||||||
|
DRAW_BG = 1 << 0,
|
||||||
|
DRAW_FG = 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
enum selection_mode {
|
enum selection_mode {
|
||||||
SEL_IDLE = 0,
|
SEL_IDLE = 0,
|
||||||
SEL_EMPTY = 1,
|
SEL_EMPTY = 1,
|
||||||
|
|
44
x.c
44
x.c
|
@ -142,7 +142,7 @@ typedef struct {
|
||||||
|
|
||||||
static inline ushort sixd_to_16bit(int);
|
static inline ushort sixd_to_16bit(int);
|
||||||
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
|
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
|
||||||
static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
|
static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int, int);
|
||||||
static void xdrawglyph(Glyph, int, int);
|
static void xdrawglyph(Glyph, int, int);
|
||||||
static void xclear(int, int, int, int);
|
static void xclear(int, int, int, int);
|
||||||
static int xgeommasktogravity(int);
|
static int xgeommasktogravity(int);
|
||||||
|
@ -1372,7 +1372,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
|
xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y, int dmode)
|
||||||
{
|
{
|
||||||
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
|
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
|
||||||
int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
|
int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
|
||||||
|
@ -1463,6 +1463,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
if (base.mode & ATTR_INVISIBLE)
|
if (base.mode & ATTR_INVISIBLE)
|
||||||
fg = bg;
|
fg = bg;
|
||||||
|
|
||||||
|
if (dmode & DRAW_BG) {
|
||||||
/* Intelligent cleaning up of the borders. */
|
/* Intelligent cleaning up of the borders. */
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
xclear(0, (y == 0)? 0 : winy, borderpx,
|
xclear(0, (y == 0)? 0 : winy, borderpx,
|
||||||
|
@ -1477,33 +1478,25 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
xclear(winx, 0, winx + width, borderpx);
|
xclear(winx, 0, winx + width, borderpx);
|
||||||
if (winy + win.ch >= borderpx + win.th)
|
if (winy + win.ch >= borderpx + win.th)
|
||||||
xclear(winx, winy + win.ch, winx + width, win.h);
|
xclear(winx, winy + win.ch, winx + width, win.h);
|
||||||
|
/* Fill the background */
|
||||||
/* Clean up the region we want to draw to. */
|
|
||||||
XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the clip region because Xft is sometimes dirty. */
|
if (dmode & DRAW_FG) {
|
||||||
r.x = 0;
|
|
||||||
r.y = 0;
|
|
||||||
r.height = win.ch;
|
|
||||||
r.width = width;
|
|
||||||
XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
|
|
||||||
|
|
||||||
/* Render the glyphs. */
|
/* Render the glyphs. */
|
||||||
XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
|
XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
|
||||||
|
|
||||||
/* Render underline and strikethrough. */
|
/* Render underline and strikethrough. */
|
||||||
if (base.mode & ATTR_UNDERLINE) {
|
if (base.mode & ATTR_UNDERLINE) {
|
||||||
XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1,
|
XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
|
||||||
width, 1);
|
width, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.mode & ATTR_STRUCK) {
|
if (base.mode & ATTR_STRUCK) {
|
||||||
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
|
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
|
||||||
width, 1);
|
width, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Reset clip to none. */
|
|
||||||
XftDrawSetClip(xw.draw, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1513,7 +1506,7 @@ xdrawglyph(Glyph g, int x, int y)
|
||||||
XftGlyphFontSpec spec;
|
XftGlyphFontSpec spec;
|
||||||
|
|
||||||
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
|
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
|
||||||
xdrawglyphfontspecs(&spec, g, numspecs, x, y);
|
xdrawglyphfontspecs(&spec, g, numspecs, x, y, DRAW_BG | DRAW_FG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1648,11 +1641,17 @@ xstartdraw(void)
|
||||||
void
|
void
|
||||||
xdrawline(Line line, int x1, int y1, int x2)
|
xdrawline(Line line, int x1, int y1, int x2)
|
||||||
{
|
{
|
||||||
int i, x, ox, numspecs;
|
int i, x, ox, numspecs, numspecs_cached;
|
||||||
Glyph base, new;
|
Glyph base, new;
|
||||||
XftGlyphFontSpec *specs = xw.specbuf;
|
XftGlyphFontSpec *specs;
|
||||||
|
|
||||||
numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
|
numspecs_cached = xmakeglyphfontspecs(xw.specbuf, &line[x1], x2 - x1, x1, y1);
|
||||||
|
|
||||||
|
/* Draw line in 2 passes: background and foreground. This way wide glyphs
|
||||||
|
won't get truncated (#223) */
|
||||||
|
for (int dmode = DRAW_BG; dmode <= DRAW_FG; dmode <<= 1) {
|
||||||
|
specs = xw.specbuf;
|
||||||
|
numspecs = numspecs_cached;
|
||||||
i = ox = 0;
|
i = ox = 0;
|
||||||
for (x = x1; x < x2 && i < numspecs; x++) {
|
for (x = x1; x < x2 && i < numspecs; x++) {
|
||||||
new = line[x];
|
new = line[x];
|
||||||
|
@ -1661,7 +1660,7 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||||
if (selected(x, y1))
|
if (selected(x, y1))
|
||||||
new.mode ^= ATTR_REVERSE;
|
new.mode ^= ATTR_REVERSE;
|
||||||
if (i > 0 && ATTRCMP(base, new)) {
|
if (i > 0 && ATTRCMP(base, new)) {
|
||||||
xdrawglyphfontspecs(specs, base, i, ox, y1);
|
xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
||||||
specs += i;
|
specs += i;
|
||||||
numspecs -= i;
|
numspecs -= i;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -1673,7 +1672,8 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
xdrawglyphfontspecs(specs, base, i, ox, y1);
|
xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue