nixpkgs/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl
Vladimír Čunát b16994f7ce fontconfig: stop using xml:space; vital for nixos+2.11
This is a proper fix for problems described in ec985c8ffa .
The code is from @lethalman.
2014-09-28 16:57:47 +02:00

52 lines
1.5 KiB
XML

<?xml version="1.0"?>
<!--
This script copies the original fonts.conf from the fontconfig
distribution, but replaces all <dir> entries with the directories
specified in the $fontDirectories parameter.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str"
>
<xsl:output method='xml' encoding="UTF-8" doctype-system="fonts.dtd" />
<xsl:param name="fontDirectories" />
<xsl:param name="fontconfig" />
<xsl:template match="/fontconfig">
<fontconfig>
<xsl:apply-templates select="child::node()[name() != 'dir' and name() != 'cachedir' and name() != 'include']" />
<include ignore_missing="yes">/etc/fonts/conf.d</include>
<include><xsl:value-of select="$fontconfig" />/etc/fonts/conf.d</include>
<cachedir>/var/cache/fontconfig</cachedir>
<cachedir>~/.fontconfig</cachedir>
<xsl:for-each select="str:tokenize($fontDirectories)">
<dir><xsl:value-of select="." /></dir>
<xsl:text>&#0010;</xsl:text>
</xsl:for-each>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>
</fontconfig>
</xsl:template>
<!-- New fontconfig >=2.11 doesn't like xml:space added by xsl:copy-of -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*[name() != 'xml:space']"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>