ladybird/Userland/Libraries/LibWeb/CSS/FontFace.h
Sam Atkins 12b8570ce3 LibWeb: Understand the format() part of a @font-face's src
This is used to skip downloading fonts in formats that we don't support.
Currently we only support TTF as far as I am aware.

The parts of a `src` are in a fixed order, unusually, which makes the
parsing more nesty instead of loopy.
2022-04-07 21:20:14 +02:00

38 lines
984 B
C++

/*
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <AK/URL.h>
#include <LibWeb/CSS/UnicodeRange.h>
namespace Web::CSS {
class FontFace {
public:
struct Source {
AK::URL url;
// FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing?
Optional<FlyString> format;
};
FontFace(FlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges);
~FontFace() = default;
FlyString font_family() const { return m_font_family; }
Vector<Source> const& sources() const { return m_sources; }
Vector<UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
// FIXME: font-style, font-weight, font-stretch, font-feature-settings
private:
FlyString m_font_family;
Vector<Source> m_sources;
Vector<UnicodeRange> m_unicode_ranges;
};
}