private void InitFontSize() { String mainTag = raf.ReadString(4, PdfEncodings.WINANSI); if (!mainTag.Equals("ttcf")) { throw new iText.IO.IOException(iText.IO.IOException.InvalidTtcFile); } raf.SkipBytes(4); TTCSize = raf.ReadInt(); }
/// <exception cref="System.IO.IOException"/> protected internal virtual void CreateTableDirectory() { tableDirectory = new Dictionary <String, int[]>(); rf.Seek(directoryOffset); int id = rf.ReadInt(); if (id != 0x00010000) { throw new iText.IO.IOException(iText.IO.IOException.NotAtTrueTypeFile).SetMessageParams(fileName); } int num_tables = rf.ReadUnsignedShort(); rf.SkipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = ReadStandardString(4); int[] tableLocation = new int[3]; tableLocation[TABLE_CHECKSUM] = rf.ReadInt(); tableLocation[TABLE_OFFSET] = rf.ReadInt(); tableLocation[TABLE_LENGTH] = rf.ReadInt(); tableDirectory.Put(tag, tableLocation); } }
private void InitializeSfntTables() { tables = new LinkedDictionary <String, int[]>(); if (ttcIndex >= 0) { int dirIdx = ttcIndex; if (dirIdx < 0) { if (fileName != null) { throw new iText.IO.IOException("The font index for {0} must be positive.").SetMessageParams(fileName); } else { throw new iText.IO.IOException("The font index must be positive."); } } String mainTag = ReadStandardString(4); if (!mainTag.Equals("ttcf")) { if (fileName != null) { throw new iText.IO.IOException("{0} is not a valid ttc file.").SetMessageParams(fileName); } else { throw new iText.IO.IOException("Not a valid ttc file."); } } raf.SkipBytes(4); int dirCount = raf.ReadInt(); if (dirIdx >= dirCount) { if (fileName != null) { throw new iText.IO.IOException("The font index for {0} must be between 0 and {1}. It is {2}.").SetMessageParams (fileName, dirCount - 1, dirIdx); } else { throw new iText.IO.IOException("The font index must be between 0 and {0}. It is {1}.").SetMessageParams(dirCount - 1, dirIdx); } } raf.SkipBytes(dirIdx * 4); directoryOffset = raf.ReadInt(); } raf.Seek(directoryOffset); int ttId = raf.ReadInt(); if (ttId != 0x00010000 && ttId != 0x4F54544F) { if (fileName != null) { throw new iText.IO.IOException("{0} is not a valid ttf or otf file.").SetMessageParams(fileName); } else { throw new iText.IO.IOException("Not a valid ttf or otf file."); } } int num_tables = raf.ReadUnsignedShort(); raf.SkipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = ReadStandardString(4); raf.SkipBytes(4); int[] table_location = new int[2]; table_location[0] = raf.ReadInt(); table_location[1] = raf.ReadInt(); tables.Put(tag, table_location); } }
/// <summary>Reads the font data.</summary> /// <exception cref="System.IO.IOException"/> protected internal virtual void Process() { tables = new LinkedDictionary <String, int[]>(); if (ttcIndex >= 0) { int dirIdx = ttcIndex; if (dirIdx < 0) { if (fileName != null) { throw new iText.IO.IOException("the.font.index.for.1.must.be.positive").SetMessageParams(fileName); } else { throw new iText.IO.IOException("the.font.index.must.be.positive"); } } String mainTag = ReadStandardString(4); if (!mainTag.Equals("ttcf")) { if (fileName != null) { throw new iText.IO.IOException("1.is.not.a.valid.ttc.file").SetMessageParams(fileName); } else { throw new iText.IO.IOException("not.a.valid.ttc.file"); } } raf.SkipBytes(4); int dirCount = raf.ReadInt(); if (dirIdx >= dirCount) { if (fileName != null) { throw new iText.IO.IOException("the.font.index.for.1.must.be.between.0.and.2.it.was.3").SetMessageParams(fileName , dirCount - 1, dirIdx); } else { throw new iText.IO.IOException("the.font.index.must.be.between.0.and.1.it.was.2").SetMessageParams(dirCount - 1, dirIdx); } } raf.SkipBytes(dirIdx * 4); directoryOffset = raf.ReadInt(); } raf.Seek(directoryOffset); int ttId = raf.ReadInt(); if (ttId != 0x00010000 && ttId != 0x4F54544F) { if (fileName != null) { throw new iText.IO.IOException("1.is.not.a.valid.ttf.or.otf.file").SetMessageParams(fileName); } else { throw new iText.IO.IOException("not.a.valid.ttf.or.otf.file"); } } int num_tables = raf.ReadUnsignedShort(); raf.SkipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = ReadStandardString(4); raf.SkipBytes(4); int[] table_location = new int[2]; table_location[0] = raf.ReadInt(); table_location[1] = raf.ReadInt(); tables[tag] = table_location; } CheckCff(); ReadHheaTable(); ReadNameTable(); ReadHeadTable(); ReadOs_2Table(); ReadPostTable(); ReadGlyphWidths(); ReadCmapTable(); }