From: Ben Harris Date: Tue, 23 Sep 2025 21:44:19 +0000 (+0100) Subject: Add support for generating 8-cell mosaic graphics X-Git-Tag: bedstead-3.261~85 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=c62b3925534a58d5e3d4a93e8c6b80b75bffc468;p=bedstead.git Add support for generating 8-cell mosaic graphics This follows the pattern of the 6-cell and 4-cell versions, but without separated mode because Unicode doesn't have that. This required making the bitmap data into an unsigned char array to allow for using all eight bits. The cell boundaries are chosen so that they line up with existing 6-cell and 4-cell boundaries. So we have row heights of [3,2,2,3], which is maybe less pretty than [3,2,3,2], but is more in keeping with the existing mosaics. Indeed, it means that the existing 4-cell and 6-cell contiguous characters could be expressed in 8-cell terms if I wanted to. --- diff --git a/bedstead.c b/bedstead.c index 7d98eae..d2b1de2 100644 --- a/bedstead.c +++ b/bedstead.c @@ -216,7 +216,7 @@ static struct weight const *weight = &weights[0]; static struct glyph { union { /* Top row (and left column) don't appear in ROM. */ - char data[YSIZE - 1]; + unsigned char data[YSIZE - 1]; char const *alias_of; int subr_idx; }; @@ -226,12 +226,13 @@ static struct glyph { #define SEP 0x01 /* Separated graphics */ #define MOS6 0x02 /* 6-cell mosaic graphics character */ #define MOS4 0x04 /* 4-cell mosaic graphics character */ +#define MOS8 0x08 /* 8-cell mosaic graphics character */ #define SEP6 (SEP | MOS6) #define SEP4 (SEP | MOS4) -#define JOIN_L 0x08 /* Copy left column leftward to join to next character. */ -#define JOIN_U 0x10 /* Copy top row upwards ditto. */ -#define JOIN_R 0x20 /* Pretend column to right is identical to right column. */ -#define JOIN_D 0x40 /* Similarly downwards. */ +#define JOIN_L 0x10 /* Copy left column leftward to join to next character. */ +#define JOIN_U 0x20 /* Copy top row upwards ditto. */ +#define JOIN_R 0x40 /* Pretend column to right is identical to right column. */ +#define JOIN_D 0x80 /* Similarly downwards. */ #define JOIN_H (JOIN_L | JOIN_R) #define JOIN_V (JOIN_U | JOIN_D) #define JOIN (JOIN_H | JOIN_V) @@ -3153,6 +3154,7 @@ static void dochar(struct glyph *g); static void dochar_plotter(struct glyph *g); static void domosaic(struct glyph *g); static void domosaic4(struct glyph *g); +static void domosaic8(struct glyph *g); static void dopanose(void); static void docmap(int pid, int eid, int format); static void dogsub(void); @@ -3165,7 +3167,7 @@ static void bdf_gen(int size); static void doglyph(struct glyph *); static bool -getpix(char const data[YSIZE - 1], int x, int y, unsigned flags) +getpix(unsigned char const data[YSIZE - 1], int x, int y, unsigned flags) { /* @@ -4124,7 +4126,7 @@ dosinglesubs(char const *suffix) } static int -glyph_footprint(char data[YSIZE - 1]) +glyph_footprint(unsigned char data[YSIZE - 1]) { int i; int footprint = 0; @@ -4214,6 +4216,8 @@ doglyph(struct glyph *g) domosaic(g); else if (g->flags & MOS4) domosaic4(g); + else if (g->flags & MOS8) + domosaic8(g); else if (plottermode) dochar_plotter(g); else @@ -5012,6 +5016,25 @@ domosaic4(struct glyph *g) emit_path(); } +static void +domosaic8(struct glyph *g) +{ + unsigned code = g->data[0]; + + clearpath(); + if (code & 1) tile(0, 7, 3, 10); + if (code & 2) tile(3, 7, 6, 10); + if (code & 4) tile(0, 5, 3, 7); + if (code & 8) tile(3, 5, 6, 7); + if (code & 16) tile(0, 3, 3, 5); + if (code & 32) tile(3, 3, 6, 5); + if (code & 64) tile(0, 0, 3, 3); + if (code & 128) tile(3, 0, 6, 3); + clean_path(); + record_lsb(g); + emit_path(); +} + static int byunicode(const void *va, const void *vb) {