mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 22:12:59 +00:00 
			
		
		
		
	Merge pull request #378 from jlmjlm/fakemob-font
Make fake-mobile fail cleanly if font missing.
This commit is contained in:
		| @@ -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); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue