Esempio n. 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));
        }
Esempio n. 2
0
        public Chunk CreateChunk(String text, ChainedProperties props)
        {
            Font  font = GetFont(props);
            float size = font.Size;

            size /= 2;
            Chunk ck = new Chunk(text, font);

            if (props.HasProperty("sub"))
            {
                ck.SetTextRise(-size);
            }
            else if (props.HasProperty("sup"))
            {
                ck.SetTextRise(size);
            }
            ck.SetHyphenation(GetHyphenation(props));
            return(ck);
        }