LibGfx+LibWeb: Rename Gfx::WOFF2::Font to Gfx::WOFF2::Typeface

It's a leftover from VectorFont -> Typeface renaming
This commit is contained in:
Aliaksandr Kalenik 2024-07-12 16:52:04 +03:00 committed by Andreas Kling
parent 1d2e559e13
commit c09b5b8df0
Notes: sideshowbarker 2024-07-16 22:11:09 +09:00
7 changed files with 18 additions and 18 deletions

View file

@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibGfx/Font/WOFF2/Typeface.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size)
{
AK::set_debug_enabled(false);
(void)WOFF2::Font::try_load_from_externally_owned_memory({ data, size });
(void)WOFF2::Typeface::try_load_from_externally_owned_memory({ data, size });
return 0;
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibGfx/Font/WOFF2/Typeface.h>
#include <LibTest/TestCase.h>
#define TEST_INPUT(x) ("test-inputs/" x)
@ -12,7 +12,7 @@
TEST_CASE(tolerate_incorrect_sfnt_size)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("woff2/incorrect_sfnt_size.woff2"sv)));
auto font = TRY_OR_FAIL(WOFF2::Font::try_load_from_externally_owned_memory(file->bytes()));
auto font = TRY_OR_FAIL(WOFF2::Typeface::try_load_from_externally_owned_memory(file->bytes()));
EXPECT_EQ(font->family(), "Test"_string);
EXPECT_EQ(font->glyph_count(), 4u);
}
@ -26,7 +26,7 @@ TEST_CASE(malformed_woff2)
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
auto font_or_error = WOFF2::Font::try_load_from_externally_owned_memory(file->bytes());
auto font_or_error = WOFF2::Typeface::try_load_from_externally_owned_memory(file->bytes());
EXPECT(font_or_error.is_error());
}
}

View file

@ -22,7 +22,7 @@ set(SOURCES
Font/ScaledFont.cpp
Font/Typeface.cpp
Font/WOFF/Typeface.cpp
Font/WOFF2/Font.cpp
Font/WOFF2/Typeface.cpp
GradientPainting.cpp
ICC/BinaryWriter.cpp
ICC/Enums.cpp

View file

@ -6,7 +6,7 @@
#define AK_DONT_REPLACE_STD
#include <LibGfx/Font/OpenType/Typeface.h>
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibGfx/Font/WOFF2/Typeface.h>
#include <woff2/decode.h>
namespace WOFF2 {
@ -54,7 +54,7 @@ private:
ByteBuffer& m_buffer;
};
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(ReadonlyBytes bytes)
ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_externally_owned_memory(ReadonlyBytes bytes)
{
auto ttf_buffer = TRY(ByteBuffer::create_uninitialized(0));
auto output = WOFF2ByteBufferOut { ttf_buffer };
@ -63,7 +63,7 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(Readonl
return Error::from_string_literal("Failed to convert the WOFF2 font to TTF");
}
auto input_font = TRY(OpenType::Typeface::try_load_from_externally_owned_memory(ttf_buffer.bytes()));
return adopt_ref(*new Font(input_font, move(ttf_buffer)));
return adopt_ref(*new Typeface(input_font, move(ttf_buffer)));
}
}

View file

@ -17,11 +17,11 @@
namespace WOFF2 {
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_externally_owned_memory(ReadonlyBytes);
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_externally_owned_memory(ReadonlyBytes);
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); }
@ -44,7 +44,7 @@ public:
virtual bool has_color_bitmaps() const override { return m_input_font->has_color_bitmaps(); }
private:
Font(NonnullRefPtr<Gfx::Typeface> input_font, ByteBuffer input_font_buffer)
Typeface(NonnullRefPtr<Gfx::Typeface> input_font, ByteBuffer input_font_buffer)
: m_input_font_buffer(move(input_font_buffer))
, m_input_font(move(input_font))
{

View file

@ -8,7 +8,7 @@
#include <LibGfx/Font/OpenType/Typeface.h>
#include <LibGfx/Font/Typeface.h>
#include <LibGfx/Font/WOFF/Typeface.h>
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibGfx/Font/WOFF2/Typeface.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/ArrayBuffer.h>
#include <LibJS/Runtime/Realm.h>
@ -45,7 +45,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> load_vector_fo
promise->resolve(woff.release_value());
return;
}
auto woff2 = WOFF2::Font::try_load_from_externally_owned_memory(data);
auto woff2 = WOFF2::Typeface::try_load_from_externally_owned_memory(data);
if (!woff2.is_error()) {
promise->resolve(woff2.release_value());
return;

View file

@ -23,7 +23,7 @@
#include <LibGfx/Font/ScaledFont.h>
#include <LibGfx/Font/Typeface.h>
#include <LibGfx/Font/WOFF/Typeface.h>
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibGfx/Font/WOFF2/Typeface.h>
#include <LibWeb/Animations/AnimationEffect.h>
#include <LibWeb/Animations/DocumentTimeline.h>
#include <LibWeb/CSS/AnimationEvent.h>
@ -177,7 +177,7 @@ ErrorOr<NonnullRefPtr<Gfx::Typeface>> FontLoader::try_load_font()
}
}
if (mime_type == "font/woff2"sv || mime_type == "application/font-woff2"sv) {
if (auto result = WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data()); !result.is_error()) {
if (auto result = WOFF2::Typeface::try_load_from_externally_owned_memory(resource()->encoded_data()); !result.is_error()) {
return result;
}
}
@ -189,7 +189,7 @@ ErrorOr<NonnullRefPtr<Gfx::Typeface>> FontLoader::try_load_font()
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());
auto woff2 = WOFF2::Typeface::try_load_from_externally_owned_memory(resource()->encoded_data());
if (!woff2.is_error())
return woff2.release_value();
return Error::from_string_literal("Automatic format detection failed");