summaryrefslogtreecommitdiff
path: root/app-text/fop-corefonts-metrics/files/config.xsl
Unidiff
Diffstat (limited to 'app-text/fop-corefonts-metrics/files/config.xsl') (more/less context) (ignore whitespace changes)
-rw-r--r--app-text/fop-corefonts-metrics/files/config.xsl71
1 files changed, 71 insertions, 0 deletions
diff --git a/app-text/fop-corefonts-metrics/files/config.xsl b/app-text/fop-corefonts-metrics/files/config.xsl
new file mode 100644
index 0000000..0d3eae3
--- a/dev/null
+++ b/app-text/fop-corefonts-metrics/files/config.xsl
@@ -0,0 +1,71 @@
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
4
5 <xsl:output
6 method="xml" version="1.0"
7 encoding="utf-8"
8 indent="yes"
9 omit-xml-declaration="yes"
10 media-type="text/xml" />
11
12 <xsl:param name="ttfdir"/>
13 <xsl:param name="xmldir"/>
14 <xsl:param name="destdir"/>
15 <xsl:param name="aliasfile"/>
16
17 <xsl:variable name="aliases" select="document($aliasfile)"/>
18
19 <xsl:template match="/">
20 <configuration>
21 <fonts>
22 <xsl:apply-templates select="/fonts"/>
23 </fonts>
24 </configuration>
25 </xsl:template>
26
27 <xsl:template match="font">
28 <xsl:variable name="x" select="document(concat($xmldir,'/',@name,'.xml'))"/>
29 <xsl:variable name="fn" select="$x/font-metrics/font-name"/>
30 <xsl:comment>font-name: <xsl:value-of select="$fn"/></xsl:comment>
31 <font metrics-file="{$destdir}/{@name}.xml" kerning="yes" embed-file="{$ttfdir}/{@name}.ttf">
32 <xsl:variable name="n"><!-- font name -->
33 <xsl:choose>
34 <xsl:when test="contains($fn,',')">
35 <xsl:value-of select="substring-before($fn,',')"/>
36 </xsl:when>
37 <xsl:when test="$fn">
38 <xsl:value-of select="$fn"/>
39 </xsl:when>
40 <xsl:otherwise>
41 <xsl:value-of select="@name"/>
42 </xsl:otherwise>
43 </xsl:choose>
44 </xsl:variable>
45 <xsl:variable name="a"><!-- attributes -->
46 <xsl:if test="contains($fn,',')">
47 <xsl:value-of select="substring-after($fn,',')"/>
48 </xsl:if>
49 </xsl:variable>
50 <xsl:variable name="style">
51 <xsl:choose>
52 <xsl:when test="contains($a,'Italic')">italic</xsl:when>
53 <xsl:otherwise>normal</xsl:otherwise>
54 </xsl:choose>
55 </xsl:variable>
56 <xsl:variable name="weight">
57 <xsl:choose>
58 <xsl:when test="contains($a,'Bold')">bold</xsl:when>
59 <xsl:otherwise>normal</xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62 <xsl:variable name="nn" select="@name"/>
63 <xsl:for-each select="$aliases/fonts/font[@name=$n or @name=$nn]/alias[text()!=$n and text()!=$nn]">
64 <font-triplet name="{./text()}" style="{$style}" weight="{$weight}"/>
65 </xsl:for-each>
66 <font-triplet name="{$n}" style="{$style}" weight="{$weight}"/>
67 <font-triplet name="{@name}" style="normal" weight="normal"/>
68 </font>
69 </xsl:template>
70
71</xsl:stylesheet>