Package org.xhtmlrenderer.swing
Class Java2DTextRenderer
- java.lang.Object
-
- org.xhtmlrenderer.swing.Java2DTextRenderer
-
- All Implemented Interfaces:
TextRenderer
public class Java2DTextRenderer extends java.lang.Object implements TextRenderer
Renders to a Graphics2D instance.- Author:
- Joshua Marinacci, Torbjoern Gannholm
-
-
Constructor Summary
Constructors Constructor Description Java2DTextRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drawGlyphVector(OutputDevice outputDevice, FSGlyphVector fsGlyphVector, float x, float y)
void
drawString(OutputDevice outputDevice, java.lang.String string, float x, float y)
void
drawString(OutputDevice outputDevice, java.lang.String string, float x, float y, JustificationInfo info)
float
getFontScale()
FSFontMetrics
getFSFontMetrics(FontContext fc, FSFont font, java.lang.String string)
java.awt.Rectangle
getGlyphBounds(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector, int index, float x, float y)
float[]
getGlyphPositions(OutputDevice outputDevice, FSFont font, java.lang.String text)
float[]
getGlyphPositions(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector)
FSGlyphVector
getGlyphVector(OutputDevice outputDevice, FSFont font, java.lang.String text)
java.lang.Object
getRenderingHints()
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.int
getSmoothingLevel()
int
getWidth(FontContext fc, FSFont font, java.lang.String string)
void
setFontScale(float scale)
void
setRenderingHints(java.lang.Object renderingHints)
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.void
setSmoothingLevel(int level)
void
setSmoothingThreshold(float fontsize)
Set the smoothing threashold.void
setup(FontContext fontContext)
-
-
-
Method Detail
-
drawString
public void drawString(OutputDevice outputDevice, java.lang.String string, float x, float y)
- Specified by:
drawString
in interfaceTextRenderer
-
drawString
public void drawString(OutputDevice outputDevice, java.lang.String string, float x, float y, JustificationInfo info)
- Specified by:
drawString
in interfaceTextRenderer
-
drawGlyphVector
public void drawGlyphVector(OutputDevice outputDevice, FSGlyphVector fsGlyphVector, float x, float y)
- Specified by:
drawGlyphVector
in interfaceTextRenderer
-
setup
public void setup(FontContext fontContext)
- Specified by:
setup
in interfaceTextRenderer
-
setFontScale
public void setFontScale(float scale)
- Specified by:
setFontScale
in interfaceTextRenderer
-
setSmoothingThreshold
public void setSmoothingThreshold(float fontsize)
Description copied from interface:TextRenderer
Set the smoothing threashold. This is a font size above which all text will be anti-aliased. Text below this size will not be antialiased. Set to -1 for no antialiasing. Set to 0 for all antialising. Else, set to the threshold font size. does not take font scaling into account.- Specified by:
setSmoothingThreshold
in interfaceTextRenderer
-
setSmoothingLevel
public void setSmoothingLevel(int level)
- Specified by:
setSmoothingLevel
in interfaceTextRenderer
- Parameters:
level
- no-op
-
getFSFontMetrics
public FSFontMetrics getFSFontMetrics(FontContext fc, FSFont font, java.lang.String string)
- Specified by:
getFSFontMetrics
in interfaceTextRenderer
-
getWidth
public int getWidth(FontContext fc, FSFont font, java.lang.String string)
- Specified by:
getWidth
in interfaceTextRenderer
-
getFontScale
public float getFontScale()
- Specified by:
getFontScale
in interfaceTextRenderer
-
getSmoothingLevel
public int getSmoothingLevel()
- Specified by:
getSmoothingLevel
in interfaceTextRenderer
-
getRenderingHints
public java.lang.Object getRenderingHints()
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D. Defaults toRenderingHints.VALUE_TEXT_ANTIALIAS_ON
.- Returns:
- Current AA rendering hint
-
setRenderingHints
public void setRenderingHints(java.lang.Object renderingHints)
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D. Defaults toRenderingHints.VALUE_TEXT_ANTIALIAS_ON
.- Parameters:
renderingHints
- rendering hint for AA smoothing in Java2D
-
getGlyphPositions
public float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, java.lang.String text)
-
getGlyphBounds
public java.awt.Rectangle getGlyphBounds(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector, int index, float x, float y)
- Specified by:
getGlyphBounds
in interfaceTextRenderer
-
getGlyphPositions
public float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector)
- Specified by:
getGlyphPositions
in interfaceTextRenderer
-
getGlyphVector
public FSGlyphVector getGlyphVector(OutputDevice outputDevice, FSFont font, java.lang.String text)
- Specified by:
getGlyphVector
in interfaceTextRenderer
-
-