Android TextRenderer: Add try {} around loading the Roboto font. Also improve an unrelated assert.

This commit is contained in:
Henrik Rydgård 2024-10-10 15:59:46 +02:00
parent 1ac580b726
commit f1cbf1ba96
2 changed files with 11 additions and 7 deletions

View file

@ -74,8 +74,8 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
_assert_(result == VK_SUCCESS);
result = vmaMapMemory(vulkan_->Allocator(), block.allocation, (void **)(&block.writePtr));
_assert_msg_(result == VK_SUCCESS, "VulkanPushPool: Failed to map memory (result = %s)", VulkanResultToString(result));
_assert_msg_(result == VK_SUCCESS, "VulkanPushPool: Failed to map memory (result = %s, size = %d)", VulkanResultToString(result), (int)size);
_assert_msg_(block.writePtr != nullptr, "VulkanPushPool: Failed to map memory on block of size %d", (int)block.size);
return block;
}

View file

@ -22,12 +22,16 @@ public class TextRenderer {
}
public static void init(Context ctx) {
robotoCondensed = Typeface.createFromAsset(ctx.getAssets(), "Roboto-Condensed.ttf");
if (robotoCondensed != null) {
Log.i(TAG, "Successfully loaded Roboto Condensed");
textPaint.setTypeface(robotoCondensed);
} else {
Log.e(TAG, "Failed to load Roboto Condensed");
try {
robotoCondensed = Typeface.createFromAsset(ctx.getAssets(), "Roboto-Condensed.ttf");
if (robotoCondensed != null) {
Log.i(TAG, "Successfully loaded Roboto Condensed");
textPaint.setTypeface(robotoCondensed);
} else {
Log.e(TAG, "Failed to load Roboto Condensed");
}
} catch (Exception e) {
Log.e(TAG, "Exception when loading typeface. shouldn't happen but is reported. We just fall back." + e);
}
highContrastFontsEnabled = Settings.Secure.getInt(ctx.getContentResolver(), "high_text_contrast_enabled", 0) == 1;
}