/// <summary> /// Constructs a Font-object. /// </summary> /// <param name="attributes">the attributes of a Font object</param> /// <returns>a Font object</returns> public static Font getFont(Properties attributes) { string fontname = null; string encoding = defaultEncoding; bool embedded = defaultEmbedding; float size = Font.UNDEFINED; int style = Font.NORMAL; Color color = null; string value = attributes.Remove(MarkupTags.STYLE); if (value != null && value.Length > 0) { Properties styleAttributes = MarkupParser.parseAttributes(value); if (styleAttributes.Count == 0) { attributes.Add(MarkupTags.STYLE, value); } else { fontname = (string)styleAttributes.Remove(MarkupTags.CSS_FONTFAMILY); if (fontname != null) { string tmp; while (fontname.IndexOf(",") != -1) { tmp = fontname.Substring(0, fontname.IndexOf(",")); if (isRegistered(tmp)) { fontname = tmp; } else { fontname = fontname.Substring(fontname.IndexOf(",") + 1); } } } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTSIZE)) != null) { size = MarkupParser.parseLength(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTWEIGHT)) != null) { style |= Font.getStyleValue(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTSTYLE)) != null) { style |= Font.getStyleValue(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_COLOR)) != null) { color = MarkupParser.decodeColor(value); } attributes.AddAll(styleAttributes); } } if ((value = attributes.Remove(ElementTags.ENCODING)) != null) { encoding = value; } if ("false".Equals(attributes.Remove(ElementTags.EMBEDDED))) { embedded = false; } if ((value = attributes.Remove(ElementTags.FONT)) != null) { fontname = value; } if ((value = attributes.Remove(ElementTags.SIZE)) != null) { size = float.Parse(value); } if ((value = attributes.Remove(MarkupTags.STYLE)) != null) { style |= Font.getStyleValue(value); } if ((value = attributes.Remove(ElementTags.STYLE)) != null) { style |= Font.getStyleValue(value); } string r = attributes.Remove(ElementTags.RED); string g = attributes.Remove(ElementTags.GREEN); string b = attributes.Remove(ElementTags.BLUE); if (r != null || g != null || b != null) { int red = 0; int green = 0; int blue = 0; if (r != null) { red = int.Parse(r); } if (g != null) { green = int.Parse(g); } if (b != null) { blue = int.Parse(b); } color = new Color(red, green, blue); } else if ((value = attributes.Remove(ElementTags.COLOR)) != null) { color = MarkupParser.decodeColor(value); } if (fontname == null) { return(getFont(null, encoding, embedded, size, style, color)); } return(getFont(fontname, encoding, embedded, size, style, color)); }