mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 18:10:48 +08:00
Try to fix conversion from uri to string path
'file://System/Library/Fonts/Helvetica.ttc#postscript-name=Helvetica' -> '/System/Library/Fonts/Helvetica.ttc'
This commit is contained in:
parent
20c72c527a
commit
d3e212486b
@ -43,6 +43,20 @@ static bool is_valid_ttf(std::string_view file_path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string get_path_from_file_uri(const wxString &file_uri)
|
||||||
|
{
|
||||||
|
wxURI uri(file_uri);
|
||||||
|
const wxString &path = uri.GetPath();
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "input uri(" << file_uri.c_str() << ") convert to path(" << path.c_str() << ").";
|
||||||
|
std::string file_path(path.c_str());
|
||||||
|
size_t start = std::string("file://").size();
|
||||||
|
if (file_path.empty() || file_path.size() <= start)
|
||||||
|
return {};
|
||||||
|
// remove prefix file://
|
||||||
|
file_path = file_path.substr(start, file_path.size() - start);
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
|
|
||||||
// get filepath from wxFont on Mac OsX
|
// get filepath from wxFont on Mac OsX
|
||||||
static std::string get_file_path(const wxFont& font) {
|
static std::string get_file_path(const wxFont& font) {
|
||||||
const wxNativeFontInfo *info = font.GetNativeFontInfo();
|
const wxNativeFontInfo *info = font.GetNativeFontInfo();
|
||||||
@ -55,13 +69,7 @@ static std::string get_file_path(const wxFont& font) {
|
|||||||
if (url == NULL) return {};
|
if (url == NULL) return {};
|
||||||
wxString file_uri;
|
wxString file_uri;
|
||||||
wxCFTypeRef(url).GetValue(file_uri);
|
wxCFTypeRef(url).GetValue(file_uri);
|
||||||
std::string file_path(wxURI::Unescape(file_uri).c_str());
|
return get_path_from_file_uri(file_uri);
|
||||||
size_t start = std::string("file://").size();
|
|
||||||
if (file_path.empty() || file_path.size() <= start)
|
|
||||||
return {};
|
|
||||||
// remove prefix file://
|
|
||||||
file_path = file_path.substr(start, file_path.size() - start);
|
|
||||||
return file_path;
|
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user