aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen/font-file.xsl
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-06-28 07:52:54 +0000
committerKeiron Liddle <keiron@apache.org>2002-06-28 07:52:54 +0000
commit490de46b9eeca6cadf789acc45531f283e79fcbe (patch)
tree45877b06add37290cd33c8e831752caf6049505f /src/codegen/font-file.xsl
parent9091d3250a9551da1b6af7d3be363c491a6a2e0d (diff)
downloadxmlgraphics-fop-490de46b9eeca6cadf789acc45531f283e79fcbe.tar.gz
xmlgraphics-fop-490de46b9eeca6cadf789acc45531f283e79fcbe.zip
proper use of font encodings for native fonts
updated xalan Submitted by: Rainer Garus <rainer.garus@arcor.de> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194932 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/codegen/font-file.xsl')
-rw-r--r--src/codegen/font-file.xsl60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/codegen/font-file.xsl b/src/codegen/font-file.xsl
index 96a6f8583..7167c5b54 100644
--- a/src/codegen/font-file.xsl
+++ b/src/codegen/font-file.xsl
@@ -1,33 +1,30 @@
-<!--
-This files writes the class files for the fonts (Courier.java, Helvetica.java etc.).
-It uses the information in the font description files (Courier.xml, Helvetica.xml) to this
-In these font description files each character is referenced by its adobe name:
- <char name="A" width="667"/>
-To resolve this name and to find the code for this character it looks up the adobe name in the
-file charlist.xml and extracts the WinAnsi code.
--->
-
+<!-- This file writes the class files for the fonts (Courier.java,
+ Helvetica.java etc.). It uses the information in the font
+ description files (Courier.xml, Helvetica.xml) to do this. In these
+ font description files each character is referenced by its adobe
+ glyph name:
+ <char name="A" width="667"/>
+ To resolve this name and to find the code for this character it looks
+ up the adobe name in the file encodings.xml and extracts the appropriate
+ code. -->
<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:lxslt="http://xml.apache.org/xslt"
- xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
- extension-element-prefixes="redirect">
-<xsl:output method="text" />
-
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<!-- Note: this key is used with charlist.xml in a for-each. -->
-<xsl:key name="adobe-char-map" match="map" use="@adobe-name"/>
+ <xsl:output method="text"/>
+
+ <xsl:param name="encoding" select="/font-metrics/encoding"/>
+ <xsl:variable name="native-encoding" select="/font-metrics/encoding"/>
+ <xsl:variable name="glyphs" select="document('encodings.xml')/encoding-set/encoding[@id=$encoding]/glyph"/>
-<xsl:template match="font-metrics">
-<xsl:variable name="class-name" select="class-name"/>
-<!--<redirect:write select="concat('org/apache/fop/render/pdf/fonts/', $class-name, '.java')">-->
+ <xsl:template match="font-metrics">
package org.apache.fop.render.pdf.fonts;
import org.apache.fop.render.pdf.Font;
+import org.apache.fop.render.pdf.CodePointMapping;
public class <xsl:value-of select="class-name"/> extends Font {
private final static String fontName = "<xsl:value-of select="font-name"/>";
- private final static String encoding = "<xsl:value-of select="encoding"/>";
+ private final static String encoding = <xsl:choose><xsl:when test="$encoding != $native-encoding">"<xsl:value-of select="$encoding"/>"</xsl:when><xsl:otherwise>null</xsl:otherwise></xsl:choose>;
private final static int capHeight = <xsl:value-of select="cap-height"/>;
private final static int xHeight = <xsl:value-of select="x-height"/>;
private final static int ascender = <xsl:value-of select="ascender"/>;
@@ -35,13 +32,12 @@ public class <xsl:value-of select="class-name"/> extends Font {
private final static int firstChar = <xsl:value-of select="first-char"/>;
private final static int lastChar = <xsl:value-of select="last-char"/>;
private final static int[] width;
+ private final CodePointMapping mapping
+ = CodePointMapping.getMapping("<xsl:value-of select="$encoding"/>");
static {
width = new int[256];
-<xsl:for-each select="widths/char"><xsl:variable name="char-name" select="@name"/><xsl:variable name="char-width" select="@width"/>
-<xsl:for-each select="document('charlist.xml')"><xsl:variable name="char-num" select="key('adobe-char-map',$char-name)/@win-ansi"/>
-<xsl:if test="$char-num!='-1'"> width[<xsl:value-of select="$char-num"/>] = <xsl:value-of select="$char-width"/>;
-</xsl:if></xsl:for-each></xsl:for-each>
+ <xsl:apply-templates select="widths"/>
}
public String encoding() {
@@ -86,8 +82,18 @@ public class <xsl:value-of select="class-name"/> extends Font {
for( int i = 0; i &lt; arr.length; i++) arr[i] *= size;
return arr;
}
+
+ public char mapChar(char c) {
+ char d = mapping.mapChar(c);
+ if(d != 0)
+ return d;
+ else
+ return '#';
+ }
+
}
-<!--</redirect:write>-->
-</xsl:template>
+ </xsl:template>
+
+ <xsl:template match="widths/char"><xsl:variable name="char-name" select="@name"/><xsl:variable name="char-num" select="$glyphs[@name = $char-name]/@codepoint"/><xsl:if test="$char-num!=''"> width[0x<xsl:value-of select="$char-num"/>] = <xsl:value-of select="@width"/>;</xsl:if></xsl:template>
</xsl:stylesheet>