mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibGfx: Load the system default fonts by name
Instead of loading them by absolute path, that is.
This commit is contained in:
parent
2fd5ce1eb0
commit
70eaadc1cd
1 changed files with 17 additions and 20 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <AK/kmalloc.h>
|
#include <AK/kmalloc.h>
|
||||||
#include <LibCore/FileStream.h>
|
#include <LibCore/FileStream.h>
|
||||||
|
#include <LibGfx/FontDatabase.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -61,32 +62,29 @@ struct [[gnu::packed]] FontFileHeader
|
||||||
|
|
||||||
Font& Font::default_font()
|
Font& Font::default_font()
|
||||||
{
|
{
|
||||||
static Font* s_default_font;
|
static Font* font;
|
||||||
static const char* default_font_path = "/res/fonts/KaticaRegular10.font";
|
if (!font) {
|
||||||
if (!s_default_font) {
|
font = FontDatabase::the().get_by_name("Katica 10 400");
|
||||||
s_default_font = Font::load_from_file(default_font_path).leak_ref();
|
ASSERT(font);
|
||||||
ASSERT(s_default_font);
|
|
||||||
}
|
}
|
||||||
return *s_default_font;
|
return *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font& Font::default_fixed_width_font()
|
Font& Font::default_fixed_width_font()
|
||||||
{
|
{
|
||||||
static Font* s_default_fixed_width_font;
|
static Font* font;
|
||||||
static const char* default_fixed_width_font_path = "/res/fonts/CsillaRegular10.font";
|
if (!font) {
|
||||||
if (!s_default_fixed_width_font) {
|
font = FontDatabase::the().get_by_name("Csilla 10 400");
|
||||||
s_default_fixed_width_font = Font::load_from_file(default_fixed_width_font_path).leak_ref();
|
ASSERT(font);
|
||||||
ASSERT(s_default_fixed_width_font);
|
|
||||||
}
|
}
|
||||||
return *s_default_fixed_width_font;
|
return *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font& Font::default_bold_fixed_width_font()
|
Font& Font::default_bold_fixed_width_font()
|
||||||
{
|
{
|
||||||
static Font* font;
|
static Font* font;
|
||||||
static const char* default_bold_fixed_width_font_path = "/res/fonts/CsillaBold10.font";
|
|
||||||
if (!font) {
|
if (!font) {
|
||||||
font = Font::load_from_file(default_bold_fixed_width_font_path).leak_ref();
|
font = FontDatabase::the().get_by_name("Csilla 10 700");
|
||||||
ASSERT(font);
|
ASSERT(font);
|
||||||
}
|
}
|
||||||
return *font;
|
return *font;
|
||||||
|
@ -94,13 +92,12 @@ Font& Font::default_bold_fixed_width_font()
|
||||||
|
|
||||||
Font& Font::default_bold_font()
|
Font& Font::default_bold_font()
|
||||||
{
|
{
|
||||||
static Font* s_default_bold_font;
|
static Font* font;
|
||||||
static const char* default_bold_font_path = "/res/fonts/KaticaBold10.font";
|
if (!font) {
|
||||||
if (!s_default_bold_font) {
|
font = FontDatabase::the().get_by_name("Katica 10 700");
|
||||||
s_default_bold_font = Font::load_from_file(default_bold_font_path).leak_ref();
|
ASSERT(font);
|
||||||
ASSERT(s_default_bold_font);
|
|
||||||
}
|
}
|
||||||
return *s_default_bold_font;
|
return *font;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Font> Font::clone() const
|
NonnullRefPtr<Font> Font::clone() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue