mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 00:38:56 +00:00
LibGfx: Join ScaledFont into Font
Since ScaledFont is the only class inherited from Font we could simply merge them.
This commit is contained in:
parent
16e883a9a3
commit
8e2d1559ec
Notes:
github-actions[bot]
2025-04-21 07:52:41 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 8e2d1559ec
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4409
18 changed files with 166 additions and 234 deletions
|
@ -21,7 +21,6 @@
|
|||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/Font/FontStyleMapping.h>
|
||||
#include <LibGfx/Font/FontWeight.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF/Loader.h>
|
||||
#include <LibGfx/Font/WOFF2/Loader.h>
|
||||
|
@ -236,7 +235,7 @@ RefPtr<Gfx::Font const> FontLoader::font_with_point_size(float point_size)
|
|||
start_loading_next_url();
|
||||
return nullptr;
|
||||
}
|
||||
return m_vector_font->scaled_font(point_size);
|
||||
return m_vector_font->font(point_size);
|
||||
}
|
||||
|
||||
void FontLoader::start_loading_next_url()
|
||||
|
@ -304,7 +303,7 @@ struct StyleComputer::MatchingFontCandidate {
|
|||
return font_list;
|
||||
}
|
||||
|
||||
font_list->add(loader_or_typeface.get<Gfx::Typeface const*>()->scaled_font(point_size));
|
||||
font_list->add(loader_or_typeface.get<Gfx::Typeface const*>()->font(point_size));
|
||||
return font_list;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -150,8 +150,8 @@ public:
|
|||
bool can_contain_boxes_with_position_absolute() const;
|
||||
|
||||
Gfx::Font const& first_available_font() const;
|
||||
Gfx::Font const& scaled_font(PaintContext&) const;
|
||||
Gfx::Font const& scaled_font(float scale_factor) const;
|
||||
Gfx::Font const& font(PaintContext&) const;
|
||||
Gfx::Font const& font(float scale_factor) const;
|
||||
|
||||
CSS::ImmutableComputedValues const& computed_values() const;
|
||||
|
||||
|
@ -315,12 +315,12 @@ inline Gfx::Font const& Node::first_available_font() const
|
|||
return parent()->first_available_font();
|
||||
}
|
||||
|
||||
inline Gfx::Font const& Node::scaled_font(PaintContext& context) const
|
||||
inline Gfx::Font const& Node::font(PaintContext& context) const
|
||||
{
|
||||
return scaled_font(context.device_pixels_per_css_pixel());
|
||||
return font(context.device_pixels_per_css_pixel());
|
||||
}
|
||||
|
||||
inline Gfx::Font const& Node::scaled_font(float scale_factor) const
|
||||
inline Gfx::Font const& Node::font(float scale_factor) const
|
||||
{
|
||||
auto const& font = first_available_font();
|
||||
return font.with_size(font.point_size() * scale_factor);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibGfx/BoundingBox.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibGfx/TextLayout.h>
|
||||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <gpu/ganesh/SkSurfaceGanesh.h>
|
||||
#include <pathops/SkPathOps.h>
|
||||
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/PainterSkia.h>
|
||||
#include <LibGfx/PathSkia.h>
|
||||
#include <LibGfx/SkiaUtils.h>
|
||||
|
@ -77,7 +77,7 @@ void DisplayListPlayerSkia::flush()
|
|||
|
||||
void DisplayListPlayerSkia::draw_glyph_run(DrawGlyphRun const& command)
|
||||
{
|
||||
auto const& gfx_font = static_cast<Gfx::ScaledFont const&>(command.glyph_run->font());
|
||||
auto const& gfx_font = command.glyph_run->font();
|
||||
auto sk_font = gfx_font.skia_font(command.scale);
|
||||
|
||||
auto glyph_count = command.glyph_run->glyphs().size();
|
||||
|
|
|
@ -70,7 +70,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
if (auto text = layout_box().text(); text.has_value()) {
|
||||
// FIXME: This should use proper text layout logic!
|
||||
// This does not line up with the text in the <li> element which looks very sad :(
|
||||
context.display_list_recorder().draw_text(device_enclosing.to_type<int>(), *text, layout_box().scaled_font(context), Gfx::TextAlignment::Center, color);
|
||||
context.display_list_recorder().draw_text(device_enclosing.to_type<int>(), *text, layout_box().font(context), Gfx::TextAlignment::Center, color);
|
||||
} else if (auto const* counter_style = layout_box().list_style_type().get_pointer<CSS::CounterStyleNameKeyword>()) {
|
||||
switch (*counter_style) {
|
||||
case CSS::CounterStyleNameKeyword::Square:
|
||||
|
|
|
@ -118,7 +118,7 @@ MediaPaintable::Components MediaPaintable::compute_control_bar_components(PaintC
|
|||
auto display_time = human_readable_digital_time(round(media_element.layout_display_time({})));
|
||||
auto duration = human_readable_digital_time(isnan(media_element.duration()) ? 0 : round(media_element.duration()));
|
||||
components.timestamp = String::formatted("{} / {}", display_time, duration).release_value_but_fixme_should_propagate_errors();
|
||||
components.timestamp_font = layout_node().scaled_font(context);
|
||||
components.timestamp_font = layout_node().font(context);
|
||||
|
||||
auto timestamp_size = DevicePixels { static_cast<DevicePixels::Type>(ceilf(components.timestamp_font->width(components.timestamp))) };
|
||||
if (timestamp_size <= remaining_rect.width()) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibUnicode/CharacterTypes.h>
|
||||
#include <LibWeb/CSS/SystemColor.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue