Truly independent web browser
LibWeb: Support the size-adjust font-face descriptor
sideshowbarker093b084d9b57
diff --git a/Libraries/LibWeb/Bindings/Rust/src/css/css_font_face_descriptors.rs b/Libraries/LibWeb/Bindings/Rust/src/css/css_font_face_descriptors.rsindex c3e5017a043..310570cf65b 100644--- a/Libraries/LibWeb/Bindings/Rust/src/css/css_font_face_descriptors.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/css/css_font_face_descriptors.rs@@ -37,4 +37,5 @@ descriptors_interface!((ascent_override, set_ascent_override, "ascent-override"),(descent_override, set_descent_override, "descent-override"),(line_gap_override, set_line_gap_override, "line-gap-override"),+ (size_adjust, set_size_adjust, "size-adjust"),);diff --git a/Libraries/LibWeb/CSS/CSSFontFaceDescriptors.idl b/Libraries/LibWeb/CSS/CSSFontFaceDescriptors.idlindex f11e6676e8a..216268f137d 100644--- a/Libraries/LibWeb/CSS/CSSFontFaceDescriptors.idl+++ b/Libraries/LibWeb/CSS/CSSFontFaceDescriptors.idl@@ -30,4 +30,6 @@ interface CSSFontFaceDescriptors : CSSStyleDeclaration {[LegacyNullToEmptyString, AttributeCallbackName=descent_override_dashed, ImplementedAs=descent_override] attribute CSSOMString descent-override;[LegacyNullToEmptyString, AttributeCallbackName=line_gap_override_regular, ImplementedAs=line_gap_override] attribute CSSOMString lineGapOverride;[LegacyNullToEmptyString, AttributeCallbackName=line_gap_override_dashed, ImplementedAs=line_gap_override] attribute CSSOMString line-gap-override;+ [LegacyNullToEmptyString, AttributeCallbackName=size_adjust_regular, ImplementedAs=size_adjust] attribute CSSOMString sizeAdjust;+ [LegacyNullToEmptyString, AttributeCallbackName=size_adjust_dashed, ImplementedAs=size_adjust] attribute CSSOMString size-adjust;};diff --git a/Libraries/LibWeb/CSS/Descriptors.json b/Libraries/LibWeb/CSS/Descriptors.jsonindex 188b86f1674..52827ad6465 100644--- a/Libraries/LibWeb/CSS/Descriptors.json+++ b/Libraries/LibWeb/CSS/Descriptors.json@@ -90,6 +90,12 @@"<percentage [0,∞]>"]},+ "size-adjust": {+ "initial": "100%",+ "syntax": [+ "<percentage [0,∞]>"+ ]+ },"src": {"syntax": ["<font-src-list>"diff --git a/Libraries/LibWeb/CSS/FontComputer.cpp b/Libraries/LibWeb/CSS/FontComputer.cppindex 314e06fe337..45ea285c3bc 100644--- a/Libraries/LibWeb/CSS/FontComputer.cpp+++ b/Libraries/LibWeb/CSS/FontComputer.cpp@@ -381,7 +381,7 @@ FontFeatureValues const& FontComputer::font_feature_values_for_family(Utf16FlyStreturn m_font_feature_values_cache.ensure(move(key), [&] { return move(font_feature_values); });}-Gfx::Font const& FontComputer::initial_font() const+Gfx::Font const& FontComputer::initial_font(){// FIXME: This is not correct.static auto const& font = Platform::FontPlugin::the().default_font(12).release_nonnull().leak_ref();@@ -561,6 +561,7 @@ NonnullRefPtr<FontFaceSnapshot const> FontComputer::font_face_snapshot() const.rendering_typeface = face->rendering_typeface(),.rendering_state = face->rendering_state_without_requesting(),.unicode_ranges = face->unicode_ranges(),+ .size_adjust = face->size_adjust(),.has_urls = face->has_urls(),.is_unusable = face->is_unusable_for_rendering(),.has_non_default_unicode_range = face->has_non_default_unicode_range(),diff --git a/Libraries/LibWeb/CSS/FontComputer.h b/Libraries/LibWeb/CSS/FontComputer.hindex df1e7bba1d8..9c3dfd66fad 100644--- a/Libraries/LibWeb/CSS/FontComputer.h+++ b/Libraries/LibWeb/CSS/FontComputer.h@@ -116,6 +116,8 @@ struct ComputedFontCacheKey {double font_oblique_angle { 14 };// Which synthesis the font-synthesis longhands forbid, as the style engine encodes it.u8 font_synthesis { 0 };+ // The from-font metric lookup ignores size-adjust before choosing a numeric adjustment.+ bool is_font_size_adjust_probe { false };[[nodiscard]] bool operator==(ComputedFontCacheKey const& other) const = default;};@@ -204,7 +206,7 @@ public:DOM::Document& document() { return *m_document; }DOM::Document const& document() const { return *m_document; }- Gfx::Font const& initial_font() const;+ static Gfx::Font const& initial_font();bool should_defer_initial_paint();bool has_completed_initial_paint() const { return m_has_completed_initial_paint; }bool initial_paint_had_pending_fonts() const { return m_initial_paint_had_pending_fonts; }diff --git a/Libraries/LibWeb/CSS/FontFace.cpp b/Libraries/LibWeb/CSS/FontFace.cppindex f3f8d834dcb..4ab04bd7b11 100644--- a/Libraries/LibWeb/CSS/FontFace.cpp+++ b/Libraries/LibWeb/CSS/FontFace.cpp@@ -24,6 +24,7 @@#include <LibWeb/Bindings/Wrappable.h>#include <LibWeb/Bindings/WrapperWorld.h>#include <LibWeb/CSS/CSSFontFaceRule.h>+#include <LibWeb/CSS/ComputedStyleWorkingSet.h>#include <LibWeb/CSS/Enums.h>#include <LibWeb/CSS/FontComputer.h>#include <LibWeb/CSS/FontFace.h>@@ -32,11 +33,13 @@#include <LibWeb/CSS/Parser/Parser.h>#include <LibWeb/CSS/StyleComputer.h>#include <LibWeb/CSS/StyleSheetState.h>+#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>#include <LibWeb/CSS/StyleValues/ComputationContext.h>#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>#include <LibWeb/CSS/StyleValues/FontSourceStyleValue.h>#include <LibWeb/CSS/StyleValues/FontStyleStyleValue.h>#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>+#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>#include <LibWeb/CSS/StyleValues/StringStyleValue.h>#include <LibWeb/CSS/StyleValues/StyleValueList.h>#include <LibWeb/CSS/StyleValues/UnicodeRangeStyleValue.h>@@ -104,6 +107,7 @@ static constexpr Array<FontFaceAttribute, FontFaceState::attribute_count> font_f{ DescriptorID::AscentOverride, "ascentOverride"sv },{ DescriptorID::DescentOverride, "descentOverride"sv },{ DescriptorID::LineGapOverride, "lineGapOverride"sv },+ { DescriptorID::SizeAdjust, "sizeAdjust"sv },} };static size_t attribute_index(DescriptorID descriptor)@@ -272,6 +276,7 @@ GC::Ref<FontFace> FontFaceState::create_for_constructor(JS::Object& relevant_glotry_set_descriptor(DescriptorID::AscentOverride, descriptors.ascent_override);try_set_descriptor(DescriptorID::DescentOverride, descriptors.descent_override);try_set_descriptor(DescriptorID::LineGapOverride, descriptors.line_gap_override);+ try_set_descriptor(DescriptorID::SizeAdjust, descriptors.size_adjust);RefPtr<StyleValue const> parsed_source;if (auto* source_string = source.get_pointer<Utf16String>()) {parsed_source = parse_css_descriptor(parsing_params, AtRuleID::FontFace, DescriptorNameAndID::from_id(DescriptorID::Src), source_string->utf16_view());@@ -585,7 +590,7 @@ GC::RootVector<GC::Ref<FontFaceSet>> FontFaceState::containing_sets() constreturn sets;}-Optional<ComputationContext> FontFaceState::computation_context() const+ComputationContext FontFaceState::computation_context() const{if (m_css_font_face_rule_identity.has_value()) {if (auto document = m_source_style_sheet->owning_document())@@ -593,7 +598,16 @@ Optional<ComputationContext> FontFaceState::computation_context() const}if (auto document = m_environment->responsible_document())return ComputationContext { .length_resolution_context = Length::ResolutionContext::for_document(*document) };- return {};+ auto const& initial_font = FontComputer::initial_font();+ auto const& pixel_metrics = initial_font.pixel_metrics();+ Length::FontMetrics font_metrics { CSSPixels { initial_font.pixel_size() }, pixel_metrics, normal_line_height(pixel_metrics) };+ return ComputationContext {+ .length_resolution_context = {+ .viewport_rect = {},+ .font_metrics = font_metrics,+ .root_font_metrics = font_metrics,+ },+ };}void FontFaceState::disconnect_from_css_rule()@@ -835,7 +849,7 @@ WebIDL::ExceptionOr<void> FontFaceState::set_descriptor(DescriptorID descriptor,if (auto font_computer = registered_font_computer(); font_computer.has_value()) {if (changes_matching_key)font_computer->register_font_face(*this);- else if (descriptor == DescriptorID::UnicodeRange)+ else if (first_is_one_of(descriptor, DescriptorID::UnicodeRange, DescriptorID::SizeAdjust))font_computer->did_load_font(m_family);}return {};@@ -846,9 +860,7 @@ void FontFaceState::apply_descriptor(DescriptorID descriptor, StyleValue const&auto& text = m_descriptor_texts[attribute_index(descriptor)];auto absolutized = [&] -> NonnullRefPtr<StyleValue const> {auto context = computation_context();- NonnullRefPtr<StyleValue const> absolutized_value = value;- if (context.has_value())- absolutized_value = value.absolutized(*context);+ auto absolutized_value = value.absolutized(context);text = serialize_style_value_to_utf16(*absolutized_value);return absolutized_value;};@@ -877,6 +889,13 @@ void FontFaceState::apply_descriptor(DescriptorID descriptor, StyleValue const&m_unicode_ranges.unchecked_append(range->as_unicode_range().unicode_range());break;}+ case DescriptorID::SizeAdjust: {+ auto computed_value = absolutized();+ m_size_adjust = computed_value->is_percentage()+ ? computed_value->as_percentage().percentage().as_fraction()+ : computed_value->as_calculated().resolve_percentage({}).value().as_fraction();+ break;+ }case DescriptorID::FontDisplay:text = serialize_style_value_to_utf16(value);m_font_display = keyword_to_font_display(value.to_keyword()).value_or(FontDisplay::Auto);diff --git a/Libraries/LibWeb/CSS/FontFace.h b/Libraries/LibWeb/CSS/FontFace.hindex 60fa6f47d40..f17326ce739 100644--- a/Libraries/LibWeb/CSS/FontFace.h+++ b/Libraries/LibWeb/CSS/FontFace.h@@ -46,6 +46,9 @@ public:Utf16String line_gap_override() const { return m_state->descriptor_text(DescriptorID::LineGapOverride); }WebIDL::ExceptionOr<void> set_line_gap_override(Utf16View value) { return m_state->set_descriptor(DescriptorID::LineGapOverride, value); }+ Utf16String size_adjust() const { return m_state->descriptor_text(DescriptorID::SizeAdjust); }+ WebIDL::ExceptionOr<void> set_size_adjust(Utf16View value) { return m_state->set_descriptor(DescriptorID::SizeAdjust, value); }+FontFaceLoadStatus status() const { return m_state->status(); }GC::Ref<WebIDL::Promise> load() { return m_state->load(); }GC::Ref<WebIDL::Promise> loaded() const { return m_state->loaded(); }diff --git a/Libraries/LibWeb/CSS/FontFace.idl b/Libraries/LibWeb/CSS/FontFace.idlindex 8eaeae2e816..819841c7ab0 100644--- a/Libraries/LibWeb/CSS/FontFace.idl+++ b/Libraries/LibWeb/CSS/FontFace.idl@@ -9,6 +9,7 @@ dictionary FontFaceDescriptors {CSSOMString ascentOverride = "normal";CSSOMString descentOverride = "normal";CSSOMString lineGapOverride = "normal";+ CSSOMString sizeAdjust = "100%";};enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };@@ -29,6 +30,7 @@ interface FontFace {attribute CSSOMString ascentOverride;attribute CSSOMString descentOverride;attribute CSSOMString lineGapOverride;+ attribute CSSOMString sizeAdjust;readonly attribute FontFaceLoadStatus status;diff --git a/Libraries/LibWeb/CSS/FontFaceSnapshot.h b/Libraries/LibWeb/CSS/FontFaceSnapshot.hindex b836a9541f4..77908e21757 100644--- a/Libraries/LibWeb/CSS/FontFaceSnapshot.h+++ b/Libraries/LibWeb/CSS/FontFaceSnapshot.h@@ -59,6 +59,7 @@ public:// Where a pending face is on its font-display timeline, which a frozen cascade records.Gfx::PendingFontState rendering_state { Gfx::PendingFontState::Visible };Vector<Gfx::UnicodeRange> unicode_ranges;+ double size_adjust { 1 };bool has_urls { false };// Its font-display period failed or its load errored, so it contributes nothing.bool is_unusable { false };diff --git a/Libraries/LibWeb/CSS/FontFaceState.h b/Libraries/LibWeb/CSS/FontFaceState.hindex b6c548e5d2c..3fcfe46465d 100644--- a/Libraries/LibWeb/CSS/FontFaceState.h+++ b/Libraries/LibWeb/CSS/FontFaceState.h@@ -52,7 +52,7 @@ public:// The serialization of the @font-face descriptor a FontFace attribute reflects.Utf16String const& descriptor_text(DescriptorID) const;WebIDL::ExceptionOr<void> set_descriptor(DescriptorID, Utf16View);- static constexpr size_t attribute_count = 11;+ static constexpr size_t attribute_count = 12;bool is_css_connected() const { return m_css_font_face_rule_identity.has_value(); }Optional<u64> css_rule_identity() const@@ -80,6 +80,8 @@ public:};}+ [[nodiscard]] double size_adjust() const { return m_size_adjust; }+// Whether the font-weight descriptor is auto, which takes the weight range of the font file in place of the// range the matching key carries.[[nodiscard]] bool weight_descriptor_is_auto() const { return m_weight_descriptor_is_auto; }@@ -135,7 +137,7 @@ private:CSSFontFaceRule& cssom_rule() const;RustDescriptorBlock connected_descriptors() const;- [[nodiscard]] Optional<ComputationContext> computation_context() const;+ [[nodiscard]] ComputationContext computation_context() const;void apply_descriptor(DescriptorID, StyleValue const&);u64 m_id { 0 };@@ -146,6 +148,7 @@ private:FontWeightRange m_cached_weight_range { 400, 400 };bool m_weight_descriptor_is_auto { true };+ double m_size_adjust { 1 };int m_cached_slope { 0 };int m_cached_width { 100 };GC::Ptr<FontLoader> m_font_loader;diff --git a/Libraries/LibWeb/CSS/FontResolution.cpp b/Libraries/LibWeb/CSS/FontResolution.cppindex d061d6c8951..66e8b5fcaf9 100644--- a/Libraries/LibWeb/CSS/FontResolution.cpp+++ b/Libraries/LibWeb/CSS/FontResolution.cpp@@ -92,14 +92,30 @@ static Gfx::FontSynthesis synthesis_for_face(FontFaceSnapshot::Face const& face,return synthesis;}+struct FontFaceSize {+ float points;+ bool apply_size_adjust;+ bool automatic_optical_size;+};+// What one face of the snapshot renders with. A face still waiting on its load becomes a pending entry: a cascade is// frozen and laid out on whichever thread resolves it, so the entry reads the snapshot and the typeface the face// publishes, and only selecting it for a rendered code point, on the document thread, reaches the face, by its number// through the document's registry.-static RefPtr<Gfx::FontCascadeList const> font_for_face(FontFaceSnapshot::Face const& face, FontFaceKey const& key, float point_size, Gfx::FontVariationSettings const& variations, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request)+static RefPtr<Gfx::FontCascadeList const> font_for_face(FontFaceSnapshot::Face const& face, FontFaceKey const& key, FontFaceSize size, Gfx::FontVariationSettings const& requested_variations, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request){if (face.is_unusable)return {};+ auto point_size = size.points;+ Optional<Gfx::FontVariationSettings> adjusted_variations;+ if (size.apply_size_adjust && face.size_adjust != 1) {+ point_size = clamp(size.points * face.size_adjust, 0.0, CSSPixels::max().to_double() * 0.75);+ if (size.automatic_optical_size) {+ adjusted_variations = requested_variations;+ adjusted_variations->set_optical_sizing(point_size / 0.75f);+ }+ }+ auto const& variations = adjusted_variations.has_value() ? *adjusted_variations : requested_variations;auto font_list = Gfx::FontCascadeList::create();if (face.typeface) {font_list->add(face.typeface->font(point_size, variations, shape_features, synthesis_for_face(face, key, *face.typeface, synthesis_request, variations)), face.unicode_ranges);@@ -158,11 +174,11 @@ struct MatchingFontCandidate {unsigned width { Gfx::FontWidth::Normal };Gfx::Typeface const* system_typeface { nullptr };- [[nodiscard]] RefPtr<Gfx::FontCascadeList const> font_with_point_size(FontFaceSnapshot const& snapshot, float point_size, Gfx::FontVariationSettings const& variations, WeightAxisFollowsFontWeight weight_axis_follows_font_weight, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request) const+ [[nodiscard]] RefPtr<Gfx::FontCascadeList const> font_with_point_size(FontFaceSnapshot const& snapshot, FontFaceSize size, Gfx::FontVariationSettings const& variations, WeightAxisFollowsFontWeight weight_axis_follows_font_weight, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request) const{if (system_typeface) {auto font_list = Gfx::FontCascadeList::create();- font_list->add(system_typeface->font(point_size, variations, shape_features, system_typeface->synthesis_for(synthesis_request, variations)));+ font_list->add(system_typeface->font(size.points, variations, shape_features, system_typeface->synthesis_for(synthesis_request, variations)));return font_list;}@@ -183,7 +199,7 @@ struct MatchingFontCandidate {// afterwards, and does nothing for a face past "unloaded" already.if (face.has_urls && !face.has_non_default_unicode_range)note_wanted_web_face(face.id);- if (auto face_fonts = font_for_face(face, key, point_size, variations_for_face(face, variations, clamped_variations), shape_features, synthesis_request)) {+ if (auto face_fonts = font_for_face(face, key, size, variations_for_face(face, variations, clamped_variations), shape_features, synthesis_request)) {font_list->extend(*face_fonts);continue;}@@ -205,7 +221,7 @@ struct MatchingFontCandidate {// Partial implementation of the font-matching algorithm: https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm// FIXME: This should be replaced by the full CSS font selection algorithm.-static RefPtr<Gfx::FontCascadeList const> font_matching_algorithm(FontFaceSnapshot const& snapshot, Utf16FlyString const& family_name, int weight, Percentage const& font_width, int slope, float font_size_in_pt, Gfx::FontVariationSettings const& variations, WeightAxisFollowsFontWeight weight_axis_follows_font_weight, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request)+static RefPtr<Gfx::FontCascadeList const> font_matching_algorithm(FontFaceSnapshot const& snapshot, Utf16FlyString const& family_name, int weight, Percentage const& font_width, int slope, FontFaceSize size, Gfx::FontVariationSettings const& variations, WeightAxisFollowsFontWeight weight_axis_follows_font_weight, Gfx::ShapeFeatures const& shape_features, Gfx::FontSynthesisRequest const& synthesis_request){// If a font family match occurs, the user agent assembles the set of font faces in that family and then// narrows the set to a single face using other font properties in the order given below.@@ -242,7 +258,7 @@ static RefPtr<Gfx::FontCascadeList const> font_matching_algorithm(FontFaceSnapshorder.resize(matching_family_fonts.size());auto order_length = Parser::ValueParserFFI::rust_font_matching_order(weighed_candidates.span(), weight, font_width_bucket_from_percentage(font_width.value()), slope, order.span());for (auto index : order.span().trim(order_length)) {- if (auto found_font = matching_family_fonts[index].font_with_point_size(snapshot, font_size_in_pt, variations, weight_axis_follows_font_weight, shape_features, synthesis_request))+ if (auto found_font = matching_family_fonts[index].font_with_point_size(snapshot, size, variations, weight_axis_follows_font_weight, shape_features, synthesis_request))return found_font;}return {};@@ -339,9 +355,12 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshot// The size the lookups below select fonts at, which font-size-adjust can change for each family.Gfx::FontVariationSettings variation;auto weight_axis_follows_font_weight = WeightAxisFollowsFontWeight::Yes;- float font_size_in_pt = 0;+ // https://drafts.csswg.org/css-fonts-5/#size-adjust-desc+ // The font-size-adjust property cancels the descriptor's scale by normalizing the font's metrics to font-size.+ FontFaceSize face_size { .points = 0, .apply_size_adjust = !key.font_size_adjust.has_value() && !key.is_font_size_adjust_probe, .automatic_optical_size = false };auto select_fonts_at = [&](float font_size_used_value) {variation = {};+ face_size.automatic_optical_size = font_optical_sizing == FontOpticalSizing::Auto;variation.set_weight(font_weight);variation.set_width(font_width.value());@@ -355,18 +374,21 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshotstruct FontVariationSettingsTarget {Gfx::FontVariationSettings& variation;WeightAxisFollowsFontWeight& weight_axis_follows_font_weight;- } target { variation, weight_axis_follows_font_weight };+ bool& automatic_optical_size;+ } target { variation, weight_axis_follows_font_weight, face_size.automatic_optical_size };weight_axis_follows_font_weight = WeightAxisFollowsFontWeight::Yes;Parser::ValueParserFFI::rust_font_variation_axes(feature_value_data(key, FontResolutionFeatureInput::FontVariationSettings), &target, [](void* target, u32 tag, double value) {- auto& [variation, weight_axis_follows_font_weight] = *static_cast<FontVariationSettingsTarget*>(target);+ auto& [variation, weight_axis_follows_font_weight, automatic_optical_size] = *static_cast<FontVariationSettingsTarget*>(target);auto four_cc = Gfx::FourCC::from_u32(tag);if (four_cc == Gfx::FourCC("wght"))weight_axis_follows_font_weight = WeightAxisFollowsFontWeight::No;+ if (four_cc == Gfx::FourCC("opsz"))+ automatic_optical_size = false;variation.axes.set(four_cc, value);});// FIXME: Implement the full font-matching algorithm: https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm- font_size_in_pt = font_size_used_value * 0.75f;+ face_size.points = font_size_used_value * 0.75f;};select_fonts_at(font_size);@@ -418,7 +440,7 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshotreturn {};auto font_list = Gfx::FontCascadeList::create();- font_list->add(typeface->font(font_size_in_pt, variation, shape_features, typeface->synthesis_for(synthesis_request, variation)));+ font_list->add(typeface->font(face_size.points, variation, shape_features, typeface->synthesis_for(synthesis_request, variation)));return font_list;};#endif@@ -438,7 +460,7 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshotauto clamped_variations = variations_clamped_to_weight_descriptor(variation, weight_axis_follows_font_weight, lookup_key.weight);auto result = Gfx::FontCascadeList::create();for (auto const& face : *faces) {- if (auto face_fonts = font_for_face(face, lookup_key, font_size_in_pt, variations_for_face(face, variation, clamped_variations), shape_features, synthesis_request))+ if (auto face_fonts = font_for_face(face, lookup_key, face_size, variations_for_face(face, variation, clamped_variations), shape_features, synthesis_request))result->extend(*face_fonts);}if (!result->is_empty())@@ -454,7 +476,7 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshot}#endif- if (auto found_font = font_matching_algorithm(snapshot, family, weight, font_width, slope, font_size_in_pt, variation, weight_axis_follows_font_weight, shape_features, synthesis_request); found_font && !found_font->is_empty())+ if (auto found_font = font_matching_algorithm(snapshot, family, weight, font_width, slope, face_size, variation, weight_axis_follows_font_weight, shape_features, synthesis_request); found_font && !found_font->is_empty())return found_font;return {};@@ -520,10 +542,10 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshot}// NB: @font-feature-values can't apply to the default font since it's not loaded from CSS- auto default_font = Platform::FontPlugin::the().default_font(font_size_in_pt, variation, shape_features_for(key, nullptr));+ auto default_font = Platform::FontPlugin::the().default_font(face_size.points, variation, shape_features_for(key, nullptr));if (auto adjusted_font_size = adjusted_font_size_for(*default_font); adjusted_font_size.has_value()) {select_fonts_at(*adjusted_font_size);- default_font = Platform::FontPlugin::the().default_font(font_size_in_pt, variation, shape_features_for(key, nullptr));+ default_font = Platform::FontPlugin::the().default_font(face_size.points, variation, shape_features_for(key, nullptr));select_fonts_at(font_size);}if (font_list->is_empty()) {@@ -551,7 +573,7 @@ NonnullRefPtr<Gfx::FontCascadeList const> resolve_font_cascade(FontFaceSnapshot// FIXME: Normalize the size of each system fallback font by font-size-adjust as well, rather than giving it// the requested size.Gfx::FontCascadeList::SystemFallbackRequest request {- .point_size = font_size_in_pt,+ .point_size = face_size.points,.weight = static_cast<u16>(clamp(weight, 1, 1000)),.width = static_cast<u16>(font_width_bucket_from_percentage(font_width.value())),.slope = static_cast<u8>(slope),@@ -728,6 +750,7 @@ static StyleEngineFFI::FfiResolvedFont resolve_font_for_style_engine(void const*.font_feature_values_scope = TreeScopeID { request.font_feature_values_scope },.font_oblique_angle = request.font_oblique_angle,.font_synthesis = request.font_synthesis,+ .is_font_size_adjust_probe = request.font_size_adjust == StyleEngineFFI::FontSizeAdjustKind::FromFont,};if (request.font_size_adjust == StyleEngineFFI::FontSizeAdjustKind::Number)key.font_size_adjust = FontSizeAdjust { static_cast<FontSizeAdjustMetric>(request.font_size_adjust_metric), request.font_size_adjust_value };@@ -753,10 +776,10 @@ static StyleEngineFFI::FfiResolvedFont resolve_font_for_style_engine(void const*// NB: The element's other fonts are then sized by that number.auto metric = static_cast<FontSizeAdjustMetric>(request.font_size_adjust_metric);font_size_adjust_from_font = font_size_adjust_aspect_value(font_list->first_available_font(), metric);- if (font_size_adjust_from_font > 0) {+ if (font_size_adjust_from_font > 0)key.font_size_adjust = FontSizeAdjust { metric, font_size_adjust_from_font };- font_list = resolve();- }+ key.is_font_size_adjust_probe = false;+ font_list = resolve();}// The metric probe must not load a face: the first available font answers without one.auto const& first_available_font = font_list->first_available_font();diff --git a/Libraries/LibWeb/CSS/FontResolution.h b/Libraries/LibWeb/CSS/FontResolution.hindex e54915117f8..c49a803dba1 100644--- a/Libraries/LibWeb/CSS/FontResolution.h+++ b/Libraries/LibWeb/CSS/FontResolution.h@@ -33,6 +33,7 @@ struct AK::Traits<Web::CSS::ComputedFontCacheKey> : public AK::DefaultTraits<Webhash = pair_int_hash(hash, Traits<Web::CSSPixels>::hash(key.font_size));if (key.font_size_adjust.has_value())hash = pair_int_hash(hash, pair_int_hash(to_underlying(key.font_size_adjust->metric), Traits<double>::hash(key.font_size_adjust->value)));+ hash = pair_int_hash(hash, key.is_font_size_adjust_probe);hash = pair_int_hash(hash, key.font_slope);hash = pair_int_hash(hash, Traits<double>::hash(key.font_weight));hash = pair_int_hash(hash, Traits<double>::hash(key.font_width.value()));diff --git a/Libraries/LibWeb/Rust/src/css/parser/descriptor_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/descriptor_parser.rsindex 4dde8374b88..7c5b80edd05 100644--- a/Libraries/LibWeb/Rust/src/css/parser/descriptor_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/descriptor_parser.rs@@ -19,8 +19,8 @@ use crate::css::parser::fonts_parser::parse_font_descriptor;use crate::css::parser::token_stream::TokenStream;use crate::css::parser::value_parser::{FfiValueParsingContext, FfiValueParsingContextKind, FontDescriptorKind, NumericRange, ParseContext, ParseOutcome,- is_valid_custom_ident, parse_css_value, parse_integer_from_stream, parse_length_value, parse_percentage_value,- string_style_value, unresolved_value, value_list,+ is_valid_custom_ident, parse_calculated_numeric_value_with_ranges, parse_css_value, parse_integer_from_stream,+ parse_length_value, parse_percentage_value, string_style_value, unresolved_value, value_list,};use crate::css::property_metadata::property_id;use crate::css::style_compute::FfiLengthResolutionContext;@@ -28,6 +28,7 @@ use crate::css::style_value::CounterStyleSystemPayload;use crate::css::style_value::StyleValueBox;use crate::css::style_value::{CssString, RetainedStyleValueData, StyleValueData};use crate::css::style_value_arc::StyleValueArc;+use crate::css::value_codes::VALUE_TYPE_PERCENTAGE;use std::ffi::c_void;#[derive(Clone)]@@ -335,7 +336,21 @@ fn parse_value_type(NumericRange::new(f64::NEG_INFINITY, f64::INFINITY),),DescriptorValueType::PositivePercentage => {- parse_percentage_value(single_non_whitespace(values)?, NumericRange::new(0.0, f64::INFINITY))+ let value = single_non_whitespace(values)?;+ let range = NumericRange::new(0.0, f64::INFINITY);+ if let Some((name, arguments)) = value.function() {+ parse_calculated_numeric_value_with_ranges(+ context,+ property_id::CUSTOM,+ VALUE_TYPE_PERCENTAGE,+ None,+ range,+ name,+ arguments,+ )+ } else {+ parse_percentage_value(value, range)+ }}DescriptorValueType::String => Some(string_style_value(single_non_whitespace(values)?.string()?)),DescriptorValueType::Symbol => parse_symbol(context, single_non_whitespace(values)?),diff --git a/Tests/LibWeb/Ref/expected/font-face-size-adjust-optical.html b/Tests/LibWeb/Ref/expected/font-face-size-adjust-optical.htmlnew file mode 100644index 00000000000..74186b25244--- /dev/null+++ b/Tests/LibWeb/Ref/expected/font-face-size-adjust-optical.html@@ -0,0 +1,11 @@+<!DOCTYPE html>+<html class="reftest-wait">+<style>@font-face { font-family: Optical; src: url("wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf"); }+body { margin: 0; }+div { font-family: Optical; font-size: 48px; line-height: 80px; }+</style>+<div>B</div>+<div style="font-variation-settings: 'opsz' 12">B</div>+<div style="font-optical-sizing: none">B</div>+<script>document.fonts.ready.then(() => document.documentElement.classList.remove("reftest-wait"));</script>+</html>diff --git a/Tests/LibWeb/Ref/expected/font-face-size-adjust-system-fallback.html b/Tests/LibWeb/Ref/expected/font-face-size-adjust-system-fallback.htmlnew file mode 100644index 00000000000..2ab3d3354dd--- /dev/null+++ b/Tests/LibWeb/Ref/expected/font-face-size-adjust-system-fallback.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<meta charset="utf-8">++<style>+@font-face { font-family: Adjusted; src: url("../data/fonts/Ahem.ttf"); }+body { font-size: 16px; }+</style>+<span style="font: 160px Adjusted"> </span><span style="font: 16px sans-serif">あ</span>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor-ref.htmlnew file mode 100644index 00000000000..e752f4110c6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor-ref.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>Tests that the sizeAdjust attribute of FontFace works</title>+<script>+/* Load Ahem similarly to the testcase so that Gecko gives it the+ same antialiasing treatment. */+const ahem = new FontFace(+ 'Ahem-normal',+ 'local("Ahem"), url("/fonts/Ahem.ttf")');+document.fonts.add(ahem);+</script>+<style>+#target {+ font-family: "Ahem-normal";+ font-size: 40px;+ letter-spacing: 10px;+}+span {+ font-size: 50%;+}+</style>++<p>The first and fourth characters should be double-sized:</p>+<div id="target">+ F<span>oo</span>B<span>ar</span>+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-01-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-01-ref.htmlnew file mode 100644index 00000000000..7250b5372ac--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-01-ref.html@@ -0,0 +1,37 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<title>Tests the size-adjust descriptor of @font-face</title>+<style>+@font-face {+ font-family: reference-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ /* Uppercase ASCII only + U+20 to make this "first available font" */+ unicode-range: U+20,U+41-5A;+}++div {+ font-size: 40px;+ line-height: 100px;+}++.reference {+ font-family: reference-font, sans-serif;+}++.large {+ font-size: 60px;+}+</style>++<p>size-adjust:100% should be the same as no override.</p>++<div>+ <span class="reference">TheQuickBrownFox</span>+</div>++<p>size-adjust:150% should affect Ahem characters only.</p>++<div>+ <span class="reference"><span class="large">T</span>he<span class="large">Q</span>uick<span class="large">B</span>rown<span class="large">F</span>ox</span>+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-02-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-02-ref.htmlnew file mode 100644index 00000000000..7b9a0870904--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-02-ref.html@@ -0,0 +1,37 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<title>Tests that font-size-adjust overrides the size-adjust descriptor</title>+<style>+@font-face {+ font-family: reference-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ unicode-range: U+41-5A; /* Uppercase ASCII only */+}++div {+ font-size: 40px;+ line-height: 100px;+ font-size-adjust: 0.5;+}++.reference {+ font-family: reference-font, sans-serif;+}++.large {+ font-size: 60px;+}+</style>++<p>Without size-adjust applied to the Ahem font.</p>++<div>+ <span class="reference">The Quick Brown Fox</span>+</div>++<p>With size-adjust:150% there should be no change as font-size-adjust overrides it.</p>++<div>+ <span class="reference">The Quick Brown Fox</span>+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-03-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-03-ref.htmlnew file mode 100644index 00000000000..a88952f98b2--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-03-ref.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<title>Tests that font-size-adjust preempts size-adjust from the descriptor.</title>+<style>+@font-face {+ font-family: reference-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+}++div {+ line-height: 100px;+}++.font-size-adjust-override {+ font-family: reference-font, sans-serif;+ font-size: 40px;+}++.descriptor-size-adjust-active {+ font-family: reference-font, sans-serif;+ font-size: 60px;+}+</style>++<p>With font-size-adjust, size-adjust:150% has no effect as font-size-adjust overrides it.</p>++<div class="font-size-adjust-override">The Quick Brown Fox</div>++<p>Without font-size-adjust, size-adjust:150% should be applied. Pass if the following texts show bigger than the above.</p>++<div class="descriptor-size-adjust-active">The Quick Brown Fox</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-tentative-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-tentative-ref.htmlnew file mode 100644index 00000000000..5c28f7da445--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-tentative-ref.html@@ -0,0 +1,52 @@+<!DOCTYPE html>+<title>Tests the size-adjust descriptor of @font-face</title>++<style>+@font-face {+ font-family: custom-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ unicode-range: U+20, U+30-39; /* Digits and space */+}++.target {+ font-size: 10px;+ font-family: custom-font, sans-serif;+}++.unaffected {+ font-size: 20px;+}++.square {+ display: inline-block;+ vertical-align: bottom;+ background-color: black;+ width: var(--l);+ height: var(--l);+}+</style>++<p>size-adjust should scale ascent and descent metrics in 'line-height: normal'.</p>+<div class="target">+ 123<br>+ 123<br>+ 123+</div>++<p>In a text node with multiple fonts, size-adjust should only scale characters in the modified font. In the test case below, digits should be scaled, but not letters.</p>+<div class="target" style="height: 30px">+ 123<span class="unaffected">xxx</span>+</div>++<p>In nested elements, size-adjust should be applied to each text segment independently. Both elements below should be scaled to 50% of their original sizes, respectively.</p>+<div class="target">+ 123+ <div style="font-size: 200%">+ 456+ </div>+</div>++<p>The computed 'font-size' value (i.e., 'em') should not be affected. But 'ex' should be scaled since it's measured from the actual glyph.</p>+<div class="target" style="font-size: 20px; line-height: 1">+ <span class="square" style="--l: 1em"></span><span class="square" style="--l: 0.5ex"></span>+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-text-decoration-tentative-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-text-decoration-tentative-ref.htmlnew file mode 100644index 00000000000..4ce37f263a6--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/size-adjust-text-decoration-tentative-ref.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<!-- Test is tentative due to the following issues:+ - https://github.com/w3c/csswg-drafts/issues/6112+ - https://github.com/w3c/csswg-drafts/issues/6114+-->+<title>Tests interaction between the size-adjust descriptor of @font-face and text decoration</title>++<style>+@font-face {+ font-family: custom-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+}++.target {+ margin: 20px;+ font-size: 10px;+ font-family: custom-font, sans-serif;+ text-decoration-line: underline;+ text-decoration-style: solid;+ text-decoration-color: black;+}+</style>++<p>size-adjust should not affect em- or percentage-based text-underline-offset.</p>++<!-- We fix thickness because the default thickness value 'auto' allows browser-specific behaviors. -->++<div class="target" style="text-underline-offset: 0.2em; text-decoration-thickness: 1px;">+ É+</div>++<div class="target" style="text-underline-offset: 20%; text-decoration-thickness: 1px;">+ É+</div>++<p>size-adjust should not affect em- or percentage-based text-decoration-thickness.</p>++<div class="target" style="text-decoration-thickness: 0.2em">+ É+</div>++<div class="target" style="text-decoration-thickness: 20%">+ É+</div>++<p>size-adjust should affect 'text-underline-thickness: from-font', which is a metric obtained from the font file. The underline should be 50% as thick as original.</p>+<div class="target" style="text-decoration-thickness: from-font">+ É+</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttfnew file mode 100644index 00000000000..0d5bf3e267fBinary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf differdiff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/variable-opsz-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/variable-opsz-ref.htmlnew file mode 100644index 00000000000..24080345ba0--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-fonts/variations/variable-opsz-ref.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html class="reftest-wait">+<meta charset="utf-8">+<style>+ @font-face {+ font-family: variabletest_box;+ src: url(resources/variabletest_box.ttf);+ }++ body {+ font-family: variabletest_box, sans-serif;+ font-optical-sizing: none;+ }+</style>+<div style="font-size: 6px; font-variation-settings: 'opsz' 6;">B</div>+<div style="font-size: 12px; font-variation-settings: 'opsz' 12;">B</div>+<div style="font-size: 24px; font-variation-settings: 'opsz' 24;">B</div>+<div style="font-size: 48px; font-variation-settings: 'opsz' 48;">B</div>+<div style="font-size: 64px; font-variation-settings: 'opsz' 64;">B</div>+<div style="font-size: 128px; font-variation-settings: 'opsz' 128;">B</div>+<div style="font-size: 24px; font-variation-settings: 'opsz' 128;">B</div>+<div style="font-size: 48px; font-variation-settings: 'opsz' 12;">B</div>+<script>+ document.fonts.ready.then(+ () => { document.documentElement.classList.remove("reftest-wait"); });+</script>+</html>diff --git a/Tests/LibWeb/Ref/input/font-face-size-adjust-optical.html b/Tests/LibWeb/Ref/input/font-face-size-adjust-optical.htmlnew file mode 100644index 00000000000..9f506b89936--- /dev/null+++ b/Tests/LibWeb/Ref/input/font-face-size-adjust-optical.html@@ -0,0 +1,11 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../expected/font-face-size-adjust-optical.html"><style>@font-face { font-family: Optical; src: url("wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf"); size-adjust: 200%; }+body { margin: 0; }+div { font-family: Optical; font-size: 24px; line-height: 80px; }+</style>+<div>B</div>+<div style="font-variation-settings: 'opsz' 12">B</div>+<div style="font-optical-sizing: none">B</div>+<script>document.fonts.ready.then(() => document.documentElement.classList.remove("reftest-wait"));</script>+</html>diff --git a/Tests/LibWeb/Ref/input/font-face-size-adjust-system-fallback.html b/Tests/LibWeb/Ref/input/font-face-size-adjust-system-fallback.htmlnew file mode 100644index 00000000000..8ec76a7c590--- /dev/null+++ b/Tests/LibWeb/Ref/input/font-face-size-adjust-system-fallback.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="match" href="../expected/font-face-size-adjust-system-fallback.html">+<style>+@font-face { font-family: Adjusted; src: url("../data/fonts/Ahem.ttf"); size-adjust: 1000%; unicode-range: U+0020, U+00A0; }+body { font-size: 16px; }+</style>+<span style="font-family: Adjusted"> あ</span>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor.htmlnew file mode 100644index 00000000000..b70d71dfc82--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<title>Tests that the sizeAdjust attribute of FontFace works</title>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-font-loading/#fontface-interface">+<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-size-adjust-desc">+<link rel="match" href="../../../../expected/wpt-import/css/css-font-loading/fontface-size-adjust-descriptor-ref.html">+<script>+const ahem = new FontFace(+ 'Ahem-normal',+ 'local("Ahem"), url("/fonts/Ahem.ttf")');+document.fonts.add(ahem);+const large = new FontFace(+ 'Ahem-large',+ 'local("Ahem"), url("/fonts/Ahem.ttf")',+ {sizeAdjust: "200%", unicodeRange: "U+20,U+41-5A"});+document.fonts.add(large);+</script>+<style>+#target {+ font-family: "Ahem-large", "Ahem-normal";+ font-size: 20px;+ letter-spacing: 10px;+}+</style>++<p>The first and fourth characters should be double-sized:</p>+<div id="target">+ FooBar+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-01.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-01.htmlnew file mode 100644index 00000000000..b75a900a067--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-01.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-fonts-5/"> <!-- XXX to be added -->+<link rel="match" href="../../../../expected/wpt-import/css/css-fonts/size-adjust-01-ref.html">+<link rel="assert" title="Tests that size-adjust scales the glyphs of the face">+<title>Tests the size-adjust descriptor of @font-face</title>+<style>+@font-face {+ font-family: reference-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 100%;+ /* Uppercase ASCII only + U+20 to make this "first available font" */+ unicode-range: U+20,U+41-5A;+}++@font-face {+ font-family: large-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 150%;+ /* Uppercase ASCII only + U+20 to make this "first available font" */+ unicode-range: U+20,U+41-5A;+}++div {+ font-size: 40px;+ line-height: 100px;+}++.reference {+ font-family: reference-font, sans-serif;+}++.large {+ font-family: large-font, sans-serif;+}+</style>++<p>size-adjust:100% should be the same as no override.</p>++<div>+ <span class="reference">TheQuickBrownFox</span>+</div>++<p>size-adjust:150% should affect Ahem characters only.</p>++<div>+ <span class="large">TheQuickBrownFox</span>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-02.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-02.htmlnew file mode 100644index 00000000000..33cfaaa6371--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-02.html@@ -0,0 +1,48 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-fonts-5/"> <!-- XXX to be added -->+<link rel="match" href="../../../../expected/wpt-import/css/css-fonts/size-adjust-02-ref.html">+<link rel="assert" title="Tests that font-size-adjust overrides the size-adjust descriptor">+<title>Tests that font-size-adjust overrides the size-adjust descriptor</title>+<style>+@font-face {+ font-family: reference-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 100%;+ unicode-range: U+41-5A; /* Uppercase ASCII only */+}++@font-face {+ font-family: large-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 150%;+ unicode-range: U+41-5A; /* Uppercase ASCII only */+}++div {+ font-size: 40px;+ line-height: 100px;+ font-size-adjust: 0.5;+}++.reference {+ font-family: reference-font, sans-serif;+}++.large {+ font-family: large-font, sans-serif;+}+</style>++<p>Without size-adjust applied to the Ahem font.</p>++<div>+ <span class="reference">The Quick Brown Fox</span>+</div>++<p>With size-adjust:150% there should be no change as font-size-adjust overrides it.</p>++<div>+ <span class="large">The Quick Brown Fox</span>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-03.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-03.htmlnew file mode 100644index 00000000000..39d8f237ff5--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-03.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-fonts-5/#font-size-adjust-prop">+<link rel="match" href="../../../../expected/wpt-import/css/css-fonts/size-adjust-03-ref.html">+<link rel="assert" title="Tests that font-size-adjust preempts size-adjust from the descriptor.">+<title>Tests that font-size-adjust preempts size-adjust from the descriptor.</title>+<style>+@font-face {+ font-family: large-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 150%;+}++div {+ font-size: 40px;+ line-height: 100px;+}++.font-size-adjust-override {+ font-family: large-font, sans-serif;+ font-size-adjust: 0.8;+}++.descriptor-size-adjust-active {+ font-family: large-font, sans-serif;+}+</style>++<p>With font-size-adjust, size-adjust:150% has no effect as font-size-adjust overrides it.</p>++<div class="font-size-adjust-override">The Quick Brown Fox</div>++<p>Without font-size-adjust, size-adjust:150% should be applied. Pass if the following texts show bigger than the above.</p>++<div class="descriptor-size-adjust-active">The Quick Brown Fox</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-text-decoration.tentative.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-text-decoration.tentative.htmlnew file mode 100644index 00000000000..dfe7005ea5e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust-text-decoration.tentative.html@@ -0,0 +1,54 @@+<!DOCTYPE html>+<!-- Test is tentative due to the following issues:+ - https://github.com/w3c/csswg-drafts/issues/6112+ - https://github.com/w3c/csswg-drafts/issues/6114+-->+<title>Tests interaction between the size-adjust descriptor of @font-face and text decoration</title>+<link rel="help" href="https://drafts.csswg.org/css-fonts-5/#descdef-font-face-size-adjust">+<link rel="author" href="mailto:[email protected]">+<link rel="match" href="../../../../expected/wpt-import/css/css-fonts/size-adjust-text-decoration-tentative-ref.html">+<link rel="assert" title="size-adjust should not affect em- or percentage-based values, but affects 'from-font'">++<style>+@font-face {+ font-family: custom-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 50%;+}++.target {+ margin: 20px;+ font-size: 20px;+ font-family: custom-font, sans-serif;+ text-decoration-line: underline;+ text-decoration-style: solid;+ text-decoration-color: black;+}+</style>++<p>size-adjust should not affect em- or percentage-based text-underline-offset.</p>++<!-- We fix thickness because the default thickness value 'auto' allows browser-specific behaviors. -->++<div class="target" style="text-underline-offset: 0.1em; text-decoration-thickness: 1px;">+ É+</div>++<div class="target" style="text-underline-offset: 10%; text-decoration-thickness: 1px;">+ É+</div>++<p>size-adjust should not affect em- or percentage-based text-decoration-thickness.</p>++<div class="target" style="text-decoration-thickness: 0.1em">+ É+</div>++<div class="target" style="text-decoration-thickness: 10%">+ É+</div>++<p>size-adjust should affect 'text-underline-thickness: from-font', which is a metric obtained from the font file. The underline should be 50% as thick as original.</p>+<div class="target" style="text-decoration-thickness: from-font">+ É+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust.tentative.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust.tentative.htmlnew file mode 100644index 00000000000..09aafdacbfc--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/size-adjust.tentative.html@@ -0,0 +1,57 @@+<!DOCTYPE html>+<!-- Test is tentative due to the following issues:+ - https://github.com/w3c/csswg-drafts/issues/6112+ - https://github.com/w3c/csswg-drafts/issues/6114+-->+<title>Tests the size-adjust descriptor of @font-face</title>+<link rel="help" href="https://drafts.csswg.org/css-fonts-5/#descdef-font-face-size-adjust">+<link rel="author" href="mailto:[email protected]">+<link rel="match" href="../../../../expected/wpt-import/css/css-fonts/size-adjust-tentative-ref.html">+<link rel="assert" title="size-adjust should resize all metrics of the font face">++<style>+@font-face {+ font-family: custom-font;+ src: local(Ahem), url(../../fonts/Ahem.ttf);+ size-adjust: 50%;+ unicode-range: U+20, U+30-39; /* Digits and space */+}++.target {+ font-size: 20px;+ font-family: custom-font, sans-serif;+}++.square {+ display: inline-block;+ vertical-align: bottom;+ background-color: black;+ width: var(--l);+ height: var(--l);+}+</style>++<p>size-adjust should scale ascent and descent metrics in 'line-height: normal'.</p>+<div class="target">+ 123<br>+ 123<br>+ 123+</div>++<p>In a text node with multiple fonts, size-adjust should only scale characters in the modified font. In the test case below, digits should be scaled, but not letters.</p>+<div class="target" style="height: 30px">+ 123xxx+</div>++<p>In nested elements, size-adjust should be applied to each text segment independently. Both elements below should be scaled to 50% of their original sizes, respectively.</p>+<div class="target">+ 123+ <div style="font-size: 200%">+ 456+ </div>+</div>++<p>The computed 'font-size' value (i.e., 'em') should not be affected. But 'ex' should be scaled since it's measured from the actual glyph.</p>+<div class="target" style="line-height: 1">+ <span class="square" style="--l: 1em"></span><span class="square" style="--l: 1ex"></span>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttfnew file mode 100644index 00000000000..0d5bf3e267fBinary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/resources/variabletest_box.ttf differdiff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/variable-opsz.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/variable-opsz.htmlnew file mode 100644index 00000000000..e1c3e4fa61c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-fonts/variations/variable-opsz.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="author" title="Dominik Röttsches" href="[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-optical-sizing-def"/>+<meta name="assert" content="Ensures that optical size is automatically applied."/>+<link rel="match" href="../../../../../expected/wpt-import/css/css-fonts/variations/variable-opsz-ref.html">+<meta charset="utf-8">+<style>+ @font-face {+ font-family: variabletest_box;+ src: url(resources/variabletest_box.ttf);+ }++ body {+ font-family: variabletest_box, sans-serif;+ }+</style>+<!-- The variabletest_box font file contains a glyph for letter B which moves a+ horizontal bar up from the middle for opsz > 12 and moves it down for opsz >+ 12 where the opsz axis ranges from 12 to 128. -->+<div style="font-size: 6px;">B</div>+<div style="font-size: 12px;">B</div>+<div style="font-size: 24px;">B</div>+<div style="font-size: 48px;">B</div>+<div style="font-size: 64px;">B</div>+<div style="font-size: 128px;">B</div>+<!-- Explicit value overrides auto. -->+<div style="font-size: 24px; font-variation-settings: 'opsz' 128;">B</div>+<div style="font-size: 48px; font-optical-sizing: none;">B</div>+<script>+ document.fonts.ready.then(+ () => { document.documentElement.classList.remove("reftest-wait"); });+</script>+</html>diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex e7867e9b683..0348d4bb91c 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -247,6 +247,8 @@ Text/input/css/font-face-load-dedups-same-url.htmlText/input/css/font-load-delays-document-load-event.htmlText/input/css/font-face-unused-face-not-fetched.htmlText/input/css/font-face-reconnect-after-descriptor-change.html+Text/input/css/font-face-size-adjust.html+Text/input/css/font-face-size-adjust-worker.htmlText/input/css/style-engine/removing-stylesheet-preserves-descendant-animation-overlay.htmlText/input/css/unrecognized-font-family-fallback-honors-weight.htmlText/input/wpt-import/html/syntax/parsing/html5lib_url.htmldiff --git a/Tests/LibWeb/Text/expected/css/font-face-size-adjust-css-text.txt b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-css-text.txtnew file mode 100644index 00000000000..f0008cf2776--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-css-text.txt@@ -0,0 +1,3 @@+initial: 50% / 40+replacement: 150% / 120+removed descriptor: 100% / 80diff --git a/Tests/LibWeb/Text/expected/css/font-face-size-adjust-values.txt b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-values.txtnew file mode 100644index 00000000000..e565c40f054--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-values.txt@@ -0,0 +1,20 @@+0%: 0+0% with from-font: 80+0% restored: true+37.5%: 30+37.5% with from-font: 80+37.5% restored: true+calc(25% + 50%): 60+calc(25% + 50%) with from-font: 80+calc(25% + 50%) restored: true+calc(10% - 20%): 0+calc(10% - 20%) with from-font: 80+calc(10% - 20%) restored: true+100000000000%: finite geometry: true+100000000000% with from-font: 80+100000000000% restored: true+normal: SyntaxError+-1%: SyntaxError+10px: SyntaxError+100: SyntaxError+inherit: SyntaxErrordiff --git a/Tests/LibWeb/Text/expected/css/font-face-size-adjust-worker.txt b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-worker.txtnew file mode 100644index 00000000000..2a64b788db1--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/font-face-size-adjust-worker.txt@@ -0,0 +1,12 @@+px: calc(100%)+px setter: calc(200%)+em: calc(1600%)+em setter: calc(3200%)+rem: calc(1600%)+rem setter: calc(3200%)+vw: calc(0%)+vw setter: calc(0%)+vh: calc(0%)+vh setter: calc(0%)+cqw: calc(0%)+cqw setter: calc(0%)diff --git a/Tests/LibWeb/Text/expected/css/font-face-size-adjust.txt b/Tests/LibWeb/Text/expected/css/font-face-size-adjust.txtnew file mode 100644index 00000000000..faaf9cd0b93--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/font-face-size-adjust.txt@@ -0,0 +1,17 @@+local face at 50%: 40+computed font-size: 20px+CSSOM camel/dashed: 50% / 50%+CSSOM mutation: 120+setProperty mutation: 20+connected FontFace mutation: 60 / 75%+removed descriptor: 80 / 100%+unicode-range fallback: 60+URL face at 200%: 160 / 200%+loaded FontFace mutation: 40+calculated descriptor: 60+zero descriptor: 0+font-size-adjust supersedes descriptor: 80+default descriptor: 100%+negative setter: SyntaxError / 100%+invalid constructor: error+binary face at 125%: 100diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/idlharness.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/idlharness.txtindex 4703028d66c..c9e597d44df 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/idlharness.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/idlharness.txt@@ -2,8 +2,8 @@ Harness status: OKFound 97 tests-75 Pass-22 Fail+77 Pass+20 FailPass idl_test setupPass idl_test validationPass Partial interface CSSRule: original interface defined@@ -27,8 +27,8 @@ Pass CSSFontFaceDescriptors interface: attribute fontWidthPass CSSFontFaceDescriptors interface: attribute font-widthFail CSSFontFaceDescriptors interface: attribute fontSizeFail CSSFontFaceDescriptors interface: attribute font-size-Fail CSSFontFaceDescriptors interface: attribute sizeAdjust-Fail CSSFontFaceDescriptors interface: attribute size-adjust+Pass CSSFontFaceDescriptors interface: attribute sizeAdjust+Pass CSSFontFaceDescriptors interface: attribute size-adjustPass CSSFontFaceDescriptors interface: attribute unicodeRangePass CSSFontFaceDescriptors interface: attribute unicode-rangePass CSSFontFaceDescriptors interface: attribute fontFeatureSettingsdiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-face-size-adjust.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-face-size-adjust.txtindex b8fc5dce7fa..9394ade60aa 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-face-size-adjust.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/parsing/font-face-size-adjust.txt@@ -2,11 +2,10 @@ Harness status: OKFound 6 tests-2 Pass-4 Fail-Fail Check that size-adjust: 100% is valid-Fail Check that size-adjust: 0% is valid-Fail Check that size-adjust: 110% is valid-Fail Check that size-adjust: 100000000000% is valid+6 Pass+Pass Check that size-adjust: 100% is valid+Pass Check that size-adjust: 0% is valid+Pass Check that size-adjust: 110% is valid+Pass Check that size-adjust: 100000000000% is validPass Check that size-adjust: -100% is invalidPass Check that size-adjust: -1% is invalid\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/css/font-face-size-adjust-css-text.html b/Tests/LibWeb/Text/input/css/font-face-size-adjust-css-text.htmlnew file mode 100644index 00000000000..f8c7100730d--- /dev/null+++ b/Tests/LibWeb/Text/input/css/font-face-size-adjust-css-text.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ @font-face { font-family: Adjusted; src: local(Ahem); size-adjust: 50%; }+ span { display: inline-block; font: 20px Adjusted; }+</style>+<span id="sample">AAAA</span>+<script>+promiseTest(async () => {+ await document.fonts.load("20px Adjusted");+ const rule = document.styleSheets[0].cssRules[0];+ const face = [...document.fonts][0];+ const width = () => sample.getBoundingClientRect().width;+ println(`initial: ${face.sizeAdjust} / ${width()}`);+ rule.style.cssText = "font-family: Adjusted; src: local(Ahem); size-adjust: 150%";+ println(`replacement: ${face.sizeAdjust} / ${width()}`);+ rule.style.cssText = "font-family: Adjusted; src: local(Ahem)";+ println(`removed descriptor: ${face.sizeAdjust} / ${width()}`);+});+</script>diff --git a/Tests/LibWeb/Text/input/css/font-face-size-adjust-values.html b/Tests/LibWeb/Text/input/css/font-face-size-adjust-values.htmlnew file mode 100644index 00000000000..b53ccd88d1d--- /dev/null+++ b/Tests/LibWeb/Text/input/css/font-face-size-adjust-values.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<script>+promiseTest(async () => {+ for (const [index, value] of ["0%", "37.5%", "calc(25% + 50%)", "calc(10% - 20%)", "100000000000%"].entries()) {+ const family = `AdjustedValue${index}`;+ const face = new FontFace(family, "local(Ahem)", { sizeAdjust: value });+ document.fonts.add(face);+ await face.load();+ const span = document.createElement("span");+ span.style.cssText = `font: 20px ${family}; display: inline-block; position: absolute; visibility: hidden`;+ span.textContent = "AAAA";+ document.body.append(span);+ const width = span.getBoundingClientRect().width;+ println(`${value}: ${index === 4 ? `finite geometry: ${Number.isFinite(width)}` : width}`);+ span.style.fontSizeAdjust = "from-font";+ println(`${value} with from-font: ${span.getBoundingClientRect().width}`);+ span.style.fontSizeAdjust = "none";+ println(`${value} restored: ${span.getBoundingClientRect().width === width}`);+ span.remove();+ document.fonts.delete(face);+ }+ const face = new FontFace("ValidateAdjusted", "local(Ahem)");+ for (const value of ["normal", "-1%", "10px", "100", "inherit"]) {+ try {+ face.sizeAdjust = value;+ println(`${value}: accepted`);+ } catch (error) {+ println(`${value}: ${error.name}`);+ }+ }+});+</script>diff --git a/Tests/LibWeb/Text/input/css/font-face-size-adjust-worker.html b/Tests/LibWeb/Text/input/css/font-face-size-adjust-worker.htmlnew file mode 100644index 00000000000..b32eca035c5--- /dev/null+++ b/Tests/LibWeb/Text/input/css/font-face-size-adjust-worker.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<script>+promiseTest(async () => {+ const source = `+ const results = [];+ for (const unit of ["px", "em", "rem", "vw", "vh", "cqw"]) {+ const sizeAdjust = "calc(1" + unit + " / 1px * 100%)";+ const face = new FontFace("Adjusted", "local(Ahem)", { sizeAdjust });+ results.push(unit + ": " + face.sizeAdjust);+ face.sizeAdjust = "calc(2" + unit + " / 1px * 100%)";+ results.push(unit + " setter: " + face.sizeAdjust);+ }+ postMessage(results);+ `;+ const url = URL.createObjectURL(new Blob([source], { type: "text/javascript" }));+ const worker = new Worker(url);+ try {+ const results = await new Promise((resolve, reject) => {+ worker.onmessage = event => resolve(event.data);+ worker.onerror = event => reject(new Error(event.message));+ });+ results.forEach(println);+ } finally {+ worker.terminate();+ URL.revokeObjectURL(url);+ }+});+</script>diff --git a/Tests/LibWeb/Text/input/css/font-face-size-adjust.html b/Tests/LibWeb/Text/input/css/font-face-size-adjust.htmlnew file mode 100644index 00000000000..32ccf9e0ebf--- /dev/null+++ b/Tests/LibWeb/Text/input/css/font-face-size-adjust.html@@ -0,0 +1,69 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ @font-face { font-family: Adjusted; src: local("Ahem"); size-adjust: 50%; }+ @font-face { font-family: SubsetAdjusted; src: local("Ahem"); size-adjust: 200%; unicode-range: U+41; }+ span { display: inline-block; font: 20px Ahem; }+</style>+<script>+promiseTest(async () => {+ function measure(family, text = "AAAA") {+ const span = document.createElement("span");+ span.style.fontFamily = family;+ span.textContent = text;+ document.body.append(span);+ return span;+ }+ const width = element => element.getBoundingClientRect().width;+ const css = measure("Adjusted");+ await document.fonts.load("20px Adjusted");+ println(`local face at 50%: ${width(css)}`);+ println(`computed font-size: ${getComputedStyle(css).fontSize}`);+ const descriptors = document.styleSheets[0].cssRules[0].style;+ println(`CSSOM camel/dashed: ${descriptors.sizeAdjust} / ${descriptors["size-adjust"]}`);+ descriptors.sizeAdjust = "150%";+ println(`CSSOM mutation: ${width(css)}`);+ descriptors.setProperty("size-adjust", "25%");+ println(`setProperty mutation: ${width(css)}`);+ const cssFace = [...document.fonts].find(face => face.family === "Adjusted");+ cssFace.sizeAdjust = "75%";+ println(`connected FontFace mutation: ${width(css)} / ${descriptors.sizeAdjust}`);+ descriptors.removeProperty("size-adjust");+ println(`removed descriptor: ${width(css)} / ${cssFace.sizeAdjust}`);++ const subset = measure("SubsetAdjusted, Ahem", "AB");+ await document.fonts.load("20px SubsetAdjusted", "AB");+ println(`unicode-range fallback: ${width(subset)}`);++ const face = new FontFace("DynamicAdjusted", "url(../wpt-import/fonts/Ahem.ttf)", { sizeAdjust: "200%" });+ document.fonts.add(face);+ const dynamic = measure("DynamicAdjusted");+ await face.load();+ println(`URL face at 200%: ${width(dynamic)} / ${face.sizeAdjust}`);+ face.sizeAdjust = "50%";+ println(`loaded FontFace mutation: ${width(dynamic)}`);+ face.sizeAdjust = "calc(25% + 50%)";+ println(`calculated descriptor: ${width(dynamic)}`);+ face.sizeAdjust = "0%";+ println(`zero descriptor: ${width(dynamic)}`);+ face.sizeAdjust = "200%";+ dynamic.style.fontSizeAdjust = "0.8";+ println(`font-size-adjust supersedes descriptor: ${width(dynamic)}`);+ const initial = new FontFace("DefaultAdjusted", "local(Ahem)");+ println(`default descriptor: ${initial.sizeAdjust}`);+ try {+ initial.sizeAdjust = "-1%";+ println("negative setter accepted");+ } catch (error) {+ println(`negative setter: ${error.name} / ${initial.sizeAdjust}`);+ }+ const invalid = new FontFace("InvalidAdjusted", "local(Ahem)", { sizeAdjust: "-1%" });+ invalid.loaded.catch(() => {});+ println(`invalid constructor: ${invalid.status}`);+ const data = await fetch("../wpt-import/fonts/Ahem.ttf").then(response => response.arrayBuffer());+ const binary = new FontFace("BinaryAdjusted", data, { sizeAdjust: "125%" });+ document.fonts.add(binary);+ await binary.loaded;+ println(`binary face at 125%: ${width(measure("BinaryAdjusted"))}`);+});+</script>