diff options
author | Tianjie Xu <xunchang@google.com> | 2018-06-01 14:33:28 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-06-01 14:33:28 +0200 |
commit | 381fa3a7dba98b4ad7ec97f74230d28f167cc871 (patch) | |
tree | 9933e943a7f9da797ea01fff6c82377f67ecd3e0 /minui/graphics.cpp | |
parent | Merge "recovery: add --fsck_unshare_blocks option for adb remount" am: bda4495176 (diff) | |
parent | Merge "Let gr_init proceed even if we failed to load a font file" (diff) | |
download | android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar.gz android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar.bz2 android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar.lz android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar.xz android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.tar.zst android_bootable_recovery-381fa3a7dba98b4ad7ec97f74230d28f167cc871.zip |
Diffstat (limited to 'minui/graphics.cpp')
-rw-r--r-- | minui/graphics.cpp | 15 |
1 files changed, 12 insertions, 3 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>() }; |