diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2022-07-07 22:59:16 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2022-07-07 22:59:16 +0300 |
commit | b9c0eed206b0d7d1b6af6809c6d2cb6c2187bcc8 (patch) | |
tree | a84d8653a5e2c1e9a40d4f37877b2f5672ab142e /source/blender/blenfont/intern/blf_font.c | |
parent | fc06b4c03356b5b9a272df8a2b96b6c4f9254ee7 (diff) |
BLF: Add Support for Variable Fonts
Add support for Variable/Multiple Master font features. These are fonts
that contain a range of design variations along multiple axes. This
contains no client-facing options.
See D12977 for details and examples
Differential Revision: https://developer.blender.org/D12977
Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3e2927d581e..038e73cc928 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,7 +18,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { + FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { + FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } + if (font->variations) { + FT_Done_MM_Var(ft_lib, font->variations); + } + FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); |