Fix proportional font rendering with pixel-based horizontal scroll
The GUI renderer had two competing horizontal scroll systems: a character-based one (coloffs × space_w) and a pixel-based one. For proportional fonts the character-based system used "M" width to calculate viewport columns, triggering premature scrolling at ~50% of the actual display width. Switch the GUI renderer to purely pixel-based horizontal scrolling: - Remove coloffs↔ImGui scroll_x bidirectional sync - Measure rx_to_px from column 0 (absolute) instead of from coloffs - Draw full expanded lines; let ImGui clip via its scroll viewport - Report content width via SetCursorPosX+Dummy for the scrollbar - Use average character width for cols estimate (not "M" width) The terminal renderer continues using coloffs correctly—no changes needed there. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,7 +76,9 @@ static void
|
||||
update_editor_dimensions(Editor &ed, float disp_w, float disp_h)
|
||||
{
|
||||
float row_h = ImGui::GetTextLineHeightWithSpacing();
|
||||
float ch_w = ImGui::CalcTextSize("M").x;
|
||||
// Use average character width rather than "M" (the widest character)
|
||||
// so that column count is reasonable for proportional fonts too.
|
||||
float ch_w = ImGui::CalcTextSize("abcdefghijklmnopqrstuvwxyz").x / 26.0f;
|
||||
if (row_h <= 0.0f)
|
||||
row_h = 16.0f;
|
||||
if (ch_w <= 0.0f)
|
||||
|
||||
Reference in New Issue
Block a user