Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r--source/blender/blenfont/intern/blf_font.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 02b21264115..ac13387b92a 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -72,7 +72,7 @@ void blf_font_size(FontBLF *font, int size, int dpi)
GlyphCacheBLF *gc;
FT_Error err;
- err= FT_Set_Char_Size((FT_Face)font->engine, 0, (size * 64), dpi, dpi);
+ err= FT_Set_Char_Size(font->face, 0, (size * 64), dpi, dpi);
if (err) {
/* FIXME: here we can go through the fixed size and choice a close one */
printf("The current font don't support the size, %d and dpi, %d\n", size, dpi);
@@ -99,7 +99,6 @@ void blf_font_draw(FontBLF *font, char *str)
unsigned int c;
GlyphBLF *g, *g_prev;
FT_Vector delta;
- FT_Face face;
FT_UInt glyph_index, g_prev_index;
int pen_x, pen_y;
int i, has_kerning;
@@ -107,11 +106,10 @@ void blf_font_draw(FontBLF *font, char *str)
if (!font->glyph_cache)
return;
- face= (FT_Face)font->engine;
i= 0;
pen_x= 0;
pen_y= 0;
- has_kerning= FT_HAS_KERNING(face);
+ has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
g_prev_index= 0;
@@ -120,7 +118,7 @@ void blf_font_draw(FontBLF *font, char *str)
if (c == 0)
break;
- glyph_index= FT_Get_Char_Index(face, c);
+ glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_search(font->glyph_cache, c);
if (!g)
g= blf_glyph_add(font, glyph_index, c);
@@ -144,7 +142,7 @@ void blf_font_draw(FontBLF *font, char *str)
delta.x= 0;
delta.y= 0;
- FT_Get_Kerning(face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
+ FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
pen_x += delta.x >> 6;
}
@@ -163,7 +161,6 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
GlyphBLF *g, *g_prev;
FT_Vector delta;
FT_UInt glyph_index, g_prev_index;
- FT_Face face;
rctf gbox;
int pen_x, pen_y;
int i, has_kerning;
@@ -171,7 +168,6 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
if (!font->glyph_cache)
return;
- face= (FT_Face)font->engine;
box->xmin= 32000.0f;
box->xmax= -32000.0f;
box->ymin= 32000.0f;
@@ -180,7 +176,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
i= 0;
pen_x= 0;
pen_y= 0;
- has_kerning= FT_HAS_KERNING(face);
+ has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
g_prev_index= 0;
@@ -189,7 +185,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
if (c == 0)
break;
- glyph_index= FT_Get_Char_Index(face, c);
+ glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_search(font->glyph_cache, c);
if (!g)
g= blf_glyph_add(font, glyph_index, c);
@@ -213,7 +209,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
delta.x= 0;
delta.y= 0;
- FT_Get_Kerning(face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
+ FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
pen_x += delta.x >> 6;
}
@@ -278,7 +274,7 @@ void blf_font_free(FontBLF *font)
blf_glyph_cache_free(gc);
}
- FT_Done_Face((FT_Face)font->engine);
+ FT_Done_Face(font->face);
if (font->filename)
MEM_freeN(font->filename);
if (font->name)
@@ -289,7 +285,6 @@ void blf_font_free(FontBLF *font)
void blf_font_fill(FontBLF *font)
{
font->mode= BLF_MODE_TEXTURE;
- font->ref= 1;
font->aspect= 1.0f;
font->pos[0]= 0.0f;
font->pos[1]= 0.0f;
@@ -305,37 +300,32 @@ void blf_font_fill(FontBLF *font)
font->cache.first= NULL;
font->cache.last= NULL;
font->glyph_cache= NULL;
+ font->blur= 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
-
- font->size_set= blf_font_size;
- font->draw= blf_font_draw;
- font->boundbox_get= blf_font_boundbox;
- font->width_get= blf_font_width;
- font->height_get= blf_font_height;
- font->free= blf_font_free;
}
FontBLF *blf_font_new(char *name, char *filename)
{
FontBLF *font;
FT_Error err;
- FT_Face face;
- err= FT_New_Face(global_ft_lib, filename, 0, &face);
- if (err)
+ font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
+ err= FT_New_Face(global_ft_lib, filename, 0, &font->face);
+ if (err) {
+ MEM_freeN(font);
return(NULL);
+ }
- err= FT_Select_Charmap(face, ft_encoding_unicode);
+ err= FT_Select_Charmap(font->face, ft_encoding_unicode);
if (err) {
printf("Can't set the unicode character map!\n");
- FT_Done_Face(face);
+ FT_Done_Face(font->face);
+ MEM_freeN(font);
return(NULL);
}
- font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
font->name= BLI_strdup(name);
font->filename= BLI_strdup(filename);
- font->engine= (void *)face;
blf_font_fill(font);
return(font);
}
@@ -344,24 +334,24 @@ FontBLF *blf_font_new_from_mem(char *name, unsigned char *mem, int mem_size)
{
FontBLF *font;
FT_Error err;
- FT_Face face;
- err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &face);
- if (err)
+ font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
+ err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &font->face);
+ if (err) {
+ MEM_freeN(font);
return(NULL);
+ }
- err= FT_Select_Charmap(face, ft_encoding_unicode);
+ err= FT_Select_Charmap(font->face, ft_encoding_unicode);
if (err) {
printf("Can't set the unicode character map!\n");
- FT_Done_Face(face);
+ FT_Done_Face(font->face);
+ MEM_freeN(font);
return(NULL);
}
- font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
font->name= BLI_strdup(name);
font->filename= NULL;
- font->engine= (void *)face;
- font->blur= 0;
blf_font_fill(font);
return(font);
}