pbwest 2003/07/05 13:20:23 Modified: src/codegen Tag: FOP_0-20-0_Alt-Design font-file.xsl Log: Added the licence and its inclusion in the generated file. Revision Changes Path No revision No revision 1.8.4.1 +114 -35 xml-fop/src/codegen/font-file.xsl Index: font-file.xsl =================================================================== RCS file: /home/cvs/xml-fop/src/codegen/font-file.xsl,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -u -r1.8 -r1.8.4.1 --- font-file.xsl 16 Nov 2000 19:19:25 -0000 1.8 +++ font-file.xsl 5 Jul 2003 20:20:23 -0000 1.8.4.1 @@ -1,33 +1,88 @@ -<!-- -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. ---> - +<?xml version="1.0" encoding="iso-8859-1"?> <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" /> - -<!-- note that match in xsl:key doesn't like document('charlist.xml'), so the charlist - must be merged with the source xml at build time by the Xslt task --> -<xsl:key name="adobe-char-map" match="/font-metrics/font-mappings/map" use="@adobe-name"/> - -<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')">--> -package org.apache.fop.render.pdf.fonts; + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -import org.apache.fop.render.pdf.Font; + <xsl:output method="text"/> + <xsl:variable name="licence"><![CDATA[/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <[EMAIL PROTECTED]>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + * + *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Automatically generated by font-file.xsl. DO NOT EDIT! + *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */]]> + </xsl:variable> +<!-- 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: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/[EMAIL PROTECTED]/glyph"/> + + <xsl:template match="font-metrics"> + <xsl:value-of select="$licence"/> +package org.apache.fop.fonts.base14; + +import org.apache.fop.fonts.FontType; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.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,19 +90,24 @@ 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-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="@width"/>; -</xsl:if></xsl:for-each> + <xsl:apply-templates select="widths"/> } - public String encoding() { + public String getEncoding() { return encoding; } + + public String getFontName() { + return fontName; + } - public String fontName() { - return fontName; + public FontType getFontType() { + return FontType.TYPE1; } public int getAscender(int size) { @@ -74,18 +134,37 @@ return lastChar; } - public int width(int i,int size) { + public int getWidth(int i,int size) { return size * width[i]; } - public int[] getWidths(int size) { + public int[] getWidths() { int[] arr = new int[getLastChar()-getFirstChar()+1]; System.arraycopy(width, getFirstChar(), arr, 0, getLastChar()-getFirstChar()+1); - for( int i = 0; i < arr.length; i++) arr[i] *= size; + //for( int i = 0; i < arr.length; i++) arr[i] *= size; return arr; } + + public boolean hasKerningInfo() { + return false; + } + + public java.util.Map getKerningInfo() { + return java.util.Collections.EMPTY_MAP; + } + + 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="[EMAIL PROTECTED] = $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>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]