Esempio n. 1
0
        private bool CheckNames(Validator v,
                                OTFontVal fontOwner,
                                PostNames pn,
                                uint iGlyph,
                                uint index)
        {
            bool   bNamesOk = true;
            string sName    = GetNameString(index - 258);

            System.Globalization.NumberStyles hexStyle =
                System.Globalization.NumberStyles.HexNumber;
            if (Is_uniXXXX(sName))
            {
                char c = (char)Int16.Parse(sName.Substring(3, 4), hexStyle);
                if (fontOwner.FastMapUnicodeToGlyphID(c) != iGlyph)
                {
                    char   cMapped = fontOwner.MapGlyphIDToUnicode(iGlyph, (char)0);
                    string s       = "glyph = " + iGlyph +
                                     ", char = U+" +
                                     ((uint)cMapped).ToString("X4")
                                     + ", name = " + sName;
                    v.Info(T.post_v2_names,
                           I.post_I_names_uni_unexpected,
                           m_tag, s);
                    bNamesOk = false;
                }
            }
            else if (Is_uXXXXX(sName))
            {
                uint c = (uint)Int32.Parse(sName.Substring(1), hexStyle);
                if (c < 0xffff)
                {
                    if (fontOwner.FastMapUnicodeToGlyphID((char)c) != iGlyph)
                    {
                        char cMapped = fontOwner.MapGlyphIDToUnicode(iGlyph,
                                                                     (char)0);
                        string s = "glyph = " + iGlyph + ", char = U+" +
                                   ((uint)cMapped).ToString("X4") + ", name = " + sName;
                        v.Info(T.post_v2_names, I.post_I_names_uni_unexpected,
                               m_tag, s);
                        bNamesOk = false;
                    }
                }
                else
                {
                    if (fontOwner.FastMapUnicode32ToGlyphID(c) != iGlyph)
                    {
                        uint cMapped =
                            fontOwner.MapGlyphIDToUnicode32(iGlyph, 0);
                        string s = "glyph = " + iGlyph + ", char = U+" +
                                   ((uint)cMapped).ToString("X5") + ", name = " + sName;
                        v.Info(T.post_v2_names, I.post_I_names_uni_unexpected,
                               m_tag, s);
                        bNamesOk = false;
                    }
                }
            }
            else
            {
                // check the Adobe Glyph Names

                char c = (char)fontOwner.MapGlyphIDToUnicode(iGlyph, (char)0);
                if (c != 0xffff)
                {
                    string sAdobeName = pn.GetAdobeGlyphName(c);
                    if (sAdobeName == null)
                    {
                        string s = "glyph = " + iGlyph + ", char = U+" +
                                   ((uint)c).ToString("X4") + ", name = " + sName;
                        v.Info(T.post_v2_names, I.post_I_names_noAdobe, m_tag, s);
                        bNamesOk = false;
                    }
                    else if (sName != sAdobeName)
                    {
                        string s = "glyph = " + iGlyph + ", char = U+" +
                                   ((uint)c).ToString("X4") + ", name = " + sName;
                        v.Info(T.post_v2_names, I.post_I_names_nomatch, m_tag, s);
                        bNamesOk = false;
                    }
                }
            }
            return(bNamesOk);
        }
Esempio n. 2
0
 private bool CheckNames( Validator v,
                          OTFontVal fontOwner,
                          PostNames pn,
                          uint iGlyph,
                          uint index )
 {
     bool bNamesOk = true;
     string sName = GetNameString(index-258);
     System.Globalization.NumberStyles hexStyle = 
         System.Globalization.NumberStyles.HexNumber;
     if (Is_uniXXXX(sName))
     {
         char c = (char)Int16.Parse(sName.Substring(3, 4), hexStyle );
         if (fontOwner.FastMapUnicodeToGlyphID(c) != iGlyph)
         {
             char cMapped = fontOwner.MapGlyphIDToUnicode(iGlyph,(char)0);
             string s = "glyph = " + iGlyph +
                 ", char = U+" + 
                 ((uint)cMapped).ToString("X4")
                 + ", name = " + sName;
             v.Info(T.post_v2_names, 
                    I.post_I_names_uni_unexpected, 
                    m_tag, s);
             bNamesOk = false;
         }
     }
     else if (Is_uXXXXX(sName))
     {
         uint c = (uint)Int32.Parse(sName.Substring(1), hexStyle );
         if (c < 0xffff)
         {
             if (fontOwner.FastMapUnicodeToGlyphID((char)c) != iGlyph)
             {
                 char cMapped = fontOwner.MapGlyphIDToUnicode(iGlyph, 
                                                              (char)0);
                 string s = "glyph = " + iGlyph + ", char = U+" +
                     ((uint)cMapped).ToString("X4") + ", name = " + sName;
                 v.Info(T.post_v2_names, I.post_I_names_uni_unexpected, 
                        m_tag, s);
                 bNamesOk = false;
             }
         }
         else
         {
             if (fontOwner.FastMapUnicode32ToGlyphID(c) != iGlyph)
             {
                 uint cMapped = 
                     fontOwner.MapGlyphIDToUnicode32(iGlyph, 0);
                 string s = "glyph = " + iGlyph + ", char = U+" + 
                     ((uint)cMapped).ToString("X5") + ", name = " + sName;
                 v.Info(T.post_v2_names, I.post_I_names_uni_unexpected, 
                        m_tag, s);
                 bNamesOk = false;
             }
         }
     }
     else
     {
         // check the Adobe Glyph Names
         
         char c = (char)fontOwner.MapGlyphIDToUnicode(iGlyph, (char)0);
         if (c != 0xffff)
         {
             string sAdobeName = pn.GetAdobeGlyphName(c);
             if (sAdobeName == null)
             {
                 string s = "glyph = " + iGlyph + ", char = U+" + 
                     ((uint)c).ToString("X4") + ", name = " + sName;
                 v.Info(T.post_v2_names, I.post_I_names_noAdobe, m_tag,s);
                 bNamesOk = false;
             }
             else if (sName != sAdobeName)
             {
                 string s = "glyph = " + iGlyph + ", char = U+" + 
                     ((uint)c).ToString("X4") + ", name = " + sName;
                 v.Info(T.post_v2_names, I.post_I_names_nomatch, m_tag,s);
                 bNamesOk = false;
             }
         }
     }
     return bNamesOk;
 }