Skip to content

Commit

Permalink
Nicer font for ImGui overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaWillems committed Feb 20, 2019
1 parent eec6444 commit cf83c1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions base/VulkanUIOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ namespace vks
// Create font texture
unsigned char* fontData;
int texWidth, texHeight;
#if defined(__ANDROID__)
float scale = (float)vks::android::screenDensity / (float)ACONFIGURATION_DENSITY_MEDIUM;
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, "Roboto-Medium.ttf", AASSET_MODE_STREAMING);
if (asset) {
size_t size = AAsset_getLength(asset);
assert(size > 0);
char *fontAsset = new char[size];
AAsset_read(asset, fontAsset, size);
AAsset_close(asset);
io.Fonts->AddFontFromMemoryTTF(fontAsset, size, 14.0f * scale);
delete[] fontAsset;
}
#else
io.Fonts->AddFontFromFileTTF("./../data/Roboto-Medium.ttf", 16.0f);
#endif
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
VkDeviceSize uploadSize = texWidth*texHeight * 4 * sizeof(char);

Expand Down
4 changes: 4 additions & 0 deletions data/Robot-Medium-license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Roboto-Medium.ttf
Apache License 2.0
by Christian Robertson
https://fonts.google.com/specimen/Roboto
Binary file added data/Roboto-Medium.ttf
Binary file not shown.

0 comments on commit cf83c1b

Please sign in to comment.