diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-01-20 00:16:08 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-20 20:50:42 +0000 |
commit | 3a16168aceb16dbdc7d2af2f0659e0e834716cf4 (patch) | |
tree | eddfd599eaa764b99abdb5d5d419116947af006a | |
parent | 9eb040af32a660283ef35267db9dff0a64589070 (diff) | |
download | serenity-3a16168aceb16dbdc7d2af2f0659e0e834716cf4.zip |
LibGfx: Use `Core::Stream` to write bitmap fonts
-rw-r--r-- | Userland/Libraries/LibGfx/Font/BitmapFont.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp index df3e04c023..99bfa179dd 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp @@ -9,7 +9,7 @@ #include <AK/BuiltinWrappers.h> #include <AK/Utf32View.h> #include <AK/Utf8View.h> -#include <LibCore/FileStream.h> +#include <LibCore/Stream.h> #include <LibGfx/Font/FontDatabase.h> #include <LibGfx/Font/FontStyleMapping.h> #include <LibGfx/Painter.h> @@ -257,15 +257,12 @@ ErrorOr<void> BitmapFont::write_to_file(DeprecatedString const& path) memcpy(header.name, m_name.characters(), min(m_name.length(), sizeof(header.name) - 1)); memcpy(header.family, m_family.characters(), min(m_family.length(), sizeof(header.family) - 1)); - auto stream = TRY(Core::OutputFileStream::open_buffered(path)); + auto stream = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write)); size_t bytes_per_glyph = sizeof(u32) * m_glyph_height; - stream << ReadonlyBytes { &header, sizeof(header) }; - stream << ReadonlyBytes { m_range_mask, m_range_mask_size }; - stream << ReadonlyBytes { m_rows, m_glyph_count * bytes_per_glyph }; - stream << ReadonlyBytes { m_glyph_widths, m_glyph_count }; - - stream.flush(); - TRY(stream.try_handle_any_error()); + TRY(stream->write_entire_buffer({ &header, sizeof(header) })); + TRY(stream->write_entire_buffer({ m_range_mask, m_range_mask_size })); + TRY(stream->write_entire_buffer({ m_rows, m_glyph_count * bytes_per_glyph })); + TRY(stream->write_entire_buffer({ m_glyph_widths, m_glyph_count })); return {}; } |