org.freehep.graphicsio.font
Class FontEmbedder

java.lang.Object
  extended by org.freehep.graphicsio.font.FontIncluder
      extended by org.freehep.graphicsio.font.FontEmbedder
Direct Known Subclasses:
FontEmbedderType1, PDFFontEmbedder, PSFontEmbedder

public abstract class FontEmbedder
extends FontIncluder

A FontIncluder that also embeds all glyphs. Subclasses must implement the writeGlyph method which is called for all defined (up to 256) characters and the notdefined character. These method calls are bracketed by openGlyphs() and closeGlyph(). All invocations of methods that are abstract in this class succeed the method calls of the superclass FontIncluder (especially closeIncludeFont()!) All of these calls are again succeeded by closeEmbedFont.
The abstract methods are called in the following order:

Version:
$Id: FontEmbedder.java 8584 2006-08-10 23:06:37Z duns $
Author:
Simon Fischer

Field Summary
static java.lang.String NOTDEF
           
 
Fields inherited from class org.freehep.graphicsio.font.FontIncluder
FONT_SIZE
 
Constructor Summary
FontEmbedder(java.awt.font.FontRenderContext context)
           
 
Method Summary
protected abstract  void closeEmbedFont()
           
protected  void closeGlyphs()
          Called after the glyph loop ends.
protected  double getAdvanceWidth(int character)
           
protected  double[] getAdvanceWidths()
           
protected  java.awt.Shape getGlyph(int i)
           
protected  java.awt.font.GlyphMetrics getGlyphMetrics(int i)
           
 void includeFont(java.awt.Font font, CharTable charTable, java.lang.String name)
          Embed this font to the file.
protected  void openGlyphs()
          Called before the glyph loop starts.
protected abstract  void writeGlyph(java.lang.String unicodeName, java.awt.Shape glyph, java.awt.font.GlyphMetrics glyphMetrics)
          Writes a single glyph to the file.
protected abstract  void writeWidths(double[] widths)
          Writes the character widths to the file.
 
Methods inherited from class org.freehep.graphicsio.font.FontIncluder
closeIncludeFont, getCharName, getContext, getEncodingTable, getFont, getFontBBox, getFontName, getNODefinedChars, getUndefinedWidth, getUnicode, getUnicode, openIncludeFont, writeEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTDEF

public static final java.lang.String NOTDEF
See Also:
Constant Field Values
Constructor Detail

FontEmbedder

public FontEmbedder(java.awt.font.FontRenderContext context)
Method Detail

writeGlyph

protected abstract void writeGlyph(java.lang.String unicodeName,
                                   java.awt.Shape glyph,
                                   java.awt.font.GlyphMetrics glyphMetrics)
                            throws java.io.IOException
Writes a single glyph to the file. A null value for glyphMetrics indicates the undefined character. In this case the value of unicodeName equals the value of NOTDEF (=.notdef).

Parameters:
unicodeName - the character's name according to the unicode standard
glyph - the shape that represents this glyph
glyphMetrics - the metrics of this glyph
Throws:
java.io.IOException

writeWidths

protected abstract void writeWidths(double[] widths)
                             throws java.io.IOException
Writes the character widths to the file.

Throws:
java.io.IOException

openGlyphs

protected void openGlyphs()
                   throws java.io.IOException
Called before the glyph loop starts. Does nothing by default but can be implemented.

Throws:
java.io.IOException

closeGlyphs

protected void closeGlyphs()
                    throws java.io.IOException
Called after the glyph loop ends. Does nothing by default but can be implemented.

Throws:
java.io.IOException

closeEmbedFont

protected abstract void closeEmbedFont()
                                throws java.io.IOException
Throws:
java.io.IOException

getAdvanceWidths

protected double[] getAdvanceWidths()

getAdvanceWidth

protected double getAdvanceWidth(int character)

getGlyph

protected java.awt.Shape getGlyph(int i)

getGlyphMetrics

protected java.awt.font.GlyphMetrics getGlyphMetrics(int i)

includeFont

public void includeFont(java.awt.Font font,
                        CharTable charTable,
                        java.lang.String name)
                 throws java.io.IOException
Description copied from class: FontIncluder
Embed this font to the file.

Overrides:
includeFont in class FontIncluder
Parameters:
font - The font to include
name - The name under which this font is addressed within the document (can be retrieved by getFontName())
Throws:
java.io.IOException


Copyright © 2000-2007 FreeHEP. All Rights Reserved.