diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index 94b1c0ce1d..8a370160bd 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -79,7 +79,7 @@ int main(int argc, char** argv) path = "/tmp/saved.font"; edited_font = static_ptr_cast(Gfx::FontDatabase::default_font().clone()); } else { - edited_font = static_ptr_cast(Gfx::Font::load_from_file(path)->clone()); + edited_font = static_ptr_cast(Gfx::BitmapFont::load_from_file(path)->clone()); if (!edited_font) { String message = String::formatted("Couldn't load font: {}\n", path); GUI::MessageBox::show(nullptr, message, "Font Editor", GUI::MessageBox::Type::Error); @@ -111,7 +111,7 @@ int main(int argc, char** argv) if (!open_path.has_value()) return; - RefPtr new_font = static_ptr_cast(Gfx::Font::load_from_file(open_path.value())->clone()); + RefPtr new_font = static_ptr_cast(Gfx::BitmapFont::load_from_file(open_path.value())->clone()); if (!new_font) { String message = String::formatted("Couldn't load font: {}\n", open_path.value()); GUI::MessageBox::show(window, message, "Font Editor", GUI::MessageBox::Type::Error); diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index f3192f4cc7..8d40798e30 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -167,7 +167,7 @@ void Canvas::draw() painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue); painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_bold_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Yellow); - auto font = Gfx::Font::load_from_file("/res/fonts/PebbletonBold14.font"); + auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font"); painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray); painter.draw_text({ 520, 510, 240, 30 }, "Hello friends! :^)", *font, Gfx::TextAlignment::Center, Color::White); diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 037f088968..52287a1dd0 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES Color.cpp DisjointRectSet.cpp Emoji.cpp - Font.cpp FontDatabase.cpp GIFLoader.cpp ICOLoader.cpp diff --git a/Userland/Libraries/LibGfx/Font.cpp b/Userland/Libraries/LibGfx/Font.cpp deleted file mode 100644 index ba0849b21b..0000000000 --- a/Userland/Libraries/LibGfx/Font.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020, Stephan Unverwerth - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -namespace Gfx { - -RefPtr Font::load_from_file(const StringView& path) -{ - if (path.ends_with(".font")) { - return BitmapFont::load_from_file(path); - } - return {}; -} - -} diff --git a/Userland/Libraries/LibGfx/Font.h b/Userland/Libraries/LibGfx/Font.h index c5a588ecde..747f778b25 100644 --- a/Userland/Libraries/LibGfx/Font.h +++ b/Userland/Libraries/LibGfx/Font.h @@ -103,8 +103,6 @@ private: class Font : public RefCounted { public: - static RefPtr load_from_file(const StringView& path); - virtual NonnullRefPtr clone() const = 0; virtual ~Font() {}; diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index bf50ea8892..5bd687472d 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -104,7 +104,7 @@ FontDatabase::FontDatabase() auto path = String::format("/res/fonts/%s", name.characters()); if (name.ends_with(".font")) { - if (auto font = Gfx::Font::load_from_file(path)) { + if (auto font = Gfx::BitmapFont::load_from_file(path)) { m_private->full_name_to_font_map.set(font->qualified_name(), font); auto typeface = get_or_create_typeface(font->family(), font->variant()); typeface->add_bitmap_font(font);