Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2019 iText Group NV
Authors: Bruno Lowagie, Paulo Soares, et al.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation with the addition of the
following permission added to Section 15 as permitted in Section 7(a):
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
OF THIRD PARTY RIGHTS
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see http://www.gnu.org/licenses or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA, 02110-1301 USA, or download the license from the following URL:
http://itextpdf.com/terms-of-use/
The interactive user interfaces in modified source and object code versions
of this program must display Appropriate Legal Notices, as required under
Section 5 of the GNU Affero General Public License.
In accordance with Section 7(b) of the GNU Affero General Public License,
a covered work must retain the producer line in every PDF that is created
or manipulated using iText.
You can be released from the requirements of the license by purchasing
a commercial license. Buying such a license is mandatory as soon as you
develop commercial activities involving the iText software without
disclosing the source code of your own applications.
These activities include: offering paid services to customers as an ASP,
serving PDFs on the fly in a web application, shipping iText with a closed
source product.
For more information, please contact iText Software Corp. at this
address: [email protected]
*/
package com.itextpdf.layout.renderer;
import com.itextpdf.io.LogMessageConstant;
import com.itextpdf.io.font.FontMetrics;
import com.itextpdf.io.font.FontProgram;
import com.itextpdf.io.font.TrueTypeFont;
import com.itextpdf.io.font.otf.Glyph;
import com.itextpdf.io.font.otf.GlyphLine;
import com.itextpdf.io.util.EnumUtil;
import com.itextpdf.io.util.MessageFormatUtil;
import com.itextpdf.io.util.TextUtil;
import com.itextpdf.kernel.PdfException;
import com.itextpdf.kernel.colors.Color;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfType0Font;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.CanvasArtifact;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants;
import com.itextpdf.kernel.pdf.tagutils.TagTreePointer;
import com.itextpdf.layout.borders.Border;
import com.itextpdf.layout.element.Text;
import com.itextpdf.layout.font.FontCharacteristics;
import com.itextpdf.layout.font.FontFamilySplitter;
import com.itextpdf.layout.font.FontProvider;
import com.itextpdf.layout.font.FontSelectorStrategy;
import com.itextpdf.layout.font.FontSet;
import com.itextpdf.layout.hyphenation.Hyphenation;
import com.itextpdf.layout.hyphenation.HyphenationConfig;
import com.itextpdf.layout.layout.LayoutArea;
import com.itextpdf.layout.layout.LayoutContext;
import com.itextpdf.layout.layout.LayoutResult;
import com.itextpdf.layout.layout.TextLayoutResult;
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
import com.itextpdf.layout.minmaxwidth.MinMaxWidthUtils;
import com.itextpdf.layout.property.Background;
import com.itextpdf.layout.property.BaseDirection;
import com.itextpdf.layout.property.FloatPropertyValue;
import com.itextpdf.layout.property.FontKerning;
import com.itextpdf.layout.property.OverflowPropertyValue;
import com.itextpdf.layout.property.Property;
import com.itextpdf.layout.property.TransparentColor;
import com.itextpdf.layout.property.Underline;
import com.itextpdf.layout.property.UnitValue;
import com.itextpdf.layout.splitting.ISplitCharacters;
import com.itextpdf.layout.tagging.LayoutTaggingHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* This class represents the {@link IRenderer renderer} object for a {@link Text}
* object. It will draw the glyphs of the textual content on the {@link DrawContext}.
*/
public class TextRenderer extends AbstractRenderer implements ILeafElementRenderer {
protected static final float TEXT_SPACE_COEFF = FontProgram.UNITS_NORMALIZATION;
private static final float ITALIC_ANGLE = 0.21256f;
private static final float BOLD_SIMULATION_STROKE_COEFF = 1 / 30f;
private static final float TYPO_ASCENDER_SCALE_COEFF = 1.2f;
protected float yLineOffset;
// font should be stored only during converting original string to GlyphLine, however now it's not true
private PdfFont font;
protected GlyphLine text;
protected GlyphLine line;
protected String strToBeConverted;
protected boolean otfFeaturesApplied = false;
protected float tabAnchorCharacterPosition = -1;
protected List reversedRanges;
protected GlyphLine savedWordBreakAtLineEnding;
/**
* Creates a TextRenderer from its corresponding layout object.
*
* @param textElement the {@link Text} which this object should manage
*/
public TextRenderer(Text textElement) {
this(textElement, textElement.getText());
}
/**
* Creates a TextRenderer from its corresponding layout object, with a custom
* text to replace the contents of the {@link Text}.
*
* @param textElement the {@link Text} which this object should manage
* @param text the replacement text
*/
public TextRenderer(Text textElement, String text) {
super(textElement);
this.strToBeConverted = text;
}
protected TextRenderer(TextRenderer other) {
super(other);
this.text = other.text;
this.line = other.line;
this.font = other.font;
this.yLineOffset = other.yLineOffset;
this.strToBeConverted = other.strToBeConverted;
this.otfFeaturesApplied = other.otfFeaturesApplied;
this.tabAnchorCharacterPosition = other.tabAnchorCharacterPosition;
this.reversedRanges = other.reversedRanges;
}
@Override
public LayoutResult layout(LayoutContext layoutContext) {
updateFontAndText();
if (null != text) {
// if text != null => font != null
text = replaceSpecialWhitespaceGlyphs(text, font);
}
LayoutArea area = layoutContext.getArea();
Rectangle layoutBox = area.getBBox().clone();
boolean noSoftWrap = Boolean.TRUE.equals(this.parent.getOwnProperty(Property.NO_SOFT_WRAP_INLINE));
OverflowPropertyValue overflowX = this.parent.getProperty(Property.OVERFLOW_X);
List floatRendererAreas = layoutContext.getFloatRendererAreas();
FloatPropertyValue floatPropertyValue = this.getProperty(Property.FLOAT);
if (FloatingHelper.isRendererFloating(this, floatPropertyValue)) {
FloatingHelper.adjustFloatedBlockLayoutBox(this, layoutBox, null, floatRendererAreas, floatPropertyValue, overflowX);
}
UnitValue[] margins = getMargins();
applyMargins(layoutBox, margins, false);
Border[] borders = getBorders();
applyBorderBox(layoutBox, borders, false);
UnitValue[] paddings = getPaddings();
applyPaddings(layoutBox, paddings, false);
MinMaxWidth countedMinMaxWidth = new MinMaxWidth(area.getBBox().getWidth() - layoutBox.getWidth());
AbstractWidthHandler widthHandler;
if (noSoftWrap) {
widthHandler = new SumSumWidthHandler(countedMinMaxWidth);
} else {
widthHandler = new MaxSumWidthHandler(countedMinMaxWidth);
}
occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY() + layoutBox.getHeight(), 0, 0));
boolean anythingPlaced = false;
int currentTextPos = text.start;
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
if (!fontSize.isPointValue()) {
Logger logger = LoggerFactory.getLogger(TextRenderer.class);
logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
}
float textRise = (float) this.getPropertyAsFloat(Property.TEXT_RISE);
Float characterSpacing = this.getPropertyAsFloat(Property.CHARACTER_SPACING);
Float wordSpacing = this.getPropertyAsFloat(Property.WORD_SPACING);
float hScale = (float) this.getProperty(Property.HORIZONTAL_SCALING, (Float) 1f);
ISplitCharacters splitCharacters = this.getProperty(Property.SPLIT_CHARACTERS);
float italicSkewAddition = Boolean.TRUE.equals(getPropertyAsBoolean(Property.ITALIC_SIMULATION)) ? ITALIC_ANGLE * fontSize.getValue() : 0;
float boldSimulationAddition = Boolean.TRUE.equals(getPropertyAsBoolean(Property.BOLD_SIMULATION)) ? BOLD_SIMULATION_STROKE_COEFF * fontSize.getValue() : 0;
line = new GlyphLine(text);
line.start = line.end = -1;
float[] ascenderDescender = calculateAscenderDescender(font);
float ascender = ascenderDescender[0];
float descender = ascenderDescender[1];
float currentLineAscender = 0;
float currentLineDescender = 0;
float currentLineHeight = 0;
int initialLineTextPos = currentTextPos;
float currentLineWidth = 0;
int previousCharPos = -1;
savedWordBreakAtLineEnding = null;
Glyph wordBreakGlyphAtLineEnding = null;
Character tabAnchorCharacter = this.getProperty(Property.TAB_ANCHOR);
TextLayoutResult result = null;
OverflowPropertyValue overflowY = !layoutContext.isClippedHeight()
? OverflowPropertyValue.FIT
: this.parent.getProperty(Property.OVERFLOW_Y);
// true in situations like "\nHello World" or "Hello\nWorld"
boolean isSplitForcedByNewLine = false;
// needed in situation like "\nHello World" or " Hello World", when split occurs on first character, but we want to leave it on previous line
boolean forcePartialSplitOnFirstChar = false;
// true in situations like "Hello\nWorld"
boolean ignoreNewLineSymbol = false;
// true when \r\n are found
boolean crlf = false;
HyphenationConfig hyphenationConfig = this.getProperty(Property.HYPHENATION);
// For example, if a first character is a RTL mark (U+200F), and the second is a newline, we need to break anyway
int firstPrintPos = currentTextPos;
while (firstPrintPos < text.end && noPrint(text.get(firstPrintPos))) {
firstPrintPos++;
}
while (currentTextPos < text.end) {
if (noPrint(text.get(currentTextPos))) {
if (line.start == -1) {
line.start = currentTextPos;
}
line.end = Math.max(line.end, currentTextPos + 1);
currentTextPos++;
continue;
}
int nonBreakablePartEnd = text.end - 1;
float nonBreakablePartFullWidth = 0;
float nonBreakablePartWidthWhichDoesNotExceedAllowedWidth = 0;
float nonBreakablePartMaxAscender = 0;
float nonBreakablePartMaxDescender = 0;
float nonBreakablePartMaxHeight = 0;
int firstCharacterWhichExceedsAllowedWidth = -1;
float nonBreakingHyphenRelatedChunkWidth = 0;
int nonBreakingHyphenRelatedChunkStart = -1;
float beforeNonBreakingHyphenRelatedChunkMaxAscender = 0;
float beforeNonBreakingHyphenRelatedChunkMaxDescender = 0;
for (int ind = currentTextPos; ind < text.end; ind++) {
if (TextUtil.isNewLine(text.get(ind))) {
wordBreakGlyphAtLineEnding = text.get(ind);
isSplitForcedByNewLine = true;
firstCharacterWhichExceedsAllowedWidth = ind + 1;
if (ind != firstPrintPos) {
ignoreNewLineSymbol = true;
} else {
// Notice that in that case we do not need to ignore the new line symbol ('\n')
forcePartialSplitOnFirstChar = true;
}
if (line.start == -1) {
line.start = currentTextPos;
}
crlf = TextUtil.isCarriageReturnFollowedByLineFeed(text, currentTextPos);
if (crlf) {
currentTextPos++;
}
line.end = Math.max(line.end, firstCharacterWhichExceedsAllowedWidth - 1);
break;
}
Glyph currentGlyph = text.get(ind);
if (noPrint(currentGlyph)) {
if (ind + 1 == text.end ||
splitCharacters.isSplitCharacter(text, ind + 1) &&
TextUtil.isSpaceOrWhitespace(text.get(ind + 1))) {
nonBreakablePartEnd = ind;
break;
}
continue;
}
if (tabAnchorCharacter != null && tabAnchorCharacter == text.get(ind).getUnicode()) {
tabAnchorCharacterPosition = currentLineWidth + nonBreakablePartFullWidth;
tabAnchorCharacter = null;
}
float glyphWidth = getCharWidth(currentGlyph, fontSize.getValue(), hScale, characterSpacing, wordSpacing) / TEXT_SPACE_COEFF;
float xAdvance = previousCharPos != -1 ? text.get(previousCharPos).getXAdvance() : 0;
if (xAdvance != 0) {
xAdvance = scaleXAdvance(xAdvance, fontSize.getValue(), hScale) / TEXT_SPACE_COEFF;
}
if (!noSoftWrap
&& (nonBreakablePartFullWidth + glyphWidth + xAdvance + italicSkewAddition + boldSimulationAddition) > layoutBox.getWidth() - currentLineWidth
&& firstCharacterWhichExceedsAllowedWidth == -1) {
firstCharacterWhichExceedsAllowedWidth = ind;
if (TextUtil.isSpaceOrWhitespace(text.get(ind))) {
wordBreakGlyphAtLineEnding = currentGlyph;
if (ind == firstPrintPos) {
forcePartialSplitOnFirstChar = true;
firstCharacterWhichExceedsAllowedWidth = ind + 1;
break;
}
}
}
if (null != hyphenationConfig) {
if (glyphBelongsToNonBreakingHyphenRelatedChunk(text, ind)) {
if (-1 == nonBreakingHyphenRelatedChunkStart) {
beforeNonBreakingHyphenRelatedChunkMaxAscender = nonBreakablePartMaxAscender;
beforeNonBreakingHyphenRelatedChunkMaxDescender = nonBreakablePartMaxDescender;
nonBreakingHyphenRelatedChunkStart = ind;
}
nonBreakingHyphenRelatedChunkWidth += glyphWidth + xAdvance;
} else {
nonBreakingHyphenRelatedChunkStart = -1;
nonBreakingHyphenRelatedChunkWidth = 0;
}
}
if (firstCharacterWhichExceedsAllowedWidth == -1) {
nonBreakablePartWidthWhichDoesNotExceedAllowedWidth += glyphWidth + xAdvance;
}
nonBreakablePartFullWidth += glyphWidth + xAdvance;
nonBreakablePartMaxAscender = Math.max(nonBreakablePartMaxAscender, ascender);
nonBreakablePartMaxDescender = Math.min(nonBreakablePartMaxDescender, descender);
nonBreakablePartMaxHeight = (nonBreakablePartMaxAscender - nonBreakablePartMaxDescender) * fontSize.getValue() / TEXT_SPACE_COEFF + textRise;
previousCharPos = ind;
if (!noSoftWrap
&& nonBreakablePartFullWidth + italicSkewAddition + boldSimulationAddition > layoutBox.getWidth()
&& (0 == nonBreakingHyphenRelatedChunkWidth || ind + 1 == text.end || !glyphBelongsToNonBreakingHyphenRelatedChunk(text, ind + 1))) {
if (isOverflowFit(overflowX)) {
// we have extracted all the information we wanted and we do not want to continue.
// we will have to split the word anyway.
break;
}
}
if (splitCharacters.isSplitCharacter(text, ind) || ind + 1 == text.end ||
splitCharacters.isSplitCharacter(text, ind + 1) &&
TextUtil.isSpaceOrWhitespace(text.get(ind + 1))) {
nonBreakablePartEnd = ind;
break;
}
}
if (firstCharacterWhichExceedsAllowedWidth == -1) {
// can fit the whole word in a line
if (line.start == -1) {
line.start = currentTextPos;
}
line.end = Math.max(line.end, nonBreakablePartEnd + 1);
currentLineAscender = Math.max(currentLineAscender, nonBreakablePartMaxAscender);
currentLineDescender = Math.min(currentLineDescender, nonBreakablePartMaxDescender);
currentLineHeight = Math.max(currentLineHeight, nonBreakablePartMaxHeight);
currentTextPos = nonBreakablePartEnd + 1;
currentLineWidth += nonBreakablePartFullWidth;
widthHandler.updateMinChildWidth(nonBreakablePartWidthWhichDoesNotExceedAllowedWidth + italicSkewAddition + boldSimulationAddition);
widthHandler.updateMaxChildWidth(nonBreakablePartWidthWhichDoesNotExceedAllowedWidth + italicSkewAddition + boldSimulationAddition);
anythingPlaced = true;
} else {
// check if line height exceeds the allowed height
if (Math.max(currentLineHeight, nonBreakablePartMaxHeight) > layoutBox.getHeight() && isOverflowFit(overflowY)) {
applyPaddings(occupiedArea.getBBox(), paddings, true);
applyBorderBox(occupiedArea.getBBox(), borders, true);
applyMargins(occupiedArea.getBBox(), margins, true);
// Force to place what we can
if (line.start == -1) {
line.start = currentTextPos;
}
line.end = Math.max(line.end, firstCharacterWhichExceedsAllowedWidth - 1);
// the line does not fit because of height - full overflow
TextRenderer[] splitResult = split(initialLineTextPos);
return new TextLayoutResult(LayoutResult.NOTHING, occupiedArea, splitResult[0], splitResult[1], this);
} else {
// cannot fit a word as a whole
boolean wordSplit = false;
boolean hyphenationApplied = false;
if (hyphenationConfig != null) {
if (-1 == nonBreakingHyphenRelatedChunkStart) {
int[] wordBounds = getWordBoundsForHyphenation(text, currentTextPos, text.end, Math.max(currentTextPos, firstCharacterWhichExceedsAllowedWidth - 1));
if (wordBounds != null) {
String word = text.toUnicodeString(wordBounds[0], wordBounds[1]);
Hyphenation hyph = hyphenationConfig.hyphenate(word);
if (hyph != null) {
for (int i = hyph.length() - 1; i >= 0; i--) {
String pre = hyph.getPreHyphenText(i);
String pos = hyph.getPostHyphenText(i);
float currentHyphenationChoicePreTextWidth =
getGlyphLineWidth(convertToGlyphLine(text.toUnicodeString(currentTextPos, wordBounds[0]) + pre + hyphenationConfig.getHyphenSymbol()), fontSize.getValue(), hScale, characterSpacing, wordSpacing);
if (currentLineWidth + currentHyphenationChoicePreTextWidth + italicSkewAddition + boldSimulationAddition <= layoutBox.getWidth()) {
hyphenationApplied = true;
if (line.start == -1) {
line.start = currentTextPos;
}
line.end = Math.max(line.end, wordBounds[0] + pre.length());
GlyphLine lineCopy = line.copy(line.start, line.end);
lineCopy.add(font.getGlyph(hyphenationConfig.getHyphenSymbol()));
lineCopy.end++;
line = lineCopy;
// TODO these values are based on whole word. recalculate properly based on hyphenated part
currentLineAscender = Math.max(currentLineAscender, nonBreakablePartMaxAscender);
currentLineDescender = Math.min(currentLineDescender, nonBreakablePartMaxDescender);
currentLineHeight = Math.max(currentLineHeight, nonBreakablePartMaxHeight);
currentLineWidth += currentHyphenationChoicePreTextWidth;
widthHandler.updateMinChildWidth(currentHyphenationChoicePreTextWidth + italicSkewAddition + boldSimulationAddition);
widthHandler.updateMaxChildWidth(currentHyphenationChoicePreTextWidth + italicSkewAddition + boldSimulationAddition);
currentTextPos = wordBounds[0] + pre.length();
break;
}
}
}
}
} else {
if (text.start == nonBreakingHyphenRelatedChunkStart) {
nonBreakingHyphenRelatedChunkWidth = 0;
firstCharacterWhichExceedsAllowedWidth = previousCharPos + 1;
} else {
firstCharacterWhichExceedsAllowedWidth = nonBreakingHyphenRelatedChunkStart;
nonBreakablePartFullWidth -= nonBreakingHyphenRelatedChunkWidth;
nonBreakablePartMaxAscender = beforeNonBreakingHyphenRelatedChunkMaxAscender;
nonBreakablePartMaxDescender = beforeNonBreakingHyphenRelatedChunkMaxDescender;
}
}
}
if ((nonBreakablePartFullWidth > layoutBox.getWidth() && !anythingPlaced && !hyphenationApplied) || forcePartialSplitOnFirstChar || -1 != nonBreakingHyphenRelatedChunkStart) {
// if the word is too long for a single line we will have to split it
if (line.start == -1) {
line.start = currentTextPos;
}
if (!crlf) {
currentTextPos = (forcePartialSplitOnFirstChar || isOverflowFit(overflowX)) ? firstCharacterWhichExceedsAllowedWidth : nonBreakablePartEnd + 1;
}
line.end = Math.max(line.end, currentTextPos);
wordSplit = !forcePartialSplitOnFirstChar && (text.end != currentTextPos);
if (wordSplit || !(forcePartialSplitOnFirstChar || isOverflowFit(overflowX))) {
currentLineAscender = Math.max(currentLineAscender, nonBreakablePartMaxAscender);
currentLineDescender = Math.min(currentLineDescender, nonBreakablePartMaxDescender);
currentLineHeight = Math.max(currentLineHeight, nonBreakablePartMaxHeight);
currentLineWidth += nonBreakablePartWidthWhichDoesNotExceedAllowedWidth;
widthHandler.updateMinChildWidth(nonBreakablePartWidthWhichDoesNotExceedAllowedWidth + italicSkewAddition + boldSimulationAddition);
widthHandler.updateMaxChildWidth(nonBreakablePartWidthWhichDoesNotExceedAllowedWidth + italicSkewAddition + boldSimulationAddition);
} else {
// process empty line (e.g. '\n')
currentLineAscender = ascender;
currentLineDescender = descender;
currentLineHeight = (currentLineAscender - currentLineDescender) * fontSize.getValue() / TEXT_SPACE_COEFF + textRise;
currentLineWidth += getCharWidth(line.get(line.start), fontSize.getValue(), hScale, characterSpacing, wordSpacing) / TEXT_SPACE_COEFF;
}
}
if (line.end <= line.start) {
return new TextLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this);
} else {
result = new TextLayoutResult(LayoutResult.PARTIAL, occupiedArea, null, null).setWordHasBeenSplit(wordSplit);
}
break;
}
}
}
// indicates whether the placing is forced while the layout result is LayoutResult.NOTHING
boolean isPlacingForcedWhileNothing = false;
if (currentLineHeight > layoutBox.getHeight()) {
if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT)) && isOverflowFit(overflowY)) {
applyPaddings(occupiedArea.getBBox(), paddings, true);
applyBorderBox(occupiedArea.getBBox(), borders, true);
applyMargins(occupiedArea.getBBox(), margins, true);
return new TextLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this);
} else {
isPlacingForcedWhileNothing = true;
}
}
yLineOffset = currentLineAscender * fontSize.getValue() / TEXT_SPACE_COEFF;
occupiedArea.getBBox().moveDown(currentLineHeight);
occupiedArea.getBBox().setHeight(occupiedArea.getBBox().getHeight() + currentLineHeight);
occupiedArea.getBBox().setWidth(Math.max(occupiedArea.getBBox().getWidth(), currentLineWidth));
layoutBox.setHeight(area.getBBox().getHeight() - currentLineHeight);
occupiedArea.getBBox().setWidth(occupiedArea.getBBox().getWidth() + italicSkewAddition + boldSimulationAddition);
applyPaddings(occupiedArea.getBBox(), paddings, true);
applyBorderBox(occupiedArea.getBBox(), borders, true);
applyMargins(occupiedArea.getBBox(), margins, true);
if (result == null) {
result = new TextLayoutResult(LayoutResult.FULL, occupiedArea, null, null, isPlacingForcedWhileNothing ? this : null);
} else {
TextRenderer[] split;
if (ignoreNewLineSymbol || crlf) {
// ignore '\n'
split = splitIgnoreFirstNewLine(currentTextPos);
} else {
split = split(currentTextPos);
}
result.setSplitForcedByNewline(isSplitForcedByNewLine);
result.setSplitRenderer(split[0]);
if (wordBreakGlyphAtLineEnding != null) {
split[0].saveWordBreakIfNotYetSaved(wordBreakGlyphAtLineEnding);
}
// no sense to process empty renderer
if (split[1].text.start != split[1].text.end) {
result.setOverflowRenderer(split[1]);
} else {
// LayoutResult with partial status should have non-null overflow renderer
result.setStatus(LayoutResult.FULL);
}
}
if (FloatingHelper.isRendererFloating(this, floatPropertyValue)) {
if (result.getStatus() == LayoutResult.FULL) {
if (occupiedArea.getBBox().getWidth() > 0) {
floatRendererAreas.add(occupiedArea.getBBox());
}
} else if (result.getStatus() == LayoutResult.PARTIAL) {
floatRendererAreas.add(result.getSplitRenderer().getOccupiedArea().getBBox());
}
}
result.setMinMaxWidth(countedMinMaxWidth);
return result;
}
public void applyOtf() {
updateFontAndText();
Character.UnicodeScript script = this.getProperty(Property.FONT_SCRIPT);
if (!otfFeaturesApplied && TypographyUtils.isTypographyModuleInitialized() && text.start < text.end) {
if (hasOtfFont()) {
Object typographyConfig = this.