mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:27:34 +00:00
LibGFX: Move default_xxx_font() methods from Font to FontDatabase
When we have an abstract font class it makes no sense to keep these methods in the Font class.
This commit is contained in:
parent
1a072a61fb
commit
b4d1390714
48 changed files with 152 additions and 115 deletions
|
@ -202,7 +202,7 @@ void StyleProperties::load_font() const
|
|||
|
||||
if (!found_font) {
|
||||
dbgln("Font not found: '{}' {} {}", family, size, weight);
|
||||
found_font = Gfx::Font::default_font();
|
||||
found_font = Gfx::FontDatabase::default_font();
|
||||
}
|
||||
|
||||
m_font = found_font;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
|
@ -86,12 +87,12 @@ RefPtr<Layout::Node> HTMLInputElement::create_layout_node(const CSS::StyleProper
|
|||
auto& widget = downcast<Layout::WidgetBox>(layout_node())->widget();
|
||||
const_cast<HTMLInputElement*>(this)->set_attribute(HTML::AttributeNames::value, static_cast<const GUI::TextBox&>(widget).text());
|
||||
};
|
||||
int text_width = Gfx::Font::default_font().width(value());
|
||||
int text_width = Gfx::FontDatabase::default_font().width(value());
|
||||
auto size_value = attribute(HTML::AttributeNames::size);
|
||||
if (!size_value.is_null()) {
|
||||
auto size = size_value.to_uint();
|
||||
if (size.has_value())
|
||||
text_width = Gfx::Font::default_font().glyph_width('x') * size.value();
|
||||
text_width = Gfx::FontDatabase::default_font().glyph_width('x') * size.value();
|
||||
}
|
||||
text_box.set_relative_rect(0, 0, text_width + 20, 20);
|
||||
return adopt(*new Layout::WidgetBox(document(), *this, text_box));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibGfx/ImageDecoder.h>
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/Layout/ImageBox.h>
|
||||
|
@ -79,7 +80,7 @@ void ImageBox::prepare_for_replaced_layout()
|
|||
|
||||
if (renders_as_alt_text()) {
|
||||
auto& image_element = downcast<HTML::HTMLImageElement>(dom_node());
|
||||
auto& font = Gfx::Font::default_font();
|
||||
auto& font = Gfx::FontDatabase::default_font();
|
||||
auto alt = image_element.alt();
|
||||
if (alt.is_empty())
|
||||
alt = image_element.src();
|
||||
|
@ -107,7 +108,7 @@ void ImageBox::paint(PaintContext& context, PaintPhase phase)
|
|||
if (phase == PaintPhase::Foreground) {
|
||||
if (renders_as_alt_text()) {
|
||||
auto& image_element = downcast<HTML::HTMLImageElement>(dom_node());
|
||||
context.painter().set_font(Gfx::Font::default_font());
|
||||
context.painter().set_font(Gfx::FontDatabase::default_font());
|
||||
Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2);
|
||||
auto alt = image_element.alt();
|
||||
if (alt.is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue