/** * Used for creating sub-TextRenderInfos for each individual character * @param parent the parent TextRenderInfo * @param charIndex the index of the character that this TextRenderInfo will represent * @param horizontalOffset the unscaled horizontal offset of the character that this TextRenderInfo represents * @since 5.3.3 */ private TextRenderInfo(TextRenderInfo parent, int charIndex, float horizontalOffset) { this.text = parent.text.Substring(charIndex, 1); this.textToUserSpaceTransformMatrix = new Matrix(horizontalOffset, 0).Multiply(parent.textToUserSpaceTransformMatrix); this.gs = parent.gs; this.markedContentInfos = parent.markedContentInfos; }
/** * Displays text. * @param string the text to display */ private void DisplayPdfString(PdfString str) { String unicode = Decode(str); //if (w.log) w._tr.WriteLine("RenderText : \"{0}\"", unicode); TextRenderInfo renderInfo = new TextRenderInfo(unicode, Gs(), textMatrix, markedContentStack); renderListener.RenderText(renderInfo); textMatrix = new Matrix(renderInfo.GetUnscaledWidth(), 0).Multiply(textMatrix); }
/** * * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo) */ public virtual void RenderText(TextRenderInfo renderInfo) { LineSegment segment = renderInfo.GetBaseline(); if (renderInfo.GetRise() != 0) { // remove the rise from the baseline - we do this because the text from a super/subscript render operations should probably be considered as part of the baseline of the text the super/sub is relative to Matrix riseOffsetTransform = new Matrix(0, -renderInfo.GetRise()); segment = segment.TransformBy(riseOffsetTransform); } TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth()); locationalResult.Add(location); currentTextBlock.text.Add(location); }
/** * Provides detail useful if a listener needs access to the position of each individual glyph in the text render operation * @return A list of {@link TextRenderInfo} objects that represent each glyph used in the draw operation. The next effect is if there was a separate Tj opertion for each character in the rendered string * @since 5.3.3 */ public List <TextRenderInfo> GetCharacterRenderInfos() { List <TextRenderInfo> rslt = new List <TextRenderInfo>(text.Length); DocumentFont font = gs.font; char[] chars = text.ToCharArray(); float totalWidth = 0; for (int i = 0; i < chars.Length; i++) { float w = font.GetWidth(chars[i]) / 1000.0f; float wordSpacing = chars[i] == 32 ? gs.wordSpacing : 0f; TextRenderInfo subInfo = new TextRenderInfo(this, i, totalWidth); rslt.Add(subInfo); totalWidth += (w * gs.fontSize + gs.characterSpacing + wordSpacing) * gs.horizontalScaling; } return(rslt); }