mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibWeb: Remove unused CRC2D::bitmap_font_fill_text()
This commit is contained in:
parent
e81bd34561
commit
4822d1da4e
Notes:
sideshowbarker
2024-07-17 05:18:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/4822d1da4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/42
@ -199,49 +199,6 @@ Optional<Gfx::AntiAliasingPainter> CanvasRenderingContext2D::antialiased_painter
|
||||
return {};
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::bitmap_font_fill_text(StringView text, float x, float y, Optional<double> max_width)
|
||||
{
|
||||
if (max_width.has_value() && max_width.value() <= 0)
|
||||
return;
|
||||
|
||||
draw_clipped([&](auto& painter) {
|
||||
auto& drawing_state = this->drawing_state();
|
||||
auto& base_painter = painter.underlying_painter();
|
||||
|
||||
// Create text rect from font
|
||||
auto font = current_font();
|
||||
auto text_rect = Gfx::FloatRect(x, y, max_width.has_value() ? static_cast<float>(max_width.value()) : font->width(text), font->pixel_size());
|
||||
|
||||
// Apply text align to text_rect
|
||||
// FIXME: CanvasTextAlign::Start and CanvasTextAlign::End currently do not nothing for right-to-left languages:
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textalign-start
|
||||
// Default alignment of draw_text is left so do nothing by CanvasTextAlign::Start and CanvasTextAlign::Left
|
||||
if (drawing_state.text_align == Bindings::CanvasTextAlign::Center) {
|
||||
text_rect.translate_by(-text_rect.width() / 2, 0);
|
||||
}
|
||||
if (drawing_state.text_align == Bindings::CanvasTextAlign::End || drawing_state.text_align == Bindings::CanvasTextAlign::Right) {
|
||||
text_rect.translate_by(-text_rect.width(), 0);
|
||||
}
|
||||
|
||||
// Apply text baseline to text_rect
|
||||
// FIXME: Implement CanvasTextBasline::Hanging, Bindings::CanvasTextAlign::Alphabetic and Bindings::CanvasTextAlign::Ideographic for real
|
||||
// right now they are just handled as textBaseline = top or bottom.
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textbaseline-hanging
|
||||
// Default baseline of draw_text is top so do nothing by CanvasTextBaseline::Top and CanvasTextBasline::Hanging
|
||||
if (drawing_state.text_baseline == Bindings::CanvasTextBaseline::Middle) {
|
||||
text_rect.translate_by(0, -font->pixel_size() / 2);
|
||||
}
|
||||
if (drawing_state.text_baseline == Bindings::CanvasTextBaseline::Alphabetic || drawing_state.text_baseline == Bindings::CanvasTextBaseline::Ideographic || drawing_state.text_baseline == Bindings::CanvasTextBaseline::Bottom) {
|
||||
text_rect.translate_by(0, -font->pixel_size());
|
||||
}
|
||||
|
||||
auto transformed_rect = drawing_state.transform.map(text_rect);
|
||||
auto color = drawing_state.fill_style.to_color_but_fixme_should_accept_any_paint_style();
|
||||
base_painter.draw_text(transformed_rect, text, *font, Gfx::TextAlignment::TopLeft, color.with_opacity(drawing_state.global_alpha));
|
||||
return transformed_rect;
|
||||
});
|
||||
}
|
||||
|
||||
Gfx::Path CanvasRenderingContext2D::text_path(StringView text, float x, float y, Optional<double> max_width)
|
||||
{
|
||||
if (max_width.has_value() && max_width.value() <= 0)
|
||||
|
@ -142,7 +142,6 @@ private:
|
||||
Gfx::Path rect_path(float x, float y, float width, float height);
|
||||
|
||||
Gfx::Path text_path(StringView text, float x, float y, Optional<double> max_width);
|
||||
void bitmap_font_fill_text(StringView text, float x, float y, Optional<double> max_width);
|
||||
|
||||
void stroke_internal(Gfx::Path const&);
|
||||
void fill_internal(Gfx::Path const&, Gfx::Painter::WindingRule);
|
||||
|
Loading…
Reference in New Issue
Block a user