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:
authorRob Haarsma <phaseIV@zonnet.nl>2004-01-16 15:49:43 +0300
committerRob Haarsma <phaseIV@zonnet.nl>2004-01-16 15:49:43 +0300
commit0ef6f7e92798d862de39260203332c23d9da72e8 (patch)
treea7fd713d9b0bf011d02fed66383458ac1da6fb47 /source/blender/blenlib/intern/freetypefont.c
parentfb6133264ad8146816a28eceebd5f5a4c83b200a (diff)
Corrected the line distance behaviour for Text objects.
The font vectordata is scaled on load, so the character size will fit between the default (1.0) linedist. Warning: this might change the font size in older blend files. (read: breaks backward compatibility)
Diffstat (limited to 'source/blender/blenlib/intern/freetypefont.c')
-rw-r--r--source/blender/blenlib/intern/freetypefont.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 4acc6234500..01520714e1c 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -42,6 +42,8 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
+#include FT_BBOX_H
+#include FT_SIZES_H
#include <freetype/ttnameid.h>
#include "MEM_guardedalloc.h"
@@ -64,7 +66,6 @@
static FT_Library library;
static FT_Error err;
-
static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
{
// Blender
@@ -77,6 +78,8 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
FT_GlyphSlot glyph;
FT_UInt glyph_index;
FT_Outline ftoutline;
+ FT_Size ftsize;
+
/*
FT_CharMap found = 0;
FT_CharMap charmap;
@@ -84,9 +87,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
FT_UShort my_encoding_id = TT_MS_ID_UNICODE_CS;
int n;
*/
- //scale needs text_height from freetype metrics to make a standard linedist,
- //is currently set to generic value
- float scale= 1. / 1024.;
+ float scale, height;
float dx, dy;
int i, j, k, l, m;
@@ -119,7 +120,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
// allocate blender font
vfd= MEM_callocN(sizeof(*vfd), "FTVFontData");
- strcpy(vfd->name, FT_Get_Postscript_Name(face));
+ strcpy(vfd->name, FT_Get_Postscript_Name(face));
+
+ // adjust font size
+ height = ((double) face->bbox.yMax - (double) face->bbox.yMin);
+
+ if(height != 0.0)
+ scale = 1.0 / height;
+ else
+ scale = 1.0 / 1000.0;
// extract generic ascii character range
for(i = myMIN_ASCII; i <= myMAX_ASCII; i++) {