Skip to content

Commit 0818fc0

Browse files
committed
Add system font last to avoid assert failures when selecting fonts
1 parent a144ccd commit 0818fc0

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

kauai/src/fontsdl.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,6 @@ bool NTL::FInit(void)
104104

105105
// TODO: enumerate fonts
106106

107-
// Add system font
108-
stnFontName = "System";
109-
AssertDo(FAddFontName(stnFontName.Psz(), &onn, &pglsdlfont), "Could not add system font");
110-
111-
stnFontPath = "C:\\windows\\fonts\\vgasys.fon";
112-
AssertDo(fniFont.FBuildFromPath(&stnFontPath), "Could not build path to font");
113-
AssertDo(psdlfComicSans = SDLFontFile::PSDLFontFileNew(&fniFont, (fontBold | fontItalic)),
114-
"Could not allocate font");
115-
pglsdlfont->FAdd(&psdlfComicSans);
116-
ReleasePpo(&pglsdlfont);
117-
118107
// Add Comic Sans MS
119108
stnFontName = "Comic Sans MS";
120109
AssertDo(FAddFontName(stnFontName.Psz(), &onn, &pglsdlfont), "Could not add system font");
@@ -146,6 +135,18 @@ bool NTL::FInit(void)
146135

147136
ReleasePpo(&pglsdlfont);
148137

138+
// Add a system default font last
139+
stnFontName = "System";
140+
AssertDo(FAddFontName(stnFontName.Psz(), &onn, &pglsdlfont), "Could not add system font");
141+
_onnSystem = onn;
142+
143+
// TODO: package a default font
144+
stnFontPath = "C:\\windows\\fonts\\vgasys.fon";
145+
AssertDo(fniFont.FBuildFromPath(&stnFontPath), "Could not build path to font");
146+
AssertDo(psdlfComicSans = SDLFontFile::PSDLFontFileNew(&fniFont, fontAll), "Could not allocate font");
147+
pglsdlfont->FAdd(&psdlfComicSans);
148+
ReleasePpo(&pglsdlfont);
149+
149150
return fTrue;
150151

151152
LFail:

0 commit comments

Comments
 (0)