mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibGfx+LibWeb: Rename Gfx::WOFF::Font to Gfx::WOFF::Typeface
It's a leftover from VectorFont -> Typeface renaming
This commit is contained in:
parent
2f515827c0
commit
1d2e559e13
Notes:
sideshowbarker
2024-07-16 22:54:10 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/1d2e559e13 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/600
8 changed files with 21 additions and 21 deletions
|
@ -4,12 +4,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size)
|
||||
{
|
||||
AK::set_debug_enabled(false);
|
||||
(void)WOFF::Font::try_load_from_externally_owned_memory({ data, size });
|
||||
(void)WOFF::Typeface::try_load_from_externally_owned_memory({ data, size });
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#define TEST_INPUT(x) ("test-inputs/" x)
|
||||
|
@ -17,7 +17,7 @@ TEST_CASE(malformed_woff)
|
|||
|
||||
for (auto test_input : test_inputs) {
|
||||
auto file = MUST(Core::MappedFile::map(test_input));
|
||||
auto font_or_error = WOFF::Font::try_load_from_externally_owned_memory(file->bytes());
|
||||
auto font_or_error = WOFF::Typeface::try_load_from_externally_owned_memory(file->bytes());
|
||||
EXPECT(font_or_error.is_error());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ set(SOURCES
|
|||
Font/OpenType/Typeface.cpp
|
||||
Font/ScaledFont.cpp
|
||||
Font/Typeface.cpp
|
||||
Font/WOFF/Font.cpp
|
||||
Font/WOFF/Typeface.cpp
|
||||
Font/WOFF2/Font.cpp
|
||||
GradientPainting.cpp
|
||||
ICC/BinaryWriter.cpp
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibGfx/Font/OpenType/Typeface.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -52,7 +52,7 @@ void FontDatabase::load_all_fonts_from_uri(StringView uri)
|
|||
family.append(font);
|
||||
}
|
||||
} else if (path.has_extension(".woff"sv)) {
|
||||
if (auto font_or_error = WOFF::Font::try_load_from_resource(resource); !font_or_error.is_error()) {
|
||||
if (auto font_or_error = WOFF::Typeface::try_load_from_resource(resource); !font_or_error.is_error()) {
|
||||
auto font = font_or_error.release_value();
|
||||
auto& family = m_private->typeface_by_family.ensure(font->family(), [] {
|
||||
return Vector<NonnullRefPtr<Typeface>> {};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <LibCompress/Zlib.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibGfx/Font/OpenType/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
|
||||
namespace WOFF {
|
||||
|
||||
|
@ -69,12 +69,12 @@ 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_resource(Core::Resource const& resource, unsigned index)
|
||||
ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_resource(Core::Resource const& resource, unsigned 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)
|
||||
ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_externally_owned_memory(ReadonlyBytes buffer, unsigned int index)
|
||||
{
|
||||
FixedMemoryStream stream(buffer);
|
||||
auto header = TRY(stream.read_value<Header>());
|
||||
|
@ -159,7 +159,7 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(Readonl
|
|||
return Error::from_string_literal("Invalid WOFF total sfnt size");
|
||||
|
||||
auto input_font = TRY(OpenType::Typeface::try_load_from_externally_owned_memory(font_buffer.bytes(), { .index = index }));
|
||||
auto font = adopt_ref(*new Font(input_font, move(font_buffer)));
|
||||
auto font = adopt_ref(*new Typeface(input_font, move(font_buffer)));
|
||||
return font;
|
||||
}
|
||||
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
namespace WOFF {
|
||||
|
||||
class Font : public Gfx::Typeface {
|
||||
AK_MAKE_NONCOPYABLE(Font);
|
||||
class Typeface : public Gfx::Typeface {
|
||||
AK_MAKE_NONCOPYABLE(Typeface);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Font>> try_load_from_resource(Core::Resource const&, unsigned index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Font>> try_load_from_externally_owned_memory(ReadonlyBytes bytes, unsigned index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_resource(Core::Resource const&, unsigned index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_externally_owned_memory(ReadonlyBytes bytes, unsigned index = 0);
|
||||
|
||||
virtual Gfx::ScaledFontMetrics metrics(float x_scale, float y_scale) const override { return m_input_font->metrics(x_scale, y_scale); }
|
||||
virtual Gfx::ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const override { return m_input_font->glyph_metrics(glyph_id, x_scale, y_scale, point_width, point_height); }
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
virtual bool has_color_bitmaps() const override { return m_input_font->has_color_bitmaps(); }
|
||||
|
||||
private:
|
||||
Font(NonnullRefPtr<Gfx::Typeface const> input_font, ByteBuffer input_font_buffer)
|
||||
Typeface(NonnullRefPtr<Gfx::Typeface const> input_font, ByteBuffer input_font_buffer)
|
||||
: m_input_font_buffer(move(input_font_buffer))
|
||||
, m_input_font(move(input_font))
|
||||
{
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibCore/Promise.h>
|
||||
#include <LibGfx/Font/OpenType/Typeface.h>
|
||||
#include <LibGfx/Font/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF2/Font.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
|
@ -40,7 +40,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> load_vector_fo
|
|||
promise->resolve(ttf.release_value());
|
||||
return;
|
||||
}
|
||||
auto woff = WOFF::Font::try_load_from_externally_owned_memory(data);
|
||||
auto woff = WOFF::Typeface::try_load_from_externally_owned_memory(data);
|
||||
if (!woff.is_error()) {
|
||||
promise->resolve(woff.release_value());
|
||||
return;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <LibGfx/Font/OpenType/Typeface.h>
|
||||
#include <LibGfx/Font/ScaledFont.h>
|
||||
#include <LibGfx/Font/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibGfx/Font/WOFF/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF2/Font.h>
|
||||
#include <LibWeb/Animations/AnimationEffect.h>
|
||||
#include <LibWeb/Animations/DocumentTimeline.h>
|
||||
|
@ -172,7 +172,7 @@ ErrorOr<NonnullRefPtr<Gfx::Typeface>> FontLoader::try_load_font()
|
|||
}
|
||||
}
|
||||
if (mime_type == "font/woff"sv || mime_type == "application/font-woff"sv) {
|
||||
if (auto result = WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data()); !result.is_error()) {
|
||||
if (auto result = WOFF::Typeface::try_load_from_externally_owned_memory(resource()->encoded_data()); !result.is_error()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ ErrorOr<NonnullRefPtr<Gfx::Typeface>> FontLoader::try_load_font()
|
|||
auto ttf = OpenType::Typeface::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
if (!ttf.is_error())
|
||||
return ttf.release_value();
|
||||
auto woff = WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
auto woff = WOFF::Typeface::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
if (!woff.is_error())
|
||||
return woff.release_value();
|
||||
auto woff2 = WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
|
|
Loading…
Add table
Reference in a new issue