# -*- 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
# $Id: Portfile 68052 2010-05-25 18:16:42Z ryandesign@macports.org $

PortSystem      1.0

name            fontforge
version         20100501
set docversion  20100429
set ftversion   2.3.12
categories      graphics fonts
platforms       darwin
maintainers     nomaintainer
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        http://fontforge.sourceforge.net/
master_sites    sourceforge \
                ${homepage}:cidmaps \
                http://download.savannah.gnu.org/releases/freetype/:freetype \
                sourceforge:freetype:freetype
distname        ${name}_full-${version}
dist_subdir     ${name}/${version}_0
use_bzip2       yes

set docdistname ${name}_htdocs-${docversion}

distfiles-append \
    cidmaps.tgz:cidmaps \
    [suffix ${docdistname}]

patchfiles      patch-Makefile.dynamic.in.diff \
                patch-fontforge_start.c.diff \
                patch-gutils_dynamic.c.diff \
                patch-configure.in.diff

checksums       [suffix ${distname}] \
                md5     5f3d20d645ec1aa2b7b4876386df8717 \
                sha1    483425116c6af6ad90e37f9ada0c28e34f251ec3 \
                rmd160  4dee2ecdbd32bf3854105f195984d9cabf198fd8 \
                cidmaps.tgz \
                md5     063691163e592515b31514515bb3ce8c \
                sha1    efbc7c9d3e95159f5600dc71f9cccb370e46bb94 \
                rmd160  d194355e61813d31fe4813bdf10a62d66a9f6d04 \
                [suffix ${docdistname}] \
                md5     7ff67bcb694b673dbe0b8ca3dfd4675e \
                sha1    eeda060ad5e83392d1a27f6c9c1eac2a9c780c09 \
                rmd160  f1dedf39898d12398ffe463c06ebcb5d88fb575b \
                [suffix freetype-${ftversion}] \
                md5     e974a82e5939be8e05ee65f07275d7c5 \
                sha1    ebf0438429c0bedd310059326d91646c3c91016b \
                rmd160  57437a2bc0d85859cff2ca1253b36e64629397a1

worksrcdir      ${name}-${version}

extract.only    [suffix ${distname}]

post-extract {
    xinstall -d \
        ${worksrcpath}/cidmap \
        ${worksrcpath}/htdocs

    system "tar xzf ${distpath}/cidmaps.tgz -C ${worksrcpath}/cidmap"
    system "tar xjf ${distpath}/[suffix ${docdistname}] -C ${worksrcpath}/htdocs"
}

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" \
        ${worksrcpath}/gutils/dynamic.c
    reinplace "/^applicationsdir/s|/Applications|${applications_dir}|" \
        ${worksrcpath}/Makefile.dynamic.in
}

depends_lib \
                port:xorg-libXi \
                port:xorg-libxkbui \
                port:xorg-libXt \
                port:freetype \
                port:gettext \
                port:giflib \
                port:jpeg \
                port:libiconv \
                port:libpng \
                port:libuninameslist \
                port:libxml2 \
                port:tiff \
                port:zlib

use_autoconf    yes

configure.args  --mandir=${prefix}/share/man \
                --enable-type3 \
                --enable-devicetables \
                --enable-gb12345 \
                --without-python \
                --without-freetype-bytecode \
                --without-pango \
                --without-cairo \
                --x-includes=${prefix}/include \
                --x-libraries=${prefix}/lib

configure.ldflags-append -lintl

use_parallel_build  yes

set docdir      ${prefix}/share/doc/${name}

destroot.args   docdir=${docdir}

post-destroot {
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS INSTALL LICENSE README-Mac.html README-Unix.html README-unix \
        ${destroot}${docdir}
}

variant with_freetype_bytecode description {Enable support for bytecode interpreter} {
    distfiles-append        freetype-${ftversion}${extract.suffix}:freetype
    extract.only-append     freetype-${ftversion}${extract.suffix}
    configure.args-delete   --without-freetype-bytecode
    configure.args-append   --with-freetype-src=${workpath}/freetype-${ftversion}
}

livecheck.distname  ${name}-source

universal_variant   no
