Skip to content

Commit

Permalink
build: Raise freetype minimum to 2.10.0 and allow auto-build (#4283)
Browse files Browse the repository at this point in the history
freetype 2.10.0 dates from 2019, so we're still supporting 5 years back.

Previously, we enforced no minimum, so we're not sure how far back it
would really work, but the earliest version we tested in CI was 2.8,
which dated from 2018.

Add a build_Freetype.bash for easy setup for CI (and other users).

Add build_freetype.cmake to allow automatic local builds if it can't
be found at build time.

CI many cases need to build freetype, because the old CentOS 7 era
freetype is now too old.

Remove some reference output that was only needed for older freetype.

---------

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz authored Jun 15, 2024
1 parent 8acc6bf commit d3c5d79
Show file tree
Hide file tree
Showing 27 changed files with 117 additions and 104 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
fmt_ver: 7.1.0
pybind11_ver: v2.7.0
setenvs: export PUGIXML_VERSION=v1.9 WEBP_VERSION=v1.1.0 USE_OPENVDB=0
FREETYPE_VERSION=VER-2-10-0
- desc: clang10/C++17 avx2 exr3.1 ocio2.0
nametag: linux-clang10-cpp14
runner: ubuntu-latest
Expand All @@ -60,6 +61,7 @@ jobs:
simd: "avx2,f16c"
fmt_ver: 8.1.1
setenvs: export USE_OPENVDB=0
FREETYPE_VERSION=VER-2-11-0
- desc: gcc9/C++17 py39 exr3.1 ocio2.1
nametag: linux-vfx2022
runner: ubuntu-latest
Expand All @@ -70,6 +72,7 @@ jobs:
simd: "avx2,f16c"
fmt_ver: 8.1.1
pybind11_ver: v2.9.0
setenvs: export FREETYPE_VERSION=VER-2-12-0
- desc: clang13/C++17 py39 avx2 exr3.1 ocio2.1
nametag: linux-vfx2022-clang13
runner: ubuntu-latest
Expand All @@ -82,6 +85,7 @@ jobs:
simd: "avx2,f16c"
fmt_ver: 9.1.0
pybind11_ver: v2.8.1
setenvs: export FREETYPE_VERSION=VER-2-12-0
- desc: icc/C++17 py3.9 exr3.1 ocio2.1 qt5.15
nametag: linux-vfx2022-icc
runner: ubuntu-latest
Expand All @@ -95,6 +99,7 @@ jobs:
pybind11_ver: v2.9.0
setenvs: export USE_ICC=1 USE_OPENVDB=0
OIIO_EXTRA_CPP_ARGS="-fp-model=precise"
FREETYPE_VERSION=VER-2-13-0
# For icc, use fp-model precise to eliminate needless LSB errors
# that make test results differ from other platforms.
- desc: icx/C++17 py3.9 exr3.1 ocio2.1 qt5.15
Expand Down Expand Up @@ -163,6 +168,7 @@ jobs:
USE_JPEGTURBO=0
USE_OPENCOLORIO=0
USE_OPENCV=0
FREETYPE_VERSION=VER-2-10-0
depcmds: sudo rm -rf /usr/local/include/OpenEXR

# Test ABI stability. `abi_check` is the version or commit that we
Expand All @@ -183,7 +189,7 @@ jobs:
# abi_check: v2.6.2.0
abi_check: e83cd7c44916105034f2d539a5e55a6c6f178a7f
setenvs: export OIIO_CMAKE_FLAGS="-DOIIO_BUILD_TOOLS=0 -DOIIO_BUILD_TESTS=0 -DUSE_PYTHON=0"
USE_OPENCV=0 USE_FFMPEG=0 USE_PYTHON=0
USE_OPENCV=0 USE_FFMPEG=0 USE_PYTHON=0 USE_FREETYPE=0
CMAKE_BUILD_TYPE=RelWithDebInfo

runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -294,6 +300,7 @@ jobs:
PUGIXML_VERSION=v1.14
USE_OPENVDB=0
WEBP_VERSION=v1.3.0
FREETYPE_VERSION=VER-2-13-2
# The installed OpenVDB has a TLS conflict with Python 3.8
- desc: bleeding edge gcc14 C++20 py3.12 OCIO/libtiff/exr-master avx2
nametag: linux-bleeding-edge
Expand All @@ -320,6 +327,7 @@ jobs:
PIP_INSTALLS="none"
USE_OPENVDB=0
SKIP_APT_GET_UPDATE=1
FREETYPE_VERSION=master
# The installed OpenVDB has a TLS conflict with Python 3.8
# Disabling the `apt-get update` in gh-installdeps.bash
# addresses a job killing problem in the GHA Ubuntu
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Release 2.6 (Fall 2024) -- compared to 2.5
* *OpenVDB*: Raise OpenVDB minimum to 9.0 [#4218](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4218) (2.6.2.0)
* *LibRaw*: Raise minimum LibRaw to 0.20 (from 0.18) [#4217](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4217) (2.6.2.0)
* *Boost*: Is no longer a dependency! [#4191](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4191) (by Christopher Kulla) [#4221](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4221) (by Christopher Kulla) [#4222](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4222) [#4233](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4233) (2.6.2.0)
* *Freetype*: minimum raised to 2.10 (from no previously stated minimum, but we had been testing as far back as 2.8).

### ⛰️ New features and public API changes:

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* If you want support for Ptex:
* Ptex >= 2.3.1 (probably works for older; tested through 2.4.2)
* If you want to be able to do font rendering into images:
* Freetype (minimum unknown, tested 2.8 through 2.13)
* **Freetype >= 2.10.0** (tested through 2.13)
* We use PugiXML for XML parsing. There is a version embedded in the OIIO
tree, but if you want to use an external, system-installed version (as
may be required by some software distributions with policies against
Expand Down
56 changes: 56 additions & 0 deletions src/build-scripts/build_Freetype.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

# Utility script to download and build Freetype
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

# Exit the whole script if any command fails.
set -ex

# Repo and branch/tag/commit of Freetype to download if we don't have it yet
FREETYPE_REPO=${FREETYPE_REPO:=https://github.com/freetype/freetype.git}
FREETYPE_VERSION=${FREETYPE_VERSION:=VER-2-13-2}

# Where to put Freetype repo source (default to the ext area)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
FREETYPE_SRC_DIR=${FREETYPE_SRC_DIR:=${LOCAL_DEPS_DIR}/Freetype}
FREETYPE_BUILD_DIR=${FREETYPE_BUILD_DIR:=${FREETYPE_SRC_DIR}/build}
FREETYPE_INSTALL_DIR=${FREETYPE_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
FREETYPE_BUILD_TYPE=${FREETYPE_BUILD_TYPE:=Release}

pwd
echo "Freetype install dir will be: ${FREETYPE_INSTALL_DIR}"

mkdir -p ./ext
pushd ./ext

# Clone Freetype project from GitHub and build
if [[ ! -e ${FREETYPE_SRC_DIR} ]] ; then
echo "git clone ${FREETYPE_REPO} ${FREETYPE_SRC_DIR}"
git clone ${FREETYPE_REPO} ${FREETYPE_SRC_DIR}
fi
cd ${FREETYPE_SRC_DIR}

echo "git checkout ${FREETYPE_VERSION} --force"
git checkout ${FREETYPE_VERSION} --force

if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${FREETYPE_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${FREETYPE_BUILD_TYPE} \
-DBUILD_SHARED_LIBS=${FREETYPE_BUILD_SHARED_LIBS:-ON} \
-DCMAKE_INSTALL_PREFIX=${FREETYPE_INSTALL_DIR} \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
${FREETYPE_CONFIG_OPTS}
time cmake --build ${FREETYPE_BUILD_DIR} --config ${FREETYPE_BUILD_TYPE} --target install
fi

# ls -R ${FREETYPE_INSTALL_DIR}
popd


# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export Freetype_ROOT=$FREETYPE_INSTALL_DIR

7 changes: 7 additions & 0 deletions src/build-scripts/gh-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ if [[ "$ASWF_ORG" != "" ]] ; then
if [[ "${USE_FFMPEG}" != "0" ]] ; then
sudo yum install -y ffmpeg ffmpeg-devel && true
fi
if [[ "${USE_FREETYPE:-1}" != "0" ]] ; then
sudo yum install -y freetype freetype-devel && true
fi
if [[ "${EXTRA_DEP_PACKAGES}" != "" ]] ; then
time sudo yum install -y ${EXTRA_DEP_PACKAGES}
fi
Expand Down Expand Up @@ -204,6 +207,10 @@ if [[ "$LIBJPEGTURBO_VERSION" != "" ]] ; then
source src/build-scripts/build_libjpeg-turbo.bash
fi

if [[ "$FREETYPE_VERSION" != "" ]] ; then
source src/build-scripts/build_Freetype.bash
fi

if [[ "$USE_ICC" != "" ]] ; then
# We used gcc for the prior dependency builds, but use icc for OIIO itself
echo "which icpc:" $(which icpc)
Expand Down
40 changes: 40 additions & 0 deletions src/cmake/build_Freetype.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

######################################################################
# Freetype by hand!
######################################################################

set_cache (Freetype_BUILD_VERSION 2.13.2 "Freetype version for local builds")
set (Freetype_GIT_REPOSITORY "https://github.com/freetype/freetype")
set (Freetype_GIT_TAG "VER-2-13-2")
set_cache (Freetype_BUILD_SHARED_LIBS OFF
DOC "Should a local Freetype build, if necessary, build shared libraries" ADVANCED)
# We would prefer to build a static Freetype, but haven't figured out how to make
# it all work with the static dependencies, it just makes things complicated
# downstream.

string (MAKE_C_IDENTIFIER ${Freetype_BUILD_VERSION} Freetype_VERSION_IDENT)

build_dependency_with_cmake(Freetype
VERSION ${Freetype_BUILD_VERSION}
GIT_REPOSITORY ${Freetype_GIT_REPOSITORY}
GIT_TAG ${Freetype_GIT_TAG}
CMAKE_ARGS
-D BUILD_SHARED_LIBS=${Freetype_BUILD_SHARED_LIBS}
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
-D CMAKE_INSTALL_LIBDIR=lib
)

# Set some things up that we'll need for a subsequent find_package to work

set (Freetype_ROOT ${Freetype_LOCAL_INSTALL_DIR})

# Signal to caller that we need to find again at the installed location
set (Freetype_REFIND TRUE)
set (Freetype_REFIND_ARGS CONFIG)

if (Freetype_BUILD_SHARED_LIBS)
install_local_dependency_libs (Freetype Freetype)
endif ()
3 changes: 2 additions & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ if (NOT BZIP2_FOUND)
endif ()

checked_find_package (Freetype
DEFINITIONS USE_FREETYPE=1 )
VERSION_MIN 2.10.0
DEFINITIONS USE_FREETYPE=1 )

checked_find_package (OpenColorIO
VERSION_MIN 1.1
Expand Down
2 changes: 1 addition & 1 deletion src/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

file (GLOB public_fonts "*/*.ttf")

if (INSTALL_FONTS AND FREETYPE_FOUND)
if (INSTALL_FONTS AND (Freetype_FOUND OR FREETYPE_FOUND))
install (FILES ${public_fonts}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/fonts/OpenImageIO
COMPONENT fonts)
Expand Down
100 changes: 0 additions & 100 deletions testsuite/oiiotool-subimage/ref/out-oldfreetype.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified testsuite/oiiotool-subimage/ref/subimageB1.exr
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified testsuite/oiiotool-subimage/ref/subimageD3.exr
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified testsuite/oiiotool-subimage/ref/subimages-4.exr
Binary file not shown.
Binary file removed testsuite/texture-udim/ref/out-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim/ref/out2-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim2/ref/out-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim2/ref/out2-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim2/ref/out3-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim2/ref/out4-oldfreetype.tif
Binary file not shown.
Binary file removed testsuite/texture-udim2/ref/out5-oldfreetype.tif
Binary file not shown.

0 comments on commit d3c5d79

Please sign in to comment.