Skip to content

Commit

Permalink
Merge 936d931 into 13df3c1
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Jan 5, 2023
2 parents 13df3c1 + 936d931 commit d45a8a7
Show file tree
Hide file tree
Showing 181 changed files with 1,533 additions and 1,276 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
- name: Configure
run: |
./bootstrap.sh
./configure --without-system-luarocks --with-manual
./configure \
--disable-font-variations \
--without-system-luarocks \
--with-manual
echo "VERSION=$(./build-aux/git-version-gen .tarball-version)" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc) -Otarget" >> $GITHUB_ENV
- name: Make
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
./bootstrap.sh
./configure \
--enable-developer LUACHECK=false \
--disable-font-variations \
--without-system-luarocks \
--with-luajit \
--without-manual
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
./bootstrap.sh
./configure \
--enable-developer LUACHECK=false \
--disable-font-variations \
--without-system-luarocks \
--with${{ startsWith(matrix.luaVersion[0], '5') && 'out' || '' }}-luajit \
--without-manual
Expand Down
44 changes: 15 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,17 @@ if (WIN32)
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DICU_BUILD_IO=ON
INSTALL_DIR "${TMP_INSTALL_DIR}")

ExternalProject_Add(ragel
GIT_REPOSITORY https://github.com/tamaskenez/ragel-cmake
GIT_TAG 651ce281
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
INSTALL_DIR "${TMP_INSTALL_DIR}")

ExternalProject_Add(freetype2_bootstrap
GIT_REPOSITORY https://github.com/aseprite/freetype2
GIT_TAG VER-2-10-0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DFT_WITH_HARFBUZZ=OFF
INSTALL_DIR "${CMAKE_BINARY_DIR}/bootstrap")

ExternalProject_Add(harfbuzz
DEPENDS ragel icu freetype2_bootstrap
GIT_REPOSITORY https://github.com/harfbuzz/harfbuzz
GIT_TAG 2.3.1
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DHB_HAVE_ICU=ON -DHB_HAVE_FREETYPE=ON -DHB_BUILD_TESTS=OFF "-DCMAKE_PREFIX_PATH=${CMAKE_BINARY_DIR}/bootstrap"
GIT_TAG 6.0.0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DHB_BUILD_TESTS=OFF "-DCMAKE_PREFIX_PATH=${CMAKE_BINARY_DIR}/bootstrap"
INSTALL_DIR "${TMP_INSTALL_DIR}")

ExternalProject_Add(freetype2
DEPENDS harfbuzz libpng zlib
GIT_REPOSITORY https://github.com/aseprite/freetype2
GIT_TAG VER-2-10-0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DFT_WITH_HARFBUZZ=ON -DFT_WITH_ZLIB=ON -DFT_WITH_PNG=ON
DEPENDS libpng zlib
GIT_REPOSITORY https://gitlab.freedesktop.org/freetype/freetype.git
GIT_TAG VER-2-12-1
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DFT_DISABLE_HARFBUZZ=ON -DFT_REQUIRE_ZLIB=ON -DFT_REQUIRE_PNG=ON
INSTALL_DIR "${TMP_INSTALL_DIR}")

ExternalProject_Add(libiconv
Expand All @@ -67,7 +54,7 @@ if (WIN32)
COMMAND git clean -dfx
COMMAND git apply "${CMAKE_CURRENT_SOURCE_DIR}/cmake/fontconfig.diff"
LIST_SEPARATOR ::
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DCMAKE_C_FLAGS=/DXML_STATIC=1 -DBUILD_SHARED=OFF -DBUILD_STATIC=ON "-DEXPAT_LIBRARIES=<INSTALL_DIR>/lib/expat.lib" "-DFREETYPE_LIBRARIES=<INSTALL_DIR>/lib/freetype.lib" "-DLIBRARIES_TO_LINK=<INSTALL_DIR>/lib/harfbuzz.lib::<INSTALL_DIR>/lib/libpng16_static.lib::<INSTALL_DIR>/lib/zlibstatic.lib"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DCMAKE_C_FLAGS=/DXML_STATIC=1 -DBUILD_SHARED=OFF -DBUILD_STATIC=ON "-DEXPAT_LIBRARIES=<INSTALL_DIR>/lib/expat.lib" "-DFREETYPE_LIBRARIES=<INSTALL_DIR>/lib/freetype.lib" "-DLIBRARIES_TO_LINK=<INSTALL_DIR>/lib/libpng16_static.lib::<INSTALL_DIR>/lib/zlibstatic.lib"
INSTALL_DIR "${TMP_INSTALL_DIR}")
ExternalProject_Add_Step(fontconfig genconf
COMMAND "${CMAKE_COMMAND}" "-DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/fonts_conf.cmake"
Expand Down Expand Up @@ -162,17 +149,17 @@ target_link_libraries(justenoughlibtexpdf PUBLIC libtexpdf lua51.lib)
target_link_options(justenoughlibtexpdf PUBLIC /EXPORT:luaopen_justenoughlibtexpdf)


add_library(justenoughharfbuzz SHARED src/justenoughharfbuzz.c)
add_dependencies(justenoughharfbuzz harfbuzz freetype2 lua)
add_library(justenoughharfbuzz SHARED src/justenoughharfbuzz.c src/hb-utils.c src/hb-utils.h)
add_dependencies(justenoughharfbuzz harfbuzz lua)
target_include_directories(justenoughharfbuzz PUBLIC
"${TMP_INSTALL_DIR}/include"
"${TMP_INSTALL_DIR}/include/harfbuzz"
"${TMP_INSTALL_DIR}/include/freetype2"
"${TMP_LUA_DIR}/include")
target_link_directories(justenoughharfbuzz PUBLIC
"${TMP_INSTALL_DIR}/lib"
"${TMP_LUA_DIR}")
target_link_libraries(justenoughharfbuzz PUBLIC harfbuzz.lib freetype.lib zlibstatic.lib lua51.lib libpng16_static.lib)
target_compile_definitions(justenoughharfbuzz PUBLIC HAVE_HARFBUZZ_SUBSET)
target_link_libraries(justenoughharfbuzz PUBLIC harfbuzz.lib harfbuzz-subset.lib lua51.lib)
target_link_options(justenoughharfbuzz PUBLIC /EXPORT:luaopen_justenoughharfbuzz)

add_library(justenoughicu SHARED src/justenoughicu.c)
Expand All @@ -194,20 +181,19 @@ target_include_directories(justenoughfontconfig PUBLIC
target_link_directories(justenoughfontconfig PUBLIC
"${TMP_INSTALL_DIR}/lib"
"${TMP_LUA_DIR}")
target_link_libraries(justenoughfontconfig PUBLIC fontconfig-static.lib lua51.lib expat.lib freetype.lib harfbuzz.lib libpng16_static.lib zlibstatic.lib)
target_link_libraries(justenoughfontconfig PUBLIC fontconfig-static.lib lua51.lib expat.lib freetype.lib libpng16_static.lib zlibstatic.lib)
target_link_options(justenoughfontconfig PUBLIC /EXPORT:luaopen_justenoughfontconfig)

add_library(fontmetrics SHARED src/fontmetrics.c)
add_dependencies(fontmetrics harfbuzz freetype2 lua)
add_library(fontmetrics SHARED src/fontmetrics.c src/hb-utils.c src/hb-utils.h)
add_dependencies(fontmetrics harfbuzz lua)
target_include_directories(fontmetrics PUBLIC
"${TMP_INSTALL_DIR}/include"
"${TMP_INSTALL_DIR}/include/harfbuzz"
"${TMP_INSTALL_DIR}/include/freetype2"
"${TMP_LUA_DIR}/include")
target_link_directories(fontmetrics PUBLIC
"${TMP_INSTALL_DIR}/lib"
"${TMP_LUA_DIR}")
target_link_libraries(fontmetrics PUBLIC harfbuzz.lib freetype.lib zlibstatic.lib lua51.lib libpng16_static.lib)
target_link_libraries(fontmetrics PUBLIC harfbuzz.lib lua51.lib)
target_link_options(fontmetrics PUBLIC /EXPORT:luaopen_fontmetrics)

add_library(svg SHARED src/svg.c)
Expand Down
9 changes: 9 additions & 0 deletions Makefile-fonts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ TESTFONTFILES += NotoSerifCJK-Regular.ttc
TESTFONTFILES += SBL_Hbrw.ttf
TESTFONTFILES += TwemojiMozilla.ttf

if FONT_VARIATIONS
TESTFONTFILES += Tourney[wdth,wght].ttf
endif

comma = ,
varencode = $(subst $(comma),%2C,$(subst [,%5B,$(subst ],%5D,$(1))))
notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')

# Tell make how to download individual font files directly (when available)
Expand All @@ -60,6 +66,9 @@ notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')
.fonts/Symbola.otf: | .fonts
$(CURL) -fsSL https://github.com/ChiefMikeK/ttf-symbola/raw/master/Symbola-13.otf -o $@

.fonts/Tourney%: | .fonts
$(CURL) -fsSL https://raw.githubusercontent.com/Etcetera-Type-Co/Tourney/643f1026ad6d41b4527f42cd93c776414fdd6503/fonts/variable/$(call varencode,$(notdir $@)) -o $@

.fonts/TwemojiMozilla.ttf: | .fonts
$(CURL) -fsSL https://github.com/mozilla/twemoji-colr/releases/download/v0.5.1/$(notdir $@) -o $@

Expand Down
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ include Makefile-luarocks
# Actual rules for downloading test fonts are in a separate file
include Makefile-fonts

# Our regression test suite includes test for all features. Anything that is
# only expected to work with code behind a feature flag needs to be filtered
# out if we are configured with the feature disabled.
if !FONT_VARIATIONS
TESTSRC = $(filter-out tests/variations-%,$(TESTSRC))
endif

# Since we can't use $(wildcard ...) in automake file lists, we generate a file
# with a script that builds our dynamic file lists instead. This is tricky,
# because if we just include the file automake will flatten this include. By
Expand Down
152 changes: 88 additions & 64 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,60 @@ AX_PROGVAR([find])
LT_PREREQ([2.2])
LT_INIT([dlopen])

AC_CANONICAL_HOST

AC_ARG_ENABLE([dependency-checks],
AS_HELP_STRING([--disable-dependency-checks], [Disable dependency checks]))
AS_HELP_STRING([--disable-dependency-checks],
[Disable dependency checks]))
AM_CONDITIONAL([DEPENDENCY_CHECKS], [test "x$enable_dependency_checks" != "xno"])

AC_ARG_ENABLE([developer],
AS_HELP_STRING([--enable-developer], [Check for and enable tooling required only for SILE developers]))
AS_HELP_STRING([--enable-developer],
[Check for and enable tooling required only for SILE developers]))
AM_CONDITIONAL([DEVELOPER], [test "x$enable_developer" = "xyes"])

AC_CANONICAL_HOST
AC_ARG_ENABLE([font-variations],
AS_HELP_STRING([--disable-font-variations],
[Disable support for OpenType variations and variable fonts that requires HarfBuzz subsetter library]))
AM_CONDITIONAL([FONT_VARIATIONS], [test "x$enable_font_variations" != "xno"])

AC_ARG_ENABLE([linklua],
AS_HELP_STRING([--disable-linklua],
[Don’t link lua library with dylibs]))
AM_CONDITIONAL([LINKLUA], [test "x$enable_linklua" != "xno"])

# TODO: Refactor fontconfig check to allow Appkit/DirectWrite as alternatives, maybe default to off on Darwin
# AC_ARG_WITH([fontconfig],
# AS_HELP_STRING([--without-fontconfig],
# [Compile without fontconfig font manager support]))
AM_CONDITIONAL([FONTCONFIG], [test "x$with_fontconfig" != "xno"])

AC_ARG_WITH([harfbuzz],
AS_HELP_STRING([--without-harfbuzz],
[Compile without HarfBuzz support used as default shaping backend]))
AM_CONDITIONAL([HARFBUZZ], [test "x$with_harfbuzz" != "xno"])

AC_ARG_WITH([system-libtexpdf],
AS_HELP_STRING([--with-system-libtexpdf], [Don’t bundle libtexpdf, use system provided version]))
AS_HELP_STRING([--with-system-libtexpdf],
[Don’t bundle libtexpdf, use system provided version]))
AM_CONDITIONAL([SYSTEM_LIBTEXPDF], [test "x$with_system_libtexpdf" = "xyes"])

AC_ARG_WITH([system-luarocks],
AS_HELP_STRING([--with-system-luarocks], [Don’t bundle LuaRocks, use system provided versions]))
AS_HELP_STRING([--with-system-luarocks],
[Don’t bundle LuaRocks, use system provided versions]))
AM_CONDITIONAL([SYSTEM_LUAROCKS], [test "x$with_system_luarocks" = "xyes"])
AC_SUBST([SYSTEM_LUAROCKS])

AC_ARG_WITH([luajit],
AS_HELP_STRING([--with-luajit], [Run under LuaJIT instead of Lua]))
AS_HELP_STRING([--with-luajit],
[Run under LuaJIT instead of Lua]))
AM_CONDITIONAL([LUAJIT], [test "x$with_luajit" = "xyes"])

AC_ARG_WITH([manual],
AS_HELP_STRING([--with-manual], [Rebuild manual and install to system’s PDF documentation directory]))
AS_HELP_STRING([--with-manual],
[Rebuild manual and install to system’s PDF documentation directory]))
AM_CONDITIONAL([MANUAL], [test "x$with_manual" = "xyes"])

AM_COND_IF([SYSTEM_LIBTEXPDF],
[AC_CHECK_LIB([texpdf],[texpdf_doc_set_verbose],
[],
[AC_MSG_FAILURE([--with-system-libtexpdf was given, but test for libtexpdf failed])]) ],
[AC_CONFIG_SUBDIRS([libtexpdf])])

AM_CONDITIONAL([FONT_DOWNLOAD_TOOLS], [test -z ${DEVELOPER_TRUE} || (test -z ${MANUAL_TRUE} && test -z ${IS_SDIST_FALSE})])
AC_SUBST([FONT_DOWNLOAD_TOOLS])

Expand All @@ -76,7 +97,6 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[@import AppKit;]],[[]])],
[
have_appkit=yes
AC_DEFINE([APPKIT], [1], [Build using AppKit])
AC_MSG_RESULT([yes])
], [
have_appkit=no
Expand All @@ -90,40 +110,49 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
;;
esac
PKG_CHECK_MODULES(HARFBUZZ, harfbuzz, [
PKG_CHECK_MODULES(FREETYPE, freetype2,[],[AC_MSG_FAILURE([Harfbuzz found but not freetype2])])
PKG_CHECK_MODULES(FONTCONFIG, fontconfig,[],[AC_MSG_FAILURE([Harfbuzz found but not fontconfig])])
with_harfbuzz=yes
backend=harfbuzz
], [
if test "x$with_harfbuzz" != xcheck; then
AC_MSG_FAILURE([--with-harfbuzz was given, but test for harfbuzz failed])
fi
])
AM_COND_IF([FONTCONFIG],
[PKG_CHECK_MODULES(FONTCONFIG, [fontconfig],
[],
[AC_MSG_FAILURE([Fontconfig package not found])])])
AM_COND_IF([HARFBUZZ],
[PKG_CHECK_MODULES(HARFBUZZ, [harfbuzz >= 2.7.4],
[],
[AC_MSG_FAILURE([--with-harfbuzz was given, but harfbuzz not found])]) ])
AM_COND_IF([FONT_VARIATIONS],
[PKG_CHECK_MODULES(HARFBUZZ_SUBSET, [harfbuzz-subset >= 6.0.0],
[AC_DEFINE(HAVE_HARFBUZZ_SUBSET, [1], [Have harfbuzz-subset library])],
[AC_MSG_FAILURE([--enable-font-variations was given, but harfbuzz version not new enough to include required subset library functions])])])
AM_COND_IF([SYSTEM_LIBTEXPDF],
[AC_CHECK_LIB([texpdf], [texpdf_doc_set_verbose],
[],
[AC_MSG_FAILURE([--with-system-libtexpdf was given, but test for libtexpdf failed])])],
[AC_CONFIG_SUBDIRS([libtexpdf])])
PKG_CHECK_MODULES(ICU, icu-uc icu-io, [
AC_DEFINE([ICU], [1], [Build using icu4c])
with_icu=yes
],[
AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
AC_MSG_CHECKING([for ICU by using icu-config fallback])
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
ICU_LIBS=`icu-config --ldflags-libsonly --ldflags-icuio`
ICU_CFLAGS=`icu-config --cppflags`
with_icu=yes
AC_MSG_RESULT([yes])
else
AC_MSG_FAILURE([Required ICU library not found])
fi
],[
AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
AC_MSG_CHECKING([for ICU by using icu-config fallback])
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
ICU_LIBS=`icu-config --ldflags-libsonly --ldflags-icuio`
ICU_CFLAGS=`icu-config --cppflags`
with_icu=yes
AC_MSG_RESULT([yes])
else
AC_MSG_FAILURE([Required ICU library not found])
fi
])
case $host_os in
msys)
LUA_VERSION=5.3 # By fiat. This is obviously not good.
;;
*)
AX_PROG_LUA([5.1])
;;
msys)
LUA_VERSION=5.3 # By fiat. This is obviously not good.
;;
*)
AX_PROG_LUA([5.1])
;;
esac
AX_LUA_HEADERS
Expand Down Expand Up @@ -175,37 +204,32 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
])
])
AC_SUBST([ICU_CFLAGS])
AC_SUBST([ICU_LIBS])

AM_CONDITIONAL([APPKIT], [test "x$have_appkit" = "xyes"])
AC_SUBST([APPKIT])

AM_CONDITIONAL([ICU], [test "x$with_icu" = "xyes"])
AC_ARG_ENABLE([linklua],
AS_HELP_STRING([--disable-linklua], [Don’t link lua library with dylibs]))
AM_CONDITIONAL([LINKLUA], [test "x$enable_linklua" != "xno"])

AC_CANONICAL_HOST
AC_SUBST([HARFBUZZ_CFLAGS])
AC_SUBST([HARFBUZZ_LIBS])
AC_SUBST([HARFBUZZ_SUBSET_CFLAGS])
AC_SUBST([HARFBUZZ_SUBSET_LIBS])
AC_SUBST([ICU_CFLAGS])
AC_SUBST([ICU_LIBS])

case $host_os in
darwin*)
LUAROCKSARGS="EXPAT_DIR=/usr/local/opt/expat OPENSSL_DIR=/usr/local/opt/openssl ZLIB_DIR=/usr/local/opt/zlib"
SHARED_LIB_EXT="so"
;;
cygwin*|mingw*)
SHARED_LIB_EXT="dll"
;;
*)
SHARED_LIB_EXT="so"
;;
darwin*)
LUAROCKSARGS="EXPAT_DIR=/usr/local/opt/expat OPENSSL_DIR=/usr/local/opt/openssl ZLIB_DIR=/usr/local/opt/zlib"
SHARED_LIB_EXT="so"
;;
cygwin*|mingw*)
SHARED_LIB_EXT="dll"
;;
*)
SHARED_LIB_EXT="so"
;;
esac
AC_SUBST([SHARED_LIB_EXT])
AC_SUBST([LUAROCKSARGS])

AC_SUBST([HARFBUZZ_CFLAGS])
AC_SUBST([HARFBUZZ_LIBS])
AC_SUBST([shared_ext])

AX_SUBST_TRANSFORMED_PACKAGE_NAME

adl_RECURSIVE_EVAL(["${datadir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_PATH])
Expand Down

0 comments on commit d45a8a7

Please sign in to comment.