public static List <TextBaseElement> GetTextBaseList(this string String, CharList FontMap) { List <TextBaseElement> MyByteArrayList = new List <TextBaseElement>(); foreach (var a in Regex.Split(String, "(\r\n|\r|\n)")) { if (Regex.IsMatch(a, "\r\n|\r|\n")) { MyByteArrayList.Add(new TextBaseElement("System", new byte[] { 0x0A })); } else { foreach (var b in Regex.Split(a, @"({[^}]+})")) { if (Regex.IsMatch(b, @"{.+}")) { MyByteArrayList.Add(new TextBaseElement("System", Utilities.String.SplitString(b.Substring(1, b.Length - 2), ' '))); } else { MyByteArrayList.Add(new TextBaseElement("Text", FontMap.Encode(b, CharList.EncodeOptions.Bracket))); } } } } return(MyByteArrayList); }
public byte[] Get(CharList charlist) { byte[] returned = null; using (BinaryWriter writer = Utilities.IO.OpenWriteFile(new MemoryStream(), true)) { foreach (var a in list) { byte[] temp; int index = 0; do { temp = charlist.Encode(a.Item1.Substring(0, a.Item1.Length - index), CharList.EncodeOptions.OneChar); index++; } while (temp.Length > a.Item2); if (temp.Length == 0) { temp = new byte[] { 0x32 } } ; if (index > 1) { Logging.Write("", "StringList: Max length reach for \"" + a.Item1 + "\""); } writer.Write(temp); writer.Write(new byte[Utilities.Utilities.Alignment(temp.Length, a.Item2)]); } writer.BaseStream.Position = 0; returned = new byte[writer.BaseStream.Length]; writer.BaseStream.Read(returned, 0, returned.Length); } return(returned); } }