From 1dc93f1919c68169cb32c83b2ff7095207449ce4 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 10 Feb 2025 17:46:36 +1000 Subject: [PATCH] Don't use specific kilolitres codepoint glyph in WebAssembly The font we use doesn't support that glyph, so work around it. --- src/units.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/units.cpp b/src/units.cpp index 44f445835..1dca38963 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -309,7 +309,15 @@ quantityInfo Units::getDisplayTextWithHysteresis(VenusOS::Enums::Units_Type unit if (unit == VenusOS::Enums::Units_Volume_Liter) { if (isOverLimit(scaleMatch, VenusOS::Enums::Units_Scale_Kilo, previousScale)) { // \u2113 = l, \u3398 = kl +#if defined(VENUS_WEBASSEMBLY_BUILD) + // The Roboto-Regular.ttf font used in WebAssembly builds doesn't provide a glyph for the \u3398 codepoint. + // We could pass the Global._quantityFontLoader font file to this method via getDisplayText() + // and then use QFontMetrics::inFont(QChar('\u3398')) to determine its existence programmatically, + // but then if there were per-language fallbacks this wouldn't work. So, just hardcode a workaround. + quantity.unit = QStringLiteral("k\u2113"); +#else quantity.unit = QStringLiteral("\u3398"); +#endif quantity.scale = VenusOS::Enums::Units_Scale_Kilo; scaledValue = scaledValue / 1000.0; }