// This method is for the data cache but should be used later once the // the constructor that sets the number of glyphs is used public vMetric GetVMetric(uint i) { vMetric vm = new vMetric(); if( m_nGlyphsInTheFont == 0 ) { throw new ArgumentException( "Number of Glyphs has not been set." ); } else if ( i >= m_nGlyphsInTheFont ) { throw new ArgumentOutOfRangeException(); } if( i < m_nLongVerMetrics ) { vm.advanceHeight = m_bufTable.GetUshort(i*4); vm.topSideBearing = m_bufTable.GetShort(i*4+2); } else { vm.advanceHeight = m_bufTable.GetUshort(((uint)m_nLongVerMetrics-1)*4); vm.topSideBearing = m_bufTable.GetShort((uint)m_nLongVerMetrics*4 + (i-(uint)m_nLongVerMetrics)*2); } return vm; }
// This method is for the data cache but should be used later once the // the construtor that sets the number of glyphs is used public vMetric GetVMetric(uint i) { vMetric vm = new vMetric(); if (m_nGlyphsInTheFont == 0) { throw new ArgumentException("Number of Glyphs has not been set."); } else if (i >= m_nGlyphsInTheFont) { throw new ArgumentOutOfRangeException(); } if (i < m_nLongVerMetrics) { vm.advanceHeight = m_bufTable.GetUshort(i * 4); vm.topSideBearing = m_bufTable.GetShort(i * 4 + 2); } else { vm.advanceHeight = m_bufTable.GetUshort(((uint)m_nLongVerMetrics - 1) * 4); vm.topSideBearing = m_bufTable.GetShort((uint)m_nLongVerMetrics * 4 + (i - (uint)m_nLongVerMetrics) * 2); } return(vm); }
// Does the real work of adding protected bool addToVerticalMetric(ushort nIndex, ushort nAdvanceHeight, short nTopSideBearing) { 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) { // if we are adding 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 vhea_table if (nIndex < m_nLongVerMetrics || (nIndex == m_nLongVerMetrics && nAdvanceHeight != 0)) { m_nLongVerMetrics++; Table_vhea.vhea_cache vheaCache = (Table_vhea.vhea_cache)m_vheaTable.GetCache(); vheaCache.numOfLongVerMetrics++; } // NOTE: Table maxp and ltsh numGlyphs isn't being dynamically updated m_nGlyphsInTheFont++; vMetric vm = new vMetric(); vm.advanceHeight = nAdvanceHeight; vm.topSideBearing = nTopSideBearing; m_vMetric.Insert(nIndex, vm); m_bDirty = true; } else { bResult = false; throw new ArgumentOutOfRangeException("Tried to add a Vertical Matric to a position greater than the number of Glyphs + 1."); } return(bResult); }
/************************ * accessors */ public vMetric GetVMetric(uint i, OTFont fontOwner) { vMetric vm = new vMetric(); m_nLongVerMetrics = (ushort)GetNumOfLongVerMetrics(fontOwner); m_nGlyphsInTheFont = fontOwner.GetMaxpNumGlyphs(); if( i >= m_nGlyphsInTheFont ) { throw new ArgumentOutOfRangeException(); } vm = GetVMetric( i ); return vm; }
/************************ * accessors */ public vMetric GetVMetric(uint i, OTFont fontOwner) { vMetric vm = new vMetric(); m_nLongVerMetrics = (ushort)GetNumOfLongVerMetrics(fontOwner); m_nGlyphsInTheFont = fontOwner.GetMaxpNumGlyphs(); if (i >= m_nGlyphsInTheFont) { throw new ArgumentOutOfRangeException(); } vm = GetVMetric(i); return(vm); }
// Just as you would expect this returns a requested VMetric public vMetric getVMetric(ushort nIndex) { vMetric vMetricResult = new vMetric(); if (nIndex >= m_nGlyphsInTheFont) { throw new ArgumentOutOfRangeException("Tried to access a Vertical Matric that did not exist."); } else if (nIndex >= m_nLongVerMetrics) { vMetricResult.advanceHeight = ((vMetric)m_vMetric[m_nLongVerMetrics - 1]).advanceHeight; vMetricResult.topSideBearing = ((vMetric)m_vMetric[nIndex]).topSideBearing; } else { vMetricResult.advanceHeight = ((vMetric)m_vMetric[nIndex]).advanceHeight; vMetricResult.topSideBearing = ((vMetric)m_vMetric[nIndex]).topSideBearing; } return(vMetricResult); }
// Does the real work of adding protected bool addToVerticalMetric( ushort nIndex, ushort nAdvanceHeight, short nTopSideBearing ) { 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 ) { // if we are adding 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 vhea_table if( nIndex < m_nLongVerMetrics || (nIndex == m_nLongVerMetrics && nAdvanceHeight != 0)) { m_nLongVerMetrics++; Table_vhea.vhea_cache vheaCache = (Table_vhea.vhea_cache)m_vheaTable.GetCache(); vheaCache.numOfLongVerMetrics++; } // NOTE: Table maxp and ltsh numGlyphs isn't being dynamically updated m_nGlyphsInTheFont++; vMetric vm = new vMetric(); vm.advanceHeight = nAdvanceHeight; vm.topSideBearing = nTopSideBearing; m_vMetric.Insert( nIndex, vm ); m_bDirty = true; } else { bResult = false; throw new ArgumentOutOfRangeException("Tried to add a Vertical Matric to a position greater than the number of Glyphs + 1."); } return bResult; }
// Just as you would expect this returns a requested VMetric public vMetric getVMetric(ushort nIndex) { vMetric vMetricResult = new vMetric(); if( nIndex >= m_nGlyphsInTheFont ) { throw new ArgumentOutOfRangeException("Tried to access a Vertical Matric that did not exist."); } else if( nIndex >= m_nLongVerMetrics ) { vMetricResult.advanceHeight = ((vMetric)m_vMetric[m_nLongVerMetrics - 1]).advanceHeight; vMetricResult.topSideBearing = ((vMetric)m_vMetric[nIndex]).topSideBearing; } else { vMetricResult.advanceHeight = ((vMetric)m_vMetric[nIndex]).advanceHeight; vMetricResult.topSideBearing = ((vMetric)m_vMetric[nIndex]).topSideBearing; } return vMetricResult; }