AnalogTerm2: Font and DEC Special Graphics related changes:
authorMatthew Mondor <mmondor@pulsar-zone.net>
Fri, 2 Jun 2023 10:41:16 +0000 (10:41 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Fri, 2 Jun 2023 10:41:16 +0000 (10:41 +0000)
- DEC Special Graphics are now remapped to unicode glyphs internally,
  and the missing related glyphs have been implemented, meaning
  that under screen/tmux that also does that, they always display
  correctly without extra font-specific mapping.  This also allows
  loaded fonts to provide their own graphics characters, that also
  work in applications using the DEC feature like dialog(1).
- Copy-pasting of text under DEC Special Graphics charset used to
  return the corresponding ASCII characters.  These now return the
  unicode characters used to map/render them.
- The NBSP (Ux00a0) character is now included as part of the Latin-1
  glyphs.  This allows fonts that would like to distinguish the
  display of these from normal space to provide a glyph.
- Accept 'x' as an alternative to ',' for the -g command line option.
- Now check for large contiguous range blocks before glyph-order
  tables for glyph lookup.
- Properly mark as "defined" altered glyphs when the default font
  cannot be loaded because the font size is too small.

mmsoftware/analogterm2/src/font.c
mmsoftware/analogterm2/src/font.h
mmsoftware/analogterm2/src/font/analogterm_latin_9.png
mmsoftware/analogterm2/src/font/analogterm_latin_9.xbm
mmsoftware/analogterm2/src/font/analogterm_misc_9.png
mmsoftware/analogterm2/src/font/analogterm_misc_9.xbm
mmsoftware/analogterm2/src/main.c
mmsoftware/analogterm2/src/screen.c
mmsoftware/analogterm2/src/state.h
mmsoftware/analogterm2/tests/dec-graphics.txt [new file with mode: 0644]

index 84e8341..1737599 100644 (file)
@@ -39,7 +39,6 @@
 /* AnalogTerm font */
 
 #include "font/analogterm_unknown_9.xbm"
-#include "font/analogterm_dec_graphics_9.xbm"
 #include "font/analogterm_misc_9.xbm"
 #include "font/analogterm_ascii_9.xbm"
 #include "font/analogterm_latin_9.xbm"
@@ -61,6 +60,25 @@ static void  ftable_free(ftable_t *);
 static void    *font_glyph_new(state_t *, uint32_t);
 
 
+/* VT100 DEC Special Graphics to Unicode mapping. */
+const uint32_t decgfx_unicode_table[128] = {
+       0, 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 - 48, '+' - '0' Linux console extensions */
+       0x2192, 0x2190, 0x2191, 0x2193, 47, 0x25ae,
+       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, 93, 94,
+       /* 95 - 126, '_' - '~' VT100 DEC Special Graphics */
+       0x00a0,
+       0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1,
+       0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba,
+       0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c,
+       0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7,
+       127
+};
+
 /* Map of supported Latin-2 characters in glyph order. */
 static const uint32_t latin2_characters[59] = {
        0x0104, 0x02D8, 0x0141, 0x013D, 0x015A, 0x0160, 0x015E, 0x0164,
@@ -100,11 +118,14 @@ static uint32_t iso8859_14_characters[27] = {
        0x1EF2, 0x1EF3
 };
 
-/* Various characters including ISO-8859-15/16 */
-static const uint32_t misc_characters[24] = {
-       0x20AC, 0x01A9, 0x0283, 0x02D0, 0x0186, 0x0254, 0x039B, 0x03BB,
-       0x221E, 0x2122, 0x2026, 0x226E, 0x226F, 0x25A0, 0x25A1, 0x201E,
-       0xFFFD, 0x203E, 0x0152, 0x0153, 0x0178, 0x2018, 0x201C, 0x201D
+/* Various characters including DEC Special Graphics and ISO-8859-15/16 */
+static const uint32_t misc_characters[44] = {
+       0x2192, 0x2190, 0x2191, 0x2193, 0x25c6, 0x2409, 0x240c, 0x240d,
+       0x240a, 0x2424, 0x240b, 0x23ba, 0x23bb, 0x23bc, 0x23bd, 0x2264,
+       0x2265, 0x03c0, 0x2260, 0x20AC, 0x01A9, 0x0283, 0x02D0, 0x0186,
+       0x0254, 0x039B, 0x03BB, 0x221E, 0x2122, 0x2026, 0x226E, 0x226F,
+       0x25A0, 0x25A1, 0x201E, 0xFFFD, 0x203E, 0x0152, 0x0153, 0x0178,
+       0x2018, 0x201C, 0x201D, 0x2022
 };
 
 static screen_t        *scr = NULL;
@@ -389,8 +410,6 @@ font_init(state_t *state, screen_t *screen)
        /* Glyph order table sets */
        state->font_unknown = font_load(0, analogterm_unknown_9_bits,
            analogterm_unknown_9_width, analogterm_unknown_9_height);
-       state->font_decgfx = font_load(96, analogterm_dec_graphics_9_bits,
-           analogterm_dec_graphics_9_width, analogterm_dec_graphics_9_height);
        state->font_latin2 = font_load(0, analogterm_latin2_9_bits,
            analogterm_latin2_9_width, analogterm_latin2_9_height);
        state->font_latin3 = font_load(0, analogterm_latin3_9_bits,
@@ -422,7 +441,7 @@ font_init(state_t *state, screen_t *screen)
        /* Contiguous block sets */
        state->font = font_load(32, analogterm_ascii_9_bits,
            analogterm_ascii_9_width, analogterm_ascii_9_height);
-       state->font->next = font_load(161, analogterm_latin_9_bits,
+       state->font->next = font_load(160, analogterm_latin_9_bits,
            analogterm_latin_9_width, analogterm_latin_9_height);
        state->font->next->next = font_load(9472, analogterm_graphics1_9_bits,
            analogterm_graphics1_9_width, analogterm_graphics1_9_height);
@@ -499,8 +518,6 @@ font_cleanup(state_t *state)
        state->font_latin3 = NULL;
        font_free(state->font_latin2);
        state->font_latin2 = NULL;
-       font_free(state->font_decgfx);
-       state->font_decgfx = NULL;
 }
 
 void
@@ -531,6 +548,13 @@ font_glyph(state_t *state, uint32_t c, bool decgfx, bool raw)
        if (raw)
                goto raw;
 
+       /* DEC Special Graphics, translate to unicode. */
+       if (decgfx && c > 0 && c < 128)
+               c = decgfx_unicode_table[c];
+       /* Uppercase mode */
+       else if (cfg_uppercaseview && c > 96 && c < 123)
+               c -= 32;
+
        /*
         * Map unsupported glyphs to supported ones where relevant.
         * XXX May need a more generic mapping table eventually.
@@ -559,10 +583,6 @@ font_glyph(state_t *state, uint32_t c, bool decgfx, bool raw)
        case 0x021B:    /* ISO-8859-16 t comma -> t cedilla */
                c = 0x0163;
                break;
-       case 0x03C0:    /* Pi */
-               decgfx = true;
-               c = 123;
-               break;
        case 0x1D27:    /* Capital lambda */
                c = 0x039B;
                break;
@@ -594,35 +614,11 @@ font_glyph(state_t *state, uint32_t c, bool decgfx, bool raw)
        case 0x25B7:    /* White right-pointing triangle */
                c = 0x1FB6C;
                break;
-       case 0x2190:    /* Left arrow */
-               c = 0x1FBB5;
-               break;
-       case 0x2191:    /* Up arrow */
-               c = 0x1FBB8;
+       case 0x2a7d:    /* Less or equal */
+               c = 0x2264;
                break;
-       case 0x2192:    /* Right arrow */
-               c = 0x1FBB6;
-               break;
-       case 0x2193:    /* Down arrow */
-               c = 0x1FBB7;
-               break;
-       case 0x2022:    /* Bullet */
-               decgfx = true;
-               c = 96;
-               break;
-       case 0x2260:    /* Not equal */
-               decgfx = true;
-               c = 124;
-               break;
-       case 0x2264:    /* Less or equal */
-       case 0x2A7D:    /* FALLTHROUGH */
-               decgfx = true;
-               c = 121;
-               break;
-       case 0x2265:    /* Greater or equal */
-       case 0x2A7E:    /* FALLTHROUGH */
-               decgfx = true;
-               c = 122;
+       case 0x2a7e:
+               c = 2265;
                break;
        case 0x226A:    /* Much less than */
                c = 0xAB;
@@ -640,14 +636,16 @@ font_glyph(state_t *state, uint32_t c, bool decgfx, bool raw)
                break;
        }
 
-       /* DEC Special Graphics */
-       if (decgfx && c > 95 && c < 127)
-               return state->font_decgfx->glyphs[c - 96];
-       else if (cfg_uppercaseview && c > 96 && c < 123)
-               c -= 32;
-
 raw:
 
+       /* Contiguous character blocks  */
+       for (font = state->font; font != NULL; font = font->next) {
+               if (c < font->end && c >= font->start) {
+                       glyph = font->glyphs[c - font->start];
+                       goto done;
+               }
+       }
+
        /* Glyph order character tables */
        for (table = state->ftable; table != NULL; table = table->next) {
                /* Check for possible empty user table */
@@ -659,21 +657,18 @@ raw:
                        const uint32_t *code = table->code;
 
                        for (i = 0, t = table->n; i < t; i++) {
-                               if (code[i] == c)
-                                       return table->font->glyphs[i];
+                               if (code[i] == c) {
+                                       glyph = table->font->glyphs[i];
+                                       goto done;
+                               }
                        }
                }
        }
 
-       /* Any other supported, contiguous character blocks  */
-       for (font = state->font; font != NULL; font = font->next) {
-               if (c < font->end && c >= font->start) {
-                       glyph = font->glyphs[c - font->start];
-                       if (!glyph->defined)
-                               glyph = state->font_unknown->glyphs[0];
-                       break;
-               }
-       }
+done:
+       if (!raw && glyph != NULL && glyph != state->font_unknown->glyphs[0] &&
+           !glyph->defined)
+               glyph = state->font_unknown->glyphs[0];
 
        return glyph;
 }
@@ -685,6 +680,9 @@ font_edit(state_t *state, uint32_t c, int l, int v)
        uint8_t *row;
        int i;
 
+       if (l < 0 || l >= cfg_font_height)
+               return;
+
        /* Can never be NULL but can be "unknown" */
        if ((gl = font_glyph(state, c, false, true)) ==
            state->font_unknown->glyphs[0]) {
@@ -699,4 +697,5 @@ font_edit(state_t *state, uint32_t c, int l, int v)
        for (i = 0; i < cfg_font_width; i++)
                row[(cfg_font_width - 1) - i] =
                    ((v & (1 << i)) != 0 ? 255 : 0);
+       gl->defined = true;
 }
index 3007ddc..a63550a 100644 (file)
@@ -68,4 +68,7 @@ void  *font_glyph(state_t *, uint32_t, bool, bool);
 void   font_edit(state_t *, uint32_t, int, int);
 
 
+extern const uint32_t decgfx_unicode_table[128];
+
+
 #endif
index 7337ee7..967a0f5 100644 (file)
Binary files a/mmsoftware/analogterm2/src/font/analogterm_latin_9.png and b/mmsoftware/analogterm2/src/font/analogterm_latin_9.png differ
index 037f581..c7a7d58 100644 (file)
@@ -1,67 +1,67 @@
-#define analogterm_latin_9_width 665
+#define analogterm_latin_9_width 672
 #define analogterm_latin_9_height 9
 static char analogterm_latin_9_bits[] = {
-  0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x0B, 0x80, 0x00, 0x00, 0x08, 0x10
-  0x04, 0x80, 0x00, 0x41, 0x00, 0x00, 0x2C, 0x02, 0x04, 0xC1, 0x02, 0x00
-  0x00, 0x04, 0x08, 0x42, 0x04, 0x01, 0x00, 0x08, 0x10, 0x04, 0x0B, 0x80
-  0x00, 0x00, 0x08, 0x10, 0x04, 0x80, 0x00, 0x41, 0x00, 0x14, 0x2C, 0x02
-  0x04, 0xC1, 0x02, 0x00, 0x00, 0x04, 0x08, 0x02, 0x00, 0x01, 0x00, 0x00, 
-  0x08, 0x04, 0x0E, 0x20, 0x42, 0xF0, 0x44, 0x1C, 0x06, 0x00, 0x00, 0xE0, 
-  0xF8, 0x10, 0x08, 0x06, 0x07, 0x02, 0xE0, 0x01, 0x00, 0x08, 0x04, 0x40
-  0x20, 0x30, 0x20, 0x20, 0x04, 0x8A, 0x46, 0x44, 0xE1, 0x71, 0x10, 0x08, 
-  0x8A, 0x08, 0x81, 0xA0, 0x88, 0x38, 0x1A, 0x04, 0x82, 0xA2, 0x11, 0x01
-  0x40, 0x08, 0x04, 0x05, 0x80, 0x10, 0x78, 0x10, 0x08, 0x8A, 0x46, 0x44
-  0x01, 0x00, 0x10, 0x08, 0x8A, 0x08, 0x81, 0xA0, 0x88, 0x08, 0x1A, 0x04
-  0x82, 0xA2, 0x11, 0x01, 0x00, 0x08, 0x04, 0x45, 0x84, 0x10, 0x88, 0x00
-  0x00, 0x1E, 0x51, 0x24, 0x42, 0x08, 0x00, 0x22, 0x0C, 0x09, 0x00, 0x10, 
-  0x01, 0x28, 0x08, 0x08, 0x02, 0x01, 0x50, 0x01, 0x00, 0x0C, 0x8A, 0x44
-  0x24, 0x22, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x50, 0x88, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88
-  0x38, 0x22, 0x91, 0x48, 0x24, 0x12, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 
-  0x08, 0x05, 0x81, 0x43, 0x01, 0x70, 0x00, 0x59, 0x8A, 0xC4, 0x07, 0xE8
-  0x02, 0x10, 0x3E, 0x04, 0x84, 0x20, 0x52, 0x01, 0x00, 0x08, 0x0A, 0x49
-  0x22, 0xB1, 0x20, 0x10, 0x08, 0x04, 0x02, 0xC1, 0x51, 0x08, 0x7C, 0x3E, 
-  0x9F, 0x8F, 0xC3, 0xE1, 0x70, 0x48, 0x22, 0x0E, 0x87, 0xC3, 0xE1, 0x50, 
-  0x64, 0x22, 0x91, 0x48, 0x24, 0xF2, 0x88, 0x38, 0x1C, 0x0E, 0x87, 0xC3, 
-  0xB1, 0xF0, 0x38, 0x1C, 0x0E, 0x07, 0x81, 0x40, 0x20, 0x20, 0x1E, 0x0E
-  0x87, 0xC3, 0xE1, 0x00, 0x38, 0x22, 0x91, 0x48, 0x24, 0xF2, 0x88, 0x00
-  0x08, 0x85, 0x83, 0x82, 0x00, 0x88, 0x00, 0x45, 0x4C, 0x02, 0xE4, 0x6B
-  0x02, 0x00, 0x08, 0x0E, 0x03, 0x20, 0xE2, 0x21, 0x00, 0x1C, 0x04, 0x12, 
-  0x81, 0x40, 0x20, 0x28, 0x14, 0x0A, 0x85, 0x22, 0xF2, 0x09, 0x04, 0x02, 
-  0x81, 0x00, 0x81, 0x40, 0x20, 0x5C, 0x26, 0x91, 0x48, 0x24, 0x12, 0x21
-  0x54, 0x22, 0x91, 0x48, 0x24, 0x12, 0x79, 0x40, 0x20, 0x10, 0x08, 0x04, 
-  0x42, 0x09, 0x44, 0x22, 0x91, 0x08, 0x81, 0x40, 0x20, 0x38, 0x22, 0x91, 
-  0x48, 0x24, 0x12, 0xF9, 0x64, 0x22, 0x91, 0x48, 0x24, 0x12, 0x89, 0x00
-  0x08, 0x05, 0x81, 0xE3, 0x03, 0x70, 0x00, 0x59, 0x80, 0x04, 0x04, 0xA8
-  0x02, 0x00, 0x08, 0x00, 0x00, 0x20, 0x42, 0x01, 0x00, 0x00, 0x00, 0x89
-  0x42, 0xA3, 0x10, 0x44, 0x22, 0x91, 0x48, 0xE4, 0x53, 0x08, 0x3C, 0x1E, 
-  0x8F, 0x07, 0x81, 0x40, 0x20, 0x48, 0x2A, 0x91, 0x48, 0x24, 0x12, 0x51
-  0x54, 0x22, 0x91, 0x48, 0x44, 0xF1, 0x88, 0x78, 0x3C, 0x1E, 0x8F, 0xC7, 
-  0xE3, 0x09, 0x7C, 0x3E, 0x9F, 0x0F, 0x81, 0x40, 0x20, 0x44, 0x22, 0x91, 
-  0x48, 0x24, 0x12, 0x01, 0x54, 0x22, 0x91, 0x48, 0x24, 0x12, 0x89, 0x00
-  0x08, 0x1E, 0x41, 0x84, 0x40, 0x80, 0x00, 0x22, 0x0E, 0x09, 0x00, 0x10, 
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x43, 0x01, 0x00, 0x00, 0x8E, 0x44
-  0x26, 0x91, 0x89, 0x7C, 0x3E, 0x9F, 0xCF, 0x27, 0x52, 0x88, 0x04, 0x02, 
-  0x81, 0x00, 0x81, 0x40, 0x20, 0x48, 0x32, 0x91, 0x48, 0x24, 0x12, 0x89, 
-  0x4C, 0x22, 0x91, 0x48, 0x84, 0x10, 0x88, 0x44, 0x22, 0x91, 0x48, 0x24, 
-  0x52, 0x08, 0x04, 0x02, 0x81, 0x00, 0x81, 0x40, 0x20, 0x44, 0x22, 0x91, 
-  0x48, 0x24, 0x12, 0x21, 0x4C, 0x22, 0x91, 0x48, 0xC4, 0xF3, 0xF0, 0x00
-  0x08, 0x84, 0x1E, 0x80, 0x40, 0x78, 0x00, 0x1C, 0x00, 0x00, 0x00, 0xE0, 
-  0x00, 0x00, 0x3E, 0x00, 0x00, 0xA0, 0x42, 0x01, 0x20, 0x00, 0x00, 0x00, 
-  0x04, 0x03, 0x71, 0x44, 0x22, 0x91, 0x48, 0x24, 0xD2, 0x71, 0x7C, 0x3E, 
-  0x9F, 0x8F, 0xC3, 0xE1, 0x70, 0x38, 0x22, 0x0E, 0x87, 0xC3, 0xE1, 0x00, 
-  0x38, 0x1C, 0x0E, 0x87, 0x83, 0x10, 0x68, 0x78, 0x3C, 0x1E, 0x8F, 0xC7, 
-  0xE3, 0xF1, 0x78, 0x3C, 0x1E, 0x0F, 0x81, 0x40, 0x20, 0x38, 0x22, 0x0E
-  0x87, 0xC3, 0xE1, 0x00, 0x38, 0x3C, 0x1E, 0x8F, 0x07, 0x12, 0x80, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x82, 0x05, 0x40, 0x00, 0x00, 0x04
+  0x08, 0x02, 0x40, 0x80, 0x20, 0x00, 0x00, 0x16, 0x01, 0x82, 0x60, 0x01
+  0x00, 0x00, 0x02, 0x04, 0x21, 0x82, 0x00, 0x00, 0x04, 0x08, 0x82, 0x05
+  0x40, 0x00, 0x00, 0x04, 0x08, 0x02, 0x40, 0x80, 0x20, 0x00, 0x0A, 0x16
+  0x01, 0x82, 0x60, 0x01, 0x00, 0x00, 0x02, 0x04, 0x01, 0x80, 0x00, 0x00, 
+  0x00, 0x04, 0x02, 0x07, 0x10, 0x21, 0x78, 0x22, 0x0E, 0x03, 0x00, 0x00, 
+  0x70, 0x7C, 0x08, 0x04, 0x83, 0x03, 0x01, 0xF0, 0x00, 0x00, 0x04, 0x02
+  0x20, 0x10, 0x18, 0x10, 0x10, 0x02, 0x45, 0x23, 0xA2, 0xF0, 0x38, 0x08, 
+  0x04, 0x45, 0x84, 0x40, 0x50, 0x44, 0x1C, 0x0D, 0x02, 0x41, 0xD1, 0x88
+  0x00, 0x20, 0x04, 0x82, 0x02, 0x40, 0x08, 0x3C, 0x08, 0x04, 0x45, 0x23
+  0xA2, 0x00, 0x00, 0x08, 0x04, 0x45, 0x84, 0x40, 0x50, 0x44, 0x04, 0x0D
+  0x02, 0x41, 0xD1, 0x88, 0x00, 0x00, 0x04, 0x82, 0x22, 0x42, 0x08, 0x44
+  0x00, 0x00, 0x8F, 0x28, 0x12, 0x21, 0x04, 0x00, 0x11, 0x86, 0x04, 0x00, 
+  0x88, 0x00, 0x14, 0x04, 0x04, 0x81, 0x00, 0xA8, 0x00, 0x00, 0x06, 0x45
+  0x22, 0x12, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x28, 0x44, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00
+  0x44, 0x1C, 0x91, 0x48, 0x24, 0x12, 0x09, 0x44, 0x00, 0x00, 0x00, 0x00, 
+  0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 
+  0x00, 0x84, 0x82, 0xC0, 0xA1, 0x00, 0x38, 0x80, 0x2C, 0x45, 0xE2, 0x03
+  0x74, 0x01, 0x08, 0x1F, 0x02, 0x42, 0x10, 0xA9, 0x00, 0x00, 0x04, 0x85
+  0x24, 0x91, 0x58, 0x10, 0x08, 0x04, 0x02, 0x81, 0xE0, 0x28, 0x04, 0x3E, 
+  0x9F, 0xCF, 0xC7, 0xE1, 0x70, 0x38, 0x24, 0x11, 0x87, 0xC3, 0xE1, 0x70, 
+  0x28, 0x32, 0x91, 0x48, 0x24, 0x12, 0x79, 0x44, 0x1C, 0x0E, 0x87, 0xC3, 
+  0xE1, 0x58, 0x78, 0x1C, 0x0E, 0x87, 0x83, 0x40, 0x20, 0x10, 0x10, 0x0F
+  0x87, 0xC3, 0xE1, 0x70, 0x00, 0x1C, 0x91, 0x48, 0x24, 0x12, 0x79, 0x44
+  0x00, 0x84, 0xC2, 0x41, 0x41, 0x00, 0x44, 0x80, 0x22, 0x26, 0x01, 0xF2
+  0x35, 0x01, 0x00, 0x04, 0x87, 0x01, 0x10, 0xF1, 0x10, 0x00, 0x0E, 0x02, 
+  0x89, 0x40, 0x20, 0x10, 0x14, 0x0A, 0x85, 0x42, 0x11, 0xF9, 0x04, 0x02, 
+  0x81, 0x40, 0x80, 0x40, 0x20, 0x10, 0x2E, 0x93, 0x48, 0x24, 0x12, 0x89
+  0x10, 0x2A, 0x91, 0x48, 0x24, 0x12, 0x89, 0x3C, 0x20, 0x10, 0x08, 0x04, 
+  0x02, 0xA1, 0x04, 0x22, 0x91, 0x48, 0x84, 0x40, 0x20, 0x10, 0x1C, 0x91, 
+  0x48, 0x24, 0x12, 0x89, 0x7C, 0x32, 0x91, 0x48, 0x24, 0x12, 0x89, 0x44
+  0x00, 0x84, 0x82, 0xC0, 0xF1, 0x01, 0x38, 0x80, 0x2C, 0x40, 0x02, 0x02
+  0x54, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10, 0xA1, 0x00, 0x00, 0x00, 0x80
+  0x44, 0xA1, 0x51, 0x08, 0x22, 0x91, 0x48, 0x24, 0xF2, 0x29, 0x04, 0x1E, 
+  0x8F, 0xC7, 0x83, 0x40, 0x20, 0x10, 0x24, 0x95, 0x48, 0x24, 0x12, 0x89
+  0x28, 0x2A, 0x91, 0x48, 0x24, 0xA2, 0x78, 0x44, 0x3C, 0x1E, 0x8F, 0xC7, 
+  0xE3, 0xF1, 0x04, 0x3E, 0x9F, 0xCF, 0x87, 0x40, 0x20, 0x10, 0x22, 0x91, 
+  0x48, 0x24, 0x12, 0x89, 0x00, 0x2A, 0x91, 0x48, 0x24, 0x12, 0x89, 0x44
+  0x00, 0x04, 0x8F, 0x20, 0x42, 0x20, 0x40, 0x00, 0x11, 0x87, 0x04, 0x00, 
+  0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xA1, 0x00, 0x00, 0x00, 0x47
+  0x22, 0x93, 0xC8, 0x44, 0x3E, 0x9F, 0xCF, 0xE7, 0x13, 0x29, 0x44, 0x02, 
+  0x81, 0x40, 0x80, 0x40, 0x20, 0x10, 0x24, 0x99, 0x48, 0x24, 0x12, 0x89, 
+  0x44, 0x26, 0x91, 0x48, 0x24, 0x42, 0x08, 0x44, 0x22, 0x91, 0x48, 0x24, 
+  0x12, 0x29, 0x04, 0x02, 0x81, 0x40, 0x80, 0x40, 0x20, 0x10, 0x22, 0x91, 
+  0x48, 0x24, 0x12, 0x89, 0x10, 0x26, 0x91, 0x48, 0x24, 0xE2, 0x79, 0x78
+  0x00, 0x04, 0x42, 0x0F, 0x40, 0x20, 0x3C, 0x00, 0x0E, 0x00, 0x00, 0x00, 
+  0x70, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x50, 0xA1, 0x00, 0x10, 0x00, 0x00, 
+  0x00, 0x82, 0x81, 0x38, 0x22, 0x91, 0x48, 0x24, 0x12, 0xE9, 0x38, 0x3E, 
+  0x9F, 0xCF, 0xC7, 0xE1, 0x70, 0x38, 0x1C, 0x11, 0x87, 0xC3, 0xE1, 0x70, 
+  0x00, 0x1C, 0x0E, 0x87, 0xC3, 0x41, 0x08, 0x34, 0x3C, 0x1E, 0x8F, 0xC7, 
+  0xE3, 0xF1, 0x78, 0x3C, 0x1E, 0x8F, 0x87, 0x40, 0x20, 0x10, 0x1C, 0x11
+  0x87, 0xC3, 0xE1, 0x70, 0x00, 0x1C, 0x1E, 0x8F, 0xC7, 0x03, 0x09, 0x40, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xC0, 0x11, 0x70, 0x00
+  0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xE0, 0x08, 0x38
   };
index a1a2ac9..f90f8a8 100644 (file)
Binary files a/mmsoftware/analogterm2/src/font/analogterm_misc_9.png and b/mmsoftware/analogterm2/src/font/analogterm_misc_9.png differ
index dbcc836..94d4df8 100644 (file)
@@ -1,19 +1,33 @@
-#define analogterm_misc_9_width 168
+#define analogterm_misc_9_width 308
 #define analogterm_misc_9_height 9
 static char analogterm_misc_9_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x88, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1F, 0x0C, 
-  0xC0, 0x01, 0x70, 0x18, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x1C, 
-  0x00, 0x1F, 0x20, 0x22, 0x48, 0x48, 0x22, 0x01, 0x82, 0x23, 0x02, 0x50, 
-  0x10, 0x00, 0x00, 0x00, 0xBD, 0xF0, 0xF9, 0x00, 0x22, 0x80, 0x02, 0x00, 
-  0x40, 0x48, 0x48, 0x0F, 0x02, 0x02, 0x01, 0xF2, 0x50, 0x20, 0x80, 0x2B, 
-  0x80, 0xC3, 0xF1, 0x89, 0x00, 0x5D, 0x40, 0xC2, 0x26, 0x82, 0x90, 0x24, 
-  0x02, 0x04, 0x02, 0x00, 0x02, 0x89, 0x20, 0x36, 0x39, 0x60, 0x81, 0xF6, 
-  0x89, 0x00, 0x67, 0x40, 0x2E, 0x29, 0x02, 0x00, 0x00, 0x0F, 0x02, 0x02, 
-  0x00, 0x02, 0x89, 0x30, 0x49, 0x29, 0x80, 0xC3, 0xF1, 0x89, 0x28, 0x3E, 
-  0x40, 0x22, 0x4F, 0x01, 0x00, 0x00, 0x22, 0x01, 0x02, 0x21, 0x02, 0x05, 
-  0x49, 0x36, 0x29, 0x00, 0xBD, 0xF0, 0xF9, 0x28, 0x14, 0x80, 0x22, 0x81, 
-  0x00, 0x00, 0x00, 0x1C, 0x1F, 0x82, 0xC3, 0xF1, 0x04, 0x45, 0x00, 0x80, 
-  0x0A, 0x81, 0x00, 0x00, 0x28, 0x08, 0x00, 0xDF, 0x8E, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x07, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x1C, 0x0C, 0x81, 0x42, 
+  0x01, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x84, 0xE3, 0x83, 0x01, 0x38, 
+  0x00, 0x0E, 0x03, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x80, 0x03, 0xE0, 
+  0x03, 0x44, 0x04, 0x09, 0x09, 0x00, 0x08, 0x04, 0x02, 0x81, 0x28, 0x04, 
+  0x02, 0x81, 0x42, 0xE1, 0x0F, 0x00, 0x00, 0x18, 0x18, 0x00, 0x44, 0x24, 
+  0x40, 0x70, 0x44, 0x00, 0x0A, 0x02, 0x00, 0x00, 0xA0, 0x17, 0x3E, 0x1F, 
+  0x40, 0x04, 0x50, 0x00, 0x00, 0x08, 0x09, 0x09, 0x03, 0x10, 0x02, 0x07, 
+  0xC1, 0x39, 0x0C, 0x02, 0xF1, 0x43, 0x01, 0xF0, 0x07, 0x00, 0x04, 0x20, 
+  0x9F, 0xEF, 0x41, 0x40, 0x20, 0x40, 0x1E, 0x0A, 0x04, 0x70, 0x05, 0x70, 
+  0x38, 0x3E, 0x11, 0xA0, 0x0B, 0x48, 0xD8, 0x44, 0x10, 0x92, 0x84, 0x07, 
+  0x3E, 0x9F, 0x4A, 0xE5, 0xAB, 0xC7, 0xE3, 0x91, 0x8A, 0x1C, 0x00, 0x00, 
+  0x00, 0x18, 0x98, 0x0A, 0x42, 0x80, 0x40, 0x00, 0x40, 0x20, 0x11, 0xC4, 
+  0x26, 0x07, 0x2C, 0xD0, 0x3E, 0x11, 0xE0, 0x0C, 0xC8, 0x25, 0x45, 0x00, 
+  0x00, 0xC0, 0x0F, 0x10, 0x02, 0x82, 0xC3, 0x29, 0x45, 0xAC, 0xB7, 0x8A, 
+  0x08, 0x00, 0xF8, 0x03, 0x60, 0x06, 0x8A, 0xEF, 0x41, 0x40, 0x00, 0x40, 
+  0x20, 0x11, 0x26, 0x29, 0x05, 0x70, 0x38, 0x3E, 0x11, 0xC5, 0x07, 0x48, 
+  0xE4, 0x29, 0x00, 0x00, 0xC0, 0x0F, 0x08, 0x04, 0x02, 0x81, 0x00, 0xC1, 
+  0x60, 0x10, 0x08, 0x08, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x0A, 0x41, 0x24, 
+  0x40, 0x20, 0x44, 0xA0, 0x20, 0xC9, 0x26, 0x05, 0xA0, 0x17, 0x3E, 0x1F, 
+  0x85, 0x02, 0x50, 0x24, 0x10, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x41, 0xA0, 0x10, 0x08, 0x08, 0x00, 0x00, 0x00, 0x7C, 0x3E, 
+  0x11, 0x81, 0xE3, 0x43, 0x70, 0x38, 0x9E, 0xA0, 0x08, 0x00, 0x50, 0x21, 
+  0x10, 0x00, 0x00, 0x05, 0x01, 0xE0, 0xDB, 0x11, 0x00, 0x00, 0x00, 0x03, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xA0, 0x10, 0x38, 0x08, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, };
index 79a9094..4ae0237 100644 (file)
@@ -271,6 +271,7 @@ usage(void)
            "      internal default font is supplied.  A custom font must be\n"
            "      defined/loaded with ATC sequences for other sizes.  If the\n"
            "      new matrix is larger, the internal font is still loaded.\n"
+           "      Alternatively 'x' can be used instead of a comma.\n"
            " -l - Add extra leading pixels between lines.  This will also\n"
            "      affect the vertical connectivity of graphics characters.\n"
            " -f - Number of frames to keep reverse video on for the flash\n"
@@ -478,6 +479,10 @@ main(int argc, char **argv, char **envp)
 
                                if ((str = strdup(optarg)) == NULL)
                                        err(EXIT_FAILURE, "strdup()");
+                               if (cfg_strspl(cols, str, 2, 'x') == 2) {
+                                       w = atoi(cols[0]);
+                                       h = atoi(cols[1]);
+                               }
                                if (cfg_strspl(cols, str, 2, ',') == 2) {
                                        w = atoi(cols[0]);
                                        h = atoi(cols[1]);
index c182386..c090a22 100644 (file)
@@ -38,6 +38,7 @@
 #include <screen.h>
 #include <state.h>
 #include <draw.h>
+#include <font.h>
 
 
 /* dead key -> char -> result */
@@ -772,8 +773,15 @@ screen_select_end(state_t *st, XButtonEvent *bev)
 
                xf = (y == st->sel_y1 ? st->sel_x1 : 0);
                xt = (y == st->sel_y2 ? st->sel_x2 + 1 : cfg_text_width);
-               for (x = xf; x < xt && ptr < tptr; x++)
-                       *ptr++ = st->text_char[y][x];
+               for (x = xf; x < xt && ptr < tptr; x++) {
+                       uint32_t c = st->text_char[y][x];
+
+                       /* Translate DEC Special Graphics if needed */
+                       if ((st->text_mode[y][x] & TMODE_GFX) != 0 &&
+                           c > 0 && c < 128)
+                               c = decgfx_unicode_table[c];
+                       *ptr++ = c;
+               }
                if (--x == cfg_text_width - 1 && st->text_char[y][x] == ' ') {
                        for ( ; x > 0 && ptr > buf &&
                            st->text_char[y][x] == ' ';
index 2aaaf32..3adaefd 100644 (file)
@@ -97,7 +97,6 @@ struct state_s {
 
        /* Font glyphs */
        font_t *font;
-       font_t *font_decgfx;
        font_t *font_latin2;
        font_t *font_latin3;
        font_t *font_latin4;
diff --git a/mmsoftware/analogterm2/tests/dec-graphics.txt b/mmsoftware/analogterm2/tests/dec-graphics.txt
new file mode 100644 (file)
index 0000000..c18ea05
--- /dev/null
@@ -0,0 +1,47 @@
+Mapping DEC Special Graphics to unicode.
+
+Linux and tmux console extensions:
+(43 - 48, '+' - '0')
+
++ →
+, ←
+- ↑
+. ↓
+0 ▮
+
+VT100:
+(95 - 126, '_' - '~')
+
+_  
+` ◆
+a ▒
+b ␉
+c ␌
+d ␍
+e ␊
+f °
+g ±
+h ␤
+i ␋
+j ┘
+k ┐
+l ┌
+m └
+n ┼
+o ⎺
+p ⎻
+q ─
+r ⎼
+s ⎽
+t ├
+u ┤
+v ┴
+w ┬
+x │
+y ≤
+z ≥
+{ π
+| ≠
+} £
+~ ·
+