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

PortSystem          1.0
PortGroup           active_variants 1.1
PortGroup           cmake 1.1
PortGroup           github 1.0

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # Until this is fixed: https://github.com/fontmatrix/fontmatrix/issues/40
    PortGroup       qt4 1.0

    github.setup    fontmatrix fontmatrix 55f688aafb7c07899fade13dd8d8ec8663127e35
    version         0.9.99
    revision        1
    checksums       rmd160  83f9f59d99d605f76447e0387843c1c40f4205e0 \
                    sha256  f83775ef559712390a8784f53fc136359230364fded07c1a517cb0327f9818da \
                    size    2111845
    github.tarball_from archive
} else {
    PortGroup       qt5 1.0

    github.setup    fontmatrix fontmatrix 0.9.100 v
    revision        1
    checksums       rmd160  b8169f49a6b8c647fbe2f773c6043dd75c4768c6 \
                    sha256  241021e24b0e2cdbc4bdf516d41ddfd23675a5a098bdaa0f7564d866cd292659 \
                    size    2113983
    github.tarball_from archive

    qt5.depends_component qtlocation qttools qttranslations qtwebkit

    # Some menus may not display correctly with dark mode:
    # https://github.com/fontmatrix/fontmatrix/issues/42

    # The port requires qtlocation, and that may fail to build with rapidjson-devel.
    # https://trac.macports.org/ticket/68508
}

categories          sysutils print
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         Free font collections manager
long_description    Fontmatrix is a font management application for Linux, macOS and Windows. \
                    It helps keeping your font collection in order, allowing you to enable and disable \
                    availability of fonts and font families in your system. This is typically in demand \
                    by designers who tend to have huge collections of typefaces.
license             GPL-2+

# https://github.com/fontmatrix/fontmatrix/issues/39
patchfiles-append   0001-CMakeLists-do-not-force-i386.patch

# Does not build at the moment with our harfbuzz:
# https://github.com/fontmatrix/fontmatrix/issues/41

set py_ver          3.11
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    port:python${py_ver_nodot}
depends_lib-append  port:freetype \
                    path:lib/pkgconfig/icu-uc.pc:icu

configure.python    ${prefix}/bin/python${py_ver}

destroot {
    move ${cmake.build_dir}/src/${name}.app ${destroot}${applications_dir}/${name}.app
}