/// <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]; }
public ImageArchive(ref ArchiveParser jagArchive) { this.jagArchive = jagArchive; byte[] indexData = jagArchive.getFile("index.dat"); for (int i = 0; i < jagArchive.getTotalFiles(); i++) { int hash = jagArchive.getIdentifierAt(i); if (validImage(hash)) images.Add(new ImageGroup(indexData, jagArchive.getFileAt(i), true)); } }
public ImageArchive(ref ArchiveParser jagArchive) { this.jagArchive = jagArchive; byte[] indexData = jagArchive.getFile("index.dat"); for (int i = 0; i < jagArchive.getTotalFiles(); i++) { int hash = jagArchive.getIdentifierAt(i); if (validImage(hash)) { images.Add(new ImageGroup(indexData, jagArchive.getFileAt(i), true)); } } }
/// <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]; } }