本文整理汇总了C#中OTFontFileVal.Validator.Warning方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.Warning方法的具体用法?C# Validator.Warning怎么用?C# Validator.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTFontFileVal.Validator
的用法示例。
在下文中一共展示了Validator.Warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateGlyfEntryEmpty
private bool ValidateGlyfEntryEmpty(Validator validator,
OTFont fontOwner)
{
int cntInfo=0;
int numEntry=this.NumEntry(fontOwner);
if (numEntry==Table_loca.ValueInvalid)
{
if (validator!=null)
{
validator.Warning(T.T_NULL, W._TEST_W_OtherErrorsInTable,
m_tag,
"Unable to determine the number of entries in the 'loca' table");
}
return false;
}
int offsGlyfCur, offsGlyfNext;
for (int iEntry=0; iEntry<numEntry-1; iEntry++)
{
if ((!this.GetGlyfOffset(iEntry, out offsGlyfCur, validator, fontOwner))||
(!this.GetGlyfOffset(iEntry+1, out offsGlyfNext, validator, fontOwner)))
{
cntInfo++;
continue;
}
if (offsGlyfNext==offsGlyfCur)
{
cntInfo++;
}
}
if (validator!=null)
{
if (cntInfo==0)
{
validator.Pass(P.loca_P_GlyfEntryEmpty, m_tag);
}
else
{
validator.Info(T.T_NULL, I.loca_I_GlyfEntryEmpty,
m_tag,
"Number of glyphs that are empty = "+cntInfo);
}
}
return (cntInfo==0);
}
示例2: Validate
public bool Validate(Validator v, OTTable table, ushort numGlyphs,
String sIdentity)
{
bool bRet = true;
// warn if not encoding id 10
if (m_ete.encodingID != 10)
{
v.Warning(T.T_NULL, W.cmap_W_f12_EncID, table.m_tag,
sIdentity);
}
// check that groups are sorted by ascending startCharCodes
if (nGroups > 1)
{
for (uint i=0; i<nGroups-1; i++)
{
Group gCurr = GetGroup(i);
Group gNext = GetGroup(i+1);
if (gCurr.startCharCode >= gNext.startCharCode)
{
v.Error(T.T_NULL, E.cmap_E_f12_SortOrder,
table.m_tag, sIdentity);
bRet = false;
break;
}
}
}
// check each start code is less than or equal to the end code
for (uint i=0; i<nGroups; i++)
{
Group g = GetGroup(i);
if (g.startCharCode > g.endCharCode)
{
String sDetails = ", group[" + i +
"], startCharCode = 0x" +
g.startCharCode.ToString("X8") +
", endCharCode = 0x" + g.endCharCode.ToString("X8");
v.Error(T.T_NULL, E.cmap_E_f12_StartCode_GT_EndCode,
table.m_tag, sIdentity + sDetails);
bRet = false;
}
}
// check the mapping
for (uint i=0; i<nGroups; i++)
{
Group g = GetGroup(i);
uint c = g.endCharCode;
uint nGlyphID = g.startGlyphID + (c - g.startCharCode);
if (nGlyphID >= numGlyphs)
{
v.Error(T.T_NULL, E.cmap_E_Mapping, table.m_tag,
sIdentity + ", char = 0x" +
((uint)c).ToString("X4") + ", glyphID = " +
nGlyphID);
bRet = false;
}
}
// if encoding id 10, then check that the greatest character
// is not greater than 0x10ffff
if (m_ete.encodingID == 10)
{
if (nGroups > 0)
{
Group lastgroup = GetGroup(nGroups-1);
if (lastgroup.endCharCode > 0x10ffff)
{
v.Error(T.T_NULL, E.cmap_E_f12_EndCode_GT_10FFFF,
table.m_tag, sIdentity +
", last endCharCode = 0x" +
lastgroup.endCharCode.ToString("X8"));
bRet = false;
}
}
}
return bRet;
}
示例3: Validate
public bool Validate(Validator v, string sIdentity, OTTable table)
{
bool bRet = true;
// check the LookupType
if (((string)table.m_tag == "GPOS") && LookupType > 9
|| ((string)table.m_tag == "GSUB" && LookupType > 8))
{
v.Error(T.T_NULL, E._OTL_LookupTable_E_LookupType, table.m_tag, sIdentity + ", LookupType = " + LookupType);
bRet = false;
}
// check LookupFlag reserved bits are clear
if ((LookupFlag & 0x00f0) != 0)
{
v.Error(T.T_NULL, E._OTL_LookupTable_E_LookupFlag_reserved, table.m_tag, sIdentity);
bRet = false;
}
// check Subtable offset array doesn't extend past end of table
if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + SubTableCount*2 > m_bufTable.GetLength())
{
v.Error(T.T_NULL, E._OTL_LookupTable_E_SubtableArray_pastEOT, table.m_tag, sIdentity);
bRet = false;
}
// check Subtable offsets don't point past end of table
for (uint i=0; i<SubTableCount; i++)
{
// verify that the subtable offset is accessible, if not error was already reported
if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + i*2 + 2 <= m_bufTable.GetLength())
{
if (m_offsetLookupTable + GetSubTableOffset(i) > m_bufTable.GetLength())
{
v.Error(T.T_NULL, E._OTL_LookupTable_E_SubtableArray_offset, table.m_tag, sIdentity + ", SubTable[" + i + "]");
bRet = false;
}
}
}
// way too many lookup tables to justify this pass message
//if (bRet)
//{
// v.Pass("_OTL_LookupTable_P_valid", table.m_tag, sIdentity);
//}
// validate each subtable
for (uint i=0; i<SubTableCount; i++)
{
// verify that the subtable offset is accessible, if not error was already reported
if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + i*2 + 2 <= m_bufTable.GetLength())
{
// verify subtable offset is valid
if (m_offsetLookupTable + GetSubTableOffset(i) <= m_bufTable.GetLength())
{
SubTable st = GetSubTable(i);
if (st != null)
{
I_OTLValidate iv = (I_OTLValidate)st;
bRet &= iv.Validate(v, sIdentity + ", SubTable[" + i + "]", table);
}
else
{
v.Warning(T.T_NULL, W._TEST_W_OtherErrorsInTable, table.m_tag, "unable to validate subtable: " + sIdentity + ", SubTable[" + i + "]");
}
}
else
{
v.Warning(T.T_NULL, W._TEST_W_OtherErrorsInTable, table.m_tag, "unable to validate subtable: " + sIdentity + ", SubTable[" + i + "]");
}
}
}
return bRet;
}
示例4: 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))
//.........这里部分代码省略.........
示例5: CheckCodePageBit
//.........这里部分代码省略.........
}
}
else
{
try
{
if (MultiByte.IsCodePageInstalled(CodePage))
{
ushort [] arrMissingChars = new ushort[10];
uint nMaxCharSize = MultiByte.GetCodePageMaxCharSize(CodePage);
if (nMaxCharSize == 1)
{
for (ushort c = 0; c<256; c++)
{
// check for special case: MultiByteToWideChar maps char 0xca in CP1255 to U05BA, but CP1255 spec says its not defined
if (CodePage != 1255 || c != 0xca)
{
CheckCodePageGlyph(CodePage, (char)c, ref nTotalChars, ref nMissingChars, arrMissingChars, fontOwner);
}
}
}
else if (nMaxCharSize == 2)
{
bool [] LeadByteMap = new bool[256];
for (int i=0; i<256; i++)
{
LeadByteMap[i] = MultiByte.IsCodePageLeadByte(CodePage, (byte)i);
}
for (ushort c = 0; c<256; c++)
{
if (LeadByteMap[c] == false)
{
CheckCodePageGlyph(CodePage, (char)c, ref nTotalChars, ref nMissingChars, arrMissingChars, fontOwner);
}
}
for (uint leadbyte = 0; leadbyte<256; leadbyte++)
{
if (LeadByteMap[leadbyte] == true)
{
for (uint secondbyte = 0; secondbyte<256; secondbyte++)
{
char c = (char)((leadbyte << 8) + secondbyte);
CheckCodePageGlyph(CodePage, c, ref nTotalChars, ref nMissingChars, arrMissingChars, fontOwner);
}
}
}
}
else
{
Debug.Assert(false);
}
if (bBitSet)
{
if (nMissingChars != 0)
{
string sDetails = "bit #" + nBit + ", " + sName;
int n = 0;
if (nMissingChars <=10)
{
sDetails += " (missing chars:";
n = nMissingChars;
}
else
{
sDetails += " (" + nMissingChars + " missing, first ten missing chars are:";
n = 10;
}
for (int i=0; i<n; i++)
{
sDetails += " U" + arrMissingChars[i].ToString("X4");
}
sDetails += ")";
v.Warning(T.T_NULL, W.OS_2_W_CodePageRangeBitSet, m_tag, sDetails);
}
}
else
{
if (nMissingChars == 0)
{
v.Warning(T.T_NULL, W.OS_2_W_CodePageRangeBitClear, m_tag, "bit #" + nBit + ", " + sName);
}
}
}
else
{
v.ApplicationError(T.T_NULL, E.OS_2_A_CodePageNotInstalled, m_tag, "CodePage " + CodePage + " is not installed on the system");
}
}
catch (Exception e)
{
v.ApplicationError(T.T_NULL, E.OS_2_A_CodePageNotInstalled, m_tag, "CodePage " + CodePage + " throws an exception:" + e.Message);
}
}
return bRet;
}
示例6: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
ushort numGlyphs = GetNumGlyphs(fontOwner);
if (v.PerformTest(T.hdmx_Version))
{
if (TableVersionNumber == 0)
{
v.Pass(T.hdmx_Version, P.hdmx_P_Version, m_tag);
}
else
{
v.Error(T.hdmx_Version, E.hdmx_E_Version, m_tag, TableVersionNumber.ToString());
bRet = false;
}
}
bool bNumDeviceRecordsOk = true;
if (v.PerformTest(T.hdmx_NumDeviceRecords))
{
if (NumberDeviceRecords >= 0)
{
v.Pass(T.hdmx_NumDeviceRecords, P.hdmx_P_NumDeviceRecords, m_tag, NumberDeviceRecords.ToString());
}
else
{
v.Error(T.hdmx_NumDeviceRecords, E.hdmx_E_NumDeviceRecords_neg, m_tag, NumberDeviceRecords.ToString());
bNumDeviceRecordsOk = false;
bRet = false;
}
}
bool bSizeOk = true;
if (v.PerformTest(T.hdmx_SizeofDeviceRecord))
{
if ((SizeofDeviceRecord & 3) != 0)
{
v.Error(T.hdmx_SizeofDeviceRecord, E.hdmx_E_SizeofDeviceRecord_alignment, m_tag, SizeofDeviceRecord.ToString());
bSizeOk = false;
bRet = false;
}
uint CalculatedSizeofDeviceRecord = CalculateSizeofDeviceRecord(numGlyphs);
if (SizeofDeviceRecord != CalculatedSizeofDeviceRecord)
{
string s = "actual = " + SizeofDeviceRecord + ", calc = " + CalculatedSizeofDeviceRecord;
v.Error(T.hdmx_SizeofDeviceRecord, E.hdmx_E_SizeofDeviceRecord_numGlyphs, m_tag, s);
bSizeOk = false;
bRet = false;
}
if (bSizeOk)
{
v.Pass(T.hdmx_SizeofDeviceRecord, P.hdmx_P_SizeofDeviceRecord, m_tag, SizeofDeviceRecord.ToString());
}
}
bool bLengthOk = true;
if (v.PerformTest(T.hdmx_TableLength))
{
if (bNumDeviceRecordsOk)
{
uint CalculatedTableLength = 8 + (uint)NumberDeviceRecords * CalculateSizeofDeviceRecord(numGlyphs);
if (GetLength() == CalculatedTableLength)
{
v.Pass(T.hdmx_TableLength, P.hdmx_P_TableLength, m_tag);
}
else
{
string s = "actual: " + GetLength() + ", calc: " + CalculatedTableLength;
v.Error(T.hdmx_TableLength, E.hdmx_E_TableLength, m_tag, s);
bLengthOk = false;
bRet = false;
}
}
else
{
v.Warning(T.hdmx_TableLength, W._TEST_W_OtherErrorsInTable, m_tag, "unable to validate table length");
}
}
if (v.PerformTest(T.hdmx_DeviceRecordPadBytesZero))
{
if (bSizeOk && bLengthOk & bNumDeviceRecordsOk)
{
uint unpaddedLength = (uint)numGlyphs + 2;
if ((unpaddedLength & 3) == 0)
{
v.Pass(T.hdmx_DeviceRecordPadBytesZero, P.hdmx_P_DeviceRecordPadBytes_none, m_tag);
}
//.........这里部分代码省略.........
示例7: Validate
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
bool bContinue = true;
if (v.PerformTest(T.SVG_version))
{
if ( version == 0 )
v.Pass(T.SVG_version, P.SVG_P_version, m_tag);
else
v.Warning(T.SVG_version, W.SVG_W_version, m_tag,
"Version=" + version);
}
if (v.PerformTest(T.SVG_offsetToSVGDocIndex))
{
uint offsetToSVGDocIndex_version0 = 10;
if ( offsetToSVGDocIndex == offsetToSVGDocIndex_version0 )
{
v.Pass(T.SVG_offsetToSVGDocIndex, P.SVG_P_offsetToSVGDocIndex, m_tag);
}
else
{
if ( offsetToSVGDocIndex < offsetToSVGDocIndex_version0 )
{
v.Error(T.SVG_offsetToSVGDocIndex, E.SVG_E_offsetToSVGDocIndex_Overlapping, m_tag,
"offset=" + offsetToSVGDocIndex);
bContinue = false;
bRet = false;
}
else
{
v.Warning(T.SVG_offsetToSVGDocIndex, W.SVG_W_offsetToSVGDocIndex_NonContiguous, m_tag,
"offset=" + offsetToSVGDocIndex);
}
}
}
if (v.PerformTest(T.SVG_reserved))
{
if ( reserved == 0 )
v.Pass(T.SVG_reserved, P.SVG_P_reserved, m_tag);
else
{
v.Warning(T.SVG_reserved, W.SVG_W_reserved, m_tag,
"Reserved=" + reserved);
}
}
if (v.PerformTest(T.SVG_numEntries))
{
if ( numEntries != 0 )
v.Pass(T.SVG_numEntries, P.SVG_P_numEntries, m_tag);
else
{
v.Warning(T.SVG_numEntries, W.SVG_W_numEntries, m_tag);
bContinue = false;
}
}
if (bContinue && v.PerformTest(T.SVG_SVGDocIndex))
{
bool statusOK = true;
int prev_startGlyphID = GetDocIndexEntry(0).startGlyphID - 1;
int prev_endGlyphID = GetDocIndexEntry(0).startGlyphID - 1;
uint prev_end = 2
+ (uint) numEntries * 12;
for (uint j = 0; j < numEntries ; j++)
{
var docEntry = GetDocIndexEntry(j);
if (docEntry.endGlyphID < docEntry.startGlyphID)
{
v.Error(T.SVG_SVGDocIndex, E.SVG_E_SVGDocIndex, m_tag,
"Entry " + j + ": endGlyphID < startGlyphID");
statusOK = false;
}
if (docEntry.svgDocOffset == 0)
{
v.Error(T.SVG_SVGDocIndex, E.SVG_E_SVGDocIndex, m_tag,
"Entry " + j + ": svgDocOffset is zero");
statusOK = false;
}
if (docEntry.svgDocLength == 0)
{
v.Error(T.SVG_SVGDocIndex, E.SVG_E_SVGDocIndex, m_tag,
"Entry " + j + ": svgDocLength is zero");
statusOK = false;
}
if (docEntry.startGlyphID <= prev_startGlyphID)
{
v.Error(T.SVG_SVGDocIndex, E.SVG_E_SVGDocIndex, m_tag,
"Entry " + j + ": startGlyphID not in increasing order");
statusOK = false;
}
//.........这里部分代码省略.........
示例8: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.post_TableLength))
{
bool bLenOk = true;
if (Version.GetUint() == 0x00010000 ||
Version.GetUint() == 0x00030000)
{
if (GetLength() != 32)
{
v.Error(T.post_TableLength, E.post_E_TableLenNot32, m_tag);
bLenOk = false;
bRet = false;
}
}
if (Version.GetUint() == 0x00020000)
{
if (GetLength() < 34)
{
v.Error(T.post_TableLength, E.post_E_InvalidTableLen, m_tag);
bLenOk = false;
bRet = false;
}
}
if (bLenOk)
{
v.Pass(T.post_TableLength, P.post_P_TableLength, m_tag);
}
}
if (v.PerformTest(T.post_Version))
{
uint ver = Version.GetUint();
if (ver == 0x00025000)
{
v.Warning(T.post_Version, W.post_W_Version_2_5, m_tag);
}
else if (ver == 0x00010000 || ver == 0x00020000 || ver == 0x00030000)
{
v.Pass(T.post_Version, P.post_P_Version, m_tag);
}
else
{
v.Error(T.post_Version, E.post_E_Version, m_tag, "0x"+ver.ToString("x8"));
}
}
if (v.PerformTest(T.post_italicAngle))
{
bool bItalOk = true;
uint ia = italicAngle.GetUint();
double dItalicAngle = italicAngle.GetDouble();
if (dItalicAngle < -30.0 || dItalicAngle > 360.0 || (dItalicAngle > 0.0 && dItalicAngle < 330.0 ))
{
v.Warning(T.post_italicAngle, W.post_W_italicAngle_unlikely, m_tag, "0x"+ia.ToString("x8"));
bItalOk = false;
}
Table_head headTable = (Table_head)fontOwner.GetTable("head");
if (headTable != null)
{
if ((headTable.macStyle & 0x0002) != 0)
{
if (ia == 0)
{
v.Error(T.post_italicAngle, E.post_E_italicAngleZero_macStyle, m_tag);
bItalOk = false;
bRet = false;
}
}
else
{
if (ia != 0)
{
v.Error(T.post_italicAngle, E.post_E_italicAngleNonzero_macStyle, m_tag);
bItalOk = false;
bRet = false;
}
}
}
else
{
v.Error(T.post_italicAngle, E._TEST_E_TableMissing, m_tag, "head table missing, can't compare italicAngle to head.macStyle");
bItalOk = false;
}
Table_hhea hheaTable = (Table_hhea)fontOwner.GetTable("hhea");
if (hheaTable != null)
{
//.........这里部分代码省略.........
示例9: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.kern_TableVersion))
{
if (version == 0)
{
v.Pass(T.kern_TableVersion, P.kern_P_TableVersion, m_tag);
}
else
{
v.Error(T.kern_TableVersion, E.kern_E_TableVersion, m_tag, "version = " + version.ToString() + ", unrecognized version #, no further tests can be performed");
return false;
}
}
if (v.PerformTest(T.kern_NumSubtables))
{
if (nTables != 0)
{
v.Pass(T.kern_NumSubtables, P.kern_P_NumSubTables, m_tag, nTables.ToString());
}
else
{
v.Error(T.kern_NumSubtables, E.kern_E_NumSubTables, m_tag);
bRet = false;
}
}
if (v.PerformTest(T.kern_SubtableFormats))
{
bool bFormatsOk = true;
for (uint i=0; i<nTables; i++)
{
SubTableHeader sth = GetSubTableHeader(i);
if (sth != null)
{
if (sth.GetFormat() != 0 && sth.GetFormat() != 2)
{
v.Error(T.kern_SubtableFormats, E.kern_E_SubtableFormats, m_tag, "subtable #" + i + ", format " + sth.GetFormat());
bFormatsOk = false;
bRet = false;
}
}
else
{
v.Error(T.kern_SubtableFormats, E.kern_E_SubTableExtendsPastEOT, m_tag, "subtable #" + i );
bFormatsOk = false;
bRet = false;
break;
}
}
if (bFormatsOk)
{
v.Pass(T.kern_SubtableFormats, P.kern_P_SubtableFormats, m_tag);
}
}
if (!bRet)
{
v.Warning(T.kern_SubtableFormats, W._TEST_W_OtherErrorsInTable, m_tag, "kern table appears to be corrupt. No further tests will be performed.");
return bRet;
}
if (v.PerformTest(T.kern_SubtableLength))
{
bool bLengthsOk = true;
for (uint i=0; i<nTables; i++)
{
SubTable st = this.GetSubTable(i);
if (st.length != st.CalculatedLength())
{
v.Error(T.kern_SubtableLength, E.kern_E_SubtableLength, m_tag, "subtable #" + i + ", length = " + st.length + ", calculated length = " + st.CalculatedLength());
bLengthsOk = false;
bRet = false;
}
}
if (bLengthsOk)
{
v.Pass(T.kern_SubtableLength, P.kern_P_SubtableLengths, m_tag);
}
}
if (v.PerformTest(T.kern_CoverageReservedBits))
{
bool bReservedOk = true;
for (uint i=0; i<nTables; i++)
{
//.........这里部分代码省略.........
示例10: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
if (v.PerformTest(T.LTSH_version))
{
if (version == 0)
{
v.Pass(T.LTSH_version, P.LTSH_P_version, m_tag);
}
else
{
v.Error(T.LTSH_version, E.LTSH_E_version, m_tag, version.ToString());
bRet = false;
}
}
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.LTSH_numGlyphs))
{
if (numGlyphs == fontOwner.GetMaxpNumGlyphs())
{
v.Pass(T.LTSH_numGlyphs, P.LTSH_P_numGlyphs, m_tag);
}
else
{
string s = "LTSH.numGlyphs = " + numGlyphs + ", maxp.numGlyphs = " + fontOwner.GetMaxpNumGlyphs();
v.Error(T.LTSH_numGlyphs, E.LTSH_E_numGlyphs, m_tag, s);
bRet = false;
}
}
if (v.PerformTest(T.LTSH_TableLength))
{
uint CalcLength = (uint)FieldOffsets.yPels + numGlyphs;
if (GetLength() == CalcLength)
{
v.Pass(T.LTSH_TableLength, P.LTSH_P_TableLength, m_tag);
}
else
{
string s = "calc length = " + CalcLength + ", actual length = " + GetLength();
v.Error(T.LTSH_TableLength, E.LTSH_E_TableLength, m_tag, s);
bRet = false;
}
}
if (v.PerformTest(T.LTSH_yPels))
{
bool bYPelsOk = true;
RasterInterf.DevMetricsData dmd = null;
try
{
Version ver = fontOwner.GetFile().GetRasterizer().FTVersion;
if ( ver.CompareTo(new Version(2,6,1)) < 0 )
v.Warning(T.LTSH_yPels, W.LTSH_W_Need_Newer_FreeType, m_tag,
"Using FreeType Version " + ver + " may not get correct results for LTSH");
dmd = fontOwner.GetCalculatedDevMetrics();
}
catch (Exception e)
{
v.ApplicationError(T.LTSH_yPels, E._Table_E_Exception, m_tag, e.Message);
bRet = false;
}
if (dmd != null)
{
for( uint iGlyphIndex = 0; iGlyphIndex < numGlyphs; iGlyphIndex++ )
{
if (iGlyphIndex >= fontOwner.GetMaxpNumGlyphs())
{
// JJF. Figure out what to do
v.Warning(T.LTSH_yPels, W._TEST_W_OtherErrorsInTable, m_tag, "can't test all yPel values, LTSH.numGlyphs does not equal maxp.numGlyphs");
bRet = false;
bYPelsOk = false;
break;
}
if( GetYPel(iGlyphIndex) != dmd.ltshData.yPels[iGlyphIndex] )
{
String sDetails = "glyph# = " + iGlyphIndex + ", value = " + GetYPel(iGlyphIndex) + ", calculated value = " + dmd.ltshData.yPels[iGlyphIndex];
v.Error(T.LTSH_yPels, E.LTSH_E_yPels, m_tag, sDetails);
bRet = false;
bYPelsOk = false;
}
/*
else
//.........这里部分代码省略.........
示例11: Validate
/************************
* public methods
*/
public bool Validate(Validator v, OTFontVal fontOwner)
{
bool bRet = true;
Table_hhea hheaTable = (Table_hhea)fontOwner.GetTable("hhea");
if (hheaTable == null)
{
v.Error(T.T_NULL, E._TEST_E_TableMissing, m_tag, "Unable to test this table, hhea table is invalid or missing");
return false;
}
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.hmtx_TableSize))
{
uint nhm = GetNumberOfHMetrics(fontOwner);
uint nlsb = GetNumLeftSideBearingEntries(fontOwner);
uint CalcTableLength = nhm*4 + nlsb*2;
if (CalcTableLength == GetLength())
{
v.Pass(T.hmtx_TableSize, P.hmtx_P_TableSize, m_tag);
}
else
{
v.Error(T.hmtx_TableSize, E.hmtx_E_TableSize, m_tag);
bRet = false;
}
}
if (v.PerformTest(T.hmtx_CheckMetrics))
{
bool bMetricsOk = true;
for (uint iGlyph=0; iGlyph<fontOwner.GetMaxpNumGlyphs(); iGlyph++)
{
longHorMetric hm = this.GetOrMakeHMetric(iGlyph, fontOwner);
if (hm != null)
{
if (hm.lsb > hm.advanceWidth)
{
v.Warning(T.hmtx_CheckMetrics, W.hmtx_W_CheckMetrics_lsb_gt_adv, m_tag, "glyph# " + iGlyph);
bMetricsOk = false;
}
}
else
{
// unable to fetch this horizontal metric
// (probably bad hheaTable.numberOfHMetrics or bad table length)
bMetricsOk = false;
}
}
if (bMetricsOk)
{
v.Pass(T.hmtx_CheckMetrics, P.hmtx_P_CheckMetrics, m_tag);
}
}
return bRet;
}
示例12: GetValidateEntryGlyf
/*
* METHODS PUBLIC: GLYF ACCESS
*/
public bool GetValidateEntryGlyf(int indexGlyph,
out int offsStart, out int length,
Validator validator, OTFont fontOwner)
{
offsStart=Table_loca.ValueInvalid;
length=Table_loca.ValueInvalid;
int offsGlyfCur, offsGlyfNext;
if ((!this.GetGlyfOffset(indexGlyph,out offsGlyfCur,validator, fontOwner))||
(!this.GetGlyfOffset(indexGlyph+1,out offsGlyfNext,validator, fontOwner)))
{
return false; // the error is already reported
}
int lengthGlyf=this.LengthGlyf(fontOwner);
if (lengthGlyf==Table_loca.ValueInvalid)
{
return false;
}
if ((offsGlyfCur<0)||(offsGlyfCur>=lengthGlyf))
{
if (validator!=null)
{
validator.Error(E.loca_E_OffsetWithinGlyfRange,"loca");
}
return false;
}
if ((offsGlyfNext<0)||(offsGlyfNext>=lengthGlyf))
{
int numEntry=this.NumEntry(fontOwner);
if ((indexGlyph!=numEntry-2)||(offsGlyfNext!=lengthGlyf))
{
if (validator!=null)
{
validator.Error(T.T_NULL, E.loca_E_OffsetWithinGlyfRange,
(OTTag)"loca","index glyph="+indexGlyph+1);
}
}
}
int lengthGlyfCur=offsGlyfNext-offsGlyfCur;
if (lengthGlyfCur<0)
{
if (validator!=null)
{
validator.Error(E.loca_E_OffsetsIncreasing,"loca");
}
return false;
}
if (lengthGlyfCur==0)
{
if (validator!=null)
{
validator.Warning(T.T_NULL, W.loca_W_GlyfEntryEmpty,"loca");
}
}
if (lengthGlyfCur%4!=0)
{
if (validator!=null)
{
validator.Warning(T.T_NULL, W.loca_W_GlyfEntryLengthAlignment,"loca");
}
}
offsStart=offsGlyfCur;
length=lengthGlyfCur;
return true;
}
示例13: ValidateGlyfPartiallyUnreferenced
private bool ValidateGlyfPartiallyUnreferenced(Validator validator,
OTFont fontOwner)
{
int numEntry=this.NumEntry(fontOwner);
if (numEntry==Table_loca.ValueInvalid)
{
validator.Warning(T.T_NULL, W.loca_W_GlyfPartiallyUnreferenced,this.m_tag);
return false;
}
int offsLast;
if (!this.GetGlyfOffset(numEntry-1,out offsLast,validator,fontOwner))
{
validator.Warning(T.T_NULL, W.loca_W_GlyfPartiallyUnreferenced,this.m_tag);
return false;
}
int lengthGlyf=this.LengthGlyf(fontOwner);
if (lengthGlyf==Table_loca.ValueInvalid)
{
validator.Warning(T.T_NULL, W.loca_W_GlyfPartiallyUnreferenced,this.m_tag);
return false;
}
if (lengthGlyf!=offsLast)
{
validator.Warning(T.T_NULL, W.loca_W_GlyfPartiallyUnreferenced,this.m_tag);
return false;
}
validator.Pass(P.loca_P_GlyfPartiallyUnreferenced,this.m_tag);
return true;
}
示例14: CheckTableAlignment
protected bool CheckTableAlignment(Validator v)
{
Debug.Assert(m_OffsetTable != null);
bool bRet = false;
if (m_OffsetTable != null)
{
bRet = true;
for (int i = 0; i<m_OffsetTable.DirectoryEntries.Count; i++)
{
DirectoryEntry de = (DirectoryEntry)m_OffsetTable.DirectoryEntries[i];
if ((de.offset & 0x03) != 0)
{
v.Warning(T.T_NULL, W._DE_W_TableAlignment, null, (string)de.tag);
//bRet = false;
}
}
if (bRet == true)
{
v.Pass(P._DE_P_TableAlignment, null);
}
}
return bRet;
}
示例15: Validate
//.........这里部分代码省略.........
prepLength = dePrep.length;
}
DirectoryEntry deFpgm =
fontOwner.GetDirectoryEntry("fpgm" );
uint fpgmLength = 0;
if ( null != deFpgm ) {
fpgmLength = deFpgm.length;
}
if ( maxSizeOfInstructions ==
maxSizeOfInstructionsCalc ) {
// Case 1:
String sDetails = "maxSizeOfInstructions=" +
maxSizeOfInstructions + ", computed " +
"from the glyf table";
v.Info( T.maxp_GlyphStats,
I.maxp_I_Calculation_Method1,
m_tag, sDetails);
}
else if ( maxSizeOfInstructions ==
( maxSizeOfInstructionsCalc +
prepLength + fpgmLength ) ) {
// Case 2:
String sDetails =
"maxp maxSizeOfInstructions is " +
maxSizeOfInstructions + ", which is " +
"glyf maxSizeOfInstructions (" +
maxSizeOfInstructionsCalc +
") + prep size (" + prepLength +
") + fpgm size (" + fpgmLength + ")";
v.Info( T.maxp_GlyphStats,
I.maxp_I_Calculation_Method2,
m_tag, sDetails);
}
else if ( maxSizeOfInstructions <
maxSizeOfInstructionsCalc ) {
// Case 3
String sDetails =
"maxp maxSizeOfInstructions is " +
maxSizeOfInstructions +
", which is smaller than the " +
"size of instuctions (" +
maxSizeOfInstructionsCalc + ") found" +
" for some glyph in the glyf table.";
v.Error( T.maxp_GlyphStats,
E.maxp_E_Calculation, m_tag,
sDetails);
bRet = false;
}
else {
// Case 4
String sDetails =
"glyf maxSizeOfInstructions=" +
maxSizeOfInstructionsCalc +
", prep size=" + prepLength +
", fpgm size=" + fpgmLength +
", whereas maxp maxSizeOfInstruction " +
"is " + maxSizeOfInstructions;
v.Warning(T.maxp_GlyphStats,
W.maxp_W_Calculation_Unclear,
m_tag,
sDetails);
bGlyphStatsOk = false;
}
if (maxComponentElements != maxComponentElementsCalc)
{
String sDetails = "maxComponentElements = " + maxComponentElements + ", calculated = " + maxComponentElementsCalc;
v.Error(T.maxp_GlyphStats, E.maxp_E_Calculation, m_tag, sDetails);
bRet = false;
bGlyphStatsOk = false;
}
if (maxComponentDepth != maxComponentDepthCalc)
{
String sDetails = "maxComponentDepth = " + maxComponentDepth + ", calculated = " + maxComponentDepthCalc;
v.Error(T.maxp_GlyphStats, E.maxp_E_Calculation, m_tag, sDetails);
bRet = false;
bGlyphStatsOk = false;
}
if (bGlyphStatsOk)
{
v.Pass(T.maxp_GlyphStats, P.maxp_P_Calculation, m_tag);
}
}
else
{
v.Warning(T.maxp_GlyphStats, W._TEST_W_ErrorInAnotherTable, m_tag, "Errors in the glyf table are preventing validation of maxPoints, maxContours, maxCompositePoints, maxCompositeContours, maxSizeofInstructions, maxComponentElements, and maxComponentDepth");
}
}
}
else
{
v.Info(T.maxp_GlyphStats, I._TEST_I_TableVersion, m_tag, "test = maxp_GlyphStats");
}
}
return bRet;
}