Exemplo n.º 1
0
        /// <summary>Rmove a table to an non-file based table. Throws
        /// exception if table is not in font.
        /// </summary>
        public void RemoveTable(OTTag tag)
        {
            if (m_File != null)
            {
                throw new ApplicationException("attempted to remove a table from a file-based OTFont object");
            }

            if (GetDirectoryEntry(tag) == null)
            {
                throw new ArgumentException("the specified table doesn't doesn't exist in the font");
            }


            // remove the directory entry

            for (int i = 0; i < m_OffsetTable.DirectoryEntries.Count; i++)
            {
                DirectoryEntry de = (DirectoryEntry)m_OffsetTable.DirectoryEntries[i];
                if (tag == de.tag)
                {
                    m_OffsetTable.DirectoryEntries.RemoveAt(i);
                    m_OffsetTable.numTables--;
                    break;
                }
            }


            // remove the table from the list of tables in memory

            for (int i = 0; i < MemBasedTables.Count; i++)
            {
                OTTable t = (OTTable)MemBasedTables[i];
                if (tag == t.m_tag)
                {
                    MemBasedTables.RemoveAt(i);
                    break;
                }
            }

            string sTable = (string)tag;

            if (sTable == "CFF ")
            {
                m_OutlineType = OutlineType.OUTLINE_INVALID;
            }
            else if (sTable == "glyf")
            {
                m_OutlineType = OutlineType.OUTLINE_INVALID;
            }
        }
Exemplo n.º 2
0
        /// <summary>Add a new table to an non-file based table. Table cannot
        /// already exist in the font.
        /// </summary>
        public void AddTable(OTTable t)
        {
            if (m_File != null)
            {
                throw new ApplicationException("attempted to add a table to a file-based OTFont object");
            }

            if (GetDirectoryEntry(t.m_tag) != null)
            {
                throw new ArgumentException("the specified table already exists in the font");
            }

            // build a new directory entry
            DirectoryEntry de = new DirectoryEntry();

            de.tag      = new OTTag(t.m_tag.GetBytes());
            de.checkSum = t.CalcChecksum();
            de.offset   = 0; // this value won't get fixed up until the font is written
            de.length   = t.GetLength();

            // add the directory entry

            m_OffsetTable.DirectoryEntries.Add(de);
            m_OffsetTable.numTables++;


            // add the table to the list of tables in memory

            MemBasedTables.Add(t);


            // special handling for certain tables

            string sTable = (string)t.m_tag;

            if (sTable == "CFF ")
            {
                m_OutlineType = OutlineType.OUTLINE_POSTSCRIPT;
            }
            else if (sTable == "glyf")
            {
                m_OutlineType = OutlineType.OUTLINE_TRUETYPE;
            }
        }