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/editors/space_file/filelist.c
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/editors/space_file/filelist.c')
-rw-r--r--source/blender/editors/space_file/filelist.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 6ac67a126cd..93c27e1fe90 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -37,6 +37,8 @@
#endif
#include "MEM_guardedalloc.h"
+#include "BLF_api.h"
+
#include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_fileops_types.h"
@@ -1812,13 +1814,23 @@ BlendHandle *filelist_lib(struct FileList *filelist)
return filelist->libfiledata;
}
-static const char *fileentry_uiname(const char *root,
- const char *relpath,
- const eFileSel_File_Types typeflag,
- char *buff)
+static char *fileentry_uiname(const char *root,
+ const char *relpath,
+ const eFileSel_File_Types typeflag,
+ char *buff)
{
char *name = NULL;
+ if (typeflag & FILE_TYPE_FTFONT && !(typeflag & FILE_TYPE_BLENDERLIB)) {
+ char abspath[FILE_MAX_LIBEXTRA];
+ BLI_join_dirfile(abspath, sizeof(abspath), root, relpath);
+ name = BLF_display_name_from_file(abspath);
+ if (name) {
+ /* Allocated string, so no need to BLI_strdup.*/
+ return name;
+ }
+ }
+
if (typeflag & FILE_TYPE_BLENDERLIB) {
char abspath[FILE_MAX_LIBEXTRA];
char *group;
@@ -1840,7 +1852,7 @@ static const char *fileentry_uiname(const char *root,
}
BLI_assert(name);
- return name;
+ return BLI_strdup(name);
}
const char *filelist_dir(struct FileList *filelist)
@@ -3203,7 +3215,7 @@ static void filelist_readjob_do(const bool do_lib,
MEM_freeN(entry->relpath);
entry->relpath = BLI_strdup(dir + 2); /* + 2 to remove '//'
* added by BLI_path_rel to rel_subdir. */
- entry->name = BLI_strdup(fileentry_uiname(root, entry->relpath, entry->typeflag, dir));
+ entry->name = fileentry_uiname(root, entry->relpath, entry->typeflag, dir);
entry->free_name = true;
/* Here we decide whether current filedirentry is to be listed too, or not. */