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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-12 06:06:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-12 06:06:15 +0400
commit3116062a828e24ed2e91c219ab338a38030f2f42 (patch)
treefe77a0722deaee3afd521b4a596bbe5c1c827b2e /source/blender/blenfont
parent8b9bb47a3faf753cb0ca2ec0e9c6a741c7af31c2 (diff)
2.5: Couple of small fun features
* Text window font size now supports full range 8-32, instead of just 12 and 15. I added BLF_fixed_width to get the character width of a fixed size font. * Buttons do undo push on change again. * Animated/Keyframe/Driver colors are now themable, with blend value to blend with original color. Set this to 0.5 now to give colors less constrast. * Fix tooltip popping up with RMB menu open, and missing redraw. * Autokeyframe now works for buttons. * Driver expressions can be edited in place in a button now. (still some refresh issues). * Also made python driver default for the Add Driver function in the RMB button. This way you don't have to open a Graph editor if you just want to type an expression. Also, the default expression then is the current value. * Tooltips now show some extra info, not sure what is good to have, but currently I added: * Shortcut key for operator buttons. * Python struct & property name for RNA buttons. * Expression for driven values. * Value for text/search/pointer buttons.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_api.h7
-rw-r--r--source/blender/blenfont/intern/blf.c10
-rw-r--r--source/blender/blenfont/intern/blf_font.c21
-rw-r--r--source/blender/blenfont/intern/blf_internal.h1
4 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 99934a80143..b77f4a8fcd1 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -70,6 +70,13 @@ void BLF_boundbox(char *str, struct rctf *box);
float BLF_width(char *str);
float BLF_height(char *str);
+
+/*
+ * For fixed width fonts only, returns the width of a
+ * character.
+ */
+float BLF_fixed_width(void);
+
/*
* and this two function return the width and height
* of the string, using the default font and both value
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 9a249c2f241..cd7f969d5e5 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -398,6 +398,16 @@ float BLF_width(char *str)
return(0.0f);
}
+float BLF_fixed_width(void)
+{
+ FontBLF *font;
+
+ font= global_font[global_font_cur];
+ if (font)
+ return(blf_font_fixed_width(font));
+ return(0.0f);
+}
+
float BLF_width_default(char *str)
{
FontBLF *font;
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index affc35ea11e..6fc35a96e1e 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -274,6 +274,27 @@ float blf_font_height(FontBLF *font, char *str)
return((box.ymax - box.ymin) * font->aspect);
}
+float blf_font_fixed_width(FontBLF *font)
+{
+ GlyphBLF *g;
+ FT_UInt glyph_index;
+ unsigned int c = ' ';
+
+ if (!font->glyph_cache)
+ return 0.0f;
+
+ 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);
+
+ /* if we don't find the glyph. */
+ if (!g)
+ return 0.0f;
+
+ return g->advance;
+}
+
void blf_font_free(FontBLF *font)
{
GlyphCacheBLF *gc;
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index c9bdc428ebb..30d5c8ede65 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -48,6 +48,7 @@ void blf_font_draw(FontBLF *font, char *str);
void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
float blf_font_width(FontBLF *font, char *str);
float blf_font_height(FontBLF *font, char *str);
+float blf_font_fixed_width(FontBLF *font);
void blf_font_free(FontBLF *font);
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi);