iTextSharp.text.pdf.CFFFontSubset.AssembleIndex C# (CSharp) Метод

AssembleIndex() защищенный Метод

protected AssembleIndex ( int NewOffsets, byte NewObjects ) : byte[]
NewOffsets int
NewObjects byte
Результат byte[]
        protected byte[] AssembleIndex(int[] NewOffsets,byte[] NewObjects)
        {
            // Calc the index' count field
            char Count = (char)(NewOffsets.Length-1);
            // Calc the size of the object array
            int Size = NewOffsets[NewOffsets.Length-1];
            // Calc the Offsize
            byte Offsize;
            if (Size <= 0xff) Offsize = 1;
            else if (Size <= 0xffff) Offsize = 2;
            else if (Size <= 0xffffff) Offsize = 3;
            else Offsize = 4;
            // The byte array for the new index. The size is calc by
            // Count=2, Offsize=1, OffsetArray = Offsize*(Count+1), The object array
            byte[] NewIndex = new byte[2+1+Offsize*(Count+1)+NewObjects.Length];
            // The counter for writing
            int Place = 0;
            // Write the count field
            NewIndex[Place++] = (byte) ((Count >> 8) & 0xff);
            NewIndex[Place++] = (byte) ((Count >> 0) & 0xff);
            // Write the offsize field
            NewIndex[Place++] = Offsize;
            // Write the offset array according to the offsize
            foreach (int newOffset in NewOffsets)
            {
                // The value to be written
                int Num = newOffset-NewOffsets[0]+1;
                // Write in bytes according to the offsize
                switch (Offsize) {
                    case 4:
                        NewIndex[Place++] = (byte) ((Num >> 24) & 0xff);
                        goto case 3;
                    case 3:
                        NewIndex[Place++] = (byte) ((Num >> 16) & 0xff);
                        goto case 2;
                    case 2:
                        NewIndex[Place++] = (byte) ((Num >>  8) & 0xff);
                        goto case 1;
                    case 1:
                        NewIndex[Place++] = (byte) ((Num >>  0) & 0xff);
                        break;
                }
            }
            // Write the new object array one by one
            foreach (byte newObject in NewObjects)
            {
                NewIndex[Place++] = newObject;
            }
            // Return the new index
            return NewIndex;
        }