org.extex.font.format.tfm
Class LoadableTfmFont

java.lang.Object
  extended by org.extex.font.format.tfm.LoadableTfmFont
All Implemented Interfaces:
BackendFont, BaseFont, ExtexFont, TfmMetricFont, LoadableFont, LogEnabled, ResourceAware, CharNodeBuilder

public class LoadableTfmFont
extends java.lang.Object
implements LoadableFont, BackendFont, ResourceAware, LogEnabled, TfmMetricFont, CharNodeBuilder

Class to load tfm fonts.

Version:
$Revision: 7275 $
Author:
Michael Niedermair

Constructor Summary
LoadableTfmFont()
           
 
Method Summary
 CharNode buildCharNode(UnicodeChar uc, TypesettingContext tc, NodeFactory factory, TypesettingContextFactory tcFactory)
          Create a node for a Unicode character.
 void enableLogging(java.util.logging.Logger logger)
          Setter for the logger.
 FontKey getActualFontKey()
          Returns the actual FontKey for this font after a font substitution.
 FixedDimen getActualSize()
          Returns the actual size of the font.
 byte[] getAfm()
          Returns the afm data, or null, if not available.
 int getCheckSum()
          Returns the checksum.
 FixedGlue getDepth(UnicodeChar uc)
          Returns the depth of the char.
 FixedDimen getDesignSize()
          Returns the design size of the font.
 FixedDimen getEm()
          Returns the size of 'M'.
 int getEncodingForChar(int codepoint)
          Returns the number of the encoding vector for the codepoint.
 java.util.List<java.lang.String[]> getEncodingVectors()
          Returns the encoding vectors as list of string array (without a '/') or null, if no one exists.
 FixedDimen getEx()
          Returns the size of 'x'.
 FixedDimen getFontDimen(java.lang.String name)
          Returns the size of the parameter with the name 'name'.
 FontKey getFontKey()
          Returns the FontKey for this font.
 java.lang.String getFontName()
          Returns the name of the font.
 FixedGlue getHeight(UnicodeChar uc)
          Returns the height of the char.
 FixedDimen getItalicCorrection(UnicodeChar uc)
          Returns the italic correction of the char.
 FixedDimen getKerning(UnicodeChar uc1, UnicodeChar uc2)
          Returns the kerning between two chars.
 UnicodeChar getLigature(UnicodeChar uc1, UnicodeChar uc2)
          Returns the ligature for two chars.
 java.lang.String getName()
          Returns the internal name of the font.
 byte[] getPfa()
          Returns the pfa data, or null, if not available.
 byte[] getPfb()
          Returns the pfb data, or null, if not available.
 FixedCount getScaleFactor()
          Returns the scale factor of the font.
 FixedGlue getSpace()
          Returns the size of the 'space'.
 UnicodeChar getUnicodeChar(int pos)
          Returns the Unicode char for the position or null, if not found.
 FixedGlue getWidth(UnicodeChar uc)
          Returns the width of the char.
 byte[] getXtf()
          Returns the xtf data, or null, if not available.
 boolean hasEncodingVector()
          Returns true, if the font has an encoding vector, otherwise false.
 boolean hasGlyph(UnicodeChar uc)
          Returns true, if the glyph exists.
 boolean hasMultiFonts()
          If true, the font has more the one font in it.
 boolean isType1()
          Returns true, if the font is a type 1 font (with afm/pfb), otherwise false.
 boolean isXtf()
          Returns true, if the font is a ttf/otf font, otherwise false.
 void loadFont(java.io.InputStream in, CoreFontFactory factory, FontKey key)
          Load a font from the stream.
 void setResourceFinder(ResourceFinder finder)
          Setter for the resource finder.
 void usedCharacter(BackendCharacter bc)
          Tells the font, which character is used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadableTfmFont

public LoadableTfmFont()
Method Detail

buildCharNode

public CharNode buildCharNode(UnicodeChar uc,
                              TypesettingContext tc,
                              NodeFactory factory,
                              TypesettingContextFactory tcFactory)
Create a node for a Unicode character. Note that the result can either be a simple CharNode or a VirtualCharNode. In the latter case a composition of several components can be contained.

Specified by:
buildCharNode in interface CharNodeBuilder
Parameters:
uc - the Unicode character
tc - the default typesetting context to use
factory - the factory to acquire new nodes from
tcFactory - the factor for new typesetting contexts
Returns:
the node for the character or null if none can be determined
See Also:
CharNodeBuilder.buildCharNode(org.extex.core.UnicodeChar, org.extex.typesetter.tc.TypesettingContext, org.extex.typesetter.type.node.factory.NodeFactory, org.extex.typesetter.tc.TypesettingContextFactory)

enableLogging

public void enableLogging(java.util.logging.Logger logger)
Setter for the logger.

Specified by:
enableLogging in interface LogEnabled
Parameters:
logger - the logger to use
See Also:
LogEnabled.enableLogging(java.util.logging.Logger)

getActualFontKey

public FontKey getActualFontKey()
Returns the actual FontKey for this font after a font substitution.

Specified by:
getActualFontKey in interface BackendFont
Specified by:
getActualFontKey in interface BaseFont
Returns:
Returns the actual FontKey for this font.
See Also:
BaseFont.getActualFontKey()

getActualSize

public FixedDimen getActualSize()
Returns the actual size of the font.

Specified by:
getActualSize in interface ExtexFont
Returns:
Returns the actual size of the font.
See Also:
ExtexFont.getActualSize()

getAfm

public byte[] getAfm()
Returns the afm data, or null, if not available. TODO mgn raus

Specified by:
getAfm in interface BackendFont
Returns:
Returns the afm data, or null, if not available.
See Also:
BackendFont.getAfm()

getCheckSum

public int getCheckSum()
Returns the checksum.

Specified by:
getCheckSum in interface BackendFont
Returns:
Returns the checksum.
See Also:
Font.getCheckSum()

getDepth

public FixedGlue getDepth(UnicodeChar uc)
Returns the depth of the char. If the character is not defined or an invalid value is given, then the depth 0pt is returned.

Specified by:
getDepth in interface ExtexFont
Parameters:
uc - The Unicode char.
Returns:
Returns the depth of the char.
See Also:
ExtexFont.getDepth(org.extex.core.UnicodeChar)

getDesignSize

public FixedDimen getDesignSize()
Returns the design size of the font.

Specified by:
getDesignSize in interface ExtexFont
Returns:
Returns the design size of the font.
See Also:
ExtexFont.getDesignSize()

getEm

public FixedDimen getEm()
Returns the size of 'M'.

Specified by:
getEm in interface ExtexFont
Returns:
Returns the size of 'M'.
See Also:
ExtexFont.getEm()

getEncodingForChar

public int getEncodingForChar(int codepoint)
Returns the number of the encoding vector for the codepoint. If no enocding vector exists, -1 is returned. TODO mgn raus

Specified by:
getEncodingForChar in interface BackendFont
Parameters:
codepoint - The codepoint of the char.
Returns:
Returns the number of the encoding vector for the codepoint.
See Also:
BackendFont.getEncodingForChar(int)

getEncodingVectors

public java.util.List<java.lang.String[]> getEncodingVectors()
Returns the encoding vectors as list of string array (without a '/') or null, if no one exists. TODO mgn raus

Specified by:
getEncodingVectors in interface BackendFont
Returns:
Returns the encoding vectors.
See Also:
BackendFont.getEncodingVectors()

getEx

public FixedDimen getEx()
Returns the size of 'x'.

Specified by:
getEx in interface ExtexFont
Returns:
Returns the size of 'x'.
See Also:
ExtexFont.getEx()

getFontDimen

public FixedDimen getFontDimen(java.lang.String name)
Returns the size of the parameter with the name 'name'.

The size are multiples of the design size!

Specified by:
getFontDimen in interface ExtexFont
Parameters:
name - The name of the parameter.
Returns:
Returns the size of the parameter with the name 'name'.
See Also:
ExtexFont.getFontDimen(java.lang.String)

getFontKey

public FontKey getFontKey()
Returns the FontKey for this font.

Specified by:
getFontKey in interface BaseFont
Returns:
Returns the FontKey for this font.
See Also:
BaseFont.getFontKey()

getFontName

public java.lang.String getFontName()
Returns the name of the font.

Specified by:
getFontName in interface ExtexFont
Returns:
Returns the name of the font.
See Also:
ExtexFont.getFontName()

getHeight

public FixedGlue getHeight(UnicodeChar uc)
Returns the height of the char. If the character is not defined or an invalid value is given, then the height 0pt is returned.

Specified by:
getHeight in interface ExtexFont
Parameters:
uc - The Unicode char.
Returns:
Returns the height of the char.
See Also:
ExtexFont.getHeight(org.extex.core.UnicodeChar)

getItalicCorrection

public FixedDimen getItalicCorrection(UnicodeChar uc)
Returns the italic correction of the char. If the character is not defined or an invalid value is given, then the italic correction 0pt is returned.

Specified by:
getItalicCorrection in interface ExtexFont
Parameters:
uc - The Unicode char.
Returns:
Returns the italic correction of the char.
See Also:
ExtexFont.getItalicCorrection(org.extex.core.UnicodeChar)

getKerning

public FixedDimen getKerning(UnicodeChar uc1,
                             UnicodeChar uc2)
Returns the kerning between two chars.

Specified by:
getKerning in interface ExtexFont
Parameters:
uc1 - The Unicode char (first one).
uc2 - The Unicode char (second one).
Returns:
Returns the kerning between two chars.
See Also:
ExtexFont.getKerning(org.extex.core.UnicodeChar, org.extex.core.UnicodeChar)

getLigature

public UnicodeChar getLigature(UnicodeChar uc1,
                               UnicodeChar uc2)
Returns the ligature for two chars. If no ligature exists then null is returned.

Specified by:
getLigature in interface ExtexFont
Parameters:
uc1 - The Unicode char (first one).
uc2 - The Unicode char (second one).
Returns:
Returns the ligature for two chars.
See Also:
ExtexFont.getLigature(org.extex.core.UnicodeChar, org.extex.core.UnicodeChar)

getName

public java.lang.String getName()
Returns the internal name of the font.

Specified by:
getName in interface BackendFont
Returns:
the internal name of the font.
See Also:
BackendFont.getName()

getPfa

public byte[] getPfa()
Returns the pfa data, or null, if not available. TODO mgn raus

Specified by:
getPfa in interface BackendFont
Returns:
Returns the pfa data, or null, if not available.
See Also:
BackendFont.getPfa()

getPfb

public byte[] getPfb()
Returns the pfb data, or null, if not available. TODO mgn raus

Specified by:
getPfb in interface BackendFont
Returns:
Returns the pfb data, or null, if not available.
See Also:
BackendFont.getPfb()

getScaleFactor

public FixedCount getScaleFactor()
Returns the scale factor of the font. The scale factor is a multiple of 1000.

Specified by:
getScaleFactor in interface ExtexFont
Returns:
Returns the scale factor of the font.
See Also:
ExtexFont.getScaleFactor()

getSpace

public FixedGlue getSpace()
Returns the size of the 'space'.

Specified by:
getSpace in interface ExtexFont
Returns:
Returns the size of the 'space'.
See Also:
ExtexFont.getSpace()

getUnicodeChar

public UnicodeChar getUnicodeChar(int pos)
Returns the Unicode char for the position or null, if not found.

Parameters:
pos - The position.
Returns:
Returns the Unicode char.

getWidth

public FixedGlue getWidth(UnicodeChar uc)
Returns the width of the char. If the character is not defined or an invalid value is given, then the width 0pt is returned.

Specified by:
getWidth in interface ExtexFont
Parameters:
uc - The Unicode char.
Returns:
Returns the width of the char.
See Also:
ExtexFont.getWidth(org.extex.core.UnicodeChar)

getXtf

public byte[] getXtf()
Returns the xtf data, or null, if not available. TODO mgn raus

Specified by:
getXtf in interface BackendFont
Returns:
Returns the xtf data, or null, if not available.
See Also:
BackendFont.getXtf()

hasEncodingVector

public boolean hasEncodingVector()
Returns true, if the font has an encoding vector, otherwise false. TODO mgn raus

Specified by:
hasEncodingVector in interface BackendFont
See Also:
BackendFont.hasEncodingVector()

hasGlyph

public boolean hasGlyph(UnicodeChar uc)
Returns true, if the glyph exists.

Specified by:
hasGlyph in interface ExtexFont
Parameters:
uc - the unicode char
Returns:
true, if the glyph exists.
See Also:
Font.hasGlyph(org.extex.core.UnicodeChar)

hasMultiFonts

public boolean hasMultiFonts()
If true, the font has more the one font in it. TODO mgn raus

Specified by:
hasMultiFonts in interface BackendFont
Returns:
Returns true, if the font has more fonts in it.
See Also:
BackendFont.hasMultiFonts()

isType1

public boolean isType1()
Returns true, if the font is a type 1 font (with afm/pfb), otherwise false. TODO mgn raus

Specified by:
isType1 in interface BackendFont
Returns:
Returns true, if the font is a type 1 font (with afm/pfb), otherwise false.
See Also:
BackendFont.isType1()

isXtf

public boolean isXtf()
Returns true, if the font is a ttf/otf font, otherwise false. TODO mgn raus

Specified by:
isXtf in interface BackendFont
Returns:
Returns true, if the font is a ttf/otf font, otherwise false.
See Also:
BackendFont.isXtf()

loadFont

public void loadFont(java.io.InputStream in,
                     CoreFontFactory factory,
                     FontKey key)
              throws CorruptFontException,
                     ConfigurationException
Load a font from the stream.

Specified by:
loadFont in interface LoadableFont
Parameters:
in - The stream for reading.
factory - Tthe font factory.
key - The font key.
Throws:
CorruptFontException - if the font is corrupt.
ConfigurationException - from the configuration system.
See Also:
LoadableFont.loadFont(java.io.InputStream, org.extex.font.CoreFontFactory, org.extex.font.FontKey)

setResourceFinder

public void setResourceFinder(ResourceFinder finder)
Setter for the resource finder.

Specified by:
setResourceFinder in interface ResourceAware
Parameters:
finder - the resource finder
See Also:
ResourceAware.setResourceFinder(org.extex.resource.ResourceFinder)

usedCharacter

public void usedCharacter(BackendCharacter bc)
Tells the font, which character is used. TODO mgn raus

Specified by:
usedCharacter in interface BackendFont
Parameters:
bc - The character.
See Also:
BackendFont.usedCharacter(org.extex.font.BackendCharacter)