本文整理汇总了C#中OTFontFileVal.Validator.TestTable方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.TestTable方法的具体用法?C# Validator.TestTable怎么用?C# Validator.TestTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTFontFileVal.Validator
的用法示例。
在下文中一共展示了Validator.TestTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateTable
/*****************
* protected methods
*/
/*****************
* public methods
*/
//meant to avoid code repetition (is called from OTFontVal too)
public bool ValidateTable(OTTable table, Validator v, DirectoryEntry de, OTFontVal fontOwner)
{
String tname = GetTableManager().GetUnaliasedTableName(de.tag);
bool bRet = true;
// verify the checksum value from the directory entry matches the checksum for the table
if (!(tname == "DSIG" && IsCollection()))
{
uint calcChecksum = 0;
if (table != null)
{
calcChecksum = table.CalcChecksum();
}
if (de.checkSum != calcChecksum)
{
string s = "table '" + de.tag + "', calc: 0x" + calcChecksum.ToString("x8") + ", font: 0x" + de.checkSum.ToString("x8");
v.Error(T.T_NULL, E._DE_E_ChecksumError, de.tag, s);
bRet = false;
}
}
// verify that table has pad bytes set to zero
if (table != null)
{
uint nBytes = GetNumPadBytesAfterTable(table);
bool bPadBytesZero = true;
if (nBytes != 0)
{
long PadFilePos = table.GetBuffer().GetFilePos() + table.GetBuffer().GetLength();
byte[] padbuf = ReadBytes(PadFilePos, nBytes);
for (int iByte = 0; iByte < padbuf.Length; iByte++)
{
if (padbuf[iByte] != 0)
{
bPadBytesZero = false;
break;
}
}
}
if (bPadBytesZero == false)
{
v.Warning(T.T_NULL, W._DE_W_PadBytesNotZero, de.tag, "after " + de.tag + " table");
}
}
// ask the table object to validate its data
if (!(tname == "DSIG" && IsCollection())) v.OnTableValidationEvent(de, true);
if (table != null)
{
if (v.TestTable(de.tag)) // don't test deselected tables
{
try
{
ITableValidate valtable = (ITableValidate)table;
bRet &= valtable.Validate(v, fontOwner);
}
catch (InvalidCastException e)
{
v.ApplicationError(T.T_NULL, E._Table_E_Exception, table.m_tag, e.ToString());
bRet = false;
}
}
else
{
v.Info(I._Table_I_NotSelected, de.tag);
}
}
else
{
if (de.length == 0)
{
// check if it's a known OT table type since zero length private tables seem allowable
if (TableManager.IsKnownOTTableType(de.tag))
{
v.Error(T.T_NULL, E._Table_E_Invalid, de.tag, "The directory entry length is zero");
bRet = false;
}
}
else if (de.offset == 0)
{
v.Error(T.T_NULL, E._Table_E_Invalid, de.tag, "The directory entry offset is zero");
bRet = false;
}
else if (de.offset > GetFileLength())
{
v.Error(T.T_NULL, E._Table_E_Invalid, de.tag, "The table offset points past end of file");
//.........这里部分代码省略.........