Class Java2DTextRenderer
java.lang.Object
com.openhtmltopdf.java2d.Java2DTextRenderer
- All Implemented Interfaces:
TextRenderer
Renders to a Graphics2D instance.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadjustGlyphPositions(String string, JustificationInfo info, GlyphVector vector) private booleancanDisplayWithFont(String str, Font fnt) private List<Java2DTextRenderer.FontRun> divideIntoFontRuns(List<Font> fonts, String string) voiddrawString(OutputDevice outputDevice, String string, float x, float y) voiddrawString(OutputDevice outputDevice, String string, float x, float y, JustificationInfo info) Draws a justified string.floatgetFSFontMetrics(FontContext fc, FSFont font, String string) float[]getGlyphPositions(OutputDevice outputDevice, FSFont font, String text) This method gets glyph positions for purposes of selecting text.If anti-alias text is enabled, the value from RenderingHints to use for AA smoothing in Java2D.intintgetWidth(FontContext fc, FSFont font, String string) Rarely need to use this method directly.private intgetWidthFast(FontContext fc, Font awtFont, String string) private intgetWidthSlow(FontContext fc, List<Font> fonts, String string) This method divides the string up into font runs, then measures each font run, adding it to the total.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) Set the smoothing threashold.voidsetup(FontContext context) voidsetup(FontContext fontContext, BidiReorderer bidiReorderer)
-
Field Details
-
scale
protected float scale -
threshold
protected float threshold -
antiAliasRenderingHint
-
fractionalFontMetricsHint
-
-
Constructor Details
-
Java2DTextRenderer
public Java2DTextRenderer()
-
-
Method Details
-
drawString
- 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
-
adjustGlyphPositions
-
setup
- Parameters:
bidiReorderer-
-
setFontScale
public void setFontScale(float scale) - Specified by:
setFontScalein interfaceTextRenderer
-
setSmoothingThreshold
public void setSmoothingThreshold(float fontsize) Description copied from interface:TextRendererSet 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:
setSmoothingThresholdin interfaceTextRenderer
-
setSmoothingLevel
public void setSmoothingLevel(int level) - Specified by:
setSmoothingLevelin interfaceTextRenderer- Parameters:
level- no-op
-
getFSFontMetrics
- Specified by:
getFSFontMetricsin interfaceTextRenderer
-
canDisplayWithFont
-
getWidthFast
-
divideIntoFontRuns
-
getWidthSlow
This method divides the string up into font runs, then measures each font run, adding it to the total. We do this, rather than get the width of each character, in case kerning is enabled and it also may be faster. -
getWidth
Description copied from interface:TextRendererRarely need to use this method directly. Instead favorBreakerstatic method instead.- Specified by:
getWidthin interfaceTextRenderer
-
getFontScale
public float getFontScale()- Specified by:
getFontScalein interfaceTextRenderer
-
getSmoothingLevel
public int getSmoothingLevel()- Specified by:
getSmoothingLevelin interfaceTextRenderer
-
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
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
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
- Specified by:
setupin interfaceTextRenderer
-