From 312af01fb4faa7d1ff0dea4d2ef936caa9af4c67 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 5 Sep 2018 11:21:12 +1000 Subject: 3D Text: improvements to vertical alignment They way Blender handles vertical alignment is very buggy: - Top-Base: It works perfectly. - Bottom: It is actually bottom-baseline, and it fails when line size is != 1.0 when working with text boxes. - Top: Poorly implemented, it should use font's ascent (recommended distance from baseline), so it has room for accents, but it's not one line distance far from the origin (as it is now). - Center: Poorly implemented. This is tricky since there is no silver bullet. To clear this situation I created a new option (Bottom-Baseline), and addressed the issues above. I'm getting the ascent and descent from freetype2, and use this for padding above/below the text. Also for vertically centering the text. --- source/blender/blenlib/BLI_vfontdata.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenlib/BLI_vfontdata.h') diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index 1cc1ef17486..892d084f5ee 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -43,6 +43,9 @@ typedef struct VFontData { struct GHash *characters; char name[128]; float scale; + /* Calculated from the font. */ + float em_height; + float ascender; } VFontData; typedef struct VChar { -- cgit v1.2.3