From c625ba34fec94d92d8acbd2d9185817fce578466 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 12 Jul 2023 14:25:22 -0400 Subject: [PATCH] LibPDF: Implement set_flatness_tolerance We now track it in the graphics state. It isn't used for anything yet. Fixes the one thing that rendering the first 100 pages of pdf_reference_1-7.pdf complains about. --- Userland/Libraries/LibPDF/Renderer.cpp | 7 ++++++- Userland/Libraries/LibPDF/Renderer.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index 26c24837ca..ad3a685cff 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -181,7 +181,12 @@ RENDERER_HANDLER(set_dash_pattern) } RENDERER_TODO(set_color_rendering_intent) -RENDERER_TODO(set_flatness_tolerance) + +RENDERER_HANDLER(set_flatness_tolerance) +{ + state().flatness_tolerance = args[0].to_float(); + return {}; +} RENDERER_HANDLER(set_graphics_state_from_dict) { diff --git a/Userland/Libraries/LibPDF/Renderer.h b/Userland/Libraries/LibPDF/Renderer.h index fb92551ead..1dad8187c7 100644 --- a/Userland/Libraries/LibPDF/Renderer.h +++ b/Userland/Libraries/LibPDF/Renderer.h @@ -76,6 +76,7 @@ struct GraphicsState { RefPtr paint_color_space { DeviceGrayColorSpace::the() }; Gfx::Color stroke_color { Gfx::Color::NamedColor::Black }; Gfx::Color paint_color { Gfx::Color::NamedColor::Black }; + float flatness_tolerance { 0.0f }; float line_width { 1.0f }; LineCapStyle line_cap_style { LineCapStyle::ButtCap }; LineJoinStyle line_join_style { LineJoinStyle::Miter }; @@ -261,6 +262,7 @@ struct Formatter : Formatter { builder.appendff(" ctm={}\n", state.ctm); builder.appendff(" stroke_color={}\n", state.stroke_color); builder.appendff(" paint_color={}\n", state.paint_color); + builder.appendff(" flatness_tolerance={}\n", state.flatness_tolerance); builder.appendff(" line_width={}\n", state.line_width); builder.appendff(" line_cap_style={}\n", state.line_cap_style); builder.appendff(" line_join_style={}\n", state.line_join_style);