Пример #1
0
        public bool Validate_Format2(Validator v, string sIdentity, Table_EBLC.indexSubTable ist)
        {
            bool bOk = true;

            Table_EBLC.indexSubTableArray ista = ist.GetIndexSubTableArray();

            for (ushort idGlyph = ista.firstGlyphIndex; idGlyph <= ista.lastGlyphIndex; idGlyph++)
            {
                // validate small metrics
                smallGlyphMetrics sgm = null;
                try {
                    sgm = GetSmallMetrics(ist, idGlyph, ista.firstGlyphIndex);
                }
                catch (Exception e)
                {
                    v.ApplicationError(T.EBDT_GlyphImageData, E._Table_E_Exception, m_tag, "EBDT.Format2: " + e.Message);
                    bOk = false;
                    return(bOk);
                }
                if (sgm != null)
                {
                    smallGlyphMetrics_val sgm_val = smallGlyphMetrics_val.CreateFromSmallGlyphMetrics(sgm);
                    if (!sgm_val.Validate(v, sIdentity + ", idGlyph=" + idGlyph, this))
                    {
                        bOk = false;
                    }

                    // validate image data
                    // - this is just bitmap data, any values should be valid
                }
            }

            return(bOk);
        }
Пример #2
0
        public bool Validate_Format1(Validator v, string sIdentity, Table_EBLC.indexSubTable ist)
        {
            bool bOk = true;

            Table_EBLC.indexSubTableArray ista = ist.GetIndexSubTableArray();

            for (ushort idGlyph = ista.firstGlyphIndex; idGlyph <= ista.lastGlyphIndex; idGlyph++)
            {
                // validate small metrics
                smallGlyphMetrics sgm = GetSmallMetrics(ist, idGlyph, ista.firstGlyphIndex);
                if (sgm != null)
                {
                    smallGlyphMetrics_val sgm_val = smallGlyphMetrics_val.CreateFromSmallGlyphMetrics(sgm);
                    if (!sgm_val.Validate(v, sIdentity + ", idGlyph=" + idGlyph, this))
                    {
                        bOk = false;
                    }

                    // validate image data
                    // - this is just bitmap data, any values should be valid
                }
            }

            return(bOk);
        }
Пример #3
0
            public static smallGlyphMetrics_val CreateFromSmallGlyphMetrics(smallGlyphMetrics sgm)
            {
                smallGlyphMetrics_val sgm_val = new smallGlyphMetrics_val();

                sgm_val.height   = sgm.height;
                sgm_val.width    = sgm.width;
                sgm_val.BearingX = sgm.BearingX;
                sgm_val.BearingY = sgm.BearingY;
                sgm_val.Advance  = sgm.Advance;

                return sgm_val;
            }
Пример #4
0
            public static smallGlyphMetrics_val CreateFromSmallGlyphMetrics(smallGlyphMetrics sgm)
            {
                smallGlyphMetrics_val sgm_val = new smallGlyphMetrics_val();

                sgm_val.height   = sgm.height;
                sgm_val.width    = sgm.width;
                sgm_val.BearingX = sgm.BearingX;
                sgm_val.BearingY = sgm.BearingY;
                sgm_val.Advance  = sgm.Advance;

                return(sgm_val);
            }
Пример #5
0
        public bool Validate_Format8(Validator v, string sIdentity, Table_EBLC.indexSubTable ist)
        {
            bool bOk = true;

            Table_EBLC.indexSubTableArray ista = ist.GetIndexSubTableArray();

            for (ushort idGlyph = ista.firstGlyphIndex; idGlyph <= ista.lastGlyphIndex; idGlyph++)
            {
                // validate small metrics
                smallGlyphMetrics sgm = GetSmallMetrics(ist, idGlyph, ista.firstGlyphIndex);
                if (sgm != null)
                {
                    smallGlyphMetrics_val sgm_val = smallGlyphMetrics_val.CreateFromSmallGlyphMetrics(sgm);
                    if (!sgm_val.Validate(v, sIdentity + ", idGlyph=" + idGlyph, this))
                    {
                        bOk = false;
                    }

                    ushort numComponents = this.GetNumComponents(ist, idGlyph, ista.firstGlyphIndex);

                    // validate component array
                    for (uint i = 0; i < numComponents; i++)
                    {
                        ebdtComponent component = GetComponent(ist, idGlyph, ista.firstGlyphIndex, i);
                        Debug.Assert(component != null);


                        // validate the ebdtComponent

                        // verify that the component's glyph code is less than maxp numGlyphs
                        if (component.glyphCode >= m_nCachedMaxpNumGlyphs)
                        {
                            string sDetails = sIdentity + ", idGlyph=" + idGlyph +
                                              ", component[" + i + "].glyphCode=" + component.glyphCode +
                                              ", maxp.numGlyphs = " + m_nCachedMaxpNumGlyphs;
                            v.Error(T.EBDT_GlyphImageData, E.EBDT_E_GlyphImageData, m_tag, sDetails);
                            bOk = false;
                        }

                        // verify that the component's glyph code isn't 0, which should be reserved as the empty glyph
                        // (technically, someone could use the empty glyph as a component, but it's more likely to be an error)
                        if (component.glyphCode == 0)
                        {
                            string sDetails = sIdentity + ", idGlyph=" + idGlyph +
                                              ", component[" + i + "].glyphCode=" + component.glyphCode;
                            v.Error(T.EBDT_GlyphImageData, E.EBDT_E_GlyphImageData, m_tag, sDetails);
                            bOk = false;
                        }

                        // verify that the component's glyph code isn't the glyph code of its parent
                        if (component.glyphCode == idGlyph)
                        {
                            string sDetails = sIdentity + ", idGlyph=" + idGlyph +
                                              ", component[" + i + "].glyphCode=" + component.glyphCode + " (glyph can't use itself as a component)";
                            v.Error(T.EBDT_GlyphImageData, E.EBDT_E_GlyphImageData, m_tag, sDetails);
                            bOk = false;
                        }
                    }
                }
            }

            return(bOk);
        }