LibWeb: Implement dominant-baseline for SVG text

This property determines the default baseline used to align content
within the given box.
This commit is contained in:
Tim Ledbetter
2026-02-25 20:46:37 +00:00
committed by Jelle Raaijmakers
parent 90a211bf47
commit f05bc7c0cd
Notes: github-actions[bot] 2026-02-26 08:24:27 +00:00
25 changed files with 311 additions and 10 deletions

View File

@@ -15,6 +15,7 @@
#include <LibGfx/TextLayout.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/DominantBaseline.h>
#include <LibWeb/Layout/SVGClipBox.h>
#include <LibWeb/Layout/SVGFormattingContext.h>
#include <LibWeb/Layout/SVGGeometryBox.h>
@@ -381,6 +382,9 @@ Gfx::Path SVGFormattingContext::compute_path_for_text(SVGTextBox const& text_box
VERIFY_NOT_REACHED();
}
auto baseline_metric = resolve_dominant_baseline_metric(text_box.computed_values());
text_offset.translate_by(0, dominant_baseline_offset(baseline_metric, font.pixel_metrics()));
Gfx::Path path;
path.move_to(text_offset);
path.text(text_contents, font);