MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / Font

Method Font

framework/gui.h:68–82  ·  view source on GitHub ↗

* @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 */

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 2

read_assetFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected