Skip to content

Commit

Permalink
Use the local font for the hyphen's render plan
Browse files Browse the repository at this point in the history
Fixes #380.
  • Loading branch information
baskerville committed Oct 26, 2024
1 parent a6bf892 commit 8aa30f1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions crates/core/src/document/html/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,17 +1410,14 @@ impl Engine {

if let ParagraphItem::Penalty { width, .. } = items[index] {
if width > 0 {
let font_size = (style.font_size * 64.0) as u32;
let mut hyphen_plan = {
if let Some(DrawCommand::Text(tc)) = page.last_mut() {
let font = self.fonts.as_mut().unwrap()
.get_mut(style.font_kind, style.font_style, style.font_weight);
font.set_size(font_size, self.dpi);
font.plan("-", None, style.font_features.as_deref())
};
if let Some(DrawCommand::Text(TextCommand { ref mut rect, ref mut plan, ref mut text, .. })) = page.last_mut() {
rect.max.x += hyphen_plan.width;
plan.append(&mut hyphen_plan);
text.push('\u{00AD}');
.get_mut(tc.font_kind, tc.font_style, tc.font_weight);
font.set_size(tc.font_size, self.dpi);
let mut hyphen_plan = font.plan("-", None, None);
tc.rect.max.x += hyphen_plan.width;
tc.plan.append(&mut hyphen_plan);
tc.text.push('\u{00AD}');
}
}
}
Expand Down

0 comments on commit 8aa30f1

Please # to comment.