added fullbright

This commit is contained in:
st committed 2026-10-13 02:04:50 -05:00
1 parent fafeee709f
commit b1634d195c
21 files changed
+1263 -204

No files matched your search

+74
View File
@@ -0,0 +1,74 @@
#pragma once
#include <windows.h>
#include <string>
#include "imgui.h"
// optional fallback if the Segoe UI files can't be found
#if __has_include("../font_data.h")
#include "../font_data.h"
#define AMNESIA_HAS_FONT 1
#else
#define AMNESIA_HAS_FONT 0
#endif
namespace fonts {
inline constexpr float k_body_size = 14.f; // launcher base font size
inline constexpr float k_label_size = 11.f; // the small uppercase labels
inline constexpr float k_heading_size = 20.f;
inline ImFont* body = nullptr; // Segoe UI
inline ImFont* semibold = nullptr; // Segoe UI Semibold (buttons, module names)
inline ImFont* label = nullptr; // Segoe UI Bold
inline ImFont* heading = nullptr; // Segoe UI Semibold, larger
// PushFont changed signature in ImGui 1.92 (fonts became size-flexible)
inline void push_font(ImFont* font, float size) {
#if IMGUI_VERSION_NUM >= 19200
ImGui::PushFont(font, size);
#else
(void)size;
ImGui::PushFont(font);
#endif
}
inline ImVec2 text_size(ImFont* font, float size, const char* text) {
push_font(font, size);
const ImVec2 ts = ImGui::CalcTextSize(text);
ImGui::PopFont();
return ts;
}
inline bool windows_font_path(const char* file, std::string& out) {
char dir[MAX_PATH] = {};
const UINT n = GetWindowsDirectoryA(dir, MAX_PATH);
if (n == 0 || n >= MAX_PATH) return false;
out = std::string(dir) + "\\Fonts\\" + file;
return GetFileAttributesA(out.c_str()) != INVALID_FILE_ATTRIBUTES;
}
inline ImFont* load_one(ImGuiIO& io, const char* file, float size) {
std::string path;
if (windows_font_path(file, path)) {
if (ImFont* f = io.Fonts->AddFontFromFileTTF(path.c_str(), size)) return f;
}
#if AMNESIA_HAS_FONT
ImFontConfig cfg;
cfg.FontDataOwnedByAtlas = false;
return io.Fonts->AddFontFromMemoryTTF((void*)k_font_data, (int)k_font_size, size, &cfg);
#else
return io.Fonts->AddFontDefault();
#endif
}
// after ImGui::CreateContext(), before the backends are initialized
inline void load() {
ImGuiIO& io = ImGui::GetIO();
body = load_one(io, "segoeui.ttf", k_body_size);
semibold = load_one(io, "seguisb.ttf", k_body_size);
label = load_one(io, "segoeuib.ttf", k_label_size);
heading = load_one(io, "seguisb.ttf", k_heading_size);
io.FontDefault = body;
}
} // namespace fonts