MSDOS: Accept only single character font mappings
* makefont.lua generates incorrect PSF fonts. There can be multiple characters mapped to a single glyph, but the mappings should be separated by FE bytes. * font.c should accept only single character mappings -- not combining sequences. The bundled fonts have no combining sequences, but I am exploring other options that provide more Unicode coverate.
This commit is contained in:
+20
-4
@@ -112,11 +112,27 @@ load_font(const char *filename)
|
|||||||
bufsize -= strsize;
|
bufsize -= strsize;
|
||||||
memmove(buf, buf + strsize, bufsize);
|
memmove(buf, buf + strsize, bufsize);
|
||||||
}
|
}
|
||||||
codepoints = uni_8to32(buf2);
|
/* Split the individual mappings and use only single character
|
||||||
for (j = 0; codepoints[j] != 0; ++j) {
|
mappings */
|
||||||
add_unicode_index(font, codepoints[j], i);
|
char *start = buf2;
|
||||||
|
while (*start != '\0') {
|
||||||
|
/* Mapping ends with a 0xFE byte */
|
||||||
|
char *end = strchr(start, 0xFE);
|
||||||
|
if (end == NULL) {
|
||||||
|
end = start + strlen(start);
|
||||||
|
} else {
|
||||||
|
*end = '\0';
|
||||||
|
++end;
|
||||||
|
}
|
||||||
|
/* Convert this mapping */
|
||||||
|
codepoints = uni_8to32(start);
|
||||||
|
/* Accept it if it is a single character */
|
||||||
|
if (codepoints[0] != 0 && codepoints[1] == 0) {
|
||||||
|
add_unicode_index(font, codepoints[0], i);
|
||||||
|
}
|
||||||
|
free(codepoints);
|
||||||
|
start = end;
|
||||||
}
|
}
|
||||||
free(codepoints);
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,9 @@ end
|
|||||||
for i = 1, next_pos-1 do
|
for i = 1, next_pos-1 do
|
||||||
glyph = font[i]
|
glyph = font[i]
|
||||||
for j = 1, #glyph.code do
|
for j = 1, #glyph.code do
|
||||||
|
if j ~= 1 then
|
||||||
|
outfile:write("\xFE")
|
||||||
|
end
|
||||||
outfile:write(utf8.char(glyph.code[j]))
|
outfile:write(utf8.char(glyph.code[j]))
|
||||||
end
|
end
|
||||||
outfile:write("\xFF")
|
outfile:write("\xFF")
|
||||||
|
|||||||
Reference in New Issue
Block a user