summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-02-18 20:26:17 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-02-18 20:26:17 -0500
commit49c26802a6513a14187d4c2e22f74676056de099 (patch)
treeed5aaa83d38874643543a2b8730a88584691ef72 /editor
parentfae5df7328306078421cfdda65279f7e90f7658f (diff)
pke: font rendering correct glyph transform
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 860e470..8f90c9d 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -795,23 +795,18 @@ void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) {
arr_glyphs.stride = sizeof(FontGlyphChar);
pk_arr_resize(&arr_glyphs, glyphs.size());
FontGlyphChar *arr = reinterpret_cast<FontGlyphChar *>(arr_glyphs.data);
- uint32_t u;
for (uint64_t i = 0; i < glyphs.size(); ++i) {
arr[i].advance = glyphs[i].getAdvance();
arr[i].unicode = glyphs[i].getCodepoint();
arr[i].is_whitespace = glyphs[i].isWhitespace();
- u = arr[i].unicode;
- (void)u;
-
- // TODO double-check this math
glyphs[i].getQuadPlaneBounds(dbounds.x, dbounds.y, dbounds.z, dbounds.a);
- arr[i].baseline_bounding_box = dbounds;
+ arr[i].plane_bounds = dbounds;
// library counts up from the bottom of the image to the bottom of the glyph
- ibounds.y = height - (ibounds.y + ibounds.a);
- arr[i].sprite_region_min = glm::vec2(ibounds.x, ibounds.y);
- arr[i].sprite_region_max = glm::vec2(ibounds.x, ibounds.y) + glm::vec2(ibounds.z, ibounds.a);
+ glyphs[i].getQuadAtlasBounds(dbounds.x, dbounds.y, dbounds.z, dbounds.a);
+ arr[i].sprite_region_min = glm::vec2(dbounds.x, height - dbounds.a);
+ arr[i].sprite_region_max = glm::vec2(dbounds.z, height - dbounds.y);
}
qsort(arr_glyphs.data, arr_glyphs.next, arr_glyphs.stride, SortFontGlyphChar);
@@ -835,7 +830,7 @@ void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) {
font_title.val = pk_new<char>(font_title.reserved);
snprintf((char *)font_title.val, AssetKeyLength, "%s", a->key);
assert(ah_image != ah_glyphs && ah_image != AssetHandle_MAX);
- FontType_RegisterFont(font_title, ah_image, ah_glyphs, &ft_spacing);
+ FontType_RegisterFont(font_title, ah_image, ah_glyphs, msdf_settings, &ft_spacing);
}
bool RecordImGui_GenerateMTSDFModal() {