Skip to content

[222_46] display consistent normalized font size across status bar and font size selector#2875

Merged
MoonL79 merged 4 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/222_44/fix-statusbar-font-size-display
Mar 5, 2026
Merged

[222_46] display consistent normalized font size across status bar and font size selector#2875
MoonL79 merged 4 commits intoMoganLab:mainfrom
1sh-repalto:1sh-repalto/222_44/fix-statusbar-font-size-display

Conversation

@1sh-repalto
Copy link
Contributor

@1sh-repalto 1sh-repalto commented Feb 26, 2026

Fixes #2808
Decimal font sizes not displayed correctly in status bar and font size selector


Summary

Normalize font size display to the nearest 0.5 across the status bar and font size selector, ensuring consistent and accurate representation.

Developer document: devel/222_44.md


Issues Found

  • In edit_footer.cpp, get_env_int(FONT_BASE_SIZE) truncates decimal values to integers.
  • The display lines also use (int) casts, discarding any fractional part.
  • The font size selector in document-menu.scm displays raw user input without normalization.
  • The font rendering engine only supports size changes at 0.5 increments (via normalize_half_multiple_size), arbitrary decimals like 10.3 are internally rounded to 10.5 but displayed as 10.3, causing a mismatch.

Changes

  • Changed get_env_int to get_env_double for FONT_BASE_SIZE in edit_footer.cpp to preserve decimal values.
  • Replaced (int) cast with round(x * 2.0) / 2.0 normalization for text, math, and prog modes in the status bar.
  • Updated font-base-size-menu-name in document-menu.scm to display the normalized font size instead of raw user input.
  • Added init-font-base-size-interactive to sanitize the "Other" input dialog — invalid or non-numeric entries default to 10.
  • Reused font-base-size-menu-name in fold-menu.scm for the beamer toolbar instead of raw string display.

How to Test

Go to Font Size -> Other, then:

  1. Set font size to 10.5 — status bar and selector should both show 10.5
  2. Set font size to 14.2 — both should show 14 (rounded to nearest 0.5 with no trailing .0)
  3. Set font size to 14.25 — both should show 14.5 (rounded to nearest 0.5)
  4. Enter "abc" — should default to 10 without errors
how_to_test.mp4

@1sh-repalto
Copy link
Contributor Author

Hi, another approach I thought to handle invalid input from the user is to show an error dialogue message. Let me know if this needs to be implemented, I'll create a seperate issue for it. Thanks!

…n status bar and selector

- Fix truncated decimal font sizes in status bar (get_env_double, round to 0.5)
- Normalize and validate font size selector input (invalid defaults to 10)
@1sh-repalto 1sh-repalto force-pushed the 1sh-repalto/222_44/fix-statusbar-font-size-display branch from b1c611c to e200837 Compare February 27, 2026 07:02
@1sh-repalto 1sh-repalto changed the title [222_44] display consistent normalized font size across status bar and font size selector [222_46] display consistent normalized font size across status bar and font size selector Feb 27, 2026
@MoonL79
Copy link
Contributor

MoonL79 commented Mar 5, 2026

Thanks for the fix.

The core logic looks good overall (consistent 0.5-step normalization and using get_env_double in the footer). The only significant issue I found is in the new Other input path:

  • init-font-base-size-interactive currently accepts any numeric value, including 0 and negative numbers.
  • This should be validated as a positive font size (> 0) before writing font-base-size; otherwise fallback to 10 (as you already do for non-numeric input).

Suggested change:

  • In init-font-base-size-interactive, treat values as valid only when numeric and > 0.
  • Optional hardening: apply the same positivity guard in font-base-size-menu-name so legacy/invalid stored values are also handled safely.

So yes, I think the main follow-up needed for this PR is adding the positivity check in the Other handler.

@1sh-repalto
Copy link
Contributor Author

Thanks for the review! I've added the positivity check — both init-font-base-size-interactive and font-base-size-menu-name now validate (and num (> num 0)), so zero and negative values fall back to the default of 10, same as non-numeric input.
Let me know if more changes are needed.

handle-zero-and-negative-input.mp4

Copy link
Contributor

@MoonL79 MoonL79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MoonL79 MoonL79 merged commit e67ae4a into MoganLab:main Mar 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

带小数的字号不会在状态栏中正确显示

2 participants