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-02-19 19:39:36 +0300
committerDiego Borghetti <bdiego@gmail.com>2009-02-19 19:39:36 +0300
commit6bf9f383dc3d0dc271dd3ffa3e22becea5675530 (patch)
tree2a77c248e1cb9952e5474cce1b7714b9b77e4be2 /source/blender/blenfont/intern/blf.c
parentf377be3783937e5979efa9952296af1a72909a54 (diff)
4 new function, boundbox, width, height and rotation.
The rotation is through glRotatef and as you can see it's ugly, the freetype2 allow apply a transformation (2x2 mat) to the glyph before load, so I want to try using that. Another thing to add is the 4x4 mat to get the scale and size from there.. but I need commit this now to continue from my home.
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r--source/blender/blenfont/intern/blf.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 491d39aa301..1b29f3ebdd8 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#ifdef WITH_FREETYPE2
@@ -229,9 +230,26 @@ void BLF_position(float x, float y, float z)
{
#ifdef WITH_FREETYPE2
FontBLF *font;
+ float remainder;
font= global_font[global_font_cur];
if (font) {
+ remainder= x - floor(x);
+ if (remainder > 0.4 && remainder < 0.6) {
+ if (remainder < 0.5)
+ x -= 0.1 * font->aspect;
+ else
+ x += 0.1 * font->aspect;
+ }
+
+ remainder= y - floor(y);
+ if (remainder > 0.4 && remainder < 0.6) {
+ if (remainder < 0.5)
+ y -= 0.1 * font->aspect;
+ else
+ y += 0.1 * font->aspect;
+ }
+
font->pos[0]= x;
font->pos[1]= y;
font->pos[2]= z;
@@ -263,6 +281,8 @@ void BLF_draw(char *str)
glPushMatrix();
glTranslatef(font->pos[0], font->pos[1], font->pos[2]);
+ glScalef(font->aspect, font->aspect, 1.0);
+ glRotatef(font->angle, 0.0f, 0.0f, 1.0f);
blf_font_draw(font, str);
@@ -272,3 +292,49 @@ void BLF_draw(char *str)
}
#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
+}
+
+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
+ 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
+ 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
+}