FontFace.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
  3. * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/FlyString.h>
  9. #include <AK/URL.h>
  10. #include <LibGfx/Font/UnicodeRange.h>
  11. namespace Web::CSS {
  12. class FontFace {
  13. public:
  14. struct Source {
  15. Variant<String, URL> local_or_url;
  16. // FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing?
  17. Optional<FlyString> format;
  18. };
  19. FontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges);
  20. ~FontFace() = default;
  21. FlyString font_family() const { return m_font_family; }
  22. Optional<int> weight() const { return m_weight; }
  23. Optional<int> slope() const { return m_slope; }
  24. Vector<Source> const& sources() const { return m_sources; }
  25. Vector<Gfx::UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
  26. // FIXME: font-stretch, font-feature-settings
  27. private:
  28. FlyString m_font_family;
  29. Optional<int> m_weight { 0 };
  30. Optional<int> m_slope { 0 };
  31. Vector<Source> m_sources;
  32. Vector<Gfx::UnicodeRange> m_unicode_ranges;
  33. };
  34. }