Helper function to load a font file
| 20 | |
| 21 | // Helper function to load a font file |
| 22 | fl::vector<unsigned char> loadFontFile(const char* filename) { |
| 23 | fl::setTestFileSystemRoot("tests/fl/font/data"); |
| 24 | fl::FileSystem fs; |
| 25 | |
| 26 | // Initialize the filesystem (required for stub platform) |
| 27 | if (!fs.beginSd(0)) { |
| 28 | return fl::vector<unsigned char>(); |
| 29 | } |
| 30 | |
| 31 | auto file_handle = fs.openRead(filename); |
| 32 | if (!file_handle.is_open()) { |
| 33 | return fl::vector<unsigned char>(); |
| 34 | } |
| 35 | |
| 36 | // Get file size |
| 37 | fl::size size = file_handle.size(); |
| 38 | |
| 39 | // Read file into buffer |
| 40 | fl::vector<unsigned char> buffer(size); |
| 41 | fl::size bytes_read = file_handle.read(buffer.data(), size); |
| 42 | if (bytes_read != size) { |
| 43 | return fl::vector<unsigned char>(); |
| 44 | } |
| 45 | |
| 46 | return buffer; |
| 47 | } |
| 48 | |
| 49 | } // anonymous namespace |
| 50 |
no test coverage detected