Merge "Let gr_init proceed even if we failed to load a font file"
am: 2d85a0f6f7
Change-Id: I2c830126f9d6a060d321ce48e7602fc808836e11
This commit is contained in:
+12
-3
@@ -51,12 +51,21 @@ const GRFont* gr_sys_font() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gr_measure(const GRFont* font, const char* s) {
|
int gr_measure(const GRFont* font, const char* s) {
|
||||||
|
if (font == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return font->char_width * strlen(s);
|
return font->char_width * strlen(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gr_font_size(const GRFont* font, int* x, int* y) {
|
int gr_font_size(const GRFont* font, int* x, int* y) {
|
||||||
|
if (font == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*x = font->char_width;
|
*x = font->char_width;
|
||||||
*y = font->char_height;
|
*y = font->char_height;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blends gr_current onto pix value, assumes alpha as most significant byte.
|
// Blends gr_current onto pix value, assumes alpha as most significant byte.
|
||||||
@@ -319,8 +328,8 @@ void gr_flip() {
|
|||||||
int gr_init() {
|
int gr_init() {
|
||||||
int ret = gr_init_font("font", &gr_font);
|
int ret = gr_init_font("font", &gr_font);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Failed to init font: %d\n", ret);
|
printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
|
||||||
return -1;
|
ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto backend = std::unique_ptr<MinuiBackend>{ std::make_unique<MinuiBackendAdf>() };
|
auto backend = std::unique_ptr<MinuiBackend>{ std::make_unique<MinuiBackendAdf>() };
|
||||||
|
|||||||
@@ -66,8 +66,10 @@ void gr_texticon(int x, int y, GRSurface* icon);
|
|||||||
const GRFont* gr_sys_font();
|
const GRFont* gr_sys_font();
|
||||||
int gr_init_font(const char* name, GRFont** dest);
|
int gr_init_font(const char* name, GRFont** dest);
|
||||||
void gr_text(const GRFont* font, int x, int y, const char* s, bool bold);
|
void gr_text(const GRFont* font, int x, int y, const char* s, bool bold);
|
||||||
|
// Return -1 if font is nullptr.
|
||||||
int gr_measure(const GRFont* font, const char* s);
|
int gr_measure(const GRFont* font, const char* s);
|
||||||
void gr_font_size(const GRFont* font, int* x, int* y);
|
// Return -1 if font is nullptr.
|
||||||
|
int gr_font_size(const GRFont* font, int* x, int* y);
|
||||||
|
|
||||||
void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
|
void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
|
||||||
unsigned int gr_get_width(GRSurface* surface);
|
unsigned int gr_get_width(GRSurface* surface);
|
||||||
|
|||||||
Reference in New Issue
Block a user