mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-26 11:46:49 -06:00
Grid: #### is sized by the width of #, so it fits its cell in every font (#2378)
A number too wide for its column is drawn as ####, with as many # as fit. The count used the width of 0, and in fonts where # is wider than 0 the hashes ran past the cell edge. accounting_fill::too_wide_fill_number_shows_hashes_not_a_clipped_value caught it on FreeBSD and on Linux machines without the CI font set.
This commit is contained in:
@@ -1300,7 +1300,9 @@ pub(crate) fn paint_quadrant(
|
||||
// Numbers and dates never overflow: they show #### when too narrow.
|
||||
let hashed = !shrunk && (numeric || matches!(v, Value::Number(_))) && w > avail_w - 2.0 * pad && st.align.h != HAlign::Fill;
|
||||
if hashed {
|
||||
let n = ((avail_w - 2.0 * pad) / char_w).floor().max(1.0) as usize;
|
||||
// Measured on `#` itself: it is wider than `0` in some fonts, and #### must fit its cell.
|
||||
let hash_w = p.layout_no_wrap("#".to_string(), font.clone(), color).size().x.max(1.0);
|
||||
let n = ((avail_w - 2.0 * pad) / hash_w).floor().max(1.0) as usize;
|
||||
galley = p.layout_no_wrap("#".repeat(n), font.clone(), color);
|
||||
w = galley.size().x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user