Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Last active April 9, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StanAngeloff/743c1cbb7566b5f0d84aeb41503bb989 to your computer and use it in GitHub Desktop.
Save StanAngeloff/743c1cbb7566b5f0d84aeb41503bb989 to your computer and use it in GitHub Desktop.
rxvt-unicode 9.22 patches
Add space to extent_test_chars to have FontAwesome being recognized.
Fixes:
$ urxvt -fn "xft:FontAwesome"
urxvt: unable to calculate font width for 'FontAwesome:minspace=True', ignoring.
urxvt: unable to load base fontset, please specify a valid one using -fn, aborting.
Posted to upstream mailinglist:
http://lists.schmorp.de/pipermail/rxvt-unicode/2016q4/002308.html
Followed up in http://lists.schmorp.de/pipermail/rxvt-unicode/2017q4/002441.html
src/rxvtfont.C | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rxvtfont.C b/src/rxvtfont.C
index c56921c..5932f03 100644
--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -155,7 +155,7 @@ static const struct rxvt_fallback_font {
// these characters are used to guess the font height and width
// pango uses a similar algorithm and doesn't trust the font either.
static uint16_t extent_test_chars[] = {
- '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
+ ' ', '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
0x304c, 0x672c, // が本
};
--
2.10.0
diff --git a/config.h.in b/config.h.in
index 914d6062..2e2e03f3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -18,6 +18,9 @@
/* Define if you want your background to use the parent window background */
#undef ENABLE_TRANSPARENCY
+/* Define if you want to display wide glyphs */
+#undef ENABLE_WIDE_GLYPHS
+
/* Define if you want european extended codesets */
#undef ENCODING_EU
diff --git a/configure b/configure
index 3e3f78bd..b8b1591d 100755
--- a/configure
+++ b/configure
@@ -717,6 +717,7 @@ enable_unicode3
enable_combining
enable_xft
enable_font_styles
+enable_wide_glyphs
enable_pixbuf
enable_startup_notification
enable_transparency
@@ -1390,6 +1391,7 @@ Optional Features:
--enable-combining enable composition of base and combining characters
--enable-xft enable xft support on systems that have it
--enable-font-styles enable bold and italic support
+ --enable-wide-glyphs enable displaying of wide glyphs
--enable-pixbuf enable integration with gdk-pixbuf for background images
--enable-startup-notification enable freedesktop startup notification support
--enable-transparency enable transparent backgrounds
@@ -4780,6 +4782,7 @@ if test "${enable_everything+set}" = set; then :
support_8bitctrls=no
support_iso14755=no
support_styles=no
+ support_wide_glyphs=no
support_perl=no
codesets=
fi
@@ -4808,6 +4811,7 @@ if test "${enable_everything+set}" = set; then :
#support_8bitctrls=yes
support_iso14755=yes
support_styles=yes
+ support_wide_glyphs=yes
support_perl=yes
codesets=all
fi
@@ -4909,6 +4913,14 @@ if test "${enable_font_styles+set}" = set; then :
fi
+# Check whether --enable-wide-glyphs was given.
+if test "${enable_wide_glyphs+set}" = set; then :
+ enableval=$enable_wide_glyphs; if test x$enableval = xyes -o x$enableval = xno; then
+ support_wide_glyphs=$enableval
+ fi
+fi
+
+
# Check whether --enable-pixbuf was given.
if test "${enable_pixbuf+set}" = set; then :
enableval=$enable_pixbuf; if test x$enableval = xyes -o x$enableval = xno; then
@@ -7733,6 +7745,11 @@ if test x$support_styles = xyes; then
$as_echo "#define ENABLE_STYLES 1" >>confdefs.h
+fi
+if test x$support_wide_glyphs = xyes; then
+
+$as_echo "#define ENABLE_WIDE_GLYPHS 1" >>confdefs.h
+
fi
if test x$support_iso14755 = xyes; then
diff --git a/configure.ac b/configure.ac
index 0da3b596..52ab8e4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,6 +132,7 @@ AC_ARG_ENABLE(everything,
support_8bitctrls=no
support_iso14755=no
support_styles=no
+ support_wide_glyphs=no
support_perl=no
codesets=
fi
@@ -160,6 +161,7 @@ AC_ARG_ENABLE(everything,
#support_8bitctrls=yes
support_iso14755=yes
support_styles=yes
+ support_wide_glyphs=yes
support_perl=yes
codesets=all
fi
@@ -225,6 +227,12 @@ AC_ARG_ENABLE(font-styles,
support_styles=$enableval
fi])
+AC_ARG_ENABLE(wide-glyphs,
+ [ --enable-wide-glyphs enable displaying of wide glyphs],
+ [if test x$enableval = xyes -o x$enableval = xno; then
+ support_wide_glyphs=$enableval
+ fi])
+
AC_ARG_ENABLE(pixbuf,
[ --enable-pixbuf enable integration with gdk-pixbuf for background images],
[if test x$enableval = xyes -o x$enableval = xno; then
@@ -648,6 +656,9 @@ fi
if test x$support_styles = xyes; then
AC_DEFINE(ENABLE_STYLES, 1, Define if you want bold and italic support)
fi
+if test x$support_wide_glyphs = xyes; then
+ AC_DEFINE(ENABLE_WIDE_GLYPHS, 1, Define if you want to display wide glyphs)
+fi
if test x$support_iso14755 = xyes; then
AC_DEFINE(ISO_14755, 1, Define if you want ISO 14755 extended support)
fi
diff --git a/src/command.C b/src/command.C
index 19e4fccf..75853d75 100644
--- a/src/command.C
+++ b/src/command.C
@@ -237,7 +237,9 @@ rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y, int y2)
# endif
scr_overlay_set (11, y + 1, ch, r);
+#if !ENABLE_WIDE_GLYPHS
if (WCWIDTH (ch) >= 2)
+#endif
scr_overlay_set (12, y + 1, NOCHAR, r);
}
diff --git a/src/rxvtfont.C b/src/rxvtfont.C
index c56921c8..9d75541a 100644
--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -471,6 +471,7 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
else
switch (t)
{
+ case ' ':
case '\t':
case ZERO_WIDTH_CHAR:
case NOCHAR:
@@ -1026,8 +1027,10 @@ rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &car
careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw;
+#if !ENABLE_WIDE_GLYPHS
if (careful && !OVERLAP_OK (w, wcw, prop))
return false;
+#endif
return true;
}
@@ -1345,12 +1348,14 @@ rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &car
careful = g.x > 0 || w > prop->width * wcw;
+#if !ENABLE_WIDE_GLYPHS
if (careful && !OVERLAP_OK (w, wcw, prop))
return false;
// this weeds out _totally_ broken fonts, or glyphs
if (!OVERLAP_OK (g.xOff, wcw, prop))
return false;
+#endif
return true;
}
@@ -1395,6 +1400,10 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
ep->glyph = glyph;
ep->x = x_ + (cwidth - extents.xOff >> 1);
+#if ENABLE_WIDE_GLYPHS
+ /* Left-align to bounding box, do not overlap to the left. */
+ max_it(ep->x, x_);
+#endif
ep->y = y_ + ascent;
if (extents.xOff == 0)
diff --git a/src/screen.C b/src/screen.C
index 115afbf2..61681b84 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -936,7 +936,61 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
# endif
#endif
- rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
+ rend_t rend;
+#if ENABLE_WIDE_GLYPHS
+ // Re-use previous font for space characters.
+ // This allows for better display of wider chars with regard to
+ // backtracking (which uses RS_SAME).
+ if (c != ' ')
+ {
+#endif
+ rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
+#if ENABLE_WIDE_GLYPHS
+
+ }
+ else
+ {
+ // Code taken from ENABLE_COMBINING - might get refactored.
+ line_t *linep;
+ text_t *tp;
+ rend_t *rp = NULL;
+
+ if (screen.cur.col > 0)
+ {
+ linep = line;
+ tp = line->t + screen.cur.col - 1;
+ rp = line->r + screen.cur.col - 1;
+ }
+ else if (screen.cur.row > 0
+ && ROW(screen.cur.row - 1).is_longer ())
+ {
+ linep = &ROW(screen.cur.row - 1);
+ tp = linep->t + ncol - 1;
+ rp = linep->r + ncol - 1;
+ }
+
+ if (rp)
+ {
+ // XXX: this font does not show up in iso-14755 mode for the space!?
+ if (*tp == NOCHAR)
+ {
+ while (*tp == NOCHAR && tp > linep->t)
+ tp--, rp--;
+
+ // first try to find a precomposed character
+ unicode_t n = rxvt_compose (*tp, c);
+ if (n == NOCHAR)
+ n = rxvt_composite.compose (*tp, c);
+
+ *tp = n;
+ *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
+ }
+ rend = SET_FONT (rstyle, GET_FONT(*rp));
+ }
+ else
+ rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
+ }
+#endif
// if the character doesn't fit into the remaining columns...
if (ecb_unlikely (screen.cur.col > ncol - width && ncol >= width))
@@ -2387,7 +2441,12 @@ rxvt_term::scr_refresh () NOTHROW
text--, count++, xpixel -= fwidth;
// force redraw after "careful" characters to avoid pixel droppings
- for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
+ for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1
+#if ENABLE_WIDE_GLYPHS
+ // But not for spaces.
+ && stp[col + i + 1] != ' '
+#endif
+ ; i++)
drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw;
// force redraw before "careful" characters to avoid pixel droppings
diff --git a/src/xdefaults.C b/src/xdefaults.C
index 9b47bf2c..add21eec 100644
--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -294,6 +294,9 @@ static const char optionsstring[] = "options: "
#if ENABLE_STYLES
"styles,"
#endif
+#if ENABLE_WIDE_GLYPHS
+ "wide-glyphs,"
+#endif
#if ENABLE_COMBINING
"combining,"
#endif
diff --git a/wide-glyphs-after.png b/wide-glyphs-after.png
new file mode 100644
index 00000000..5661ea79
Binary files /dev/null and b/wide-glyphs-after.png differ
diff --git a/wide-glyphs-before.png b/wide-glyphs-before.png
new file mode 100644
index 00000000..71ae7d5d
Binary files /dev/null and b/wide-glyphs-before.png differ
commit bec3f19
Author: Emanuele Giaquinta <e.giaquinta@glauco.it>
Date: Tue Jun 28 21:56:17 2016 +0000
Fix invalid moves when smart resize is enabled and the wm uses X11 borders for the frame windows.
Patch by Uli Schlachter.
---
src/main.C | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/main.C b/src/main.C
index 39aa5ec..5fa605e 100644
--- a/src/main.C
+++ b/src/main.C
@@ -1054,6 +1054,25 @@ rxvt_term::alias_color (int dst, int src)
pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]);
}
+#ifdef SMART_RESIZE
+static unsigned int
+get_parent_bw (Display *dpy, Window w)
+{
+ int idummy;
+ unsigned int udummy;
+ Window wdummy, parent;
+ Window *children;
+ unsigned int nchildren, border_width;
+
+ XQueryTree (dpy, w, &wdummy, &parent, &children, &nchildren);
+ XFree (children);
+ XGetGeometry (dpy, parent, &wdummy, &idummy, &idummy,
+ &udummy, &udummy, &border_width, &udummy);
+
+ return border_width;
+}
+#endif
+
/* -------------------------------------------------------------------- *
* - WINDOW RESIZING - *
* -------------------------------------------------------------------- */
@@ -1098,8 +1117,10 @@ rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, in
*/
if (x1 != x || y1 != y)
{
- x -= x1;
- y -= y1;
+ unsigned int border_width = get_parent_bw (dpy, parent);
+
+ x -= x1 + border_width;
+ y -= y1 + border_width;
}
x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
--- src/rxvtfont.C.bukind 2007-11-30 14:36:33.000000000 +0600
+++ src/rxvtfont.C 2007-11-30 14:39:29.000000000 +0600
@@ -1171,12 +1171,21 @@
XGlyphInfo g;
XftTextExtents16 (disp, f, &ch, 1, &g);
+/*
+ * bukind: don't use g.width as a width of a character!
+ * instead use g.xOff, see e.g.: http://keithp.com/~keithp/render/Xft.tutorial
+
g.width -= g.x;
int wcw = WCWIDTH (ch);
if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;
if (width < g.width ) width = g.width;
+ */
+ int wcw = WCWIDTH (ch);
+ if (wcw > 1) g.xOff = g.xOff / wcw;
+ if (width < g.xOff) width = g.xOff;
+
if (height < g.height ) height = g.height;
if (glheight < g.height - g.y) glheight = g.height - g.y;
}
--- src/rxvtfont.C.orig 2011-07-20 22:19:29.878012201 -0300
+++ src/rxvtfont.C 2011-07-20 22:19:33.634671723 -0300
@@ -1237,11 +1237,22 @@
FT_Face face = XftLockFace (f);
+/*
+ * use ascent, descent and height from XftFont *f instead of FT_Face face.
+ * this somehow reproduces the behaviour of the line height as seen on xterm.
+
ascent = (face->size->metrics.ascender + 63) >> 6;
descent = (-face->size->metrics.descender + 63) >> 6;
height = max (ascent + descent, (face->size->metrics.height + 63) >> 6);
width = 0;
+ */
+
+ ascent = f->ascent;
+ descent = f->descent;
+ height = max (ascent + descent, f->height);
+ width = 0;
+
bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE;
XftUnlockFace (f);
--- src/command.C.orig 2019-03-04 10:17:27.883887432 +0200
+++ src/command.C 2019-03-04 10:17:36.823993112 +0200
@@ -788,7 +788,7 @@
}
}
- if (ctrl && meta && (keysym == XK_c || keysym == XK_v))
+ if (ctrl && shft && (keysym == XK_c || keysym == XK_v))
{
if (keysym == XK_v)
selection_request (ev.time, Sel_Clipboard);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment