Coverage Report

Created: 2025-08-28 06:26

/src/serenity/Userland/Libraries/LibGfx/Font/FontDatabase.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/ByteString.h>
10
#include <AK/FlyString.h>
11
#include <AK/Function.h>
12
#include <AK/HashMap.h>
13
#include <AK/OwnPtr.h>
14
#include <LibGfx/Font/FontWeight.h>
15
#include <LibGfx/Font/Typeface.h>
16
#include <LibGfx/Forward.h>
17
18
namespace Gfx {
19
20
class FontDatabase {
21
public:
22
    static FontDatabase& the();
23
24
    static Font& default_font();
25
    static Font& default_fixed_width_font();
26
    static Font& window_title_font();
27
28
    static ByteString default_font_query();
29
    static ByteString window_title_font_query();
30
    static ByteString fixed_width_font_query();
31
32
    static ByteString default_fonts_lookup_path();
33
    static void set_default_font_query(ByteString);
34
    static void set_window_title_font_query(ByteString);
35
    static void set_fixed_width_font_query(ByteString);
36
37
    RefPtr<Gfx::Font> get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
38
    RefPtr<Gfx::Font> get(FlyString const& family, FlyString const& variant, float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
39
    RefPtr<Gfx::Font> get_by_name(StringView);
40
    void for_each_font(Function<void(Gfx::Font const&)>);
41
    void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
42
43
    void for_each_typeface(Function<void(Typeface const&)>);
44
    void for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)>);
45
46
    void load_all_fonts_from_uri(StringView);
47
48
private:
49
    FontDatabase();
50
0
    ~FontDatabase() = default;
51
52
    RefPtr<Typeface> get_or_create_typeface(FlyString const& family, FlyString const& variant);
53
54
    struct Private;
55
    OwnPtr<Private> m_private;
56
};
57
58
}