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

Merge pull request #378 from jlmjlm/fakemob-font

Make fake-mobile fail cleanly if font missing.
This commit is contained in:
Zeno Rogue 2024-05-28 13:36:01 +02:00 committed by GitHub
commit e66f071521
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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);