Ejemplo n.º 1
0
 /// <summary>
 /// Runescape Font. Doesn't work!
 /// </summary>
 public RSFont(bool flag, string fontName, ArchiveParser titleArchive)
 {
     glyphPixels = new List<byte[]>();
     glyphWidth = new int[256];
     glyphHeight = new int[256];
     horizontalKerning = new int[256];
     verticalKerning = new int[256];
     charEffectiveWidth = new int[256];
     random = new Random();
     isStrikethrough = false;
     byte[] data = titleArchive.getFile(fontName + ".dat");
     byte[] index = titleArchive.getFile("index.dat");
     dataReader = new BigEndianBinaryReader(new MemoryStream(data));
     indexReader = new BigEndianBinaryReader(new MemoryStream(index));
     int pos = dataReader.ReadInt16() + 4;
     int k = indexReader.ReadByte();
     if (k > 0)
         pos += 3 * (k - 1);
     indexReader.BaseStream.Position = pos;
     for (int l = 0; l < 256; l++)
     {
         horizontalKerning[l] = indexReader.ReadChar();
         verticalKerning[l] = indexReader.ReadChar();
         int width = glyphWidth[l] = indexReader.ReadInt16();
         int height = glyphWidth[l] = indexReader.ReadInt16();
         int k1 = indexReader.ReadByte();
         int l1 = width * height;
         glyphPixels.Add(new byte[l1]);
         if (k1 == 0)
             for (int i = 0; i < l1; i++)
                 glyphPixels[l][i] = dataReader.ReadByte();
         else
             if (k1 == 1)
                 for (int j = 0; j < width; j++)
                     for (int l2 = 0; l2 < height; l2++)
                         glyphPixels[l][j + l2 * width] = dataReader.ReadByte();
         if (height > charHeight && l < 128)
             charHeight = height;
         horizontalKerning[l] = 1;
         charEffectiveWidth[l] = width + 2;
         int k2 = 0;
         for (int i = height / 7; i < height; i++)
             k2 += glyphPixels[l][i * width];
         if (k2 <= height / 7)
         {
             charEffectiveWidth[l]--;
             horizontalKerning[l] = 0;
         }
         k2 = 0;
         for (int j = height / 7; j < height; j++)
             k2 += glyphPixels[l][(width - 1) + j * width];
         if (k2 <= height / 7)
             charEffectiveWidth[l]--;
     }
     if (flag)
         charEffectiveWidth[32] = charEffectiveWidth[73];
     else
         charEffectiveWidth[32] = charEffectiveWidth[105];
 }
Ejemplo n.º 2
0
 public static string[] ParseDomainEnc(byte[] domainenc)
 {
     BigEndianBinaryReader br = new BigEndianBinaryReader(new MemoryStream(domainenc));
     int length = br.ReadInt32();
     List<char[]> domains = new List<char[]>();
     for (int j = 0; j < length; j++)
     {
         char[] val = new char[br.ReadByte()];
         for (int k = 0; k < val.GetLength(0); k++)
             val[k] = (char)br.ReadChar();
         domains.Add(val);
     }
     string[] s = new string[domains.Count];
     for (int c = 0; c < s.Length; c++)
         s[c] = new string(domains[c]);
     return s;
 }
Ejemplo n.º 3
0
 public static string[] ParseBadEnc(byte[] badenc)
 {
     BigEndianBinaryReader br = new BigEndianBinaryReader(new MemoryStream(badenc));
     int length = br.ReadInt32();
     List<char[]> bads = new List<char[]>();
     for (int i = 0; i < length; i++)
     {
         char[] val = new char[br.ReadChar()];
         for (int charid = 0; charid < val.Length; charid++)
             val[charid] = (char)br.ReadChar();
         bads.Add(val);
         byte[,] b1 = new byte[br.ReadByte(), 2];
         for (int l = 0; l < b1.Length/2; l++)
         {
             b1[l, 0] = (byte)br.ReadByte();
             b1[l, 1] = (byte)br.ReadByte();
         }
     }
     string[] s = new string[bads.Count];
     for(int c=0;c<s.Length;c++)
         s[c] = new string(bads[c]);
     return s;
 }