You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by fo...@apache.org on 2001/02/27 13:30:36 UTC

cvs commit: xml-fop/src/org/apache/fop/render/pdf/fonts BFEntry.java MultiByteFont.java SingleByteFont.java

fotis       01/02/27 04:30:36

  Added:       src/org/apache/fop/configuration FontInfo.java
                        FontTriplet.java
               src/org/apache/fop/render/pdf CIDFont.java CMap.java
                        FontReader.java
               src/org/apache/fop/render/pdf/fonts BFEntry.java
                        MultiByteFont.java SingleByteFont.java
  Log:
  enabling CID keyed truetype fonts; this gives support
           for other encodings than WinAnsiEncoding (eg japanese, chinese, arabic,
           iso-whatever, etc). Also makes font inclusion easier Tore Engvig
  
  Revision  Changes    Path
  1.1                  xml-fop/src/org/apache/fop/configuration/FontInfo.java
  
  Index: FontInfo.java
  ===================================================================
  /*
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources."
   */
  
  
  package org.apache.fop.configuration;
  
  import java.util.Vector;
  
  /**
   * FontInfo contains meta information on fonts (where is the metrics file etc.)
   */
  
  public class FontInfo {
      private String metricsFile, embedFile, name;
      private boolean kerning;
      private Vector fontTriplets;
  
      public FontInfo (String name, String metricsFile, boolean kerning,
                       Vector fontTriplets, String embedFile) {
          this.name = name;
          this.metricsFile = metricsFile;
          this.embedFile = embedFile;
          this.kerning = kerning;
          this.fontTriplets = fontTriplets;
      }
  
      public String getMetricsFile() {
          return metricsFile;
      }
      public String getEmbedFile() {
          return embedFile;
      }
      public boolean getKerning() {
          return kerning;
      }
      public Vector getFontTriplets() {
          return fontTriplets;
      }
  
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/configuration/FontTriplet.java
  
  Index: FontTriplet.java
  ===================================================================
  /*
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources."
   */
  
  
  package org.apache.fop.configuration;
  
  /**
   * FontTriplet contains information on name, weight, style of one font
   */
  
  
  public class FontTriplet {
      private String name, weight, style;
      public FontTriplet(String name, String weight, String style) {
          this.name = name;
          this.weight = weight;
          this.style = style;
      }
  
      public String getName() {
          return name;
      }
  
      public String getWeight() {
          return weight;
      }
  
      public String getStyle() {
          return style;
      }
  
  }
  
  
  
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/CIDFont.java
  
  Index: CIDFont.java
  ===================================================================
  package org.apache.fop.render.pdf;
  
  import org.apache.fop.pdf.PDFWArray;
  
  public abstract class CIDFont extends Font {
  
  	// Required
  	public abstract String getCidBaseFont();
  	public abstract byte getCidType();
  	public abstract String getCharEncoding();
  	public abstract String getRegistry();
  	public abstract String getOrdering();
  	public abstract int getSupplement();
  	// Optional
  	public int getDefaultWidth() { return 0; }
  	public PDFWArray getWidths() { return null; }
  	// public int getWinCharSet() { return 0; }
  
  	// Need For FOP
  
  	/**
  	 *Returns CMap Object .
  	 *<p>
  	 *If this method does not return null , the mapping from character codes
  	 *to a font number is performed in FOP . When the getCidType() method
  	 *returns CIDFontType2 , this method must not return null .
  	 */
  	public CMap getCMap() { return null; }
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/CMap.java
  
  Index: CMap.java
  ===================================================================
  /*-- $Id: CMap.java,v 1.1 2001/02/27 12:30:36 fotis Exp $ --
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
      Copyright (C) 1999 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
      apache@apache.org.
  
   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 <jt...@jtauber.com>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
   */
  package org.apache.fop.render.pdf;
  
  public interface CMap {
  	public abstract char mapping(char ch);
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/FontReader.java
  
  Index: FontReader.java
  ===================================================================
  /*-- $Id: FontReader.java,v 1.1 2001/02/27 12:30:36 fotis Exp $ -- 
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
      Copyright (C) 1999 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
      apache@apache.org.
   
   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 <jt...@jtauber.com>. For more  information on the Apache 
   Software Foundation, please see <http://www.apache.org/>.
   
   */
  
  package org.apache.fop.render.pdf;
  import org.apache.fop.render.pdf.fonts.*;
  import org.xml.sax.helpers.DefaultHandler;
  import org.xml.sax.XMLReader;
  import org.xml.sax.SAXException;
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.Attributes;
  import java.io.IOException;
  import java.util.Enumeration;
  import java.util.Vector;
  import java.util.Hashtable;
  import org.apache.fop.pdf.PDFWArray;
  import org.apache.fop.pdf.PDFCIDFont;
  import org.apache.fop.configuration.ConfigurationReader;
  
  /**
   * Class for reading a metric.xml file and creating a font object.
   * Typical usage:
   <pre>
   FontReader reader = new FontReader(<path til metrics.xml>);
   reader.setFontEmbedPath(<path to a .ttf or .pfb file or null to diable embedding>);
   reader.useKerning(true);
   Font f = reader.getFont();
   </pre>
  */
  public class FontReader extends DefaultHandler {
      private Locator locator = null;
      private boolean isCID = false;
      private MultiByteFont multiFont = null;
      private SingleByteFont singleFont = null;
      private Font returnFont = null;
          //private SingleByteFont singleFont = null;
      private String text = null;
  
      private Vector cidWidths = null;
      private int cidWidthIndex = 0;
  
      private Hashtable currentKerning = null;
  
      private Vector bfranges = null;
      
      private void createFont(String path) throws IOException {
          XMLReader parser = ConfigurationReader.createParser();
          if (parser == null)
              throw new IOException("Unable to create SAX parser");
  
          try {
              parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
                                false);
          } catch (SAXException e) {
              throw new IOException ("You need a SAX parser which supports " +
                                     "SAX version 2");
          }
  
          parser.setContentHandler(this);
  
          try {
              parser.parse(path);
          } catch (SAXException e) {
              throw new IOException(e.getMessage());
          }
      }
  
          /**
           * Sets the path to embed a font. a null value disables font embedding
           */
      public void setFontEmbedPath(String path) {
          if (isCID)
              multiFont.embedFileName=path;
          else
              singleFont.embedFileName=path;
      }
      
          /**
           * Enable/disable use of kerning for the font
           */
      public void useKerning(boolean kern) {
          if (isCID)
              multiFont.useKerning = true;
          else
              singleFont.useKerning = true;
      }
      
          
          /**
           * Get the generated font object
           */
      public Font getFont() {
          return returnFont;
      }
  
          /**
           * Construct a FontReader object from a path to a metric.xml file
           * and read metric data
           */
      public FontReader(String path) throws IOException {
          createFont(path);
      }
  
      public void startDocument() {
      }
  
      public void setDocumentLocator(Locator locator) {
          this.locator = locator;
      }
  
      public void startElement(String uri, String localName,
                               String qName, Attributes attributes) {
          if (localName.equals("font-metrics")) {
              if ("TYPE0".equals(attributes.getValue("type"))) {
                  multiFont = new MultiByteFont();
                  returnFont = multiFont;
                  isCID = true;
              } else if ("TRUETYPE".equals(attributes.getValue("type"))) {
                  singleFont = new SingleByteFont();
                  singleFont.subType = org.apache.fop.pdf.PDFFont.TRUETYPE;
                  returnFont = singleFont;
                  isCID = false;
              } else {
                  singleFont = new SingleByteFont();
                  singleFont.subType = org.apache.fop.pdf.PDFFont.TYPE1;
                  returnFont = singleFont;
                  isCID = false;
              }
          } else if ("embed".equals(localName)) {
              if (isCID) {
                      // This *is* annoying... should create a common
                      // interface for sing/multibytefonts...
                  multiFont.embedFileName = attributes.getValue("file");
                  multiFont.embedResourceName = attributes.getValue("class");
              } else {
                  singleFont.embedFileName = attributes.getValue("file");
                  singleFont.embedResourceName = attributes.getValue("class");
              }   
          } else if ("cid-widths".equals(localName)) {
              cidWidthIndex = getInt(attributes.getValue("start-index"));
              cidWidths = new Vector();
          } else if ("kerning".equals(localName)) {
              currentKerning = new Hashtable();
              if (isCID)
                  multiFont.kerning.put(new Integer(attributes.getValue("kpx1")),
                                        currentKerning);
              else
                  singleFont.kerning.put(new Integer(attributes.getValue("kpx1")),
                                         currentKerning);
          } else if ("bfranges".equals(localName)) {
              bfranges = new Vector();
          } else if ("bf".equals(localName)) {
              BFEntry entry = new BFEntry();
              entry.unicodeStart = getInt(attributes.getValue("us"));
              entry.unicodeEnd = getInt(attributes.getValue("ue"));
              entry.glyphStartIndex = getInt(attributes.getValue("gi"));
              bfranges.addElement(entry);
          } else if ("wx".equals(localName)) {
              cidWidths.addElement(new Integer(attributes.getValue("w")));
          } else if ("widths".equals(localName)) {
              singleFont.width = new int[256];
          } else if ("char".equals(localName)) {
              try {
                  singleFont.width[Integer.parseInt(attributes.getValue("idx"))] =
                      Integer.parseInt(attributes.getValue("wdt"));
              } catch (NumberFormatException ne) {
                  System.out.println("Malformed width in metric file: " +
                                     ne.getMessage());
              }
          } else if ("pair".equals(localName)) {
              currentKerning.put(new Integer(attributes.getValue("kpx2")),
                                 new Integer(attributes.getValue("kern")));
          }
      }
  
      private int getInt(String str) {
          int ret = 0;
          try {
              ret = Integer.parseInt(str);
          } catch (Exception e) {}
          return ret;
      }
      
      public void endElement(String uri, String localName, String qName) {
          if ("font-name".equals(localName))
              if (isCID)
                  multiFont.fontName = text;
              else
                  singleFont.fontName = text;
          else if ("cap-height".equals(localName))
              if (isCID)
                  multiFont.capHeight = getInt(text);
              else
                  singleFont.capHeight = getInt(text);
          else if ("x-height".equals(localName))
              if (isCID)
                  multiFont.xHeight = getInt(text);
              else
                  singleFont.xHeight = getInt(text);
          else if ("ascender".equals(localName))
              if (isCID)
                  multiFont.ascender = getInt(text);
              else
                  singleFont.ascender = getInt(text);
          else if ("descender".equals(localName))
              if (isCID)
                  multiFont.descender = getInt(text);
              else
                  singleFont.descender = getInt(text);
          else if ("left".equals(localName))
              if (isCID)
                  multiFont.fontBBox[0] = getInt(text);
              else
                  singleFont.fontBBox[0] = getInt(text);
          else if ("bottom".equals(localName))
              if (isCID)
                  multiFont.fontBBox[1] = getInt(text);
              else
                  singleFont.fontBBox[1] = getInt(text);
          else if ("right".equals(localName))
              if (isCID)
                  multiFont.fontBBox[2] = getInt(text);
              else
                  singleFont.fontBBox[2] = getInt(text);
          else if ("first-char".equals(localName))
              singleFont.firstChar = getInt(text);
          else if ("last-char".equals(localName))
              singleFont.lastChar = getInt(text);
          else if ("top".equals(localName))
              if (isCID)
                  multiFont.fontBBox[3] = getInt(text);
              else
                  singleFont.fontBBox[3] = getInt(text);
          else if ("flags".equals(localName))
              if (isCID)
                  multiFont.flags = getInt(text);
              else
                  singleFont.flags = getInt(text);
          else if ("stemv".equals(localName))
              if (isCID)
                  multiFont.stemV = getInt(text);
              else
                  singleFont.stemV = getInt(text);
          else if ("italic-angle".equals(localName))
              if (isCID)
                  multiFont.italicAngle = getInt(text);
              else
                  singleFont.italicAngle = getInt(text);
          else if ("missing-width".equals(localName))
              if (isCID)
                  multiFont.missingWidth = getInt(text);
              else
                  singleFont.missingWidth = getInt(text);
          else if ("cid-type".equals(localName)) {
              if ("CIDFontType2".equals(text))
                  multiFont.cidType = PDFCIDFont.CID_TYPE2;
          } else if ("default-width".equals(localName)) {
              multiFont.defaultWidth = getInt(text);
          } else if ("cid-widths".equals(localName)) {
              int[] wds = new int[cidWidths.size()];
              int j = 0;
              for (Enumeration e = cidWidths.elements(); e.hasMoreElements();) {
                  Integer i = (Integer)e.nextElement();
                  wds[j++] = i.intValue();
              }
  
              multiFont.warray.addEntry(cidWidthIndex, wds);
              multiFont.width = wds;
              
          } else if ("bfranges".equals(localName)) {
              BFEntry[] entries = new BFEntry[bfranges.size()];
              bfranges.copyInto(entries);
              multiFont.bfentries = entries;
          }
  
      }
  
      public void characters(char[] ch, int start, int length) {
          char c[] = new char[length];
          System.arraycopy(ch, start, c, 0, length);
          text = new String(c);
      }
      
  }
  
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/fonts/BFEntry.java
  
  Index: BFEntry.java
  ===================================================================
  /*-- $Id: BFEntry.java,v 1.1 2001/02/27 12:30:36 fotis Exp $ -- 
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
      Copyright (C) 1999 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
      apache@apache.org.
   
   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 <jt...@jtauber.com>. For more  information on the Apache 
   Software Foundation, please see <http://www.apache.org/>.
   
   */
  
  package org.apache.fop.render.pdf.fonts;
  
  /**
   * This is just a holder class for bfentries - not get/put methods provided
   */
  public class BFEntry {
      public int unicodeStart;
      public int unicodeEnd;
      public int glyphStartIndex;
      
      public BFEntry() {
      }
  
      public BFEntry (int unicodeStart,
                      int unicodeEnd,
                      int glyphStartIndex) {
          this.unicodeStart = unicodeStart;
          this.unicodeEnd = unicodeEnd;
          this.glyphStartIndex = glyphStartIndex;
      }
      
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java
  
  Index: MultiByteFont.java
  ===================================================================
  
  
  package org.apache.fop.render.pdf.fonts;
  
  import org.apache.fop.render.pdf.Font;
  import org.apache.fop.layout.FontDescriptor;
  import org.apache.fop.fonts.Glyphs;
  import org.apache.fop.pdf.PDFStream;
  import org.apache.fop.pdf.PDFWArray;
  import org.apache.fop.pdf.PDFCIDFont;
  import org.apache.fop.render.pdf.CIDFont;
  import org.apache.fop.render.pdf.CMap;
  import org.apache.fop.pdf.PDFTTFStream;
  import java.io.InputStream;
  import java.io.FileInputStream;
  import java.io.File;
  import java.io.BufferedInputStream;
  import java.util.Hashtable;
  
  /**
   * Generic MultiByte (CID) font
   */
  public class MultiByteFont extends CIDFont implements FontDescriptor {
      public String fontName = null;
      public String encoding = "Identity-H";
      
      public int capHeight = 0;
      public int xHeight = 0;
      public int ascender = 0;
      public int descender = 0;
      public int[] fontBBox = {0, 0, 0, 0};
      
      public String embedFileName = null;
      public String embedResourceName = null;
      public PDFTTFStream embeddedFont=null;
      
      public int flags = 4;
      public int stemV = 0;
      public int italicAngle = 0;
      public int missingWidth = 0;
      public int defaultWidth = 0;
      public byte cidType = PDFCIDFont.CID_TYPE2;
      
      public Hashtable kerning=new Hashtable();
      public boolean useKerning = true;
      
      public PDFWArray warray=new PDFWArray();
      public int width[] = null;
  
      public BFEntry[] bfentries = null;
      
  
      public MultiByteFont() {}
      
      public final boolean hasKerningInfo() {
          return (useKerning & kerning.isEmpty());
      }
      public final java.util.Hashtable getKerningInfo() {return kerning;}
  
      public byte getSubType() {
          return org.apache.fop.pdf.PDFFont.TYPE0;
      }
  
      public String getLang() {return null;}
      public String getPanose() {return null;}
      public int getAvgWidth() {return -1;}
      public int getMinWidth() {return -1;}
      public int getMaxWidth() {return -1;}
      public int getleading() {return -1;}
      public int getStemH() {return 0;}
      public int getMissingWidth() {return missingWidth;}
      public int getDefaultWidth() {return defaultWidth;}
      public String getRegistry() {return "Adobe";}
      public String getOrdering() {return "UCS";}
      public int getSupplement() {return 0;}
      public byte getCidType() {return cidType;}
      public String getCidBaseFont() {return fontName;}
      public String getCharEncoding() {return "Identity-H";}
  
      public PDFWArray getWidths() {
          return warray;
      }
  
      public boolean isEmbeddable() {
          return (embedFileName==null && embedResourceName==null) ? false : true;
      }
  
      
      public PDFStream getFontFile(int i) {
          InputStream instream=null;
  
          int iniSize = 256000;
          int incSize = 128000;
          // Get file first
          if (embedFileName!=null)
          try {
              File ef = new File(embedFileName);
              iniSize = (int)ef.length()+1;
              incSize = (int)ef.length()/10;
             instream=new FileInputStream(embedFileName);
          } catch (Exception e) {
             System.out.println("Failed to embed fontfile: "+embedFileName);
          }
     
          // Get resource
          if (instream==null && embedResourceName!=null)
          try {
             instream=new BufferedInputStream(this.getClass().getResourceAsStream(embedResourceName));
          } catch (Exception e) {
             System.out.println("Failed to embed fontresource: "+embedResourceName);
          }
          
          if (instream==null)
              return (PDFStream)null;
          
          // Read fontdata
          byte[] file = new byte[iniSize];
          int fsize = 0;
  
          try {
            int l = instream.read(file, 0, iniSize);
            fsize += l;
        
            if (l==iniSize) {
                   // More to read - needs to extend
               byte[] tmpbuf;
           
               while (l > 0) {
                   tmpbuf = new byte[file.length + incSize];
                   System.arraycopy(file, 0, tmpbuf, 0, file.length);
                   l=instream.read(tmpbuf, file.length, incSize);
                   fsize += l;
                   file = tmpbuf;
              
                   if (l < incSize) // whole file read. No need to loop again
                      l=0;
               }
            }
  
                // Only TrueType CID fonts are supported now
            embeddedFont=new PDFTTFStream(i, fsize);
            embeddedFont.addFilter("flate");
            embeddedFont.addFilter("ascii-85");
            embeddedFont.setData(file, fsize);
            instream.close();
          } catch (Exception e) {}  
  
          return (PDFStream) embeddedFont;
      }
      
      public String encoding() {
          return encoding;
      }
      
      public String fontName() {
          return fontName;
      }
  
      public int getAscender() {return ascender;}
      public int getDescender() {return descender;}
      public int getCapHeight() {return capHeight;}
  
      public int getAscender(int size) {
          return size * ascender;
      }
  
      public int getCapHeight(int size) {
          return size * capHeight;
      }
  
      public int getDescender(int size) {
          return size * descender;
      }
  
      public int getXHeight(int size) {
          return size * xHeight;
      }
  
      public int getFlags() {
          return flags;
      }
  
      public int[] getFontBBox() {
          return fontBBox;
      }
  
      public int getItalicAngle() {
          return italicAngle;
      }
  
      public int getStemV() {
          return stemV;
      }
  
      public int getFirstChar() {
          return 0;
      }
  
      public int getLastChar() {
          return 255;
      }
  
      public int width(int i, int size) {
          return size * width[i];
      }
  
      public int[] getWidths(int size) {
          int[] arr = new int[width.length];
          System.arraycopy(width, 0, arr, 0, width.length-1);
          for( int i = 0; i < arr.length; i++) arr[i] *= size;
          return arr;
      }
  
      public char mapChar(char c) {
          int idx = (int)c;
          int retIdx = 0;
  
          for (int i = 0; (i < bfentries.length) && retIdx == 0; i++) {
  
                  /*
                    System.out.println("us: "+bfentries[i].unicodeStart +
                    " ue: "+bfentries[i].unicodeEnd+
                    " gi: "+bfentries[i].glyphStartIndex);
                  */
              if (bfentries[i].unicodeStart <= idx &&
                  bfentries[i].unicodeEnd >= idx) {
                  retIdx=bfentries[i].glyphStartIndex + idx -
                      bfentries[i].unicodeStart;
              }
          }
  
              //System.out.println("Map: "+ c + " (" + idx + ") = " + retIdx);
          return (char)retIdx;
      }
  }
  
  
  
  
  1.1                  xml-fop/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java
  
  Index: SingleByteFont.java
  ===================================================================
  
  
  package org.apache.fop.render.pdf.fonts;
  
  import org.apache.fop.render.pdf.Font;
  import org.apache.fop.layout.FontDescriptor;
  import org.apache.fop.fonts.Glyphs;
  import org.apache.fop.pdf.PDFStream;
  import org.apache.fop.pdf.PDFTTFStream;
  import org.apache.fop.pdf.PDFT1Stream;
  import java.io.InputStream;
  import java.io.FileInputStream;
  import java.io.BufferedInputStream;
  import java.util.Hashtable;
  
  /**
   * Generic SingleByte font
   */
  public class SingleByteFont extends Font implements FontDescriptor {
      public String fontName = null;
      public String encoding = "WinAnsiEncoding";
      
      public int capHeight = 0;
      public int xHeight = 0;
      public int ascender = 0;
      public int descender = 0;
      public int[] fontBBox = {0, 0, 0, 0};
      
      public String embedFileName = null;
      public String embedResourceName = null;
      public PDFStream embeddedFont=null;
      
      public int firstChar = 0;
      public int lastChar = 255;
      public int flags = 4;
      public int stemV = 0;
      public int italicAngle = 0;
      public int missingWidth = 0;
      
      public Hashtable kerning=new Hashtable();
      public boolean useKerning = true;
      
      public int width[] = null;
      public byte subType = 0;
      
      public final boolean hasKerningInfo() {
          return (useKerning & kerning.isEmpty());
      }
      
      public final java.util.Hashtable getKerningInfo() {return kerning;}
  
      public byte getSubType() {
          return subType;
      }
  
      public int getAvgWidth() {return -1;}
      public int getMinWidth() {return -1;}
      public int getMaxWidth() {return -1;}
      public int getleading() {return -1;}
      public int getStemH() {return 0;}
      public int getMissingWidth() {return missingWidth;}
  
      public String getCharEncoding() {return encoding;}
  
      public boolean isEmbeddable() {
          return (embedFileName==null && embedResourceName==null) ? false : true;
      }
  
      
      public PDFStream getFontFile(int i) {
          InputStream instream=null;
          
          // Get file first
          if (embedFileName!=null)
          try {
             instream=new FileInputStream(embedFileName);
          } catch (Exception e) {
             System.out.println("Failed to embed fontfile: "+embedFileName);
          }
     
          // Get resource
          if (instream==null && embedResourceName!=null)
          try {
             instream=new BufferedInputStream(this.getClass().getResourceAsStream(embedResourceName));
          } catch (Exception e) {
             System.out.println("Failed to embed fontresource: "+embedResourceName);
          }
          
          if (instream==null)
              return (PDFStream)null;
          
          // Read fontdata
          byte[] file = new byte[128000];
          int fsize = 0;
  
          try {
            int l = instream.read(file, 0, 128000);
            fsize += l;
        
            if (l==128000) {
                   // More to read - needs to extend
               byte[] tmpbuf;
           
               while (l > 0) {
                   tmpbuf = new byte[file.length + 64000];
                   System.arraycopy(file, 0, tmpbuf, 0, file.length);
                   l=instream.read(tmpbuf, file.length, 64000);
                   fsize += l;
                   file = tmpbuf;
              
                   if (l < 64000) // whole file read. No need to loop again
                      l=0;
               }
            }
  
            if (subType == org.apache.fop.pdf.PDFFont.TYPE1) {
                embeddedFont=new PDFT1Stream(i, fsize);
                ((PDFT1Stream)embeddedFont).setData(file, fsize);
            } else {
                embeddedFont=new PDFTTFStream(i, fsize);
                ((PDFTTFStream)embeddedFont).setData(file, fsize);
            }
            
            embeddedFont.addFilter("flate");
            embeddedFont.addFilter("ascii-85");
            instream.close();
          } catch (Exception e) {}  
  
          return (PDFStream) embeddedFont;
      }
      
      public String encoding() {
          return encoding;
      }
      
      public String fontName() {
          return fontName;
      }
  
      public int getAscender() {return ascender;}
      public int getDescender() {return descender;}
      public int getCapHeight() {return capHeight;}
  
      public int getAscender(int size) {
          return size * ascender;
      }
  
      public int getCapHeight(int size) {
          return size * capHeight;
      }
  
      public int getDescender(int size) {
          return size * descender;
      }
  
      public int getXHeight(int size) {
          return size * xHeight;
      }
  
      public int getFlags() {
          return flags;
      }
  
      public int[] getFontBBox() {
          return fontBBox;
      }
  
      public int getItalicAngle() {
          return italicAngle;
      }
  
      public int getStemV() {
          return stemV;
      }
  
      public int getFirstChar() {
          return 0;
              //return firstChar;
      }
  
      public int getLastChar() {
          return lastChar;
      }
  
      public int width(int i, int size) {
          return size * width[i];
      }
  
      public int[] getWidths(int size) {
          int[] arr = new int[width.length];
          System.arraycopy(width, 0, arr, 0, width.length-1);
          for( int i = 0; i < arr.length; i++) arr[i] *= size;
          return arr;
      }
  }