Index: .
===================================================================
diff --git a/trunk/dports/print/freetype/Portfile b/trunk/dports/print/freetype/Portfile
--- a/trunk/dports/print/freetype/Portfile	(revision 131791)
+++ b/trunk/dports/print/freetype/Portfile	(working copy)
@@ -2,106 +2,187 @@
 # $Id$
 
 PortSystem              1.0
-PortGroup               muniversal 1.0
 
 name                    freetype
-version                 2.5.5
+
+subport "${name}-infinality" {
+    # sadly we need to provide a senseless univ. variant because
+    # freetype +infinality+universal would require it.
+    #universal_variant   no
+    #variant universal description {this is a stub variant for dependency reasons only} {
+    #}
+    supported_archs     noarch
+}
+
 categories              print graphics
-maintainers             ryandesign
-license                 {FreeType GPL-2}
-homepage                http://freetype.sourceforge.net/
-use_bzip2               yes
 platforms               darwin
-use_parallel_build      yes
 
-description \
-    A software font engine
+if {${subport} eq "${name}-infinality"} {
+    version             2015.01.31
+    maintainers         gmail.com:rjvbertin
+    license             MIT
+    homepage            http://bohoomil.com
+    description         The Freetype Infinality patches
+    long_description    This is a s(t)ub port providing versioning information \
+                        for the Infinality patches maintained by Bohoomil and that \
+                        are available through freetype's +infinality variant.
+    distfiles
+    use_configure       no
+    # this appears to be required despite an empty build block!
+    build.cmd           echo
+    fetch {}
+    checksum {}
+    extract {
+        xinstall -m 0755 -d ${worksrcpath}
+    }
+    patch {}
+    post-patch {}
+    configure {}
+    build {}
+    post-destroot {
+        xinstall -m 0755 -d ${destroot}${prefix}/share/fonts/fontconfig-ultimate
+        foreach f [glob ${filespath}/infinality-settings*] {
+            copy ${f} ${destroot}${prefix}/share/fonts/fontconfig-ultimate
+        }
+        xinstall -m 0755 ${filespath}/launchctl-infinality-settings.sh ${destroot}${prefix}/share/fonts/fontconfig-ultimate
+        xinstall -m 0644 ${filespath}/Infinality-CHANGELOG ${destroot}${prefix}/share/fonts/fontconfig-ultimate
+    }
+    notes-append "freetype must be now be (re)build and (re)installed with the +infinality variant."
 
-long_description \
-    FreeType2 is a software font engine that is designed to \
-    be small, efficient, highly customizable and portable while \
-    capable of producing high-quality output (glyph images). \
-    It can be used in graphics libraries, display servers, font \
-    conversion tools, text image generation tools, and many \
-    other products as well.
+} else {
+    PortGroup               muniversal 1.0
 
-master_sites            sourceforge:project/freetype/freetype2/${version}:source \
-                        sourceforge:project/freetype/freetype-docs/${version}:docs \
-                        http://download.savannah.gnu.org/releases/freetype/
+    version                 2.5.5
+    maintainers             ryandesign
+    license                 {FreeType GPL-2}
+    homepage                http://freetype.sourceforge.net/
+    use_bzip2               yes
 
-set docdistname         ${name}-doc-${version}
+    description \
+        A software font engine
 
-distfiles               ${distname}${extract.suffix}:source \
-                        ${docdistname}${extract.suffix}:docs
+    long_description \
+        FreeType2 is a software font engine that is designed to \
+        be small, efficient, highly customisable and portable while \
+        capable of producing high-quality output (glyph images). \
+        It can be used in graphics libraries, display servers, font \
+        conversion tools, text image generation tools, and many \
+        other products as well.
 
-checksums               ${distname}${extract.suffix} \
-                        rmd160  49093b839e6cc0639383d6baacfb73da80a4ee1a \
-                        sha256  387bcc4b780b12484aa2ec9f7db1a55d8286eb5639f45fbc0fbba7a4e5a1afb9 \
-                        ${docdistname}${extract.suffix} \
-                        rmd160  59309bbd1cced9e982c327b8217329d64b69d649 \
-                        sha256  68becbae3578a8101e9f3c55f10e435fb75535011d3f7a523719371e86e368e7
 
-patchfiles \
-    patch-src_base_ftrfork.c.diff \
-    patch-modules.cfg.diff
+    use_parallel_build      yes
 
-depends_lib             port:bzip2 \
-                        port:libpng \
-                        port:zlib
+    master_sites            sourceforge:project/freetype/freetype2/${version}:source \
+                            sourceforge:project/freetype/freetype-docs/${version}:docs \
+                            http://download.savannah.gnu.org/releases/freetype/
 
+    set docdistname         ${name}-doc-${version}
+
+    distfiles               ${distname}${extract.suffix}:source \
+                            ${docdistname}${extract.suffix}:docs
+
+    checksums               freetype-${version}.tar.bz2 \
+                            rmd160  49093b839e6cc0639383d6baacfb73da80a4ee1a \
+                            sha256  387bcc4b780b12484aa2ec9f7db1a55d8286eb5639f45fbc0fbba7a4e5a1afb9 \
+                            freetype-doc-${version}.tar.bz2 \
+                            rmd160  59309bbd1cced9e982c327b8217329d64b69d649 \
+                            sha256  68becbae3578a8101e9f3c55f10e435fb75535011d3f7a523719371e86e368e7
+
+    patchfiles              patch-src_base_ftrfork.c.diff \
+                            patch-modules.cfg.diff
+
+    depends_lib             port:bzip2 \
+                            port:libpng \
+                            port:zlib
+
 # See http://trac.macports.org/ticket/18232
-configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include
+    configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include
 
-configure.args          --with-bzip2 \
-                        --with-png \
-                        --with-zlib \
-                        --without-harfbuzz
+    configure.args          --with-bzip2 \
+                            --with-png \
+                            --with-zlib \
+                            --without-harfbuzz
 
-configure.universal_args-delete --disable-dependency-tracking
+    configure.universal_args-delete --disable-dependency-tracking
 
-platform macosx {
-    if {${os.major} < 9} {
-        configure.args-append \
-            --with-old-mac-fonts
+    platform macosx {
+        if {${os.major} < 9} {
+            configure.args-append \
+                --with-old-mac-fonts
+        }
     }
-}
 
-set docdir              ${prefix}/share/doc/${name}
+    set docdir              ${prefix}/share/doc/${name}
 
-post-destroot {
-    xinstall -m 0755 -d ${destroot}${docdir}
-    
-    xinstall -m 0644 -W ${worksrcpath} \
-        ChangeLog \
-        README \
-        ${destroot}${docdir}
-    xinstall -m 0644 -W ${worksrcpath}/docs \
-        CHANGES \
-        FTL.TXT \
-        GPLv2.TXT \
-        LICENSE.TXT \
-        PROBLEMS \
-        TODO \
-        formats.txt \
-        raster.txt \
-        ${destroot}${docdir}
-    
-    xinstall -m 0755 -d ${destroot}${docdir}/html
-    xinstall -m 0644 -W ${worksrcpath}/docs ft2faq.html ${destroot}${docdir}/html
-    foreach dir {design glyphs reference tutorial} {
-        copy ${worksrcpath}/docs/${dir} ${destroot}${docdir}/html
+    if {[file exists ${prefix}/share/fonts/fontconfig-ultimate/infinality-settings.sh]} {
+        default_variants    +infinality
     }
-}
 
-if {${os.arch} eq "i386"} {
-    if { ${os.major}>=10 } {
-        set merger_configure_env(ppc) CC_BUILD=${configure.cc}
+    variant infinality description {patched for improved font rendering, bohoomil ultimate style} {
+
+        depends_run-append  port:${name}-infinality
+
+        # 20150118: remove the 2nd hunk from freetype-2.5.x-enable-valid.patch because already done by patch-modules-cfg.diff
+        patchfiles-append           01-freetype-2.5.5-enable-valid.patch \
+                                    02-ftsmooth-2.5.5.patch \
+                                    03-upstream-2015.01.23.patch \
+                                    04-infinality-2.5.5-2015.01.23.patch
+# 03-upstream-2015.01.23.patch contains a byte sequence that reinplace doesn't like ...
+#        pre-patch {
+#            # make -p0 patches
+#            set pf [split ${patchfiles} " "]
+#            foreach f ${pf} {
+#                reinplace -W ${filespath} "s| \[ab\]/| |g" ${f}
+#            }
+#        }
+        configure.args-replace --without-harfbuzz --with-harfbuzz
+        depends_lib-append    port:harfbuzz
+
+        notes-append "Copy ${prefix}/share/fonts/fontconfig-ultimate/infinality-settings.sh (or .csh) to an appropriate location
+         and make sure it gets read when you log in. See infinality-settings-explained.sh for explanation
+         of the various settings and variables. Then, use launchctl-infinality-settings.sh to copy the
+         selected environment variables to those managed by LaunchServices"
     }
-    set merger_configure_env(ppc64)   CC_BUILD=${configure.cc}
-} else {
-    set merger_configure_env(i386)    CC_BUILD=${configure.cc}
-    set merger_configure_env(x86_64)  CC_BUILD=${configure.cc}
+
+    post-destroot {
+        xinstall -m 0755 -d ${destroot}${docdir}
+        
+        xinstall -m 0644 -W ${worksrcpath} \
+            ChangeLog \
+            README \
+            ${destroot}${docdir}
+        xinstall -m 0644 -W ${worksrcpath}/docs \
+            CHANGES \
+            FTL.TXT \
+            GPLv2.TXT \
+            LICENSE.TXT \
+            PROBLEMS \
+            TODO \
+            formats.txt \
+            raster.txt \
+            ${destroot}${docdir}
+        
+        xinstall -m 0755 -d ${destroot}${docdir}/html
+        xinstall -m 0644 -W ${worksrcpath}/docs ft2faq.html ${destroot}${docdir}/html
+        foreach dir {design glyphs reference tutorial} {
+            copy ${worksrcpath}/docs/${dir} ${destroot}${docdir}/html
+        }
+        if {[variant_isset infinality]} {
+            ln -s ${prefix}/share/fonts/fontconfig-ultimate/launchctl-infinality-settings.sh ${destroot}${prefix}/bin
+        }
+    }
+
+    if {${os.arch} eq "i386"} {
+        if { ${os.major}>=10 } {
+            set merger_configure_env(ppc) CC_BUILD=${configure.cc}
+        }
+        set merger_configure_env(ppc64)   CC_BUILD=${configure.cc}
+    } else {
+        set merger_configure_env(i386)    CC_BUILD=${configure.cc}
+        set merger_configure_env(x86_64)  CC_BUILD=${configure.cc}
+    }
+
+    livecheck.type          sourceforge
+    livecheck.regex         {/freetype2/([0-9.]+)/}
+
 }
-
-livecheck.type          sourceforge
-livecheck.regex         {/freetype2/([0-9.]+)/}
