Files
ladybird/Libraries/LibWebView/Plugins/FontPlugin.h
Callum Law b55023fad3 LibGfx+LibWeb: Resolve font features per font rather than per element
Previously we would resolve font features
(https://drafts.csswg.org/css-fonts-4/#feature-variation-precedence)
per element, while this works for the current subset of the font feature
resolution algorithm that we support, some as yet unimplemented parts
require us to know whether we are resolving against a CSS @font-face
rule, and if so which one (e.g. applying descriptors from the @font-face
rule, deciding which @font-feature-values rules to apply, etc).

To achieve this we store the data required to resolve font features in a
struct and pass that to `FontComputer` which resolves the font features
and stores them with the computed `Font`.

We no longer need to invalidate the font shaping cache when features
change since the features are defined per font (and therefore won't ever
change).
2026-02-02 14:11:43 +00:00

39 lines
1.2 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibWeb/Platform/FontPlugin.h>
#include <LibWebView/Forward.h>
namespace WebView {
class WEBVIEW_API FontPlugin final : public Web::Platform::FontPlugin {
public:
FontPlugin(bool is_layout_test_mode, Gfx::SystemFontProvider* = nullptr);
virtual ~FontPlugin();
virtual RefPtr<Gfx::Font> default_font(float point_size, Optional<Gfx::FontVariationSettings> const& font_variation_settings = {}, Optional<Gfx::ShapeFeatures> const& shape_features = {}) override;
virtual Gfx::Font& default_fixed_width_font() override;
virtual FlyString generic_font_name(Web::Platform::GenericFont) override;
virtual Vector<FlyString> symbol_font_names() override;
virtual bool is_layout_test_mode() const override { return m_is_layout_test_mode; }
void update_generic_fonts();
private:
Vector<FlyString> m_generic_font_names;
Vector<FlyString> m_symbol_font_names;
FlyString m_default_font_name;
RefPtr<Gfx::Font> m_default_fixed_width_font;
bool m_is_layout_test_mode { false };
};
}