ladybird/Userland/Libraries/LibWeb/CSS/FontFace.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

42 lines
1.3 KiB
C++

/*
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <LibGfx/Font/UnicodeRange.h>
#include <LibURL/URL.h>
namespace Web::CSS {
class FontFace {
public:
struct Source {
Variant<String, URL::URL> local_or_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, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges);
~FontFace() = default;
FlyString font_family() const { return m_font_family; }
Optional<int> weight() const { return m_weight; }
Optional<int> slope() const { return m_slope; }
Vector<Source> const& sources() const { return m_sources; }
Vector<Gfx::UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
// FIXME: font-stretch, font-feature-settings
private:
FlyString m_font_family;
Optional<int> m_weight { 0 };
Optional<int> m_slope { 0 };
Vector<Source> m_sources;
Vector<Gfx::UnicodeRange> m_unicode_ranges;
};
}