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:
authorCampbell Barton <ideasman42@gmail.com>2013-12-28 12:45:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-28 12:45:54 +0400
commit2654b28f046ea3a444717ebc7f36f9b5ef22f7f1 (patch)
tree56dc15d7c666bc54413c35f8278487b948710fb7 /source/blender/blenlib/intern/freetypefont.c
parent1aa62605cdf7c43085c9d1db606b2c0c460e9897 (diff)
Text3d: avoid calculating the font boundbox scale for every character
Diffstat (limited to 'source/blender/blenlib/intern/freetypefont.c')
-rw-r--r--source/blender/blenlib/intern/freetypefont.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index f9e09abef54..43cf6c665c2 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -65,6 +65,7 @@ static FT_Error err;
static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd)
{
+ const float scale = vfd->scale;
const float eps = 0.0001f;
const float eps_sq = eps * eps;
/* Blender */
@@ -76,17 +77,9 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
FT_GlyphSlot glyph;
FT_UInt glyph_index;
FT_Outline ftoutline;
- float scale, height;
float dx, dy;
int j, k, l, m = 0;
- /* adjust font size */
- height = ((double) face->bbox.yMax - (double) face->bbox.yMin);
- if (height != 0.0f)
- scale = 1.0f / height;
- else
- scale = 1.0f / 1000.0f;
-
/*
* Generate the character 3D data
*
@@ -403,6 +396,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
lcode = charcode = FT_Get_First_Char(face, &glyph_index);
}
+
+ /* Adjust font size */
+ if (face->bbox.yMax != face->bbox.yMin) {
+ vfd->scale = (float)(1.0 / (double)(face->bbox.yMax - face->bbox.yMin));
+ }
+ else {
+ vfd->scale = 1.0f / 1000.0f;
+ }
+
/* Load characters */
vfd->characters = BLI_ghash_int_new_ex(__func__, charcode_reserve);