Example #1
0
        public Font GetFont(ChainedProperties props)
        {
            String face = props[ElementTags.FACE];

            if (face != null)
            {
                StringTokenizer tok = new StringTokenizer(face, ",");
                while (tok.HasMoreTokens())
                {
                    face = tok.NextToken().Trim();
                    if (face.StartsWith("\""))
                    {
                        face = face.Substring(1);
                    }
                    if (face.EndsWith("\""))
                    {
                        face = face.Substring(0, face.Length - 1);
                    }
                    if (fontImp.IsRegistered(face))
                    {
                        break;
                    }
                }
            }
            int style = 0;

            if (props.HasProperty(HtmlTags.I))
            {
                style |= Font.ITALIC;
            }
            if (props.HasProperty(HtmlTags.B))
            {
                style |= Font.BOLD;
            }
            if (props.HasProperty(HtmlTags.U))
            {
                style |= Font.UNDERLINE;
            }
            if (props.HasProperty(HtmlTags.S))
            {
                style |= Font.STRIKETHRU;
            }

            String value = props[ElementTags.SIZE];
            float  size  = 12;

            if (value != null)
            {
                size = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
            }
            Color  color    = Markup.DecodeColor(props["color"]);
            String encoding = props["encoding"];

            if (encoding == null)
            {
                encoding = BaseFont.WINANSI;
            }
            return(fontImp.GetFont(face, encoding, true, size, style, color));
        }