Skip to content

Commit

Permalink
Don't use specific kilolitres codepoint glyph in WebAssembly
Browse files Browse the repository at this point in the history
The font we use doesn't support that glyph, so work around it.
  • Loading branch information
chriadam committed Feb 10, 2025
1 parent 65b9215 commit 1dc93f1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1dc93f1

Please sign in to comment.