fixed issue with default font loading

This commit is contained in:
2026-02-04 07:23:26 +01:00
parent 87059f8ca3
commit 25fb5285f7

View File

@@ -304,12 +304,14 @@ extern "C"
mlx::Error("Font loader: filepath is NULL"); mlx::Error("Font loader: filepath is NULL");
return; return;
} }
if (!std::filesystem::exists(filepath))
std::filesystem::path file(filepath);
if (std::strcmp(filepath, "default") != 0 && filepath !std::filesystem::exists(file))
{ {
mlx::Error("TTF loader: unable to find file '%'", filepath); mlx::Error("TTF loader: unable to find file '%'", filepath);
return; return;
} }
std::filesystem::path file(filepath);
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte") if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
{ {
mlx::Error("TTF loader: not a truetype font file '%'", filepath); mlx::Error("TTF loader: not a truetype font file '%'", filepath);
@@ -329,12 +331,14 @@ extern "C"
mlx::Error("Font loader: filepath is NULL"); mlx::Error("Font loader: filepath is NULL");
return; return;
} }
if (!std::filesystem::exists(filepath))
std::filesystem::path file(filepath);
if (std::strcmp(filepath, "default") != 0 && filepath !std::filesystem::exists(file))
{ {
mlx::Error("TTF loader: unable to find file '%'", filepath); mlx::Error("TTF loader: unable to find file '%'", filepath);
return; return;
} }
std::filesystem::path file(filepath);
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte") if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
{ {
mlx::Error("TTF loader: not a truetype font file '%'", filepath); mlx::Error("TTF loader: not a truetype font file '%'", filepath);