diff --git a/src/ui/material/typography.cpp b/src/ui/material/typography.cpp index 6b5260b..05222fb 100644 --- a/src/ui/material/typography.cpp +++ b/src/ui/material/typography.cpp @@ -34,13 +34,21 @@ namespace material { const TypeSpec* Typography::getTypeSpecs() { - // Rebuild each call to pick up hot-reloaded values + // Memoized on the schema generation. Every input (typography.* and fonts.*) is read via + // schema::UI().drawElement, and UISchema bumps generation() on each loadFromFile / loadFromString / + // mergeOverlayFromFile (startup, hot-reload, skin/theme switch). ~0u sentinel: generation_ starts at 0, + // so the first call always builds (pre-load defaults), then the first load rebuilds. + // DPI / font scale / language are NOT inputs (kFont*() are raw schema px). UI thread only, as before. static TypeSpec specs[kNumStyles]; + static uint32_t s_builtGen = ~0u; // Helper: read typography entry from UISchema auto& S = schema::UI(); + const uint32_t gen = S.generation(); + if (gen == s_builtGen) return specs; + s_builtGen = gen; auto tspec = [&](const char* key, float defLS, float defLH, bool defUpper) -> TypeSpec { - auto e = S.drawElement("typography", key); + const auto& e = S.drawElement("typography", key); // ref into styleCache_: never let it escape this lambda float ls = e.getFloat("letter-spacing", defLS); float lh = e.getFloat("line-height", defLH); // text-transform stored as extraColors (string map)