Skip to content

Commit

Permalink
LibGfx+LibWeb: Rename Gfx::WOFF::Font to Gfx::WOFF::Typeface
Browse files Browse the repository at this point in the history
It's a leftover from VectorFont -> Typeface renaming
  • Loading branch information
kalenikaliaksandr committed Jul 12, 2024
1 parent 2cdb41d commit fd2ce70
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Meta/Lagom/Fuzzers/FuzzWOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 2 deletions Tests/LibGfx/TestWOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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());
}
}
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Font/FontDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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>> {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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>());
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -43,7 +43,7 @@ class Font : public Gfx::Typeface {
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))
{
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/CSS/FontFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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());
Expand Down

0 comments on commit fd2ce70

Please sign in to comment.