summaryrefslogtreecommitdiff
path: root/SharedGraphics
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-04 11:37:15 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-04 11:37:15 +0100
commitcacba45f1c615257c2c6a9f041e851e0ac030c13 (patch)
tree37447734500405b2fb10e4447bf4c2bd94bc4d7c /SharedGraphics
parentac11c90dee3ac43e5e6d78ff9e9b64c4ce115744 (diff)
downloadserenity-cacba45f1c615257c2c6a9f041e851e0ac030c13.zip
LizaBold8x10: Import a bold variant of Liza8x10 and make it the default bold.
Start using it right away for window titles.
Diffstat (limited to 'SharedGraphics')
-rw-r--r--SharedGraphics/Font.cpp26
-rw-r--r--SharedGraphics/Font.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp
index f428ee5d3c..54ddf5dff4 100644
--- a/SharedGraphics/Font.cpp
+++ b/SharedGraphics/Font.cpp
@@ -32,10 +32,12 @@ static constexpr const char* error_glyph {
};
static Font* s_default_font;
+static Font* s_default_bold_font;
void Font::initialize()
{
s_default_font = nullptr;
+ s_default_bold_font = nullptr;
}
Font& Font::default_font()
@@ -44,7 +46,6 @@ Font& Font::default_font()
if (!s_default_font) {
#ifdef USERLAND
s_default_font = Font::load_from_file(default_font_path).leak_ref();
- ASSERT(s_default_font);
#else
int error;
auto descriptor = VFS::the().open(default_font_path, error, 0, 0, *VFS::the().root_inode());
@@ -56,10 +57,33 @@ Font& Font::default_font()
ASSERT(buffer);
s_default_font = Font::load_from_memory(buffer.pointer()).leak_ref();
#endif
+ ASSERT(s_default_font);
}
return *s_default_font;
}
+Font& Font::default_bold_font()
+{
+ static const char* default_bold_font_path = "/res/fonts/LizaBold8x10.font";
+ if (!s_default_bold_font) {
+#ifdef USERLAND
+ s_default_bold_font = Font::load_from_file(default_bold_font_path).leak_ref();
+#else
+ int error;
+ auto descriptor = VFS::the().open(default_bold_font_path, error, 0, 0, *VFS::the().root_inode());
+ if (!descriptor) {
+ kprintf("Failed to open default font (%s)\n", default_bold_font_path);
+ ASSERT_NOT_REACHED();
+ }
+ auto buffer = descriptor->read_entire_file(*current);
+ ASSERT(buffer);
+ s_default_bold_font = Font::load_from_memory(buffer.pointer()).leak_ref();
+#endif
+ ASSERT(s_default_bold_font);
+ }
+ return *s_default_bold_font;
+}
+
RetainPtr<Font> Font::clone() const
{
size_t bytes_per_glyph = glyph_width() * glyph_height();
diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h
index b32d672b1f..0b560d822c 100644
--- a/SharedGraphics/Font.h
+++ b/SharedGraphics/Font.h
@@ -9,6 +9,7 @@
class Font : public Retainable<Font> {
public:
static Font& default_font();
+ static Font& default_bold_font();
RetainPtr<Font> clone() const;