mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Store required font metrics on TextFragment
This commit is contained in:
parent
74d9fec9cf
commit
e3c8597ccb
3 changed files with 32 additions and 11 deletions
|
@ -9,7 +9,7 @@ use crate::flow::FlowLayout;
|
|||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragments::{
|
||||
AbsoluteOrFixedPositionedFragment, AnonymousFragment, BoxFragment, CollapsedBlockMargins,
|
||||
DebugId, Fragment, TextFragment,
|
||||
DebugId, FontMetrics, Fragment, TextFragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::positioned::{
|
||||
|
@ -631,8 +631,7 @@ fn layout_atomic(
|
|||
}
|
||||
|
||||
struct BreakAndShapeResult {
|
||||
font_ascent: Au,
|
||||
font_line_gap: Au,
|
||||
font_metrics: FontMetrics,
|
||||
font_key: FontInstanceKey,
|
||||
runs: Vec<GlyphRun>,
|
||||
break_at_start: bool,
|
||||
|
@ -699,8 +698,7 @@ impl TextRun {
|
|||
);
|
||||
|
||||
BreakAndShapeResult {
|
||||
font_ascent: font.metrics.ascent,
|
||||
font_line_gap: font.metrics.line_gap,
|
||||
font_metrics: (&font.metrics).into(),
|
||||
font_key: font.font_key,
|
||||
runs,
|
||||
break_at_start,
|
||||
|
@ -712,8 +710,7 @@ impl TextRun {
|
|||
use style::values::generics::text::LineHeight;
|
||||
|
||||
let BreakAndShapeResult {
|
||||
font_ascent,
|
||||
font_line_gap,
|
||||
font_metrics,
|
||||
font_key,
|
||||
runs,
|
||||
break_at_start: _,
|
||||
|
@ -750,7 +747,7 @@ impl TextRun {
|
|||
}
|
||||
}
|
||||
let line_height = match self.parent_style.get_inherited_text().line_height {
|
||||
LineHeight::Normal => font_line_gap.into(),
|
||||
LineHeight::Normal => font_metrics.line_gap,
|
||||
LineHeight::Number(n) => font_size * n.0,
|
||||
LineHeight::Length(l) => l.0,
|
||||
};
|
||||
|
@ -775,7 +772,7 @@ impl TextRun {
|
|||
debug_id: DebugId::new(),
|
||||
parent_style: self.parent_style.clone(),
|
||||
rect,
|
||||
ascent: font_ascent.into(),
|
||||
font_metrics,
|
||||
font_key,
|
||||
glyphs,
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue