org.icepdf.core.pobjects.fonts.ofont
Class OFont

java.lang.Object
  extended by org.icepdf.core.pobjects.fonts.ofont.OFont
All Implemented Interfaces:
FontFile

public class OFont
extends java.lang.Object
implements FontFile

OFont is an awt Font wrapper used to aid in the paint of glyphs.

Since:
3.0

Field Summary
protected  float ascent
           
protected  java.util.Map<java.lang.Integer,java.lang.Float> cidWidths
           
protected  char[] cMap
           
protected  float descent
           
protected  Encoding encoding
           
protected  int firstCh
           
protected  float missingWidth
           
protected  CMap toUnicode
           
protected  float[] widths
           
 
Fields inherited from interface org.icepdf.core.pobjects.fonts.FontFile
LAYOUT_NONE
 
Constructor Summary
OFont(java.awt.Font awtFont)
           
 
Method Summary
 boolean canDisplayEchar(char ech)
          Can the character ch in the nfont's encoding be rendered?
 FontFile deriveFont(java.awt.geom.AffineTransform at)
           
 FontFile deriveFont(Encoding encoding, CMap toUnicode)
           
 FontFile deriveFont(float pointsize)
          Creates nfont a new pointsize, assuming 72 ppi.
 FontFile deriveFont(float[] widths, int firstCh, float missingWidth, float ascent, float descent, char[] diff)
           
 FontFile deriveFont(java.util.Map<java.lang.Integer,java.lang.Float> widths, int firstCh, float missingWidth, float ascent, float descent, char[] diff)
           
 void drawEstring(java.awt.Graphics2D g, java.lang.String displayText, float x, float y, long layout, int mode, java.awt.Color strokecolor)
           
 java.awt.geom.Point2D echarAdvance(char ech)
           
 double getAscent()
          Returns maximum ascent glyphs above baseline.
 char getCharDiff(char character)
          Return the width of the given character
 double getDescent()
          Returns maximum descent of glyphs below baseline.
 java.awt.geom.Rectangle2D getEstringBounds(java.lang.String estr, int beginIndex, int limit)
           
 java.awt.Shape getEstringOutline(java.lang.String displayText, float x, float y)
          Get the glyph outline shape for the given estr translated to x,y.
 java.lang.String getFamily()
          Returns name of nfont, such as "Times".
 java.lang.String getFormat()
          Returns primary format, such as "Type1" or "OpenType".
 java.awt.geom.Rectangle2D getMaxCharBounds()
          Returns left in rectangle's x, ascent in y, width in width, height in height.
 java.lang.String getName()
          Returns name of nfont, such as "Times-Roman", which is different than the filename.
 int getNumGlyphs()
          Returns number of glyphs defined in nfont.
 int getRights()
          Returns nfont usage rights bit mask.
 float getSize()
           
 char getSpaceEchar()
          Returns the character that seems to be used as a space in the current encoding, or NOTDEF_CHAR if no such character.
 int getStyle()
           
 CMap getToUnicode()
           
 java.awt.geom.AffineTransform getTransform()
          Returns a copy of the transform associated with this font file.
 boolean isHinted()
          Returns true iff nfont has hinted outlines, which is Type 1 and TrueType is a sign of higher quality.
 boolean isOneByteEncoding()
           
 java.lang.String toUnicode(char c1)
           
 java.lang.String toUnicode(java.lang.String displayText)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

widths

protected float[] widths

cidWidths

protected java.util.Map<java.lang.Integer,java.lang.Float> cidWidths

missingWidth

protected float missingWidth

firstCh

protected int firstCh

ascent

protected float ascent

descent

protected float descent

encoding

protected Encoding encoding

toUnicode

protected CMap toUnicode

cMap

protected char[] cMap
Constructor Detail

OFont

public OFont(java.awt.Font awtFont)
Method Detail

deriveFont

public FontFile deriveFont(Encoding encoding,
                           CMap toUnicode)
Specified by:
deriveFont in interface FontFile

deriveFont

public FontFile deriveFont(float[] widths,
                           int firstCh,
                           float missingWidth,
                           float ascent,
                           float descent,
                           char[] diff)
Specified by:
deriveFont in interface FontFile

deriveFont

public FontFile deriveFont(java.util.Map<java.lang.Integer,java.lang.Float> widths,
                           int firstCh,
                           float missingWidth,
                           float ascent,
                           float descent,
                           char[] diff)
Specified by:
deriveFont in interface FontFile

deriveFont

public FontFile deriveFont(java.awt.geom.AffineTransform at)
Specified by:
deriveFont in interface FontFile

canDisplayEchar

public boolean canDisplayEchar(char ech)
Description copied from interface: FontFile
Can the character ch in the nfont's encoding be rendered?

Specified by:
canDisplayEchar in interface FontFile

deriveFont

public FontFile deriveFont(float pointsize)
Description copied from interface: FontFile
Creates nfont a new pointsize, assuming 72 ppi. Note to subclassers: you must make a complete independent instance of the nfont here, even if pointsize and everything else is the same, as other deriveFont methods use this to make a clone and might make subsequent changes.

Specified by:
deriveFont in interface FontFile

echarAdvance

public java.awt.geom.Point2D echarAdvance(char ech)
Specified by:
echarAdvance in interface FontFile

getCharDiff

public char getCharDiff(char character)
Return the width of the given character

Parameters:
character - character to retreive width of
Returns:
width of the given character

getToUnicode

public CMap getToUnicode()
Specified by:
getToUnicode in interface FontFile

getStyle

public int getStyle()
Specified by:
getStyle in interface FontFile

getFamily

public java.lang.String getFamily()
Description copied from interface: FontFile
Returns name of nfont, such as "Times".

Specified by:
getFamily in interface FontFile

getSize

public float getSize()
Specified by:
getSize in interface FontFile

getAscent

public double getAscent()
Description copied from interface: FontFile
Returns maximum ascent glyphs above baseline.

Specified by:
getAscent in interface FontFile

getDescent

public double getDescent()
Description copied from interface: FontFile
Returns maximum descent of glyphs below baseline.

Specified by:
getDescent in interface FontFile

getMaxCharBounds

public java.awt.geom.Rectangle2D getMaxCharBounds()
Description copied from interface: FontFile
Returns left in rectangle's x, ascent in y, width in width, height in height.

Specified by:
getMaxCharBounds in interface FontFile

getTransform

public java.awt.geom.AffineTransform getTransform()
Description copied from interface: FontFile
Returns a copy of the transform associated with this font file.

Specified by:
getTransform in interface FontFile

getRights

public int getRights()
Description copied from interface: FontFile
Returns nfont usage rights bit mask.

Specified by:
getRights in interface FontFile

getName

public java.lang.String getName()
Description copied from interface: FontFile
Returns name of nfont, such as "Times-Roman", which is different than the filename.

Specified by:
getName in interface FontFile

isHinted

public boolean isHinted()
Description copied from interface: FontFile
Returns true iff nfont has hinted outlines, which is Type 1 and TrueType is a sign of higher quality.

Specified by:
isHinted in interface FontFile

getNumGlyphs

public int getNumGlyphs()
Description copied from interface: FontFile
Returns number of glyphs defined in nfont.

Specified by:
getNumGlyphs in interface FontFile

getSpaceEchar

public char getSpaceEchar()
Description copied from interface: FontFile
Returns the character that seems to be used as a space in the current encoding, or NOTDEF_CHAR if no such character.

Specified by:
getSpaceEchar in interface FontFile

getEstringBounds

public java.awt.geom.Rectangle2D getEstringBounds(java.lang.String estr,
                                                  int beginIndex,
                                                  int limit)
Specified by:
getEstringBounds in interface FontFile

getFormat

public java.lang.String getFormat()
Description copied from interface: FontFile
Returns primary format, such as "Type1" or "OpenType".

Specified by:
getFormat in interface FontFile

drawEstring

public void drawEstring(java.awt.Graphics2D g,
                        java.lang.String displayText,
                        float x,
                        float y,
                        long layout,
                        int mode,
                        java.awt.Color strokecolor)
Specified by:
drawEstring in interface FontFile

toUnicode

public java.lang.String toUnicode(java.lang.String displayText)
Specified by:
toUnicode in interface FontFile

toUnicode

public java.lang.String toUnicode(char c1)
Specified by:
toUnicode in interface FontFile

isOneByteEncoding

public boolean isOneByteEncoding()
Specified by:
isOneByteEncoding in interface FontFile

getEstringOutline

public java.awt.Shape getEstringOutline(java.lang.String displayText,
                                        float x,
                                        float y)
Description copied from interface: FontFile
Get the glyph outline shape for the given estr translated to x,y.

Specified by:
getEstringOutline in interface FontFile
Parameters:
displayText - text to calculate glyph outline shape
x - x coordinate to translate outline shape.
y - y coordinate to translate outline shape.
Returns:
glyph outline of the estr.