public class TextRenderer extends AbstractRenderer implements ILeafElementRenderer
renderer object for a Text
object. It will draw the glyphs of the textual content on the DrawContext.| Modifier and Type | Field and Description |
|---|---|
protected com.itextpdf.io.font.otf.GlyphLine |
line |
protected boolean |
otfFeaturesApplied |
protected List<int[]> |
reversedRanges |
protected com.itextpdf.io.font.otf.GlyphLine |
savedWordBreakAtLineEnding |
protected String |
strToBeConverted |
protected float |
tabAnchorCharacterPosition |
protected com.itextpdf.io.font.otf.GlyphLine |
text |
protected static float |
TEXT_SPACE_COEFF |
protected float |
yLineOffset |
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, parent, positionedRenderers, properties| Modifier | Constructor and Description |
|---|---|
|
TextRenderer(Text textElement)
Creates a TextRenderer from its corresponding layout object.
|
protected |
TextRenderer(TextRenderer other) |
|
TextRenderer(Text textElement,
String text)
Creates a TextRenderer from its corresponding layout object, with a custom
text to replace the contents of the
Text. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyOtf() |
protected int |
baseCharactersCount() |
protected float |
calculateLineWidth() |
int |
charAt(int pos)
Gets char code at given position for the text belonging to this renderer.
|
protected TextRenderer |
createCopy(com.itextpdf.io.font.otf.GlyphLine gl,
PdfFont font) |
protected TextRenderer |
createOverflowRenderer() |
protected TextRenderer |
createSplitRenderer() |
void |
draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e.
|
void |
drawBackground(DrawContext drawContext)
Draws a background layer if it is defined by a key
Property.BACKGROUND
in either the layout element or this IRenderer itself. |
protected void |
drawSingleUnderline(Underline underline,
Color fontStrokeColor,
PdfCanvas canvas,
float fontSize,
float italicAngleTan)
Deprecated.
|
protected void |
drawSingleUnderline(Underline underline,
TransparentColor fontStrokeColor,
PdfCanvas canvas,
float fontSize,
float italicAngleTan) |
float |
getAscent()
Gets the maximum offset above the base line that this Text extends to.
|
float |
getDescent()
Gets the maximum offset below the base line that this Text extends to.
|
protected Float |
getFirstYLineRecursively()
Gets the first yLine of the nested children recursively.
|
protected Float |
getLastYLineRecursively() |
protected MinMaxWidth |
getMinMaxWidth(float availableWidth) |
IRenderer |
getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, if
IRenderer.layout(LayoutContext) is called more than once. |
protected int |
getNumberOfSpaces() |
float |
getTabAnchorCharacterPosition() |
com.itextpdf.io.font.otf.GlyphLine |
getText() |
float |
getYLine()
Gets the position on the canvas of the imaginary horizontal line upon which
the
Text's contents will be written. |
protected static boolean |
isNewLine(com.itextpdf.io.font.otf.GlyphLine text,
int ind)
Deprecated.
Use
TextUtil.isNewLine(Glyph) instead. |
LayoutResult |
layout(LayoutContext layoutContext)
This method simulates positioning of the renderer, including all of its children, and returns
the
LayoutResult, representing the layout result, including occupied area, status, i.e. |
int |
length()
The length of the whole text assigned to this renderer.
|
protected int |
lineLength()
Returns the length of the
line which is the result of the layout call. |
void |
moveYLineTo(float y)
Moves the vertical position to the parameter's value.
|
protected boolean |
resolveFonts(List<IRenderer> addTo)
Resolve
Property.FONT string value. |
protected void |
setGlyphLineAndFont(com.itextpdf.io.font.otf.GlyphLine gl,
PdfFont font) |
void |
setText(com.itextpdf.io.font.otf.GlyphLine text,
int leftPos,
int rightPos)
Manually sets a GlyphLine to be rendered with a specific start and end
point.
|
void |
setText(String text)
Manually sets the contents of the Text's representation on the canvas,
regardless of the Text's own contents.
|
protected TextRenderer[] |
split(int initialOverflowTextPos) |
String |
toString()
Returns a string representation of the renderer.
|
void |
trimFirst()
Trims any whitespace characters from the start of the
GlyphLine
to be rendered. |
float |
trimLast()
Deprecated.
visibility will be changed to package.
|
addAllProperties, addChild, alignChildHorizontally, alignChildHorizontally, applyAbsolutePosition, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTranformationIfApplied, calculateAbsolutePdfBBox, calculateBBox, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBorderArea, deleteOwnProperty, deleteProperty, drawBorder, drawChildren, endElementOpacityApplying, endTranformationIfApplied, getBorderAreaBBox, getBorders, getChildRenderers, getDefaultProperty, getInnerAreaBBox, getMargins, getModelElement, getOccupiedArea, getOccupiedAreaBBox, getOwnProperties, getOwnProperty, getPaddings, getParent, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, hasAbsoluteUnitValue, hasOwnOrModelProperty, hasOwnProperty, hasProperty, initElementAreas, isAbsolutePosition, isFixedLayout, isFlushed, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isPositioned, isRelativePosition, isStaticLayout, move, overrideHeightProperties, rectangleToPointsList, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveUnitValue, retrieveWidth, setBorders, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, transformPoints, updateHeightsOnSplitclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddChild, getChildRenderers, getModelElement, getOccupiedArea, getProperty, isFlushed, move, setParentdeleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setPropertyprotected static final float TEXT_SPACE_COEFF
protected float yLineOffset
protected com.itextpdf.io.font.otf.GlyphLine text
protected com.itextpdf.io.font.otf.GlyphLine line
protected String strToBeConverted
protected boolean otfFeaturesApplied
protected float tabAnchorCharacterPosition
protected List<int[]> reversedRanges
protected com.itextpdf.io.font.otf.GlyphLine savedWordBreakAtLineEnding
public TextRenderer(Text textElement)
textElement - the Text which this object should managepublic TextRenderer(Text textElement, String text)
Text.textElement - the Text which this object should managetext - the replacement textprotected TextRenderer(TextRenderer other)
public LayoutResult layout(LayoutContext layoutContext)
IRendererLayoutResult, representing the layout result, including occupied area, status, i.e.
if there was enough place to fit the renderer subtree, etc.
LayoutResult can be extended to return custom layout results for custom elements, e.g.
TextRenderer uses TextLayoutResult as its result.
This method can be called standalone to learn how much area the renderer subtree needs, or can be called
before IRenderer.draw(DrawContext), to prepare the renderer to be flushed to the output stream.public void applyOtf()
public void draw(DrawContext drawContext)
AbstractRendererPdfDocument etc.draw in interface IRendererdraw in class AbstractRendererdrawContext - contains the PdfDocument to which the renderer subtree if flushed,
the PdfCanvas on which the renderer subtree is drawn and other additional parameters
needed to perform drawingpublic void drawBackground(DrawContext drawContext)
AbstractRendererProperty.BACKGROUND
in either the layout element or this IRenderer itself.drawBackground in class AbstractRendererdrawContext - the context (canvas, document, etc) of this drawing operation.public void trimFirst()
GlyphLine
to be rendered.@Deprecated public float trimLast()
GlyphLine.public float getAscent()
getAscent in interface ILeafElementRendererTextpublic float getDescent()
getDescent in interface ILeafElementRendererTextpublic float getYLine()
Text's contents will be written.DrawContextpublic void moveYLineTo(float y)
y - the new vertical position of the Textpublic void setText(String text)
text - the replacement textpublic void setText(com.itextpdf.io.font.otf.GlyphLine text,
int leftPos,
int rightPos)
text - a GlyphLineleftPos - the leftmost end of the GlyphLinerightPos - the rightmost end of the GlyphLinepublic com.itextpdf.io.font.otf.GlyphLine getText()
public int length()
public String toString()
AbstractRenderertoString in class AbstractRendererStringObject.toString()public int charAt(int pos)
pos - the position in range [0; length())public float getTabAnchorCharacterPosition()
public IRenderer getNextRenderer()
IRendererIRenderer.layout(LayoutContext) is called more than once.getNextRenderer in interface IRenderer@Deprecated protected static boolean isNewLine(com.itextpdf.io.font.otf.GlyphLine text, int ind)
TextUtil.isNewLine(Glyph) instead.protected Float getFirstYLineRecursively()
AbstractRenderergetFirstYLineRecursively in class AbstractRendererprotected Float getLastYLineRecursively()
getLastYLineRecursively in class AbstractRendererprotected int lineLength()
line which is the result of the layout call.protected int baseCharactersCount()
protected MinMaxWidth getMinMaxWidth(float availableWidth)
getMinMaxWidth in class AbstractRendererprotected int getNumberOfSpaces()
protected TextRenderer createSplitRenderer()
protected TextRenderer createOverflowRenderer()
protected TextRenderer[] split(int initialOverflowTextPos)
@Deprecated protected void drawSingleUnderline(Underline underline, Color fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
protected void drawSingleUnderline(Underline underline, TransparentColor fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
protected float calculateLineWidth()
protected boolean resolveFonts(List<IRenderer> addTo)
Property.FONT string value.addTo - add all processed renderers to.TextRenderer has been created.protected void setGlyphLineAndFont(com.itextpdf.io.font.otf.GlyphLine gl,
PdfFont font)
protected TextRenderer createCopy(com.itextpdf.io.font.otf.GlyphLine gl, PdfFont font)
Copyright © 1998–2017 iText Group NV. All rights reserved.