Skip to content

Commit 146a113

Browse files
committed
misc: just check if font path exists
idfk why I didn't think of that before
1 parent d34dc6d commit 146a113

2 files changed

Lines changed: 3 additions & 18 deletions

File tree

src/main_tool_opengl3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ int run_main_tool(const std::string& imgui_ini_path)
213213

214214
if (!g_config->File.font.empty())
215215
{
216-
const auto& path = get_font_path(g_config->File.font);
217-
if (!path.empty())
216+
const fs::path& path = get_font_path(g_config->File.font);
217+
if (fs::exists(path))
218218
io.FontDefault =
219219
io.Fonts->AddFontFromFileTTF(path.string().c_str(), 16.0f, nullptr, io.Fonts->GetGlyphRangesDefault());
220220
}

src/util.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,6 @@ fs::path get_config_dir()
442442
return get_home_config_dir() / "oshot";
443443
}
444444

445-
static bool is_direct_path(const fs::path& p)
446-
{
447-
if (p.has_root_path())
448-
return true;
449-
450-
auto it = p.begin();
451-
if (it != p.end() && (*it == "." || *it == ".."))
452-
{
453-
++it;
454-
return it != p.end();
455-
}
456-
457-
return false;
458-
}
459-
460445
fs::path get_font_path(const std::string& font)
461446
{
462447
if (font.empty())
@@ -477,7 +462,7 @@ fs::path get_font_path(const std::string& font)
477462
#endif
478463

479464
fs::path font_path(font);
480-
if (is_direct_path(font_path))
465+
if (fs::exists(font_path))
481466
return font_path;
482467

483468
// Direct join (fast)

0 commit comments

Comments
 (0)