Class TextRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.TextRenderer
-
- All Implemented Interfaces:
IPropertyContainer
,ILeafElementRenderer
,IRenderer
- Direct Known Subclasses:
FormFieldValueNonTrimmingTextRenderer
,LinkRenderer
,ListRenderer.ConstantFontTextRenderer
public class TextRenderer extends AbstractRenderer implements ILeafElementRenderer
This class represents therenderer
object for aText
object. It will draw the glyphs of the textual content on theDrawContext
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TextRenderer.CustomGlyphLineFilter
private static class
TextRenderer.ReversedCharsIterator
private static class
TextRenderer.ScriptRange
-
Field Summary
Fields Modifier and Type Field Description private static float
BOLD_SIMULATION_STROKE_COEFF
private PdfFont
font
private int
indexOfFirstCharacterToBeForcedToOverflow
private static float
ITALIC_ANGLE
protected GlyphLine
line
protected boolean
otfFeaturesApplied
protected java.util.List<int[]>
reversedRanges
protected GlyphLine
savedWordBreakAtLineEnding
private int
specialScriptFirstNotFittingIndex
private java.util.List<java.lang.Integer>
specialScriptsWordBreakPoints
protected java.lang.String
strToBeConverted
protected float
tabAnchorCharacterPosition
protected GlyphLine
text
protected static float
TEXT_SPACE_COEFF
(package private) static float
TYPO_ASCENDER_SCALE_COEFF
(package private) static int
UNDEFINED_FIRST_CHAR_TO_FORCE_OVERFLOW
protected float
yLineOffset
-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
BOTTOM_SIDE, childRenderers, EPS, flushed, INF, isLastRendererForModelElement, LEFT_SIDE, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties, RIGHT_SIDE, TOP_SIDE
-
-
Constructor Summary
Constructors Modifier Constructor Description TextRenderer(Text textElement)
Creates a TextRenderer from its corresponding layout object.TextRenderer(Text textElement, java.lang.String text)
Creates a TextRenderer from its corresponding layout object, with a custom text to replace the contents of theText
.protected
TextRenderer(TextRenderer other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyOtf()
protected int
baseCharactersCount()
static float[]
calculateAscenderDescender(PdfFont font)
Get ascender and descender from font metrics.static float[]
calculateAscenderDescender(PdfFont font, RenderingMode mode)
Get ascender and descender from font metrics.protected float
calculateLineWidth()
int
charAt(int pos)
Gets char code at given position for the text belonging to this renderer.(package private) static boolean
codePointIsOfSpecialScript(int codePoint)
private GlyphLine
convertToGlyphLine(java.lang.String text)
protected TextRenderer
createCopy(GlyphLine gl, PdfFont font)
protected TextRenderer
createOverflowRenderer()
protected TextRenderer
createSplitRenderer()
void
draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e.private void
drawAndTagSingleUnderline(boolean isTagged, Underline underline, TransparentColor fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
protected void
drawSingleUnderline(Underline underline, TransparentColor fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
(package private) static int
findPossibleBreaksSplitPosition(java.util.List<java.lang.Integer> list, int textStartBasedInitialOverflowTextPos, boolean amongPresentOnly)
float
getAscent()
Gets the maximum offset above the base line that this Text extends to.protected Rectangle
getBackgroundArea(Rectangle occupiedAreaWithMargins)
Evaluate the actual backgroundprivate float
getCharWidth(Glyph g, float fontSize, java.lang.Float hScale, java.lang.Float characterSpacing, java.lang.Float wordSpacing)
float
getDescent()
Gets the maximum offset below the base line that this Text extends to.protected java.lang.Float
getFirstYLineRecursively()
Gets the first yLine of the nested children recursively.private float
getGlyphLineWidth(GlyphLine glyphLine, float fontSize, float hScale, java.lang.Float characterSpacing, java.lang.Float wordSpacing)
protected java.lang.Float
getLastYLineRecursively()
MinMaxWidth
getMinMaxWidth()
Calculates min and max width values for current renderer.IRenderer
getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.protected int
getNumberOfSpaces()
(package private) java.util.List<int[]>
getReversedRanges()
(package private) int
getSpecialScriptFirstNotFittingIndex()
(package private) java.util.List<java.lang.Integer>
getSpecialScriptsWordBreakPoints()
float
getTabAnchorCharacterPosition()
GlyphLine
getText()
private int[]
getWordBoundsForHyphenation(GlyphLine text, int leftTextPos, int rightTextPos, int wordMiddleCharPos)
float
getYLine()
Gets the position on the canvas of the imaginary horizontal line upon which theText
's contents will be written.private static boolean
glyphBelongsToNonBreakingHyphenRelatedChunk(GlyphLine text, int ind)
private boolean
hasOtfFont()
private void
increaseYLineOffset(UnitValue[] paddings, Border[] borders, UnitValue[] margins)
(package private) java.util.List<int[]>
initReversedRanges()
private boolean
isGlyphPartOfWordForHyphenation(Glyph g)
(package private) boolean[]
isStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(ISplitCharacters splitCharacters)
Identifies two properties for the layouted text renderer text: start and end break possibilities.LayoutResult
layout(LayoutContext layoutContext)
This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, 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 theline
which is the result of the layout call.void
moveYLineTo(float y)
Moves the vertical position to the parameter's value.private static boolean
noPrint(Glyph g)
private static int
numberOfElementsLessThan(java.util.ArrayList<java.lang.Integer> numbers, int n)
private static int
numberOfElementsLessThanOrEqual(java.util.ArrayList<java.lang.Integer> numbers, int n)
(package private) TextRenderer
removeReversedRanges()
(package private) PdfFont
resolveFirstPdfFont(java.lang.String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts)
Get first validPdfFont
for this renderer, based on given font-families, font provider and font characteristics.protected boolean
resolveFonts(java.util.List<IRenderer> addTo)
ResolveProperty.FONT
String[] value.private void
saveWordBreakIfNotYetSaved(Glyph wordBreak)
private float
scaleXAdvance(float xAdvance, float fontSize, java.lang.Float hScale)
(package private) void
setIndexOfFirstCharacterToBeForcedToOverflow(int indexOfFirstCharacterToBeForcedToOverflow)
protected void
setProcessedGlyphLineAndFont(GlyphLine gl, PdfFont font)
(package private) void
setSpecialScriptFirstNotFittingIndex(int lastFittingIndex)
(package private) void
setSpecialScriptsWordBreakPoints(java.util.List<java.lang.Integer> specialScriptsWordBreakPoints)
void
setText(GlyphLine text, PdfFont font)
Manually set a GlyphLine and PdfFont for rendering.void
setText(java.lang.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)
private TextRenderer[]
splitIgnoreFirstNewLine(int currentTextPos)
(package private) boolean
textContainsSpecialScriptGlyphs(boolean analyzeSpecialScriptsWordBreakPointsOnly)
Analyzes/checks whethertext
, bounded by start and end, contains glyphs belonging to special script.java.lang.String
toString()
Returns a string representation of the renderer.void
trimFirst()
Trims any whitespace characters from the start of theGlyphLine
to be rendered.(package private) float
trimLast()
private void
updateFontAndText()
(package private) static void
updateRangeBasedOnRemovedCharacters(java.util.ArrayList<java.lang.Integer> removedIds, int[] range)
-
Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllChildRenderers, addAllChildRenderers, addAllProperties, addChild, addChildRenderer, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAbsolutePositionIfNeeded, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyMarginsBordersPaddings, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateAdditionalWidth, calculateBBox, calculatePaddingBorderHeight, calculatePaddingBorderWidth, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createFontCharacteristics, createXObject, deleteOwnProperty, deleteProperty, drawBackground, drawBorder, drawChildren, drawPositionedChildren, endElementOpacityApplying, endTransformationIfApplied, getAspectRatio, getBorderAreaBBox, getBorderRadii, getBorders, getBorders, getChildRenderers, getDefaultProperty, getInnerAreaBBox, getMargins, getModelElement, getOccupiedArea, getOccupiedAreaBBox, getOwnProperties, getOwnProperty, getPaddings, getParent, getPdfDocument, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, getPropertyAsUnitValue, getRootRenderer, hasAbsoluteUnitValue, hasAspectRatio, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, logWarningIfGetNextRendererNotOverridden, move, noAbsolutePositionInfo, preparePositionedRendererAndAreaForLayout, processWaitingDrawing, rectangleToPointsList, removeAllChildRenderers, removeChildRenderer, replaceOwnProperty, resolveFirstPdfFont, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveUnitValue, retrieveUnitValue, retrieveWidth, returnBackOwnProperty, setBorders, setChildRenderer, setChildRenderers, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, setThisAsParent, shrinkOccupiedAreaForAbsolutePosition, transformPoints, updateHeight, updateHeightsOnSplit, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidth
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
-
Methods inherited from interface com.itextpdf.layout.renderer.IRenderer
addChild, getChildRenderers, getModelElement, getOccupiedArea, getParent, getProperty, isFlushed, move, setParent
-
-
-
-
Field Detail
-
TEXT_SPACE_COEFF
protected static final float TEXT_SPACE_COEFF
- See Also:
- Constant Field Values
-
TYPO_ASCENDER_SCALE_COEFF
static final float TYPO_ASCENDER_SCALE_COEFF
- See Also:
- Constant Field Values
-
UNDEFINED_FIRST_CHAR_TO_FORCE_OVERFLOW
static final int UNDEFINED_FIRST_CHAR_TO_FORCE_OVERFLOW
- See Also:
- Constant Field Values
-
ITALIC_ANGLE
private static final float ITALIC_ANGLE
- See Also:
- Constant Field Values
-
BOLD_SIMULATION_STROKE_COEFF
private static final float BOLD_SIMULATION_STROKE_COEFF
- See Also:
- Constant Field Values
-
yLineOffset
protected float yLineOffset
-
font
private PdfFont font
-
text
protected GlyphLine text
-
line
protected GlyphLine line
-
strToBeConverted
protected java.lang.String strToBeConverted
-
otfFeaturesApplied
protected boolean otfFeaturesApplied
-
tabAnchorCharacterPosition
protected float tabAnchorCharacterPosition
-
reversedRanges
protected java.util.List<int[]> reversedRanges
-
savedWordBreakAtLineEnding
protected GlyphLine savedWordBreakAtLineEnding
-
specialScriptsWordBreakPoints
private java.util.List<java.lang.Integer> specialScriptsWordBreakPoints
-
specialScriptFirstNotFittingIndex
private int specialScriptFirstNotFittingIndex
-
indexOfFirstCharacterToBeForcedToOverflow
private int indexOfFirstCharacterToBeForcedToOverflow
-
-
Constructor Detail
-
TextRenderer
public TextRenderer(Text textElement)
Creates a TextRenderer from its corresponding layout object.- Parameters:
textElement
- theText
which this object should manage
-
TextRenderer
public TextRenderer(Text textElement, java.lang.String text)
Creates a TextRenderer from its corresponding layout object, with a custom text to replace the contents of theText
.- Parameters:
textElement
- theText
which this object should managetext
- the replacement text
-
TextRenderer
protected TextRenderer(TextRenderer other)
-
-
Method Detail
-
layout
public LayoutResult layout(LayoutContext layoutContext)
Description copied from interface:IRenderer
This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, 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
usesTextLayoutResult
as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called beforeIRenderer.draw(DrawContext)
, to prepare the renderer to be flushed to the output stream.
-
increaseYLineOffset
private void increaseYLineOffset(UnitValue[] paddings, Border[] borders, UnitValue[] margins)
-
applyOtf
public void applyOtf()
-
draw
public void draw(DrawContext drawContext)
Description copied from class:AbstractRenderer
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocument
etc.- Specified by:
draw
in interfaceIRenderer
- Overrides:
draw
in classAbstractRenderer
- Parameters:
drawContext
- contains thePdfDocument
to which the renderer subtree if flushed, thePdfCanvas
on which the renderer subtree is drawn and other additional parameters needed to perform drawing
-
trimFirst
public void trimFirst()
Trims any whitespace characters from the start of theGlyphLine
to be rendered.
-
trimLast
float trimLast()
-
getAscent
public float getAscent()
Gets the maximum offset above the base line that this Text extends to.- Specified by:
getAscent
in interfaceILeafElementRenderer
- Returns:
- the upwards vertical offset of this
Text
-
getDescent
public float getDescent()
Gets the maximum offset below the base line that this Text extends to.- Specified by:
getDescent
in interfaceILeafElementRenderer
- Returns:
- the downwards vertical offset of this
Text
-
getYLine
public float getYLine()
Gets the position on the canvas of the imaginary horizontal line upon which theText
's contents will be written.- Returns:
- the y position of this text on the
DrawContext
-
moveYLineTo
public void moveYLineTo(float y)
Moves the vertical position to the parameter's value.- Parameters:
y
- the new vertical position of the Text
-
setText
public void setText(java.lang.String text)
Manually sets the contents of the Text's representation on the canvas, regardless of the Text's own contents.- Parameters:
text
- the replacement text
-
setText
public void setText(GlyphLine text, PdfFont font)
Manually set a GlyphLine and PdfFont for rendering.- Parameters:
text
- theGlyphLine
font
- the font
-
getText
public GlyphLine getText()
-
length
public int length()
The length of the whole text assigned to this renderer.- Returns:
- the text length
-
toString
public java.lang.String toString()
Description copied from class:AbstractRenderer
Returns a string representation of the renderer.- Overrides:
toString
in classAbstractRenderer
- Returns:
- a
String
- See Also:
Object.toString()
-
charAt
public int charAt(int pos)
Gets char code at given position for the text belonging to this renderer.- Parameters:
pos
- the position in range [0; length())- Returns:
- Unicode char code
-
getTabAnchorCharacterPosition
public float getTabAnchorCharacterPosition()
-
getNextRenderer
public IRenderer getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, iflayout(LayoutContext)
is called more than once.If
TextRenderer
overflows to the next line, iText uses this method to create a renderer for the overflow part. So if one wants to extendTextRenderer
, one should override this method: otherwise the default method will be used and thus the default rather than the custom renderer will be created. Another method that should be overridden in case ofTextRenderer
's extension iscreateCopy(GlyphLine, PdfFont)
. This method is responsible for creation ofTextRenderer
's copies, which represent its parts of specific font.- Specified by:
getNextRenderer
in interfaceIRenderer
- Returns:
- new renderer instance
-
calculateAscenderDescender
public static float[] calculateAscenderDescender(PdfFont font)
Get ascender and descender from font metrics. If these values are obtained from typo metrics they are normalized with a scale coefficient.- Parameters:
font
- from which metrics will be extracted- Returns:
- array in which the first element is an ascender and the second is a descender
-
calculateAscenderDescender
public static float[] calculateAscenderDescender(PdfFont font, RenderingMode mode)
Get ascender and descender from font metrics. In RenderingMode.DEFAULT_LAYOUT_MODE if these values are obtained from typo metrics they are normalized with a scale coefficient.- Parameters:
font
- from which metrics will be extractedmode
- mode in which metrics will be obtained. Impact on the use of scale coefficient- Returns:
- array in which the first element is an ascender and the second is a descender
-
getReversedRanges
java.util.List<int[]> getReversedRanges()
-
initReversedRanges
java.util.List<int[]> initReversedRanges()
-
removeReversedRanges
TextRenderer removeReversedRanges()
-
splitIgnoreFirstNewLine
private TextRenderer[] splitIgnoreFirstNewLine(int currentTextPos)
-
convertToGlyphLine
private GlyphLine convertToGlyphLine(java.lang.String text)
-
hasOtfFont
private boolean hasOtfFont()
-
textContainsSpecialScriptGlyphs
boolean textContainsSpecialScriptGlyphs(boolean analyzeSpecialScriptsWordBreakPointsOnly)
Analyzes/checks whethertext
, bounded by start and end, contains glyphs belonging to special script. Mind that the behavior of this method depends on the analyzeSpecialScriptsWordBreakPointsOnly parameter: - passfalse
if you need to analyze thetext
by checking each of its glyphs AND to fillspecialScriptsWordBreakPoints
list afterwards, i.e. when analyzing a sequence of TextRenderers prior to layouting; - passtrue
if you want to check if text contains glyphs belonging to special scripts, according to the already filledspecialScriptsWordBreakPoints
list.- Parameters:
analyzeSpecialScriptsWordBreakPointsOnly
- false if analysis of each glyph is required, true if analysis has already been performed earlier and the results are stored inspecialScriptsWordBreakPoints
- Returns:
- true if
text
, bounded by start and end, contains glyphs belonging to special script, otherwise false - See Also:
specialScriptsWordBreakPoints
-
setSpecialScriptsWordBreakPoints
void setSpecialScriptsWordBreakPoints(java.util.List<java.lang.Integer> specialScriptsWordBreakPoints)
-
getSpecialScriptsWordBreakPoints
java.util.List<java.lang.Integer> getSpecialScriptsWordBreakPoints()
-
setSpecialScriptFirstNotFittingIndex
void setSpecialScriptFirstNotFittingIndex(int lastFittingIndex)
-
getSpecialScriptFirstNotFittingIndex
int getSpecialScriptFirstNotFittingIndex()
-
setIndexOfFirstCharacterToBeForcedToOverflow
void setIndexOfFirstCharacterToBeForcedToOverflow(int indexOfFirstCharacterToBeForcedToOverflow)
-
getBackgroundArea
protected Rectangle getBackgroundArea(Rectangle occupiedAreaWithMargins)
Description copied from class:AbstractRenderer
Evaluate the actual background- Overrides:
getBackgroundArea
in classAbstractRenderer
- Parameters:
occupiedAreaWithMargins
- the current occupied area with applied margins- Returns:
- the actual background area
-
getFirstYLineRecursively
protected java.lang.Float getFirstYLineRecursively()
Description copied from class:AbstractRenderer
Gets the first yLine of the nested children recursively. E.g. for a list, this will be the yLine of the first item (if the first item is indeed a paragraph). NOTE: this method will no go further than the first child.- Overrides:
getFirstYLineRecursively
in classAbstractRenderer
- Returns:
- the first yline of the nested children, null if there is no text found
-
getLastYLineRecursively
protected java.lang.Float getLastYLineRecursively()
- Overrides:
getLastYLineRecursively
in classAbstractRenderer
-
lineLength
protected int lineLength()
Returns the length of theline
which is the result of the layout call.- Returns:
- the length of the line
-
baseCharactersCount
protected int baseCharactersCount()
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth()
Description copied from class:AbstractRenderer
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidth
in classAbstractRenderer
- Returns:
- instance of
MinMaxWidth
-
getNumberOfSpaces
protected int getNumberOfSpaces()
-
createSplitRenderer
protected TextRenderer createSplitRenderer()
-
createOverflowRenderer
protected TextRenderer createOverflowRenderer()
-
split
protected TextRenderer[] split(int initialOverflowTextPos)
-
drawSingleUnderline
protected void drawSingleUnderline(Underline underline, TransparentColor fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
-
calculateLineWidth
protected float calculateLineWidth()
-
resolveFonts
protected boolean resolveFonts(java.util.List<IRenderer> addTo)
ResolveProperty.FONT
String[] value.- Parameters:
addTo
- add all processed renderers to.- Returns:
- true, if new
TextRenderer
has been created.
-
setProcessedGlyphLineAndFont
protected void setProcessedGlyphLineAndFont(GlyphLine gl, PdfFont font)
-
createCopy
protected TextRenderer createCopy(GlyphLine gl, PdfFont font)
Creates a copy of thisTextRenderer
, which corresponds to the passedGlyphLine
withPdfFont
.While processing
TextRenderer
, iText uses this method to createglyph lines
of specificfonts
, which represent theTextRenderer
's parts. If one extendsTextRenderer
, one should override this method, otherwise ifFontSelector
related logic is triggered, copies of thisTextRenderer
will have the default behavior rather than the custom one.- Parameters:
gl
- aGlyphLine
which represents some of thisTextRenderer
's contentfont
- aPdfFont
for this part of theTextRenderer
's content- Returns:
- copy of this
TextRenderer
, which correspond to the passedGlyphLine
withPdfFont
-
updateRangeBasedOnRemovedCharacters
static void updateRangeBasedOnRemovedCharacters(java.util.ArrayList<java.lang.Integer> removedIds, int[] range)
-
findPossibleBreaksSplitPosition
static int findPossibleBreaksSplitPosition(java.util.List<java.lang.Integer> list, int textStartBasedInitialOverflowTextPos, boolean amongPresentOnly)
-
codePointIsOfSpecialScript
static boolean codePointIsOfSpecialScript(int codePoint)
-
resolveFirstPdfFont
PdfFont resolveFirstPdfFont(java.lang.String[] font, FontProvider provider, FontCharacteristics fc, FontSet additionalFonts)
Description copied from class:AbstractRenderer
Get first validPdfFont
for this renderer, based on given font-families, font provider and font characteristics. This method will not change font property of renderer. Also it is not guarantied that returned font will contain all glyphs used in renderer or its children.This method is usually needed for evaluating some layout characteristics like ascender or descender.
- Overrides:
resolveFirstPdfFont
in classAbstractRenderer
- Returns:
- a valid
PdfFont
instance based on rendererProperty.FONT
property.
-
isStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar
boolean[] isStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(ISplitCharacters splitCharacters)
Identifies two properties for the layouted text renderer text: start and end break possibilities. First - if it ends with split character, second - if it starts with the split character which is at the same time is a whitespace character. These properties will later be used for identifying if we can consider this and previous/next text renderers chunks to be a part of a single word spanning across the text renderers boundaries. In the start of the text renderer we only care about split characters, which are white spaces, because only such will allow soft-breaks before them: normally split characters allow breaks only after them.- Parameters:
splitCharacters
- current rendererISplitCharacters
property value- Returns:
- a boolean array of two elements, where first element identifies start break possibility, and second - end break possibility.
-
drawAndTagSingleUnderline
private void drawAndTagSingleUnderline(boolean isTagged, Underline underline, TransparentColor fontStrokeColor, PdfCanvas canvas, float fontSize, float italicAngleTan)
-
getCharWidth
private float getCharWidth(Glyph g, float fontSize, java.lang.Float hScale, java.lang.Float characterSpacing, java.lang.Float wordSpacing)
-
scaleXAdvance
private float scaleXAdvance(float xAdvance, float fontSize, java.lang.Float hScale)
-
getGlyphLineWidth
private float getGlyphLineWidth(GlyphLine glyphLine, float fontSize, float hScale, java.lang.Float characterSpacing, java.lang.Float wordSpacing)
-
getWordBoundsForHyphenation
private int[] getWordBoundsForHyphenation(GlyphLine text, int leftTextPos, int rightTextPos, int wordMiddleCharPos)
-
isGlyphPartOfWordForHyphenation
private boolean isGlyphPartOfWordForHyphenation(Glyph g)
-
updateFontAndText
private void updateFontAndText()
-
saveWordBreakIfNotYetSaved
private void saveWordBreakIfNotYetSaved(Glyph wordBreak)
-
numberOfElementsLessThan
private static int numberOfElementsLessThan(java.util.ArrayList<java.lang.Integer> numbers, int n)
-
numberOfElementsLessThanOrEqual
private static int numberOfElementsLessThanOrEqual(java.util.ArrayList<java.lang.Integer> numbers, int n)
-
noPrint
private static boolean noPrint(Glyph g)
-
glyphBelongsToNonBreakingHyphenRelatedChunk
private static boolean glyphBelongsToNonBreakingHyphenRelatedChunk(GlyphLine text, int ind)
-
-