Esempio n. 1
0
        public override void OnSaveEvent(IndirectObject indirectObject, PDFObjects pdfObjects)
        {
            // a good guide: http://www.4real.gr/technical-documents-ttf-subset.html
            SubsetTTFFont = Subset(TTFFont);

            File.WriteAllBytes("file.ttf", SubsetTTFFont);

            var widths = new List <PdfObject>();

            widths.Add(new IntegerObject(this.Width));
            foreach (int i in hashChar)
            {
                if (!dctCharCodeToGlyphID.ContainsKey(i))
                {
                    widths.Add(new IntegerObject(this.Width));
                }
                else
                {
                    widths.Add(new IntegerObject(Glypth[dctCharCodeToGlyphID[i]].width));
                }
            }

            var descriptor = new DocumentTtfDescriptorFont(this);
            var cmap       = new DocumentCmapFont(this);

            var entries = new Dictionary <string, PdfObject> {
                { "Type", new NameObject("Font") },
                { "Subtype", new NameObject("TrueType") },
                { "BaseFont", new NameObject(Name) },
                { "FirstChar", new IntegerObject(0) },
                { "LastChar", new IntegerObject(hashChar.Count) },
                { "Widths", new ArrayObject(widths) },
                { "FontDescriptor", descriptor.IndirectReferenceObject(pdfObjects) },
                { "ToUnicode", cmap.IndirectReferenceObject(pdfObjects) },
            };

            indirectObject.SetChild(new DictionaryObject(entries));
        }
Esempio n. 2
0
 public DocumentTtfFont()
 {
     descriptor = new DocumentTtfDescriptorFont(this);
 }
Esempio n. 3
0
 public DocumentTtfFont(string FullPath) : base(FullPath)
 {
     descriptor = new DocumentTtfDescriptorFont(this);
 }