K.Takata's patch queue for Vim
Revision | ef90a5349fb709a6c697f4e43e6ba4c9136a4d36 (tree) |
---|---|
Zeit | 2022-01-21 16:28:43 |
Autor | K.Takata <kentkt@csc....> |
Commiter | K.Takata |
Update ambiwidth patch
@@ -58,7 +58,7 @@ | ||
58 | 58 | + //_RPT2(_CRT_WARN, "len %d, count %d", len, count); |
59 | 59 | + for (UINT32 i = 0; i < count; i++) |
60 | 60 | + { |
61 | -+ _RPT2(_CRT_WARN, "%x (%C), [%d]: width %f", c, c, i, metrics[i].width); | |
61 | ++ //_RPT2(_CRT_WARN, "%x (%C), [%d]: width %f", c, c, i, metrics[i].width); | |
62 | 62 | + } |
63 | 63 | +#endif |
64 | 64 | + if (count >= 1) |
@@ -103,16 +103,19 @@ | ||
103 | 103 | diff --git a/src/gui_w32.c b/src/gui_w32.c |
104 | 104 | --- a/src/gui_w32.c |
105 | 105 | +++ b/src/gui_w32.c |
106 | -@@ -5182,21 +5182,21 @@ error: | |
106 | +@@ -5181,30 +5181,41 @@ error: | |
107 | + #endif | |
107 | 108 | |
108 | 109 | #ifdef USE_AMBIWIDTH_AUTO |
109 | - # define CHARWIDE_CACHESIZE 0x20000 | |
110 | +-# define CHARWIDE_CACHESIZE 0x20000 | |
110 | 111 | -static GuiFont last_font = NOFONT; |
112 | ++# define CHARWIDE_CACHESIZE 0x40000 | |
111 | 113 | |
112 | 114 | int |
113 | 115 | gui_mch_get_charwidth(int c) |
114 | 116 | { |
115 | - static int cache[CHARWIDE_CACHESIZE]; | |
117 | +- static int cache[CHARWIDE_CACHESIZE]; | |
118 | ++ static char cache[CHARWIDE_CACHESIZE]; | |
116 | 119 | + static GuiFont last_font = NOFONT; |
117 | 120 | GuiFont usingfont = gui.wide_font ? gui.wide_font : gui.norm_font; |
118 | 121 |
@@ -127,8 +130,10 @@ | ||
127 | 130 | + TRACE("Charwidth cache will be updated (base=%d)\n", gui.char_width); |
128 | 131 | last_font = usingfont; |
129 | 132 | for (i = 0; i < CHARWIDE_CACHESIZE; ++i) |
130 | - cache[i] = -1; | |
131 | -@@ -5205,6 +5205,17 @@ gui_mch_get_charwidth(int c) | |
133 | +- cache[i] = -1; | |
134 | ++ cache[i] = (char)-1; | |
135 | + } | |
136 | + if (usingfont && 0 <= c && c < CHARWIDE_CACHESIZE) | |
132 | 137 | { |
133 | 138 | if (cache[c] >= 0) |
134 | 139 | return cache[c]; /* Use cached value */ |
@@ -139,7 +144,7 @@ | ||
139 | 144 | + |
140 | 145 | + DWriteContext_SetFont(s_dwc, (HFONT)usingfont); |
141 | 146 | + len = DWriteContext_GetCharWidth(s_dwc, c); |
142 | -+ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width; | |
147 | ++ cache[c] = (char)((len + (gui.char_width >> 1)) / gui.char_width); | |
143 | 148 | + return cache[c]; |
144 | 149 | + } |
145 | 150 | +# endif |
@@ -151,7 +156,7 @@ | ||
151 | 156 | } |
152 | 157 | else |
153 | 158 | - cache[c] = ((len + (gui.char_width >> 1)) / gui.char_width); |
154 | -+ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width; | |
159 | ++ cache[c] = (char)((len + (gui.char_width >> 1)) / gui.char_width); | |
155 | 160 | SelectFont(s_hdc, hfntOld); |
156 | 161 | |
157 | 162 | return cache[c]; |