From af9be6e093c571aa9afbbfc6276572bba0aa2ff4 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 26 Jul 2021 00:08:22 -0600 Subject: [PATCH] LibTTF/LibGfx: Remove circular dependency by merging LibTTF into LibGfx LibTTF has a concrete dependency on LibGfx for things like Gfx::Bitmap, and LibGfx has a concrete dependency in the TTF::Font class in Gfx::FontDatabase. This circular dependency works fine for Serenity and Lagom Linux builds of the two libraries. It also works fine for static library builds on Lagom macOS builds. However, future changes will make Lagom use shared libraries, and circular library dependencies are not tolerated in macOS. --- Meta/Lagom/CMakeLists.txt | 4 ++-- Meta/Lagom/Fuzzers/FuzzTTF.cpp | 2 +- Userland/Libraries/CMakeLists.txt | 1 - Userland/Libraries/LibGfx/CMakeLists.txt | 5 ++++- Userland/Libraries/LibGfx/FontDatabase.cpp | 2 +- .../Libraries/{LibTTF => LibGfx/TrueTypeFont}/Cmap.cpp | 2 +- Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Cmap.h | 0 .../Libraries/{LibTTF => LibGfx/TrueTypeFont}/Font.cpp | 8 ++++---- Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Font.h | 6 +++--- .../Libraries/{LibTTF => LibGfx/TrueTypeFont}/Glyf.cpp | 2 +- Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Glyf.h | 2 +- .../Libraries/{LibTTF => LibGfx/TrueTypeFont}/Tables.h | 0 Userland/Libraries/LibGfx/Typeface.h | 2 +- Userland/Libraries/LibTTF/CMakeLists.txt | 8 -------- 14 files changed, 19 insertions(+), 25 deletions(-) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Cmap.cpp (99%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Cmap.h (100%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Font.cpp (99%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Font.h (98%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Glyf.cpp (99%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Glyf.h (99%) rename Userland/Libraries/{LibTTF => LibGfx/TrueTypeFont}/Tables.h (100%) delete mode 100644 Userland/Libraries/LibTTF/CMakeLists.txt diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 85e6370fa3..0ae79c4680 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -96,7 +96,7 @@ file(GLOB LIBCRYPTO_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibCrypt file(GLOB LIBCRYPTO_SUBDIR_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibCrypto/*/*.cpp") file(GLOB LIBCRYPTO_SUBSUBDIR_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibCrypto/*/*/*.cpp") file(GLOB LIBTLS_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTLS/*.cpp") -file(GLOB LIBTTF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTTF/*.cpp") +file(GLOB LIBGFX_TTF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibGfx/TrueTypeFont/*.cpp") file(GLOB LIBTEXTCODEC_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTextCodec/*.cpp") file(GLOB SHELL_SOURCES CONFIGURE_DEPENDS "../../Userland/Shell/*.cpp") file(GLOB SHELL_TESTS CONFIGURE_DEPENDS "../../Userland/Shell/Tests/*.sh") @@ -118,7 +118,7 @@ file(GLOB LIBUNICODE_TEST_SOURCES CONFIGURE_DEPENDS "../../Tests/LibUnicode/*.cp set(LAGOM_REGEX_SOURCES ${LIBREGEX_LIBC_SOURCES} ${LIBREGEX_SOURCES}) set(LAGOM_CORE_SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES}) -set(LAGOM_MORE_SOURCES ${LIBARCHIVE_SOURCES} ${LIBAUDIO_SOURCES} ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBJS_SUBSUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBCRYPTO_SUBSUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBTTF_SOURCES} ${LIBTEXTCODEC_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBGUI_GML_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${SHELL_SOURCES} ${LIBSQL_SOURCES} ${LIBWASM_SOURCES} ${LIBIMAP_SOURCES} ${LIBUNICODE_SOURCES}) +set(LAGOM_MORE_SOURCES ${LIBARCHIVE_SOURCES} ${LIBAUDIO_SOURCES} ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBJS_SUBSUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBCRYPTO_SUBSUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBGFX_TTF_SOURCES} ${LIBTEXTCODEC_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBGUI_GML_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${SHELL_SOURCES} ${LIBSQL_SOURCES} ${LIBWASM_SOURCES} ${LIBIMAP_SOURCES} ${LIBUNICODE_SOURCES}) set(LAGOM_TEST_SOURCES ${LIBTEST_SOURCES}) # FIXME: This is a hack, because the lagom stuff can be build individually or diff --git a/Meta/Lagom/Fuzzers/FuzzTTF.cpp b/Meta/Lagom/Fuzzers/FuzzTTF.cpp index a4214857f2..32628a1f4d 100644 --- a/Meta/Lagom/Fuzzers/FuzzTTF.cpp +++ b/Meta/Lagom/Fuzzers/FuzzTTF.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index 56cdc75ed3..c4ebb79bb0 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -42,7 +42,6 @@ add_subdirectory(LibTest) add_subdirectory(LibTextCodec) add_subdirectory(LibThreading) add_subdirectory(LibTLS) -add_subdirectory(LibTTF) add_subdirectory(LibUnicode) add_subdirectory(LibUSBDB) add_subdirectory(LibVideo) diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index fc9b6a42e5..b16f1caf50 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -33,9 +33,12 @@ set(SOURCES TextDirection.cpp TextLayout.cpp Triangle.cpp + TrueTypeFont/Font.cpp + TrueTypeFont/Glyf.cpp + TrueTypeFont/Cmap.cpp Typeface.cpp WindowTheme.cpp ) serenity_lib(LibGfx gfx) -target_link_libraries(LibGfx LibM LibCompress LibCore LibTTF) +target_link_libraries(LibGfx LibM LibCompress LibCore LibTextCodec) diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index 555212f170..68b16547f0 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include namespace Gfx { diff --git a/Userland/Libraries/LibTTF/Cmap.cpp b/Userland/Libraries/LibGfx/TrueTypeFont/Cmap.cpp similarity index 99% rename from Userland/Libraries/LibTTF/Cmap.cpp rename to Userland/Libraries/LibGfx/TrueTypeFont/Cmap.cpp index 12a457f429..cd5d281466 100644 --- a/Userland/Libraries/LibTTF/Cmap.cpp +++ b/Userland/Libraries/LibGfx/TrueTypeFont/Cmap.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include namespace TTF { diff --git a/Userland/Libraries/LibTTF/Cmap.h b/Userland/Libraries/LibGfx/TrueTypeFont/Cmap.h similarity index 100% rename from Userland/Libraries/LibTTF/Cmap.h rename to Userland/Libraries/LibGfx/TrueTypeFont/Cmap.h diff --git a/Userland/Libraries/LibTTF/Font.cpp b/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp similarity index 99% rename from Userland/Libraries/LibTTF/Font.cpp rename to Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp index e9d270e7d3..b60290bec4 100644 --- a/Userland/Libraries/LibTTF/Font.cpp +++ b/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp @@ -11,10 +11,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/Userland/Libraries/LibTTF/Font.h b/Userland/Libraries/LibGfx/TrueTypeFont/Font.h similarity index 98% rename from Userland/Libraries/LibTTF/Font.h rename to Userland/Libraries/LibGfx/TrueTypeFont/Font.h index b3dfd41180..81a294f70e 100644 --- a/Userland/Libraries/LibTTF/Font.h +++ b/Userland/Libraries/LibGfx/TrueTypeFont/Font.h @@ -13,9 +13,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #define POINTS_PER_INCH 72.0f #define DEFAULT_DPI 96 diff --git a/Userland/Libraries/LibTTF/Glyf.cpp b/Userland/Libraries/LibGfx/TrueTypeFont/Glyf.cpp similarity index 99% rename from Userland/Libraries/LibTTF/Glyf.cpp rename to Userland/Libraries/LibGfx/TrueTypeFont/Glyf.cpp index cfc60eb7f5..7cdd39eb84 100644 --- a/Userland/Libraries/LibTTF/Glyf.cpp +++ b/Userland/Libraries/LibGfx/TrueTypeFont/Glyf.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include namespace TTF { diff --git a/Userland/Libraries/LibTTF/Glyf.h b/Userland/Libraries/LibGfx/TrueTypeFont/Glyf.h similarity index 99% rename from Userland/Libraries/LibTTF/Glyf.h rename to Userland/Libraries/LibGfx/TrueTypeFont/Glyf.h index bc9135dd7d..2d34aaacb7 100644 --- a/Userland/Libraries/LibTTF/Glyf.h +++ b/Userland/Libraries/LibGfx/TrueTypeFont/Glyf.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace TTF { diff --git a/Userland/Libraries/LibTTF/Tables.h b/Userland/Libraries/LibGfx/TrueTypeFont/Tables.h similarity index 100% rename from Userland/Libraries/LibTTF/Tables.h rename to Userland/Libraries/LibGfx/TrueTypeFont/Tables.h diff --git a/Userland/Libraries/LibGfx/Typeface.h b/Userland/Libraries/LibGfx/Typeface.h index 8d12b59c39..ae3a235b81 100644 --- a/Userland/Libraries/LibGfx/Typeface.h +++ b/Userland/Libraries/LibGfx/Typeface.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace Gfx { diff --git a/Userland/Libraries/LibTTF/CMakeLists.txt b/Userland/Libraries/LibTTF/CMakeLists.txt deleted file mode 100644 index fa9daa9d5f..0000000000 --- a/Userland/Libraries/LibTTF/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(SOURCES - Cmap.cpp - Font.cpp - Glyf.cpp -) - -serenity_lib(LibTTF ttf) -target_link_libraries(LibTTF LibM LibCore LibTextCodec)