* @brief Constructor * @param name_ The name of the font file that exists within 'assets/fonts' (without extension) * @param size_ The font size, scaled by DPI */
| 66 | */ |
| 67 | Font(const std::string &name_, float size_) : |
| 68 | name{name_}, data{vkb::fs::read_asset("fonts/" + name + ".ttf")}, size{size_} |
| 69 | { |
| 70 | // Keep ownership of the font data to avoid a double delete |
| 71 | ImFontConfig font_config{}; |
| 72 | font_config.FontDataOwnedByAtlas = false; |
| 73 | |
| 74 | if (size < 1.0f) |
| 75 | { |
| 76 | size = 20.0f; |
| 77 | } |
| 78 | |
| 79 | ImGuiIO &io = ImGui::GetIO(); |
| 80 | handle = io.Fonts->AddFontFromMemoryTTF(data.data(), static_cast<int>(data.size()), size, &font_config); |
| 81 | } |
| 82 | |
| 83 | ImFont *handle = nullptr; |
| 84 | std::string name; |
| 85 | std::vector<uint8_t> data; |
nothing calls this directly
no test coverage detected