public virtual void SplitAndOverflowInheritSpecialScriptsWordBreakPoints()
        {
            String       nonSpecialScriptText = "Some non-special script";
            TextRenderer textRenderer         = new TextRenderer(new Text(nonSpecialScriptText));

            textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(REGULAR_FONT, PdfEncodings.IDENTITY_H));
            textRenderer.SetText(nonSpecialScriptText);
            NUnit.Framework.Assert.IsNull(textRenderer.GetSpecialScriptsWordBreakPoints());
            LineRenderer.IsTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer);
            NUnit.Framework.Assert.IsNotNull(textRenderer.GetSpecialScriptsWordBreakPoints());
            NUnit.Framework.Assert.IsTrue(textRenderer.GetSpecialScriptsWordBreakPoints().IsEmpty());
            // layout is needed prior to calling #split() in order to fill TextRenderer fields required to be non-null
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
            Document    document    = new Document(pdfDocument);

            textRenderer.SetParent(document.GetRenderer());
            LayoutArea layoutArea = new LayoutArea(1, new Rectangle(MinMaxWidthUtils.GetInfWidth(), AbstractRenderer.INF
                                                                    ));

            textRenderer.Layout(new LayoutContext(layoutArea));
            TextRenderer[] splitRenderers = textRenderer.Split(nonSpecialScriptText.Length / 2);
            foreach (TextRenderer split in splitRenderers)
            {
                NUnit.Framework.Assert.IsNotNull(split.GetSpecialScriptsWordBreakPoints());
                NUnit.Framework.Assert.IsTrue(split.GetSpecialScriptsWordBreakPoints().IsEmpty());
            }
        }
        public virtual void NothingLayoutResult()
        {
            PdfDocument  pdfDocument  = new PdfDocument(new PdfWriter(new MemoryStream()));
            Document     document     = new Document(pdfDocument);
            TextRenderer textRenderer = new TextRenderer(new iText.Layout.Element.Text(THAI_TEXT));

            textRenderer.SetSpecialScriptsWordBreakPoints(new List <int>(JavaUtil.ArraysAsList(3, 8, 10, 12, 15, 20, 23
                                                                                               , 26, 28, 30, 36)));
            textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(THAI_FONT, PdfEncodings.IDENTITY_H));
            LineRenderer lineRenderer = new LineRenderer();

            lineRenderer.SetParent(document.GetRenderer());
            lineRenderer.AddChild(textRenderer);
            LayoutArea layoutArea   = new LayoutArea(1, new Rectangle(MinMaxWidthUtils.GetInfWidth(), 10000));
            Rectangle  occupiedArea = lineRenderer.Layout(new LayoutContext(layoutArea)).GetOccupiedArea().GetBBox();
            LayoutArea decreasedHeightLayoutArea = new LayoutArea(1, new Rectangle(occupiedArea.GetWidth(), occupiedArea
                                                                                   .GetHeight() - 1));
            LayoutResult nothingExpected = lineRenderer.Layout(new LayoutContext(decreasedHeightLayoutArea));

            NUnit.Framework.Assert.AreEqual(LayoutResult.NOTHING, nothingExpected.GetStatus());
        }
Beispiel #3
0
        public override MinMaxWidth GetMinMaxWidth()
        {
            LayoutResult errorResult = InitializeListSymbols(new LayoutContext(new LayoutArea(1, new Rectangle(MinMaxWidthUtils
                                                                                                               .GetInfWidth(), AbstractRenderer.INF))));

            if (errorResult != null)
            {
                return(MinMaxWidthUtils.CountDefaultMinMaxWidth(this));
            }
            return(base.GetMinMaxWidth());
        }
 public override MinMaxWidth GetMinMaxWidth()
 {
     return(((MinMaxWidthLayoutResult)Layout(new LayoutContext(new LayoutArea(1, new Rectangle(MinMaxWidthUtils
                                                                                               .GetInfWidth(), AbstractRenderer.INF))))).GetMinMaxWidth());
 }
        public override MinMaxWidth GetMinMaxWidth()
        {
            MinMaxWidth minMaxWidth = new MinMaxWidth();
            float?      rotation    = this.GetPropertyAsFloat(Property.ROTATION_ANGLE);

            if (!SetMinMaxWidthBasedOnFixedWidth(minMaxWidth))
            {
                float?minWidth = HasAbsoluteUnitValue(Property.MIN_WIDTH) ? RetrieveMinWidth(0) : null;
                float?maxWidth = HasAbsoluteUnitValue(Property.MAX_WIDTH) ? RetrieveMaxWidth(0) : null;
                if (minWidth == null || maxWidth == null)
                {
                    bool restoreRotation = HasOwnProperty(Property.ROTATION_ANGLE);
                    SetProperty(Property.ROTATION_ANGLE, null);
                    MinMaxWidthLayoutResult result = (MinMaxWidthLayoutResult)Layout(new LayoutContext(new LayoutArea(1, new Rectangle
                                                                                                                          (MinMaxWidthUtils.GetInfWidth(), AbstractRenderer.INF))));
                    if (restoreRotation)
                    {
                        SetProperty(Property.ROTATION_ANGLE, rotation);
                    }
                    else
                    {
                        DeleteOwnProperty(Property.ROTATION_ANGLE);
                    }
                    minMaxWidth = result.GetMinMaxWidth();
                }
                if (minWidth != null)
                {
                    minMaxWidth.SetChildrenMinWidth((float)minWidth);
                }
                if (maxWidth != null)
                {
                    minMaxWidth.SetChildrenMaxWidth((float)maxWidth);
                }
                if (minMaxWidth.GetChildrenMinWidth() > minMaxWidth.GetChildrenMaxWidth())
                {
                    minMaxWidth.SetChildrenMaxWidth(minMaxWidth.GetChildrenMaxWidth());
                }
            }
            else
            {
                minMaxWidth.SetAdditionalWidth(CalculateAdditionalWidth(this));
            }
            return(rotation != null?RotationUtils.CountRotationMinMaxWidth(minMaxWidth, this) : minMaxWidth);
        }