// // 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); }
/* * 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); }
// // 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; }