[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19461] branches/blender2.5/blender/source /blender/blenfont: Add blender internal font.
Diego Borghetti
bdiego at gmail.com
Mon Mar 30 07:32:46 CEST 2009
Revision: 19461
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19461
Author: bdiego
Date: 2009-03-30 07:32:46 +0200 (Mon, 30 Mar 2009)
Log Message:
-----------
Add blender internal font.
This is the old bmfont library but using textures.
I made small test in the space Info and work fine,
commit now to finish tomorrow from work.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h
branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal_types.h
Added Paths:
-----------
branches/blender2.5/blender/source/blender/blenfont/intern/blf_font_helv10.h
branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c
Modified: branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-03-30 01:16:28 UTC (rev 19460)
+++ branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-03-30 05:32:46 UTC (rev 19461)
@@ -52,6 +52,9 @@
void BLF_enable(int option);
void BLF_disable(int option);
+/* return the id of the current font. */
+int BLF_get(void);
+
/* Read the .Blanguages file, return 1 on success or 0 if fails. */
int BLF_lang_init(void);
Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf.c 2009-03-30 01:16:28 UTC (rev 19460)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf.c 2009-03-30 05:32:46 UTC (rev 19461)
@@ -165,7 +165,7 @@
FontBLF *font;
int i;
- if (!name || !mem || !mem_size)
+ if (!name)
return(-1);
i= blf_search(name);
@@ -181,19 +181,27 @@
return(-1);
}
+ font= blf_internal_new(name);
+ if (!font) {
#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);
- return(-1);
+ if (!mem || !mem_size) {
+ printf("Can't load font, %s from memory!!\n", name);
+ return(-1);
+ }
+
+ font= blf_font_new_from_mem(name, mem, mem_size);
+#endif /* WITH_FREETYPE2 */
+
+ if (!font) {
+ printf("Can't load font, %s from memory!!\n", name);
+ return(-1);
+ }
}
global_font[global_font_num]= font;
i= global_font_num;
global_font_num++;
return(i);
-#endif /* WITH_FREETYPE2 */
- return(-1);
}
void BLF_set(int fontid)
@@ -202,6 +210,11 @@
global_font_cur= fontid;
}
+int BLF_get(void)
+{
+ return(global_font_cur);
+}
+
void BLF_enable(int option)
{
FontBLF *font;
@@ -272,7 +285,7 @@
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->draw && font->glyph_cache) {
+ if (font && font->draw) {
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -297,7 +310,7 @@
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->boundbox_get && font->glyph_cache)
+ if (font && font->boundbox_get)
(*font->boundbox_get)(font, str, box);
}
@@ -306,7 +319,7 @@
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->width_get && font->glyph_cache)
+ if (font && font->width_get)
return((*font->width_get)(font, str));
return(0.0f);
}
@@ -316,7 +329,7 @@
FontBLF *font;
font= global_font[global_font_cur];
- if (font && font->height_get && font->glyph_cache)
+ if (font && font->height_get)
return((*font->height_get)(font, str));
return(0.0f);
}
Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-03-30 01:16:28 UTC (rev 19460)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-03-30 05:32:46 UTC (rev 19461)
@@ -110,6 +110,9 @@
int pen_x, pen_y;
int i, has_kerning;
+ if (!font->glyph_cache)
+ return;
+
face= (FT_Face)font->engine;
i= 0;
pen_x= 0;
@@ -161,6 +164,9 @@
int pen_x, pen_y;
int i, has_kerning;
+ if (!font->glyph_cache)
+ return;
+
face= (FT_Face)font->engine;
box->xmin= 32000.0f;
box->xmax= -32000.0f;
@@ -228,6 +234,9 @@
{
rctf box;
+ if (!font->glyph_cache)
+ return(0.0f);
+
blf_font_boundbox(font, str, &box);
return((box.xmax - box.xmin) * font->aspect);
}
@@ -236,6 +245,9 @@
{
rctf box;
+ if (!font->glyph_cache)
+ return(0.0f);
+
blf_font_boundbox(font, str, &box);
return((box.ymax - box.ymin) * font->aspect);
}
Added: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font_helv10.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font_helv10.h (rev 0)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font_helv10.h 2009-03-30 05:32:46 UTC (rev 19461)
@@ -0,0 +1,487 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BLF_FONT_HELV10_H
+#define BLF_FONT_HELV10_H
+
+static unsigned char helv10_bitmap_data[]= {
+ 0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0xa0,0xa0,0x50,0x50,0xf8,0x28,0x7c,0x28,
+ 0x28,0x20,0x70,0xa8,0x28,0x70,0xa0,0xa8,
+ 0x70,0x20,0x26,0x29,0x16,0x10,0x08,0x68,
+ 0x94,0x64,0x64,0x98,0x98,0xa4,0x60,0x50,
+ 0x50,0x20,0x80,0x40,0x40,0x20,0x40,0x40,
+ 0x80,0x80,0x80,0x80,0x40,0x40,0x20,0x80,
+ 0x40,0x40,0x20,0x20,0x20,0x20,0x40,0x40,
+ 0x80,0xa0,0x40,0xa0,0x20,0x20,0xf8,0x20,
+ 0x20,0x80,0x40,0x40,0xf8,0x80,0x80,0x80,
+ 0x40,0x40,0x40,0x40,0x20,0x20,0x70,0x88,
+ 0x88,0x88,0x88,0x88,0x88,0x70,0x40,0x40,
+ 0x40,0x40,0x40,0x40,0xc0,0x40,0xf8,0x80,
+ 0x40,0x30,0x08,0x08,0x88,0x70,0x70,0x88,
+ 0x08,0x08,0x30,0x08,0x88,0x70,0x10,0x10,
+ 0xf8,0x90,0x50,0x50,0x30,0x10,0x70,0x88,
+ 0x08,0x08,0xf0,0x80,0x80,0xf8,0x70,0x88,
+ 0x88,0xc8,0xb0,0x80,0x88,0x70,0x40,0x40,
+ 0x20,0x20,0x10,0x10,0x08,0xf8,0x70,0x88,
+ 0x88,0x88,0x70,0x88,0x88,0x70,0x70,0x88,
+ 0x08,0x68,0x98,0x88,0x88,0x70,0x80,0x00,
+ 0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x00,
+ 0x00,0x00,0x00,0x40,0x20,0x40,0x80,0x40,
+ 0x20,0xf0,0x00,0xf0,0x80,0x40,0x20,0x40,
+ 0x80,0x40,0x00,0x40,0x40,0x20,0x10,0x90,
+ 0x60,0x3e,0x00,0x40,0x00,0x9b,0x00,0xa4,
+ 0x80,0xa4,0x80,0xa2,0x40,0x92,0x40,0x4d,
+ 0x40,0x20,0x80,0x1f,0x00,0x82,0x82,0x7c,
+ 0x44,0x28,0x28,0x10,0x10,0xf0,0x88,0x88,
+ 0x88,0xf0,0x88,0x88,0xf0,0x78,0x84,0x80,
+ 0x80,0x80,0x80,0x84,0x78,0xf0,0x88,0x84,
+ 0x84,0x84,0x84,0x88,0xf0,0xf8,0x80,0x80,
+ 0x80,0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,
+ 0x80,0xf0,0x80,0x80,0xf8,0x74,0x8c,0x84,
+ 0x8c,0x80,0x80,0x84,0x78,0x84,0x84,0x84,
+ 0x84,0xfc,0x84,0x84,0x84,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x60,0x90,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x88,0x88,0x90,
+ 0x90,0xe0,0xa0,0x90,0x88,0xf0,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x92,0x92,0x92,
+ 0xaa,0xaa,0xc6,0xc6,0x82,0x8c,0x8c,0x94,
+ 0x94,0xa4,0xa4,0xc4,0xc4,0x78,0x84,0x84,
+ 0x84,0x84,0x84,0x84,0x78,0x80,0x80,0x80,
+ 0x80,0xf0,0x88,0x88,0xf0,0x02,0x7c,0x8c,
+ 0x94,0x84,0x84,0x84,0x84,0x78,0x88,0x88,
+ 0x88,0x88,0xf0,0x88,0x88,0xf0,0x70,0x88,
+ 0x88,0x08,0x70,0x80,0x88,0x70,0x20,0x20,
+ 0x20,0x20,0x20,0x20,0x20,0xf8,0x78,0x84,
+ 0x84,0x84,0x84,0x84,0x84,0x84,0x10,0x28,
+ 0x28,0x44,0x44,0x44,0x82,0x82,0x22,0x00,
+ 0x22,0x00,0x22,0x00,0x55,0x00,0x49,0x00,
+ 0x49,0x00,0x88,0x80,0x88,0x80,0x88,0x88,
+ 0x50,0x50,0x20,0x50,0x88,0x88,0x10,0x10,
+ 0x10,0x28,0x28,0x44,0x44,0x82,0xf8,0x80,
+ 0x40,0x20,0x20,0x10,0x08,0xf8,0xc0,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
+ 0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,
+ 0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
+ 0x40,0xc0,0x88,0x50,0x50,0x20,0x20,0xfc,
+ 0x80,0x80,0x40,0x68,0x90,0x90,0x70,0x10,
+ 0xe0,0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,
+ 0x80,0x60,0x90,0x80,0x80,0x90,0x60,0x68,
+ 0x98,0x88,0x88,0x98,0x68,0x08,0x08,0x60,
+ 0x90,0x80,0xf0,0x90,0x60,0x40,0x40,0x40,
+ 0x40,0x40,0xe0,0x40,0x30,0x70,0x08,0x68,
+ 0x98,0x88,0x88,0x98,0x68,0x88,0x88,0x88,
+ 0x88,0xc8,0xb0,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x00,0x80,0x90,0x90,
+ 0xa0,0xc0,0xa0,0x90,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x92,0x92,
+ 0x92,0x92,0x92,0xec,0x88,0x88,0x88,0x88,
+ 0xc8,0xb0,0x70,0x88,0x88,0x88,0x88,0x70,
+ 0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,
+ 0x08,0x08,0x68,0x98,0x88,0x88,0x98,0x68,
+ 0x80,0x80,0x80,0x80,0xc0,0xa0,0x60,0x90,
+ 0x10,0x60,0x90,0x60,0x60,0x40,0x40,0x40,
+ 0x40,0xe0,0x40,0x40,0x70,0x90,0x90,0x90,
+ 0x90,0x90,0x20,0x20,0x50,0x50,0x88,0x88,
+ 0x28,0x28,0x54,0x54,0x92,0x92,0x88,0x88,
+ 0x50,0x20,0x50,0x88,0x80,0x40,0x40,0x60,
+ 0xa0,0xa0,0x90,0x90,0xf0,0x80,0x40,0x20,
+ 0x10,0xf0,0x20,0x40,0x40,0x40,0x40,0x80,
+ 0x40,0x40,0x40,0x20,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,
+ 0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
+ 0x98,0x64,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x00,0x80,0x40,0x70,0xa8,0xa0,0xa0,0xa8,
+ 0x70,0x10,0xb0,0x48,0x40,0x40,0xe0,0x40,
+ 0x48,0x30,0x90,0x60,0x90,0x90,0x60,0x90,
+ 0x20,0xf8,0x20,0xf8,0x50,0x50,0x88,0x88,
+ 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,
+ 0x80,0x80,0x70,0x88,0x18,0x70,0xc8,0x98,
+ 0x70,0xc0,0x88,0x70,0xa0,0x38,0x44,0x9a,
+ 0xa2,0x9a,0x44,0x38,0xe0,0x00,0xa0,0x20,
+ 0xe0,0x28,0x50,0xa0,0x50,0x28,0x08,0x08,
+ 0xf8,0xe0,0x38,0x44,0xaa,0xb2,0xba,0x44,
+ 0x38,0xe0,0x60,0x90,0x90,0x60,0xf8,0x00,
+ 0x20,0x20,0xf8,0x20,0x20,0xe0,0x40,0xa0,
+ 0x60,0xc0,0x20,0x40,0xe0,0x80,0x40,0x80,
+ 0x80,0xf0,0x90,0x90,0x90,0x90,0x90,0x28,
+ 0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,
+ 0x7c,0xc0,0xc0,0x40,0x40,0x40,0xc0,0x40,
+ 0xe0,0x00,0xe0,0xa0,0xe0,0xa0,0x50,0x28,
+ 0x50,0xa0,0x21,0x00,0x17,0x80,0x13,0x00,
+ 0x09,0x00,0x48,0x00,0x44,0x00,0xc4,0x00,
+ 0x42,0x00,0x27,0x12,0x15,0x0b,0x48,0x44,
+ 0xc4,0x42,0x21,0x00,0x17,0x80,0x13,0x00,
+ 0x09,0x00,0xc8,0x00,0x24,0x00,0x44,0x00,
+ 0xe2,0x00,0x60,0x90,0x80,0x40,0x20,0x20,
+ 0x00,0x20,0x82,0x82,0x7c,0x44,0x28,0x28,
+ 0x10,0x10,0x00,0x10,0x20,0x82,0x82,0x7c,
+ 0x44,0x28,0x28,0x10,0x10,0x00,0x10,0x08,
+ 0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
+ 0x00,0x28,0x10,0x82,0x82,0x7c,0x44,0x28,
+ 0x28,0x10,0x10,0x00,0x28,0x14,0x82,0x82,
+ 0x7c,0x44,0x28,0x28,0x10,0x10,0x00,0x28,
+ 0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
+ 0x10,0x28,0x10,0x8f,0x80,0x88,0x00,0x78,
+ 0x00,0x48,0x00,0x2f,0x80,0x28,0x00,0x18,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list