public static FontProvider ProcessArgs(string[] args) { // -fontImage "emojidark12.png" -charSize "8x9" -dither 0 string fontImagePath = ""; Size charSize = new Size(8, 8); IDitherProvider dither = null; int leftTopPadding = 0; args.ProcessArg("-leftTopPadding", s => { leftTopPadding = int.Parse(s); }); args.ProcessArg("-fontimage", s => { fontImagePath = s; }); args.ProcessArg("-charsize", s => { charSize = new Size(int.Parse(s.Split('x')[0]), int.Parse(s.Split('x')[1])); }); args.ProcessArg("-dither", s => { double amt = double.Parse(s); if (amt > 0) { dither = new Bayer8DitherProvider(amt); } else { Log.WriteLine("Ignoring dither value: {0}", s); } }); return(new FontProvider(fontImagePath, charSize, leftTopPadding, dither)); }
//public virtual void WriteConfig(StringBuilder sb) //{ // sb.AppendLine("fontType=Normal"); // sb.AppendLine(string.Format("charWidth={0}", this.CharSizeNoPadding.Width)); // sb.AppendLine(string.Format("charHeight={0}", this.CharSizeNoPadding.Height)); // sb.AppendLine(string.Format("fontFileName={0}", this.FontFileName)); // sb.AppendLine(string.Format("leftTopPadding={0}", this.LeftTopPadding)); // sb.AppendLine(string.Format("ditherStrength={0}", this.DitherProvider.Strength)); //} public FontProvider(string fontFileName, Size charSize, int leftTopPadding = 0, IDitherProvider dither = null) { this.FontFileName = fontFileName; this.CharSizeNoPadding = charSize; this.LeftTopPadding = LeftTopPadding; this.DitherProvider = dither; this.Image = System.Drawing.Image.FromFile(fontFileName); this.Bitmap = new Bitmap(this.Image); this.CharSizeWithPadding = new Size(charSize.Width + leftTopPadding, charSize.Height + leftTopPadding); this.SizeInChars = Utils.Div(this.Image.Size, this.CharSizeWithPadding); this.CharCount = Utils.Product(this.SizeInChars); }