소스 검색

LibGfx: Use `Core::Stream` to write bitmap fonts

Tim Schumacher 2 년 전
부모
커밋
3a16168ace
1개의 변경된 파일6개의 추가작업 그리고 9개의 파일을 삭제
  1. 6 9
      Userland/Libraries/LibGfx/Font/BitmapFont.cpp

+ 6 - 9
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 {};
 }