mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
LibGfx+Utilities: Add helpers to load vector fonts from Core::Resources
This commit is contained in:
parent
286dc6df7f
commit
86ce502ae2
8 changed files with 19 additions and 21 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/IntegralMath.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <LibCompress/Zlib.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibGfx/Font/OpenType/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
|
||||
|
@ -68,10 +69,9 @@ static u16 pow_2_less_than_or_equal(u16 x)
|
|||
return 1 << (sizeof(u16) * 8 - count_leading_zeroes_safe<u16>(x - 1));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_file(DeprecatedString path, unsigned int index)
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_resource(Core::Resource const& resource, unsigned index)
|
||||
{
|
||||
auto file = TRY(Core::MappedFile::map(path));
|
||||
return try_load_from_externally_owned_memory(file->bytes(), index);
|
||||
return try_load_from_externally_owned_memory(resource.data(), index);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(ReadonlyBytes buffer, unsigned int index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue