summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibPDF/Renderer.cpp
diff options
context:
space:
mode:
authorRodrigo Tobar <rtobarc@gmail.com>2023-01-29 10:57:21 +0800
committerLinus Groh <mail@linusgroh.de>2023-02-24 20:16:50 +0100
commitdb9fa7ff0734426250e3ca7adffbe7da64bbe63e (patch)
treea5ca79183d1c3dbca1ab21f1317762ccb4ba1fc5 /Userland/Libraries/LibPDF/Renderer.cpp
parent14c0bae70443bd3d457f9806321c323e2897cd76 (diff)
downloadserenity-db9fa7ff0734426250e3ca7adffbe7da64bbe63e.zip
LibPDF: Allow show_text to return errors
Errors can (and do) occur when trying to render text, and so far we've silently ignored them, making us think that all is well when it isn't. Letting show_text return errors will allow us to inform the user about these errors instead of having to hiding them.
Diffstat (limited to 'Userland/Libraries/LibPDF/Renderer.cpp')
-rw-r--r--Userland/Libraries/LibPDF/Renderer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp
index 3c31ed6b03..91b93ed0de 100644
--- a/Userland/Libraries/LibPDF/Renderer.cpp
+++ b/Userland/Libraries/LibPDF/Renderer.cpp
@@ -483,7 +483,7 @@ RENDERER_HANDLER(text_next_line)
RENDERER_HANDLER(text_show_string)
{
auto text = MUST(m_document->resolve_to<StringObject>(args[0]))->string();
- show_text(text);
+ TRY(show_text(text));
return {};
}
@@ -510,7 +510,7 @@ RENDERER_HANDLER(text_show_string_array)
auto shift = next_shift / 1000.0f;
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
- show_text(str);
+ TRY(show_text(str));
}
}
@@ -724,7 +724,7 @@ PDFErrorOr<void> Renderer::set_graphics_state_from_dict(NonnullRefPtr<DictObject
return {};
}
-void Renderer::show_text(DeprecatedString const& string)
+PDFErrorOr<void> Renderer::show_text(DeprecatedString const& string)
{
auto& text_rendering_matrix = calculate_text_rendering_matrix();
@@ -748,6 +748,7 @@ void Renderer::show_text(DeprecatedString const& string)
auto delta_x = glyph_position.x() - original_position.x();
m_text_rendering_matrix_is_dirty = true;
m_text_matrix.translate(delta_x / text_rendering_matrix.x_scale(), 0.0f);
+ return {};
}
PDFErrorOr<NonnullRefPtr<Gfx::Bitmap>> Renderer::load_image(NonnullRefPtr<StreamObject> image)