mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
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.
This commit is contained in:
parent
14c0bae704
commit
db9fa7ff07
2 changed files with 5 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -114,7 +114,7 @@ private:
|
|||
void begin_path_paint();
|
||||
void end_path_paint();
|
||||
PDFErrorOr<void> set_graphics_state_from_dict(NonnullRefPtr<DictObject>);
|
||||
void show_text(DeprecatedString const&);
|
||||
PDFErrorOr<void> show_text(DeprecatedString const&);
|
||||
PDFErrorOr<NonnullRefPtr<Gfx::Bitmap>> load_image(NonnullRefPtr<StreamObject>);
|
||||
PDFErrorOr<void> show_image(NonnullRefPtr<StreamObject>);
|
||||
void show_empty_image(int width, int height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue