@@ -451,20 +451,11 @@ void Renderer::stroke_current_path()
451451 }
452452}
453453
454- static void do_fill_path (Gfx::AntiAliasingPainter& painter, Gfx::Path const & path, ColorOrStyle const & style, float paint_style_opacity = 1 .0f , Gfx::WindingRule winding_rule = Gfx::WindingRule::Nonzero)
455- {
456- if (auto * paint_style = style.get_pointer <NonnullRefPtr<Gfx::PaintStyle>>()) {
457- painter.fill_path (path, *paint_style, paint_style_opacity, winding_rule);
458- } else {
459- painter.fill_path (path, style.get <Color>(), winding_rule);
460- }
461- }
462-
463454void Renderer::fill_current_path (Gfx::WindingRule winding_rule)
464455{
465456 auto path_end = m_current_path.end ();
466457 m_current_path.close_all_subpaths ();
467- do_fill_path (anti_aliasing_painter (), m_current_path, state ().paint_style , state ().paint_alpha_constant , winding_rule);
458+ fill_path_with_style (anti_aliasing_painter (), m_current_path, state ().paint_style , state ().paint_alpha_constant , winding_rule);
468459 // .close_all_subpaths() only adds to the end of the path, so we can .trim() the path to remove any changes.
469460 m_current_path.trim (path_end);
470461}
@@ -1380,28 +1371,7 @@ PDFErrorOr<void> Renderer::show_text(ByteString const& string)
13801371 return Error::rendering_unsupported_error (" Can't draw text because an invalid font was in use" );
13811372
13821373 auto start_position = Gfx::FloatPoint { 0 .0f , 0 .0f };
1383- auto end_position = start_position;
1384-
1385- if (m_text_rendering_matrix.is_identity_or_translation_or_scale (Gfx::AffineTransform::AllowNegativeScaling::No)) {
1386- // Fast path: Use cached bitmap glyphs.
1387- end_position = TRY (text_state ().font ->draw_string (painter (), start_position, string, *this ));
1388- } else {
1389- Gfx::Path text_path;
1390- // Slow path: Create a Gfx::Path for the string, transform it, then draw it. This handles arbitrary transforms.
1391- if (auto maybe_end = text_state ().font ->append_text_path (text_path, start_position, string, *this ); !maybe_end.is_error ()) {
1392- end_position = maybe_end.release_value ();
1393- // FIXME: This is a bit janky, but the font is already scaled by `m_text_rendering_matrix.x_scale() / horizontal_scaling`,
1394- // which is included in `m_text_rendering_matrix`. So, we must scale it by the reciprocal. Also, the y-axis is flipped.
1395- text_path.transform (m_text_rendering_matrix.multiply (
1396- Gfx::AffineTransform {}
1397- .set_scale (1 / m_text_rendering_matrix.x_scale () * text_state ().horizontal_scaling ,
1398- -1 / m_text_rendering_matrix.x_scale () * text_state ().horizontal_scaling )));
1399- do_fill_path (anti_aliasing_painter (), text_path, state ().paint_style , state ().paint_alpha_constant );
1400- } else {
1401- // Fallback to the fast path in case `append_path` is unimplemented.
1402- end_position = TRY (text_state ().font ->draw_string (painter (), start_position, string, *this ));
1403- }
1404- }
1374+ auto end_position = TRY (text_state ().font ->draw_string (painter (), start_position, string, *this ));
14051375
14061376 // Update text matrix.
14071377 auto delta = end_position - start_position;
0 commit comments