From 7caf0192182233de4c7524a6c40d914229952dd8 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 20 Feb 2005 18:19:29 +0000 Subject: [project @ 2005-02-20 18:19:29 by bursa] Fix glyph with multiple Unicodes issue on RO3-4. svn path=/import/rufl/; revision=2452 --- makefile | 4 ++-- makeglyphs | 16 ++++++++++++---- rufl_init.c | 15 ++++++++++++--- rufl_internal.h | 4 ++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/makefile b/makefile index 7c53a67..f7ce348 100644 --- a/makefile +++ b/makefile @@ -22,8 +22,8 @@ all: rufl.o rufl_test,ff8 rufl_chars,ff8 rufl.o: $(SOURCE) Glyphs $(CC) $(CFLAGS) -c -o $@ $(SOURCE) -rufl_glyph_map.c: Glyphs - ./makeglyphs < $^ > $@ +rufl_glyph_map.c: Glyphs makeglyphs + ./makeglyphs < Glyphs > $@ rufl_test,ff8: rufl_test.c rufl.o $(CC) $(CFLAGS) $(LIBS) -o $@ $^ diff --git a/makeglyphs b/makeglyphs index 4cca836..6acb350 100755 --- a/makeglyphs +++ b/makeglyphs @@ -1,21 +1,29 @@ #!/usr/bin/perl -W -%glyph = (); +%name = (); print "#include \n"; print "#include \"rufl_internal.h\"\n"; print "const struct rufl_glyph_map_entry rufl_glyph_map[] = {\n"; +print "\t{\" \", 0}, /* sentinel */\n"; while (<>) { if (/^([0-9A-F]{4});([a-zA-Z0-9]+);/) { - $glyph{$2} = $1; + $name{"$1:$2"} = 1; } } -foreach $z (sort keys %glyph) { - print "\t{\"$z\", 0x$glyph{$z}},\n"; +@glyph = (); +while (($un, ) = each %name) { + ($u, $n) = split ':', $un; + push @glyph, [$n, $u]; } +foreach $z (sort {$$a[0] cmp $$b[0] or $$a[1] cmp $$b[1]} @glyph) { + print "\t{\"$$z[0]\", 0x$$z[1]},\n"; +} + +print "\t{\"~\", 0} /* sentinel */\n"; print "};\n"; print "const size_t rufl_glyph_map_size = sizeof rufl_glyph_map /\n"; print " sizeof rufl_glyph_map[0];\n"; diff --git a/rufl_init.c b/rufl_init.c index 3778978..7756ad9 100644 --- a/rufl_init.c +++ b/rufl_init.c @@ -521,9 +521,18 @@ rufl_code rufl_init_read_encoding(font_f font, sizeof rufl_glyph_map[0], rufl_glyph_map_cmp); if (entry) { - umap->map[u].u = entry->u; - umap->map[u].c = i - 1; - u++; + /* may be more than one unicode for the glyph + * sentinels stop overshooting array */ + while (strcmp(s, (entry - 1)->glyph_name) == 0) + entry--; + for (; strcmp(s, entry->glyph_name) == 0; + entry++) { + umap->map[u].u = entry->u; + umap->map[u].c = i - 1; + u++; + if (u == 256) + break; + } } } } diff --git a/rufl_internal.h b/rufl_internal.h index 5eb4989..6394722 100644 --- a/rufl_internal.h +++ b/rufl_internal.h @@ -51,7 +51,7 @@ struct rufl_unicode_map { /** Number of valid entries in u and c. */ unsigned int entries; /** Map from Unicode to character code. */ - struct rufl_unicode_map_entry map[224]; + struct rufl_unicode_map_entry map[256]; }; @@ -156,7 +156,7 @@ unsigned int rufl_substitution_lookup(unsigned int c); } #define rufl_CACHE ".RUfl_cache" -#define rufl_CACHE_VERSION 1 +#define rufl_CACHE_VERSION 2 struct rufl_glyph_map_entry { -- cgit v1.2.3