Package com.openhtmltopdf.java2d
Class Java2DTextRenderer
- java.lang.Object
-
- com.openhtmltopdf.java2d.Java2DTextRenderer
-
- All Implemented Interfaces:
com.openhtmltopdf.extend.TextRenderer
public class Java2DTextRenderer extends Object implements com.openhtmltopdf.extend.TextRenderer
Renders to a Graphics2D instance.- Author:
- Joshua Marinacci, Torbjoern Gannholm
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
antiAliasRenderingHint
protected Object
fractionalFontMetricsHint
protected float
scale
protected float
threshold
-
Constructor Summary
Constructors Constructor Description Java2DTextRenderer()
-
Method Summary
Modifier and Type Method Description void
drawGlyphVector(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector, float x, float y)
void
drawString(com.openhtmltopdf.extend.OutputDevice outputDevice, String string, float x, float y)
void
drawString(com.openhtmltopdf.extend.OutputDevice outputDevice, String string, float x, float y, com.openhtmltopdf.render.JustificationInfo info)
Draws a justified string.float
getFontScale()
com.openhtmltopdf.render.FSFontMetrics
getFSFontMetrics(com.openhtmltopdf.extend.FontContext fc, com.openhtmltopdf.render.FSFont font, String string)
Rectangle
getGlyphBounds(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector, int index, float x, float y)
This method gets glyph bounds for purposes of selecting text.float[]
getGlyphPositions(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector)
This method gets glyph positions for purposes of selecting text.float[]
getGlyphPositions(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, String text)
This method gets glyph positions for purposes of selecting text.com.openhtmltopdf.extend.FSGlyphVector
getGlyphVector(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, String text)
This method gets a glyph vector for purposes of selecting text.Object
getRenderingHints()
If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.int
getSmoothingLevel()
int
getWidth(com.openhtmltopdf.extend.FontContext fc, com.openhtmltopdf.render.FSFont font, String string)
void
setFontScale(float scale)
void
setRenderingHints(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)
void
setup(com.openhtmltopdf.extend.FontContext context)
void
setup(com.openhtmltopdf.extend.FontContext fontContext, com.openhtmltopdf.bidi.BidiReorderer bidiReorderer)
-
-
-
Method Detail
-
drawString
public void drawString(com.openhtmltopdf.extend.OutputDevice outputDevice, String string, float x, float y)
- Specified by:
drawString
in interfacecom.openhtmltopdf.extend.TextRenderer
-
drawString
public void drawString(com.openhtmltopdf.extend.OutputDevice outputDevice, String string, float x, float y, com.openhtmltopdf.render.JustificationInfo info)
Draws a justified string. TODO: Font fallback.- Specified by:
drawString
in interfacecom.openhtmltopdf.extend.TextRenderer
-
drawGlyphVector
public void drawGlyphVector(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector, float x, float y)
- Specified by:
drawGlyphVector
in interfacecom.openhtmltopdf.extend.TextRenderer
-
setup
public void setup(com.openhtmltopdf.extend.FontContext fontContext, com.openhtmltopdf.bidi.BidiReorderer bidiReorderer)
- Parameters:
bidiReorderer
-
-
setFontScale
public void setFontScale(float scale)
- Specified by:
setFontScale
in interfacecom.openhtmltopdf.extend.TextRenderer
-
setSmoothingThreshold
public void setSmoothingThreshold(float fontsize)
- Specified by:
setSmoothingThreshold
in interfacecom.openhtmltopdf.extend.TextRenderer
-
setSmoothingLevel
public void setSmoothingLevel(int level)
- Specified by:
setSmoothingLevel
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getFSFontMetrics
public com.openhtmltopdf.render.FSFontMetrics getFSFontMetrics(com.openhtmltopdf.extend.FontContext fc, com.openhtmltopdf.render.FSFont font, String string)
- Specified by:
getFSFontMetrics
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getWidth
public int getWidth(com.openhtmltopdf.extend.FontContext fc, com.openhtmltopdf.render.FSFont font, String string)
- Specified by:
getWidth
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getFontScale
public float getFontScale()
- Specified by:
getFontScale
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getSmoothingLevel
public int getSmoothingLevel()
- Specified by:
getSmoothingLevel
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getRenderingHints
public 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(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(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, String text)
This method gets glyph positions for purposes of selecting text. WE are not too worried about selecting text at this point so we just use the first font available.
-
getGlyphBounds
public Rectangle getGlyphBounds(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector, int index, float x, float y)
This method gets glyph bounds for purposes of selecting text. WE are not too worried about selecting text at this point so we just use the first font available.- Specified by:
getGlyphBounds
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getGlyphPositions
public float[] getGlyphPositions(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, com.openhtmltopdf.extend.FSGlyphVector fsGlyphVector)
This method gets glyph positions for purposes of selecting text. WE are not too worried about selecting text at this point so we just use the first font available.- Specified by:
getGlyphPositions
in interfacecom.openhtmltopdf.extend.TextRenderer
-
getGlyphVector
public com.openhtmltopdf.extend.FSGlyphVector getGlyphVector(com.openhtmltopdf.extend.OutputDevice outputDevice, com.openhtmltopdf.render.FSFont font, String text)
This method gets a glyph vector for purposes of selecting text. WE are not too worried about selecting text at this point so we just use the first font available.- Specified by:
getGlyphVector
in interfacecom.openhtmltopdf.extend.TextRenderer
-
setup
public void setup(com.openhtmltopdf.extend.FontContext context)
- Specified by:
setup
in interfacecom.openhtmltopdf.extend.TextRenderer
-
-