com.openpcl.pclrenderimage.render
Class PriFonts

java.lang.Object
  extended by com.openpcl.pclrenderimage.render.PriFonts
All Implemented Interfaces:
IPluginHooksPriFonts

public class PriFonts
extends Object
implements IPluginHooksPriFonts

All the Font related. This class creates Java built in Logical Fonts (and not any specific Physcial Font or using any .TTF file). At run time, the Java JVM maps these fonts to the actual font on the running system, be it WinTel or Mac or Unix or Linux or etc.

Author:
howard. 5/16/2006

Field Summary
protected  ArrayList<int[]> mCharWidthArrayList
           
protected  float mCurrentFontHeight
           
protected  int mCurrentFontStylePlanBoldItalic
           
protected  int mCurrentHorizontalMotionIndexHMI
           
protected  int mCurrentHorizontalPitch
           
protected  int mCurrentJavaBuiltInFont
           
protected  int mCurrentSymbolSet
           
protected  int mFontIsPrimaryOrSecondary
           
protected  FontRenderContext mFontRenderContext
           
protected  Graphics2D mGraphics2D
           
protected  PclRenderImage mPclRenderImage
           
protected  Font mPrimaryFont
           
protected  Font mSecondaryFont
           
protected  TextLayout mTextLayout
           
static int sFontIsMonospaced
           
static int sFontIsPrimary
           
static int sFontIsSansSerif
           
static int sFontIsSecondary
           
static int sFontIsSerif
           
protected static int[][] sFontSubstitutionArray
           
static int sFontSymbolSetIsOther
           
static int sFontSymbolSetIsPC8
           
static int sFontSymbolSetIsRoman8
           
static int sFontSymbolSetIsWindows30Latin1
           
protected static float sFontToPclUnitsConversion
           
protected static Font sMonospacedBaseFont
           
protected static Font sSansSerifBaseFont
           
protected static Font sSerifBaseFont
           
 
Constructor Summary
PriFonts(PclRenderImage pPclRenderImage)
          Constructor without passing the Graphics2D.
PriFonts(PclRenderImage pPclRenderImage, Graphics2D pGraphics2D)
          Constructor
 
Method Summary
 void freeUpMemory()
          When the user is done with this rendering session, then free up memory.
 Font getCurrentFont()
           
 int getCurrentFontStylePlanBoldItalic()
           
 int getCurrentHorizontalPitch()
           
 int getCurrentJavaBuiltInFont()
           
 int getCurrentSymbolSet()
           
 FontRenderContext getFontRenderContext()
           
 int getInternalPrinterFontPixelWidthFor1Char(char pCharToDraw)
          Get the adjusted pixel width of the character in the current font by using the internal printer font character width tables.
 boolean getIsMonospacedFont()
           
 int getPixelWidthFromCharMeasurement(char pCharToDraw)
          Get the pixel width of the char from the char measurement instead of from the printer font tables.
 Font getPrimaryFont()
           
 int getScreenFontPixelHeightFor1Char(char pCharToDraw)
          Get the Screen Font height of this char.
 Font getSecondaryFont()
           
protected  void makeFontCurrent()
          After setting mCurrentJavaBuiltInFont, make that font current
 void setCurrentFont(Font pCurrentFont)
          Set the current font.
 void setFontHeight(float pHeight)
          The height (aka point size) of the font
 void setFontHorizontalPitch(int pNumCharactersPerInch)
          The Horizontal Pitch is the number of characters per inch
 void setFontIsPrimary()
          Set the font is the Primary Font
 void setFontIsSecondary()
          Set the font is the Secondary Font
 void setFontItalicOrCondensedStyle(int pStyle)
          The PCL bytes specified to set Italic or Condensed Style.
 void setFontStrokeWeight(int pWeight)
          The PCL bytes specified to set the font weight.
 void setHorizontalMotionIndexHMI(int pHmiValue)
          Set Horizontal Motion Index (HMI).
 void setJavaBuiltInFont(int pFontTypefaceNumberFromPclFile)
          Pick which Java built in font from the font number read from the original PCL bytes
protected  void setMonospacedJavaBuiltInFont(int pStyle, float pSize)
          Set the Monospaced Java built in font on the Graphics2D for the BufferedImage
 void setPrimaryFont(Font pPrimaryFont)
          Set the primary font.
protected  void setSansSerifJavaBuiltInFont(int pStyle, float pSize)
          Set the SansSerif (aka Arial, Univers, Helvetica) Java built in font on the Graphics2D for the BufferedImage
 void setSecondaryFont(Font pSecondaryFont)
          Set the secondary font
protected  void setSerifJavaBuiltInFont(int pStyle, float pSize)
          Set the Serif (aka Times Roman) Java built in font on the Graphics2D for the BufferedImage
 void setSymbolSetGroupU(int pSymbolSetInGroupU)
          The Symbol Set.
 void setSymbolSetIsUnsupported(int pSymbolSetIsUnsupported, String pCmdTerminator)
          This method is for when the parsed PCL has a symbol set that is not supported due to it's not one of: Roman8 = (s8U Windows30Latin1 = (s9U PC8 = (s10U
 void setToInitialValues()
          Set to initial values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mPclRenderImage

protected PclRenderImage mPclRenderImage

mGraphics2D

protected Graphics2D mGraphics2D

mFontRenderContext

protected FontRenderContext mFontRenderContext

mTextLayout

protected TextLayout mTextLayout

mPrimaryFont

protected Font mPrimaryFont

mSecondaryFont

protected Font mSecondaryFont

sMonospacedBaseFont

protected static final Font sMonospacedBaseFont

sSansSerifBaseFont

protected static final Font sSansSerifBaseFont

sSerifBaseFont

protected static final Font sSerifBaseFont

mCharWidthArrayList

protected ArrayList<int[]> mCharWidthArrayList

mCurrentHorizontalPitch

protected int mCurrentHorizontalPitch

mCurrentHorizontalMotionIndexHMI

protected int mCurrentHorizontalMotionIndexHMI

mCurrentFontStylePlanBoldItalic

protected int mCurrentFontStylePlanBoldItalic

mCurrentFontHeight

protected float mCurrentFontHeight

sFontIsMonospaced

public static final int sFontIsMonospaced
See Also:
Constant Field Values

sFontIsSansSerif

public static final int sFontIsSansSerif
See Also:
Constant Field Values

sFontIsSerif

public static final int sFontIsSerif
See Also:
Constant Field Values

mCurrentJavaBuiltInFont

protected int mCurrentJavaBuiltInFont

sFontSymbolSetIsOther

public static final int sFontSymbolSetIsOther
See Also:
Constant Field Values

sFontSymbolSetIsRoman8

public static final int sFontSymbolSetIsRoman8
See Also:
Constant Field Values

sFontSymbolSetIsWindows30Latin1

public static final int sFontSymbolSetIsWindows30Latin1
See Also:
Constant Field Values

sFontSymbolSetIsPC8

public static final int sFontSymbolSetIsPC8
See Also:
Constant Field Values

mCurrentSymbolSet

protected int mCurrentSymbolSet

sFontToPclUnitsConversion

protected static final float sFontToPclUnitsConversion
See Also:
Constant Field Values

sFontIsPrimary

public static final int sFontIsPrimary
See Also:
Constant Field Values

sFontIsSecondary

public static final int sFontIsSecondary
See Also:
Constant Field Values

mFontIsPrimaryOrSecondary

protected int mFontIsPrimaryOrSecondary

sFontSubstitutionArray

protected static final int[][] sFontSubstitutionArray
Constructor Detail

PriFonts

public PriFonts(PclRenderImage pPclRenderImage,
                Graphics2D pGraphics2D)
Constructor

Parameters:
PclRenderImage -
pGraphics2D -

PriFonts

public PriFonts(PclRenderImage pPclRenderImage)
Constructor without passing the Graphics2D. Needed for subclasses that don't use the Graphics2D, so don't delete or change this constructor.

Method Detail

setToInitialValues

public void setToInitialValues()
Set to initial values. Subclass plugins override this method so do not delete or rename this method.

Specified by:
setToInitialValues in interface IPluginHooksPriFonts

freeUpMemory

public void freeUpMemory()
When the user is done with this rendering session, then free up memory. Subclass plugins override this method so do not delete or rename this method.

Specified by:
freeUpMemory in interface IPluginHooksPriFonts

getCurrentFont

public Font getCurrentFont()

getPrimaryFont

public Font getPrimaryFont()

getSecondaryFont

public Font getSecondaryFont()

getCurrentSymbolSet

public int getCurrentSymbolSet()

getCurrentJavaBuiltInFont

public int getCurrentJavaBuiltInFont()

getFontRenderContext

public FontRenderContext getFontRenderContext()

getCurrentFontStylePlanBoldItalic

public int getCurrentFontStylePlanBoldItalic()

getIsMonospacedFont

public boolean getIsMonospacedFont()

getCurrentHorizontalPitch

public int getCurrentHorizontalPitch()

getInternalPrinterFontPixelWidthFor1Char

public int getInternalPrinterFontPixelWidthFor1Char(char pCharToDraw)
Get the adjusted pixel width of the character in the current font by using the internal printer font character width tables.

Parameters:
char - pCharToDraw
Returns:
int

getPixelWidthFromCharMeasurement

public int getPixelWidthFromCharMeasurement(char pCharToDraw)
Get the pixel width of the char from the char measurement instead of from the printer font tables. Subclass plugins override this method so do not delete or rename this method.

Specified by:
getPixelWidthFromCharMeasurement in interface IPluginHooksPriFonts
Parameters:
pCharToDraw -
Returns:
int

getScreenFontPixelHeightFor1Char

public int getScreenFontPixelHeightFor1Char(char pCharToDraw)
Get the Screen Font height of this char. Subclass plugins override this method so do not delete or rename this method.

Specified by:
getScreenFontPixelHeightFor1Char in interface IPluginHooksPriFonts
Parameters:
pCharToDraw -
Returns:
int

setFontItalicOrCondensedStyle

public void setFontItalicOrCondensedStyle(int pStyle)
The PCL bytes specified to set Italic or Condensed Style. 0 is not Italic. 1 is Italic. 4 is Condensed mono mode. The below code is to maintain and not overwrite the previous current setting for the italic attribute when setting the passed in value for "not bold or bold". There combinations are: 1. Not bold not Italic, 2. Not bold, Italic 3. Bold, not Italic 4. Bold, Italic

Parameters:
pStyle -

setFontStrokeWeight

public void setFontStrokeWeight(int pWeight)
The PCL bytes specified to set the font weight. 0 is not bold. 1 is bold. The below code is to maintain and not overwrite the previous current setting for the italic attribute when setting the passed in value for "not bold or bold". There combinations are: 1. Not bold not Italic, 2. Not bold, Italic 3. Bold, not Italic 4. Bold, Italic

Parameters:
pWeight -

setSymbolSetGroupU

public void setSymbolSetGroupU(int pSymbolSetInGroupU)
The Symbol Set. Roman8 = (s8U Windows30Latin1 = (s9U PC8 = (s10U

Parameters:
pSymbolSetInGroupU -

setSymbolSetIsUnsupported

public void setSymbolSetIsUnsupported(int pSymbolSetIsUnsupported,
                                      String pCmdTerminator)
This method is for when the parsed PCL has a symbol set that is not supported due to it's not one of: Roman8 = (s8U Windows30Latin1 = (s9U PC8 = (s10U

Parameters:
pSymbolSetIsUnsupported -
pCmdTerminator -

setFontHorizontalPitch

public void setFontHorizontalPitch(int pNumCharactersPerInch)
The Horizontal Pitch is the number of characters per inch

Parameters:
pNumCharactersPerInch -

setHorizontalMotionIndexHMI

public void setHorizontalMotionIndexHMI(int pHmiValue)
Set Horizontal Motion Index (HMI). HMI effects characters per inch on mono fonts (not proportional fonts) without changing the font vertical pitch or horizontal pitch. This means, "same font, but squish or stretch the text". HMI works like this: Formulas: hmi = 120 / cpi cpi * hmi = 120 cpi = 120 / hmi Example calculations to get the cpi if the HMI is known: cpi = 120 / 12 = 10 cpi = 120 / 10 = 12 cpi = 120 / 8 = 15 Example calculations to get the cpi and then the character width pixel horizonal X move if the HMI is known: cpi = 120 / 12 = 10 ---> pixels = 300 / 10 = 30 cpi = 120 / 10 = 12 ---> pixels = 300 / 12 = 25 cpi = 120 / 8 = 15 ---> pixels = 300 / 15 = 20

Parameters:
pHmiValue -

setFontHeight

public void setFontHeight(float pHeight)
The height (aka point size) of the font

Parameters:
pHeight -

setFontIsPrimary

public void setFontIsPrimary()
Set the font is the Primary Font


setFontIsSecondary

public void setFontIsSecondary()
Set the font is the Secondary Font


setJavaBuiltInFont

public void setJavaBuiltInFont(int pFontTypefaceNumberFromPclFile)
Pick which Java built in font from the font number read from the original PCL bytes

Parameters:
pFontTypefaceNumberFromPclFile -

makeFontCurrent

protected void makeFontCurrent()
After setting mCurrentJavaBuiltInFont, make that font current


setMonospacedJavaBuiltInFont

protected void setMonospacedJavaBuiltInFont(int pStyle,
                                            float pSize)
Set the Monospaced Java built in font on the Graphics2D for the BufferedImage

Parameters:
pStyle -
pSize -

setSansSerifJavaBuiltInFont

protected void setSansSerifJavaBuiltInFont(int pStyle,
                                           float pSize)
Set the SansSerif (aka Arial, Univers, Helvetica) Java built in font on the Graphics2D for the BufferedImage

Parameters:
pStyle -
pSize -

setSerifJavaBuiltInFont

protected void setSerifJavaBuiltInFont(int pStyle,
                                       float pSize)
Set the Serif (aka Times Roman) Java built in font on the Graphics2D for the BufferedImage

Parameters:
pStyle -
pSize -

setCurrentFont

public void setCurrentFont(Font pCurrentFont)
Set the current font. This calls setPrimaryFont(Font).

Parameters:
pCurrentFont -

setPrimaryFont

public void setPrimaryFont(Font pPrimaryFont)
Set the primary font. Subclass plugins override this method so do not delete or rename this method.

Specified by:
setPrimaryFont in interface IPluginHooksPriFonts
Parameters:
pPrimaryFont -

setSecondaryFont

public void setSecondaryFont(Font pSecondaryFont)
Set the secondary font



OpenPCL http://www.openpcl.com