/src/serenity/Userland/Libraries/LibGfx/FontCascadeList.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibGfx/Font/Font.h> |
10 | | #include <LibGfx/Font/UnicodeRange.h> |
11 | | |
12 | | namespace Gfx { |
13 | | |
14 | | class FontCascadeList : public RefCounted<FontCascadeList> { |
15 | | public: |
16 | | static NonnullRefPtr<FontCascadeList> create() |
17 | 0 | { |
18 | 0 | return adopt_ref(*new FontCascadeList()); |
19 | 0 | } |
20 | | |
21 | 0 | size_t size() const { return m_fonts.size(); } |
22 | 0 | bool is_empty() const { return m_fonts.is_empty(); } |
23 | 0 | Font const& first() const { return *m_fonts.first().font; } |
24 | | |
25 | | template<typename Callback> |
26 | | void for_each_font_entry(Callback callback) const |
27 | | { |
28 | | for (auto const& font : m_fonts) |
29 | | callback(font); |
30 | | } |
31 | | |
32 | | void add(NonnullRefPtr<Font> font); |
33 | | void add(NonnullRefPtr<Font> font, Vector<UnicodeRange> unicode_ranges); |
34 | | |
35 | | void extend(FontCascadeList const& other); |
36 | | |
37 | | Gfx::Font const& font_for_code_point(u32 code_point) const; |
38 | | |
39 | | bool equals(FontCascadeList const& other) const; |
40 | | |
41 | | struct Entry { |
42 | | NonnullRefPtr<Font> font; |
43 | | Optional<Vector<UnicodeRange>> unicode_ranges; |
44 | | }; |
45 | | |
46 | | private: |
47 | | Vector<Entry> m_fonts; |
48 | | }; |
49 | | |
50 | | } |