/// <summary>Resolve the font size stored inside the passed renderer</summary> /// <param name="renderer">renderer containing the font size declaration</param> /// <param name="parentFontSize">parent font size to fall back on if the renderer does not contain a font size declarations or if the stored declaration is invalid /// </param> /// <returns>float containing the font-size, or the parent font size if the renderer's declaration cannot be resolved /// </returns> public static float ResolveFontSize(ISvgTextNodeRenderer renderer, float parentFontSize) { //Use own font-size declaration if it is present, parent's otherwise float fontSize = float.NaN; String elementFontSize = renderer.GetAttribute(SvgConstants.Attributes.FONT_SIZE); if (null != elementFontSize && !String.IsNullOrEmpty(elementFontSize)) { if (CssUtils.IsRelativeValue(elementFontSize) || CommonCssConstants.LARGER.Equals(elementFontSize) || CommonCssConstants .SMALLER.Equals(elementFontSize)) { // TODO DEVSIX-2866 Support rem value for svgs fontSize = CssUtils.ParseRelativeFontSize(elementFontSize, parentFontSize); } else { fontSize = CssUtils.ParseAbsoluteFontSize(elementFontSize, CommonCssConstants.PX); } } if ((float.IsNaN(fontSize)) || fontSize < 0f) { fontSize = parentFontSize; } return(fontSize); }
public void AddChild(ISvgTextNodeRenderer child) { // final method, in order to disallow adding null if (child != null) { children.Add(child); } }
private void DeepCopyChildren(iText.Svg.Renderers.Impl.TextSvgBranchRenderer deepCopy) { foreach (ISvgTextNodeRenderer child in children) { ISvgTextNodeRenderer newChild = (ISvgTextNodeRenderer)child.CreateDeepCopy(); child.SetParent(deepCopy); deepCopy.AddChild(newChild); } }
/// <summary>Resolve the font size stored inside the passed renderer</summary> /// <param name="renderer">renderer containing the font size declaration</param> /// <param name="parentFontSize">parent font size to fall back on if the renderer does not contain a font size declarations or if the stored declaration is invalid /// </param> /// <returns>float containing the font-size, or the parent font size if the renderer's declaration cannot be resolved /// </returns> public static float ResolveFontSize(ISvgTextNodeRenderer renderer, float parentFontSize) { //Use own font-size declaration if it is present, parent's otherwise float fontSize = iText.Svg.Utils.SvgTextUtil.ExtractFontSize(renderer); if ((float.IsNaN(fontSize)) || fontSize < 0f) { fontSize = parentFontSize; } return(fontSize); }
/// <summary>Extract and parse the font-size declaration stored inside the attributes of the passed renderer</summary> /// <param name="renderer">renderer to extract font-size declaration from</param> /// <returns>a float containing the font-size interpreted as pt, or NaN if the font-size was not specified in the passed renderer /// </returns> private static float ExtractFontSize(ISvgTextNodeRenderer renderer) { float fontSize = float.NaN; if (renderer.GetAttribute(SvgConstants.Attributes.FONT_SIZE) != null) { String fontSizeRawValue = renderer.GetAttribute(SvgConstants.Attributes.FONT_SIZE); if (fontSizeRawValue != null && !String.IsNullOrEmpty(fontSizeRawValue)) { fontSize = CssUtils.ParseAbsoluteLength(fontSizeRawValue, CommonCssConstants.PT); } } return(fontSize); }