mirror of
https://github.com/penpot/penpot.git
synced 2026-11-27 21:57:52 +00:00
🐛 Size vertical columns of small text by their line height
A vertical column was never narrower than 12px times the line height: the largest font size of the paragraph was seeded with 12, so a column of text from 4 to 12px measured the same, about 17px at a line height of 1.4, where a horizontal line of 4px text measures 6px. The largest span now sets the column alone; 12px is only the size of a paragraph without spans. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
9c1f83dc72
commit
49d9e77d64
@ -254,7 +254,14 @@ impl ColumnGeometry {
|
||||
} else {
|
||||
1.2
|
||||
};
|
||||
let max_font_size = spans.iter().map(|s| s.font_size).fold(12.0, f32::max);
|
||||
// The largest span sets the column; a paragraph without spans
|
||||
// takes 12px. Seeding the maximum with 12 widened every column of
|
||||
// smaller text to that size.
|
||||
let max_font_size = spans
|
||||
.iter()
|
||||
.map(|s| s.font_size)
|
||||
.reduce(f32::max)
|
||||
.unwrap_or(12.0);
|
||||
|
||||
// Under automatic clearance, ruby reserves its configured-size gutter
|
||||
// on the logical annotation side. In vertical-rl, `over` is right and
|
||||
@ -1276,6 +1283,27 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn small_text_columns_are_as_wide_as_their_line_height() {
|
||||
for font_size in [4.0, 8.0, 12.0, 20.0] {
|
||||
let span = TextSpan {
|
||||
font_size,
|
||||
..make_span("あい")
|
||||
};
|
||||
let content = content_of(
|
||||
vec![vertical_paragraph(vec![span], TextAlign::Left, 1.4)],
|
||||
1000.0,
|
||||
GrowType::Fixed,
|
||||
);
|
||||
let layout = layout_content(&content, 1000.0);
|
||||
let width = layout.columns[0].width;
|
||||
assert!(
|
||||
(width - font_size * 1.4).abs() < 0.01,
|
||||
"a {font_size}px column is {width}px wide"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layout_cells_tile_the_text() {
|
||||
let text = "縦書きのAB12テスト。";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user