diff --git a/TeXmacs/progs/generic/document-edit.scm b/TeXmacs/progs/generic/document-edit.scm index ef466562fb..6e37e47536 100644 --- a/TeXmacs/progs/generic/document-edit.scm +++ b/TeXmacs/progs/generic/document-edit.scm @@ -69,7 +69,12 @@ (with old (get-init-tree s) (if (and (tree-func? old 'macro 1) (not (tm-is? val 'macro))) (init-env-tree s `(macro ,val)) - (init-env-tree s val)))) + (init-env-tree s (if (and (string? s) (string? val) (== s "font-base-size")) + (with num (string->number val) + (if (number? num) + (number->string (/ (round (* num 2)) 2)) + val)) + val))))) (tm-define (init-interactive-env var) (:interactive #t) diff --git a/devel/222_46.md b/devel/222_46.md new file mode 100644 index 0000000000..087c214731 --- /dev/null +++ b/devel/222_46.md @@ -0,0 +1,31 @@ +# 222_46: Fix font size display in status bar and font size input + + +### How to Test +Enter a decimal font size in the font size input field and check if the font size is displayed correctly in the status bar. +(multiple of 0.5) + + +### Issue #2808 : +Decimal font sizes were not displayed correctly in the status bar and font size input. + +### What +To fix, modified the font size input and status bar to display correct decimal font sizes. + +**Changes made:** + +1. **TeXmacs/progs/generic/document-edit.scm**: Modified `set-init-env` function to automatically round font-base-size inputs to the nearest 0.5 (e.g., 10.3 → 10.5, 10.7 → 10.5). Added type safety checks to ensure only valid string inputs are processed. + +2. **src/Edit/Interface/edit_footer.cpp**: + - Changed `get_env_int(FONT_BASE_SIZE)` to `get_env_double(FONT_BASE_SIZE)` to preserve decimal values + - Removed integer casting `(int)((base_sz + 0.5) * sz)` and replaced with direct decimal display `base_sz * sz` + +### Why + +This fixes both issues at their source: +- Input validation ensures all font sizes are properly rounded when set +- Display changes preserve and show the decimal values correctly +- Both top and bottom bars now show identical, correctly rounded font sizes + +* Author: Lakshy +* Date: 27-02-2026 \ No newline at end of file diff --git a/src/Edit/Interface/edit_footer.cpp b/src/Edit/Interface/edit_footer.cpp index 8629d1183a..4b5343f468 100644 --- a/src/Edit/Interface/edit_footer.cpp +++ b/src/Edit/Interface/edit_footer.cpp @@ -39,7 +39,7 @@ edit_interface_rep::append_left_footer (tree& l, string env_var) { void edit_interface_rep::set_left_footer () { tree s = concat (); - double base_sz= get_env_int (FONT_BASE_SIZE); + double base_sz= get_env_double (FONT_BASE_SIZE); double sz = get_env_double (FONT_SIZE); /* tree the_style= get_style (); @@ -55,14 +55,14 @@ edit_interface_rep::set_left_footer () { if ((mode == "text") || (mode == "src")) { s << tree (" ") << verbatim (main_family (get_env_string (FONT))); append_left_footer (s, FONT_FAMILY); - s << tree (" ") << as_string ((int) ((base_sz + 0.5) * sz)); + s << tree (" ") << as_string (base_sz * sz); append_left_footer (s, FONT_SERIES); append_left_footer (s, FONT_SHAPE); } else if (mode == "math") { s << tree (" ") << verbatim (get_env_string (MATH_FONT)); append_left_footer (s, MATH_FONT_FAMILY); - s << " " << as_string ((int) ((base_sz + 0.5) * sz)); + s << " " << as_string (base_sz * sz); append_left_footer (s, MATH_FONT_SERIES); append_left_footer (s, MATH_FONT_SHAPE); } @@ -71,7 +71,7 @@ edit_interface_rep::set_left_footer () { if (session_name != "default") s << "-" << session_name; s << tree (" ") << verbatim (get_env_string (PROG_FONT)); append_left_footer (s, PROG_FONT_FAMILY); - s << " " << as_string ((int) ((base_sz + 0.5) * sz)); + s << " " << as_string (base_sz * sz); append_left_footer (s, PROG_FONT_SERIES); append_left_footer (s, PROG_FONT_SHAPE); }