Skip to content

Commit b301e9d

Browse files
committed
Add Noto Sans Simplified Chinese font. Fix crash if any UI fonts fail to load.
1 parent 16b2646 commit b301e9d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

res/fonts/NotoSansSC-Medium.otf

7.96 MB
Binary file not shown.

src/window/Window.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,20 @@ Window::Window() {
362362
throw Exception("Could not initialize NanoVG");
363363
}
364364

365-
// Load default UI font
365+
// Load UI fonts
366366
uiFont = loadFont(asset::system("res/fonts/DejaVuSans.ttf"));
367-
std::shared_ptr<Font> jpFont = loadFont(asset::system("res/fonts/NotoSansJP-Medium.otf"));
368-
nvgAddFallbackFontId(vg, uiFont->handle, jpFont->handle);
369-
std::shared_ptr<Font> emojiFont = loadFont(asset::system("res/fonts/NotoEmoji-Medium.ttf"));
370-
nvgAddFallbackFontId(vg, uiFont->handle, emojiFont->handle);
371-
bndSetFont(uiFont->handle);
367+
if (uiFont) {
368+
std::shared_ptr<Font> jpFont = loadFont(asset::system("res/fonts/NotoSansJP-Medium.otf"));
369+
if (jpFont)
370+
nvgAddFallbackFontId(vg, uiFont->handle, jpFont->handle);
371+
std::shared_ptr<Font> scFont = loadFont(asset::system("res/fonts/NotoSansSC-Medium.otf"));
372+
if (scFont)
373+
nvgAddFallbackFontId(vg, uiFont->handle, scFont->handle);
374+
std::shared_ptr<Font> emojiFont = loadFont(asset::system("res/fonts/NotoEmoji-Medium.ttf"));
375+
if (emojiFont)
376+
nvgAddFallbackFontId(vg, uiFont->handle, emojiFont->handle);
377+
bndSetFont(uiFont->handle);
378+
}
372379

373380
if (APP->scene) {
374381
widget::Widget::ContextCreateEvent e;

0 commit comments

Comments
 (0)