LibGfx: Use Core::Stream
to write bitmap fonts
This commit is contained in:
parent
9eb040af32
commit
3a16168ace
Notes:
sideshowbarker
2024-07-17 01:27:45 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/3a16168ace Pull-request: https://github.com/SerenityOS/serenity/pull/17098
1 changed files with 6 additions and 9 deletions
|
@ -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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue