2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-02-12 14:35:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Function.h>
|
2019-05-28 11:53:16 +02:00
|
|
|
#include <AK/HashMap.h>
|
2021-05-19 14:35:34 +02:00
|
|
|
#include <AK/OwnPtr.h>
|
2020-01-10 19:06:00 +03:00
|
|
|
#include <AK/String.h>
|
2020-02-15 00:10:34 +01:00
|
|
|
#include <LibGfx/Forward.h>
|
2021-01-02 14:49:20 +01:00
|
|
|
#include <LibGfx/Typeface.h>
|
2019-02-12 14:35:33 +01:00
|
|
|
|
2020-10-31 10:18:49 +01:00
|
|
|
namespace Gfx {
|
2020-03-07 12:02:21 +13:00
|
|
|
|
2021-03-22 19:51:06 +00:00
|
|
|
namespace FontWeight {
|
|
|
|
|
enum {
|
|
|
|
|
Thin = 100,
|
|
|
|
|
ExtraLight = 200,
|
|
|
|
|
Light = 300,
|
|
|
|
|
Regular = 400,
|
|
|
|
|
Medium = 500,
|
|
|
|
|
SemiBold = 600,
|
|
|
|
|
Bold = 700,
|
|
|
|
|
ExtraBold = 800,
|
|
|
|
|
Black = 900,
|
|
|
|
|
ExtraBlack = 950
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-07 12:02:21 +13:00
|
|
|
class FontDatabase {
|
2019-02-12 14:35:33 +01:00
|
|
|
public:
|
2020-03-07 12:02:21 +13:00
|
|
|
static FontDatabase& the();
|
2019-02-12 14:35:33 +01:00
|
|
|
|
2020-12-29 18:25:13 +01:00
|
|
|
static Font& default_font();
|
|
|
|
|
static Font& default_fixed_width_font();
|
|
|
|
|
|
2021-05-21 18:10:23 +02:00
|
|
|
static String default_font_query();
|
|
|
|
|
static String fixed_width_font_query();
|
|
|
|
|
static void set_default_font_query(String);
|
|
|
|
|
static void set_fixed_width_font_query(String);
|
|
|
|
|
|
2020-12-28 15:47:21 +01:00
|
|
|
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight);
|
2021-01-02 18:20:10 +01:00
|
|
|
RefPtr<Gfx::Font> get(const String& family, const String& variant, unsigned size);
|
2021-11-11 00:55:02 +01:00
|
|
|
RefPtr<Gfx::Font> get_by_name(StringView);
|
2020-10-25 19:28:06 +01:00
|
|
|
void for_each_font(Function<void(const Gfx::Font&)>);
|
|
|
|
|
void for_each_fixed_width_font(Function<void(const Gfx::Font&)>);
|
2019-05-25 16:43:15 -07:00
|
|
|
|
2021-01-02 18:20:10 +01:00
|
|
|
void for_each_typeface(Function<void(const Typeface&)>);
|
2021-01-02 14:49:20 +01:00
|
|
|
|
2019-02-12 14:35:33 +01:00
|
|
|
private:
|
2020-03-07 12:02:21 +13:00
|
|
|
FontDatabase();
|
|
|
|
|
~FontDatabase();
|
2019-02-12 14:35:33 +01:00
|
|
|
|
2021-01-02 18:20:10 +01:00
|
|
|
RefPtr<Typeface> get_or_create_typeface(const String& family, const String& variant);
|
|
|
|
|
|
2020-10-25 19:28:06 +01:00
|
|
|
struct Private;
|
|
|
|
|
OwnPtr<Private> m_private;
|
2019-02-12 14:35:33 +01:00
|
|
|
};
|
2020-03-07 12:02:21 +13:00
|
|
|
|
|
|
|
|
}
|