Merge remote-tracking branch 'origin/master' into claude/issue-50

# Conflicts:
#	project.cpp
This commit is contained in:
catbot 2026-06-16 16:59:05 +00:00
commit f2f5a770c0
7 changed files with 311 additions and 21 deletions

View file

@ -60,6 +60,15 @@ namespace Crafter {
stbtt_fontinfo font;
Font(const std::filesystem::path& font);
std::uint32_t GetLineWidth(const std::string_view text, float size);
// Map a target advance (px from the line start) to the nearest UTF-8
// codepoint boundary, returning its BYTE offset into `text`. A single
// left-to-right pass accumulates per-glyph advances (O(n) metric
// lookups), instead of re-walking the prefix for every boundary as a
// naive caller would. Cumulative advance is monotonic (advances are
// non-negative), so the scan stops at the first boundary past the
// closest one. Returned offsets land on codepoint boundaries, which are
// exactly the valid positions for a byte-based text cursor.
std::size_t NearestCursorByte(std::string_view text, float size, float target);
float LineHeight(float size);
float AscentPx(float size);
float ScaleForSize(float size);