diff options
author | Erich Eckner <git@eckner.net> | 2018-10-29 11:17:10 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-31 21:48:36 +0100 |
commit | 8418de17e6d897cfb692de9712674316335dfb24 (patch) | |
tree | 3840128075012f16a7ba329561d740b2e428f3e3 | |
parent | 3f8ec75fbd7f2be7153ef623ddd194d334955529 (diff) | |
download | anzeige-8418de17e6d897cfb692de9712674316335dfb24.tar.xz |
fonts: alle Umlaute
-rw-r--r-- | fonts.c | 29 | ||||
-rw-r--r-- | fonts.h | 35 |
2 files changed, 54 insertions, 10 deletions
@@ -1,22 +1,35 @@ #include <string.h> +#include <uchar.h> #include "fonts.h" +int skip_gaps(char16_t *operand) +{ + for (int i=sizeof(skip_ranges)/sizeof(skip_ranges[0])-1; i>=0; i--) { + if (*operand < skip_ranges[i][0]) + continue; + if (*operand <= skip_ranges[i][1]) + return 1; + *operand -= skip_ranges[i][1] - skip_ranges[i][0] + 1; + } + if ((*operand < 0) || (*operand >= (sizeof(symbols) / SYMBOL_WIDTH))) + return 1; + return 0; +} + int render(char *input, int input_len, char *output, int max_output_len, int skip_unprintables) { memset(output, 0, max_output_len); int output_i = 0; for (int input_i=0; (input_i < input_len) && (output_i*(SYMBOL_WIDTH+1) < max_output_len) && input[input_i]; input_i++) { - unsigned char c = input[input_i]; - if (c >= 0x7f) { - if (c <= 0xaf) { - output_i += !!skip_unprintables; + char16_t c = (unsigned char)input[input_i]; + if ((c == 0xc2) || (c == 0xc3)) { + input_i++; + if ((input_i >= input_len) || (! input[input_i])) continue; - } - c -= 0xaf - 0x7f + 1; + c = (c << 8) | (unsigned char)input[input_i]; } - c -= 0x20; - if ((c < 0) || (c >= (sizeof(symbols) / SYMBOL_WIDTH))) { + if (skip_gaps(&c)) { output_i += !!skip_unprintables; continue; } @@ -1,6 +1,8 @@ +#include <uchar.h> + #define SYMBOL_WIDTH 5 -static char const symbols[96 * SYMBOL_WIDTH] = { +static char const symbols[104 * SYMBOL_WIDTH] = { 0x00,0x00,0x00,0x00,0x00, // space 0x00,0x00,0x2F,0x00,0x00, // ! 0x00,0x07,0x00,0x07,0x00, // " @@ -97,7 +99,36 @@ static char const symbols[96 * SYMBOL_WIDTH] = { 0x00,0x41,0x36,0x08,0x00, // } 0x00,0x08,0x04,0x08,0x04, // ~ // 0x7f .. 0xaf missing - 0x00,0x02,0x05,0x02,0x00 // ° + 0x00,0x02,0x05,0x02,0x00, // ° (0xb0) +// 0xb1 .. 0xc2af missing + 0x00,0x02,0x05,0x02,0x00, // ° (0xc2b0) +// 0xc2b1 .. 0xc383 missing + 0x21,0x3E,0x0A,0x3C,0x21, // Ä (0xc384) +// 0xc385 .. 0xc395 missing + 0x01,0x1C,0x22,0x1C,0x01, // Ö (0xc396) +// 0xc397 .. 0xc39b missing + 0x03,0x3E,0x20,0x1E,0x03, // Ü (0xc39c) +// 0xc39d .. 0xc39e missing + 0x22,0x3E,0x2A,0x1C,0x00, // ß (0xc39f) +// 0xc3a0 .. 0xc3a3 missing + 0x01,0x14,0x2C,0x18,0x21, // ä (0xc3a4) +// 0xc3a5 .. 0xc3b5 missing + 0x01,0x18,0x24,0x18,0x01, // ö (0xc3b6) +// 0xc3b7 .. 0xc3bb missing + 0x05,0x3C,0x20,0x1C,0x21 // ü (0xc3bc) +}; + +static char16_t const skip_ranges[10][2] = { + {0x0000, 0x001f}, + {0x007f, 0x00af}, + {0x00b1, 0xc2af}, + {0xc2b1, 0xc383}, + {0xc385, 0xc395}, + {0xc397, 0xc39b}, + {0xc39d, 0xc39e}, + {0xc3a0, 0xc3a3}, + {0xc3a5, 0xc3b5}, + {0xc3b7, 0xc3bb} }; int render(char *input, int input_len, char *output, int max_output_len, int skip_unprintables); |