| 46 | |
| 47 | |
| 48 | void 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 | |
| 64 | std::shared_ptr<Font> Font::load(const std::string& filename) { |