forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont_path_unix.cpp
48 lines (35 loc) · 908 Bytes
/
font_path_unix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Aseprite
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/font_path.h"
#include "base/fs.h"
#include <queue>
namespace app {
base::paths g_cache;
void get_font_dirs(base::paths& fontDirs)
{
if (!g_cache.empty()) {
fontDirs = g_cache;
return;
}
std::queue<std::string> q;
q.push("~/.fonts");
q.push("/usr/local/share/fonts");
q.push("/usr/share/fonts");
while (!q.empty()) {
std::string fontDir = q.front();
q.pop();
fontDirs.push_back(fontDir);
for (const auto& file : base::list_files(fontDir, base::ItemType::Directories)) {
std::string fullpath = base::join_path(fontDir, file);
q.push(fullpath); // Add subdirectory in the queue
}
}
g_cache = fontDirs;
}
} // namespace app