/// <summary>
        /// Returns the line spacing, in design units, of the FontFamily object of the specified style.
        /// The line spacing is the vertical distance between the base lines of two consecutive lines of text.
        /// </summary>
        public int GetLineSpacing(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.LineSpacing;

            return(result);
        }
        /// <summary>
        /// Returns the cell descent, in design units, of the XFontFamily object of the specified style.
        /// </summary>
        public int GetCellDescent(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.Descender;

            return(result);
        }
        /// <summary>
        /// Returns the cell descent, in design units, of the XFontFamily object of the specified style.
        /// </summary>
        public int GetCellDescent(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.Descender;

#if DEBUG_ && GDI
            int gdiValue = _gdiFamily.GetCellDescent((FontStyle)style);
            Debug.Assert(gdiValue == result);
#endif
            return(result);
        }
        /// <summary>
        /// Gets the height, in font design units, of the em square for the specified style.
        /// </summary>
        public int GetEmHeight(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.UnitsPerEm;

#if DEBUG_
            int headValue = descriptor.FontFace.head.unitsPerEm;
            Debug.Assert(headValue == result);
#endif
            return(result);
        }
        /// <summary>
        /// Returns the line spacing, in design units, of the FontFamily object of the specified style.
        /// The line spacing is the vertical distance between the base lines of two consecutive lines of text.
        /// </summary>
        public int GetLineSpacing(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.LineSpacing;

#if DEBUG_ && GDI
            int gdiValue = _gdiFamily.GetLineSpacing((FontStyle)style);
            Debug.Assert(gdiValue == result);
#endif
#if DEBUG_ && WPF && !SILVERLIGHT
            int wpfValue = (int)Math.Round(_wpfFamily.LineSpacing * GetEmHeight(style));
            Debug.Assert(wpfValue == result);
#endif
            return(result);
        }
Example #6
0
        /// <summary>
        /// Gets the height, in font design units, of the em square for the specified style.
        /// </summary>
        public int GetEmHeight(XFontStyle style)
        {
            OpenTypeDescriptor descriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(Name, style);
            int result = descriptor.UnitsPerEm;

//#if DEBUG_ && GDI
            //int gdiValue = _gdiFamily.GetEmHeight((FontStyle)style);
            //Debug.Assert(gdiValue == result);
//#endif
//#if DEBUG_
//            int headValue = descriptor.FontFace.head.unitsPerEm;
//            Debug.Assert(headValue == result);
//#endif
            return(result);
        }
Example #7
0
        public PDFType0Font(PDFDocument document, string idName, byte[] fontData, bool vertical)
            : base(document)
        {
            Elements.SetName(Keys.Type, "/Font");
            Elements.SetName(Keys.Subtype, "/Type0");
            Elements.SetName(Keys.Encoding, vertical ? "/Identity-V" : "/Identity-H");

            OpenTypeDescriptor ttDescriptor = (OpenTypeDescriptor)FontDescriptorCache.GetOrCreateDescriptor(idName, fontData);

            FontDescriptor = new PDFFontDescriptor(document, ttDescriptor);
            FontOptions    = new XPDFFontOptions(PDFFontEncoding.Unicode);
            Debug.Assert(FontOptions != null);

            _cmapInfo      = new CMapInfo(ttDescriptor);
            DescendantFont = new PDFCIDFont(document, FontDescriptor, fontData)
            {
                CMapInfo = _cmapInfo
            };

            // Create ToUnicode map
            _toUnicode = new PDFToUnicodeMap(document, _cmapInfo);
            document.Internals.AddObject(_toUnicode);
            Elements.Add(Keys.ToUnicode, _toUnicode);

            //BaseFont = ttDescriptor.FontName.Replace(" ", "");
            BaseFont = ttDescriptor.FontName;

            // CID fonts are always embedded
            if (!BaseFont.Contains("+"))  // HACK in PDFType0Font
            {
                BaseFont = CreateEmbeddedFontSubsetName(BaseFont);
            }

            FontDescriptor.FontName = BaseFont;
            DescendantFont.BaseFont = BaseFont;

            PDFArray descendantFonts = new PDFArray(document);

            Owner.IrefTable.Add(DescendantFont);
            descendantFonts.Elements.Add(DescendantFont.Reference);
            Elements[Keys.DescendantFonts] = descendantFonts;
        }