org.pz.platypus.plugin.rtf
Class RtfFont

java.lang.Object
  extended by org.pz.platypus.plugin.rtf.RtfFont

public class RtfFont
extends java.lang.Object

Handles fonts for the RTF plugin

Author:
alb

Field Summary
private  boolean bold
          is font bold?
private  GDD gdd
           
private  boolean italics
          is fond italic?
private  com.lowagie.text.Font iTfont
          the iText font
private  RtfData rtfData
           
private  float size
          font size
private  Source source
          file and line number of last change
private  java.lang.String typeface
          the font typeface in the form of a string used by iText
 
Constructor Summary
RtfFont(RtfData rtfData)
           
RtfFont(RtfData rdd, java.lang.String fontName, RtfFont existingFont)
          Constructor for cloning an existing PdfFont, but specifying a different typeface.
 
Method Summary
(package private)  int computeItextStyle()
          iText font style captures bold, italic, strikethru, underline.
(package private)  com.lowagie.text.Font createFont(RtfFont f)
          Creates an iText Font object based on the class fields
(package private)  java.lang.String createItextFontName(RtfFont f)
          Get the name by which iText refers to this font.
(package private)  boolean findAndRegisterFont(java.lang.String typefaceName)
          Get the filenames from the typefaceMap and register them in iText's FontFactory.
 boolean getBold()
           
(package private)  com.lowagie.text.Font getCp1252Font(java.lang.String fontName, float size, int style)
          Gets the font with CP1252 (aka WINANSI) encoding
 java.lang.String getFace()
           
(package private)  com.lowagie.text.Font getIdentityHFont(java.lang.String fontName, float size, int style)
          Opens a font using the IDENTITY-H encoding.
 boolean getItalics()
           
 com.lowagie.text.Font getItextFont()
          Get the iText font
 float getSize()
           
 Source getSource()
           
(package private)  boolean isBase14Font(java.lang.String fontName)
          Determines whehter the current font is one of the Base14 Acrobat fonts, built into every PDF reader.
private  boolean isFileOtf(java.lang.String fontName)
          Looks up a font in the fontlist and determines whether it uses the .otf font format.
(package private)  java.lang.String[] lookupFontFilenames(java.lang.String typefaceName)
          Get the names of the actual font files that are the implementation of this typeface
 void setBold(boolean onOff, Source newSource)
          set bold on/off and re-create the iText font to record the change.
 void setFace(java.lang.String newFace, Source newSource)
           
 void setItalics(boolean onOff, Source newSource)
          set italics on/off and re-create the iText font to record the change.
 void setSize(float newSize, Source newSource)
           
 void setToDefault()
          Initializes all PdfFont fields to defaults, and sets line number to 0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iTfont

private com.lowagie.text.Font iTfont
the iText font


typeface

private java.lang.String typeface
the font typeface in the form of a string used by iText


size

private float size
font size


bold

private boolean bold
is font bold?


italics

private boolean italics
is fond italic?


source

private Source source
file and line number of last change


gdd

private GDD gdd

rtfData

private RtfData rtfData
Constructor Detail

RtfFont

RtfFont(RtfData rtfData)

RtfFont

public RtfFont(RtfData rdd,
               java.lang.String fontName,
               RtfFont existingFont)
Constructor for cloning an existing PdfFont, but specifying a different typeface.

Parameters:
rdd - PDF data
fontName - the name of the new font/typeface
existingFont - the font to clone the other attributes from
Method Detail

setToDefault

public void setToDefault()
Initializes all PdfFont fields to defaults, and sets line number to 0


createFont

com.lowagie.text.Font createFont(RtfFont f)
Creates an iText Font object based on the class fields

Parameters:
f - the PdfFont containing the parameters for the font
Returns:
the iText Font object

getIdentityHFont

com.lowagie.text.Font getIdentityHFont(java.lang.String fontName,
                                       float size,
                                       int style)
Opens a font using the IDENTITY-H encoding.

Parameters:
fontName - the name assigned to the font in the font list
size - the size in points
style - bold, italic, etc.
Returns:
the Font if opened; null if the file could not be opened or an error occurred.

isFileOtf

private boolean isFileOtf(java.lang.String fontName)
Looks up a font in the fontlist and determines whether it uses the .otf font format.

Parameters:
fontName - name of font to verify
Returns:
true if it's an .otf font, otherwise false.

getCp1252Font

com.lowagie.text.Font getCp1252Font(java.lang.String fontName,
                                    float size,
                                    int style)
Gets the font with CP1252 (aka WINANSI) encoding

Parameters:
fontName - name of font to get
size - size in points
style - bold, italic, etc.
Returns:
the font, or null if an error occurred.

isBase14Font

boolean isBase14Font(java.lang.String fontName)
Determines whehter the current font is one of the Base14 Acrobat fonts, built into every PDF reader. These fonts require special hanldling, and so this routine helps identify them, based on their font face name.

Parameters:
fontName - name of the font face
Returns:
true if it's a base14 font name, false otherwise.

createItextFontName

java.lang.String createItextFontName(RtfFont f)
Get the name by which iText refers to this font. This routine is mostly occupied with the special handling of the base14 fonts. For all other fonts, this method makes sure the font is registered with iText and returns its name as registered by iText (which is the family name for the font).

Parameters:
f - PdfFont whose iText name we're getting
Returns:
a string containing the iText usable name for this font.

findAndRegisterFont

boolean findAndRegisterFont(java.lang.String typefaceName)
Get the filenames from the typefaceMap and register them in iText's FontFactory.

Parameters:
typefaceName - name of the typeface
Returns:
true if the font is now registered, false if an error occurred. (Font was not in fontlist.)

lookupFontFilenames

java.lang.String[] lookupFontFilenames(java.lang.String typefaceName)
Get the names of the actual font files that are the implementation of this typeface

Parameters:
typefaceName - the typefaces
Returns:
an array of strings containing the file names.

computeItextStyle

int computeItextStyle()
iText font style captures bold, italic, strikethru, underline. Since we handle strikethrough and underline ourselves, we use it to communicate italic and bold only. This computation done here.

Returns:
the iText Style

getBold

public boolean getBold()

getItalics

public boolean getItalics()

getItextFont

public com.lowagie.text.Font getItextFont()
Get the iText font

Returns:
the iText font

getFace

public java.lang.String getFace()

getSize

public float getSize()

getSource

public Source getSource()

setBold

public void setBold(boolean onOff,
                    Source newSource)
set bold on/off and re-create the iText font to record the change.

Parameters:
onOff - the new value for the italics setting
newSource - the file and line # of the token that changed italics

setItalics

public void setItalics(boolean onOff,
                       Source newSource)
set italics on/off and re-create the iText font to record the change.

Parameters:
onOff - the new value for the italics setting
newSource - the file and line # of the token that changed italics

setSize

public void setSize(float newSize,
                    Source newSource)

setFace

public void setFace(java.lang.String newFace,
                    Source newSource)


Copyright © 2008-10 Pacific Data Works LLC