Carry paragraph font faces through the display list

This commit is contained in:
gloamxun committed 2026-10-20 18:32:33 +08:00
1 parent 96c88d2787
commit 6b74a17312
4 files changed
+54 -5

No files matched your search

+7 -1
View File
@@ -7,6 +7,7 @@
use crate::cmr10::Cmr10Metrics;
use crate::math::{self, MathAtom};
use crate::paragraph::ParagraphFont;
use crate::{FloatPlacement, Halign, HorizontalItem, Page, VerticalItem};
/// One absolute drawing primitive in scaled points.
@@ -344,6 +345,11 @@ impl Page {
y += *height + *depth;
}
VerticalItem::Paragraph(paragraph) => {
let face = match paragraph.font {
ParagraphFont::Roman => FontFace::Roman,
ParagraphFont::Bold => FontFace::Bold,
ParagraphFont::Italic => FontFace::Italic,
};
let lines = paragraph.lines.len().max(1) as i64;
let line_height = (paragraph.height / lines).max(1);
let size = ((line_height as f64) * 0.7) as i64;
@@ -355,7 +361,7 @@ impl Page {
HorizontalItem::Box(box_) => {
if let Some(character) = box_.character {
list.push(DisplayItem::Text {
font: FontFace::Roman,
font: face,
x,
y: baseline,
size,