summaryrefslogtreecommitdiff
path: root/fonts.c
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-29 11:17:10 +0100
committerErich Eckner <git@eckner.net>2018-10-31 21:48:36 +0100
commit8418de17e6d897cfb692de9712674316335dfb24 (patch)
tree3840128075012f16a7ba329561d740b2e428f3e3 /fonts.c
parent3f8ec75fbd7f2be7153ef623ddd194d334955529 (diff)
downloadanzeige-8418de17e6d897cfb692de9712674316335dfb24.tar.xz
fonts: alle Umlaute
Diffstat (limited to 'fonts.c')
-rw-r--r--fonts.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/fonts.c b/fonts.c
index 25f9cf4..7704a7d 100644
--- a/fonts.c
+++ b/fonts.c
@@ -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;
}