FontCascadeList.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Font/Font.h>
  8. #include <LibGfx/Font/UnicodeRange.h>
  9. namespace Gfx {
  10. class FontCascadeList : public RefCounted<FontCascadeList> {
  11. public:
  12. static NonnullRefPtr<FontCascadeList> create()
  13. {
  14. return adopt_ref(*new FontCascadeList());
  15. }
  16. size_t size() const { return m_fonts.size(); }
  17. bool is_empty() const { return m_fonts.is_empty(); }
  18. Font const& first() const { return *m_fonts.first().font; }
  19. void add(NonnullRefPtr<Font> font);
  20. void add(NonnullRefPtr<Font> font, Vector<UnicodeRange> unicode_ranges);
  21. void extend(FontCascadeList const& other);
  22. Gfx::Font const& font_for_code_point(u32 code_point) const;
  23. bool equals(FontCascadeList const& other) const;
  24. struct Entry {
  25. NonnullRefPtr<Font> font;
  26. Optional<Vector<UnicodeRange>> unicode_ranges;
  27. };
  28. private:
  29. Vector<Entry> m_fonts;
  30. };
  31. }