summarylogtreecommitdiffstats
path: root/unicode32.patch
blob: d83433957bcc4b6553042ccd0f6b93d6251ee2fb (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
diff --git a/lemonbar.c b/lemonbar.c
index 2dafecf..8cdd440 100644
--- a/lemonbar.c
+++ b/lemonbar.c
@@ -225,7 +225,7 @@ xcb_void_cookie_t xcb_poly_text_16_simple(xcb_connection_t * c,
 
 
 int
-xft_char_width_slot (uint16_t ch)
+xft_char_width_slot (uint32_t ch)
 {
     int slot = ch % MAX_WIDTHS;
     while (xft_char[slot] != 0 && xft_char[slot] != ch)
@@ -235,7 +235,7 @@ xft_char_width_slot (uint16_t ch)
     return slot;
 }
 
-int xft_char_width (uint16_t ch, font_t *cur_font)
+int xft_char_width (uint32_t ch, font_t *cur_font)
 {
     int slot = xft_char_width_slot(ch);
     if (!xft_char[slot]) {
@@ -300,7 +300,7 @@ draw_shift (monitor_t *mon, int x, int align, int w)
 }
 
 int
-draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch)
+draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint32_t ch)
 {
     int ch_width;
 
@@ -316,15 +316,18 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch)
 
     int y = bh / 2 + cur_font->height / 2- cur_font->descent + offsets_y[offset_y_index];
     if (cur_font->xft_ft) {
-        XftDrawString16 (xft_draw, &sel_fg, cur_font->xft_ft, x,y, &ch, 1);
+        XftDrawString32 (xft_draw, &sel_fg, cur_font->xft_ft, x,y, &ch, 1);
     } else {
         /* xcb accepts string in UCS-2 BE, so swap */
-        ch = (ch >> 8) | (ch << 8);
+
+        uint16_t ch16 = (uint16_t) ch;
+
+        ch16 = (ch16 >> 8) | (ch16 << 8);
         
         // The coordinates here are those of the baseline
         xcb_poly_text_16_simple(c, mon->pixmap, gc[GC_DRAW],
                             x, y,
-                            1, &ch);
+                            1, &ch16);
     }
 
     draw_lines(mon, x, ch_width);
@@ -543,7 +546,7 @@ area_add (char *str, const char *optend, char **end, monitor_t *mon, const int x
 }
 
 bool
-font_has_glyph (font_t *font, const uint16_t c)
+font_has_glyph (font_t *font, const uint32_t c)
 {
     if (font->xft_ft) {
         if (XftCharExists(dpy, font->xft_ft, (FcChar32) c)) {
@@ -564,7 +567,7 @@ font_has_glyph (font_t *font, const uint16_t c)
 }
 
 font_t *
-select_drawable_font (const uint16_t c)
+select_drawable_font (const uint32_t c)
 {
     // If the user has specified a font to use, try that first.
     if (font_index != -1 && font_has_glyph(font_list[font_index - 1], c)) {
@@ -715,7 +718,7 @@ parse (char *text)
                 p++;
 
             uint8_t *utf = (uint8_t *)p;
-            uint16_t ucs;
+            uint32_t ucs;
 
             // ASCII
             if (utf[0] < 0x80) {
@@ -734,7 +737,10 @@ parse (char *text)
             }
             // Four byte utf8 sequence
             else if ((utf[0] & 0xf8) == 0xf0) {
-                ucs = 0xfffd;
+                ucs = (uint32_t)(utf[0] & 0x07) << 18 |
+      (uint32_t)(utf[1] & 0x3f) << 12 |
+      (uint32_t)(utf[2] & 0x3f) << 6 |
+      (uint32_t)(utf[3] & 0x3f);
                 p += 4;
             }
             // Five byte utf8 sequence