From 698cf67bd45ee2c8f7536d71bc1d01da429cb002 Mon Sep 17 00:00:00 2001 From: steffen Date: Wed, 5 Jun 2013 22:16:06 +0000 Subject: [PATCH] need to convert from utf8 to utf-32bit --- android/jni/android_font.c | 3 ++- base/utf8.c | 23 +++++++++++++++++++++++ base/utf8.h | 25 +++++++++++++++++++++++++ sdlgl/sdl_font.c | 16 ++++++++++++++-- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 base/utf8.c create mode 100644 base/utf8.h diff --git a/android/jni/android_font.c b/android/jni/android_font.c index 6f2435b..3a32ff0 100644 --- a/android/jni/android_font.c +++ b/android/jni/android_font.c @@ -57,7 +57,8 @@ struct font* font_load(char *fname) { FT_Set_Pixel_Sizes(f->face, 0, 16); d_printf ("font loaded (size:%d).", f->buffersize); - + + FT_Select_Charmap(f->face, FT_ENCODING_UNICODE); return f; } diff --git a/base/utf8.c b/base/utf8.c new file mode 100644 index 0000000..a27236b --- /dev/null +++ b/base/utf8.c @@ -0,0 +1,23 @@ +/* $Id: utf8.c,v 1.1 2013/06/05 22:16:06 steffen Exp $ */ +/* utf8.c + * Copyright (C) Steffen Pohle 2013 + * + * spOSMroute is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * spOSMroute is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include "utf8.h" + diff --git a/base/utf8.h b/base/utf8.h new file mode 100644 index 0000000..2f80754 --- /dev/null +++ b/base/utf8.h @@ -0,0 +1,25 @@ +/* $Id: utf8.h,v 1.1 2013/06/05 22:16:06 steffen Exp $ */ +/* utf8.h + * Copyright (C) Steffen Pohle 2013 + * + * spOSMroute is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * spOSMroute is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _UTF8_H_ +#define _UTF8_H_ + + + +#endif + diff --git a/sdlgl/sdl_font.c b/sdlgl/sdl_font.c index 1d67e52..73ff66a 100644 --- a/sdlgl/sdl_font.c +++ b/sdlgl/sdl_font.c @@ -29,7 +29,7 @@ int font_init () { struct font* font_load(char *name) { - int fd; + int fd, i; struct font *f = NULL; char fname[LEN_FILENAME]; struct stat st_buf; @@ -57,7 +57,17 @@ struct font* font_load(char *name) { FT_Set_Pixel_Sizes(f->face, 0, 12); d_printf ("font loaded (size:%d).", f->buffersize); - + + d_printf ("charmap: %d == %d (unicode)", f->face->charmap->encoding, FT_ENCODING_UNICODE); + + if (FT_Select_Charmap(f->face, FT_ENCODING_UNICODE)) + d_printf ("FT_Select_Charmap: error"); + + for (i = 0; i < f->face->num_charmaps; i++) + d_printf (" %d : encoding: %d", i, f->face->charmap[i].encoding); + + d_printf ("charmap: %d == %d (unicode)", f->face->charmap->encoding, FT_ENCODING_UNICODE); + return f; } @@ -76,6 +86,8 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy 0, 0}; FT_GlyphSlot g = f->face->glyph; + if (strncmp ("Than", text, 4) == 0) d_printf ("'%s' drawing", text); + /* Create a texture that will be used to hold one "glyph" */ GLuint tex; glGenTextures(1, &tex);