MCPcopy Create free account
hub / github.com/VCVRack/Rack / loadFile

Method loadFile

src/window/Window.cpp:48–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48void Font::loadFile(const std::string& filename, NVGcontext* vg) {
49 this->vg = vg;
50 std::string name = system::getStem(filename);
51 size_t size;
52 // Transfer ownership of font data to font object
53 uint8_t* data = system::readFile(filename, &size);
54 // Don't use nvgCreateFont because it doesn't properly handle UTF-8 filenames on Windows.
55 handle = nvgCreateFontMem(vg, name.c_str(), data, size, 0);
56 if (handle < 0) {
57 std::free(data);
58 throw Exception("Failed to load font %s", filename.c_str());
59 }
60 INFO("Loaded font %s", filename.c_str());
61}
62
63
64std::shared_ptr<Font> Font::load(const std::string& filename) {

Callers 2

loadImageMethod · 0.45

Calls 4

getStemFunction · 0.85
readFileFunction · 0.85
ExceptionClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected