Esempio n. 1
0
        public void SendInfoOneByOne(ValInfoBasic info, out string strErrMessage)
        {
            strErrMessage = null;
            StringBuilder sb = null;

            if (this.dia == null)
            {
                return;
            }
            Delegate[] delegs = this.dia.GetInvocationList();
            foreach (Delegate deleg in delegs)
            {
                try
                {
                    DIAction dia = (DIAction)deleg;
                    dia(info);
                }
                catch
                {
                    if (sb == null)
                    {
                        sb = new StringBuilder();
                    }
                    sb.Append(deleg.Target.GetType());
                    sb.Append("\r\n");
                }
            }
            strErrMessage = sb.ToString();
        }
Esempio n. 2
0
        /*
         *        METHODS    :    VALIDATORS SOURCE
         */
        internal StatusGV.TypeStatusExec ValidateTypeGlyphSource(GErrList gerrlist)
        {
            DIAction dia = DIActionBuilder.DIA(gerrlist, "DIAFunc_AddToListUnique");

            gerrlist.DIW = new DIWrapperSource(this.index,
                                               GConsts.TypeGlyph.Undef,
                                               GScope.TypeGScope._GG_);

            I_IOGlyphs i_IOGlyphs = this.fm.IIOGlyphs;

            if (i_IOGlyphs == null)
            {
                //throw new ExceptionGlyph("Glyph","ValidateTypeGlyphSource",null);
                return(StatusGV.TypeStatusExec.Aborted);
            }

            int numErrBefore = gerrlist.Length;

            i_IOGlyphs.ReadTypeGlyph(this.index, out this.typeGlyph, dia);
            int numErrAfter = gerrlist.Length;
            int iErr;

            for (iErr = numErrBefore; iErr < numErrAfter; iErr++)
            {
                gerrlist[iErr].TypeGlyph = this.typeGlyph;
            }
            gerrlist.DIW = null;
            return(StatusGV.TypeStatusExec.Completed);
        }
Esempio n. 3
0
        //This version of RunValidation is to be used when the file is already opened by other process and you have the handle
        //i.e. , this is used when the validation is called from the ValInterface.dll
        //The file name is needed just for the path of the report file
        public int RunValidation(Validator v, string fpath, SafeFileHandle hFile)
        {
            int ret = 0;

            v.SetOnValidateEvent(new
                                 Validator.OnValidateEvent(OnValidateEvent));
            // enable us to receive validation info messages
            DIAction vid = new DIAction(ValidatorCallback);

            v.SetValInfoDelegate(vid);

            try
            {
                // check to see if the user canceled validation
                if (v.CancelFlag)
                {
                    m_callbacks.OnCancel();
                    return(ret);
                }

                ret |= ValidateFont(v, fpath, hFile, 0, 1);
                m_callbacks.OnReportsReady();
            }
            catch (Exception e)
            {
                m_callbacks.OnException(e);
                return(1);
            }

            return(ret);
        }
Esempio n. 4
0
        public void ReadTypeGlyph(int indexGlyph,
                                  out GConsts.TypeGlyph typeGlyph,
                                  DIAction dia)
        {
            typeGlyph            = GConsts.TypeGlyph.Undef;
            this.m_validator.DIA = dia;

            int offsStart, length;

            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                                                       out offsStart, out length, this.m_validator, this.m_font))
            {
                return;
            }
            if (length == 0)
            {
                typeGlyph = GConsts.TypeGlyph.Empty;
                return;
            }
            if ((int)Table_glyf.FieldOffsets.numCont + 2 >= offsStart + length)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                return;
            }
            int numCont;

            numCont   = this.m_tableGlyf.Buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.numCont));
            typeGlyph = (numCont >= 0)? GConsts.TypeGlyph.Simple: GConsts.TypeGlyph.Composite;
        }
Esempio n. 5
0
 public void InformAll(DIAction diaToApply)
 {
     // get information about ALL GLYPHS
     foreach (DictionaryEntry entry in this.gerrlists)
     {
         GErrList gerrlist = entry.Value as GErrList;
         gerrlist.ApplyToEach(diaToApply);
     }
 }
Esempio n. 6
0
 public void ApplyToEach(DIAction dia)
 {
     if (dia != null)
     {
         foreach (GErr gerr in this.gerrs)
         {
             dia(gerr);
         }
     }
 }
Esempio n. 7
0
        // TODO: rewrite
        public void ReadFontMetrics(out int descendMin,
                                    out int ascendMax,
                                    out int lsbMin,
                                    out int rsbMax,
                                    DIAction dia)
        {
            descendMin = -700;
            ascendMax  = 2100;
            lsbMin     = -1000;
            rsbMax     = 3500;

            try
            {
                BoxD bboxRes = new BoxD();

                Table_cmap tableCmap = (Table_cmap)this.m_font.GetTable("cmap");
                if (tableCmap == null)
                {
                    return;
                }
                Table_cmap.EncodingTableEntry eteUni =
                    tableCmap.GetEncodingTableEntry(3, 1);
                if (eteUni == null)
                {
                    return;
                }
                Table_cmap.Subtable subtableCmap = tableCmap.GetSubtable(eteUni);
                char[] samples = { 'A', 'W', 'p' };
                for (int iSample = 0; iSample < samples.Length; iSample++)
                {
                    byte[] charbuf = new byte[2];
                    charbuf[0] = (byte)'A';
                    charbuf[1] = 0;
                    int indGlyph             = (int)subtableCmap.MapCharToGlyph(charbuf, 0);
                    Table_glyf.header header = this.m_tableGlyf.GetGlyphHeader((uint)indGlyph, this.m_font);
                    if (header == null)
                    {
                        return;
                    }
                    BoxD bboxCur = new BoxD(header.xMin, header.yMin,
                                            header.xMax, header.yMax);
                    bboxRes.Unite(bboxCur);
                }
                descendMin = (int)bboxRes.VecMin.Y;
                ascendMax  = (int)bboxRes.VecMax.Y;
                lsbMin     = (int)bboxRes.VecMin.X;
                rsbMax     = (int)bboxRes.VecMax.X;
            }
            catch
            {
            }
        }
Esempio n. 8
0
 public bool RemoveDeleg(DIAction diaToRemove)
 {
     if (diaToRemove == null)
     {
         return(false);
     }
     if (this.dia == null)
     {
         return(false);
     }
     this.dia = (MulticastDelegate.Remove(this.dia, diaToRemove)) as DIAction;
     return(true);
 }
 /*
  *        METHODS
  */
 public bool AddDeleg(DIAction diaToAdd)
 {
     if (diaToAdd==null)
         return true;
     if (this.dia==null)
     {
         this.dia=diaToAdd;
     }
     else
     {
         this.dia=(MulticastDelegate.Combine(this.dia,diaToAdd)) as DIAction;
     }
     return true;
 }
Esempio n. 10
0
        public bool DIAAdd(DIAction dia, FManager.TypeActionOnErr flag)
        {
            switch (flag)
            {
            case FManager.TypeActionOnErr.onDelete:
                return(this.dia_OnErrorDelete.AddDeleg(dia));

            case FManager.TypeActionOnErr.onAdd:
                return(this.dia_OnErrorAdd.AddDeleg(dia));

            default:
                return(false);
            }
        }
Esempio n. 11
0
        internal StatusGV.TypeStatusExec ValidateCompSource(GErrList gerrlist)
        {
            if (this.bbox != null)
            {
                this.bbox.Clear();
                this.bbox = null;
            }
            if (this.comp != null)
            {
                this.comp.ClearDestroy();
                this.comp = null;
            }
            if (this.outl != null)
            {
                this.outl.ClearDestroy();
                this.outl = null;
            }

            if (this.typeGlyph == GConsts.TypeGlyph.Empty)
            {
                return(StatusGV.TypeStatusExec.Completed);
            }
            if (this.typeGlyph != GConsts.TypeGlyph.Composite)
            {
                //throw new ExceptionGlyph("Glyph","ValidateCompSource",null);
                return(StatusGV.TypeStatusExec.Aborted);
            }
            DIAction dia = DIActionBuilder.DIA(gerrlist, "DIAFunc_AddToListUnique");

            gerrlist.DIW = new DIWrapperSource(this.index, this.typeGlyph, GScope.TypeGScope._GGB_);

            I_IOGlyphs i_IOGlyphs = this.fm.IIOGlyphs;

            if (i_IOGlyphs == null)
            {
                //throw new ExceptionGlyph("Glyph","ValidateCompSource",null);
                return(StatusGV.TypeStatusExec.Aborted);
            }
            i_IOGlyphs.ReadGGB(this.index, out this.bbox, dia);
            i_IOGlyphs.ReadGGC(this.index, out this.comp, dia);
            if (this.comp != null)
            {
                this.fm.OnGComposite(this.index);
            }


            gerrlist.DIW = null;
            return(StatusGV.TypeStatusExec.Completed);
        }
Esempio n. 12
0
 /*
  *        METHODS
  */
 public bool AddDeleg(DIAction diaToAdd)
 {
     if (diaToAdd == null)
     {
         return(true);
     }
     if (this.dia == null)
     {
         this.dia = diaToAdd;
     }
     else
     {
         this.dia = (MulticastDelegate.Combine(this.dia, diaToAdd)) as DIAction;
     }
     return(true);
 }
Esempio n. 13
0
 /*
  *        CONSTRUCTORS
  */
 public DIActionContainer(params DIAction[] dias)
 {
     if (dias != null)
     {
         foreach (DIAction dia in dias)
         {
             if (dia != null)
             {
                 if (this.dia == null)
                 {
                     this.dia = dia;
                 }
                 else
                 {
                     this.dia = System.Delegate.Combine(this.dia, dia) as DIAction;
                 }
             }
         }
     }
 }
Esempio n. 14
0
 /*
  *        CONSTRUCTORS
  */
 public DIActionContainer(params DIAction[] dias)
 {
     if (dias!=null)
     {
         foreach (DIAction dia in dias)
         {
             if (dia!=null)
             {
                 if (this.dia==null)
                 {
                     this.dia=dia;
                 }
                 else
                 {
                     this.dia=System.Delegate.Combine(this.dia,dia) as DIAction;
                 }
             }    
         }
     }
 }    
Esempio n. 15
0
        public bool Inform(int indGlyph, DIAction diaToApply)
        {
            bool bRet = true;

            if (indGlyph == GConsts.IND_ALL)
            {
                this.InformAll(diaToApply);
                bRet = true;
            }
            else
            {
                GErrList gerrlist = this.gerrlists[indGlyph] as GErrList;
                if (gerrlist != null)
                {
                    //If some error is of type Error or AppError, then return false
                    bRet &= gerrlist.TestErrors();
                    gerrlist.ApplyToEach(diaToApply);
                }
            }
            return(bRet);
        }
Esempio n. 16
0
        public void ReadGGB(int indexGlyph,
                            out BoxD bbox,
                            DIAction dia)
        {
            this.m_validator.DIA = dia;

            bbox = null;

            int offsStart, length;

            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                                                       out offsStart, out length, this.m_validator, this.m_font))
            {
                return;
            }
            if (length == 0)
            {
                return;
            }
            short xMin, yMin, xMax, yMax;

            if ((int)Table_glyf.FieldOffsets.nextAfterHeader >= length)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                return;
            }

            MBOBuffer buffer = this.m_tableGlyf.Buffer;

            xMin = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.xMin));
            yMin = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.yMin));
            xMax = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.xMax));
            yMax = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.yMax));
            bbox = new BoxD(xMin, yMin, xMax, yMax);
        }
Esempio n. 17
0
        //Validates a list of font files...meant to be used by the Font Validator UI and the command line
        public int RunValidation(Validator v, string [] fontList)
        {
            int i;
            int ret = 0;

            // setup notification for validation events
            v.SetOnValidateEvent(new
                                 Validator.OnValidateEvent(OnValidateEvent));
            // enable us to receive validation info messages
            DIAction vid = new DIAction(ValidatorCallback);

            v.SetValInfoDelegate(vid);

            try
            {
                for (i = 0; i < fontList.Length; i++)
                {
                    // check to see if the user canceled validation
                    if (v.CancelFlag)
                    {
                        m_callbacks.OnCancel();
                        return(ret);
                    }

                    ret |= ValidateFont(v, fontList[i], null, i, fontList.Length);
                }
                m_callbacks.OnReportsReady();
            }
            catch (Exception e)
            {
                m_callbacks.OnException(e);
                return(1);
            }

            return(ret);
        }
Esempio n. 18
0
        // TODO: rewrite
        public void ReadFontMetrics(out int descendMin, 
            out int ascendMax,    
            out int lsbMin, 
            out int rsbMax, 
            DIAction dia)
        {
            descendMin=-700;
            ascendMax=2100;
            lsbMin=-1000;
            rsbMax=3500;

            try
            {
                BoxD bboxRes=new BoxD();

                Table_cmap tableCmap = (Table_cmap)this.m_font.GetTable("cmap");
                if (tableCmap==null)
                    return;
                Table_cmap.EncodingTableEntry eteUni = 
                    tableCmap.GetEncodingTableEntry(3,1);
                if (eteUni==null)
                    return;
                Table_cmap.Subtable subtableCmap = tableCmap.GetSubtable(eteUni);
                char[] samples={'A','W','p'};
                for (int iSample=0; iSample<samples.Length; iSample++)
                {                
                    byte[] charbuf = new byte[2];
                    charbuf[0] = (byte)'A';
                    charbuf[1] = 0; 
                    int indGlyph = (int)subtableCmap.MapCharToGlyph(charbuf, 0);
                    Table_glyf.header header=this.m_tableGlyf.GetGlyphHeader((uint)indGlyph,this.m_font);
                    if (header==null)
                        return;
                    BoxD bboxCur=new BoxD(header.xMin, header.yMin,
                        header.xMax, header.yMax);
                    bboxRes.Unite(bboxCur);
                }
                descendMin=(int)bboxRes.VecMin.Y;
                ascendMax=(int)bboxRes.VecMax.Y;
                lsbMin=(int)bboxRes.VecMin.X;
                rsbMax=(int)bboxRes.VecMax.X;
            }
            catch
            {
            }
        }
Esempio n. 19
0
 public bool DIAAdd(DIAction dia, FManager.TypeActionOnErr flag)
 {
     switch (flag)
     {
         case FManager.TypeActionOnErr.onDelete:
             return (this.dia_OnErrorDelete.AddDeleg(dia));
         case FManager.TypeActionOnErr.onAdd:
             return (this.dia_OnErrorAdd.AddDeleg(dia));
         default:
             return false;
     }
 }
Esempio n. 20
0
 public void InitValidation(DIAction vid)
 {
     m_Validator.SetValInfoDelegate(vid);
 }
 public DIActionOnCondBuilder(DICond dic, DIAction dia)
 {
     this.dic = dic;
     this.dia = dia;
 }
Esempio n. 22
0
        //Validates a list of font files...meant to be used by the Font Validator UI and the command line
        public int RunValidation( Validator v, string [] fontList )
        {
            int i;
            int ret = 0;
            // setup notification for validation events
            v.SetOnValidateEvent(new
                                 Validator.OnValidateEvent(OnValidateEvent));
            // enable us to receive validation info messages
            DIAction vid = new DIAction(ValidatorCallback);
            v.SetValInfoDelegate(vid);

            try
            {
                for (i = 0; i < fontList.Length; i++)
                {
                    // check to see if the user canceled validation
                    if (v.CancelFlag)
                    {
                        m_callbacks.OnCancel();
                        return ret;
                    }

                    ret |= ValidateFont(v, fontList[i], null, i, fontList.Length);
                }
                m_callbacks.OnReportsReady();
            }
            catch (Exception e)
            {
                m_callbacks.OnException(e);
                return 1;
            }

            return ret;

        }
Esempio n. 23
0
 public void ReadTypeGlyph(int indexGlyph, 
     out GConsts.TypeGlyph typeGlyph, 
     DIAction dia)
 {
     typeGlyph=GConsts.TypeGlyph.Undef;
     this.m_validator.DIA=dia;
     
     int offsStart,length;
     if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
         out offsStart,out length, this.m_validator, this.m_font))
         return;
     if (length==0)
     {
         
         typeGlyph=GConsts.TypeGlyph.Empty;
         return; 
     }
     if ((int)Table_glyf.FieldOffsets.numCont+2>=offsStart+length)
     {
         this.m_validator.Error(
             E._GEN_E_OffsetExceedsTableLength, 
             (OTTag)"glyf");
         return;
     }
     int numCont;
     numCont=this.m_tableGlyf.Buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.numCont));
     typeGlyph=(numCont>=0)? GConsts.TypeGlyph.Simple: GConsts.TypeGlyph.Composite;
 }
Esempio n. 24
0
 // get information
 public bool GErrGetInformed(int indGlyph, DIAction diaToApply)
 {
     this.OnGErrQuery(indGlyph);
     return this.gerrPool.Inform(indGlyph, diaToApply);
 }
Esempio n. 25
0
 // get information
 public bool GErrGetInformed(int indGlyph, DIAction diaToApply)
 {
     this.OnGErrQuery(indGlyph);
     return(this.gerrPool.Inform(indGlyph, diaToApply));
 }
Esempio n. 26
0
 /*
  *            METHODS: PUBLIC
  *            error-reporting interface for external application
  */
 public bool GErrActionAdd(DIAction dia, TypeActionOnErr flag)
 {
     return(this.gerrPool.DIAAdd(dia, flag));
 }
Esempio n. 27
0
 public void ApplyToEach(DIAction dia)
 {
     if (dia!=null)
     {
         foreach (GErr gerr in this.gerrs)
         {
             dia(gerr);
         }
     }
 }
Esempio n. 28
0
        public void ReadGGC(int indexGlyph, 
            out Composite comp, 
            DIAction dia)
        {
            this.m_validator.DIA=dia;
            comp=null;
    
            GConsts.TypeGlyph typeGlyph;
            this.ReadTypeGlyph(indexGlyph, out typeGlyph, dia);
            if (typeGlyph!=GConsts.TypeGlyph.Composite)
                return;
            int offsStart, length;
            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                out offsStart, out length, this.m_validator, this.m_font))
                return;

            MBOBuffer buffer=this.m_tableGlyf.Buffer;
            uint offsCur=(uint)(offsStart+Table_glyf.FieldOffsets.nextAfterHeader);
            bool isLast=false;
            try
            {
                Component component;
                while (!isLast)
                {
                    ushort flags=buffer.GetUshort(offsCur);
                    isLast=((flags&(ushort)Table_glyf.MaskFlagComponent.MORE_COMPONENTS)==0);
                    offsCur+=2;

                    ushort indGlyphCur=buffer.GetUshort(offsCur); // TODO: save
                    component=new Component(indGlyphCur);
                
                    // TODO: validate indGlyph is in right boundaries
                    // TODO: add Relations to FManager
                    offsCur+=2;

                    bool weHaveAScale=((flags&(ushort)Table_glyf.MaskFlagComponent.WE_HAVE_A_SCALE)!=0);
                    bool weHaveAnXAndYScale=((flags&(ushort)Table_glyf.MaskFlagComponent.WE_HAVE_AN_X_AND_Y_SCALE)!=0);
                    bool weHaveATwoByTwo=((flags&(ushort)Table_glyf.MaskFlagComponent.WE_HAVE_A_TWO_BY_TWO)!=0);
                    int cnt=0;
                    if (weHaveAScale) cnt++;
                    if (weHaveAnXAndYScale) cnt++;
                    if (weHaveATwoByTwo) cnt++;
                    if (cnt>1)
                    {
                        this.m_validator.Error(T.T_NULL,
                            E.glyf_E_CompositeAmbigousTransform, 
                            (OTTag)"glyf",
                            "Index Component: "+indGlyphCur);
                        return;
                    }
                    if ((flags&(ushort)Table_glyf.MaskFlagComponent.RESERVED)!=0)
                    {
                        this.m_validator.Warning(T.T_NULL,
                            W.glyf_W_CompositeReservedBit,
                            (OTTag)"glyf",
                            "Index Component: "+indGlyphCur);
                    }

                    int arg1, arg2;
                    if ((flags&(ushort)Table_glyf.MaskFlagComponent.ARG_1_AND_2_ARE_WORDS)!=0)
                    {
                        arg1=(int)buffer.GetShort(offsCur);
                        offsCur+=2;
                        arg2=(int)buffer.GetShort(offsCur);
                        offsCur+=2;
                    }
                    else
                    {
                        arg1=(int)buffer.GetSbyte(offsCur);
                        offsCur+=1;
    
                        arg2=(int)buffer.GetSbyte(offsCur);
                        offsCur+=1;
                    }                    
                    // TODO: validate bounding boxes
                    // TODO: check that NOT BOTH shift & knots are initialized, but ONE of them IS initialized
                    // TODO: validate that indKnots (both!) are in the right boundaries
                    // TODO: validate that a single-point contour in any glyph is used as attachment point in at least one other glyph
                    if ((flags&(ushort)Table_glyf.MaskFlagComponent.ARGS_ARE_XY_VALUES)!=0)
                    {
                        component.Shift=new VecD(arg1,arg2);
                    }
                    else
                    {
                        component.IndexKnotAttGlyph=arg1;
                        component.IndexKnotAttComponent=arg2;                
                    }

                    // TODO: check that matrix is non-degenerated (if not null)
                    if (weHaveAScale)
                    {

                        OTF2Dot14[,] m=new OTF2Dot14[2,2];

                        m[0,0]=buffer.GetF2Dot14(offsCur);
                        
                        /*
                        // for debug only - begin
                        if (indGlyphCur==272)
                        {
                            m[0,0]=new OTF2Dot14(30390);
                        }
                        // for debug only - end
                        */
                        
                        offsCur+=2;
                        m[1,1]=m[0,0];
                        component.TrOTF2Dot14=m;
                    }
                    else if (weHaveAnXAndYScale)
                    {
                        OTF2Dot14[,] m=new OTF2Dot14[2,2];
                        m[0,0]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        m[1,1]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        component.TrOTF2Dot14=m;
                    }
                    else if (weHaveATwoByTwo)
                    {
                        OTF2Dot14[,] m=new OTF2Dot14[2,2];
                        m[0,0]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        m[0,1]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        m[1,0]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        m[1,1]=buffer.GetF2Dot14(offsCur);
                        offsCur+=2;
                        component.TrOTF2Dot14=m;
                    }
        
                    if ((flags&(ushort)Table_glyf.MaskFlagComponent.WE_HAVE_INSTRUCTIONS)!=0)
                    {
                        ushort numInstr=buffer.GetUshort(offsCur);
                        offsCur+=2;
                        if (offsCur+numInstr>buffer.GetLength())
                        {
                            throw new System.IndexOutOfRangeException();
                        }
                    }
                    if (comp==null)
                        comp=new Composite();
                    comp.AddComponent(component);
                }
            }
            catch (System.IndexOutOfRangeException) 
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                if (comp != null)
                {
                    comp.ClearDestroy();
                    comp=null;
                }
            }
        }
Esempio n. 29
0
        /*
         *        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;
        }
Esempio n. 30
0
 public bool RemoveDeleg(DIAction diaToRemove)
 {
     if (diaToRemove==null)
         return false;
     if (this.dia==null)
         return false;
     this.dia=(MulticastDelegate.Remove(this.dia,diaToRemove)) as DIAction;
     return true;
 }
Esempio n. 31
0
 /*
  *            METHODS: PUBLIC
  *            error-reporting interface for external application         
  */
 public bool GErrActionAdd(DIAction dia, TypeActionOnErr flag)
 {
     return (this.gerrPool.DIAAdd(dia, flag));
 }
Esempio n. 32
0
 public bool GErrActionRemove(DIAction dia, TypeActionOnErr flag)
 {
     return (this.gerrPool.DIARemove(dia, flag));
 }
Esempio n. 33
0
 public void InformAll(DIAction diaToApply)
 {
     // get information about ALL GLYPHS
     foreach (DictionaryEntry entry in this.gerrlists)
     {
         GErrList gerrlist=entry.Value as GErrList;
         gerrlist.ApplyToEach(diaToApply);
     }
 }
Esempio n. 34
0
        public void ReadGGB(int indexGlyph, 
            out BoxD bbox, 
            DIAction dia)
        {
            this.m_validator.DIA=dia;

            bbox=null;
            
            int offsStart, length;
            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph, 
                out offsStart, out length, this.m_validator, this.m_font))
                return;
            if (length==0)
                return;
            short xMin, yMin, xMax, yMax;
            if ((int)Table_glyf.FieldOffsets.nextAfterHeader>=length)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength, 
                    (OTTag)"glyf");
                return;
            }
            
            MBOBuffer buffer=this.m_tableGlyf.Buffer;
            xMin=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.xMin));
            yMin=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.yMin));
            xMax=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.xMax));
            yMax=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.yMax));
            bbox=new BoxD(xMin,yMin,xMax,yMax);
        }
Esempio n. 35
0
        public bool AddDeleg(object obj, string nameDIA)
        {
            DIAction dia = DIActionBuilder.DIA(obj, nameDIA);

            return(this.AddDeleg(dia));
        }
Esempio n. 36
0
        /*
         *        Info Action Functions
         */


        /*
         * // Declare a delegate for a method that receives a ValidationInfo reference and returns void.
         * public delegate void ValInfoDelegate(ValidationInfo vi);
         */

        /// <summary><c>Progress.Worker</c> calls this and
        /// sets the delegate to be <c>Progress.ValidatorCallback</c>
        /// </summary>
        ///
        public void SetValInfoDelegate(DIAction vid)
        {
            base.dia = vid;
        }
Esempio n. 37
0
        public void ReadGGO(int indexGlyph,
                            out Outline outl,
                            DIAction dia)
        {
            this.m_validator.DIA = dia;
            outl = null;

            GConsts.TypeGlyph typeGlyph;
            this.ReadTypeGlyph(indexGlyph, out typeGlyph, dia);
            if (typeGlyph != GConsts.TypeGlyph.Simple)
            {
                return;
            }
            int offsStart, length;

            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                                                       out offsStart, out length, this.m_validator, this.m_font))
            {
                return;
            }
            MBOBuffer buffer = this.m_tableGlyf.Buffer;
            int       iKnot;

            ushort[] arrIndKnotEnd;
            short[]  arrXRel, arrYRel;
            byte[]   arrFlag;
            int      numCont;

            try
            {
                numCont       = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.numCont));
                arrIndKnotEnd = new ushort [numCont];
                for (short iCont = 0; iCont < numCont; iCont++)
                {
                    arrIndKnotEnd[iCont] = buffer.GetUshort((uint)(offsStart + Table_glyf.FieldOffsets.nextAfterHeader + iCont * 2));
                }
                int    numKnot         = arrIndKnotEnd[numCont - 1] + 1;
                uint   offsInstrLength = (uint)(offsStart + Table_glyf.FieldOffsets.nextAfterHeader + 2 * numCont);
                ushort lengthInstr     = buffer.GetUshort(offsInstrLength);
                uint   offsInstr       = offsInstrLength + 2;
                uint   offsFlag        = offsInstr + lengthInstr;
                arrFlag = new byte [numKnot];
                iKnot   = 0;                // index of flag in array flags
                uint offsCur = offsFlag;    // counter of flag in the file
                while (iKnot < numKnot)
                {
                    byte flag = buffer.GetByte(offsCur++);
                    arrFlag[iKnot++] = flag;
                    bool toRepeat = ((flag & (byte)(Table_glyf.MaskFlagKnot.toRepeat)) != 0);
                    if (toRepeat)
                    {
                        byte numRepeat = buffer.GetByte(offsCur++);
                        for (byte iRepeat = 0; iRepeat < numRepeat; iRepeat++)
                        {
                            arrFlag[iKnot++] = flag;
                        }
                    }
                }
                arrXRel = new short [numKnot];
                arrYRel = new short [numKnot];
                // read data for x-coordinates
                for (iKnot = 0; iKnot < numKnot; iKnot++)
                {
                    if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isXByte)) != 0)
                    {
                        byte xRel = buffer.GetByte(offsCur++);
                        if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive)) != 0)
                        {
                            arrXRel[iKnot] = xRel;
                        }
                        else
                        {
                            arrXRel[iKnot] = (short)(-xRel);
                        }
                    }
                    else
                    {
                        if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive)) != 0)
                        {
                            arrXRel[iKnot] = 0;
                        }
                        else
                        {
                            arrXRel[iKnot] = buffer.GetShort(offsCur);
                            offsCur       += 2;
                        }
                    }
                }
                // read data for y-coordinates
                for (iKnot = 0; iKnot < numKnot; iKnot++)
                {
                    if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isYByte)) != 0)
                    {
                        byte yRel = buffer.GetByte(offsCur++);
                        if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive)) != 0)
                        {
                            arrYRel[iKnot] = yRel;
                        }
                        else
                        {
                            arrYRel[iKnot] = (short)(-yRel);
                        }
                    }
                    else
                    {
                        if ((arrFlag[iKnot] & (byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive)) != 0)
                        {
                            arrYRel[iKnot] = 0;
                        }
                        else
                        {
                            arrYRel[iKnot] = buffer.GetShort(offsCur);
                            offsCur       += 2;
                        }
                    }
                }
                if (offsCur - 2 >= offsStart + length)
                {
                    throw new System.IndexOutOfRangeException();
                }
            }
            catch (System.IndexOutOfRangeException)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                return;
            }

            try
            {
                short xAbs = 0;
                short yAbs = 0;
                int   indKnotStart, indKnotEnd = -1;
                outl = new Outline();
                for (ushort iCont = 0; iCont < numCont; iCont++)
                {
                    indKnotStart = indKnotEnd + 1;
                    indKnotEnd   = arrIndKnotEnd[iCont];
                    Contour cont = null;
                    cont = new Contour();
                    for (iKnot = indKnotStart; iKnot <= indKnotEnd; iKnot++)
                    {
                        xAbs += arrXRel[iKnot];
                        yAbs += arrYRel[iKnot];
                        bool isOn = ((arrFlag[iKnot] & ((byte)(Table_glyf.MaskFlagKnot.isOnCurve))) != 0);
                        Knot knot = new Knot(iKnot, xAbs, yAbs, isOn);
                        cont.KnotAdd(knot);
                    }
                    outl.ContourAdd(cont);
                }
            }
            catch
            {
                outl.ClearDestroy();
                outl = null;
            }
        }
Esempio n. 38
0
        //This version of RunValidation is to be used when the file is already opened by other process and you have the handle
        //i.e. , this is used when the validation is called from the ValInterface.dll
        //The file name is needed just for the path of the report file
        public int RunValidation(Validator v, string fpath,SafeFileHandle hFile)
        {
            int ret = 0;
            v.SetOnValidateEvent(new
                    Validator.OnValidateEvent(OnValidateEvent));
            // enable us to receive validation info messages
            DIAction vid = new DIAction(ValidatorCallback);
            v.SetValInfoDelegate(vid);

            try
            {
                // check to see if the user canceled validation
                if (v.CancelFlag)
                {
                    m_callbacks.OnCancel();
                    return ret;
                }

                ret |= ValidateFont(v, fpath, hFile, 0, 1);
                m_callbacks.OnReportsReady();
            }
            catch (Exception e)
            {
                m_callbacks.OnException(e);
                return 1;
            }

            return ret;

        }
Esempio n. 39
0
        public void ReadGGC(int indexGlyph,
                            out Composite comp,
                            DIAction dia)
        {
            this.m_validator.DIA = dia;
            comp = null;

            GConsts.TypeGlyph typeGlyph;
            this.ReadTypeGlyph(indexGlyph, out typeGlyph, dia);
            if (typeGlyph != GConsts.TypeGlyph.Composite)
            {
                return;
            }
            int offsStart, length;

            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                                                       out offsStart, out length, this.m_validator, this.m_font))
            {
                return;
            }

            MBOBuffer buffer  = this.m_tableGlyf.Buffer;
            uint      offsCur = (uint)(offsStart + Table_glyf.FieldOffsets.nextAfterHeader);
            bool      isLast  = false;

            try
            {
                Component component;
                while (!isLast)
                {
                    ushort flags = buffer.GetUshort(offsCur);
                    isLast   = ((flags & (ushort)Table_glyf.MaskFlagComponent.MORE_COMPONENTS) == 0);
                    offsCur += 2;

                    ushort indGlyphCur = buffer.GetUshort(offsCur); // TODO: save
                    component = new Component(indGlyphCur);

                    // TODO: validate indGlyph is in right boundaries
                    // TODO: add Relations to FManager
                    offsCur += 2;

                    bool weHaveAScale       = ((flags & (ushort)Table_glyf.MaskFlagComponent.WE_HAVE_A_SCALE) != 0);
                    bool weHaveAnXAndYScale = ((flags & (ushort)Table_glyf.MaskFlagComponent.WE_HAVE_AN_X_AND_Y_SCALE) != 0);
                    bool weHaveATwoByTwo    = ((flags & (ushort)Table_glyf.MaskFlagComponent.WE_HAVE_A_TWO_BY_TWO) != 0);
                    int  cnt = 0;
                    if (weHaveAScale)
                    {
                        cnt++;
                    }
                    if (weHaveAnXAndYScale)
                    {
                        cnt++;
                    }
                    if (weHaveATwoByTwo)
                    {
                        cnt++;
                    }
                    if (cnt > 1)
                    {
                        this.m_validator.Error(T.T_NULL,
                                               E.glyf_E_CompositeAmbigousTransform,
                                               (OTTag)"glyf",
                                               "Index Component: " + indGlyphCur);
                        return;
                    }
                    if ((flags & (ushort)Table_glyf.MaskFlagComponent.RESERVED) != 0)
                    {
                        this.m_validator.Warning(T.T_NULL,
                                                 W.glyf_W_CompositeReservedBit,
                                                 (OTTag)"glyf",
                                                 "Index Component: " + indGlyphCur);
                    }

                    int arg1, arg2;
                    if ((flags & (ushort)Table_glyf.MaskFlagComponent.ARG_1_AND_2_ARE_WORDS) != 0)
                    {
                        arg1     = (int)buffer.GetShort(offsCur);
                        offsCur += 2;
                        arg2     = (int)buffer.GetShort(offsCur);
                        offsCur += 2;
                    }
                    else
                    {
                        arg1     = (int)buffer.GetSbyte(offsCur);
                        offsCur += 1;

                        arg2     = (int)buffer.GetSbyte(offsCur);
                        offsCur += 1;
                    }
                    // TODO: validate bounding boxes
                    // TODO: check that NOT BOTH shift & knots are initialized, but ONE of them IS initialized
                    // TODO: validate that indKnots (both!) are in the right boundaries
                    // TODO: validate that a single-point contour in any glyph is used as attachment point in at least one other glyph
                    if ((flags & (ushort)Table_glyf.MaskFlagComponent.ARGS_ARE_XY_VALUES) != 0)
                    {
                        component.Shift = new VecD(arg1, arg2);
                    }
                    else
                    {
                        component.IndexKnotAttGlyph     = arg1;
                        component.IndexKnotAttComponent = arg2;
                    }

                    // TODO: check that matrix is non-degenerated (if not null)
                    if (weHaveAScale)
                    {
                        OTF2Dot14[,] m = new OTF2Dot14[2, 2];

                        m[0, 0] = buffer.GetF2Dot14(offsCur);

                        /*
                         * // for debug only - begin
                         * if (indGlyphCur==272)
                         * {
                         *  m[0,0]=new OTF2Dot14(30390);
                         * }
                         * // for debug only - end
                         */

                        offsCur += 2;
                        m[1, 1]  = m[0, 0];
                        component.TrOTF2Dot14 = m;
                    }
                    else if (weHaveAnXAndYScale)
                    {
                        OTF2Dot14[,] m        = new OTF2Dot14[2, 2];
                        m[0, 0]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        m[1, 1]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        component.TrOTF2Dot14 = m;
                    }
                    else if (weHaveATwoByTwo)
                    {
                        OTF2Dot14[,] m        = new OTF2Dot14[2, 2];
                        m[0, 0]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        m[0, 1]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        m[1, 0]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        m[1, 1]               = buffer.GetF2Dot14(offsCur);
                        offsCur              += 2;
                        component.TrOTF2Dot14 = m;
                    }

                    if ((flags & (ushort)Table_glyf.MaskFlagComponent.WE_HAVE_INSTRUCTIONS) != 0)
                    {
                        ushort numInstr = buffer.GetUshort(offsCur);
                        offsCur += 2;
                        if (offsCur + numInstr > buffer.GetLength())
                        {
                            throw new System.IndexOutOfRangeException();
                        }
                    }
                    if (comp == null)
                    {
                        comp = new Composite();
                    }
                    comp.AddComponent(component);
                }
            }
            catch (System.IndexOutOfRangeException)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                if (comp != null)
                {
                    comp.ClearDestroy();
                    comp = null;
                }
            }
        }
Esempio n. 40
0
        /*
         *        Info Action Functions
         */

    
        /*
        // Declare a delegate for a method that receives a ValidationInfo reference and returns void.
        public delegate void ValInfoDelegate(ValidationInfo vi);
        */
        
        /// <summary><c>Progress.Worker</c> calls this and 
        /// sets the delegate to be <c>Progress.ValidatorCallback</c>
        /// </summary>
        /// 
        public void SetValInfoDelegate(DIAction vid)
        {
            base.dia = vid;
        }
Esempio n. 41
0
        /*
         *        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);
        }
Esempio n. 42
0
 public bool ReadNumGlyph(out int numGlyph, DIAction dia)
 {
     numGlyph = this.m_numGlyph;
     return(true);
 }
Esempio n. 43
0
        public void ReadGGO(int indexGlyph, 
            out Outline outl, 
            DIAction dia)
        {
            this.m_validator.DIA=dia;
            outl=null;
            
            GConsts.TypeGlyph typeGlyph;
            this.ReadTypeGlyph(indexGlyph, out typeGlyph, dia);
            if (typeGlyph!=GConsts.TypeGlyph.Simple)
                return;
            int offsStart, length;
            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph,
                out offsStart, out length, this.m_validator, this.m_font))
                return;
            MBOBuffer buffer=this.m_tableGlyf.Buffer;
            int iKnot;
            ushort[] arrIndKnotEnd;
            short[] arrXRel, arrYRel;
            byte[] arrFlag;
            int numCont;
            try 
            {
                numCont=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.numCont));
                arrIndKnotEnd = new ushort [numCont];
                for (short iCont=0; iCont<numCont; iCont++)
                {
                    arrIndKnotEnd[iCont]=buffer.GetUshort((uint)(offsStart+Table_glyf.FieldOffsets.nextAfterHeader+iCont*2));
                }
                int numKnot=arrIndKnotEnd[numCont-1]+1;
                uint offsInstrLength=(uint)(offsStart+Table_glyf.FieldOffsets.nextAfterHeader+2*numCont);
                ushort lengthInstr=buffer.GetUshort(offsInstrLength);
                uint offsInstr=offsInstrLength+2;
                uint offsFlag=offsInstr+lengthInstr;
                arrFlag = new byte [numKnot];
                iKnot=0;                    // index of flag in array flags
                uint offsCur=offsFlag;        // counter of flag in the file
                while (iKnot<numKnot)
                {
                    byte flag=buffer.GetByte(offsCur++);
                    arrFlag[iKnot++]=flag;
                    bool toRepeat=((flag&(byte)(Table_glyf.MaskFlagKnot.toRepeat))!=0);
                    if (toRepeat)
                    {
                        byte numRepeat=buffer.GetByte(offsCur++);
                        for (byte iRepeat=0; iRepeat<numRepeat; iRepeat++)
                        {
                            arrFlag[iKnot++]=flag;
                        }
                    }
                }
                arrXRel = new short [numKnot];
                arrYRel = new short [numKnot];
                // read data for x-coordinates
                for (iKnot=0; iKnot<numKnot; iKnot++)
                {
                    if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXByte))!=0)
                    {
                        byte xRel=buffer.GetByte(offsCur++);
                        if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive))!=0)
                        {
                            arrXRel[iKnot]=xRel;
                        }
                        else
                        {
                            arrXRel[iKnot]=(short)(-xRel);
                        }
                    }
                    else
                    {
                        if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive))!=0)
                        {
                            arrXRel[iKnot]=0;
                        }
                        else
                        {
                            arrXRel[iKnot]=buffer.GetShort(offsCur);
                            offsCur+=2;
                        }
                    }
                }
                // read data for y-coordinates
                for (iKnot=0; iKnot<numKnot; iKnot++)
                {
                    if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYByte))!=0)
                    {
                        byte yRel=buffer.GetByte(offsCur++);
                        if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive))!=0)
                        {
                            arrYRel[iKnot]=yRel;
                        }
                        else
                        {
                            arrYRel[iKnot]=(short)(-yRel);
                        }
                    }
                    else
                    {
                        if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive))!=0)
                        {
                            arrYRel[iKnot]=0;
                        }
                        else
                        {
                            arrYRel[iKnot]=buffer.GetShort(offsCur);
                            offsCur+=2;
                        }
                    }
                }
                if (offsCur-2>=offsStart+length)
                {
                    throw new System.IndexOutOfRangeException();
                }
            }
            catch (System.IndexOutOfRangeException) 
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength,
                    (OTTag)"glyf");
                return;
            }

            try
            {
                short xAbs=0;
                short yAbs=0;
                int indKnotStart, indKnotEnd=-1;
                outl=new Outline();
                for (ushort iCont=0; iCont<numCont; iCont++)
                {
                    indKnotStart=indKnotEnd+1;
                    indKnotEnd=arrIndKnotEnd[iCont];
                    Contour cont=null;
                    cont = new Contour();
                    for (iKnot=indKnotStart; iKnot<=indKnotEnd; iKnot++)
                    {
                        xAbs += arrXRel[iKnot];
                        yAbs += arrYRel[iKnot];
                        bool isOn=((arrFlag[iKnot]&((byte)(Table_glyf.MaskFlagKnot.isOnCurve)))!=0);
                        Knot knot = new Knot(iKnot, xAbs, yAbs, isOn);
                        cont.KnotAdd(knot);
                    }
                    outl.ContourAdd(cont);
                }
            }
            catch
            {
                outl.ClearDestroy();
                outl=null;
            }
        }
Esempio n. 44
0
        public bool Validate(Validator validator, OTFontVal fontOwner)
        {
            bool bRet = true;

            if (!validator.PerformTest(T.glyf_ValidateAll))
            {
                return(true);
            }

            this.m_diaValidate = validator.DIA;
            this.m_cnts        = new int[this.m_namesInfoCnt.Length];
            for (int iCnt = 0; iCnt < this.m_cnts.Length; iCnt++)
            {
                this.m_cnts[iCnt] = 0;
            }

            I_IOGlyphsFile i_IOGlyphs = new I_IOGlyphsFile();

            if (!i_IOGlyphs.Initialize(fontOwner, validator))
            {
                return(false); // the error is already reported
            }

            DIAction diaFilter =
                DIActionBuilder.DIA(this, "DIAFunc_Filter");
            FManager fm       = new FManager(i_IOGlyphs, null, null);
            int      numGlyph = fm.FNumGlyph;
            int      indGlyph;

            for (indGlyph = 0; indGlyph < numGlyph; indGlyph++)
            {
                try
                {
                    validator.OnTableProgress("Validating glyph with index " + indGlyph + " (out of " + numGlyph + " glyphs)");
                    Glyph glyph = fm.GGet(indGlyph);
                    glyph.GValidate();
                    bRet &= fm.GErrGetInformed(indGlyph, diaFilter);
                    fm.ClearManagementStructs();
                }
                catch
                {
                    validator.Error(T.T_NULL, E.glyf_E_ExceptionUnhandeled, (OTTag)"glyf",
                                    "Glyph index " + indGlyph);
                }
                if (validator.CancelFlag)
                {
                    break;
                }
            }
            i_IOGlyphs.Clear();
            fm.ClearDestroy();
            fm = null;

/*
 *          I_ProgressUpdater i_ProgressUpdater=new ValidationCancel(validator);
 *
 *          FManager fm=new FManager(i_IOGlyphs, null, null);
 *          DIAction diaFilter=
 *              DIActionBuilder.DIA(this,"DIAFunc_Filter");
 *
 *          fm.GErrActionAdd(diaFilter,
 *              FManager.TypeActionOnErr.onAdd);
 *
 *
 *          fm.FValidate(GConsts.IND_UNINITIALIZED,
 *              GConsts.IND_UNINITIALIZED);
 *
 *          i_IOGlyphs.Clear();
 *          i_ProgressUpdater.Clear();
 *          fm.ClearDestroy();
 *          fm=null;
 */
            for (int iCnt = 0; iCnt < this.m_cnts.Length; iCnt++)
            {
                if (this.m_cnts[iCnt] > 0)
                {
                    bool   isGErr         = this.m_namesInfoCnt[iCnt].StartsWith("GERR_");
                    string nameFileErr    = isGErr? GErrConsts.FILE_RES_GERR_STRINGS: GErrConsts.FILE_RES_OTFFERR_STRINGS;
                    string nameAsmFileErr = isGErr? GErrConsts.ASM_RES_GERR_STRINGS: GErrConsts.ASM_RES_OTFFERR_STRINGS;
                    string strDetails     = "Number of glyphs with the warning = " + this.m_cnts[iCnt];
                    if (validator.CancelFlag)
                    {
                        strDetails += " (Validation cancelled)";
                    }
                    ValInfoBasic info = new ValInfoBasic(
                        ValInfoBasic.ValInfoType.Warning,
                        this.m_namesInfoCnt[iCnt],
                        strDetails,
                        nameFileErr,
                        nameAsmFileErr,
                        "glyf",
                        null);
                    validator.DIA(info);
                }
            }

            this.m_cnts = null;
            return(bRet);
        }
Esempio n. 45
0
 public bool ReadNumGlyph(out int numGlyph, DIAction dia)
 {
     numGlyph=this.m_numGlyph;
     return true;
 }
Esempio n. 46
0
 public bool GErrActionRemove(DIAction dia, TypeActionOnErr flag)
 {
     return(this.gerrPool.DIARemove(dia, flag));
 }
Esempio n. 47
0
 public void InitValidation(DIAction vid)
 {
     m_Validator.SetValInfoDelegate(vid);
 }
 public DIActionOnCondBuilder(DICond dic, DIAction dia)
 {
     this.dic=dic;
     this.dia=dia;
 }
Esempio n. 49
0
 public bool Inform(int indGlyph, DIAction diaToApply)
 {
     bool bRet = true;
     if (indGlyph == GConsts.IND_ALL)
     {
         this.InformAll(diaToApply);
         bRet = true;
     }
     else
     {
         GErrList gerrlist = this.gerrlists[indGlyph] as GErrList;
         if (gerrlist != null)
         {
             //If some error is of type Error or AppError, then return false
             bRet &= gerrlist.TestErrors();
             gerrlist.ApplyToEach(diaToApply);
         }
     }
     return bRet;
 }