diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-21 15:55:35 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-22 00:47:50 -0500 |
| commit | e1133e93c75172e2815231e68bbc0830de1f7d79 (patch) | |
| tree | ab6b63ef5090b12320333fe0fbd982c7188a93ab /src/font.cpp | |
| parent | 76a38d7f972b17c33a6ffd6dc3772df721139e67 (diff) | |
pke: required chars unicode 9, 10, 13
Diffstat (limited to 'src/font.cpp')
| -rw-r--r-- | src/font.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/font.cpp b/src/font.cpp index bf03d1a..30877f2 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -95,7 +95,7 @@ float FontType_Inner_LookAheadWordLength(const FontType *const ft, const FontRen FontGlyphChar *fgc; for (i = index; i < fr->n_glyphs; ++i) { fgc = &ft->glyphs[fr->glyph_indices[i]]; - if (fgc->is_whitespace == true) { + if (PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_WHITESPACE) == true) { break; } ret += fgc->advance * font_glyph_spacing; @@ -132,8 +132,31 @@ void FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta scale = glm::vec3(1); fgc = &ft->glyphs[fr->glyph_indices[i]]; - if (fgc->is_whitespace == true) { + if (PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_NEW_LINE) == true) { + // 10 line feed '\n' + // 13 carriage return '\r' + if ((fgc->unicode == 10 || fgc->unicode == 13) && i+1 < fr->n_glyphs) { + if ((ft->glyphs[fr->glyph_indices[i+1]].unicode == 10 || ft->glyphs[fr->glyph_indices[i+1]].unicode == 13) && ft->glyphs[fr->glyph_indices[i+1]].unicode != fgc->unicode) { + i += 1;// burn /r/n and /n/r + } + } + line_index += 1; + cursor_head = 0; + continue; + } + if (PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_WHITESPACE) == true) { + // x = 2 + // a = 4 + // 6 = 2 + 4 cursor_head += fgc->advance * font_glyph_spacing; + if (PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_ALIGN_ADVANCE) == true) { + // x2 = x - (a - (x % a)) + // x2 = 6 - (4 - (6 & 4)) + // x2 = 6 - (4 - 2) + // x2 = 6 - (2) + // x2 = 4 + cursor_head -= (ft->spacing.em_size * font_glyph_spacing) - fmod(cursor_head, (ft->spacing.em_size * font_glyph_spacing)); + } new_word = true; continue; } |
