public virtual void ProcessFontSizeInPT() { float expected = 24; // Create a renderer TextSvgBranchRenderer root = new TextSvgBranchRenderer(); root.SetAttribute(SvgConstants.Attributes.FONT_SIZE, "24pt"); //Run float actual = SvgTextUtil.ResolveFontSize(root, 10); NUnit.Framework.Assert.AreEqual(expected, actual, EPS); }
public virtual void ProcessKeywordedFontSize() { float expected = 24; // Create a renderer TextSvgBranchRenderer root = new TextSvgBranchRenderer(); root.SetAttribute(SvgConstants.Attributes.FONT_SIZE, "xx-large"); //Run // Parent's font-size doesn't impact the result in this test float actual = SvgTextUtil.ResolveFontSize(root, 10); NUnit.Framework.Assert.AreEqual(expected, actual, EPS); }
public virtual void ProcessWhiteSpaceAbsPositionChange() { //Create tree TextSvgBranchRenderer root = new TextSvgBranchRenderer(); TextLeafSvgNodeRenderer textBefore = new TextLeafSvgNodeRenderer(); textBefore.SetAttribute(SvgConstants.Attributes.TEXT_CONTENT, "\n" + " text\n" + " " ); root.AddChild(textBefore); TextSvgBranchRenderer span = new TextSvgBranchRenderer(); span.SetAttribute(SvgConstants.Attributes.X, "10"); span.SetAttribute(SvgConstants.Attributes.Y, "20"); TextLeafSvgNodeRenderer textInSpan = new TextLeafSvgNodeRenderer(); textInSpan.SetAttribute(SvgConstants.Attributes.TEXT_CONTENT, "\n" + " tspan text\n" + " " ); span.AddChild(textInSpan); root.AddChild(span); TextLeafSvgNodeRenderer textAfter = new TextLeafSvgNodeRenderer(); textAfter.SetAttribute(SvgConstants.Attributes.TEXT_CONTENT, "\n" + " after text\n" + " " ); root.AddChild(textAfter); //Run SvgTextUtil.ProcessWhiteSpace(root, true); root.GetChildren()[0].GetAttribute(SvgConstants.Attributes.TEXT_CONTENT); //Create result array String[] actual = new String[] { root.GetChildren()[0].GetAttribute(SvgConstants.Attributes.TEXT_CONTENT), ((TextSvgBranchRenderer)root.GetChildren()[1]).GetChildren()[0].GetAttribute(SvgConstants.Attributes.TEXT_CONTENT ), root.GetChildren()[2].GetAttribute(SvgConstants.Attributes.TEXT_CONTENT) }; //Create expected String[] expected = new String[] { "text", "tspan text", " after text" }; //No preceding whitespace on the second element NUnit.Framework.Assert.AreEqual(expected, actual); }