Example #1
0
            // Pulls out a Vertical Matric and updates hhea if necessary
            public bool removeLongHorMetric(ushort nIndex)
            {
                bool bResult = true;

                if (nIndex >= m_nGlyphsInTheFont)
                {
                    bResult = false;
                    throw new ArgumentOutOfRangeException("Tried to remove a Vertical Matric that did not exist.");
                }
                else
                {
                    // if we are removing a vertical matrix that is less the the number of long vertical
                    // metrics we need to adjust for this so we know how to write it later and fix up the hhea_table
                    if (nIndex < m_nNumberOfHMetrics)
                    {
                        m_nNumberOfHMetrics--;
                        Table_hhea.hhea_cache hheaCache = (Table_hhea.hhea_cache)m_hheaTable.GetCache();
                        hheaCache.numberOfHMetrics--;
                    }

                    // NOTE: Table maxp and ltsh numGlyphs isn't being dynamically updated
                    m_nGlyphsInTheFont--;

                    m_longHorMetric.RemoveAt(nIndex);
                    m_bDirty = true;
                }

                return(bResult);
            }
Example #2
0
            // Does the real work of adding
            protected bool addToLongHorMetric(ushort nIndex, ushort nAdvanceWidth, short nLeftSideBearing)
            {
                bool bResult = true;

                // NOTE: This might not be OK we might want to add a glyph that is much greater the the number that is there now
                if (nIndex >= m_nGlyphsInTheFont)
                {
                    bResult = false;
                    throw new ArgumentOutOfRangeException("Tried to add a Vertical Matric to a position greater than the number of Glyphs + 1.");
                }
                else
                {
                    // if we are adding a horiz matrix that is less the the number of NumberOfHMetrics
                    // we need to adjust for this so we know how to write it later and fix up the hhea_table
                    if (nIndex < m_nNumberOfHMetrics || (nIndex == m_nNumberOfHMetrics && nAdvanceWidth != 0))
                    {
                        m_nNumberOfHMetrics++;
                        Table_hhea.hhea_cache hheaCache = (Table_hhea.hhea_cache)m_hheaTable.GetCache();
                        hheaCache.numberOfHMetrics++;
                    }

                    // NOTE: Table maxp and ltsh numGlyphs isn't being dynamically updated
                    m_nGlyphsInTheFont++;

                    longHorMetric lhm = new longHorMetric();
                    lhm.advanceWidth = nAdvanceWidth;
                    lhm.lsb          = nLeftSideBearing;

                    m_longHorMetric.Insert(nIndex, lhm);
                    m_bDirty = true;
                }

                return(bResult);
            }