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:
authorHarley Acheson <harley.acheson@gmail.com>2021-07-28 21:16:04 +0300
committerHarley Acheson <harley.acheson@gmail.com>2021-07-28 21:16:04 +0300
commit8aa1c0a326a838528470e79abad3abec343d1c9f (patch)
tree2f3aeeffdadb80451074c5ccf2eae3aaa6a093b2 /source/blender/blenfont
parent073bf8bf52edbb6f53fb6bbbecc26f20b91e8c43 (diff)
Fix T75028: Improved Font Names in File Manager
When viewing font files in the File Manager, this patch uses the font's family and style names to show the same type of string shown to users in operating system lists. For example "Book Antiqua Regular" instead of "BKANT.ttf" see D12020 for details and examples. Differential Revision: https://developer.blender.org/D12020 Reviewed by Campbell Barton and Julian Eisel
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_api.h2
-rw-r--r--source/blender/blenfont/intern/blf.c11
-rw-r--r--source/blender/blenfont/intern/blf_font.c8
-rw-r--r--source/blender/blenfont/intern/blf_internal.h2
4 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 1f39257a4c2..7e92f79a523 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -53,6 +53,8 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name) ATTR_NONNULL();
void BLF_unload_id(int fontid);
+char *BLF_display_name_from_file(const char *filename);
+
/* Check if font supports a particular glyph. */
bool BLF_has_glyph(int fontid, unsigned int unicode);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 7428798581d..9168e7aa19c 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -915,6 +915,17 @@ void BLF_draw_buffer(int fontid, const char *str, size_t len)
BLF_draw_buffer_ex(fontid, str, len, NULL);
}
+char *BLF_display_name_from_file(const char *filename)
+{
+ FontBLF *font = blf_font_new("font_name", filename);
+ if (!font) {
+ return NULL;
+ }
+ char *name = blf_display_name(font);
+ blf_font_free(font);
+ return name;
+}
+
#ifdef DEBUG
void BLF_state_print(int fontid)
{
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 74c4c684d6b..53c4135254a 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -1465,3 +1465,11 @@ float blf_font_ascender(FontBLF *font)
blf_glyph_cache_release(font);
return ascender;
}
+
+char *blf_display_name(FontBLF *font)
+{
+ if (!font->face->family_name) {
+ return NULL;
+ }
+ return BLI_sprintfN("%s %s", font->face->family_name, font->face->style_name);
+}
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index 63e1eb999cd..35a6d019eac 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -99,6 +99,8 @@ int blf_font_width_max(struct FontBLF *font);
float blf_font_descender(struct FontBLF *font);
float blf_font_ascender(struct FontBLF *font);
+char *blf_display_name(struct FontBLF *font);
+
void blf_font_boundbox_foreach_glyph(struct FontBLF *font,
const char *str,
size_t len,