1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-09 15:39:55 +00:00

Make fake-mobile fail cleanly if font missing.

This commit is contained in:
Jacob Mandelson 2024-05-16 19:30:39 -07:00
parent 7b3d2c2626
commit efc2ce90e0

View File

@ -1,5 +1,8 @@
// Hyperbolic Rogue -- fake mobile target // Hyperbolic Rogue -- fake mobile target
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
//
// Compile with: g++ fake-mobile.cpp -o fake-mobile -I/usr/include/SDL -lSDL -lSDL_gfx -lGL -lSDL_ttf -lz -Wno-invalid-offsetof
// Copy/link font file "VeraBd.ttf" to the current directory if needed.
#define ISFAKEMOBILE 1 #define ISFAKEMOBILE 1
#define MOBPAR_FORMAL int #define MOBPAR_FORMAL int
@ -96,6 +99,10 @@ int textwidth(int siz, const string &str) {
if(isize(str) == 0) return 0; if(isize(str) == 0) return 0;
if(!font[siz]) font[siz] = TTF_OpenFont("VeraBd.ttf", siz); if(!font[siz]) font[siz] = TTF_OpenFont("VeraBd.ttf", siz);
if(!font[siz]) {
fprintf(stderr, "TTF_OpenFont(\"VeraBd.ttf\", %d) failed\n", siz);
exit(1);
}
int w, h; int w, h;
TTF_SizeUTF8(font[siz], str.c_str(), &w, &h); TTF_SizeUTF8(font[siz], str.c_str(), &w, &h);