Exemple #1
0
        /// <summary>
        /// Gets the flag.
        /// </summary>
        /// <returns></returns>
        public override PdfFontDescriptor.Flag GetFlag()
        {
            PdfFontDescriptor.Flag flag = this.IsSymbolic ? PdfFontDescriptor.Flag.Symbolic : PdfFontDescriptor.Flag.Nonsymbolic;
            if (this.tables.ContainsKey("post") && this.GetTable <PostScriptTable>("post").IsFixedPicth)
            {
                flag |= PdfFontDescriptor.Flag.FixedPitch;
            }
            FontHeaderTable table = this.GetTable <FontHeaderTable>("head");

            if ((table.MacStyle & FontHeaderTable.MacStyles.Italic) == FontHeaderTable.MacStyles.Italic)
            {
                flag |= PdfFontDescriptor.Flag.Italic;
            }
            if ((table.MacStyle & FontHeaderTable.MacStyles.Bold) == FontHeaderTable.MacStyles.Bold)
            {
                flag |= PdfFontDescriptor.Flag.ForceBold;
            }
            return(flag);
        }
Exemple #2
0
        /// <summary>
        /// Inits the font tables.
        /// </summary>
        private void InitFontTables()
        {
            switch (this.reader.ReadLONG())
            {
            case 0x10000:
                this.sfntVersion = "1.0";
                break;

            case 0x4f54544f:
                this.sfntVersion = "OTTO";
                break;

            default:
                throw new PdfIncorrectFontData();
            }
            int num2 = this.reader.ReadUSHORT();

            this.reader.Skip(6L);
            for (int i = 0; i < num2; i++)
            {
                string key = this.reader.ReadTagString();
                switch (key)
                {
                case "head":
                    this.tables.Add(key, new FontHeaderTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "hhea":
                    this.tables.Add(key, new HorizontalHeaderTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "name":
                    this.tables.Add(key, new NameTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "cmap":
                    this.tables.Add(key, new CMapTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "hmtx":
                    this.tables.Add(key, new HorizontalMetricsTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "OS/2":
                    this.tables.Add(key, new OS_2Table(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "post":
                    this.tables.Add(key, new PostScriptTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "loca":
                    this.tables.Add(key, new LocationTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                case "glyf":
                    this.tables.Add(key, new GlyphTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;

                default:
                    this.tables.Add(key, new OpenTypeFontTable(key, this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader.ReadULONG(), this.reader));
                    break;
                }
            }
            FontHeaderTable        table  = this.GetTable <FontHeaderTable>("head");
            HorizontalMetricsTable table2 = this.GetTable <HorizontalMetricsTable>("hmtx");

            table2.HHeaderTable = this.GetTable <HorizontalHeaderTable>("hhea");
            table2.HeaderTable  = table;
            this.GetTable <OS_2Table>("OS/2").HeaderTable = table;
            if (this.tables.ContainsKey("loca"))
            {
                this.GetTable <LocationTable>("loca").HeaderTable = table;
            }
            if (this.tables.ContainsKey("glyf"))
            {
                this.GetTable <GlyphTable>("glyf").LocaTable = this.GetTable <LocationTable>("loca");
            }
            if (base.isEmbedded && (this.OS_2Table.FsType == 2))
            {
                throw new PdfReadFontException("Font has 'Restricted License' for embedding.");
            }
        }