Use FT_New_Memory_Face for freetype fonts to fix loading non-ascii paths on Windows
This commit is contained in:
parent
d41c53193d
commit
2e28b3ffc6
1 changed files with 6 additions and 4 deletions
|
|
@ -71,6 +71,7 @@ namespace psemek::fonts
|
||||||
|
|
||||||
struct face_shared
|
struct face_shared
|
||||||
{
|
{
|
||||||
|
util::blob data;
|
||||||
wgpu::device device;
|
wgpu::device device;
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
|
|
||||||
|
|
@ -333,11 +334,12 @@ namespace psemek::fonts
|
||||||
|
|
||||||
std::unique_ptr<font_builder> load_freetype_font(wgpu::device device, std::filesystem::path const & path)
|
std::unique_ptr<font_builder> load_freetype_font(wgpu::device device, std::filesystem::path const & path)
|
||||||
{
|
{
|
||||||
FT_Face face;
|
auto font_data = io::read_full(io::file_istream{path});
|
||||||
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 result = std::make_unique<freetype_font_builder>(std::make_shared<face_shared>(device, face));
|
FT_Face face;
|
||||||
|
ft_check_result(FT_New_Memory_Face(ft_library(), reinterpret_cast<FT_Byte const *>(font_data.data()), font_data.size(), 0, &face), util::to_string("Failed to load font ", path, ": "));
|
||||||
|
|
||||||
|
auto result = std::make_unique<freetype_font_builder>(std::make_shared<face_shared>(std::move(font_data), device, face));
|
||||||
|
|
||||||
log::debug() << "Loaded font " << result->name() << " (" << path << ")";
|
log::debug() << "Loaded font " << result->name() << " (" << path << ")";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue