1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit flag-o-matic libtool multilib-build multilib-minimal toolchain-funcs
8 DESCRIPTION="A high-quality and portable font engine"
9 HOMEPAGE="https://www.freetype.org/"
10 IUSE="X +adobe-cff bindist bzip2 +cleartype_hinting debug fontforge harfbuzz infinality png static-libs utils"
12 if [[ "${PV}" != 9999 ]] ; then
13 SRC_URI="mirror://sourceforge/freetype/${P/_/}.tar.bz2
14 mirror://nongnu/freetype/${P/_/}.tar.bz2
15 utils? ( mirror://sourceforge/freetype/ft2demos-${PV}.tar.bz2
16 mirror://nongnu/freetype/ft2demos-${PV}.tar.bz2 )
17 doc? ( mirror://sourceforge/freetype/${PN}-doc-${PV}.tar.bz2
18 mirror://nongnu/freetype/${PN}-doc-${PV}.tar.bz2 )"
19 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
22 inherit autotools git-r3
25 LICENSE="|| ( FTL GPL-2+ )"
27 RESTRICT="!bindist? ( bindist )" # bug 541408
30 >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
31 bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
32 harfbuzz? ( >=media-libs/harfbuzz-1.3.0[truetype,${MULTILIB_USEDEP}] )
33 png? ( >=media-libs/libpng-1.2.51:0=[${MULTILIB_USEDEP}] )
36 >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
37 >=x11-libs/libXau-1.0.7-r1[${MULTILIB_USEDEP}]
38 >=x11-libs/libXdmcp-1.1.1-r1[${MULTILIB_USEDEP}]
45 PDEPEND="infinality? ( media-libs/fontconfig-infinality )"
48 "${FILESDIR}"/${PN}-2.4.11-sizeof-types.patch # 459966
51 _egit_repo_handler() {
52 if [[ "${PV}" == 9999 ]] ; then
59 die "Please use this function with either \"fetch\" or \"unpack\""
64 EGIT_REPO_URI="https://git.sv.nongnu.org/r/freetype/freetype2.git"
67 EGIT_REPO_URI="https://git.sv.nongnu.org/r/freetype/freetype2-demos.git"
68 local EGIT_CHECKOUT_DIR="${WORKDIR}/ft2demos-${PV}"
77 _egit_repo_handler ${EBUILD_PHASE}
81 _egit_repo_handler ${EBUILD_PHASE}
85 if [[ "${PV}" == 9999 ]] ; then
86 # inspired by shipped autogen.sh script
87 eval $(sed -nf version.sed include/freetype/freetype.h)
88 pushd builds/unix &>/dev/null || die
89 sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \
90 < configure.raw > configure.ac || die
91 # eautoheader produces broken ftconfig.in
92 eautoheader() { return 0 ; }
93 AT_M4DIR="." eautoreconf
94 unset freetype_major freetype_minor freetype_patch
95 popd &>/dev/null || die
100 # This is the same as the 01 patch from infinality
101 sed '/AUX_MODULES += \(gx\|ot\)valid/s@^# @@' -i modules.cfg || die
104 sed -i -e "/#define $1/ { s:/\* ::; s: \*/:: }" \
105 include/${PN}/config/ftoption.h \
106 || die "unable to enable option $1"
110 sed -i -e "/#define $1/ { s:^:/* :; s:$: */: }" \
111 include/${PN}/config/ftoption.h \
112 || die "unable to disable option $1"
115 # Will be the new default for >=freetype-2.7.0
116 disable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING 2"
118 if use infinality && use cleartype_hinting; then
119 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 )"
120 elif use infinality; then
121 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING 1"
122 elif use cleartype_hinting; then
123 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING 2"
126 # Can be disabled with FREETYPE_PROPERTIES="pcf:no-long-family-names=1"
127 # via environment (new since v2.8)
128 enable_option PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
130 if ! use bindist; then
131 # See http://freetype.org/patents.html
132 # ClearType is covered by several Microsoft patents in the US
133 enable_option FT_CONFIG_OPTION_SUBPIXEL_RENDERING
136 if ! use adobe-cff; then
137 enable_option CFF_CONFIG_OPTION_OLD_ENGINE
141 enable_option FT_DEBUG_LEVEL_TRACE
142 enable_option FT_DEBUG_MEMORY
146 cd "${WORKDIR}/ft2demos-${PV}" || die
147 # Disable tests needing X11 when USE="-X". (bug #177597)
149 sed -i -e "/EXES\ +=\ ftdiff/ s:^:#:" Makefile || die
154 # we need non-/bin/sh to run configure
155 if [[ -n ${CONFIG_SHELL} ]] ; then
156 sed -i -e "1s:^#![[:space:]]*/bin/sh:#!${CONFIG_SHELL}:" \
157 "${S}"/builds/unix/configure || die
160 elibtoolize --patch-only
163 multilib_src_configure() {
164 append-flags -fno-strict-aliasing
165 type -P gmake &> /dev/null && export GNUMAKE=gmake
168 --disable-freetype-config
169 --enable-biarch-config
174 $(use_enable static-libs static)
176 # avoid using libpng-config
177 LIBPNG_CFLAGS="$($(tc-getPKG_CONFIG) --cflags libpng)"
178 LIBPNG_LDFLAGS="$($(tc-getPKG_CONFIG) --libs libpng)"
183 # Workaround windows mis-detection: bug #654712
184 # Have to do it for both ${CHOST}-windres and windres
185 *) myeconfargs+=( ac_cv_prog_RC= ac_cv_prog_ac_ct_RC= ) ;;
188 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
191 multilib_src_compile() {
194 if multilib_is_native_abi && use utils; then
195 einfo "Building utils"
196 # fix for Prefix, bug #339334
198 X11_PATH="${EPREFIX}/usr/$(get_libdir)" \
199 FT2DEMOS=1 TOP_DIR_2="${WORKDIR}/ft2demos-${PV}"
203 multilib_src_install() {
206 if multilib_is_native_abi && use utils; then
207 einfo "Installing utils"
208 rm "${WORKDIR}"/ft2demos-${PV}/bin/README || die
209 dodir /usr/bin #654780
211 for ft2demo in ../ft2demos-${PV}/bin/*; do
212 ./libtool --mode=install $(type -P install) -m 755 "${ft2demo}" \
213 "${ED}"/usr/bin || die
218 multilib_src_install_all() {
219 if use fontforge; then
220 # Probably fontforge needs less but this way makes things simplier...
221 einfo "Installing internal headers required for fontforge"
223 find src/truetype include/freetype/internal -name '*.h' | \
224 while read header; do
225 mkdir -p "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
226 cp ${header} "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
230 dodoc docs/{CHANGES,CUSTOMIZE,DEBUG,INSTALL.UNIX,*.txt,PROBLEMS,TODO}
231 if [[ "${PV}" != 9999 ]] && use doc ; then
236 find "${ED}" -name '*.la' -delete || die
237 if ! use static-libs ; then
238 find "${ED}" -name '*.a' -delete || die