mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-29 14:13:11 +00:00
fixed the font file name, also fixed the problem in rawdisplaystr
This commit is contained in:
parent
e66f071521
commit
ab0ca74328
@ -2,7 +2,6 @@
|
|||||||
// 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
|
// 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
|
||||||
@ -58,6 +57,17 @@ int gdpop() { return graphdata[gdpos++]; }
|
|||||||
|
|
||||||
TTF_Font *font[256];
|
TTF_Font *font[256];
|
||||||
|
|
||||||
|
const char* fontname = "DejaVuSans-Bold.ttf";
|
||||||
|
|
||||||
|
void load_font() {
|
||||||
|
if(!font[size])
|
||||||
|
font[size] = TTF_OpenFont(fontname, size);
|
||||||
|
if(!font[size]) {
|
||||||
|
fprintf(stderr, "failed to open font: %s", fontname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool rawdisplaystr(int x, int y, int shift, int size, const char *str, int color, int align) {
|
bool rawdisplaystr(int x, int y, int shift, int size, const char *str, int color, int align) {
|
||||||
|
|
||||||
if(strlen(str) == 0) return false;
|
if(strlen(str) == 0) return false;
|
||||||
@ -72,8 +82,7 @@ bool rawdisplaystr(int x, int y, int shift, int size, const char *str, int color
|
|||||||
|
|
||||||
col.r >>= darken; col.g >>= darken; col.b >>= darken;
|
col.r >>= darken; col.g >>= darken; col.b >>= darken;
|
||||||
|
|
||||||
if(!font[size])
|
load_font();
|
||||||
font[size] = TTF_OpenFont("DejaVuSans-Bold.ttf", size);
|
|
||||||
|
|
||||||
SDL_Surface *txt = TTF_RenderText_Solid(font[size], str, col);
|
SDL_Surface *txt = TTF_RenderText_Solid(font[size], str, col);
|
||||||
|
|
||||||
@ -98,11 +107,7 @@ bool rawdisplaystr(int x, int y, int shift, int size, const char *str, int color
|
|||||||
int textwidth(int siz, const string &str) {
|
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);
|
load_font();
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user