diff --git a/libs/fonts/source/freetype.cpp b/libs/fonts/source/freetype.cpp index 615c3cde..f27dead1 100644 --- a/libs/fonts/source/freetype.cpp +++ b/libs/fonts/source/freetype.cpp @@ -71,6 +71,7 @@ namespace psemek::fonts struct face_shared { + util::blob data; wgpu::device device; FT_Face face; @@ -333,11 +334,12 @@ namespace psemek::fonts std::unique_ptr load_freetype_font(wgpu::device device, std::filesystem::path const & path) { - FT_Face face; - auto path_str = path.string(); - ft_check_result(FT_New_Face(ft_library(), path_str.data(), 0, &face), "Failed to load font " + path_str + ": "); + auto font_data = io::read_full(io::file_istream{path}); - auto result = std::make_unique(std::make_shared(device, face)); + FT_Face face; + ft_check_result(FT_New_Memory_Face(ft_library(), reinterpret_cast(font_data.data()), font_data.size(), 0, &face), util::to_string("Failed to load font ", path, ": ")); + + auto result = std::make_unique(std::make_shared(std::move(font_data), device, face)); log::debug() << "Loaded font " << result->name() << " (" << path << ")";