Add mirroring for visual UTF-8

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-16 21:57:34 +01:00
parent 703cbe63d6
commit 6f5568ed67
4 changed files with 45 additions and 4 deletions

View File

@ -13,7 +13,7 @@ echo timestamp > stamp-h.in
python util/import_gcry.py lib/libgcrypt/ .
python util/import_unicode.py util/UnicodeData.txt unidata.c
python util/import_unicode.py util/UnicodeData.txt util/BidiMirroring.txt unidata.c
for rmk in conf/*.rmk ${GRUB_CONTRIB}/*/conf/*.rmk; do
if test -e $rmk ; then

View File

@ -23,6 +23,12 @@
#include <grub/mm.h>
#include <grub/misc.h>
struct grub_unicode_bidi_pair
{
grub_uint32_t key;
grub_uint32_t replace;
};
struct grub_unicode_compact_range
{
grub_uint32_t start:21;
@ -97,6 +103,7 @@ struct grub_unicode_glyph
#define GRUB_UNICODE_VARIATION_SELECTOR_256 0xe01ef
extern struct grub_unicode_compact_range grub_unicode_compact[];
extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
#define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
/* Unicode mandates an arbitrary limit. */

View File

@ -1087,6 +1087,16 @@ map_code (grub_uint32_t in, struct grub_term_output *term)
return in;
}
static grub_uint32_t
mirror_code (grub_uint32_t in)
{
int i;
for (i = 0; grub_unicode_bidi_pairs[i].key; i++)
if (grub_unicode_bidi_pairs[i].key == in)
return grub_unicode_bidi_pairs[i].replace;
return in;
}
static void
putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term)
{
@ -1124,7 +1134,11 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term)
grub_uint32_t code;
if (i == -1)
code = c->base;
{
code = c->base;
if (c->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR)
code = mirror_code (code);
}
else
code = c->combining[i].code;

View File

@ -25,7 +25,7 @@ if len (sys.argv) < 3:
print ("Usage: %s SOURCE DESTINATION" % sys.argv[0])
exit (0)
infile = open (sys.argv[1], "r")
outfile = open (sys.argv[2], "w")
outfile = open (sys.argv[3], "w")
outfile.write ("#include <grub/unicode.h>\n")
outfile.write ("\n")
outfile.write ("struct grub_unicode_compact_range grub_unicode_compact[] = {\n")
@ -69,4 +69,24 @@ if lastbiditype != "L" or lastcombtype != 0 or lastmirrortype:
lastmirrortype)))
outfile.write ("{0, 0, 0, 0, 0},\n")
outfile.write ("};")
outfile.write ("};\n")
infile.close ()
infile = open (sys.argv[2], "r")
outfile.write ("struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[] = {\n")
for line in infile:
line = re.sub ("#.*$", "", line)
line = line.replace ("\n", "")
line = line.replace (" ", "")
if len (line) == 0 or line[0] == '\n':
continue
sp = line.split (";")
code1 = int (sp[0], 16)
code2 = int (sp[1], 16)
outfile.write ("{0x%x, 0x%x},\n" % (code1, code2))
outfile.write ("{0, 0},\n")
outfile.write ("};\n")