Package com.openhtmltopdf.java2d
Class Java2DTextRenderer
- java.lang.Object
-
- com.openhtmltopdf.java2d.Java2DTextRenderer
-
- All Implemented Interfaces:
TextRenderer
public class Java2DTextRenderer extends Object implements TextRenderer
Renders to a Graphics2D instance.- Author:
- Joshua Marinacci, Torbjoern Gannholm
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectantiAliasRenderingHintprotected ObjectfractionalFontMetricsHintprotected floatscaleprotected floatthreshold
-
Constructor Summary
Constructors Constructor Description Java2DTextRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddrawString(OutputDevice outputDevice, String string, float x, float y)voiddrawString(OutputDevice outputDevice, String string, float x, float y, JustificationInfo info)Draws a justified string.floatgetFontScale()FSFontMetricsgetFSFontMetrics(FontContext fc, FSFont font, String string)float[]getGlyphPositions(OutputDevice outputDevice, FSFont font, String text)This method gets glyph positions for purposes of selecting text.ObjectgetRenderingHints()If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.intgetSmoothingLevel()intgetWidth(FontContext fc, FSFont font, String string)voidsetFontScale(float scale)voidsetRenderingHints(Object renderingHints)If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.voidsetSmoothingLevel(int level)voidsetSmoothingThreshold(float fontsize)voidsetup(FontContext context)voidsetup(FontContext fontContext, BidiReorderer bidiReorderer)
-
-
-
Method Detail
-
drawString
public void drawString(OutputDevice outputDevice, String string, float x, float y)
- Specified by:
drawStringin interfaceTextRenderer
-
drawString
public void drawString(OutputDevice outputDevice, String string, float x, float y, JustificationInfo info)
Draws a justified string. TODO: Font fallback.- Specified by:
drawStringin interfaceTextRenderer
-
setup
public void setup(FontContext fontContext, BidiReorderer bidiReorderer)
- Parameters:
bidiReorderer-
-
setFontScale
public void setFontScale(float scale)
- Specified by:
setFontScalein interfaceTextRenderer
-
setSmoothingThreshold
public void setSmoothingThreshold(float fontsize)
- Specified by:
setSmoothingThresholdin interfaceTextRenderer
-
setSmoothingLevel
public void setSmoothingLevel(int level)
- Specified by:
setSmoothingLevelin interfaceTextRenderer
-
getFSFontMetrics
public FSFontMetrics getFSFontMetrics(FontContext fc, FSFont font, String string)
- Specified by:
getFSFontMetricsin interfaceTextRenderer
-
getWidth
public int getWidth(FontContext fc, FSFont font, String string)
- Specified by:
getWidthin interfaceTextRenderer
-
getFontScale
public float getFontScale()
- Specified by:
getFontScalein interfaceTextRenderer
-
getSmoothingLevel
public int getSmoothingLevel()
- Specified by:
getSmoothingLevelin interfaceTextRenderer
-
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(OutputDevice outputDevice, 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.
-
setup
public void setup(FontContext context)
- Specified by:
setupin interfaceTextRenderer
-
-