本文整理汇总了C#中OTFontFile.MBOBuffer.GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# MBOBuffer.GetBuffer方法的具体用法?C# MBOBuffer.GetBuffer怎么用?C# MBOBuffer.GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTFontFile.MBOBuffer
的用法示例。
在下文中一共展示了MBOBuffer.GetBuffer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFormat4Subtable
//.........这里部分代码省略.........
break;
}
}
// add a final segment if needed
bool bNeedFinal = true;
if (arrSegments.Count != 0)
{
segment4 lastseg = (segment4)
arrSegments[arrSegments.Count-1];
if (lastseg.endCode == 0xffff)
{
bNeedFinal = false;
}
}
if (bNeedFinal)
{
segment4 segFinal = new segment4();
segFinal.startCode = 0xffff;
segFinal.endCode = 0xffff;
segFinal.idDelta = 1;
arrSegments.Add(segFinal);
}
// allocate a buffer for the subtable
ushort nSize = (ushort)(16 + 8 * arrSegments.Count);
for (int i=0; i<arrSegments.Count; i++)
{
segment4 s = (segment4)arrSegments[(int)i];
if (s.glyphIdArray != null)
{
nSize += (ushort)(s.glyphIdArray.Length*2);
}
}
MBOBuffer buf = new MBOBuffer(nSize);
// set the data
ushort segCountX2 = (ushort)(arrSegments.Count*2);
ushort searchRange = (ushort)
(2 * util.MaxPower2LE((ushort)(arrSegments.Count)));
ushort entrySelector = util.Log2((ushort)(searchRange/2));
ushort rangeShift = (ushort)(segCountX2 - searchRange);
buf.SetUshort(4,
(uint)Format4.FieldOffsets.format);
buf.SetUshort(nSize,
(uint)Format4.FieldOffsets.length);
buf.SetUshort(0,
(uint)Format4.FieldOffsets.language);
buf.SetUshort(segCountX2,
(uint)Format4.FieldOffsets.segCountX2);
buf.SetUshort(searchRange,
(uint)Format4.FieldOffsets.searchRange);
buf.SetUshort(entrySelector,
(uint)Format4.FieldOffsets.entrySelector);
buf.SetUshort(rangeShift,
(uint)Format4.FieldOffsets.rangeShift);
uint endOffset = (uint)Format4.FieldOffsets.endCode;
uint startOffset = (uint)Format4.FieldOffsets.endCode +
2*(uint)arrSegments.Count + 2;
uint idDeltaOffset = startOffset + 2*(uint)arrSegments.Count;
uint idRangeOffset = idDeltaOffset + 2*(uint)arrSegments.Count;
int nGlyphIdCount = 0;
for (uint i=0; i<arrSegments.Count; i++)
{
segment4 s = (segment4)arrSegments[(int)i];
if (s.glyphIdArray != null)
{
s.idRangeOffset = (ushort)
((arrSegments.Count - i + nGlyphIdCount)*2);
nGlyphIdCount += s.glyphIdArray.Length;
}
buf.SetUshort(s.endCode, endOffset + i*2);
buf.SetUshort(s.startCode, startOffset + i*2);
buf.SetShort(s.idDelta, idDeltaOffset + i*2);
buf.SetUshort(s.idRangeOffset, idRangeOffset + i*2);
}
uint glyphIdPos = idRangeOffset + 2*(uint)arrSegments.Count;
for (uint i=0; i<arrSegments.Count; i++)
{
segment4 s = (segment4)arrSegments[(int)i];
if (s.glyphIdArray != null)
{
for (uint j=0; j<s.glyphIdArray.Length; j++)
{
buf.SetUshort(s.glyphIdArray[j], glyphIdPos);
glyphIdPos += 2;
}
}
}
return buf.GetBuffer();
}
示例2: GenerateFormat12Subtable
protected byte[] GenerateFormat12Subtable(uint [] map)
{
bool bFound = false;
uint CurChar = 0;
ArrayList arrSegments = new ArrayList();
segment12 seg = new segment12();
while (CurChar < map.Length)
{
// find the startCode char in this segment
bFound = false;
for (uint i=CurChar; i<map.Length; i++)
{
if (map[i] != 0)
{
seg.startCharCode = i;
bFound = true;
break;
}
}
if (bFound)
{
// find the endCode character in this segment
CurChar = seg.startCharCode;
if (CurChar < map.Length-2)
{
while (CurChar < map.Length - 1)
{
if (map[CurChar]+1 == map[CurChar+1] &&
CurChar != map.Length-2)
{
CurChar++;
}
else
{
seg.endCharCode = CurChar;
break;
}
}
}
else if (CurChar == map.Length - 1)
{
seg.endCharCode = CurChar;
}
else
{
Debug.Assert(false);
}
Debug.Assert(seg.startCharCode <= seg.endCharCode);
// store the start glyph ID for this segment
seg.startGlyphID = map[seg.startCharCode];
// add the segment to the array
arrSegments.Add(seg);
Debug.Assert(arrSegments.Count < map.Length,
"more segments than characters");
CurChar = (uint)(seg.endCharCode + 1);
seg = new segment12();
}
else
{
break;
}
}
// allocate a buffer for the subtable
uint nSize = (uint)(16 + 12 * arrSegments.Count);
MBOBuffer buf = new MBOBuffer(nSize);
// set the data
buf.SetUshort(12, (uint)Format12.FieldOffsets.format);
buf.SetUshort(0, (uint)Format12.FieldOffsets.reserved);
buf.SetUint(nSize, (uint)Format12.FieldOffsets.length);
buf.SetUint(0, (uint)Format12.FieldOffsets.language);
buf.SetUint((uint)arrSegments.Count,
(uint)Format12.FieldOffsets.nGroups);
for (int i=0; i<arrSegments.Count; i++)
{
seg = (segment12)arrSegments[i];
buf.SetUint(seg.startCharCode, (uint)
(Format12.FieldOffsets.firstGroup + i*12));
buf.SetUint(seg.endCharCode, (uint)
(Format12.FieldOffsets.firstGroup + i*12 + 4));
buf.SetUint(seg.startGlyphID, (uint)
(Format12.FieldOffsets.firstGroup + i*12 + 8));
}
return buf.GetBuffer();
}
示例3: GenerateFormat0Subtable
protected byte[] GenerateFormat0Subtable( uint [] map,
ushort language )
{
// allocate the buffer
MBOBuffer buf = new MBOBuffer(262);
// set the data
buf.SetUshort(0, (uint)Format0.FieldOffsets.format);
buf.SetUshort(262, (uint)Format0.FieldOffsets.length);
buf.SetUshort(language, (uint)Format0.FieldOffsets.language);
for (int i=0; i<256; i++)
{
buf.SetByte((byte)map[i],
(uint)Format0.FieldOffsets.glyphIDArray +
(uint)i);
}
// return the buffer
return buf.GetBuffer();
}
示例4: GenerateTable
// generate a new table from the cached data
public override OTTable GenerateTable()
{
// generate the subtables
ArrayList arrSubtableBuffers = new ArrayList();
for (int i=0; i<m_arrSubtables.Count; i++)
{
byte [] buf = null;
CachedSubtable st = (CachedSubtable)m_arrSubtables[i];
if (st.m_platID == 3 && st.m_encID == 10)
{
buf = GenerateFormat12Subtable(st.m_CharToGlyphMap);
}
else if (st.m_platID == 1 && st.m_encID == 0)
{
buf = GenerateFormat0Subtable(st.m_CharToGlyphMap, 0);
}
else
{
buf = GenerateFormat4Subtable(st.m_CharToGlyphMap);
}
arrSubtableBuffers.Add(buf);
}
// calculate the number of bytes required for the cmap table
uint nBytes = 4; // version and number of subtables
// encoding table entries
nBytes += 8 * (uint)m_arrSubtables.Count;
for (int i=0; i<m_arrSubtables.Count; i++)
{
byte[] buf = (byte[])arrSubtableBuffers[i];
nBytes += (uint)buf.Length;
}
// create a buffer for the new cmap table
MBOBuffer newbuf = new MBOBuffer(nBytes);
// populate the buffer
// version and number of encoding tables
newbuf.SetUshort(0, (uint)
Table_cmap.FieldOffsets.TableVersionNumber);
newbuf.SetUshort((ushort)m_arrSubtables.Count, (uint)
Table_cmap.FieldOffsets.NumberOfEncodingTables
);
// encoding table entries
uint SubtableOffset = (uint)(4 + 8*m_arrSubtables.Count);
for (int i=0; i < m_arrSubtables.Count; i++)
{
CachedSubtable st = (CachedSubtable)m_arrSubtables[i];
uint eteOffset =
(uint)Table_cmap.FieldOffsets.EncodingTableEntries +
(uint)i*8;
newbuf.SetUshort(st.m_platID, eteOffset);
newbuf.SetUshort(st.m_encID, eteOffset+2);
newbuf.SetUint(SubtableOffset, eteOffset+4);
byte[] buf = (byte[])arrSubtableBuffers[i];
SubtableOffset += (uint)buf.Length;
}
// subtables
byte[] TableBuf = newbuf.GetBuffer();
SubtableOffset = (uint)(4 + 8*m_arrSubtables.Count);
for (int i=0; i<m_arrSubtables.Count; i++)
{
byte[] SubtableBuf = (byte[])arrSubtableBuffers[i];
System.Buffer.BlockCopy(SubtableBuf, 0, TableBuf,
(int)SubtableOffset,
SubtableBuf.Length);
SubtableOffset += (uint)SubtableBuf.Length;
}
// put the buffer into a Table_cmap object and return it
Table_cmap cmapTable = new Table_cmap("cmap", newbuf);
return cmapTable;
}
示例5: writeEBDTBuffer
private void writeEBDTBuffer( MBOBuffer bufEBDT, uint imageDataOffset, imageCache ic, ushort imageFormat )
{
switch( imageFormat )
{
case 1:
{
imageCache1 ic1 = (imageCache1)ic;
bufEBDT.SetByte( ic1.smallMetrics.height, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic1.smallMetrics.width, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic1.smallMetrics.BearingX, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
bufEBDT.SetSbyte( ic1.smallMetrics.BearingY, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
bufEBDT.SetByte( ic1.smallMetrics.Advance, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );
System.Buffer.BlockCopy( ic1.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.smallGlyphMetrics.bufSize), ic1.imageData.Length );
break;
}
case 2:
{
imageCache2 ic2 = (imageCache2)ic;
bufEBDT.SetByte( ic2.smallMetrics.height, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic2.smallMetrics.width, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic2.smallMetrics.BearingX, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
bufEBDT.SetSbyte( ic2.smallMetrics.BearingY, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
bufEBDT.SetByte( ic2.smallMetrics.Advance, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );
System.Buffer.BlockCopy( ic2.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.smallGlyphMetrics.bufSize), ic2.imageData.Length );
break;
}
case 5:
{
imageCache5 ic5 = (imageCache5)ic;
System.Buffer.BlockCopy( ic5.imageData, 0, bufEBDT.GetBuffer(), (int)imageDataOffset, ic5.imageData.Length );
break;
}
case 6:
{
imageCache6 ic6 = (imageCache6)ic;
bufEBDT.SetByte( ic6.bigMetrics.height, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic6.bigMetrics.width, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic6.bigMetrics.horiBearingX, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
bufEBDT.SetSbyte( ic6.bigMetrics.horiBearingY, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
bufEBDT.SetByte( ic6.bigMetrics.horiAdvance, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
bufEBDT.SetSbyte( ic6.bigMetrics.vertBearingX, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
bufEBDT.SetSbyte( ic6.bigMetrics.vertBearingY, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
bufEBDT.SetByte( ic6.bigMetrics.vertAdvance, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );
System.Buffer.BlockCopy( ic6.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.bigGlyphMetrics.bufSize), ic6.imageData.Length );
break;
}
case 7:
{
imageCache7 ic7 = (imageCache7)ic;
bufEBDT.SetByte( ic7.bigMetrics.height, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic7.bigMetrics.width, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic7.bigMetrics.horiBearingX, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
bufEBDT.SetSbyte( ic7.bigMetrics.horiBearingY, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
bufEBDT.SetByte( ic7.bigMetrics.horiAdvance, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
bufEBDT.SetSbyte( ic7.bigMetrics.vertBearingX, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
bufEBDT.SetSbyte( ic7.bigMetrics.vertBearingY, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
bufEBDT.SetByte( ic7.bigMetrics.vertAdvance, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );
System.Buffer.BlockCopy( ic7.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.bigGlyphMetrics.bufSize), ic7.imageData.Length );
break;
}
case 8:
{
imageCache8 ic8 = (imageCache8)ic;
bufEBDT.SetByte( ic8.smallMetrics.height, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic8.smallMetrics.width, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic8.smallMetrics.BearingX, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
bufEBDT.SetSbyte( ic8.smallMetrics.BearingY, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
bufEBDT.SetByte( ic8.smallMetrics.Advance, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );
//pad
bufEBDT.SetByte( 0, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize );
bufEBDT.SetUshort( ic8.numComponents, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 1 );
for( ushort i = 0; i < ic8.numComponents; i++ )
{
Table_EBDT.ebdtComponent ec = ic8.getComponent( i );
bufEBDT.SetUshort( ec.glyphCode, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ));
bufEBDT.SetSbyte( ec.xOffset, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 2 );
bufEBDT.SetSbyte( ec.yOffset, imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 3 );
}
break;
}
case 9:
{
imageCache9 ic9 = (imageCache9)ic;
bufEBDT.SetByte( ic9.bigMetrics.height, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
bufEBDT.SetByte( ic9.bigMetrics.width, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
bufEBDT.SetSbyte( ic9.bigMetrics.horiBearingX, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
bufEBDT.SetSbyte( ic9.bigMetrics.horiBearingY, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
bufEBDT.SetByte( ic9.bigMetrics.horiAdvance, imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
//.........这里部分代码省略.........
示例6: ReadPaddedBuffer
public new MBOBuffer ReadPaddedBuffer(uint filepos, uint length)
{
// allocate a buffer to hold the table
MBOBuffer buf = new MBOBuffer(filepos, length);
// read the table
m_fs.Seek(filepos, SeekOrigin.Begin);
int nBytes = m_fs.Read(buf.GetBuffer(), 0, (int)length);
if (nBytes != length)
{
// check for premature EOF
if (m_fs.Position == m_fs.Length)
{
m_Validator.Error(E._GEN_E_EOFError, null);
}
else
{
m_Validator.Error(E._GEN_E_ReadError, null);
}
buf = null;
}
return buf;
}
示例7: BinaryEqual
public static bool BinaryEqual(MBOBuffer buf1, MBOBuffer buf2)
{
bool bEqual = true;
if (buf1.GetLength() != buf2.GetLength())
{
bEqual = false;
}
else
{
byte [] b1 = buf1.GetBuffer();
byte [] b2 = buf2.GetBuffer();
for (int i=0; i<b1.Length; i++)
{
if (b1[i] != b2[i])
{
bEqual = false;
break;
}
}
}
return bEqual;
}