diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index e4199c0d9d..a23ef94054 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -52,7 +52,7 @@ TEST_CASE(test_clone) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); auto new_font = font->clone(); EXPECT(!new_font->name().is_empty()); @@ -65,7 +65,7 @@ TEST_CASE(test_set_name) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); auto name = "my newly created font"_string; font->set_name(name); @@ -78,7 +78,7 @@ TEST_CASE(test_set_family) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); auto family = "my newly created font family"_string; font->set_family(family); @@ -91,7 +91,7 @@ TEST_CASE(test_set_glyph_width) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); size_t ch = 123; font->set_glyph_width(ch, glyph_width); @@ -103,7 +103,7 @@ TEST_CASE(test_set_glyph_spacing) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); u8 glyph_spacing = 8; font->set_glyph_spacing(glyph_spacing); @@ -115,7 +115,7 @@ TEST_CASE(test_width) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); EXPECT(font->width("A"sv) == glyph_width); } @@ -124,7 +124,7 @@ TEST_CASE(test_glyph_or_emoji_width) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); Utf8View view { " "sv }; auto it = view.begin(); @@ -142,7 +142,7 @@ TEST_CASE(test_write_to_file) { u8 glyph_height = 1; u8 glyph_width = 1; - auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); + auto font = MUST(Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256)); char path[] = "/tmp/new.font.XXXXXX"; EXPECT(mkstemp(path) != -1); diff --git a/Userland/Applications/FontEditor/NewFontDialog.cpp b/Userland/Applications/FontEditor/NewFontDialog.cpp index ef8a0255d8..2527f96c41 100644 --- a/Userland/Applications/FontEditor/NewFontDialog.cpp +++ b/Userland/Applications/FontEditor/NewFontDialog.cpp @@ -236,7 +236,7 @@ ErrorOr> NewFontDialog::create_font() { save_metadata(); - auto font = TRY(Gfx::BitmapFont::try_create(m_new_font_metadata.glyph_height, m_new_font_metadata.glyph_width, m_new_font_metadata.is_fixed_width, 0x110000)); + auto font = TRY(Gfx::BitmapFont::create(m_new_font_metadata.glyph_height, m_new_font_metadata.glyph_width, m_new_font_metadata.is_fixed_width, 0x110000)); font->set_name(m_new_font_metadata.name); font->set_family(m_new_font_metadata.family); font->set_presentation_size(m_new_font_metadata.presentation_size); diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp index 28ae2f0434..dfcab1aea6 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp @@ -61,12 +61,7 @@ ErrorOr> BitmapFont::try_clone() const return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_range_mask_size, new_range_mask, m_baseline, m_mean_line, m_presentation_size, m_weight, m_slope, true))); } -NonnullRefPtr BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count) -{ - return MUST(try_create(glyph_height, glyph_width, fixed, glyph_count)); -} - -ErrorOr> BitmapFont::try_create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count) +ErrorOr> BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count) { glyph_count += 256 - (glyph_count % 256); glyph_count = min(glyph_count, s_max_glyph_count); diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.h b/Userland/Libraries/LibGfx/Font/BitmapFont.h index fba06b3308..8a2dee3117 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.h +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.h @@ -22,8 +22,7 @@ class BitmapFont final : public Font { public: virtual NonnullRefPtr clone() const override; ErrorOr> try_clone() const override; - static NonnullRefPtr create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count); - static ErrorOr> try_create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count); + static ErrorOr> create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count); virtual FontPixelMetrics pixel_metrics() const override;