Example #1
0
        public void AddName(NameRecord name)
        {
            _definedNames.Add(name);

            // TODO - this Is messy
            // Not the most efficient way but the other way was causing too many bugs
            int idx = FindFirstRecordLocBySid(ExternSheetRecord.sid);

            if (idx == -1)
            {
                idx = FindFirstRecordLocBySid(SupBookRecord.sid);
            }
            if (idx == -1)
            {
                idx = FindFirstRecordLocBySid(CountryRecord.sid);
            }
            int countNames = _definedNames.Count;

            _workbookRecordList.Add(idx + countNames, name);
        }
Example #2
0
        NameRecord ConvertName(NameRecord old, Dictionary <char, ushort> reverse)
        {
            var name = new NameRecord();

            if (!string.IsNullOrEmpty(old.name))
            {
                var namebuffer = new StringBuilder();
                var codebuffer = new List <ushort>();
                foreach (char c in old.name)
                {
                    if (reverse.ContainsKey(c))
                    {
                        var code = reverse[c];
                        if (code <= 0)
                        {
                            System.Diagnostics.Debug.WriteLine(string.Format("[Error] Invalid code {0} for {1}", code, c));
                            continue;
                        }

                        codebuffer.Add(code);
                        namebuffer.Append(c);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("[Error] Cannot find code for {0}", c));
                        codebuffer.Add(0x3F);
                        namebuffer.Append('?');
                    }
                }

                if (codebuffer.Count > 0)
                {
                    codebuffer.Add(0);
                    name.name  = namebuffer.ToString();
                    name.codes = codebuffer.ToArray();
                }
            }


            return(name);
        }
Example #3
0
 private static bool EnglishLanguage(NameRecord name)
 {
     return(name.LanguageId == 0 // Macintosh
            // Windows country-specific English variants:
            || name.LanguageId == 0x0C09 ||
            name.LanguageId == 0x2809 ||
            name.LanguageId == 0x1009 ||
            name.LanguageId == 0x2409 ||
            name.LanguageId == 0x4009 ||
            name.LanguageId == 0x1809 ||
            name.LanguageId == 0x2009 ||
            name.LanguageId == 0x4409 ||
            name.LanguageId == 0x1409 ||
            name.LanguageId == 0x3409 ||
            name.LanguageId == 0x4809 ||
            name.LanguageId == 0x1C09 ||
            name.LanguageId == 0x2C09 ||
            name.LanguageId == 0x0809 ||
            name.LanguageId == 0x0409 ||
            name.LanguageId == 0x3009);
 }
Example #4
0
        private List <NameRecord> GetFontNames(IntPtr hFont)
        {
            var    fontNames = new List <NameRecord>();
            IntPtr dc        = GetDC(IntPtr.Zero);

            SelectObject(dc, hFont);

            using (BinaryReader br = new BinaryReader(new MemoryStream(LoadFontMetricsNameTable(dc))))
            {
                // Read selector (always = 0) to advance reader position by 2 bytes

                ushort selector = ToLittleEndian(br.ReadUInt16());

                // Get number of records and offset byte value, from where font descriptions start

                ushort records = ToLittleEndian(br.ReadUInt16());
                ushort offset  = ToLittleEndian(br.ReadUInt16());

                // Get the correct name record
                for (ushort i = 0; i < records; i++)
                {
                    NameRecord nameRecord = new NameRecord(br);
                    if (nameRecord.IsWindowsUnicodeFullFontName)
                    {
                        fontNames.Add(nameRecord);
                    }
                }
                foreach (var record in fontNames)
                {
                    record.ReadName(br, offset);
                }


                br.Close();
            }

            ReleaseDC(IntPtr.Zero, dc);

            return(fontNames);
        }
Example #5
0
        private async Task RecordUserNameChange(SocketUser Before, SocketUser After)
        {
            if (Before.Username != After.Username && !string.IsNullOrEmpty(After.Username))
            {
                NameRecord Record = ProfilesDB.Names.AsQueryable().Where(n => n.Name == After.Username && n.UserID == After.Id && n.Type == NameType.Username).FirstOrDefault();

                if (Record != null)
                {
                    Record.SetTime = DateTimeOffset.Now.ToUnixTimeSeconds();
                }
                else
                {
                    ProfilesDB.Names.Add(new() {
                        UserID  = After.Id,
                        Name    = After.Username,
                        SetTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
                        Type    = NameType.Username
                    });
                }
                await ProfilesDB.SaveChangesAsync();
            }
        }
        public NameRecord GetNameRecord(uint i)
        {
            NameRecord nr = null;

            if (i < NumberNameRecords)
            {
                uint offset = (uint)FieldOffsets.NameRecords + i*12;
                if (offset + 12 < m_bufTable.GetLength())
                {
                    nr = new NameRecord((ushort)offset, m_bufTable);
                }
            }

            return nr;
        }
Example #7
0
        public void Test50244()
        {
            string record_0x0018 =
                "                                          18 00 " +
                "21 1E 00 00 00 11 08 00 00 00 03 00 00 00 00 00 " +
                "00 77 44 61 74 61 47 72 75 70 70 65 53 65 72 69 " +
                "65 2E 60 00 B7 02 0C 00 57 03 00 B7 02 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 30 31 02 09 00 00 31 2E " +
                "54 32 30 2E 30 30 31 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 30 31 02 09 00 00 31 2E 54 32 30 2E 30 30 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 30 30 32 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 30 32 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 30 33 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 30 33 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "30 33 02 09 00 00 31 2E 54 32 30 2E 30 31 33 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 31 33 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 31 33 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 31 34 02 09 00 00 31 2E 54 32 30 2E " +
                "30 31 34 02 09 00 00 31 2E 54 32 30 2E 30 31 34 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 31 35 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 31 35 02 09 00 00 31 2E " +
                "54 32 30 2E 30 31 35 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 32 35 02 09 00 00 31 2E 54 32 30 2E 30 32 " +
                "35 02 09 00 00 31 2E 54 32 30 2E 30 32 35 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 32 36 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 32 36 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 32 36 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "32 37 02 09 00 00 31 2E 54 32 30 2E 30 32 37 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 32 37 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 33 37 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 33 37 02 09 00 00 31 2E 54 32 30 2E " +
                "30 33 37 02 09 00 00 31 2E 54 32 30 2E 30 33 38 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 33 38 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 33 38 02 09 00 00 31 2E " +
                "54 32 30 2E 30 33 39 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 33 39 02 09 00 00 31 2E 54 32 30 2E 30 33 " +
                "39 02 09 00 00 31 2E 54 32 30 2E 30 34 39 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 34 39 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 34 39 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 35 30 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "35 30 02 09 00 00 31 2E 54 32 30 2E 30 35 30 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 35 31 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 35 31 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 35 31 02 09 00 00 31 2E 54 32 30 2E " +
                "30 36 31 02 09 00 00 31 2E 54 32 30 2E 30 36 31 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 36 31 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 36 32 02 09 00 00 31 2E " +
                "54 32 30 2E 30 36 32 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 36 32 02 09 00 00 31 2E 54 32 30 2E 30 36 " +
                "33 02 09 00 00 31 2E 54 32 30 2E 30 36 33 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 36 33 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 37 33 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 37 33 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "37 33 02 09 00 00 31 2E 54 32 30 2E 30 37 34 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 37 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 37 34 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 37 35 02 09 00 00 31 2E 54 32 30 2E " +
                "30 37 35 02 09 00 00 31 2E 54 32 30 2E 30 37 35 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 38 35 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 38 35 02 09 00 00 31 2E " +
                "54 32 30 2E 30 38 35 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 38 36 02 09 00 00 31 2E 54 32 30 2E 30 38 " +
                "36 02 09 00 00 31 2E 54 32 30 2E 30 38 36 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 38 37 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 38 37 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 38 37 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "39 37 02 09 00 00 31 2E 54 32 30 2E 30 39 37 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 39 37 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 39 38 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 39 38 02 09 00 00 31 2E 54 32 30 2E " +
                "30 39 38 02 09 00 00 31 2E 54 32 30 2E 30 39 39 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 39 39 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 39 39 02 09 00 00 31 2E " +
                "54 32 30 2E 31 30 39 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 30 39 02 09 00 00 31 2E 54 32 30 2E 31 30 " +
                "39 02 09 00 00 31 2E 54 32 30 2E 31 31 30 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 31 30 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 31 30 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 31 31 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "31 31 02 09 00 00 31 2E 54 32 30 2E 31 31 31 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 32 31 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 32 31 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 32 31 02 09 00 00 31 2E 54 32 30 2E " +
                "31 32 32 02 09 00 00 31 2E 54 32 30 2E 31 32 32 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 32 32 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 32 33 02 09 00 00 31 2E " +
                "54 32 30 2E 31 32 33 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 32 33 02 09 00 00 31 2E 54 32 30 2E 31 33 " +
                "33 02 09 00 00 31 2E 54 32 30 2E 31 33 33 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 33 33 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 33 34 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 33 34 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "33 34 02 09 00 00 31 2E 54 32 30 2E 31 33 35 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 33 35 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 33 35 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 34 35 02 09 00 00 31 2E 54 32 30 2E " +
                "31 34 35 02 09 00 00 31 2E 54 32 30 2E 31 34 35 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 34 36 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 34 36 02 09 00 00 31 2E " +
                "54 32 30 2E 31 34 36 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 34 37 02 09 00 00 31 2E 54 32 30 2E 31 34 " +
                "37 02 09 00 00 31 2E 54 32 30 2E 31 34 37 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 35 37 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 35 37 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 35 37 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "35 38 02 09 00 00 31 2E 54 32 30 2E 31 35 38 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 35 38 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 35 39 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 35 39 02 09 00 00 31 2E 54 32 30 2E " +
                "31 35 39 02 09 00 00 31 2E 54 32 30 2E 31 36 39 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 36 39 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 36 39 02 09 00 00 31 2E " +
                "54 32 30 2E 31 37 30 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 37 30 02 09 00 00 31 2E 54 32 30 2E 31 37 " +
                "30 02 09 00 00 31 2E 54 32 30 2E 31 37 31 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 37 31 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 37 31 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 30 39 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "30 39 02 09 00 00 31 2E 54 36 30 2E 30 30 39 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 31 30 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 31 30 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 31 30 02 09 00 00 31 2E 54 36 30 2E " +
                "30 31 31 02 09 00 00 31 2E 54 36 30 2E 30 31 31 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 31 31 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 32 31 02 09 00 00 31 2E " +
                "54 36 30 2E 30 32 31 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 32 31 02 09 00 00 31 2E 54 36 30 2E 30 32 " +
                "32 02 09 00 00 31 2E 54 36 30 2E 30 32 32 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 32 32 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 32 33 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 32 33 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "32 33 02 09 00 00 31 2E 54 36 30 2E 30 33 33 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 33 33 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 33 33 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 33 34 02 09 00 00 31 2E 54 36 30 2E " +
                "30 33 34 02 09 00 00 31 2E 54 36 30 2E 30 33 34 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 33 35 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 33 35 02 09 00 00 31 2E " +
                "54 36 30 2E 30 33 35 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 34 35 02 09 00 00 31 2E 54 36 30 2E 30 34 " +
                "35 02 09 00 00 31 2E 54 36 30 2E 30 34 35 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 34 36 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 34 36 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 34 36 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "34 37 02 09 00 00 31 2E 54 36 30 2E 30 34 37 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 34 37 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 35 37 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 35 37 02 09 00 00 31 2E 54 36 30 2E " +
                "30 35 37 02 09 00 00 31 2E 54 36 30 2E 30 35 38 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 35 38 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 35 38 02 09 00 00 31 2E " +
                "54 36 30 2E 30 35 39 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 35 39 02 09 00 00 31 2E 54 36 30 2E 30 35 " +
                "39 02 09 00 00 31 2E 54 36 30 2E 30 36 30 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 36 30 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 36 30 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 35 30 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "35 30 02 09 00 00 31 2E 54 36 30 2E 30 35 30 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 34 39 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 34 39 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 34 39 02 09 00 00 31 2E 54 36 30 2E " +
                "30 34 38 02 09 00 00 31 2E 54 36 30 2E 30 34 38 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 34 38 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 33 38 02 09 00 00 31 2E " +
                "54 36 30 2E 30 33 38 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 33 38 02 09 00 00 31 2E 54 36 30 2E 30 33 " +
                "37 02 09 00 00 31 2E 54 36 30 2E 30 33 37 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 33 37 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 33 36 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 33 36 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "33 36 02 09 00 00 31 2E 54 36 30 2E 30 32 36 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 32 36 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 32 36 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 32 35 02 09 00 00 31 2E 54 36 30 2E " +
                "30 32 35 02 09 00 00 31 2E 54 36 30 2E 30 32 35 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 32 34 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 32 34 02 09 00 00 31 2E " +
                "54 36 30 2E 30 32 34 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 31 34 02 09 00 00 31 2E 54 36 30 2E 30 31 " +
                "34 02 09 00 00 31 2E 54 36 30 2E 30 31 34 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 31 33 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 31 33 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 31 33 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "31 32 02 09 00 00 31 2E 54 36 30 2E 30 31 32 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 31 32 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 30 32 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 30 32 02 09 00 00 31 2E 54 36 30 2E " +
                "30 30 32 02 09 00 00 31 2E 54 36 30 2E 30 30 31 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 30 31 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 30 31 02 09 00 00 31 2E " +
                "54 32 30 2E 31 37 32 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 37 32 02 09 00 00 31 2E 54 32 30 2E 31 37 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 31 36 32 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 36 32 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 36 32 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 36 31 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "36 31 02 09 00 00 31 2E 54 32 30 2E 31 36 31 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 36 30 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 36 30 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 36 30 02 09 00 00 31 2E 54 32 30 2E " +
                "31 35 30 02 09 00 00 31 2E 54 32 30 2E 31 35 30 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 35 30 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 34 39 02 09 00 00 31 2E " +
                "54 32 30 2E 31 34 39 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 34 39 02 09 00 00 31 2E 54 32 30 2E 31 34 " +
                "38 02 09 00 00 31 2E 54 32 30 2E 31 34 38 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 34 38 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 33 38 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 33 38 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "33 38 02 09 00 00 31 2E 54 32 30 2E 31 33 37 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 33 37 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 33 37 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 33 36 02 09 00 00 31 2E 54 32 30 2E " +
                "31 33 36 02 09 00 00 31 2E 54 32 30 2E 31 33 36 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 32 36 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 32 36 02 09 00 00 31 2E " +
                "54 32 30 2E 31 32 36 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 32 35 02 09 00 00 31 2E 54 32 30 2E 31 32 " +
                "35 02 09 00 00 31 2E 54 32 30 2E 31 32 35 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 32 34 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 32 34 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 32 34 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "31 34 02 09 00 00 31 2E 54 32 30 2E 31 31 34 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 31 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 31 33 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 31 33 02 09 00 00 31 2E 54 32 30 2E " +
                "31 31 33 02 09 00 00 31 2E 54 32 30 2E 31 31 32 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 31 32 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 31 32 02 09 00 00 31 2E " +
                "54 32 30 2E 31 30 32 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 30 32 02 09 00 00 31 2E 54 32 30 2E 31 30 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 31 30 31 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 30 31 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 30 31 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 30 30 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "30 30 02 09 00 00 31 2E 54 32 30 2E 31 30 30 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 39 30 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 39 30 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 39 30 02 09 00 00 31 2E 54 32 30 2E " +
                "30 38 39 02 09 00 00 31 2E 54 32 30 2E 30 38 39 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 38 39 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 38 38 02 09 00 00 31 2E " +
                "54 32 30 2E 30 38 38 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 38 38 02 09 00 00 31 2E 54 32 30 2E 30 37 " +
                "38 02 09 00 00 31 2E 54 32 30 2E 30 37 38 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 37 38 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 37 37 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 37 37 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "37 37 02 09 00 00 31 2E 54 32 30 2E 30 37 36 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 37 36 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 37 36 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 36 36 02 09 00 00 31 2E 54 32 30 2E " +
                "30 36 36 02 09 00 00 31 2E 54 32 30 2E 30 36 36 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 36 35 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 36 35 02 09 00 00 31 2E " +
                "54 32 30 2E 30 36 35 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 36 34 02 09 00 00 31 2E 54 32 30 2E 30 36 " +
                "34 02 09 00 00 31 2E 54 32 30 2E 30 36 34 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 35 34 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 35 34 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 35 34 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "35 33 02 09 00 00 31 2E 54 32 30 2E 30 35 33 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 35 33 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 35 32 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 35 32 02 09 00 00 31 2E 54 32 30 2E " +
                "30 35 32 02 09 00 00 31 2E 54 32 30 2E 30 34 32 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 34 32 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 34 32 02 09 00 00 31 2E " +
                "54 32 30 2E 30 34 31 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 34 31 02 09 00 00 31 2E 54 32 30 2E 30 34 " +
                "31 02 09 00 00 31 2E 54 32 30 2E 30 34 30 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 34 30 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 34 30 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 33 30 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "33 30 02 09 00 00 31 2E 54 32 30 2E 30 33 30 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 32 39 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 32 39 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 32 39 02 09 00 00 31 2E 54 32 30 2E " +
                "30 32 38 02 09 00 00 31 2E 54 32 30 2E 30 32 38 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 32 38 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 31 38 02 09 00 00 31 2E " +
                "54 32 30 2E 30 31 38 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 31 38 02 09 00 00 31 2E 54 32 30 2E 30 31 " +
                "37 02 09 00 00 31 2E 54 32 30 2E 30 31 37 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 31 37 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 31 36 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 31 36 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "31 36 02 09 00 00 31 2E 54 32 30 2E 30 30 36 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 30 36 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 30 36 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 30 35 02 09 00 00 31 2E 54 32 30 2E " +
                "30 30 35 02 09 00 00 31 2E 54 32 30 2E 30 30 35 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 30 34 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 30 34 02 09 00 00 31 2E " +
                "54 32 30 2E 30 30 34 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 30 37 02 09 00 00 31 2E 54 32 30 2E 30 30 " +
                "37 02 09 00 00 31 2E 54 32 30 2E 30 30 37 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 30 38 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 30 38 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 30 38 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "30 39 02 09 00 00 31 2E 54 32 30 2E 30 30 39 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 30 39 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 31 39 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 31 39 02 09 00 00 31 2E 54 32 30 2E " +
                "30 31 39 02 09 00 00 31 2E 54 32 30 2E 30 32 30 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 32 30 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 32 30 02 09 00 00 31 2E " +
                "54 32 30 2E 30 32 31 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 32 31 02 09 00 00 31 2E 54 32 30 2E 30 32 " +
                "31 02 09 00 00 31 2E 54 32 30 2E 30 33 31 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 33 31 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 33 31 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 33 32 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "33 32 02 09 00 00 31 2E 54 32 30 2E 30 33 32 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 33 33 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 33 33 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 33 33 02 09 00 00 31 2E 54 32 30 2E " +
                "30 34 33 02 09 00 00 31 2E 54 32 30 2E 30 34 33 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 34 33 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 34 34 02 09 00 00 31 2E " +
                "54 32 30 2E 30 34 34 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 34 34 02 09 00 00 31 2E 54 32 30 2E 30 34 " +
                "35 02 09 00 00 31 2E 54 32 30 2E 30 34 35 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 34 35 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 35 35 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 35 35 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "35 35 02 09 00 00 31 2E 54 32 30 2E 30 35 36 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 35 36 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 35 36 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 35 37 02 09 00 00 31 2E 54 32 30 2E " +
                "30 35 37 02 09 00 00 31 2E 54 32 30 2E 30 35 37 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 36 37 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 36 37 02 09 00 00 31 2E " +
                "54 32 30 2E 30 36 37 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 36 38 02 09 00 00 31 2E 54 32 30 2E 30 36 " +
                "38 02 09 00 00 31 2E 54 32 30 2E 30 36 38 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 36 39 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 36 39 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 36 39 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "37 39 02 09 00 00 31 2E 54 32 30 2E 30 37 39 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 37 39 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 38 30 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 38 30 02 09 00 00 31 2E 54 32 30 2E " +
                "30 38 30 02 09 00 00 31 2E 54 32 30 2E 30 38 31 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 38 31 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 38 31 02 09 00 00 31 2E " +
                "54 32 30 2E 30 39 31 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 39 31 02 09 00 00 31 2E 54 32 30 2E 30 39 " +
                "31 02 09 00 00 31 2E 54 32 30 2E 30 39 32 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 39 32 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 39 32 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 39 33 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "39 33 02 09 00 00 31 2E 54 32 30 2E 30 39 33 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 30 33 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 30 33 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 30 33 02 09 00 00 31 2E 54 32 30 2E " +
                "31 30 34 02 09 00 00 31 2E 54 32 30 2E 31 30 34 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 30 34 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 30 35 02 09 00 00 31 2E " +
                "54 32 30 2E 31 30 35 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 30 35 02 09 00 00 31 2E 54 32 30 2E 31 31 " +
                "35 02 09 00 00 31 2E 54 32 30 2E 31 31 35 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 31 35 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 31 36 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 31 36 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "31 36 02 09 00 00 31 2E 54 32 30 2E 31 31 37 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 31 37 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 31 37 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 32 37 02 09 00 00 31 2E 54 32 30 2E " +
                "31 32 37 02 09 00 00 31 2E 54 32 30 2E 31 32 37 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 32 38 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 32 38 02 09 00 00 31 2E " +
                "54 32 30 2E 31 32 38 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 32 39 02 09 00 00 31 2E 54 32 30 2E 31 32 " +
                "39 02 09 00 00 31 2E 54 32 30 2E 31 32 39 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 33 39 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 33 39 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 33 39 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "34 30 02 09 00 00 31 2E 54 32 30 2E 31 34 30 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 34 30 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 34 31 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 34 31 02 09 00 00 31 2E 54 32 30 2E " +
                "31 34 31 02 09 00 00 31 2E 54 32 30 2E 31 35 31 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 35 31 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 35 31 02 09 00 00 31 2E " +
                "54 32 30 2E 31 35 32 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 35 32 02 09 00 00 31 2E 54 32 30 2E 31 35 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 31 35 33 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 35 33 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 35 33 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 36 33 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "36 33 02 09 00 00 31 2E 54 32 30 2E 31 36 33 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 36 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 36 34 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 36 34 02 09 00 00 31 2E 54 32 30 2E " +
                "31 36 35 02 09 00 00 31 2E 54 32 30 2E 31 36 35 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 36 35 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 30 33 02 09 00 00 31 2E " +
                "54 36 30 2E 30 30 33 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 30 33 02 09 00 00 31 2E 54 36 30 2E 30 30 " +
                "34 02 09 00 00 31 2E 54 36 30 2E 30 30 34 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 30 34 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 30 35 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 30 35 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "30 35 02 09 00 00 31 2E 54 36 30 2E 30 31 35 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 31 35 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 31 35 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 31 36 02 09 00 00 31 2E 54 36 30 2E " +
                "30 31 36 02 09 00 00 31 2E 54 36 30 2E 30 31 36 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 31 37 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 31 37 02 09 00 00 31 2E " +
                "54 36 30 2E 30 31 37 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 32 37 02 09 00 00 31 2E 54 36 30 2E 30 32 " +
                "37 02 09 00 00 31 2E 54 36 30 2E 30 32 37 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 32 38 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 32 38 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 32 38 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "32 39 02 09 00 00 31 2E 54 36 30 2E 30 32 39 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 32 39 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 33 39 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 33 39 02 09 00 00 31 2E 54 36 30 2E " +
                "30 33 39 02 09 00 00 31 2E 54 36 30 2E 30 34 30 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 34 30 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 34 30 02 09 00 00 31 2E " +
                "54 36 30 2E 30 34 31 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 34 31 02 09 00 00 31 2E 54 36 30 2E 30 34 " +
                "31 02 09 00 00 31 2E 54 36 30 2E 30 35 31 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 35 31 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 35 31 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 35 32 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "35 32 02 09 00 00 31 2E 54 36 30 2E 30 35 32 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 35 33 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 35 33 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 35 33 02 09 00 00 31 2E 54 36 30 2E " +
                "30 35 36 02 09 00 00 31 2E 54 36 30 2E 30 35 36 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 35 36 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 35 35 02 09 00 00 31 2E " +
                "54 36 30 2E 30 35 35 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 35 35 02 09 00 00 31 2E 54 36 30 2E 30 35 " +
                "34 02 09 00 00 31 2E 54 36 30 2E 30 35 34 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 35 34 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 34 34 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 34 34 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "34 34 02 09 00 00 31 2E 54 36 30 2E 30 34 33 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 34 33 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 34 33 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 34 32 02 09 00 00 31 2E 54 36 30 2E " +
                "30 34 32 02 09 00 00 31 2E 54 36 30 2E 30 34 32 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 33 32 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 33 32 02 09 00 00 31 2E " +
                "54 36 30 2E 30 33 32 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 33 31 02 09 00 00 31 2E 54 36 30 2E 30 33 " +
                "31 02 09 00 00 31 2E 54 36 30 2E 30 33 31 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 33 30 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 33 30 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 33 30 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "32 30 02 09 00 00 31 2E 54 36 30 2E 30 32 30 02 " +
                "09 00 00 31 2E 54 36 30 2E 30 32 30 02 09 00 00 " +
                "31 2E 54 36 30 2E 30 31 39 02 09 00 00 31 2E 54 " +
                "36 30 2E 30 31 39 02 09 00 00 31 2E 54 36 30 2E " +
                "30 31 39 02 09 00 00 31 2E 54 36 30 2E 30 31 38 " +
                "02 09 00 00 31 2E 54 36 30 2E 30 31 38 02 09 00 " +
                "00 31 2E 54 36 30 2E 30 31 38 02 09 00 00 31 2E " +
                "54 36 30 2E 30 30 38 02 09 00 00 31 2E 54 36 30 " +
                "2E 30 30 38 02 09 00 00 31 2E 54 36 30 2E 30 30 " +
                "38 02 09 00 00 31 2E 54 36 30 2E 30 30 37 02 09 " +
                "00 00 31 2E 54 36 30 2E 30 30 37 02 09 00 00 31 " +
                "2E 54 36 30 2E 30 30 37 02 09 00 00 31 2E 54 36 " +
                "30 2E 30 30 36 02 09 00 00 31 2E 54 36 30 2E 30 " +
                "30 36 02 09 00 00 31 2E 54 36 30 2E 30 30 36 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 36 38 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 36 38 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 36 38 02 09 00 00 31 2E 54 32 30 2E " +
                "31 36 37 02 09 00 00 31 2E 54 32 30 2E 31 36 37 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 36 37 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 36 36 02 09 00 00 31 2E " +
                "54 32 30 2E 31 36 36 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 36 36 02 09 00 00 31 2E 54 32 30 2E 31 35 " +
                "36 02 09 00 00 31 2E 54 32 30 2E 31 35 36 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 35 36 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 35 35 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 35 35 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "35 35 02 09 00 00 31 2E 54 32 30 2E 31 35 34 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 35 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 35 34 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 34 34 02 09 00 00 31 2E 54 32 30 2E " +
                "31 34 34                                       ";

            string record_0x03C =
                "         3C 00 62 05 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 34 34 02 09 00 00 31 2E 54 32 30 2E 31 34 " +
                "33 02 09 00 00 31 2E 54 32 30 2E 31 34 33 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 34 33 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 34 32 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 34 32 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "34 32 02 09 00 00 31 2E 54 32 30 2E 31 33 32 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 33 32 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 33 32 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 33 31 02 09 00 00 31 2E 54 32 30 2E " +
                "31 33 31 02 09 00 00 31 2E 54 32 30 2E 31 33 31 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 33 30 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 33 30 02 09 00 00 31 2E " +
                "54 32 30 2E 31 33 30 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 32 30 02 09 00 00 31 2E 54 32 30 2E 31 32 " +
                "30 02 09 00 00 31 2E 54 32 30 2E 31 32 30 02 09 " +
                "00 00 31 2E 54 32 30 2E 31 31 39 02 09 00 00 31 " +
                "2E 54 32 30 2E 31 31 39 02 09 00 00 31 2E 54 32 " +
                "30 2E 31 31 39 02 09 00 00 31 2E 54 32 30 2E 31 " +
                "31 38 02 09 00 00 31 2E 54 32 30 2E 31 31 38 02 " +
                "09 00 00 31 2E 54 32 30 2E 31 31 38 02 09 00 00 " +
                "31 2E 54 32 30 2E 31 30 38 02 09 00 00 31 2E 54 " +
                "32 30 2E 31 30 38 02 09 00 00 31 2E 54 32 30 2E " +
                "31 30 38 02 09 00 00 31 2E 54 32 30 2E 31 30 37 " +
                "02 09 00 00 31 2E 54 32 30 2E 31 30 37 02 09 00 " +
                "00 31 2E 54 32 30 2E 31 30 37 02 09 00 00 31 2E " +
                "54 32 30 2E 31 30 36 02 09 00 00 31 2E 54 32 30 " +
                "2E 31 30 36 02 09 00 00 31 2E 54 32 30 2E 31 30 " +
                "36 02 09 00 00 31 2E 54 32 30 2E 30 39 36 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 39 36 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 39 36 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 39 35 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "39 35 02 09 00 00 31 2E 54 32 30 2E 30 39 35 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 39 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 39 34 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 39 34 02 09 00 00 31 2E 54 32 30 2E " +
                "30 38 34 02 09 00 00 31 2E 54 32 30 2E 30 38 34 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 38 34 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 38 33 02 09 00 00 31 2E " +
                "54 32 30 2E 30 38 33 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 38 33 02 09 00 00 31 2E 54 32 30 2E 30 38 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 30 38 32 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 38 32 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 37 32 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 37 32 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "37 32 02 09 00 00 31 2E 54 32 30 2E 30 37 31 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 37 31 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 37 31 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 37 30 02 09 00 00 31 2E 54 32 30 2E " +
                "30 37 30 02 09 00 00 31 2E 54 32 30 2E 30 37 30 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 36 30 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 36 30 02 09 00 00 31 2E " +
                "54 32 30 2E 30 36 30 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 35 39 02 09 00 00 31 2E 54 32 30 2E 30 35 " +
                "39 02 09 00 00 31 2E 54 32 30 2E 30 35 39 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 35 38 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 35 38 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 35 38 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "34 38 02 09 00 00 31 2E 54 32 30 2E 30 34 38 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 34 38 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 34 37 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 34 37 02 09 00 00 31 2E 54 32 30 2E " +
                "30 34 37 02 09 00 00 31 2E 54 32 30 2E 30 34 36 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 34 36 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 34 36 02 09 00 00 31 2E " +
                "54 32 30 2E 30 33 36 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 33 36 02 09 00 00 31 2E 54 32 30 2E 30 33 " +
                "36 02 09 00 00 31 2E 54 32 30 2E 30 33 35 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 33 35 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 33 35 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 33 34 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "33 34 02 09 00 00 31 2E 54 32 30 2E 30 33 34 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 32 34 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 32 34 02 09 00 00 31 2E 54 " +
                "32 30 2E 30 32 34 02 09 00 00 31 2E 54 32 30 2E " +
                "30 32 33 02 09 00 00 31 2E 54 32 30 2E 30 32 33 " +
                "02 09 00 00 31 2E 54 32 30 2E 30 32 33 02 09 00 " +
                "00 31 2E 54 32 30 2E 30 32 32 02 09 00 00 31 2E " +
                "54 32 30 2E 30 32 32 02 09 00 00 31 2E 54 32 30 " +
                "2E 30 32 32 02 09 00 00 31 2E 54 32 30 2E 30 31 " +
                "32 02 09 00 00 31 2E 54 32 30 2E 30 31 32 02 09 " +
                "00 00 31 2E 54 32 30 2E 30 31 32 02 09 00 00 31 " +
                "2E 54 32 30 2E 30 31 31 02 09 00 00 31 2E 54 32 " +
                "30 2E 30 31 31 02 09 00 00 31 2E 54 32 30 2E 30 " +
                "31 31 02 09 00 00 31 2E 54 32 30 2E 30 31 30 02 " +
                "09 00 00 31 2E 54 32 30 2E 30 31 30 02 09 00 00 " +
                "31 2E 54 32 30 2E 30 31 30                     ";

            byte[]            data1 = HexRead.ReadFromString(record_0x0018 + record_0x03C);
            RecordInputStream in1   = TestcaseRecordInputStream.Create(data1);
            NameRecord        nr1   = new NameRecord(in1);

            assert_bug50244(nr1);

            byte[] data2 = nr1.Serialize();

            Assert.AreEqual(data1.Length, data2.Length);
            RecordInputStream in2 = TestcaseRecordInputStream.Create(data2);
            NameRecord        nr2 = new NameRecord(in2);

            assert_bug50244(nr2);
        }
Example #8
0
        /************************
         * public methods
         */


        public bool Validate(Validator v, OTFontVal fontOwner)
        {
            bool bRet = true;

            if (v.PerformTest(T.name_FormatSelector))
            {
                if (FormatSelector == 0)
                {
                    v.Pass(T.name_FormatSelector, P.name_P_FormatSelector, m_tag);
                }
                else
                {
                    v.Error(T.name_FormatSelector, E.name_E_FormatSelector, m_tag, FormatSelector.ToString());
                    bRet = false;
                }
            }

            if (v.PerformTest(T.name_StringsWithinTable))
            {
                bool bStringsWithinTable = true;

                uint tableLength = GetLength();
                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.StringOffset + nr.StringLength > tableLength)
                        {
                            v.Error(T.name_StringsWithinTable, E.name_E_StringsWithinTable, m_tag, "string# " + i);
                            bStringsWithinTable = false;
                            bRet = false;
                        }
                    }
                    else
                    {
                        v.Warning(T.name_StringsWithinTable, W._TEST_W_OtherErrorsInTable, m_tag);
                        bStringsWithinTable = false;
                        break;
                    }
                }
                if (bStringsWithinTable)
                {
                    v.Pass(T.name_StringsWithinTable, P.name_P_StringsWithinTable, m_tag);
                }
            }

            if (v.PerformTest(T.name_NameRecordsSorted))
            {
                bool bSortedOrder = true;

                if (NumberNameRecords > 1)
                {
                    NameRecord CurrNR = GetNameRecord(0);
                    NameRecord NextNR = null;
                    for (uint i = 0; i < NumberNameRecords - 1; i++)
                    {
                        NextNR = GetNameRecord(i + 1);

                        if (CurrNR == null || NextNR == null)
                        {
                            bSortedOrder = false;
                            break;
                        }

                        if (CurrNR.PlatformID > NextNR.PlatformID)
                        {
                            bSortedOrder = false;
                            break;
                        }
                        else if (CurrNR.PlatformID == NextNR.PlatformID)
                        {
                            if (CurrNR.EncodingID > NextNR.EncodingID)
                            {
                                bSortedOrder = false;
                                break;
                            }
                            else if (CurrNR.EncodingID == NextNR.EncodingID)
                            {
                                if (CurrNR.LanguageID > NextNR.LanguageID)
                                {
                                    bSortedOrder = false;
                                    break;
                                }
                                else if (CurrNR.LanguageID == NextNR.LanguageID)
                                {
                                    if (CurrNR.NameID > NextNR.NameID)
                                    {
                                        bSortedOrder = false;
                                        break;
                                    }
                                }
                            }
                        }

                        CurrNR = NextNR;
                    }
                }

                if (bSortedOrder)
                {
                    v.Pass(T.name_NameRecordsSorted, P.name_P_NameRecordsSorted, m_tag);
                }
                else
                {
                    v.Error(T.name_NameRecordsSorted, E.name_E_NameRecordsSorted, m_tag);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.name_ReservedNameIDs))
            {
                bool bReservedOk = true;

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);

                    if (nr != null)
                    {
                        if (nr.NameID >= 26 && nr.NameID <= 255)
                        {
                            string s = "platID = " + nr.PlatformID
                                       + ", encID = " + nr.EncodingID
                                       + ", langID = " + nr.LanguageID
                                       + ", nameID = " + nr.NameID;
                            v.Error(T.name_ReservedNameIDs, E.name_E_ReservedNameID, m_tag, s);
                            bReservedOk = false;
                            break;
                        }
                    }
                    else
                    {
                        v.Warning(T.name_ReservedNameIDs, W._TEST_W_OtherErrorsInTable, m_tag);
                        bReservedOk = false;
                        break;
                    }
                }

                if (bReservedOk)
                {
                    v.Pass(T.name_ReservedNameIDs, P.name_P_ReservedNameID, m_tag);
                }
            }

            if (v.PerformTest(T.name_BothPlatforms))
            {
                bool bMac = false;
                bool bMS  = false;


                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.PlatformID == 1)
                        {
                            bMac = true;
                        }
                        else if (nr.PlatformID == 3)
                        {
                            bMS = true;
                        }
                    }
                }

                if (bMac && bMS)
                {
                    v.Pass(T.name_BothPlatforms, P.name_P_BothPlatforms, m_tag);
                }
                else if (!bMac)
                {
                    v.Error(T.name_BothPlatforms, E.name_E_NoMacPlatform, m_tag);
                    bRet = false;
                }
                else if (!bMS)
                {
                    v.Error(T.name_BothPlatforms, E.name_E_NoMSPlatform, m_tag);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.name_VersionString))
            {
                bool   bFound   = false;
                string sVersion = "";

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.PlatformID == 3 &&       // ms
                            (nr.EncodingID == 1 /* unicode */ || nr.EncodingID == 0 /*symbol*/) &&
                            nr.NameID == 5)             // version string
                        {
                            bFound = true;

                            bool    bVerStringValid = false;
                            byte [] buf             = GetEncodedString(nr);

                            string s = "";

                            if (buf != null)
                            {
                                sVersion = "";
                                for (int j = 0; j < buf.Length / 2; j++)
                                {
                                    char c = (char)(ushort)(buf[j * 2] << 8 | buf[j * 2 + 1]);
                                    sVersion += c;
                                }

                                if (sVersion.Length >= 11 &&
                                    sVersion.StartsWith("Version ") &&
                                    Char.IsDigit(sVersion, 8))
                                {
                                    int j = 9;

                                    // advance past the digits in the major number
                                    while (j < sVersion.Length)
                                    {
                                        if (Char.IsDigit(sVersion, j))
                                        {
                                            j++;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }

                                    // if major number is followed by a period
                                    if (sVersion[j] == '.')
                                    {
                                        // advance past the period
                                        j++;

                                        // check for a digit
                                        if (Char.IsDigit(sVersion, j))
                                        {
                                            bVerStringValid = true;
                                        }
                                    }
                                }
                            }

                            s = "platID = " + nr.PlatformID
                                + ", encID = " + nr.EncodingID
                                + ", langID = " + nr.LanguageID
                                + ", \"" + sVersion + "\"";

                            if (bVerStringValid)
                            {
                                v.Pass(T.name_VersionString, P.name_P_VersionStringFormat, m_tag, s);
                            }
                            else
                            {
                                v.Error(T.name_VersionString, E.name_E_VersionStringFormat, m_tag, s);
                                bRet = false;
                            }

                            // compare to mac version string if present
                            string sMacVer = GetString(1, 0, 0xffff, 5);
                            if (sMacVer != null)
                            {
                                if (sVersion.CompareTo(sMacVer) != 0)
                                {
                                    v.Warning(T.name_VersionString, W.name_W_VersionMismatch_MS_MAC, m_tag);
                                }
                            }

                            // compare to 3,10 version string if present
                            string s310Ver = GetString(3, 10, nr.LanguageID, 5);
                            if (s310Ver != null)
                            {
                                if (sVersion.CompareTo(s310Ver) != 0)
                                {
                                    string s310 = "platID = 3, encID = 10, langID = " + nr.LanguageID
                                                  + ", \"" + s310Ver + "\"";
                                    v.Warning(T.name_VersionString, W.name_W_VersionMismatch_3_1_3_10, m_tag, s + " / " + s310);
                                }
                            }
                        }
                    }
                }

                if (!bFound)
                {
                    v.Error(T.name_VersionString, E.name_E_VersionStringNotFound, m_tag);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.name_PlatformSpecificEncoding))
            {
                bool bIDsOk = true;

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.PlatformID == 0) // unicode
                        {
                            if (nr.EncodingID > 7)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = " + nr.LanguageID
                                           + ", nameID = " + nr.NameID;
                                v.Error(T.name_PlatformSpecificEncoding, E.name_E_PlatformSpecificEncoding, m_tag, s);
                                bIDsOk = false;
                                bRet   = false;
                            }
                        }
                        else if (nr.PlatformID == 1) // mac
                        {
                            if (nr.EncodingID > 32)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = " + nr.LanguageID
                                           + ", nameID = " + nr.NameID;
                                v.Error(T.name_PlatformSpecificEncoding, E.name_E_PlatformSpecificEncoding, m_tag, s);
                                bIDsOk = false;
                                bRet   = false;
                            }
                        }
                        else if (nr.PlatformID == 2) // iso
                        {
                            if (nr.EncodingID > 2)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = " + nr.LanguageID
                                           + ", nameID = " + nr.NameID;
                                v.Error(T.name_PlatformSpecificEncoding, E.name_E_PlatformSpecificEncoding, m_tag, s);
                                bIDsOk = false;
                                bRet   = false;
                            }
                        }
                        else if (nr.PlatformID == 3) // MS
                        {
                            if (nr.EncodingID > 10)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = " + nr.LanguageID
                                           + ", nameID = " + nr.NameID;
                                v.Error(T.name_PlatformSpecificEncoding, E.name_E_PlatformSpecificEncoding, m_tag, s);
                                bIDsOk = false;
                                bRet   = false;
                            }
                        }

                        /*
                         * else if (nr.PlatformID == 4) // Custom
                         * {
                         * }
                         */
                    }
                    else
                    {
                        v.Warning(T.name_PlatformSpecificEncoding, W._TEST_W_OtherErrorsInTable, m_tag);
                        bIDsOk = false;
                        break;
                    }
                }

                if (bIDsOk)
                {
                    v.Pass(T.name_PlatformSpecificEncoding, P.name_P_PlatformSpecificEncoding, m_tag);
                }
            }

            if (v.PerformTest(T.name_MSLanguageIDs))
            {
                bool bFound = false;
                bool bIDsOk = true;

                ushort [] MSLangIDs = // taken from Q224804
                {
                    0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409,
                    0x040a, 0x040b, 0x040c, 0x040D, 0x040e, 0x040F, 0x0410, 0x0411, 0x0412,
                    0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b,
                    0x041c, 0x041D, 0x041E, 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424,
                    0x0425, 0x0426, 0x0427, 0x0429, 0x042a, 0x042b, 0x042c, 0x042D, 0x042e,
                    0x042f, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
                    0x0438, 0x0439, 0x043b, 0x043d, 0x043e, 0x043f, 0x0441, 0x0443, 0x0444,
                    0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d,
                    0x044e, 0x044f, 0x0457, 0x0459, 0x0461, 0x0801, 0x0804, 0x0807, 0x0809,
                    0x080a, 0x080c, 0x0810, 0x0812, 0x0813, 0x0814, 0x0816, 0x0818, 0x0819,
                    0x081a, 0x081d, 0x0820, 0x0827, 0x082c, 0x083e, 0x0843, 0x0860, 0x0861,
                    0x0C01, 0x0C04, 0x0c07, 0x0c09, 0x0c0a, 0x0c0c, 0x0c1a, 0x1001, 0x1004,
                    0x1007, 0x1009, 0x100a, 0x100c, 0x1401, 0x1404, 0x1407, 0x1409, 0x140a,
                    0x140c, 0x1801, 0x1809, 0x180a, 0x180c, 0x1C01, 0x1c09, 0x1c0a, 0x2001,
                    0x2009, 0x200a, 0x2401, 0x2409, 0x240a, 0x2801, 0x2809, 0x280a, 0x2C01,
                    0x2c09, 0x2c0a, 0x3001, 0x3009, 0x300a, 0x3401, 0x3409, 0x340a, 0x3801,
                    0x380a, 0x3C01, 0x3c0a, 0x4001, 0x400a, 0x440a, 0x480a, 0x4c0a, 0x500a
                };

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.PlatformID == 3 && nr.EncodingID == 1)
                        {
                            bFound = true;

                            bool bValidID = false;
                            for (uint j = 0; j < MSLangIDs.Length; j++)
                            {
                                if (nr.LanguageID == MSLangIDs[j])
                                {
                                    bValidID = true;
                                    break;
                                }
                            }

                            if (!bValidID)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = 0x" + nr.LanguageID.ToString("x4")
                                           + ", nameID = " + nr.NameID;
                                v.Error(T.name_MSLanguageIDs, E.name_E_MSLanguageID, m_tag, s);
                                bIDsOk = false;
                                bRet   = false;
                            }
                        }
                    }
                }

                if (bFound && bIDsOk)
                {
                    v.Pass(T.name_MSLanguageIDs, P.name_P_MSLanguageID, m_tag);
                }
            }

            if (v.PerformTest(T.name_unicode_length))
            {
                bool bLengthsOk = true;

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.PlatformID == 0 || nr.PlatformID == 2 || // unicode or iso platform
                            (nr.PlatformID == 3 && nr.EncodingID == 1)) // microsoft platform, unicode encoding
                        {
                            if ((nr.StringLength & 1) == 1)
                            {
                                string s = "platID = " + nr.PlatformID
                                           + ", encID = " + nr.EncodingID
                                           + ", langID = " + nr.LanguageID
                                           + ", nameID = " + nr.NameID
                                           + ", length = " + nr.StringLength;
                                v.Error(T.name_unicode_length, E.name_E_UnicodeLength, m_tag, s);
                                bLengthsOk = false;
                                bRet       = false;
                            }
                        }
                    }
                    else
                    {
                        v.Warning(T.name_unicode_length, W._TEST_W_OtherErrorsInTable, m_tag);
                        bLengthsOk = false;
                        break;
                    }
                }

                if (bLengthsOk)
                {
                    v.Pass(T.name_unicode_length, P.name_P_UnicodeLength, m_tag);
                }
            }

            if (v.PerformTest(T.name_Postscript))
            {
                bool bPostscriptOk = true;

                string sPostscriptMac = GetString(1, 0, 0, 6);
                if (sPostscriptMac != null)
                {
                    if (sPostscriptMac.Length > 63)
                    {
                        v.Error(T.name_Postscript, E.name_E_Postscript_length, m_tag, "name string (1, 0, 0, 6) is " + sPostscriptMac.Length + " characters long");
                        bRet          = false;
                        bPostscriptOk = false;
                    }

                    for (int i = 0; i < sPostscriptMac.Length; i++)
                    {
                        char c = sPostscriptMac[i];
                        if (c < 33 || c > 126 || c == '[' || c == ']' || c == '(' || c == ')' || c == '{' || c == '}' || c == '<' || c == '>' || c == '/' || c == '%')
                        {
                            v.Error(T.name_Postscript, E.name_E_Postscript_chars, m_tag, "name string (1, 0, 0, 6) contains an illegal character at index " + i);
                            bRet          = false;
                            bPostscriptOk = false;
                        }
                    }
                }

                ushort nEncoding = 1;
                if (fontOwner.ContainsMsSymbolEncodedCmap())
                {
                    nEncoding = 0;
                }

                string sPostscriptMS = GetString(3, nEncoding, 0x409, 6); // ms
                if (sPostscriptMS != null)
                {
                    if (sPostscriptMS.Length > 63)
                    {
                        v.Error(T.name_Postscript, E.name_E_Postscript_length, m_tag, "name string (3, " + nEncoding + ", 0x409, 6) is " + sPostscriptMS.Length + " characters long");
                        bRet          = false;
                        bPostscriptOk = false;
                    }

                    for (int i = 0; i < sPostscriptMS.Length; i++)
                    {
                        char c = sPostscriptMS[i];
                        if (c < 33 || c > 126 || c == '[' || c == ']' || c == '(' || c == ')' || c == '{' || c == '}' || c == '<' || c == '>' || c == '/' || c == '%')
                        {
                            v.Error(T.name_Postscript, E.name_E_Postscript_chars, m_tag, "name string (3, " + nEncoding + ", 0x409, 6) contains an illegal character at index " + i);
                            bRet          = false;
                            bPostscriptOk = false;
                        }
                    }
                }

                if (sPostscriptMac == null && sPostscriptMS != null)
                {
                    v.Error(T.name_Postscript, E.name_E_Postscript_missing, m_tag, "Mac Postscript string is missing, but MS Postscript string is present");
                    bRet          = false;
                    bPostscriptOk = false;
                }
                else if (sPostscriptMac != null && sPostscriptMS == null)
                {
                    v.Error(T.name_Postscript, E.name_E_Postscript_missing, m_tag, "MS Postscript string is missing, but Mac Postscript string is present");
                    bRet          = false;
                    bPostscriptOk = false;
                }
                if (sPostscriptMac != null && sPostscriptMS != null)
                {
                    if (sPostscriptMac != sPostscriptMS)
                    {
                        v.Error(T.name_Postscript, E.name_E_Postscript_unequal, m_tag, "mac postscript = " + sPostscriptMac + ", MS postscript = " + sPostscriptMS);
                        bRet          = false;
                        bPostscriptOk = false;
                    }
                }


                if (sPostscriptMac != null && sPostscriptMS != null && bPostscriptOk)
                {
                    v.Pass(T.name_Postscript, P.name_P_Postscript, m_tag);
                }
            }

            if (v.PerformTest(T.name_Subfamily))
            {
                string sStyle = GetStyleString();
                if (sStyle != null)
                {
                    Table_OS2 OS2Table = (Table_OS2)fontOwner.GetTable("OS/2");
                    if (OS2Table != null)
                    {
                        bool   bStyleOk      = true;
                        string sStyleDetails = "";
                        string s             = sStyle.ToLower();

                        bool bItalic = ((OS2Table.fsSelection & 0x01) != 0);
                        bool bBold   = ((OS2Table.fsSelection & 0x20) != 0);

                        if (bItalic)
                        {
                            if (s.IndexOf("italic") == -1 && s.IndexOf("oblique") == -1)
                            {
                                bStyleOk      = false;
                                sStyleDetails = "OS/2.fsSelection italic bit is set, but subfamily string = '" + sStyle + "'";
                            }
                        }
                        else
                        {
                            if (s.IndexOf("italic") != -1 || s.IndexOf("oblique") != -1)
                            {
                                bStyleOk      = false;
                                sStyleDetails = "OS/2.fsSelection italic bit is clear, but subfamily string = '" + sStyle + "'";
                            }
                        }

                        if (bBold)
                        {
                            if (s.IndexOf("bold") == -1)
                            {
                                bStyleOk      = false;
                                sStyleDetails = "OS/2.fsSelection bold bit is set, but subfamily string = '" + sStyle + "'";
                            }
                        }
                        else
                        {
                            if (s.IndexOf("bold") != -1)
                            {
                                bStyleOk      = false;
                                sStyleDetails = "OS/2.fsSelection bold bit is clear, but subfamily string = '" + sStyle + "'";
                            }
                        }

                        if (bStyleOk)
                        {
                            v.Pass(T.name_Subfamily, P.name_P_subfamily, m_tag);
                        }
                        else
                        {
                            v.Warning(T.name_Subfamily, W.name_W_subfamily_style, m_tag, sStyleDetails);
                        }
                    }
                }
            }


            if (v.PerformTest(T.name_NoFormat14))
            {
                bool bStringOK = true;
                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null &&
                        nr.NameID == 19 &&
                        nr.PlatformID == 0 &&
                        nr.EncodingID == 5)
                    {
                        string sDetails =
                            "name string(" + nr.PlatformID
                            + ", " + nr.EncodingID
                            + ", 0x" + nr.LanguageID.ToString("x4")
                            + ", " + nr.NameID +
                            ", offset=0x" +
                            nr.StringOffset.ToString("x4") + ")";
                        v.Error(T.name_NoFormat14,
                                E.name_E_NoFormat14,
                                m_tag,
                                sDetails);
                        bRet      = false;
                        bStringOK = false;
                    }
                }
                if (bStringOK)
                {
                    string sDetails = "PlatformID=0, EncodingID=5 is for " +
                                      "Variation Sequences (Format 14)";
                    v.Pass(T.name_NoFormat14, P.name_P_NoFormat14, m_tag,
                           sDetails);
                }
            }

            if (v.PerformTest(T.name_SampleString))
            {
                Table_cmap cmapTable = (Table_cmap)fontOwner.GetTable("cmap");
                if (cmapTable != null)
                {
                    for (uint i = 0; i < NumberNameRecords; i++)
                    {
                        NameRecord nr = GetNameRecord(i);
                        if (nr != null)
                        {
                            if (nr.NameID == 19)
                            {
                                if (nr.PlatformID == 0 &&
                                    nr.EncodingID == 5)
                                {
                                    // Unicode platform encoding ID 5 can be
                                    // used for encodings in the 'cmap' table
                                    // but not for strings in the 'name' table.
                                    // It has already been flagged as an error,
                                    // so we will just skip it here.
                                    break;
                                }
                                Table_cmap.Subtable CmapSubTable = cmapTable.GetSubtable(nr.PlatformID, nr.EncodingID);
                                if (CmapSubTable != null)
                                {
                                    bool bStringOk = true;

                                    byte[] strbuf = GetEncodedString(nr);

                                    for (uint j = 0; j < strbuf.Length;)
                                    {
                                        if (CmapSubTable.MapCharToGlyph(strbuf, j, true) == 0)
                                        {
                                            string sDetails = "name string(" + nr.PlatformID
                                                              + ", " + nr.EncodingID
                                                              + ", 0x" + nr.LanguageID.ToString("x4")
                                                              + ", " + nr.NameID
                                                              + "), character at index " + j + " is not mapped";
                                            v.Error(T.name_SampleString, E.name_E_sample, m_tag, sDetails);
                                            bStringOk = false;
                                            bRet      = false;
                                            break;
                                        }

                                        j += CmapSubTable.BytesInChar(strbuf, j);
                                    }

                                    if (bStringOk)
                                    {
                                        string sDetails = "name string(" + nr.PlatformID
                                                          + ", " + nr.EncodingID
                                                          + ", 0x" + nr.LanguageID.ToString("x4")
                                                          + ", " + nr.NameID
                                                          + ")";
                                        v.Pass(T.name_SampleString, P.name_P_sample, m_tag, sDetails);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (v.PerformTest(T.name_NameID1to6))
            {
                for (uint id = 1; id <= 6; id++)
                {
                    bool bFound = false;

                    for (uint i = 0; i < NumberNameRecords; i++)
                    {
                        NameRecord nr = GetNameRecord(i);
                        if (nr != null)
                        {
                            if (nr.NameID == id)
                            {
                                bFound = true;
                                break;
                            }
                        }
                    }

                    if (!bFound)
                    {
                        v.Warning(T.name_NameID1to6, W.name_W_ID_1to6_Required_For_Common_OSes, m_tag,
                                  "Missing Name ID " + id);
                    }
                }
            }

            if (v.PerformTest(T.name_PreferredFamily))
            {
                bool bFound = false;

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.NameID == 16)
                        {
                            string sPrefFam = this.GetString(nr.PlatformID, nr.EncodingID, nr.LanguageID, 16);

                            string s = "platID = " + nr.PlatformID
                                       + ", encID = " + nr.EncodingID
                                       + ", langID = " + nr.LanguageID
                                       + ", nameID = " + nr.NameID
                                       + ", \"" + sPrefFam + "\"";
                            v.Info(T.name_PreferredFamily, I.name_I_Preferred_family_present, m_tag, s);

                            bFound = true;
                        }
                    }
                }

                if (!bFound)
                {
                    v.Info(T.name_PreferredFamily, I.name_I_Preferred_family_not_present, m_tag);
                }
            }

            if (v.PerformTest(T.name_PreferredSubfamily))
            {
                bool bFound = false;

                for (uint i = 0; i < NumberNameRecords; i++)
                {
                    NameRecord nr = GetNameRecord(i);
                    if (nr != null)
                    {
                        if (nr.NameID == 17)
                        {
                            string sPrefSubfam = this.GetString(nr.PlatformID, nr.EncodingID, nr.LanguageID, 17);

                            string s = "platID = " + nr.PlatformID
                                       + ", encID = " + nr.EncodingID
                                       + ", langID = " + nr.LanguageID
                                       + ", nameID = " + nr.NameID
                                       + ", \"" + sPrefSubfam + "\"";
                            v.Info(T.name_PreferredSubfamily, I.name_I_Preferred_subfamily_present, m_tag, s);

                            bFound = true;
                        }
                    }
                }

                if (!bFound)
                {
                    v.Info(T.name_PreferredSubfamily, I.name_I_Preferred_subfamily_not_present, m_tag);
                }
            }

            if (v.PerformTest(T.name_CopyrightConsistent))
            {
                bool bCopyrightOk = true;

                // get mac roman English Copyright string if present
                string sMac = GetString(1, 0, 0, 0);

                // get windows 3,0 English Copyright string if present
                string sWin3_0 = GetString(3, 0, 1033, 0);

                // get windows 3,1 English Copyright string if present
                string sWin3_1 = GetString(3, 1, 1033, 0);

                // get windows 3,10 English Copyright string if present
                string sWin3_10 = GetString(3, 10, 1033, 0);

                // compare strings

                if (sMac != null)
                {
                    if (sWin3_0 != null)
                    {
                        if (sWin3_0.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,0)='" + sMac + "', (3,0,1033,0)='" + sWin3_0 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }

                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,0)='" + sMac + "', (3,1,1033,0)='" + sWin3_1 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,0)='" + sMac + "', (3,10,1033,0)='" + sWin3_10 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }
                }

                if (sWin3_0 != null)
                {
                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,0)='" + sWin3_0 + "', (3,1,1033,0)='" + sWin3_1 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,0)='" + sWin3_0 + "', (3,10,1033,0)='" + sWin3_10 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }
                }

                if (sWin3_1 != null)
                {
                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_1) != 0)
                        {
                            string sDetails = "(3,1,1033,0)='" + sWin3_1 + "', (3,10,1033,0)='" + sWin3_10 + "'";
                            v.Warning(T.name_CopyrightConsistent, W.name_W_CopyrightInconsistent, m_tag, sDetails);
                            bCopyrightOk = false;
                        }
                    }
                }

                if (bCopyrightOk)
                {
                    v.Pass(T.name_CopyrightConsistent, P.name_P_CopyrightConsistent, m_tag);
                }
                else
                {
                    //bRet = false;
                }
            }

            if (v.PerformTest(T.name_TrademarkConsistent))
            {
                bool bTrademarkOk = true;

                // get mac roman English Trademark string if present
                string sMac = GetString(1, 0, 0, 7);

                // get windows 3,0 English Trademark string if present
                string sWin3_0 = GetString(3, 0, 1033, 7);

                // get windows 3,1 English Trademark string if present
                string sWin3_1 = GetString(3, 1, 1033, 7);

                // get windows 3,10 English Trademark string if present
                string sWin3_10 = GetString(3, 10, 1033, 7);

                // compare strings

                if (sMac != null)
                {
                    if (sWin3_0 != null)
                    {
                        if (sWin3_0.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,7)='" + sMac + "', (3,0,1033,7)='" + sWin3_0 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }

                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,7)='" + sMac + "', (3,1,1033,7)='" + sWin3_1 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,7)='" + sMac + "', (3,10,1033,7)='" + sWin3_10 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }
                }

                if (sWin3_0 != null)
                {
                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,7)='" + sWin3_0 + "', (3,1,1033,7)='" + sWin3_1 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,7)='" + sWin3_0 + "', (3,10,1033,7)='" + sWin3_10 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }
                }

                if (sWin3_1 != null)
                {
                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_1) != 0)
                        {
                            string sDetails = "(3,1,1033,7)='" + sWin3_1 + "', (3,10,1033,7)='" + sWin3_10 + "'";
                            v.Warning(T.name_TrademarkConsistent, W.name_W_TrademarkInconsistent, m_tag, sDetails);
                            bTrademarkOk = false;
                        }
                    }
                }

                if (bTrademarkOk)
                {
                    v.Pass(T.name_TrademarkConsistent, P.name_P_TrademarkConsistent, m_tag);
                }
                else
                {
                    //bRet = false;
                }
            }

            if (v.PerformTest(T.name_DescriptionConsistent))
            {
                bool bDescriptionOk = true;

                // get mac roman English Description string if present
                string sMac = GetString(1, 0, 0, 10);

                // get windows 3,0 English Description string if present
                string sWin3_0 = GetString(3, 0, 1033, 10);

                // get windows 3,1 English Description string if present
                string sWin3_1 = GetString(3, 1, 1033, 10);

                // get windows 3,10 English Description string if present
                string sWin3_10 = GetString(3, 10, 1033, 10);

                // compare strings

                if (sMac != null)
                {
                    if (sWin3_0 != null)
                    {
                        if (sWin3_0.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,10)='" + sMac + "', (3,0,1033,10)='" + sWin3_0 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }

                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,10)='" + sMac + "', (3,1,1033,10)='" + sWin3_1 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sMac) != 0)
                        {
                            string sDetails = "(1,0,0,10)='" + sMac + "', (3,10,1033,10)='" + sWin3_10 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }
                }

                if (sWin3_0 != null)
                {
                    if (sWin3_1 != null)
                    {
                        if (sWin3_1.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,10)='" + sWin3_0 + "', (3,1,1033,10)='" + sWin3_1 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }

                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_0) != 0)
                        {
                            string sDetails = "(3,0,1033,10)='" + sWin3_0 + "', (3,10,1033,10)='" + sWin3_10 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }
                }

                if (sWin3_1 != null)
                {
                    if (sWin3_10 != null)
                    {
                        if (sWin3_10.CompareTo(sWin3_1) != 0)
                        {
                            string sDetails = "(3,1,1033,10)='" + sWin3_1 + "', (3,10,1033,10)='" + sWin3_10 + "'";
                            v.Warning(T.name_DescriptionConsistent, W.name_W_DescriptionInconsistent, m_tag, sDetails);
                            bDescriptionOk = false;
                        }
                    }
                }

                if (bDescriptionOk)
                {
                    v.Pass(T.name_DescriptionConsistent, P.name_P_DescriptionConsistent, m_tag);
                }
                else
                {
                    //bRet = false;
                }
            }


            return(bRet);
        }
Example #9
0
        private void PrepareList()
        {
            Assembly assembly = typeof(NamesBookWidget).Assembly;

            using (Stream book_names = assembly.GetManifestResourceStream("Resources.bk_names.txt")) {
                using (StreamReader strd = new StreamReader(book_names, Encoding.UTF8)) {
                    while (strd.Peek() != -1)
                    {
                        string ns = strd.ReadLine().Trim();
                        if (ns != "")
                        {
                            string[] toks = ns.Split('/');
                            if (toks.Length >= 3)
                            {
                                NameRecord rec = new NameRecord();

                                rec.Name = toks[0].Trim();
                                rec.Desc = toks[2].Trim();
                                string st = toks[1].Trim();

                                st = ExtractFlags(st);
                                if (!string.IsNullOrEmpty(st))
                                {
                                    char c = st[0];
                                    switch (c)
                                    {
                                    case 'f':
                                        rec.Sex = GDMSex.svFemale;
                                        break;

                                    case 'm':
                                        rec.Sex = GDMSex.svMale;
                                        break;
                                    }
                                }

                                fNames.Add(rec);
                            }
                        }
                    }
                }
            }

            using (Stream book_names = assembly.GetManifestResourceStream("Resources.bk_names_cf.txt")) {
                using (StreamReader strd = new StreamReader(book_names, Encoding.UTF8)) {
                    while (strd.Peek() != -1)
                    {
                        string ns = strd.ReadLine().Trim();
                        fChurchFNames.Add(ns);
                    }
                }
            }

            using (Stream book_names = assembly.GetManifestResourceStream("Resources.bk_names_cm.txt")) {
                using (StreamReader strd = new StreamReader(book_names, Encoding.UTF8)) {
                    while (strd.Peek() != -1)
                    {
                        string ns = strd.ReadLine().Trim();
                        fChurchMNames.Add(ns);
                    }
                }
            }
        }
Example #10
0
        public void Read()
        {
            try
            {
#if DEBUG
                _fontData.Position = DirectoryEntry.Offset;
#endif
                bytes = new byte[DirectoryEntry.PaddedLength];
                Buffer.BlockCopy(_fontData.FontSource.Bytes, DirectoryEntry.Offset, bytes, 0, DirectoryEntry.Length);

                format       = _fontData.ReadUShort();
                count        = _fontData.ReadUShort();
                stringOffset = _fontData.ReadUShort();

                for (int idx = 0; idx < count; idx++)
                {
                    NameRecord nrec  = ReadNameRecord();
                    byte[]     value = new byte[nrec.length];
                    Buffer.BlockCopy(_fontData.FontSource.Bytes, DirectoryEntry.Offset + stringOffset + nrec.offset, value, 0, nrec.length);

                    //Debug.WriteLine(nrec.platformID.ToString());

                    // Read font name and style in US English.
                    if (nrec.platformID == 0 || nrec.platformID == 3)
                    {
                        // Font Family name. Up to four fonts can share the Font Family name,
                        // forming a font style linking group (regular, italic, bold, bold italic -
                        // as defined by OS/2.fsSelection bit settings).
                        if (nrec.nameID == 1 && nrec.languageID == 0x0409)
                        {
                            if (String.IsNullOrEmpty(Name))
                            {
                                Name = Encoding.BigEndianUnicode.GetString(value, 0, value.Length);
                            }
                        }

                        // Font Subfamily name. The Font Subfamily name distinguishes the font in a
                        // group with the same Font Family name (name ID 1). This is assumed to
                        // address style (italic, oblique) and weight (light, bold, black, etc.).
                        // A font with no particular differences in weight or style (e.g. medium weight,
                        // not italic and fsSelection bit 6 set) should have the string “Regular” stored in
                        // this position.
                        if (nrec.nameID == 2 && nrec.languageID == 0x0409)
                        {
                            if (String.IsNullOrEmpty(Style))
                            {
                                Style = Encoding.BigEndianUnicode.GetString(value, 0, value.Length);
                            }
                        }

                        // Full font name; a combination of strings 1 and 2, or a similar human-readable
                        // variant. If string 2 is "Regular", it is sometimes omitted from name ID 4.
                        if (nrec.nameID == 4 && nrec.languageID == 0x0409)
                        {
                            if (String.IsNullOrEmpty(FullFontName))
                            {
                                FullFontName = Encoding.BigEndianUnicode.GetString(value, 0, value.Length);
                            }
                        }
                    }
                }
                Debug.Assert(!String.IsNullOrEmpty(Name));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(PSSR.ErrorReadingFontData, ex);
            }
        }
Example #11
0
 NameRecord ReadNameRecord()
 {
     NameRecord nrec = new NameRecord();
     nrec.platformID = _fontData.ReadUShort();
     nrec.encodingID = _fontData.ReadUShort();
     nrec.languageID = _fontData.ReadUShort();
     nrec.nameID = _fontData.ReadUShort();
     nrec.length = _fontData.ReadUShort();
     nrec.offset = _fontData.ReadUShort();
     return nrec;
 }
 public Name(NameRecord nameRecord, int index)
 {
     _nameRecord = nameRecord;
     _index      = index;
 }
Example #13
0
 /* package */
 internal HSSFName(HSSFWorkbook book, NameRecord name) : this(book, name, null)
 {
 }
 public byte[] GetEncodedString(NameRecord nr)
 {
     byte[] buf = null;
     int offset = OffsetToStrings + nr.StringOffset;
     if (offset + nr.StringLength - 1 <= m_bufTable.GetLength())
     {
         buf = new byte[nr.StringLength];
         System.Buffer.BlockCopy(m_bufTable.GetBuffer(), offset, buf, 0, nr.StringLength);
     }
     return buf;
 }
        private TrueTypeFontTable ReadNameTable(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            NamingTable nt = new NamingTable(reader.Position);

            nt.Format       = reader.ReadUInt16();
            nt.Count        = reader.ReadUInt16();
            nt.StringOffset = reader.ReadUInt16();

            nt.Names = new NameEntryList();
            List <NameRecord> records = new List <NameRecord>();
            NameEntry         entry;

            if (nt.Count > 0)
            {
                for (int i = 0; i < nt.Count; i++)
                {
                    NameRecord rec = new NameRecord();
                    rec.PlatformID       = reader.ReadUInt16();
                    rec.EncodingID       = reader.ReadUInt16();
                    rec.LanguageID       = reader.ReadUInt16();
                    rec.NameID           = reader.ReadUInt16();
                    rec.StringLength     = reader.ReadUInt16();
                    rec.StringDataOffset = reader.ReadUInt16();

                    records.Add(rec);
                }

                long startStore = nt.FileOffset + nt.StringOffset;

                int currlang   = System.Globalization.CultureInfo.CurrentCulture.LCID;
                int parentlang = System.Globalization.CultureInfo.CurrentCulture.Parent != null ?
                                 System.Globalization.CultureInfo.CurrentCulture.Parent.LCID : 0;

                foreach (NameRecord rec in records)
                {
                    reader.Position = startStore + (long)rec.StringDataOffset;

                    if (rec.PlatformID == 0 || rec.PlatformID == 3)
                    {
                        rec.Value = reader.ReadUnicodeString(rec.StringLength);
                    }
                    else
                    {
                        rec.Value = reader.ReadString(rec.StringLength);
                    }

                    if (nt.Names.TryGetEntry(rec.NameID, out entry) == false)
                    {
                        entry        = new NameEntry();
                        entry.NameID = rec.NameID;
                        nt.Names.Add(entry);
                    }
                    entry.NameItems.Add(rec);

                    if (rec.LanguageID == 0)
                    {
                        entry.InvariantName = rec.Value;
                    }
                    else if (rec.LanguageID == currlang)
                    {
                        entry.LocalName = rec.Value;
                    }
                    else if (rec.LanguageID == parentlang && string.IsNullOrEmpty(entry.LocalName))
                    {
                        entry.LocalName = rec.Value;
                    }
                }
            }
            return(nt);
        }
Example #16
0
        protected override bool ReconstructTable()
        {
            var headBuffer = _woffDir.OrigTable;

            if (headBuffer == null || headBuffer.Length < 6)
            {
                return(false);
            }
            var length = headBuffer.Length;

            _tableBuffer = new WoffBuffer((uint)length);
            _tableBuffer.Copy(headBuffer);

            var fullFontName   = this.GetNameString();
            var fontFamilyName = this.GetFamilyString();
            var postScriptName = this.GetPostScriptString();

            // Check if the FullFontName and FontFamilyName are stripped from the compressed table data
            // Some tools (such as the dvisvgm – A fast DVI to SVG converter) strip both leaving only the PostScriptName
            if (!string.IsNullOrWhiteSpace(fullFontName) && !string.IsNullOrWhiteSpace(fontFamilyName))
            {
                return(true);
            }

            var fixFullFontName   = string.IsNullOrWhiteSpace(fullFontName);
            var fixFontFamilyName = string.IsNullOrWhiteSpace(fontFamilyName);

            // For the fix, we will just duplicate an existing name record, find out which one.
            ushort searchRecord = 0;

            if (!fixFullFontName)
            {
                searchRecord = (ushort)NameIdentifiers.FullFontName;
            }
            else if (!fixFontFamilyName)
            {
                searchRecord = (ushort)NameIdentifiers.FontFamilyName;
            }
            else if (!string.IsNullOrWhiteSpace(postScriptName))
            {
                searchRecord = (ushort)NameIdentifiers.PostScriptName;
            }
            else
            {
                // We cannot fix it...
                return(true);
            }

            int numRecords = this.NumberNameRecords;
            List <NameRecord> nameRecords = new List <NameRecord>(numRecords);

            for (uint i = 0; i < numRecords; i++)
            {
                NameRecord nr = GetNameRecord(i);
                if (nr != null)
                {
                    byte[] nameBytes = GetEncodedString(nr);
                    if (nameBytes != null && nameBytes.Length != 0)
                    {
                        nr.NameBytes  = nameBytes;
                        nr.NameString = DecodeString(nr.PlatformID, nr.EncodingID, nameBytes);

                        nameRecords.Add(nr);

                        if (searchRecord == nr.NameID)
                        {
                            if (fixFontFamilyName)
                            {
                                var nrFontFamily = nr.Clone();
                                nrFontFamily.NameID = (ushort)NameIdentifiers.FontFamilyName;

                                nameRecords.Add(nrFontFamily);
                            }
                            if (fixFullFontName)
                            {
                                var nrFullFont = nr.Clone();
                                nrFullFont.NameID = (ushort)NameIdentifiers.FullFontName;

                                nameRecords.Add(nrFullFont);
                            }
                        }
                    }
                }
            }

            numRecords = nameRecords.Count;

            List <byte[]> bytesNameString = new List <byte[]>();
            uint          lengthOfStrings = 0;
            ushort        offsetToStrings = (ushort)(6 + (numRecords * 12));

            for (int i = 0; i < numRecords; i++)
            {
                var    nrc        = nameRecords[i];
                byte[] byteString = nrc.NameBytes;
                bytesNameString.Add(byteString);
                lengthOfStrings += (ushort)byteString.Length;
            }

            // create a Motorola Byte Order buffer for the new table
            var tableBuffer = new WoffBuffer((uint)((ushort)FieldOffsets.NameRecords + numRecords * 12 + lengthOfStrings));

            // populate the buffer
            tableBuffer.SetUShort(this.FormatSelector, (uint)FieldOffsets.FormatSelector);
            tableBuffer.SetUShort((ushort)numRecords, (uint)FieldOffsets.NumberNameRecords);
            tableBuffer.SetUShort(offsetToStrings, (uint)FieldOffsets.OffsetToStrings);

            ushort nOffset = 0;

            // Write the NameRecords and Strings
            for (int i = 0; i < numRecords; i++)
            {
                byte[] namBytes = bytesNameString[i];

                uint startOffset = (uint)((ushort)(FieldOffsets.NameRecords) + i * NameRecord.SizeOf);

                tableBuffer.SetUShort((nameRecords[i]).PlatformID, startOffset + (ushort)NameRecord.FieldOffsets.PlatformID);
                tableBuffer.SetUShort((nameRecords[i]).EncodingID, startOffset + (ushort)NameRecord.FieldOffsets.EncodingID);
                tableBuffer.SetUShort((nameRecords[i]).LanguageID, startOffset + (ushort)NameRecord.FieldOffsets.LanguageID);
                tableBuffer.SetUShort((nameRecords[i]).NameID, startOffset + (ushort)NameRecord.FieldOffsets.NameID);
                tableBuffer.SetUShort((ushort)namBytes.Length, startOffset + (ushort)NameRecord.FieldOffsets.StringLength);
                tableBuffer.SetUShort(nOffset, startOffset + (ushort)NameRecord.FieldOffsets.StringOffset);

                //Write the string to the buffer
                for (int j = 0; j < namBytes.Length; j++)
                {
                    tableBuffer.SetByte(namBytes[j], (uint)(offsetToStrings + nOffset + j));
                }

                nOffset += (ushort)namBytes.Length;
            }


            _tableBuffer = tableBuffer;

            var nameBuffer = _tableBuffer.GetBuffer();

            _woffDir.OrigTable  = nameBuffer;
            _woffDir.OrigLength = (uint)nameBuffer.Length;
            _woffDir.RecalculateChecksum();

            return(true);
        }
Example #17
0
 /// <summary>
 /// Creates new HSSFName   - called by HSSFWorkbook to Create a sheet from
 /// scratch.
 /// </summary>
 /// <param name="book">lowlevel Workbook object associated with the sheet.</param>
 /// <param name="name">the Name Record</param>
 public HSSFName(HSSFWorkbook book, NameRecord name)
 {
     this.book            = book;
     this._definedNameRec = name;
 }
Example #18
0
        private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this

        public LinkTable(List <Record> inputList, int startIndex, WorkbookRecordList workbookRecordList, Dictionary <String, NameCommentRecord> commentRecords)
        {
            _workbookRecordList = workbookRecordList;
            RecordStream rs = new RecordStream(inputList, startIndex);

            List <object> temp = new List <object>();

            while (rs.PeekNextClass() == typeof(SupBookRecord))
            {
                temp.Add(new ExternalBookBlock(rs));
            }

            //_externalBookBlocks = new ExternalBookBlock[temp.Count];
            _externalBookBlocks = (ExternalBookBlock[])temp.ToArray();
            temp.Clear();

            if (_externalBookBlocks.Length > 0)
            {
                // If any ExternalBookBlock present, there is always 1 of ExternSheetRecord
                if (rs.PeekNextClass() != typeof(ExternSheetRecord))
                {
                    // not quite - if written by google docs
                    _externSheetRecord = null;
                }
                else
                {
                    _externSheetRecord = ReadExtSheetRecord(rs);
                }
            }
            else
            {
                _externSheetRecord = null;
            }

            _definedNames = new List <NameRecord>();
            // collect zero or more DEFINEDNAMEs id=0x18
            while (true)
            {
                Type nextClass = rs.PeekNextClass();
                if (nextClass == typeof(NameRecord))
                {
                    NameRecord nr = (NameRecord)rs.GetNext();
                    _definedNames.Add(nr);
                }
                else if (nextClass == typeof(NameCommentRecord))
                {
                    NameCommentRecord ncr = (NameCommentRecord)rs.GetNext();
                    //commentRecords.Add(ncr.NameText, ncr);
                    commentRecords[ncr.NameText] = ncr;
                }
                else
                {
                    break;
                }
            }

            _recordCount = rs.GetCountRead();
            for (int i = startIndex; i < startIndex + _recordCount; i++)
            {
                _workbookRecordList.Records.Add(inputList[i]);
            }
        }
Example #19
0
        public Name(BigEndianBinaryRaader reader) : base(reader)
        {
            base.startInit(reader);

            format       = reader.ReadUInt16();
            count        = reader.ReadUInt16();
            stringOffset = reader.ReadUInt16();

            for (ushort i = 0; i < count; i++)
            {
                NameRecord nameRecord = new NameRecord {
                    platformID = reader.ReadUInt16(),
                    encodingID = reader.ReadUInt16(),
                    languageID = reader.ReadUInt16(),
                    nameID     = reader.ReadUInt16(),
                    length     = reader.ReadUInt16(),
                    offset     = reader.ReadUInt16(),
                };

                nameRecords.Add(nameRecord);

                long origPos = reader.BaseStream.Position;
                reader.BaseStream.Position = stringOffset + nameRecord.offset + base.offsetPos;

                Encoding encoding = (nameRecord.encodingID == 1 || nameRecord.encodingID == 3) ? Encoding.BigEndianUnicode : Encoding.UTF8;

                string recStr = encoding.GetString(reader.ReadBytes(nameRecord.length), 0, nameRecord.length);

                switch ((NameIdKind)nameRecord.nameID)
                {
                case NameIdKind.CopyRightNotice:
                    this.ids.CopyRightNotice = recStr;
                    break;

                case NameIdKind.FontFamilyName:
                    this.ids.FontFamilyName = recStr;
                    break;

                case NameIdKind.FontSubfamilyName:
                    this.ids.FontSubfamilyName = recStr;
                    break;

                case NameIdKind.UniqueFontIden:
                    this.ids.UniqueFontIden = recStr;
                    break;

                case NameIdKind.FullFontName:
                    this.ids.FullFontName = recStr;
                    break;

                case NameIdKind.VersionString:
                    this.ids.VersionString = recStr;
                    break;

                case NameIdKind.PostScriptName:
                    this.ids.PostScriptName = recStr;
                    break;

                case NameIdKind.Trademark:
                    this.ids.Trademark = recStr;
                    break;

                case NameIdKind.ManufacturerName:
                    this.ids.ManufacturerName = recStr;
                    break;

                case NameIdKind.Designer:
                    this.ids.Designer = recStr;
                    break;

                case NameIdKind.Description:
                    this.ids.Description = recStr;
                    break;

                case NameIdKind.UrlVendor:
                    this.ids.UrlVendor = recStr;
                    break;

                case NameIdKind.UrlDesigner:
                    this.ids.UrlDesigner = recStr;
                    break;

                case NameIdKind.LicenseDescription:
                    this.ids.LicenseDescription = recStr;
                    break;

                case NameIdKind.LicenseInfoUrl:
                    this.ids.LicenseInfoUrl = recStr;
                    break;

                case NameIdKind.Reserved:
                    this.ids.Reserved = recStr;
                    break;

                case NameIdKind.TypographicFamilyName:
                    this.ids.TypographicFamilyName = recStr;
                    break;

                case NameIdKind.TypographyicSubfamilyName:
                    this.ids.TypographyicSubfamilyName = recStr;
                    break;

                case NameIdKind.CompatibleFull:
                    this.ids.CompatibleFull = recStr;
                    break;

                case NameIdKind.SampleText:
                    this.ids.SampleText = recStr;
                    break;

                case NameIdKind.PostScriptCID_FindfontName:
                    this.ids.PostScriptCID_FindfontName = recStr;
                    break;

                case NameIdKind.WWSFamilyName:
                    this.ids.WWSFamilyName = recStr;
                    break;

                case NameIdKind.WWSSubfamilyName:
                    this.ids.WWSSubfamilyName = recStr;
                    break;

                case NameIdKind.LightBackgroundPalette:
                    this.ids.LightBackgroundPalette = recStr;
                    break;

                case NameIdKind.DarkBackgroundPalette:
                    this.ids.DarkBackgroundPalette = recStr;
                    break;

                case NameIdKind.VariationsPostScriptNamePrefix:
                    this.ids.VariationsPostScriptNamePrefix = recStr;
                    break;
                }

                reader.BaseStream.Position = origPos;
            }

            base.endItit(reader);
        }
Example #20
0
 /// <summary>
 /// Creates new HSSFName   - called by HSSFWorkbook to Create a sheet from
 /// scratch.
 /// </summary>
 /// <param name="book">lowlevel Workbook object associated with the sheet.</param>
 /// <param name="name">the Name Record</param>
 /// <param name="comment"></param>
 internal HSSFName(HSSFWorkbook book, NameRecord name, NameCommentRecord comment)
 {
     this.book            = book;
     this._definedNameRec = name;
     _commentRec          = comment;
 }
Example #21
0
        void ParseNameTable(Stream stream, BinaryReader reader, TableHeader header)
        {
            stream.Position = header.Offset + 2;
            int recordCount = reader.ReadUInt16();
            int offset = reader.ReadUInt16();

            var recordList = new List<NameRecord>();
            for (int i = 0; i < recordCount; i++)
            {
                var record = new NameRecord()
                {
                    PlatformId = reader.ReadUInt16(),
                    EncodingId = reader.ReadUInt16(),
                    LanguageId = reader.ReadUInt16(),
                    NameId = reader.ReadUInt16(),
                    Length = reader.ReadUInt16(),
                    Offset = reader.ReadUInt16(),
                };
                recordList.Add(record);
            }

            var englishRecords = recordList.Where(record => record.PlatformId == 3 && record.EncodingId == 1 && record.LanguageId == 0x0409);

            var familyNameRecord = englishRecords.First(record => record.NameId == 1);
            stream.Position = header.Offset + offset + familyNameRecord.Offset;
            var bytes = reader.ReadBytes(familyNameRecord.Length);
            FamilyName = Encoding.BigEndianUnicode.GetString(bytes);

            var subfamilyNameRecord = englishRecords.First(record => record.NameId == 2);
            stream.Position = header.Offset + offset + subfamilyNameRecord.Offset;
            bytes = reader.ReadBytes(subfamilyNameRecord.Length);
            SubfamilyName = Encoding.BigEndianUnicode.GetString(bytes);

            var fontNameRecord = englishRecords.First(record => record.NameId == 4);
            stream.Position = header.Offset + offset + fontNameRecord.Offset;
            bytes = reader.ReadBytes(fontNameRecord.Length);
            FontName = Encoding.BigEndianUnicode.GetString(bytes);
        }