ladybird/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

56 lines
1.5 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "FontPluginSerenity.h"
#include <AK/ByteString.h>
#include <LibGfx/Font/FontDatabase.h>
namespace Web::Platform {
FontPluginSerenity::FontPluginSerenity()
{
// NOTE: These will eventually get replaced by system defaults.
Gfx::FontDatabase::set_default_font_query("Katica 10 400 0");
Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");
}
FontPluginSerenity::~FontPluginSerenity() = default;
Gfx::Font& FontPluginSerenity::default_font()
{
return Gfx::FontDatabase::default_font();
}
Gfx::Font& FontPluginSerenity::default_fixed_width_font()
{
return Gfx::FontDatabase::default_fixed_width_font();
}
FlyString FontPluginSerenity::generic_font_name(GenericFont generic_font)
{
// FIXME: Make these configurable at the browser settings level. Fall back to system defaults.
switch (generic_font) {
case GenericFont::SansSerif:
case GenericFont::UiSansSerif:
case GenericFont::Cursive:
case GenericFont::UiRounded:
return default_font().family();
case GenericFont::Monospace:
case GenericFont::UiMonospace:
return default_fixed_width_font().family();
case GenericFont::Serif:
case GenericFont::UiSerif:
return "Roman"_fly_string;
case GenericFont::Fantasy:
return "Comic Book"_fly_string;
case GenericFont::__Count:
VERIFY_NOT_REACHED();
}
VERIFY_NOT_REACHED();
}
}