Exemple #1
0
        public PdfType0Font(PdfDocument document, XFont font, 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.GetOrCreateDescriptorFor(font);

            FontDescriptor = new PdfFontDescriptor(document, ttDescriptor);
            _fontOptions   = font.PdfOptions;
            Debug.Assert(_fontOptions != null);

            _cmapInfo                = new CMapInfo(ttDescriptor);
            _descendantFont          = new PdfCIDFont(document, FontDescriptor, font);
            _descendantFont.CMapInfo = _cmapInfo;

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

            BaseFont = font.GlyphTypeface.GetBaseName();
            // CID fonts are always embedded
            BaseFont = PdfFont.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;
        }
Exemple #2
0
        public PdfType0Font(PdfDocument document, XFont font, 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)FontDescriptorStock.Global.CreateDescriptor(font);

            fontDescriptor = new PdfFontDescriptor(document, ttDescriptor);
            fontOptions    = font.PdfOptions;
            Debug.Assert(fontOptions != null);

            cmapInfo                = new CMapInfo(ttDescriptor);
            descendantFont          = new PdfCIDFont(document, fontDescriptor, font);
            descendantFont.CMapInfo = cmapInfo;

            // Create ToUnicode map
            toUnicode = new PdfToUnicodeMap(document, cmapInfo);
            document.Internals.AddObject(toUnicode);
            Elements.Add(Keys.ToUnicode, toUnicode);

            //if (this.fontOptions.BaseFont != "")
            //{
            //  BaseFont = this.fontOptions.BaseFont;
            //}
            //else
            {
                BaseFont = font.Name.Replace(" ", "");
                switch (font.Style & (XFontStyle.Bold | XFontStyle.Italic))
                {
                case XFontStyle.Bold:
                    BaseFont += ",Bold";
                    break;

                case XFontStyle.Italic:
                    BaseFont += ",Italic";
                    break;

                case XFontStyle.Bold | XFontStyle.Italic:
                    BaseFont += ",BoldItalic";
                    break;
                }
            }
            // CID fonts are always embedded
            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;
        }
Exemple #3
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)FontDescriptorStock.Global.CreateDescriptor(idName, fontData);

            fontDescriptor = new PdfFontDescriptor(document, ttDescriptor);
            fontOptions    = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
            Debug.Assert(fontOptions != null);

            cmapInfo                = new CMapInfo(ttDescriptor);
            descendantFont          = new PdfCIDFont(document, fontDescriptor, fontData);
            descendantFont.CMapInfo = cmapInfo;

            // Create ToUnicode map
            toUnicode = new PdfToUnicodeMap(document, cmapInfo);
            document.Internals.AddObject(toUnicode);
            Elements.Add(Keys.ToUnicode, toUnicode);

            BaseFont = ttDescriptor.FontName.Replace(" ", "");
            //switch (font.Style & (XFontStyle.Bold | XFontStyle.Italic))
            //{
            //  case XFontStyle.Bold:
            //    this.BaseFont += ",Bold";
            //    break;

            //  case XFontStyle.Italic:
            //    this.BaseFont += ",Italic";
            //    break;

            //  case XFontStyle.Bold | XFontStyle.Italic:
            //    this.BaseFont += ",BoldItalic";
            //    break;
            //}

            // 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;
        }
Exemple #4
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);
            _descendantFont.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;
        }
Exemple #5
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);
            _descendantFont.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;
        }
Exemple #6
-1
        public PdfType0Font(PdfDocument document, XFont font, 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.GetOrCreateDescriptorFor(font);
            FontDescriptor = new PdfFontDescriptor(document, ttDescriptor);
            _fontOptions = font.PdfOptions;
            Debug.Assert(_fontOptions != null);

            _cmapInfo = new CMapInfo(ttDescriptor);
            _descendantFont = new PdfCIDFont(document, FontDescriptor, font);
            _descendantFont.CMapInfo = _cmapInfo;

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

            BaseFont = font.GlyphTypeface.GetBaseName();
            // CID fonts are always embedded
            BaseFont = PdfFont.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;
        }