Check if font file exists

This commit is contained in:
Yannis
2026-02-04 01:02:22 +01:00
committed by kbz_8
parent db299c6930
commit 87059f8ca3

View File

@@ -304,6 +304,11 @@ extern "C"
mlx::Error("Font loader: filepath is NULL"); mlx::Error("Font loader: filepath is NULL");
return; return;
} }
if (!std::filesystem::exists(filepath))
{
mlx::Error("TTF loader: unable to find file '%'", filepath);
return;
}
std::filesystem::path file(filepath); 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")
{ {
@@ -324,6 +329,11 @@ extern "C"
mlx::Error("Font loader: filepath is NULL"); mlx::Error("Font loader: filepath is NULL");
return; return;
} }
if (!std::filesystem::exists(filepath))
{
mlx::Error("TTF loader: unable to find file '%'", filepath);
return;
}
std::filesystem::path file(filepath); 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")
{ {