summaryrefslogtreecommitdiff
path: root/src/font.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-02-19 10:09:46 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-02-19 10:13:51 -0500
commitfdbfcf764424bf05349cd35caadba04576846458 (patch)
treea231aaba9cf75d8b9b5bf3c71dd811b0c3e4e979 /src/font.cpp
parent49c26802a6513a14187d4c2e22f74676056de099 (diff)
pke: font horizontal spacing
Diffstat (limited to 'src/font.cpp')
-rw-r--r--src/font.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/font.cpp b/src/font.cpp
index 1f97bf1..5b59dc8 100644
--- a/src/font.cpp
+++ b/src/font.cpp
@@ -106,9 +106,6 @@ void FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta
// Could be related to uv (set to a .5 value).
//
// Fonts are not aliased correctly - may or may not be related to ghosting.
- //
- // Letter spacing seems off.
- // Digits and punctuation ',' '.' are the worst offenders.
font_glyph_spacing = ft->spacing.em_size * fr->settings.char_scale;
cursor_head = 0;
@@ -143,9 +140,9 @@ void FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta
translate.x = fr->settings.surface_area_pos.x;
// current char position on x axis
translate.x += cursor_head;
- // draw from top left [-1,-1], so add left
- // (add because "left" from mtsdf is likely negative)
- // (while testing, the char '#' had a negative "left")
+ // place the left line of the glyph at the cursor head
+ translate.x += (glyph_size.x / 2.0);
+ // shift the glyph by the defined offset
translate.x += fgc->plane_bounds.x * font_glyph_spacing;
translate.x -= (Extent.width / 2.0);
translate.x /= (Extent.width / 2.0);
@@ -155,7 +152,7 @@ void FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta
translate.y = fr->settings.surface_area_pos.y;
// baseline - current line (+1 to not draw above the box)
translate.y -= ((line_index + 1) * line_height);
- // places the top-left corner of the glyph on the baseline
+ // places the top line of the glyph on the baseline
translate.y += (font_glyph_spacing / 2.0) + (glyph_size.y / 2.0);
// move glyph to the height relative to the baseline (cursor)
translate.y -= (fgc->plane_bounds.w * font_glyph_spacing);