# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           cmake 1.1
PortGroup           compiler_blacklist_versions 1.0

github.setup        fontforge fontforge 20230101
revision            0
checksums           rmd160  bd104bd30dd9b6673b2f91c6ea45649a4b8be220 \
                    sha256  ca82ec4c060c4dda70ace5478a41b5e7b95eb035fe1c4cf85c48f996d35c60f8 \
                    size    13761728

categories          graphics fonts
maintainers         nomaintainer
license             BSD
description         Outline and bitmap font editor/converter for many formats

long_description    FontForge allows you to edit outline and bitmap fonts.  You may create \
                    new ones or modify old ones.  It is also a format converter and can \
                    interconvert between PostScript (ascii & binary Type1, some Type3, \
                    some Type0), TrueType, OpenType (Type2), CID, SVG.  Previously known as \
                    pfaedit.

homepage            https://fontforge.org
github.tarball_from releases
use_xz              yes

depends_build-append \
                    port:pkgconfig

depends_lib         path:lib/pkgconfig/cairo.pc:cairo \
                    port:readline \
                    port:freetype \
                    port:gettext \
                    port:giflib \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libiconv \
                    port:libpng \
                    port:libspiro \
                    port:libuninameslist \
                    port:libxml2 \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:potrace \
                    port:tiff \
                    port:woff2 \
                    port:zlib

compiler.c_standard 2011

# fix 32bit builds by masking an old Carbon call to GetTime
patchfiles-append   patch-fontforge-carbon-gettime-namecollision.diff

# the date command on Tiger is too old for this port, use gnu coreutils dates instead
platform darwin 8 {
    depends_build-append path:libexec/coreutils/libstdbuf.so:coreutils
    configure.env-append PATH=${prefix}/libexec/gnubin/:$env(PATH)
}

configure.args-append -DENABLE_GUI=False \
                      -DENABLE_LIBGIF=True \
                      -DENABLE_LIBJPEG=True \
                      -DENABLE_LIBPNG=True \
                      -DENABLE_LIBREADLINE=True \
                      -DENABLE_LIBSPIRO=True \
                      -DENABLE_LIBTIFF=True \
                      -DENABLE_UNINAMELIST=True \
                      -DENABLE_PYTHON_SCRIPTING=False \
                      -DENABLE_PYTHON_EXTENSION=False \
                      -DENABLE_WOFF2=True \
                      -DENABLE_WRITE_PFM=False \
                      -DENABLE_X11=False

variant python37 conflicts python38 python39 python310 python311 description {Enable Python support (Python 3.7)} {
    depends_lib-append      port:python37
    configure.args-replace  -DENABLE_PYTHON_EXTENSION=False \
                            -DENABLE_PYTHON_EXTENSION=True
    configure.args-replace  -DENABLE_PYTHON_SCRIPTING=False \
                            -DENABLE_PYTHON_SCRIPTING=True
    configure.args-append   -DPython3_EXECUTABLE="${prefix}/bin/python3.7" \
                            -DPYHOOK_INSTALL_DIR="${frameworks_dir}/Python.framework/Versions/3.7/lib/python3.7/site-packages"
    configure.pkg_config_path \
                            "${frameworks_dir}/Python.framework/Versions/3.7/lib/pkgconfig"
}

variant python38 conflicts python37 python39 python310 python311 description {Enable Python support (Python 3.8)} {
    depends_lib-append      port:python38
    configure.args-replace  -DENABLE_PYTHON_EXTENSION=False \
                            -DENABLE_PYTHON_EXTENSION=True
    configure.args-replace  -DENABLE_PYTHON_SCRIPTING=False \
                            -DENABLE_PYTHON_SCRIPTING=True
    configure.args-append   -DPython3_EXECUTABLE="${prefix}/bin/python3.8" \
                            -DPYHOOK_INSTALL_DIR="${frameworks_dir}/Python.framework/Versions/3.8/lib/python3.8/site-packages"
    configure.pkg_config_path \
                            "${frameworks_dir}/Python.framework/Versions/3.8/lib/pkgconfig"
}

variant python39 conflicts python37 python38 python310 python311 description {Enable Python support (Python 3.9)} {
    depends_lib-append      port:python39
    configure.args-replace  -DENABLE_PYTHON_EXTENSION=False \
                            -DENABLE_PYTHON_EXTENSION=True
    configure.args-replace  -DENABLE_PYTHON_SCRIPTING=False \
                            -DENABLE_PYTHON_SCRIPTING=True
    configure.args-append   -DPython3_EXECUTABLE="${prefix}/bin/python3.9" \
                            -DPYHOOK_INSTALL_DIR="${frameworks_dir}/Python.framework/Versions/3.9/lib/python3.9/site-packages"
    configure.pkg_config_path \
                            "${frameworks_dir}/Python.framework/Versions/3.9/lib/pkgconfig"
}

variant python310 conflicts python37 python38 python39 python311 description {Enable Python support (Python 3.10)} {
    depends_lib-append      port:python310
    configure.args-replace  -DENABLE_PYTHON_EXTENSION=False \
                            -DENABLE_PYTHON_EXTENSION=True
    configure.args-replace  -DENABLE_PYTHON_SCRIPTING=False \
                            -DENABLE_PYTHON_SCRIPTING=True
    configure.args-append   -DPython3_EXECUTABLE="${prefix}/bin/python3.10" \
                            -DPYHOOK_INSTALL_DIR="${frameworks_dir}/Python.framework/Versions/3.10/lib/python3.10/site-packages"
    configure.pkg_config_path \
                            "${frameworks_dir}/Python.framework/Versions/3.10/lib/pkgconfig"
}

variant python311 conflicts python37 python38 python39 python310 description {Enable Python support (Python 3.11)} {
    depends_lib-append      port:python311
    configure.args-replace  -DENABLE_PYTHON_EXTENSION=False \
                            -DENABLE_PYTHON_EXTENSION=True
    configure.args-replace  -DENABLE_PYTHON_SCRIPTING=False \
                            -DENABLE_PYTHON_SCRIPTING=True
    configure.args-append   -DPython3_EXECUTABLE="${prefix}/bin/python3.11" \
                            -DPYHOOK_INSTALL_DIR="${frameworks_dir}/Python.framework/Versions/3.11/lib/python3.11/site-packages"
    configure.pkg_config_path \
                            "${frameworks_dir}/Python.framework/Versions/3.11/lib/pkgconfig"
}

variant gui description {Enable GUI support} {
    PortGroup               app 1.0

    depends_lib-append      path:lib/pkgconfig/gtk+-3.0.pc:gtk3
    configure.args-replace  -DENABLE_GUI=False -DENABLE_GUI=True
    app.name                FontForge
    app.icon                ${worksrcpath}/osx/FontForge.app/Contents/Resources/FontForge.icns
}

default_variants    +gui
if {![variant_isset python37] && ![variant_isset python38] && ![variant_isset python39] && ![variant_isset python310] && ![variant_isset python311]} {
    default_variants-append +python311
}
