Esempio n. 1
0
        public FontDescriptor Generate(PdfDictionary dictionary, bool isLenientParsing)
        {
            if (dictionary == null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            var name     = GetFontName(dictionary, isLenientParsing);
            var family   = GetFontFamily(dictionary);
            var stretch  = GetFontStretch(dictionary);
            var flags    = GetFlags(dictionary, isLenientParsing);
            var bounding = GetBoundingBox(dictionary);
            var charSet  = GetCharSet(dictionary);
            var fontFile = GetFontFile(dictionary);

            return(new FontDescriptor(name, flags)
            {
                FontFamily = family,
                Stretch = stretch,
                FontWeight = dictionary.GetDecimalOrDefault(CosName.FONT_WEIGHT, 0),
                BoundingBox = bounding,
                ItalicAngle = dictionary.GetDecimalOrDefault(CosName.ITALIC_ANGLE, 0),
                Ascent = dictionary.GetDecimalOrDefault(CosName.ASCENT, 0),
                Descent = dictionary.GetDecimalOrDefault(CosName.DESCENT, 0),
                Leading = dictionary.GetDecimalOrDefault(CosName.LEADING, 0),
                CapHeight = Math.Abs(dictionary.GetDecimalOrDefault(CosName.CAP_HEIGHT, 0)),
                XHeight = Math.Abs(dictionary.GetDecimalOrDefault(CosName.XHEIGHT, 0)),
                StemVertical = dictionary.GetDecimalOrDefault(CosName.STEM_V, 0),
                StemHorizontal = dictionary.GetDecimalOrDefault(CosName.STEM_H, 0),
                AverageWidth = dictionary.GetDecimalOrDefault(CosName.AVG_WIDTH, 0),
                MaxWidth = dictionary.GetDecimalOrDefault(CosName.MAX_WIDTH, 0),
                MissingWidth = dictionary.GetDecimalOrDefault(CosName.MISSING_WIDTH, 0),
                FontFile = fontFile,
                CharSet = charSet
            });
        }