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:
authorDiego Borghetti <bdiego@gmail.com>2009-03-03 00:02:39 +0300
committerDiego Borghetti <bdiego@gmail.com>2009-03-03 00:02:39 +0300
commit63b4879c9ed374b4213096fbea801baa7b6ef848 (patch)
tree7231c168998f098a318d969d74c85f99b4e338b7 /source/blender/blenfont/intern/blf.c
parentc2fdac64c4eed74a146507c3e3d0b8b5f3183174 (diff)
And another commit to cleanup a little, this is the last,
next commit add internal font and we can go ahead and remove ftfont and bmfont.
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r--source/blender/blenfont/intern/blf.c69
1 files changed, 17 insertions, 52 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index fd2047367dd..43c85b78977 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -58,7 +58,6 @@
#include "blf_internal_types.h"
#include "blf_internal.h"
-#ifdef WITH_FREETYPE2
/* Max number of font in memory.
* Take care that now every font have a glyph cache per size/dpi,
@@ -76,41 +75,33 @@ int global_font_num= 0;
/* Current font. */
int global_font_cur= 0;
-#endif /* WITH_FREETYPE2 */
int BLF_init(void)
{
-#ifdef WITH_FREETYPE2
int i;
for (i= 0; i < BLF_MAX_FONT; i++)
global_font[i]= NULL;
return(blf_font_init());
-#else
- return(0);
-#endif
}
void BLF_exit(void)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
int i;
for (i= 0; i < global_font_num; i++) {
font= global_font[i];
- if(font)
- blf_font_free(font);
+ if(font && font->free)
+ (*font->free)(font);
}
blf_font_exit();
-#endif
}
int blf_search(char *name)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
int i;
@@ -119,13 +110,11 @@ int blf_search(char *name)
if (font && (!strcmp(font->name, name)))
return(i);
}
-#endif
return(-1);
}
int BLF_load(char *name)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
char *filename;
int i;
@@ -153,6 +142,7 @@ int BLF_load(char *name)
return(-1);
}
+#ifdef WITH_FREETYPE2
font= blf_font_new(name, filename);
MEM_freeN(filename);
@@ -165,14 +155,13 @@ int BLF_load(char *name)
i= global_font_num;
global_font_num++;
return(i);
-#else
- return(-1);
#endif /* WITH_FREETYPE2 */
+
+ return(-1);
}
int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
int i;
@@ -192,6 +181,7 @@ int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
return(-1);
}
+#ifdef WITH_FREETYPE2
font= blf_font_new_from_mem(name, mem, mem_size);
if (!font) {
printf("Can't load font, %s from memory!!\n", name);
@@ -202,55 +192,45 @@ int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
i= global_font_num;
global_font_num++;
return(i);
-#else
- return(-1);
#endif /* WITH_FREETYPE2 */
+ return(-1);
}
void BLF_set(int fontid)
{
-#ifdef WITH_FREETYPE2
if (fontid >= 0 && fontid < BLF_MAX_FONT)
global_font_cur= fontid;
-#endif
}
void BLF_enable(int option)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
if (font)
font->flags |= option;
-#endif
}
void BLF_disable(int option)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
if (font)
font->flags &= ~option;
-#endif
}
void BLF_aspect(float aspect)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
if (font)
font->aspect= aspect;
-#endif
}
void BLF_position(float x, float y, float z)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
float remainder;
@@ -276,27 +256,23 @@ void BLF_position(float x, float y, float z)
font->pos[1]= y;
font->pos[2]= z;
}
-#endif
}
void BLF_size(int size, int dpi)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
- if (font)
- blf_font_size(font, size, dpi);
-#endif
+ if (font && font->size_set)
+ (*font->size_set)(font, size, dpi);
}
void BLF_draw(char *str)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->glyph_cache) {
+ if (font && font->draw && font->glyph_cache) {
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -308,64 +284,54 @@ void BLF_draw(char *str)
if (font->flags & BLF_ROTATION)
glRotatef(font->angle, 0.0f, 0.0f, 1.0f);
- blf_font_draw(font, str);
+ (*font->draw)(font, str);
glPopMatrix();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}
-#endif /* WITH_FREETYPE2 */
}
void BLF_boundbox(char *str, rctf *box)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->glyph_cache)
- blf_font_boundbox(font, str, box);
-#endif
+ if (font && font->boundbox_get && font->glyph_cache)
+ (*font->boundbox_get)(font, str, box);
}
float BLF_width(char *str)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->glyph_cache)
- return(blf_font_width(font, str));
-#endif
+ if (font && font->width_get && font->glyph_cache)
+ return((*font->width_get)(font, str));
return(0.0f);
}
float BLF_height(char *str)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->glyph_cache)
- return(blf_font_height(font, str));
-#endif
+ if (font && font->height_get && font->glyph_cache)
+ return((*font->height_get)(font, str));
return(0.0f);
}
void BLF_rotation(float angle)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
if (font)
font->angle= angle;
-#endif
}
void BLF_clipping(float xmin, float ymin, float xmax, float ymax)
{
-#ifdef WITH_FREETYPE2
FontBLF *font;
font= global_font[global_font_cur];
@@ -375,5 +341,4 @@ void BLF_clipping(float xmin, float ymin, float xmax, float ymax)
font->clip_rec.xmax= xmax;
font->clip_rec.ymax= ymax;
}
-#endif
}