Cogs.Core
FontInspector.cpp
1#include "Inspectors.h"
2
3#include "imgui.h"
4
5#include "Context.h"
6#include "Resources/FontManager.h"
7
8#include "InspectorGuiHelper.h"
9
10void Cogs::Core::fontInspector(Context * context, bool * show)
11{
12 if (*show) {
13 auto fonts = context->fontManager->getAllocatedResources();
14
15 // Begin window header.
16 std::string windowHeader;
17 windowHeader.reserve(20);
18 windowHeader.append("Fonts [");
19 windowHeader.append(std::to_string(fonts.size()));
20 windowHeader.append("]");
21
22 guiBegin(windowHeader, show);
23
24 std::string header;
25 header.reserve(512);
26 for (const auto & font : fonts) {
27 ResourceId id = font->getId();
28 header.clear();
29 header += std::to_string(id);
30 header += ":";
31 for (const auto& [def, h] : context->fontManager->sharedFonts) {
32 if (h.getId() == id) {
33 header += " ";
34 header += def.fontFamily;
35 header += " ";
36 header += std::to_string(def.fontSize);
37 break;
38 }
39 }
40
41 ImGui::Text("%s Refs: %u", header.c_str(), font->referenceCount());
42 }
43
44 guiEnd();
45 }
46}