summarylogtreecommitdiffstats
path: root/enable-wide-glyphs.patch
blob: 0160324009f86665636e3f0d2ae9aeb743ec8ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
diff --git a/config.h.in b/config.h.in
index 9547145..d88d6cb 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 c756724..fc4fedd 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
@@ -4723,6 +4725,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
@@ -4751,6 +4754,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
@@ -4852,6 +4856,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
@@ -7684,6 +7696,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
 
 $as_echo "#define ISO_14755 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 813b16e..714b96f 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
@@ -660,6 +668,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/rxvtfont.C b/src/rxvtfont.C
index 5dcd125..b50b678 100644
--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -299,6 +299,9 @@ struct rxvt_font_default : rxvt_font {
   {
     careful = false;
 
+    if (unicode == 0x0020)
+      return true;
+
     if (unicode <= 0x001f)
       return true;
 
@@ -471,6 +474,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 +1030,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 +1351,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 +1403,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 41f874b..b7a8fd9 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -935,7 +935,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))
@@ -2399,7 +2453,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;
+#if ENABLE_WIDE_GLYPHS
+              // But not for spaces.
+                      stp[col + i + 1] != ' ' &&
+#endif
+                      srp[col + i] & RS_Careful && col + i < ncol - 1; 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 2308844..f7e034a 100644
--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -302,6 +302,9 @@ static const char optionsstring[] = "options: "
 #if ENABLE_STYLES
                                     "styles,"
 #endif
+#if ENABLE_WIDE_GLYPHS
+                                    "wide-glyphs,"
+#endif
 #if ENABLE_COMBINING
                                     "combining,"
 #endif