##
##  fontforge.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_fontforge  20190809
%define       V_gnulib     20190809

#   package information
Name:         fontforge
Summary:      Font Editor
URL:          http://fontforge.github.io/
Vendor:       George Williams, Francois Pinard
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Typesetting
License:      GPL
Version:      %{V_fontforge}
Release:      20190809

#   package options
%option       with_python no

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/fontforge/fontforge-%{V_fontforge}.tar.xz
Source1:      http://download.openpkg.org/components/versioned/gnulib/gnulib-%{V_gnulib}.tar.xz
Source2:      fontconvert.sh
Patch0:       fontforge.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, config, autoconf, libtool, automake, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  jpeg, tiff, giflib, png, zlib, libiconv, freetype, gettext, libexecinfo, glib, libspiro
PreReq:       jpeg, tiff, giflib, png, zlib, libiconv, freetype, gettext, libexecinfo, glib, libspiro
%if "%{with_python}" == "yes"
BuildPreReq:  python
PreReq:       python
%endif

%description
    An outline font editor that lets you create your own postscript,
    truetype, opentype, cid-keyed, multi-master, cff, svg and bitmap
    (bdf, FON, NFNT) fonts, or edit existing ones. Also lets you convert
    one format to another. FontForge has support for many Macintosh font
    formats, too.

%track
    prog fontforge:fontforge = {
        version   = %{V_fontforge}
        url       = http://download.openpkg.org/components/versioned/fontforge/
        regex     = fontforge-(\d+)\.tar\.xz
    }
    prog fontforge:gnulib = {
        version   = %{V_gnulib}
        url       = http://download.openpkg.org/components/versioned/gnulib/
        regex     = gnulib-(\d+)\.tar\.xz
    }

%prep
    %setup -q -n fontforge
    %setup -q -n fontforge -T -D -a 1
    %patch -p0

%build
    ./bootstrap \
        --gnulib-srcdir=`pwd`/gnulib \
        --skip-git
    %{l_shtool} subst \
        -e 's;/usr/local;%{l_prefix};g' \
        -e 's;/usr/pkg;%{l_prefix};g' \
        -e 's;/usr/X11R6;%{l_prefix};g' \
        -e 's;-O2;;' \
        configure
    CC="%{l_cc}" \
%if "%{with_python}" == "yes"
    CFLAGS="%{l_cflags} %{l_cppflags tiff libpng16 python .} `pkg-config glib-2.0 --cflags`" \
    CPPFLAGS="%{l_cppflags tiff libpng16 python .} `pkg-config glib-2.0 --cflags`" \
%else
    CFLAGS="%{l_cflags} %{l_cppflags tiff libpng16 .} `pkg-config glib-2.0 --cflags`" \
    CPPFLAGS="%{l_cppflags tiff libpng16 .} `pkg-config glib-2.0 --cflags`" \
%endif
    LDFLAGS="%{l_ldflags} `pkg-config glib-2.0 --libs-only-L`" \
    LIBS="-ljpeg -lz -lm -liconv -lintl -lexecinfo `pkg-config glib-2.0 --libs-only-l`" \
    CONFIG_SHELL="%{l_bash}" \
    %{l_bash} ./configure \
        --cache-file=./config.cache \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --disable-freetype-debugger \
        --disable-gcc-warnings \
        --without-cairo \
        --without-x \
%if "%{with_python}" == "yes"
        --enable-python-scripting \
        --enable-python-extension \
%else
        --disable-python-scripting \
        --disable-python-extension \
%endif
        --without-libuninameslist \
        --without-libreadline \
        --disable-shared
    %{l_make} %{l_mflags -O} SHELL=%{l_bash}

%install
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share >/dev/null 2>&1 || true
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE fontconvert.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/fontconvert
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

