1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:47:45 +00:00

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.
This commit is contained in:
Rodrigo Tobar 2023-02-12 14:51:26 +08:00 committed by Andreas Kling
parent 79b4293687
commit bf61f94413

View file

@ -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;