aboutsummaryrefslogtreecommitdiffstats
path: root/surfaces/width.c
diff options
context:
space:
mode:
Diffstat (limited to 'surfaces/width.c')
-rw-r--r--surfaces/width.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/surfaces/width.c b/surfaces/width.c
index 1e893f6..645e309 100644
--- a/surfaces/width.c
+++ b/surfaces/width.c
@@ -46,9 +46,15 @@ uint32_t vega_visible(uint32_t codepoint) {
if (codepoint < 0x20) return 0x2400 + codepoint;
if (codepoint == 0x7F) return 0x2421;
if (codepoint >= 0x80 && codepoint < 0xA0) return 0xFFFD;
+ if (codepoint == 0x2028 || codepoint == 0x2029) return 0x2424;
return codepoint;
}
+uint32_t vega_cell(uint32_t codepoint) {
+ if ((codepoint >= 0x202A && codepoint <= 0x202E) || (codepoint >= 0x2066 && codepoint <= 0x2069)) return 0xFFFD;
+ return vega_visible(codepoint);
+}
+
size_t vega_decode(const char *text, size_t length, size_t at, uint32_t *codepoint) {
const unsigned char *p = (const unsigned char *)text + at;
size_t left = length - at, need = p[0] < 0x80 ? 1 : p[0] < 0xE0 ? 2 : p[0] < 0xF0 ? 3 : 4;
@@ -64,7 +70,7 @@ unsigned vega_text_width(const char *text, size_t length) {
for (size_t at = 0; at < length;) {
uint32_t codepoint;
at += vega_decode(text, length, at, &codepoint);
- width += vega_width(vega_visible(codepoint));
+ width += vega_width(vega_cell(codepoint));
}
return width;
}