FreeHEP API
Version current

org.freehep.graphicsio.font
Class FontEmbedder

java.lang.Object
  extended byorg.freehep.graphicsio.font.FontIncluder
      extended byorg.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,v 1.3 2005/01/03 21:22:27 duns Exp $
Author:
Simon Fischer
Source Code:
FontEmbedder.java

Field Summary
static String NOTDEF
           
 
Fields inherited from class org.freehep.graphicsio.font.FontIncluder
FONT_SIZE
 
Constructor Summary
FontEmbedder(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  Shape getGlyph(int i)
           
protected  GlyphMetrics getGlyphMetrics(int i)
           
 void includeFont(Font font, CharTable charTable, String name)
          Embed this font to the file.
protected  void openGlyphs()
          Called before the glyph loop starts.
protected abstract  void writeGlyph(String unicodeName, Shape glyph, 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 String NOTDEF
See Also:
Constant Field Values
Constructor Detail

FontEmbedder

public FontEmbedder(FontRenderContext context)
Method Detail

writeGlyph

protected abstract void writeGlyph(String unicodeName,
                                   Shape glyph,
                                   GlyphMetrics glyphMetrics)
                            throws 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:
IOException

writeWidths

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

Throws:
IOException

openGlyphs

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

Throws:
IOException

closeGlyphs

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

Throws:
IOException

closeEmbedFont

protected abstract void closeEmbedFont()
                                throws IOException
Throws:
IOException

getAdvanceWidths

protected double[] getAdvanceWidths()

getAdvanceWidth

protected double getAdvanceWidth(int character)

getGlyph

protected Shape getGlyph(int i)

getGlyphMetrics

protected GlyphMetrics getGlyphMetrics(int i)

includeFont

public void includeFont(Font font,
                        CharTable charTable,
                        String name)
                 throws 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:
IOException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.