Package org.apache.fop.render.ps
Class PSTextPainter
- java.lang.Object
-
- org.apache.batik.bridge.BasicTextPainter
-
- org.apache.batik.bridge.StrokingTextPainter
-
- org.apache.fop.svg.NativeTextPainter
-
- org.apache.fop.render.ps.PSTextPainter
-
- All Implemented Interfaces:
org.apache.batik.bridge.TextPainter
- Direct Known Subclasses:
PSBatikFlowTextElementBridge.PSFlowExtTextPainter
,PSSVGFlowRootElementBridge.PSFlowTextPainter
public class PSTextPainter extends NativeTextPainter
Renders the attributed character iterator of aTextNode
. This class draws the text directly using PostScript text operators so the text is not drawn using shapes which makes the PS files larger.The text runs are split into smaller text runs that can be bundles in single calls of the xshow, yshow or xyshow operators. For outline text, the charpath operator is used.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
PSTextPainter.PSTextRun
private class
PSTextPainter.TextUtil
-
Field Summary
Fields Modifier and Type Field Description private boolean
flushCurrentRun
private FontResourceCache
fontResources
private org.apache.xmlgraphics.ps.PSGenerator
gen
private static java.awt.geom.AffineTransform
IDENTITY_TRANSFORM
private org.apache.xmlgraphics.java2d.ps.PSGraphics2D
ps
private PSTextPainter.PSTextRun
psRun
private java.awt.geom.Point2D.Double
relPos
private PSTextPainter.TextUtil
textUtil
-
Fields inherited from class org.apache.fop.svg.NativeTextPainter
font, fontFamilyResolver, fontInfo, log, tpi
-
Fields inherited from class org.apache.batik.bridge.StrokingTextPainter
ADJUST_ALL, ADJUST_SPACING, ALT_GLYPH_HANDLER, ANCHOR_TYPE, BIDI_LEVEL, FLOW_PARAGRAPH, FLOW_REGIONS, GVT_FONT, GVT_FONTS, PAINT_INFO, singleton, TEXT_COMPOUND_ID, TEXTPATH, WRITING_MODE, WRITING_MODE_RTL, WRITING_MODE_TTB, XPOS, YPOS
-
-
Constructor Summary
Constructors Constructor Description PSTextPainter(FontInfo fontInfo)
Create a new PS text painter with the given font information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beginTextObject()
protected void
clip(java.awt.Shape shape)
protected void
endTextObject()
private PSFontResource
getResourceForFont(Font f, java.lang.String postfix)
protected boolean
isSupported(java.awt.Graphics2D g2d)
Indicates whether the givenGraphics2D
instance if compatible with this text painter implementation.protected void
positionGlyph(java.awt.geom.Point2D prevPos, java.awt.geom.Point2D glyphPos, boolean reposition)
protected void
preparePainting(java.awt.Graphics2D g2d)
protected void
restoreGraphicsState()
protected void
saveGraphicsState()
protected void
setInitialTransform(java.awt.geom.AffineTransform transform)
protected void
writeGlyph(char glyph, java.awt.geom.AffineTransform localTransform)
-
Methods inherited from class org.apache.fop.svg.NativeTextPainter
collectCharacters, computeTextRuns, getFontFamilyResolver, getTextLayoutFactory, getTextRunBoundaryAttributes, logCharacter, logTextRun, paintTextRun, paintTextRuns, reorderTextRuns, writeGlyphs
-
Methods inherited from class org.apache.batik.bridge.StrokingTextPainter
adjustChunkOffsets, computeTextRuns, createModifiedACIForFontMatching, getBounds2D, getDecorationOutline, getDecorationStrokeOutline, getHighlightShape, getInstance, getMark, getOutline, getSelected, getTextChunk, getTextChunkACIs, getTextRuns, hitTest, paint, paintDecorations, printAttrs, selectFirst, selectLast
-
-
-
-
Field Detail
-
fontResources
private FontResourceCache fontResources
-
ps
private org.apache.xmlgraphics.java2d.ps.PSGraphics2D ps
-
gen
private org.apache.xmlgraphics.ps.PSGenerator gen
-
textUtil
private PSTextPainter.TextUtil textUtil
-
flushCurrentRun
private boolean flushCurrentRun
-
psRun
private PSTextPainter.PSTextRun psRun
-
relPos
private java.awt.geom.Point2D.Double relPos
-
IDENTITY_TRANSFORM
private static final java.awt.geom.AffineTransform IDENTITY_TRANSFORM
-
-
Constructor Detail
-
PSTextPainter
public PSTextPainter(FontInfo fontInfo)
Create a new PS text painter with the given font information.- Parameters:
fontInfo
- the font collection
-
-
Method Detail
-
isSupported
protected boolean isSupported(java.awt.Graphics2D g2d)
Indicates whether the givenGraphics2D
instance if compatible with this text painter implementation.- Specified by:
isSupported
in classNativeTextPainter
- Parameters:
g2d
- the instance to check- Returns:
- true if the instance is compatible.
-
preparePainting
protected void preparePainting(java.awt.Graphics2D g2d)
- Specified by:
preparePainting
in classNativeTextPainter
-
saveGraphicsState
protected void saveGraphicsState() throws java.io.IOException
- Specified by:
saveGraphicsState
in classNativeTextPainter
- Throws:
java.io.IOException
-
restoreGraphicsState
protected void restoreGraphicsState() throws java.io.IOException
- Specified by:
restoreGraphicsState
in classNativeTextPainter
- Throws:
java.io.IOException
-
setInitialTransform
protected void setInitialTransform(java.awt.geom.AffineTransform transform) throws java.io.IOException
- Specified by:
setInitialTransform
in classNativeTextPainter
- Throws:
java.io.IOException
-
getResourceForFont
private PSFontResource getResourceForFont(Font f, java.lang.String postfix)
-
clip
protected void clip(java.awt.Shape shape) throws java.io.IOException
- Specified by:
clip
in classNativeTextPainter
- Throws:
java.io.IOException
-
beginTextObject
protected void beginTextObject() throws java.io.IOException
- Specified by:
beginTextObject
in classNativeTextPainter
- Throws:
java.io.IOException
-
endTextObject
protected void endTextObject() throws java.io.IOException
- Specified by:
endTextObject
in classNativeTextPainter
- Throws:
java.io.IOException
-
positionGlyph
protected void positionGlyph(java.awt.geom.Point2D prevPos, java.awt.geom.Point2D glyphPos, boolean reposition)
- Specified by:
positionGlyph
in classNativeTextPainter
-
writeGlyph
protected void writeGlyph(char glyph, java.awt.geom.AffineTransform localTransform) throws java.io.IOException
- Specified by:
writeGlyph
in classNativeTextPainter
- Throws:
java.io.IOException
-
-