mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:25:08 +00:00
LibWeb: Get default fonts via Platform::FontPlugin
Instead of asking Gfx::FontDatabase for the "default font" and the "default fixed-width font", we now proxy those requests out via the Platform::FontPlugin. This will allow Ladybird to use other default fonts as fallback.
This commit is contained in:
parent
07a0d9df30
commit
e72896e35e
10 changed files with 33 additions and 14 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <LibWeb/HTML/TextMetrics.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Platform/FontPlugin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -406,7 +407,7 @@ JS::NonnullGCPtr<TextMetrics> CanvasRenderingContext2D::measure_text(String cons
|
|||
auto prepared_text = prepare_text(text);
|
||||
auto metrics = TextMetrics::create(global_object());
|
||||
// FIXME: Use the font that was used to create the glyphs in prepared_text.
|
||||
auto& font = Gfx::FontDatabase::default_font();
|
||||
auto& font = Platform::FontPlugin::the().default_font();
|
||||
|
||||
// width attribute: The width of that inline box, in CSS pixels. (The text's advance width.)
|
||||
metrics->set_width(prepared_text.bounding_box.width());
|
||||
|
@ -477,7 +478,7 @@ CanvasRenderingContext2D::PreparedText CanvasRenderingContext2D::prepare_text(St
|
|||
// ...and with all other properties set to their initial values.
|
||||
// FIXME: Actually use a LineBox here instead of, you know, using the default font and measuring its size (which is not the spec at all).
|
||||
// FIXME: Once we have CanvasTextDrawingStyles, add the CSS attributes.
|
||||
auto& font = Gfx::FontDatabase::default_font();
|
||||
auto& font = Platform::FontPlugin::the().default_font();
|
||||
size_t width = 0;
|
||||
size_t height = font.pixel_size();
|
||||
for (auto c : Utf8View { replaced_text }) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue