summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibPDF
diff options
context:
space:
mode:
authorRodrigo Tobar <rtobarc@gmail.com>2023-02-12 14:51:26 +0800
committerAndreas Kling <kling@serenityos.org>2023-03-02 12:18:53 +0100
commitbf61f944132781c6d779104573b63379324681d5 (patch)
treeb1728e0d470f792e0be7c5e7cad990ad172314c2 /Userland/Libraries/LibPDF
parent79b4293687bd6c3841989ab1d080d0d403d69518 (diff)
downloadserenity-bf61f944132781c6d779104573b63379324681d5.zip
LibPDF: Don't crash when a font hasn't been loaded yet
This could happen because there was a problem while loading the first font in the document.
Diffstat (limited to 'Userland/Libraries/LibPDF')
-rw-r--r--Userland/Libraries/LibPDF/Renderer.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp
index e1723756e8..bf5505dfb9 100644
--- a/Userland/Libraries/LibPDF/Renderer.cpp
+++ b/Userland/Libraries/LibPDF/Renderer.cpp
@@ -726,6 +726,9 @@ PDFErrorOr<void> Renderer::set_graphics_state_from_dict(NonnullRefPtr<DictObject
PDFErrorOr<void> Renderer::show_text(DeprecatedString const& string)
{
+ if (!text_state().font)
+ return Error::rendering_unsupported_error("Can't draw text because an invalid font was in use");
+
auto& text_rendering_matrix = calculate_text_rendering_matrix();
auto font_size = text_rendering_matrix.x_scale() * text_state().font_size;