aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-05-04 08:48:01 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-05-04 08:48:01 +0000
commitf08f880911c302a22bd20ab39554f67515ec8656 (patch)
tree94b63e82de88f266513d68bbfab4b0bafa4790bd
parentMerge branch 'bg-alpha-on-default-bg-only' (diff)
parentbox-drawing: add Unicode 13 U+1FB70 - U+1FB8B (diff)
Merge branch 'more-unicode-13-box-drawings'
Related to #471
-rw-r--r--CHANGELOG.md3
-rw-r--r--box-drawing.c229
-rw-r--r--render.c31
-rw-r--r--terminal.h3
4 files changed, 260 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4dad6011..73ae227e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,9 @@
(https://codeberg.org/dnkl/foot/issues/459).
* `cursor.beam-thickness` option to `foot.ini`
(https://codeberg.org/dnkl/foot/issues/464).
+* Unicode 13 characters U+1FB70 - U+1FB8B to list of box drawing
+ characters rendered by foot itself (rather than using font glyphs)
+ (https://codeberg.org/dnkl/foot/issues/471).
### Changed
diff --git a/box-drawing.c b/box-drawing.c
index db0281bd..5701bf46 100644
--- a/box-drawing.c
+++ b/box-drawing.c
@@ -1520,6 +1520,36 @@ draw_lower_seven_eighths_block(struct buf *buf)
}
static void
+draw_upper_one_quarter_block(struct buf *buf)
+{
+ rect(0, 0, buf->width, round(buf->height / 4.));
+}
+
+static void
+draw_upper_three_eighths_block(struct buf *buf)
+{
+ rect(0, 0, buf->width, round(3. * buf->height / 8.));
+}
+
+static void
+draw_upper_five_eighths_block(struct buf *buf)
+{
+ rect(0, 0, buf->width, round(5. * buf->height / 8.));
+}
+
+static void
+draw_upper_three_quarters_block(struct buf *buf)
+{
+ rect(0, 0, buf->width, round(3. * buf->height / 4.));
+}
+
+static void
+draw_upper_seven_eighths_block(struct buf *buf)
+{
+ rect(0, 0, buf->width, round(7. * buf->height / 8.));
+}
+
+static void
draw_full_block(struct buf *buf)
{
rect(0, 0, buf->width, buf->height);
@@ -1562,9 +1592,53 @@ draw_left_one_quarter_block(struct buf *buf)
}
static void
+draw_vertical_one_eighth_block_n(struct buf *buf, int n)
+{
+ double x = round((double)n * buf->width / 8.);
+ double w = round(buf->width / 8.);
+ rect(x, 0, x + w, buf->height);
+}
+
+static void
draw_left_one_eighth_block(struct buf *buf)
{
- rect(0, 0, round(buf->width / 8.), buf->height);
+ draw_vertical_one_eighth_block_n(buf, 0);
+}
+
+static void
+draw_vertical_one_eighth_block_2(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 1);
+}
+
+static void
+draw_vertical_one_eighth_block_3(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 2);
+}
+
+static void
+draw_vertical_one_eighth_block_4(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 3);
+}
+
+static void
+draw_vertical_one_eighth_block_5(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 4);
+}
+
+static void
+draw_vertical_one_eighth_block_6(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 5);
+}
+
+static void
+draw_vertical_one_eighth_block_7(struct buf *buf)
+{
+ draw_vertical_one_eighth_block_n(buf, 6);
}
static void
@@ -1610,9 +1684,53 @@ draw_dark_shade(struct buf *buf)
}
static void
+draw_horizontal_one_eighth_block_n(struct buf *buf, int n)
+{
+ double y = round((double)n * buf->height / 8.);
+ double h = round(buf->height / 8.);
+ rect(0, y, buf->width, y + h);
+}
+
+static void
draw_upper_one_eighth_block(struct buf *buf)
{
- rect(0, 0, buf->width, round(buf->height / 8.));
+ draw_horizontal_one_eighth_block_n(buf, 0);
+}
+
+static void
+draw_horizontal_one_eighth_block_2(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 1);
+}
+
+static void
+draw_horizontal_one_eighth_block_3(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 2);
+}
+
+static void
+draw_horizontal_one_eighth_block_4(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 3);
+}
+
+static void
+draw_horizontal_one_eighth_block_5(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 4);
+}
+
+static void
+draw_horizontal_one_eighth_block_6(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 5);
+}
+
+static void
+draw_horizontal_one_eighth_block_7(struct buf *buf)
+{
+ draw_horizontal_one_eighth_block_n(buf, 6);
}
static void
@@ -1870,6 +1988,80 @@ draw_sextant(wchar_t wc, struct buf *buf)
}
static void
+draw_left_and_lower_one_eighth_block(struct buf *buf)
+{
+ draw_left_one_eighth_block(buf);
+ draw_lower_one_eighth_block(buf);
+}
+
+static void
+draw_left_and_upper_one_eighth_block(struct buf *buf)
+{
+ draw_left_one_eighth_block(buf);
+ draw_upper_one_eighth_block(buf);
+}
+
+static void
+draw_right_and_upper_one_eighth_block(struct buf *buf)
+{
+ draw_right_one_eighth_block(buf);
+ draw_upper_one_eighth_block(buf);
+}
+
+static void
+draw_right_and_lower_one_eighth_block(struct buf *buf)
+{
+ draw_right_one_eighth_block(buf);
+ draw_lower_one_eighth_block(buf);
+}
+
+static void
+draw_upper_and_lower_one_eighth_block(struct buf *buf)
+{
+ draw_upper_one_eighth_block(buf);
+ draw_lower_one_eighth_block(buf);
+}
+
+static void
+draw_horizontal_one_eighth_1358_block(struct buf *buf)
+{
+ draw_upper_one_eighth_block(buf);
+ draw_horizontal_one_eighth_block_3(buf);
+ draw_horizontal_one_eighth_block_5(buf);
+ draw_lower_one_eighth_block(buf);
+}
+
+static void
+draw_right_one_quarter_block(struct buf *buf)
+{
+ rect(buf->width - round(buf->width / 4.), 0, buf->width, buf->height);
+}
+
+static void
+draw_right_three_eighths_block(struct buf *buf)
+{
+ rect(buf->width - round(3. * buf->width / 8.), 0, buf->width, buf->height);
+}
+
+static void
+draw_right_five_eighths_block(struct buf *buf)
+{
+ rect(buf->width - round(5. * buf->width / 8.), 0, buf->width, buf->height);
+}
+
+static void
+draw_right_three_quarters_block(struct buf *buf)
+{
+ rect(buf->width - round(3. * buf->width / 4.), 0, buf->width, buf->height);
+}
+
+static void
+draw_right_seven_eighths_block(struct buf *buf)
+{
+ rect(buf->width - round(7. * buf->width / 8.), 0, buf->width, buf->height);
+}
+
+static void
draw_glyph(wchar_t wc, struct buf *buf)
{
IGNORE_WARNING("-Wpedantic")
@@ -2043,6 +2235,39 @@ draw_glyph(wchar_t wc, struct buf *buf)
case 0x259f: draw_quadrant_upper_right_and_lower_left_and_lower_right(buf); break;
case 0x1fb00 ... 0x1fb3b: draw_sextant(wc, buf); break;
+
+ case 0x1fb70: draw_vertical_one_eighth_block_2(buf); break;
+ case 0x1fb71: draw_vertical_one_eighth_block_3(buf); break;
+ case 0x1fb72: draw_vertical_one_eighth_block_4(buf); break;
+ case 0x1fb73: draw_vertical_one_eighth_block_5(buf); break;
+ case 0x1fb74: draw_vertical_one_eighth_block_6(buf); break;
+ case 0x1fb75: draw_vertical_one_eighth_block_7(buf); break;
+
+ case 0x1fb76: draw_horizontal_one_eighth_block_2(buf); break;
+ case 0x1fb77: draw_horizontal_one_eighth_block_3(buf); break;
+ case 0x1fb78: draw_horizontal_one_eighth_block_4(buf); break;
+ case 0x1fb79: draw_horizontal_one_eighth_block_5(buf); break;
+ case 0x1fb7a: draw_horizontal_one_eighth_block_6(buf); break;
+ case 0x1fb7b: draw_horizontal_one_eighth_block_7(buf); break;
+
+ case 0x1fb82: draw_upper_one_quarter_block(buf); break;
+ case 0x1fb83: draw_upper_three_eighths_block(buf); break;
+ case 0x1fb84: draw_upper_five_eighths_block(buf); break;
+ case 0x1fb85: draw_upper_three_quarters_block(buf); break;
+ case 0x1fb86: draw_upper_seven_eighths_block(buf); break;
+
+ case 0x1fb7c: draw_left_and_lower_one_eighth_block(buf); break;
+ case 0x1fb7d: draw_left_and_upper_one_eighth_block(buf); break;
+ case 0x1fb7e: draw_right_and_upper_one_eighth_block(buf); break;
+ case 0x1fb7f: draw_right_and_lower_one_eighth_block(buf); break;
+ case 0x1fb80: draw_upper_and_lower_one_eighth_block(buf); break;
+ case 0x1fb81: draw_horizontal_one_eighth_1358_block(buf); break;
+
+ case 0x1fb87: draw_right_one_quarter_block(buf); break;
+ case 0x1fb88: draw_right_three_eighths_block(buf); break;
+ case 0x1fb89: draw_right_five_eighths_block(buf); break;
+ case 0x1fb8a: draw_right_three_quarters_block(buf); break;
+ case 0x1fb8b: draw_right_seven_eighths_block(buf); break;
}
UNIGNORE_WARNINGS
diff --git a/render.c b/render.c
index 7d5dc8d7..9bcd11ba 100644
--- a/render.c
+++ b/render.c
@@ -484,12 +484,32 @@ render_cell(struct terminal *term, pixman_image_t *pix,
base = composed->base;
}
- if (unlikely((base >= 0x2500 && base <= 0x259f) ||
- (base >= 0x1fb00 && base <= 0x1fb3b)) &&
+ if (unlikely(
+ /* Classic box drawings */
+ (base >= 0x2500 && base <= 0x259f) ||
+
+ /*
+ * Unicode 13 "Symbols for Legacy Computing"
+ * sub-ranges below.
+ *
+ * Note, the full range is U+1FB00 - U+1FBF9
+ */
+
+ /* Unicode 13 sextants */
+ (base >= 0x1fb00 && base <= 0x1fb3b) ||
+
+ /* Unicode 13 partial blocks */
+ /* TODO: there's more here! */
+ (base >= 0x1fb70 && base <= 0x1fb8b)) &&
+
likely(!term->conf->box_drawings_uses_font_glyphs))
{
/* Box drawing characters */
- size_t idx = base >= 0x1fb00 ? base - 0x1fb00 + 160 : base - 0x2500;
+ size_t idx = base >= 0x1fb00
+ ? (base >= 0x1fb70
+ ? base - 0x1fb70 + 220
+ : base - 0x1fb00 + 160)
+ : base - 0x2500;
xassert(idx < ALEN(term->box_drawing));
if (likely(term->box_drawing[idx] != NULL))
@@ -3090,10 +3110,15 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
sixel_reflow(term);
+#if defined(_DEBUG) && LOG_ENABLE_DBG
LOG_DBG("resize: %dx%d, grid: cols=%d, rows=%d "
"(left-margin=%d, right-margin=%d, top-margin=%d, bottom-margin=%d)",
term->width, term->height, term->cols, term->rows,
term->margins.left, term->margins.right, term->margins.top, term->margins.bottom);
+#else
+ LOG_INFO("resize: %dx%d pixels, %dx%d chars",
+ term->width, term->height, term->cols, term->rows);
+#endif
if (term->scroll_region.start >= term->rows)
term->scroll_region.start = 0;
diff --git a/terminal.h b/terminal.h
index 3de7b8f4..0f8f52da 100644
--- a/terminal.h
+++ b/terminal.h
@@ -328,8 +328,9 @@ struct terminal {
/*
* 0-159: U+250U+259F
* 160-219: U+1FB00-1FB3B
+ * 220-247: U+1FB70-1FB8B
*/
- struct fcft_glyph *box_drawing[220];
+ struct fcft_glyph *box_drawing[248];
bool is_sending_paste_data;
ptmx_buffer_list_t ptmx_buffers;