mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Add a FontMetricsProvider
for resolving font-relative units (#31966)
The only font relative unit that Servo knows how to resolve currently is `rem` (relative to the root font size). This is because Stylo cannot do any font queries. This adds a mechanism to allow this, exposing the ability to properly render `ex` units in Servo. This change only allows resolving some font size relative units thoug, as Servo doesn't collect all the FontMetrics it needs to resolve them all. This capability will be added in followup changes. Some new tests fail: - ex-unit-001.html: This test fails because Servo does not yet have support for setting the weight using @font-face rules on web fonts. - ex-unit-004.html: This test fails because Servo does not yet have support for setting the Unicode range of a web font using @font-face rules. - first-available-font-001.html: This test fails because the above two feature are missing.
This commit is contained in:
parent
24c3a2df1e
commit
fe8b23d14a
98 changed files with 208 additions and 232 deletions
|
@ -1597,11 +1597,10 @@ impl InlineFormattingContext {
|
|||
|
||||
// It's unfortunate that it isn't possible to get this during IFC text processing, but in
|
||||
// that situation the style of the containing block is unknown.
|
||||
let default_font_metrics =
|
||||
crate::context::with_thread_local_font_context(layout_context, |font_context| {
|
||||
get_font_for_first_font_for_style(style, font_context)
|
||||
.map(|font| font.borrow().metrics.clone())
|
||||
});
|
||||
let default_font_metrics = layout_context.with_font_context(|font_context| {
|
||||
get_font_for_first_font_for_style(style, font_context)
|
||||
.map(|font| font.borrow().metrics.clone())
|
||||
});
|
||||
|
||||
let mut ifc = InlineFormattingContextState {
|
||||
positioning_context,
|
||||
|
@ -1725,7 +1724,7 @@ impl InlineFormattingContext {
|
|||
// For the purposes of `text-transform: capitalize` the start of the IFC is a word boundary.
|
||||
let mut on_word_boundary = true;
|
||||
|
||||
crate::context::with_thread_local_font_context(layout_context, |font_context| {
|
||||
layout_context.with_font_context(|font_context| {
|
||||
let mut linebreaker = None;
|
||||
self.foreach(|iter_item| match iter_item {
|
||||
InlineFormattingContextIterItem::Item(InlineLevelBox::TextRun(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue