Files
ladybird/Libraries/LibWeb/Platform/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

47 lines
1.0 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <LibGfx/Font/FontVariationSettings.h>
#include <LibGfx/Forward.h>
#include <LibGfx/ShapeFeature.h>
#include <LibWeb/Export.h>
namespace Web::Platform {
enum class GenericFont {
Cursive,
Fantasy,
Monospace,
SansSerif,
Serif,
UiMonospace,
UiRounded,
UiSansSerif,
UiSerif,
__Count,
};
class WEB_API FontPlugin {
public:
static FontPlugin& the();
static void install(FontPlugin&);
virtual ~FontPlugin();
virtual RefPtr<Gfx::Font> default_font(float point_size, Optional<Gfx::FontVariationSettings> const& font_variation_settings = {}, Optional<Gfx::ShapeFeatures> const& shape_features = {}) = 0;
virtual Gfx::Font& default_fixed_width_font() = 0;
virtual FlyString generic_font_name(GenericFont) = 0;
virtual Vector<FlyString> symbol_font_names() = 0;
virtual bool is_layout_test_mode() const = 0;
};
}