mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibGfx: Load BitmapFont data more safely
Previously, `load_from_memory()` just took a raw pointer to the data, and then manually calculated offsets from that pointer. Instead, let's use the MappedFile we already have, to stream in the data, to make things a bit safer. We also now check that the entire file's data was read, since if there was data left over, then either the file is bad or we've done something wrong. I've moved the code directly into `try_load_from_mapped_file()` since `load_from_memory()` was only called from there. The extra indirection wasn't adding anything.
This commit is contained in:
parent
253a96277e
commit
80e756daef
2 changed files with 34 additions and 18 deletions
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
static RefPtr<BitmapFont> load_from_file(DeprecatedString const& path);
|
||||
static ErrorOr<NonnullRefPtr<BitmapFont>> try_load_from_file(DeprecatedString const& path);
|
||||
static ErrorOr<NonnullRefPtr<BitmapFont>> try_load_from_mapped_file(OwnPtr<Core::MappedFile>);
|
||||
static ErrorOr<NonnullRefPtr<BitmapFont>> try_load_from_mapped_file(NonnullOwnPtr<Core::MappedFile>);
|
||||
|
||||
ErrorOr<void> write_to_file(DeprecatedString const& path);
|
||||
ErrorOr<void> write_to_file(NonnullOwnPtr<Core::File> file);
|
||||
|
@ -134,8 +134,6 @@ private:
|
|||
u8 glyph_width, u8 glyph_height, u8 glyph_spacing, Bytes range_mask,
|
||||
u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, u8 slope, bool owns_arrays = false);
|
||||
|
||||
static ErrorOr<NonnullRefPtr<BitmapFont>> load_from_memory(u8 const*);
|
||||
|
||||
template<typename T>
|
||||
int unicode_view_width(T const& view) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue