First try to handle UTF-8 maps.
authorkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 Feb 2007 10:53:15 +0000 (10:53 +0000)
committerkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 Feb 2007 10:53:15 +0000 (10:53 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@115 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/display.c

index 75cb399..6b5c218 100644 (file)
@@ -242,9 +242,13 @@ label_line(struct graphics *gr, struct graphics_gc *fg, struct graphics_gc *bg,
 #if 0
                        printf("display_text: '%s', %d, %d, %d, %d %d\n", label, x, y, dx*0x10000/l, dy*0x10000/l, l);
 #endif
-                       utf8=g_convert(label, -1, "utf8", "iso8859-1", NULL, NULL, NULL);               
-                       gr->draw_text(gr, fg, bg, font, utf8, &p_t, dx*0x10000/l, dy*0x10000/l);
-                       g_free(utf8);
+                       if(!g_utf8_validate(label,-1,NULL)){
+                               gr->draw_text(gr, fg, bg, font, label, &p_t, dx*0x10000/l, dy*0x10000/l);
+                       } else {
+                               utf8=g_convert(label, -1, "utf8", "iso8859-1", NULL, NULL, NULL);               
+                               gr->draw_text(gr, fg, bg, font, utf8, &p_t, dx*0x10000/l, dy*0x10000/l);
+                               g_free(utf8);
+                       }
                }
        }       
 }
@@ -264,9 +268,14 @@ display_labels(struct display_list *list, struct graphics *gr, struct graphics_g
                        case 3:
                                p.x=list->p[0].x+3;
                                p.y=list->p[0].y+10;
-                               utf8=g_convert(list->label, -1, "utf8", "iso8859-1", NULL, NULL, NULL);         
-                               gr->draw_text(gr, fg, bg, font, utf8, &p, 0x10000, 0);
-                               g_free(utf8);
+
+                               if(g_utf8_validate(list->label,-1, NULL)){
+                                       utf8=g_convert(list->label, -1, "utf8", "iso8859-1", NULL, NULL, NULL);         
+                                       gr->draw_text(gr, fg, bg, font, utf8, &p, 0x10000, 0);
+                                       g_free(utf8);
+                               } else {
+                                       gr->draw_text(gr, fg, bg, font, list->label, &p, 0x10000, 0);
+                               }
                                break;
                        }
                }