From: <doc...@us...> - 2007-05-23 04:27:20
|
Revision: 73 http://openpcl.svn.sourceforge.net/openpcl/?rev=73&view=rev Author: documentsystems Date: 2007-05-22 21:27:08 -0700 (Tue, 22 May 2007) Log Message: ----------- A start at implementing OpenPCL SourceForge bug 1723909 "Implement Secondary Fonts independently of Primary Fonts". Added variables and methods and method calls to save the Secondary Font independent of the Primary Font, and to set whether the currently selected font mode is the Primary Font or the Secondary Font. Modified Paths: -------------- openpcl/src/com/openpcl/pclrenderimage/PclRenderImage.java openpcl/src/com/openpcl/pclrenderimage/render/PriFonts.java Modified: openpcl/src/com/openpcl/pclrenderimage/PclRenderImage.java =================================================================== --- openpcl/src/com/openpcl/pclrenderimage/PclRenderImage.java 2007-05-18 01:55:15 UTC (rev 72) +++ openpcl/src/com/openpcl/pclrenderimage/PclRenderImage.java 2007-05-23 04:27:08 UTC (rev 73) @@ -496,6 +496,12 @@ mPriDrawText.drawBufferedUpCharsAs1String(); // Transfer soft font header data bytes mPriParseSoftFontBytes.transferSoftFontHeaderData(cmdValueInt, cmdData); + } else if (cmdCharArray[3] == 'T') { // )s,T Set Secondary Font typeface + if (mParsePclIs1stPass || mIsStateBuildingPclPages || mIsRecordingAMacro) {return;} + mPriDrawText.drawBufferedUpCharsAs1String(); + mIsSoftFontMode = false; + mPriFonts.setFontIsSecondary(); + mPriFonts.setJavaBuiltInFont(cmdValueInt); } } } @@ -514,10 +520,11 @@ if (mParsePclIs1stPass || mIsStateBuildingPclPages || mIsRecordingAMacro) {return;} mPriDrawText.drawBufferedUpCharsAs1String(); mPriFonts.setFontItalicOrCondensedStyle(cmdValueInt); - } else if (cmdCharArray[3] == 'T') { // (s,T + } else if (cmdCharArray[3] == 'T') { // (s,T Set Primary Font typeface if (mParsePclIs1stPass || mIsStateBuildingPclPages || mIsRecordingAMacro) {return;} mPriDrawText.drawBufferedUpCharsAs1String(); mIsSoftFontMode = false; + mPriFonts.setFontIsPrimary(); mPriFonts.setJavaBuiltInFont(cmdValueInt); } else if (cmdCharArray[3] == 'V') { // (s,V if (mParsePclIs1stPass || mIsStateBuildingPclPages || mIsRecordingAMacro) {return;} Modified: openpcl/src/com/openpcl/pclrenderimage/render/PriFonts.java =================================================================== --- openpcl/src/com/openpcl/pclrenderimage/render/PriFonts.java 2007-05-18 01:55:15 UTC (rev 72) +++ openpcl/src/com/openpcl/pclrenderimage/render/PriFonts.java 2007-05-23 04:27:08 UTC (rev 73) @@ -54,6 +54,12 @@ protected final static float sFontToPclUnitsConversion = 300.0F / 72.0F; + // PCL commands might define a Secondary Font, then flip to the Secondary Font using 15 shift out, + // then might flip to the Primary Font using 14 which is shift in. + public static final int sFontIsPrimary = 1; + public static final int sFontIsSecondary = 2; + protected int mFontIsPrimaryOrSecondary = sFontIsPrimary; + // (taken from Jim Gabriel's DocMaster Pascal source code) protected static final int[][] sFontSubstitutionArray = new int[][] { {0, sFontIsMonospaced}, // LinePrinter @@ -460,6 +466,20 @@ makeFontCurrent(); } + /** + * Set the font is the Primary Font + */ + public void setFontIsPrimary() { + mFontIsPrimaryOrSecondary = sFontIsPrimary; + } + + /** + * Set the font is the Secondary Font + */ + public void setFontIsSecondary() { + mFontIsPrimaryOrSecondary = sFontIsSecondary; + } + /** Pick which Java built in font from the font number read from the original PCL bytes * @param pFontTypefaceNumberFromPclFile */ @@ -557,6 +577,7 @@ public void setPrimaryFont(Font pPrimaryFont) { if (pPrimaryFont != null) { mPrimaryFont = pPrimaryFont; + mFontIsPrimaryOrSecondary = sFontIsPrimary; if (mGraphics2D != null) { mGraphics2D.setFont(mPrimaryFont); mFontRenderContext = mGraphics2D.getFontRenderContext(); @@ -570,5 +591,14 @@ } /** Set the secondary font */ - public void setSecondaryFont(Font pSecondaryFont) { mSecondaryFont = pSecondaryFont; } + public void setSecondaryFont(Font pSecondaryFont) { + if (pSecondaryFont != null) { + mSecondaryFont = pSecondaryFont; + mFontIsPrimaryOrSecondary = sFontIsSecondary; + if (mGraphics2D != null) { + mGraphics2D.setFont(mPrimaryFont); + mFontRenderContext = mGraphics2D.getFontRenderContext(); + } + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |