本文整理汇总了C#中OTFontFileVal.Validator类的典型用法代码示例。如果您正苦于以下问题:C# Validator类的具体用法?C# Validator怎么用?C# Validator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Validator类属于OTFontFileVal命名空间,在下文中一共展示了Validator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateNumEntries
public bool ValidateNumEntries(Validator validator,
OTFont fontOwner)
{
int numGlyph=this.NumGlyph(fontOwner);
int numEntry=this.NumEntry(fontOwner);
if ((numGlyph==Table_loca.ValueInvalid)||
(numEntry==Table_loca.ValueInvalid)||
(numEntry!=numGlyph+1))
{
if (validator!=null)
{
validator.Error(T.T_NULL,
E.loca_E_NumEntries,
m_tag,
"number of entries="+numEntry+" number of glyphs="+numGlyph);
}
return false;
}
else
{
if (validator!=null)
{
validator.Pass(P.loca_P_NumEntries, m_tag);
}
return true;
}
}
示例2: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
Table_maxp maxpTable = (Table_maxp)fontOwner.GetTable("maxp");
if (maxpTable == null)
{
v.Error(T.T_NULL, E._TEST_E_TableMissing, m_tag, "Unable to test this table, maxp table is invalid or missing");
return false;
}
if (v.PerformTest(T.vmtx_TableLength))
{
uint CalcTableLength = GetNumOfLongVerMetrics(fontOwner)*4
+ (fontOwner.GetMaxpNumGlyphs() - GetNumOfLongVerMetrics(fontOwner))*2;
if (CalcTableLength == GetLength())
{
v.Pass(T.vmtx_TableLength, P.vmtx_P_TableLength, m_tag);
}
else
{
v.Error(T.vmtx_TableLength, E.vmtx_E_TableLength, m_tag);
bRet = false;
}
}
return bRet;
}
示例3: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.VORG_CFF_Font))
{
if (fontOwner.ContainsPostScriptOutlines())
{
v.Pass(T.VORG_CFF_Font, P.VORG_P_CFF_Font, m_tag);
}
else
{
v.Error(T.VORG_CFF_Font, E.VORG_E_CFF_Font, m_tag);
bRet = false;
}
}
if (v.PerformTest(T.VORG_Version))
{
if (majorVersion == 1 && minorVersion == 0)
{
v.Pass(T.VORG_Version, P.VORG_P_Version, m_tag);
}
else
{
v.Error(T.VORG_Version, E.VORG_E_Version, m_tag);
bRet = false;
}
}
return bRet;
}
示例4: DoIt
public int DoIt( )
{
Validator v = new Validator();
m_vp.SetupValidator( v );
OTFontFileVal.Driver driver = new OTFontFileVal.Driver( this );
return driver.RunValidation( v, m_sFiles );
}
示例5: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
v.Info(I.fpgm_I_NotValidated, m_tag);
return bRet;
}
示例6: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
v.Info(T.T_NULL, I.CFF_I_Version, m_tag, major + "." + minor);
v.Info(I.CFF_I_NotValidated, m_tag);
return bRet;
}
示例7: OTFileVal
/***************
* constructors
*/
public OTFileVal(Validator v)
{
if (v == null)
{
throw new ArgumentNullException();
}
m_TableManager = new TableManagerVal(this);
m_Validator = v;
}
示例8: Validate
public bool Validate(Validator v, string sIdentity, OTTable tableOwner)
{
bool bOk = true;
// ???
// ??? are there any values that are invalid ???
// ???
return bOk;
}
示例9: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.vhea_version))
{
if (version.GetUint() == 0x00010000 || version.GetUint() == 0x00011000)
{
v.Pass(T.vhea_version, P.vhea_P_version, m_tag, "0x" + version.GetUint().ToString("x8"));
}
else
{
v.Error(T.vhea_version, E.vhea_E_version, m_tag, "0x" + version.GetUint().ToString("x8"));
bRet = false;
}
}
if (v.PerformTest(T.vhea_ReservedFields))
{
if (reserved1 == 0 && reserved2 == 0 && reserved3 == 0 && reserved4 == 0)
{
v.Pass(T.vhea_ReservedFields, P.vhea_P_ReservedFields, m_tag);
}
else
{
v.Error(T.vhea_ReservedFields, E.vhea_E_ReservedFields, m_tag);
bRet = false;
}
}
if (v.PerformTest(T.vhea_metricDataFormat))
{
if (metricDataFormat == 0)
{
v.Pass(T.vhea_metricDataFormat, P.vhea_P_metricDataFormat, m_tag);
}
else
{
v.Error(T.vhea_metricDataFormat, E.vhea_E_metricDataFormat, m_tag, metricDataFormat.ToString());
bRet = false;
}
}
return bRet;
}
示例10: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.cvt_length))
{
if ((m_bufTable.GetLength() & 1) != 0)
{
v.Error(T.cvt_length, E.cvt_E_length_odd, m_tag);
bRet = false;
}
else
{
v.Pass(T.cvt_length, P.cvt_P_length_even, m_tag);
}
}
return bRet;
}
示例11: ValidateFormat
/*
* VALIDATION FUNCTIONS
*/
public bool ValidateFormat(Validator validator,
OTFont fontOwner)
{
int format=this.Format(fontOwner);
if ((format!=0)&&(format!=1))
{
if (validator!=null)
{
validator.Error(E.loca_E_Format, m_tag);
}
return false;
}
else
{
if (validator!=null)
{
validator.Pass(P.loca_P_Format, m_tag);
}
return true;
}
}
示例12: Progress
public Progress( Form1 formParent,
Validator v,
string [] sFilenames,
ReportFileDestination rfd,
bool bOpenReportFiles,
string sReportFixedDir )
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
m_Validator = v;
m_sFiles = sFilenames;
m_formParent = formParent;
m_bValidationInProgress = false;
m_ReportFileDestination = rfd;
m_bOpenReportFiles = bOpenReportFiles;
m_sReportFixedDir = sReportFixedDir;
}
示例13: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.head_TableLength))
{
if (m_bufTable.GetLength() == 54)
{
v.Pass(T.head_TableLength, P.head_P_TableLength, m_tag);
}
else
{
v.Error(T.head_TableLength, E.head_E_TableLength, m_tag, m_bufTable.GetLength().ToString());
bRet = false;
}
}
if (v.PerformTest(T.head_TableVersion))
{
if (TableVersionNumber.GetUint() == 0x00010000)
{
v.Pass(T.head_TableVersion, P.head_P_TableVersion, m_tag);
}
else
{
v.Error(T.head_TableVersion, E.head_E_TableVersion, m_tag, "0x"+TableVersionNumber.GetUint().ToString("x8"));
bRet = false;
}
}
if (v.PerformTest(T.head_fontRevision))
{
string sVersion = fontOwner.GetFontVersion();
if (sVersion != null)
{
if (sVersion.Length >= 11
&& sVersion.StartsWith("Version ")
&& Char.IsDigit(sVersion, 8))
{
string sVersionNum = sVersion.Substring(8);
bool bFoundDecPt = false;
int nLastDigitPos = 0;
for (int i=0; i<sVersionNum.Length; i++)
{
if (Char.IsDigit(sVersionNum, i))
{
nLastDigitPos = i;
}
else if (sVersionNum[i] == '.')
{
if (!bFoundDecPt)
{
bFoundDecPt = true;
}
else
{
break;
}
}
else
{
break;
}
}
double fVersion = Double.Parse(sVersionNum.Substring(0, nLastDigitPos+1));
double fRevision = fontRevision.GetDouble();
if (Math.Round(fVersion, 3) == Math.Round(fRevision, 3))
{
v.Pass(T.head_fontRevision, P.head_P_fontRevision, m_tag, fRevision.ToString("f3"));
}
else
{
string s = "revision: " + fRevision.ToString("f3") + ", version: " + sVersionNum;
v.Warning(T.head_fontRevision, W.head_W_fontRevision, m_tag, s);
}
}
}
}
if (v.PerformTest(T.head_ChecksumAdjustment))
{
if (checkSumAdjustment == 0xb1b0afba - fontOwner.CalcChecksum())
{
v.Pass(T.head_ChecksumAdjustment, P.head_P_FontChecksum, m_tag, "0x"+checkSumAdjustment.ToString("x8"));
}
else
{
v.Error(T.head_ChecksumAdjustment, E.head_E_FontChecksum, m_tag, "0x"+checkSumAdjustment.ToString("x8"));
bRet = false;
}
}
if (v.PerformTest(T.head_MagicNumber))
//.........这里部分代码省略.........
示例14: Validate
public bool Validate(Validator v, string sIdentity, OTTable table)
{
bool bRet = true;
bool bScriptTableOk = true;
// check the DefaultLangSys offset
if (DefaultLangSysOffset != 0)
{
if (m_offsetScriptTable + DefaultLangSysOffset > m_bufTable.GetLength())
{
v.Error(T.T_NULL, E._OTL_ScriptTable_E_DefaultLangSysOffset, table.m_tag, sIdentity);
bScriptTableOk = false;
bRet = false;
}
else
{
// check the DefaultLangSys table
LangSysTable_val lst = GetDefaultLangSysTable_val();
bRet &= lst.Validate(v, sIdentity + ", DefaultLangSysTable", table);
}
}
// check the LansgSysRecord array length
if (m_offsetScriptTable + (uint)FieldOffsets.LangSysRecord + LangSysCount * 6 > m_bufTable.GetLength())
{
v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecordArray_pastEOT, table.m_tag, sIdentity);
bScriptTableOk = false;
bRet = false;
}
// check that the LangSysRecord array is sorted alphabetically
if (LangSysCount > 1)
{
for (uint i=0; i<LangSysCount-1; i++)
{
LangSysRecord ThisLsr = GetLangSysRecord(i);
LangSysRecord NextLsr = GetLangSysRecord(i+1);
if (ThisLsr.LangSysTag >= NextLsr.LangSysTag)
{
v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecordArray_order, table.m_tag, sIdentity);
bScriptTableOk = false;
bRet = false;
}
}
}
// check each LangSysRecord
for (uint i=0; i<LangSysCount; i++)
{
LangSysRecord lsr = GetLangSysRecord(i);
// check the tag
if (!lsr.LangSysTag.IsValid())
{
v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecord_tag, table.m_tag, sIdentity + ", LangSysRecord[" + i + "]");
bScriptTableOk = false;
bRet = false;
}
// check the offset
if (m_offsetScriptTable + lsr.LangSysOffset > m_bufTable.GetLength())
{
v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecord_offset, table.m_tag, sIdentity + ", LangSysRecord[" + i + "]");
bScriptTableOk = false;
bRet = false;
}
// validate the langsys table
LangSysTable_val lst = GetLangSysTable_val(lsr);
bRet &= lst.Validate(v, sIdentity + ", LangSysRecord[" + i + "], LangSysTable", table);
}
if (bScriptTableOk)
{
v.Pass(T.T_NULL, P._OTL_ScriptTable_P_valid, table.m_tag, sIdentity);
}
return bRet;
}
示例15: Validate
public bool Validate(Validator v, OTTable table, ushort numGlyphs,
String sIdentity)
{
bool bRet = true;
// check that segCountX2 is even
if ((segCountX2 & 1) == 1)
{
v.Error(T.T_NULL, E.cmap_E_f4_segCountX2, table.m_tag,
sIdentity + ", segCountX2 = " + segCountX2);
bRet = false;
}
// check searchRange
ushort segCount = (ushort)(segCountX2 / 2);
ushort CalculatedSearchRange =
(ushort)(2 * util.MaxPower2LE(segCount));
if (searchRange != CalculatedSearchRange)
{
v.Error(T.T_NULL, E.cmap_E_f4_searchRange, table.m_tag,
sIdentity + ", searchRange = " + searchRange +
", calc = " + CalculatedSearchRange);
bRet = false;
}
// check entrySelector
ushort CalculatedEntrySelector =
util.Log2((ushort)(CalculatedSearchRange/2));
if (entrySelector != CalculatedEntrySelector)
{
v.Error(T.T_NULL, E.cmap_E_f4_entrySelector, table.m_tag,
sIdentity + ", entrySelector = " + entrySelector +
", calc = " + CalculatedEntrySelector);
bRet = false;
}
// check rangeShift
ushort CalculatedRangeShift =
(ushort)(2 * segCount - CalculatedSearchRange);
if (rangeShift != CalculatedRangeShift)
{
v.Error(T.T_NULL, E.cmap_E_f4_rangeShift, table.m_tag,
sIdentity + ", rangeShift = " + rangeShift +
", calc = " + CalculatedRangeShift);
bRet = false;
}
// check that final endCode value is 0xffff
if (GetEndCode((uint)segCount-1) != 0xffff)
{
v.Error(T.T_NULL, E.cmap_E_f4_FinalEndCode, table.m_tag,
sIdentity + ", endCode[" + (segCount-1) + "] = " +
GetEndCode((uint)segCount-1));
bRet = false;
}
// check that end character codes are in ascending order
if (segCount > 1)
{
for (uint i=0; i<segCount-1; i++)
{
if (GetEndCode(i) >= GetEndCode(i+1))
{
v.Error(T.T_NULL, E.cmap_E_f4_EndCodeOrder,
table.m_tag, sIdentity);
bRet = false;
break;
}
}
}
// check that the reservedPad is zero
if ( m_ete.offset + (uint)FieldOffsets.endCode + segCountX2
< m_bufTable.GetLength()
&& reservedPad != 0)
{
v.Error(T.T_NULL, E.cmap_E_f4_reservedPad, table.m_tag,
sIdentity);
bRet = false;
}
// check that each start character code is not greater than
// the corresponding end character code
for (uint i=0; i<segCount; i++)
{
if (GetStartCode(i) > GetEndCode(i))
{
String sDetails = ", startCode[" + i + "] = " +
GetStartCode(i) + " , endCode[" + i + "] = " +
GetEndCode(i);
v.Error(T.T_NULL, E.cmap_E_f4_StartCode_GT_EndCode,
table.m_tag, sIdentity + sDetails);
bRet = false;
}
}
// check that each delta value (where idRangeOffset == 0)
// added to the start code is not negative
for (uint i=0; i<segCount; i++)
{
//.........这里部分代码省略.........