diff --git a/base/VulkanUIOverlay.cpp b/base/VulkanUIOverlay.cpp index b331e01a..4361edf5 100644 --- a/base/VulkanUIOverlay.cpp +++ b/base/VulkanUIOverlay.cpp @@ -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); diff --git a/data/Robot-Medium-license.txt b/data/Robot-Medium-license.txt new file mode 100644 index 00000000..e95c39a8 --- /dev/null +++ b/data/Robot-Medium-license.txt @@ -0,0 +1,4 @@ + Roboto-Medium.ttf + Apache License 2.0 + by Christian Robertson + https://fonts.google.com/specimen/Roboto \ No newline at end of file diff --git a/data/Roboto-Medium.ttf b/data/Roboto-Medium.ttf new file mode 100644 index 00000000..39c63d74 Binary files /dev/null and b/data/Roboto-Medium.ttf differ