| 86 | |
| 87 | |
| 88 | void Font::loadFile(const std::string& filename, NVGcontext* vg) { |
| 89 | this->vg = vg; |
| 90 | std::string name = system::getStem(filename); |
| 91 | size_t size; |
| 92 | // Transfer ownership of font data to font object |
| 93 | uint8_t* data = system::readFile(filename, &size); |
| 94 | // Don't use nvgCreateFont because it doesn't properly handle UTF-8 filenames on Windows. |
| 95 | handle = nvgCreateFontMem(vg, name.c_str(), data, size, 1); |
| 96 | if (handle < 0) { |
| 97 | throw Exception("Failed to load font %s", filename.c_str()); |
| 98 | } |
| 99 | INFO("Loaded font %s", filename.c_str()); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | std::shared_ptr<Font> Font::load(const std::string& filename) { |
no test coverage detected