// // The point of heavy use of callbacks is that we want to // do everything here so that the report comes out the same, // regardless of the program running the validator. // // All questions of file names, temporary file cleanup, // and decisions about what to show when should be handled // by the calling code. // private int ValidateFont(Validator v, string fpath, SafeFileHandle hFile, int i, int n) { string sReportFile = ""; OTFileVal fontFile; int ret = 0; // create a FontFile Object fontFile = new OTFileVal(v); m_callbacks.OnOTFileValChange(fontFile); // open the report file sReportFile = m_callbacks.GetReportFileName(fpath); OpenXmlReportFile(sReportFile, fpath); m_callbacks.OnOpenReportFile(sReportFile, fpath); // open the font file and validate it #if !OLD_INTERFACE bool isvalid = (hFile == null) ? fontFile.open(fpath) : fontFile.open(hFile); #else bool isvalid = fontFile.open(fpath); #endif //if the font file is invalid, we just do not go on with validation and output the results //this apparently fixed a lot of bugs (1231, 1429, 934, 1335) //Check if the sample font files are really invalid if (isvalid) { m_callbacks.OnBeginFontTest(fpath, i, n); #if !OLD_INTERFACE if (!fontFile.Validate()) { ret = 1; } #else fontFile.Validate(); #endif fontFile.close(); } else { ret = 1; } fontFile = null; m_callbacks.OnOTFileValChange(fontFile); CloseXmlReportFile(); m_callbacks.OnCloseReportFile(sReportFile); return(ret); }
/****************** * protected methods */ protected static OffsetTable ReadOffsetTable(OTFileVal file, uint filepos) { // read the Offset Table from the file Validator v = file.GetValidator(); const int SIZEOF_OFFSETTABLE = 12; OffsetTable ot = null; // read the offset table MBOBuffer buf = file.ReadPaddedBuffer(filepos, SIZEOF_OFFSETTABLE); if (buf != null) { if (OTFile.IsValidSfntVersion(buf.GetUint(0))) { ot = new OffsetTable(buf); } else { v.Error(T.T_NULL, E._OFFSET_E_InvalidSFNT, null, "0x" + buf.GetUint(0).ToString("x8")); } } // now read the directory entries if (ot != null) { const int SIZEOF_DIRECTORYENTRY = 16; for (int i = 0; i < ot.numTables; i++) { uint dirFilePos = (uint)(filepos + SIZEOF_OFFSETTABLE + i * SIZEOF_DIRECTORYENTRY); MBOBuffer DirEntBuf = file.ReadPaddedBuffer(dirFilePos, SIZEOF_DIRECTORYENTRY); if (DirEntBuf != null) { DirectoryEntry de = new DirectoryEntry(); de.tag = new OTTag(DirEntBuf.GetBuffer()); de.checkSum = DirEntBuf.GetUint(4); de.offset = DirEntBuf.GetUint(8); de.length = DirEntBuf.GetUint(12); ot.DirectoryEntries.Add(de); if (de.offset > file.GetFileLength()) { v.Error(T.T_NULL, E._DE_E_OffsetPastEOF, de.tag, "0x" + de.offset.ToString("x8")); } } else { break; } } } return(ot); }
public void OnOTFileValChange( OTFileVal fontFile ){ }
public void OnOTFileValChange( OTFileVal fontFile ) { m_curOTFileVal = fontFile; }
/****************** * protected methods */ protected static OffsetTable ReadOffsetTable(OTFileVal file, uint filepos) { // read the Offset Table from the file Validator v = file.GetValidator(); const int SIZEOF_OFFSETTABLE = 12; OffsetTable ot = null; // read the offset table MBOBuffer buf = file.ReadPaddedBuffer(filepos, SIZEOF_OFFSETTABLE); if (buf != null) { if (OTFile.IsValidSfntVersion(buf.GetUint(0))) { ot = new OffsetTable(buf); } else { v.Error(T.T_NULL, E._OFFSET_E_InvalidSFNT, null, "0x"+buf.GetUint(0).ToString("x8")); } } // now read the directory entries if (ot != null) { const int SIZEOF_DIRECTORYENTRY = 16; for (int i=0; i<ot.numTables; i++) { uint dirFilePos = (uint)(filepos+SIZEOF_OFFSETTABLE+i*SIZEOF_DIRECTORYENTRY); MBOBuffer DirEntBuf = file.ReadPaddedBuffer(dirFilePos, SIZEOF_DIRECTORYENTRY); if (DirEntBuf != null) { DirectoryEntry de = new DirectoryEntry(); de.tag = new OTTag(DirEntBuf.GetBuffer()); de.checkSum = DirEntBuf.GetUint(4); de.offset = DirEntBuf.GetUint(8); de.length = DirEntBuf.GetUint(12); ot.DirectoryEntries.Add(de); if (de.offset > file.GetFileLength()) { v.Error(T.T_NULL, E._DE_E_OffsetPastEOF, de.tag, "0x"+de.offset.ToString("x8")); } } else { break; } } } return ot; }
// // The point of heavy use of callbacks is that we want to // do everything here so that the report comes out the same, // regardless of the program running the validator. // // All questions of file names, temporary file cleanup, // and decisions about what to show when should be handled // by the calling code. // private int ValidateFont(Validator v, string fpath, SafeFileHandle hFile,int i,int n) { string sReportFile = ""; OTFileVal fontFile; int ret = 0; // create a FontFile Object fontFile = new OTFileVal(v); m_callbacks.OnOTFileValChange(fontFile); // open the report file sReportFile = m_callbacks.GetReportFileName(fpath); OpenXmlReportFile(sReportFile, fpath); m_callbacks.OnOpenReportFile(sReportFile, fpath); // open the font file and validate it bool isvalid = (hFile == null) ? fontFile.open(fpath) : fontFile.open(hFile); //if the font file is invalid, we just do not go on with validation and output the results //this apparently fixed a lot of bugs (1231, 1429, 934, 1335) //Check if the sample font files are really invalid if (isvalid) { m_callbacks.OnBeginFontTest(fpath, i, n); if (!fontFile.Validate()) { ret = 1; } fontFile.close(); } else { ret = 1; } fontFile = null; m_callbacks.OnOTFileValChange(fontFile); CloseXmlReportFile(); m_callbacks.OnCloseReportFile(sReportFile); return ret; }
/* * PROPERTIES */ /* * public OTFile FileFont * { * get {return this.font.GetFile();} * } */ /* * METHODS: I_IOGLYPHS */ public bool Initialize(Object source, DIAction dia) { /* * ASSUMPTION: source is either * - OTFont or * - NameFileFont */ this.m_validator = new Validator(); this.m_validator.DIA = dia; this.m_font = source as OTFont; if (this.m_font == null) { string nameFileFont = source as string; if (nameFileFont != null) { Validator validatorDummy = new Validator(); OTFileVal file = new OTFileVal(validatorDummy); if (!file.open(nameFileFont)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Unable to open font file " + nameFileFont); this.Clear(); return(false); } this.m_toCloseFileOnClear = true; try { this.m_font = file.GetFont(0); } catch { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Unable to get font from the file" + nameFileFont); this.Clear(); return(false); } } } this.m_tableGlyf = (val_glyf)this.m_font.GetTable("glyf"); if (this.m_tableGlyf == null) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Missing table: glyf"); this.Clear(); return(false); } this.m_tableLoca = (val_loca)this.m_font.GetTable("loca"); if (this.m_tableLoca == null) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Missing table: loca"); this.Clear(); return(false); } if (!this.m_tableLoca.ValidateFormat(m_validator, this.m_font)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Table 'loca' has incorrect format"); this.Clear(); return(false); } if (!this.m_tableLoca.ValidateNumEntries(null, this.m_font)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Table 'loca' has incorrect number of entries"); this.Clear(); return(false); } this.m_numGlyph = this.m_tableLoca.NumEntry(this.m_font) - 1; return(true); }
/* * PROPERTIES */ /* public OTFile FileFont { get {return this.font.GetFile();} } */ /* * METHODS: I_IOGLYPHS */ public bool Initialize(Object source, DIAction dia) { /* * ASSUMPTION: source is either * - OTFont or * - NameFileFont */ this.m_validator=new Validator(); this.m_validator.DIA=dia; this.m_font=source as OTFont; if (this.m_font==null) { string nameFileFont=source as string; if (nameFileFont!=null) { Validator validatorDummy=new Validator(); OTFileVal file = new OTFileVal(validatorDummy); if (!file.open(nameFileFont)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Unable to open font file "+nameFileFont); this.Clear(); return false; } this.m_toCloseFileOnClear=true; try { this.m_font=file.GetFont(0); } catch { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Unable to get font from the file"+nameFileFont); this.Clear(); return false; } } } this.m_tableGlyf=(val_glyf)this.m_font.GetTable("glyf"); if (this.m_tableGlyf==null) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Missing table: glyf"); this.Clear(); return false; } this.m_tableLoca=(val_loca)this.m_font.GetTable("loca"); if (this.m_tableLoca==null) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Missing table: loca"); this.Clear(); return false; } if (!this.m_tableLoca.ValidateFormat(m_validator, this.m_font)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Table 'loca' has incorrect format"); this.Clear(); return false; } if (!this.m_tableLoca.ValidateNumEntries(null,this.m_font)) { this.m_validator.Error(T.T_NULL, E.glyf_E_UnableToStartValidation, (OTTag)"glyf", "Table 'loca' has incorrect number of entries"); this.Clear(); return false; } this.m_numGlyph=this.m_tableLoca.NumEntry(this.m_font)-1; return true; }
public void OnOTFileValChange(OTFileVal fontFile) { }