diff options
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 8 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 48 |
2 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 44d3cf2c61b..57f8c83eda6 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -91,6 +91,14 @@ float BLF_width(int fontid, const char *str); float BLF_height(int fontid, const char *str); /* + * Return dimensions of the font without any sample text. + */ +float BLF_height_max(int fontid); +float BLF_width_max(int fontid); +float BLF_descender(int fontid); +float BLF_ascender(int fontid); + +/* * The following function return the width and height of the string, but * just in one call, so avoid extra freetype2 stuff. */ diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 5db71948024..c0e62b1c0c7 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -580,6 +580,54 @@ float BLF_height(int fontid, const char *str) return(0.0f); } +float BLF_height_max(int fontid) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) { + if(font->glyph_cache) + return(font->glyph_cache->max_glyph_height); + } + return(0.0f); +} + +float BLF_width_max(int fontid) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) { + if(font->glyph_cache) + return(font->glyph_cache->max_glyph_width); + } + return(0.0f); +} + +float BLF_descender(int fontid) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) { + if(font->glyph_cache) + return(font->glyph_cache->descender); + } + return(0.0f); +} + +float BLF_ascender(int fontid) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) { + if(font->glyph_cache) + return(font->glyph_cache->ascender); + } + return(0.0f); +} + float BLF_height_default(const char *str) { float height; |