2022-03-28 20:30:26 +01:00
|
|
|
/*
|
2025-04-03 11:50:05 +01:00
|
|
|
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2023, Andreas Kling <andreas@ladybird.org>
|
2022-03-28 20:30:26 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-18 15:13:29 +00:00
|
|
|
#include <AK/FlyString.h>
|
2024-10-01 11:02:05 +01:00
|
|
|
#include <AK/HashMap.h>
|
2023-12-09 23:30:01 +01:00
|
|
|
#include <LibGfx/Font/UnicodeRange.h>
|
2024-09-26 14:07:46 +01:00
|
|
|
#include <LibWeb/CSS/Enums.h>
|
2024-09-26 12:51:41 +01:00
|
|
|
#include <LibWeb/CSS/Percentage.h>
|
2025-05-02 12:07:22 +01:00
|
|
|
#include <LibWeb/CSS/URL.h>
|
2022-03-28 20:30:26 +01:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2024-05-07 09:18:37 -06:00
|
|
|
class ParsedFontFace {
|
2022-03-28 20:30:26 +01:00
|
|
|
public:
|
|
|
|
struct Source {
|
2025-05-02 12:07:22 +01:00
|
|
|
Variant<FlyString, URL> local_or_url;
|
2023-02-18 15:13:29 +00:00
|
|
|
Optional<FlyString> format;
|
2025-06-03 12:32:05 +01:00
|
|
|
Vector<FontTech> tech;
|
2022-03-28 20:30:26 +01:00
|
|
|
};
|
|
|
|
|
2025-04-04 15:30:36 +01:00
|
|
|
static Vector<Source> sources_from_style_value(CSSStyleValue const&);
|
2025-04-03 11:50:05 +01:00
|
|
|
static ParsedFontFace from_descriptors(CSSFontFaceDescriptors const&);
|
|
|
|
|
2025-05-02 12:07:22 +01:00
|
|
|
ParsedFontFace(GC::Ptr<CSSStyleSheet> parent_style_sheet, FlyString font_family, Optional<int> weight, Optional<int> slope, Optional<int> width, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges, Optional<Percentage> ascent_override, Optional<Percentage> descent_override, Optional<Percentage> line_gap_override, FontDisplay font_display, Optional<FlyString> font_named_instance, Optional<FlyString> font_language_override, Optional<OrderedHashMap<FlyString, i64>> font_feature_settings, Optional<OrderedHashMap<FlyString, double>> font_variation_settings);
|
2024-05-07 09:18:37 -06:00
|
|
|
~ParsedFontFace() = default;
|
2022-03-28 20:30:26 +01:00
|
|
|
|
2025-05-02 12:07:22 +01:00
|
|
|
GC::Ptr<CSSStyleSheet> parent_style_sheet() const { return m_parent_style_sheet; }
|
2024-09-26 12:51:41 +01:00
|
|
|
Optional<Percentage> ascent_override() const { return m_ascent_override; }
|
|
|
|
Optional<Percentage> descent_override() const { return m_descent_override; }
|
2024-09-26 14:07:46 +01:00
|
|
|
FontDisplay font_display() const { return m_font_display; }
|
2024-10-26 23:27:21 +02:00
|
|
|
FlyString const& font_family() const { return m_font_family; }
|
2024-10-01 11:02:05 +01:00
|
|
|
Optional<OrderedHashMap<FlyString, i64>> font_feature_settings() const { return m_font_feature_settings; }
|
2024-09-27 17:11:31 +01:00
|
|
|
Optional<FlyString> font_language_override() const { return m_font_language_override; }
|
2024-09-26 14:45:55 +01:00
|
|
|
Optional<FlyString> font_named_instance() const { return m_font_named_instance; }
|
2024-10-01 11:02:05 +01:00
|
|
|
Optional<OrderedHashMap<FlyString, double>> font_variation_settings() const { return m_font_variation_settings; }
|
2023-05-24 15:35:04 +02:00
|
|
|
Optional<int> slope() const { return m_slope; }
|
2024-09-26 12:51:41 +01:00
|
|
|
Optional<int> weight() const { return m_weight; }
|
2024-09-27 14:27:55 +01:00
|
|
|
Optional<int> width() const { return m_width; }
|
2024-09-26 12:51:41 +01:00
|
|
|
Optional<Percentage> line_gap_override() const { return m_line_gap_override; }
|
2022-03-28 20:30:26 +01:00
|
|
|
Vector<Source> const& sources() const { return m_sources; }
|
2023-12-09 23:30:01 +01:00
|
|
|
Vector<Gfx::UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
|
2022-03-28 20:30:26 +01:00
|
|
|
|
|
|
|
private:
|
2025-05-02 12:07:22 +01:00
|
|
|
GC::Ptr<CSSStyleSheet> m_parent_style_sheet;
|
2023-02-18 15:13:29 +00:00
|
|
|
FlyString m_font_family;
|
2024-09-26 14:45:55 +01:00
|
|
|
Optional<FlyString> m_font_named_instance;
|
2024-09-27 14:27:55 +01:00
|
|
|
Optional<int> m_weight;
|
|
|
|
Optional<int> m_slope;
|
|
|
|
Optional<int> m_width;
|
2022-03-28 20:30:26 +01:00
|
|
|
Vector<Source> m_sources;
|
2023-12-09 23:30:01 +01:00
|
|
|
Vector<Gfx::UnicodeRange> m_unicode_ranges;
|
2024-09-26 12:51:41 +01:00
|
|
|
Optional<Percentage> m_ascent_override;
|
|
|
|
Optional<Percentage> m_descent_override;
|
|
|
|
Optional<Percentage> m_line_gap_override;
|
2024-09-26 14:07:46 +01:00
|
|
|
FontDisplay m_font_display;
|
2024-09-27 17:11:31 +01:00
|
|
|
Optional<FlyString> m_font_language_override;
|
2024-10-01 11:02:05 +01:00
|
|
|
Optional<OrderedHashMap<FlyString, i64>> m_font_feature_settings;
|
|
|
|
Optional<OrderedHashMap<FlyString, double>> m_font_variation_settings;
|
2022-03-28 20:30:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|