diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-12-01 11:54:22 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-12-01 11:54:22 -0500 |
| commit | ac221b7a9629931b05c551225c3d65c75cff2f49 (patch) | |
| tree | 540edd42fcbe56532bd9eb645cdb72bb7ea875b5 | |
| parent | 64db50cf0657c83740276c3869e4cb6304020cf6 (diff) | |
pke: font track first word of line
| -rw-r--r-- | src/font.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/font.cpp b/src/font.cpp index 9b38d69..d368b5a 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -217,6 +217,7 @@ bool FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta FontGlyphChar *fgc, *fgc2; FontInstanceBufferItem *buf_item; bool new_word = true; + bool first_word_of_line = true; uint32_t i, ii; float font_glyph_spacing; float cursor_head, line_index, line_height, line_length, line_offset; @@ -274,6 +275,7 @@ bool FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta } line_index += 1; new_word = true; + first_word_of_line = true; cursor_head = 0; line_length = FontType_Inner_LookAheadLineLength(ft, fr, i+1, font_glyph_spacing); if (PK_HAS_FLAG(fr->settings.surface_area_type_flags, FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_HORIZONTAL)) { @@ -305,7 +307,7 @@ bool FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta } if (new_word == true) { float word_width = FontType_Inner_LookAheadWordLength(ft, fr, i, font_glyph_spacing); - if (cursor_head + word_width > fr->settings.surface_area_size.x) { + if (first_word_of_line == false && cursor_head + word_width > fr->settings.surface_area_size.x) { line_index += 1; cursor_head = 0; line_length = FontType_Inner_LookAheadLineLength(ft, fr, i, font_glyph_spacing); @@ -314,8 +316,9 @@ bool FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta cursor_head = (fr->settings.surface_area_size.x - line_length) / 2.0; } } - new_word = false; } + first_word_of_line = false; + new_word = false; // left, bottom, right, top // x, y, z, w |
