From 2ea9818fb0318946e0abbfa2a6c9ab385c8e262b Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Thu, 17 Oct 2024 09:04:35 -0600 Subject: [PATCH] Inverted text rendering so baseline is origin --- client/shader_src/ui_text.vert | 2 +- client/src/pipeline.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/shader_src/ui_text.vert b/client/shader_src/ui_text.vert index 247ea52..f24395f 100644 --- a/client/shader_src/ui_text.vert +++ b/client/shader_src/ui_text.vert @@ -57,7 +57,7 @@ void main() { float fragU = inVertexPosition.x * symbol.width/font.width; float fragV = inVertexPosition.y * symbol.height/font.height; float x = (inVertexPosition.x * symbol.width + symbol.left) * character.size / font.width; - float y = (inVertexPosition.y * symbol.height + symbol.top) * character.size / font.height; + float y = (inVertexPosition.y * symbol.height - symbol.top) * character.size / font.height; fragUV = vec2(fragU, fragV); fragColor = character.color; diff --git a/client/src/pipeline.c b/client/src/pipeline.c index 3562f14..bf75324 100644 --- a/client/src/pipeline.c +++ b/client/src/pipeline.c @@ -496,7 +496,7 @@ VkResult load_font(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayou symbols[i].width = width; symbols[i].height = height; symbols[i].left = face->glyph->bitmap_left; - symbols[i].top = ((face->bbox.yMax*size)/face->units_per_EM) - face->glyph->bitmap_top; + symbols[i].top = face->glyph->bitmap_top; symbols[i].advance = face->glyph->advance.x*16/face->units_per_EM; max_width = width > max_width ? width : max_width; max_height = height > max_height ? height : max_height;