Second 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:
Filip Sykala - NTB T15p 2023-02-23 12:01:26 +01:00
parent 20c72c527a
commit 650447cf02

View File

@ -55,13 +55,10 @@ static std::string get_file_path(const wxFont& font) {
if (url == NULL) return {};
wxString file_uri;
wxCFTypeRef(url).GetValue(file_uri);
std::string file_path(wxURI::Unescape(file_uri).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;
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() << ").";
return std::string(path.c_str());
}
#endif // __APPLE__
} // namespace