MCPcopy Create free account
hub / github.com/FastLED/FastLED / loadFontFile

Function loadFontFile

tests/fl/font/truetype.cpp:22–47  ·  view source on GitHub ↗

Helper function to load a font file

Source from the content-addressed store, hash-verified

20
21// Helper function to load a font file
22fl::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

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 7

setTestFileSystemRootFunction · 0.85
beginSdMethod · 0.80
openReadMethod · 0.45
is_openMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected