diff --git a/Meta/Lagom/Fuzzers/FuzzTTF.cpp b/Meta/Lagom/Fuzzers/FuzzTTF.cpp index f231f43770..b0cd938098 100644 --- a/Meta/Lagom/Fuzzers/FuzzTTF.cpp +++ b/Meta/Lagom/Fuzzers/FuzzTTF.cpp @@ -4,12 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size) { - (void)TTF::Font::try_load_from_externally_owned_memory({ data, size }); + (void)OpenType::Font::try_load_from_externally_owned_memory({ data, size }); return 0; } diff --git a/Tests/LibTTF/TestCmap.cpp b/Tests/LibTTF/TestCmap.cpp index adeb37c66d..f86a722bf7 100644 --- a/Tests/LibTTF/TestCmap.cpp +++ b/Tests/LibTTF/TestCmap.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include TEST_CASE(test_cmap_format_4) @@ -54,7 +54,7 @@ TEST_CASE(test_cmap_format_4) 0, 0, }; // clang-format on - auto cmap = TTF::Cmap::from_slice({ cmap_table, sizeof cmap_table }).value(); + auto cmap = OpenType::Cmap::from_slice({ cmap_table, sizeof cmap_table }).value(); cmap.set_active_index(0); // Format 4 can't handle code points > 0xffff. @@ -74,7 +74,7 @@ TEST_CASE(test_cmap_format_4) // From https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#format-4-segment-mapping-to-delta-values: // "the final start code and endCode values must be 0xFFFF. This segment need not contain any valid mappings. // (It can just map the single character code 0xFFFF to missingGlyph). However, the segment must be present." - // FIXME: Make TTF::Cmap::from_slice() reject inputs where this isn't true. + // FIXME: Make OpenType::Cmap::from_slice() reject inputs where this isn't true. EXPECT_EQ(cmap.glyph_id_for_code_point(0xfeff), 0u); EXPECT_EQ(cmap.glyph_id_for_code_point(0xffff), 0xffffu); EXPECT_EQ(cmap.glyph_id_for_code_point(0x1'0000), 0u); diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 0738d9e3e7..b84c6b36ca 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -17,11 +17,11 @@ set(SOURCES Font/BitmapFont.cpp Font/Emoji.cpp Font/FontDatabase.cpp + Font/OpenType/Cmap.cpp + Font/OpenType/Font.cpp + Font/OpenType/Glyf.cpp Font/PathRasterizer.cpp Font/ScaledFont.cpp - Font/TrueType/Cmap.cpp - Font/TrueType/Font.cpp - Font/TrueType/Glyf.cpp Font/Typeface.cpp Font/WOFF/Font.cpp GIFLoader.cpp diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index b8480b3434..b99d7e953a 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -151,7 +151,7 @@ void FontDatabase::load_all_fonts_from_path(DeprecatedString const& root) } } else if (path.ends_with(".ttf"sv)) { // FIXME: What about .otf - if (auto font_or_error = TTF::Font::try_load_from_file(path); !font_or_error.is_error()) { + if (auto font_or_error = OpenType::Font::try_load_from_file(path); !font_or_error.is_error()) { auto font = font_or_error.release_value(); auto typeface = get_or_create_typeface(font->family(), font->variant()); typeface->set_vector_font(move(font)); diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Cmap.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Cmap.cpp similarity index 98% rename from Userland/Libraries/LibGfx/Font/TrueType/Cmap.cpp rename to Userland/Libraries/LibGfx/Font/OpenType/Cmap.cpp index f37eea9691..bf134a2eb6 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Cmap.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Cmap.cpp @@ -5,9 +5,9 @@ */ #include -#include +#include -namespace TTF { +namespace OpenType { extern u16 be_u16(u8 const*); extern u32 be_u32(u8 const*); diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Cmap.h b/Userland/Libraries/LibGfx/Font/OpenType/Cmap.h similarity index 99% rename from Userland/Libraries/LibGfx/Font/TrueType/Cmap.h rename to Userland/Libraries/LibGfx/Font/OpenType/Cmap.h index 64eea73662..fd3203e5ab 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Cmap.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Cmap.h @@ -9,7 +9,7 @@ #include #include -namespace TTF { +namespace OpenType { class Cmap { public: diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Font.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp similarity index 97% rename from Userland/Libraries/LibGfx/Font/TrueType/Font.cpp rename to Userland/Libraries/LibGfx/Font/OpenType/Font.cpp index 25b967b29e..1f1de38e64 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Font.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp @@ -9,15 +9,15 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include -namespace TTF { +namespace OpenType { u16 be_u16(u8 const*); u32 be_u32(u8 const*); @@ -206,12 +206,12 @@ i16 Kern::get_glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const auto coverage = be_u16(subtable_slice.offset(2 * sizeof(u16))); if (version != 0) { - dbgln("TTF::Kern: unsupported subtable version {}", version); + dbgln("OpenType::Kern: unsupported subtable version {}", version); continue; } if (subtable_slice.size() < length) { - dbgln("TTF::Kern: subtable has an invalid size {}", length); + dbgln("OpenType::Kern: subtable has an invalid size {}", length); continue; } @@ -224,7 +224,7 @@ i16 Kern::get_glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const // FIXME: implement support for these features if (!is_horizontal || is_minimum || is_cross_stream || (reserved_bits > 0)) { - dbgln("TTF::Kern: FIXME: implement missing feature support for subtable"); + dbgln("OpenType::Kern: FIXME: implement missing feature support for subtable"); continue; } @@ -235,7 +235,7 @@ i16 Kern::get_glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const subtable_kerning = read_glyph_kerning_format0(subtable_slice.slice(Sizes::SubtableHeader), left_glyph_id, right_glyph_id); break; default: - dbgln("TTF::Kern: FIXME: subtable format {} is unsupported", format); + dbgln("OpenType::Kern: FIXME: subtable format {} is unsupported", format); continue; } if (!subtable_kerning.has_value()) diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Font.h b/Userland/Libraries/LibGfx/Font/OpenType/Font.h similarity index 94% rename from Userland/Libraries/LibGfx/Font/TrueType/Font.h rename to Userland/Libraries/LibGfx/Font/OpenType/Font.h index 42ab9a5c4a..67861c9417 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Font.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Font.h @@ -11,12 +11,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -namespace TTF { +namespace OpenType { class Font : public Gfx::VectorFont { AK_MAKE_NONCOPYABLE(Font); diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Glyf.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp similarity index 99% rename from Userland/Libraries/LibGfx/Font/TrueType/Glyf.cpp rename to Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp index a2aae72b4d..85aba856f1 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Glyf.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.cpp @@ -4,11 +4,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include -namespace TTF { +namespace OpenType { extern u16 be_u16(u8 const* ptr); extern u32 be_u32(u8 const* ptr); diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Glyf.h b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h similarity index 98% rename from Userland/Libraries/LibGfx/Font/TrueType/Glyf.h rename to Userland/Libraries/LibGfx/Font/OpenType/Glyf.h index 228e9f73f2..00385a894d 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Glyf.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Glyf.h @@ -10,11 +10,11 @@ #include #include #include +#include #include -#include #include -namespace TTF { +namespace OpenType { class Loca { public: diff --git a/Userland/Libraries/LibGfx/Font/TrueType/Tables.h b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h similarity index 99% rename from Userland/Libraries/LibGfx/Font/TrueType/Tables.h rename to Userland/Libraries/LibGfx/Font/OpenType/Tables.h index f0e065952d..0d40cd25f2 100644 --- a/Userland/Libraries/LibGfx/Font/TrueType/Tables.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h @@ -12,7 +12,7 @@ #include #include -namespace TTF { +namespace OpenType { enum class IndexToLocFormat { Offset16, diff --git a/Userland/Libraries/LibGfx/Font/WOFF/Font.cpp b/Userland/Libraries/LibGfx/Font/WOFF/Font.cpp index b4ecf6a48c..2106b5104b 100644 --- a/Userland/Libraries/LibGfx/Font/WOFF/Font.cpp +++ b/Userland/Libraries/LibGfx/Font/WOFF/Font.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace WOFF { @@ -142,7 +142,7 @@ ErrorOr> Font::try_load_from_externally_owned_memory(Readonl font_buffer_offset += orig_length; } - auto input_font = TRY(TTF::Font::try_load_from_externally_owned_memory(font_buffer.bytes(), index)); + auto input_font = TRY(OpenType::Font::try_load_from_externally_owned_memory(font_buffer.bytes(), index)); auto font = adopt_ref(*new Font(input_font, move(font_buffer))); return font; } diff --git a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp index 71376bfd0b..2d74810250 100644 --- a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp +++ b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include -#include #include #include #include @@ -24,7 +24,7 @@ PDFErrorOr TrueTypeFont::parse_data(Document* document, Non return data; auto font_file_stream = TRY(descriptor->get_stream(document, CommonNames::FontFile2)); - auto ttf_font = TRY(TTF::Font::try_load_from_externally_owned_memory(font_file_stream->bytes())); + auto ttf_font = TRY(OpenType::Font::try_load_from_externally_owned_memory(font_file_stream->bytes())); data.font = adopt_ref(*new Gfx::ScaledFont(*ttf_font, font_size, font_size)); } diff --git a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.h b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.h index a96c857ad9..333e62f524 100644 --- a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.h +++ b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include namespace PDF { diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 5aec82f4fb..4869b7a638 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -92,10 +92,10 @@ private: // FIXME: This could maybe use the format() provided in @font-face as well, since often the mime type is just application/octet-stream and we have to try every format auto mime_type = resource()->mime_type(); if (mime_type == "font/ttf"sv || mime_type == "application/x-font-ttf"sv) - return TRY(TTF::Font::try_load_from_externally_owned_memory(resource()->encoded_data())); + return TRY(OpenType::Font::try_load_from_externally_owned_memory(resource()->encoded_data())); if (mime_type == "font/woff"sv) return TRY(WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data())); - auto ttf = TTF::Font::try_load_from_externally_owned_memory(resource()->encoded_data()); + auto ttf = OpenType::Font::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()); @@ -1459,7 +1459,7 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet) continue; // NOTE: This is rather ad-hoc, we just look for the first valid - // source URL that's either a WOFF or TTF file and try loading that. + // source URL that's either a WOFF or OpenType file and try loading that. // FIXME: Find out exactly which resources we need to load and how. Optional candidate_url; for (auto& source : font_face.sources()) {