///////////////////////////////////////////////////////
| 157 | |
| 158 | //////////////////////////////////////////////////////////// |
| 159 | bool Font::openFromFile(const std::filesystem::path& filename) |
| 160 | { |
| 161 | using namespace std::string_view_literals; |
| 162 | |
| 163 | // Cleanup the previous resources |
| 164 | cleanup(); |
| 165 | |
| 166 | // Create the input stream and open the file |
| 167 | #ifndef SFML_SYSTEM_ANDROID |
| 168 | const auto stream = std::make_shared<FileInputStream>(); |
| 169 | const auto type = "file"sv; |
| 170 | #else |
| 171 | const auto stream = std::make_shared<priv::ResourceStream>(); |
| 172 | const auto type = "Android resource stream"sv; |
| 173 | #endif |
| 174 | |
| 175 | if (!stream->open(filename)) |
| 176 | { |
| 177 | err() << "Failed to load font (failed to open file): " << std::strerror(errno) << '\n' |
| 178 | << formatDebugPathInfo(filename) << std::endl; |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | // Open the font, and if succesful save the stream to keep it alive |
| 183 | if (openFromStreamImpl(*stream, type)) |
| 184 | { |
| 185 | m_stream = stream; |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | // If loading failed, print filename (after the error message already printed in openFromStreamImpl) |
| 190 | err() << formatDebugPathInfo(filename) << std::endl; |
| 191 | return false; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected