summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-06-01 08:27:30 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-06-01 08:27:30 +0200
commit2d85a0f6f7bbbaa559c206473dee995030dd4169 (patch)
tree01d5d6aeff938fbba7244193c7876dc6105a7800
parentMerge "recovery: add --fsck_unshare_blocks option for adb remount" (diff)
parentLet gr_init proceed even if we failed to load a font file (diff)
downloadandroid_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar.gz
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar.bz2
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar.lz
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar.xz
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.tar.zst
android_bootable_recovery-2d85a0f6f7bbbaa559c206473dee995030dd4169.zip
-rw-r--r--minui/graphics.cpp15
-rw-r--r--minui/include/minui/minui.h4
2 files changed, 15 insertions, 4 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index 202ce71fd..3b386015a 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -51,12 +51,21 @@ const GRFont* gr_sys_font() {
}
int gr_measure(const GRFont* font, const char* s) {
+ if (font == nullptr) {
+ return -1;
+ }
+
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;
*y = font->char_height;
+ return 0;
}
// Blends gr_current onto pix value, assumes alpha as most significant byte.
@@ -319,8 +328,8 @@ void gr_flip() {
int gr_init() {
int ret = gr_init_font("font", &gr_font);
if (ret != 0) {
- printf("Failed to init font: %d\n", ret);
- return -1;
+ printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
+ ret);
}
auto backend = std::unique_ptr<MinuiBackend>{ std::make_unique<MinuiBackendAdf>() };
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index f9da19999..e96b7ae08 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -66,8 +66,10 @@ void gr_texticon(int x, int y, GRSurface* icon);
const GRFont* gr_sys_font();
int gr_init_font(const char* name, GRFont** dest);
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);
-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);
unsigned int gr_get_width(GRSurface* surface);