mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 21:57:44 +00:00
Userland+Tests: Remove uses of direct file loading for BitmapFont
Route them through Core::Resource APIs instead.
This commit is contained in:
parent
d587bd0a04
commit
1567332e34
6 changed files with 28 additions and 26 deletions
|
@ -32,7 +32,7 @@ ErrorOr<void> WelcomeWidget::create_widgets()
|
|||
TRY(load_from_gml(welcome_window_gml));
|
||||
|
||||
m_banner_widget = find_descendant_of_type_named<GUI::Widget>("welcome_banner");
|
||||
m_banner_font = TRY(Gfx::BitmapFont::try_load_from_file("/res/fonts/MarietaRegular24.font"sv));
|
||||
m_banner_font = TRY(Gfx::BitmapFont::try_load_from_uri("resource://fonts/MarietaRegular24.font"sv));
|
||||
|
||||
m_web_view = find_descendant_of_type_named<WebView::OutOfProcessWebView>("web_view");
|
||||
m_web_view->use_native_user_style_sheet();
|
||||
|
|
|
@ -154,7 +154,7 @@ void Canvas::draw()
|
|||
painter.draw_text(Gfx::IntRect { 520, 450, 240, 20 }, "Normal text (fixed width)"sv, Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue);
|
||||
painter.draw_text(Gfx::IntRect { 520, 465, 240, 20 }, "Bold text (fixed width)"sv, Gfx::FontDatabase::default_fixed_width_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Yellow);
|
||||
|
||||
auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font"sv);
|
||||
auto font = Gfx::BitmapFont::load_from_uri("resource://fonts/PebbletonBold14.font"sv);
|
||||
painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray);
|
||||
painter.draw_text(Gfx::IntRect { 520, 510, 240, 30 }, "Hello friends! :^)"sv, *font, Gfx::TextAlignment::Center, Color::White);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ ColorLines::ColorLines(StringView app_name)
|
|||
, m_board { make<MarbleBoard>() }
|
||||
, m_marble_bitmaps { build_marble_color_bitmaps() }
|
||||
, m_trace_bitmaps { build_marble_trace_bitmaps() }
|
||||
, m_score_font { Gfx::BitmapFont::load_from_file("/res/fonts/MarietaBold24.font") }
|
||||
, m_score_font { Gfx::BitmapFont::load_from_uri("resource://fonts/MarietaBold24.font"sv) }
|
||||
{
|
||||
VERIFY(m_marble_bitmaps.size() == Marble::number_of_colors);
|
||||
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
|
||||
|
|
|
@ -20,10 +20,10 @@ REGISTER_WIDGET(GUI, Calendar);
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static auto const extra_large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular36.font");
|
||||
static auto const large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font");
|
||||
static auto const medium_font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonRegular14.font");
|
||||
static auto const small_font = Gfx::BitmapFont::load_from_file("/res/fonts/KaticaRegular10.font");
|
||||
static auto const extra_large_font = Gfx::BitmapFont::load_from_uri("resource://fonts/MarietaRegular36.font"sv);
|
||||
static auto const large_font = Gfx::BitmapFont::load_from_uri("resource://fonts/MarietaRegular24.font"sv);
|
||||
static auto const medium_font = Gfx::BitmapFont::load_from_uri("resource://fonts/PebbletonRegular14.font"sv);
|
||||
static auto const small_font = Gfx::BitmapFont::load_from_uri("resource://fonts/KaticaRegular10.font"sv);
|
||||
|
||||
Calendar::Calendar(Core::DateTime date_time, Mode mode)
|
||||
: m_selected_date(date_time)
|
||||
|
@ -451,7 +451,7 @@ void Calendar::paint_event(GUI::PaintEvent& event)
|
|||
m_months[i].is_being_pressed,
|
||||
m_months[i].is_hovered,
|
||||
false, true, false);
|
||||
set_font(small_font);
|
||||
set_font(*small_font);
|
||||
painter.draw_text(month_tile_rect, m_months[i].name, font(), Gfx::TextAlignment::Center, palette().base_text());
|
||||
i++;
|
||||
}
|
||||
|
@ -623,15 +623,15 @@ void Calendar::paint_tile(GUI::Painter& painter, GUI::Calendar::Tile& tile, Gfx:
|
|||
font().pixel_size_rounded_up() + 4);
|
||||
|
||||
if (width > 150 && height > 150) {
|
||||
set_font(extra_large_font);
|
||||
set_font(*extra_large_font);
|
||||
} else if (width > 100 && height > 100) {
|
||||
set_font(large_font);
|
||||
set_font(*large_font);
|
||||
} else if (width > 50 && height > 50) {
|
||||
set_font(medium_font);
|
||||
set_font(*medium_font);
|
||||
} else if (width >= 30 && height >= 30) {
|
||||
set_font(small_font);
|
||||
set_font(*small_font);
|
||||
} else {
|
||||
set_font(small_font);
|
||||
set_font(*small_font);
|
||||
text_alignment = Gfx::TextAlignment::Center;
|
||||
text_rect = Gfx::IntRect(tile_rect);
|
||||
}
|
||||
|
@ -654,9 +654,9 @@ void Calendar::paint_tile(GUI::Painter& painter, GUI::Calendar::Tile& tile, Gfx:
|
|||
painter.fill_rect(tile_rect, palette().base());
|
||||
|
||||
if (width > 50 && height > 50) {
|
||||
set_font(medium_font);
|
||||
set_font(*medium_font);
|
||||
} else {
|
||||
set_font(small_font);
|
||||
set_font(*small_font);
|
||||
}
|
||||
|
||||
auto display_date = DeprecatedString::number(tile.day);
|
||||
|
|
|
@ -122,7 +122,7 @@ void FontDatabase::load_all_fonts_from_uri(StringView uri)
|
|||
auto path_string = resource.filesystem_path().release_value();
|
||||
auto path = LexicalPath(path_string.bytes_as_string_view());
|
||||
if (path.has_extension(".font"sv)) {
|
||||
if (auto font_or_error = Gfx::BitmapFont::try_load_from_file(path.string()); !font_or_error.is_error()) {
|
||||
if (auto font_or_error = Gfx::BitmapFont::try_load_from_resource(resource); !font_or_error.is_error()) {
|
||||
auto font = font_or_error.release_value();
|
||||
m_private->full_name_to_font_map.set(font->qualified_name().to_deprecated_string(), *font);
|
||||
auto typeface = get_or_create_typeface(font->family(), font->variant());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue