Exemple #1
0
        /// <summary>
        /// Reads unifont*.mul
        /// </summary>
        public static void Initialize()
        {
            for (int i = 0; i < _files.Length; i++)
            {
                string filePath = Files.GetFilePath(_files[i]);
                if (filePath == null)
                {
                    continue;
                }

                Fonts[i] = new UnicodeFont();
                using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var bin = new BinaryReader(fs))
                    {
                        for (int c = 0; c < 0x10000; ++c)
                        {
                            Fonts[i].Chars[c] = new UnicodeChar();
                            fs.Seek(c * 4, SeekOrigin.Begin);
                            int num2 = bin.ReadInt32();
                            if ((num2 >= fs.Length) || (num2 <= 0))
                            {
                                continue;
                            }
                            fs.Seek(num2, SeekOrigin.Begin);

                            sbyte xOffset = bin.ReadSByte();
                            sbyte yOffset = bin.ReadSByte();
                            int   width   = bin.ReadByte();
                            int   height  = bin.ReadByte();

                            Fonts[i].Chars[c].XOffset = xOffset;
                            Fonts[i].Chars[c].YOffset = yOffset;
                            Fonts[i].Chars[c].Width   = width;
                            Fonts[i].Chars[c].Height  = height;

                            if (!((width == 0) || (height == 0)))
                            {
                                Fonts[i].Chars[c].Bytes = bin.ReadBytes(height * (((width - 1) / 8) + 1));
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Reads unifont*.mul
 /// </summary>
 public static void Initialize()
 {
     for (int i = 0; i < m_files.Length; i++)
     {
         string filePath = Files.GetFilePath(m_files[i]);
         if (filePath == null)
             continue;
         Fonts[i] = new UnicodeFont();
         using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             using (BinaryReader bin = new BinaryReader(fs))
             {
                 for (int c = 0; c < 0x10000; ++c)
                 {
                     Fonts[i].Chars[c] = new UnicodeChar();
                     fs.Seek((long)((c) * 4), SeekOrigin.Begin);
                     int num2 = bin.ReadInt32();
                     if ((num2 >= fs.Length) || (num2 <= 0))
                         continue;
                     fs.Seek((long)num2, SeekOrigin.Begin);
                     sbyte xOffset = bin.ReadSByte();
                     sbyte yOffset = bin.ReadSByte();
                     int Width = bin.ReadByte();
                     int Height = bin.ReadByte();
                     Fonts[i].Chars[c].XOffset = xOffset;
                     Fonts[i].Chars[c].YOffset = yOffset;
                     Fonts[i].Chars[c].Width = Width;
                     Fonts[i].Chars[c].Height = Height;
                     if (!((Width == 0) || (Height == 0)))
                         Fonts[i].Chars[c].Bytes = bin.ReadBytes(Height * (((Width - 1) / 8) + 1));
                 }
             }
         }
     }
 }