[Bf-blender-cvs] [b5bfb5f34c1] master: UI: VFont Display Names
Harley Acheson
noreply at git.blender.org
Wed Aug 4 17:34:37 CEST 2021
Commit: b5bfb5f34c1228df0ba673faf9d2a38a866115ac
Author: Harley Acheson
Date: Wed Aug 4 08:33:19 2021 -0700
Branches: master
https://developer.blender.org/rBb5bfb5f34c1228df0ba673faf9d2a38a866115ac
UI: VFont Display Names
When displaying the names of fonts for 3D Text objects, use the same
format as shown in File Browser: Family name + Style name. They are
currently shown with Postscript Name, which doesn't match well.
see D12069 for more details.
Differential Revision: https://developer.blender.org/D12069
Reviewed by Campbell Barton
===================================================================
M source/blender/blenlib/intern/freetypefont.c
===================================================================
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 98da85e3a8c..15c4910310f 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -40,6 +40,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLI_vfontdata.h"
@@ -286,7 +287,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
const FT_ULong charcode_reserve = 256;
FT_ULong charcode = 0, lcode;
FT_UInt glyph_index;
- const char *fontname;
VFontData *vfd;
/* load the freetype font */
@@ -299,9 +299,11 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
/* allocate blender font */
vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
- /* get the name */
- fontname = FT_Get_Postscript_Name(face);
- BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name));
+ /* Get the name. */
+ if (face->family_name) {
+ BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name);
+ BLI_utf8_invalid_strip(vfd->name, strlen(vfd->name));
+ }
/* Extract the first 256 character from TTF */
lcode = charcode = FT_Get_First_Char(face, &glyph_index);
More information about the Bf-blender-cvs
mailing list