|
|
|
@ -2,6 +2,7 @@
|
|
|
|
#include "osmroute.h"
|
|
|
|
#include "osmroute.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "memoryleak.h"
|
|
|
|
#include "memoryleak.h"
|
|
|
|
|
|
|
|
#include "utf8.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
@ -29,7 +30,7 @@ int font_init () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct font* font_load(char *name) {
|
|
|
|
struct font* font_load(char *name) {
|
|
|
|
int fd, i;
|
|
|
|
int fd;
|
|
|
|
struct font *f = NULL;
|
|
|
|
struct font *f = NULL;
|
|
|
|
char fname[LEN_FILENAME];
|
|
|
|
char fname[LEN_FILENAME];
|
|
|
|
struct stat st_buf;
|
|
|
|
struct stat st_buf;
|
|
|
|
@ -58,16 +59,9 @@ struct font* font_load(char *name) {
|
|
|
|
FT_Set_Pixel_Sizes(f->face, 0, 12);
|
|
|
|
FT_Set_Pixel_Sizes(f->face, 0, 12);
|
|
|
|
d_printf ("font loaded (size:%d).", f->buffersize);
|
|
|
|
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))
|
|
|
|
if (FT_Select_Charmap(f->face, FT_ENCODING_UNICODE))
|
|
|
|
d_printf ("FT_Select_Charmap: error");
|
|
|
|
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;
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,6 +72,7 @@ struct font* font_load(char *name) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) {
|
|
|
|
void font_draw (struct font *f, char *text, float x, float y, float sx, float sy) {
|
|
|
|
char *p;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
uint32_t u8chr;
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
GLfloat vp[8];
|
|
|
|
GLfloat vp[8];
|
|
|
|
GLfloat vt[8] = {0, 1,
|
|
|
|
GLfloat vt[8] = {0, 1,
|
|
|
|
@ -86,8 +81,6 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
|
|
|
|
0, 0};
|
|
|
|
0, 0};
|
|
|
|
FT_GlyphSlot g = f->face->glyph;
|
|
|
|
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" */
|
|
|
|
/* Create a texture that will be used to hold one "glyph" */
|
|
|
|
GLuint tex;
|
|
|
|
GLuint tex;
|
|
|
|
glGenTextures(1, &tex);
|
|
|
|
glGenTextures(1, &tex);
|
|
|
|
@ -105,10 +98,16 @@ void font_draw (struct font *f, char *text, float x, float y, float sx, float sy
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
|
|
|
|
|
|
|
|
/* Loop through all characters */
|
|
|
|
/* Loop through all characters */
|
|
|
|
for (p = text; *p; p++) {
|
|
|
|
for (p = text; *p;) {
|
|
|
|
|
|
|
|
u8chr = u8_decode (p, &i);
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
p = p + i;
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to load and render the character */
|
|
|
|
/* Try to load and render the character */
|
|
|
|
if ((i = FT_Load_Char(f->face, *p, FT_LOAD_RENDER))) {
|
|
|
|
if ((i = FT_Load_Char(f->face, u8chr, FT_LOAD_RENDER))) {
|
|
|
|
d_printf ("error:%d", i);
|
|
|
|
d_printf ("error:%d", i);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|