diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs
index 9091e68..182c3b9 100644
--- a/McBitFont/Form1.cs
+++ b/McBitFont/Form1.cs
@@ -14,6 +14,7 @@ using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.InteropServices.ComTypes;
using System.Diagnostics;
+using System.Drawing.Drawing2D;
namespace McBitFont {
public partial class MainForm : Form {
@@ -247,6 +248,7 @@ namespace McBitFont {
}
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -262,6 +264,7 @@ namespace McBitFont {
}
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -304,6 +307,7 @@ namespace McBitFont {
}
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -319,6 +323,7 @@ namespace McBitFont {
}
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -328,6 +333,7 @@ namespace McBitFont {
f.data[i, j] = !f.data[i, j];
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -346,6 +352,7 @@ namespace McBitFont {
b--;
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -364,6 +371,7 @@ namespace McBitFont {
b--;
}
}
+ modified = true;
dotPanel.Refresh();
}
@@ -451,6 +459,29 @@ namespace McBitFont {
return enc.GetString(new byte[] { (byte)code });
}
+ private FrameMiniature fillFrame(FrameMiniature ff, Font font, int sx, int sy) {
+ string s = decodeSymbol(ff.code);
+ Bitmap bmp = new Bitmap(ff.width, ff.height);
+ Graphics g = Graphics.FromImage(bmp);
+ g.Clear(Color.White);
+ g.SmoothingMode = SmoothingMode.None;
+ g.InterpolationMode = InterpolationMode.NearestNeighbor;
+ g.PixelOffsetMode = PixelOffsetMode.Half;
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ g.DrawString(s, font, Brushes.Black, sx, sy);
+ g.Flush();
+
+ for (int i = 0; i < ff.width; i++)
+ for (int j = 0; j < ff.height; j++) {
+ if (bmp.GetPixel(i, j).Name != "ffffffff")
+ ff.data[i, j] = true;
+ }
+
+ bmp.Dispose();
+ g.Dispose();
+ return ff;
+ }
+
private void newToolStripMenuItem_Click(object sender, EventArgs e) {
if (prjModified) {
if (MessageBox.Show("The project is modified.\nDo you want to save it first?", "Project was modified!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
@@ -458,7 +489,7 @@ namespace McBitFont {
return;
}
}
- New form = new New();
+ New form = new New(this);
if (form.ShowDialog() == DialogResult.OK) {
frames.Clear();
miniList.Clear();
@@ -469,6 +500,7 @@ namespace McBitFont {
int newh = (int)form.nudNewY.Value;
nudX.Value = neww;
nudY.Value = newh;
+ FrameMiniature newf;
if (form.cbSingle.Checked) {
frames.Add( new FrameMiniature(0, neww, newh));
//f = frames.Find(x => x.code == 0);
@@ -477,16 +509,25 @@ namespace McBitFont {
} else {
int i;
if (form.cbNotPrintable.Checked) {
- for (i=0; i < 32; i++)
- frames.Add(new FrameMiniature(i, neww, newh));
+ for (i = 0; i < 32; i++) {
+ newf = new FrameMiniature(i, neww, newh);
+ if (form.cbFontBased.Checked) newf = fillFrame(newf, form.dlgFont.Font, (int)form.nudShiftX.Value, (int)form.nudShiftY.Value);
+ frames.Add(newf);
+ }
}
if (form.cbLatin.Checked) {
- for (i = 32; i < 128; i++)
- frames.Add(new FrameMiniature(i, neww, newh));
+ for (i = 32; i < 128; i++) {
+ newf = new FrameMiniature(i, neww, newh);
+ if (form.cbFontBased.Checked) newf = fillFrame(newf, form.dlgFont.Font, (int)form.nudShiftX.Value, (int)form.nudShiftY.Value);
+ frames.Add(newf);
+ }
}
if (form.cbExtended.Checked) {
- for (i = 128; i < 256; i++)
- frames.Add(new FrameMiniature(i, neww, newh));
+ for (i = 128; i < 256; i++) {
+ newf = new FrameMiniature(i, neww, newh);
+ if (form.cbFontBased.Checked) newf = fillFrame(newf, form.dlgFont.Font, (int)form.nudShiftX.Value, (int)form.nudShiftY.Value);
+ frames.Add(newf);
+ }
}
monospaced = form.rbMono.Checked;
}
diff --git a/McBitFont/New.Designer.cs b/McBitFont/New.Designer.cs
index 60537f8..659a399 100644
--- a/McBitFont/New.Designer.cs
+++ b/McBitFont/New.Designer.cs
@@ -38,13 +38,37 @@
this.cbSingle = new System.Windows.Forms.CheckBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.cbEncoding = new System.Windows.Forms.ComboBox();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.pbChar2 = new System.Windows.Forms.PictureBox();
+ this.pbChar1 = new System.Windows.Forms.PictureBox();
+ this.btnFont = new System.Windows.Forms.Button();
+ this.dlgFont = new System.Windows.Forms.FontDialog();
+ this.cbFontBased = new System.Windows.Forms.CheckBox();
+ this.lblFont = new System.Windows.Forms.Label();
+ this.nudShiftX = new System.Windows.Forms.NumericUpDown();
+ this.nudShiftY = new System.Windows.Forms.NumericUpDown();
+ this.lblShiftX = new System.Windows.Forms.Label();
+ this.lblShiftY = new System.Windows.Forms.Label();
+ this.pnlFont = new System.Windows.Forms.Panel();
+ this.nudChar2 = new System.Windows.Forms.NumericUpDown();
+ this.nudChar1 = new System.Windows.Forms.NumericUpDown();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.nudNewX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudNewY)).BeginInit();
+ this.panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pbChar2)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pbChar1)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudShiftX)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudShiftY)).BeginInit();
+ this.pnlFont.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nudChar2)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudChar1)).BeginInit();
this.SuspendLayout();
//
// nudNewX
//
- this.nudNewX.Location = new System.Drawing.Point(74, 19);
+ this.nudNewX.Location = new System.Drawing.Point(68, 32);
this.nudNewX.Maximum = new decimal(new int[] {
255,
0,
@@ -63,11 +87,12 @@
0,
0,
0});
+ this.nudNewX.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
this.nudNewX.Enter += new System.EventHandler(this.nudFocus);
//
// nudNewY
//
- this.nudNewY.Location = new System.Drawing.Point(74, 45);
+ this.nudNewY.Location = new System.Drawing.Point(68, 58);
this.nudNewY.Maximum = new decimal(new int[] {
255,
0,
@@ -86,12 +111,13 @@
0,
0,
0});
+ this.nudNewY.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
this.nudNewY.Enter += new System.EventHandler(this.nudFocus);
//
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(30, 21);
+ this.label1.Location = new System.Drawing.Point(24, 34);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 13);
this.label1.TabIndex = 2;
@@ -101,7 +127,7 @@
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(27, 47);
+ this.label2.Location = new System.Drawing.Point(21, 60);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 13);
this.label2.TabIndex = 3;
@@ -112,7 +138,7 @@
//
this.rbMono.AutoSize = true;
this.rbMono.Checked = true;
- this.rbMono.Location = new System.Drawing.Point(30, 71);
+ this.rbMono.Location = new System.Drawing.Point(24, 84);
this.rbMono.Name = "rbMono";
this.rbMono.Size = new System.Drawing.Size(87, 17);
this.rbMono.TabIndex = 4;
@@ -123,7 +149,7 @@
// rbVar
//
this.rbVar.AutoSize = true;
- this.rbVar.Location = new System.Drawing.Point(30, 94);
+ this.rbVar.Location = new System.Drawing.Point(24, 107);
this.rbVar.Name = "rbVar";
this.rbVar.Size = new System.Drawing.Size(91, 17);
this.rbVar.TabIndex = 5;
@@ -133,7 +159,7 @@
// cbNotPrintable
//
this.cbNotPrintable.AutoSize = true;
- this.cbNotPrintable.Location = new System.Drawing.Point(146, 35);
+ this.cbNotPrintable.Location = new System.Drawing.Point(140, 54);
this.cbNotPrintable.Name = "cbNotPrintable";
this.cbNotPrintable.Size = new System.Drawing.Size(116, 17);
this.cbNotPrintable.TabIndex = 7;
@@ -145,7 +171,7 @@
this.cbLatin.AutoSize = true;
this.cbLatin.Checked = true;
this.cbLatin.CheckState = System.Windows.Forms.CheckState.Checked;
- this.cbLatin.Location = new System.Drawing.Point(146, 58);
+ this.cbLatin.Location = new System.Drawing.Point(140, 77);
this.cbLatin.Name = "cbLatin";
this.cbLatin.Size = new System.Drawing.Size(91, 17);
this.cbLatin.TabIndex = 8;
@@ -155,7 +181,7 @@
// cbExtended
//
this.cbExtended.AutoSize = true;
- this.cbExtended.Location = new System.Drawing.Point(146, 81);
+ this.cbExtended.Location = new System.Drawing.Point(140, 100);
this.cbExtended.Name = "cbExtended";
this.cbExtended.Size = new System.Drawing.Size(119, 17);
this.cbExtended.TabIndex = 9;
@@ -165,7 +191,8 @@
//
// btnOK
//
- this.btnOK.Location = new System.Drawing.Point(56, 143);
+ this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.btnOK.Location = new System.Drawing.Point(47, 178);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 10;
@@ -175,8 +202,9 @@
//
// btnCancel
//
+ this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(165, 143);
+ this.btnCancel.Location = new System.Drawing.Point(140, 178);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 11;
@@ -187,7 +215,7 @@
// cbSingle
//
this.cbSingle.AutoSize = true;
- this.cbSingle.Location = new System.Drawing.Point(146, 12);
+ this.cbSingle.Location = new System.Drawing.Point(140, 31);
this.cbSingle.Name = "cbSingle";
this.cbSingle.Size = new System.Drawing.Size(84, 17);
this.cbSingle.TabIndex = 12;
@@ -207,17 +235,206 @@
this.cbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbEncoding.Enabled = false;
this.cbEncoding.FormattingEnabled = true;
- this.cbEncoding.Location = new System.Drawing.Point(146, 104);
+ this.cbEncoding.Location = new System.Drawing.Point(140, 123);
this.cbEncoding.Name = "cbEncoding";
this.cbEncoding.Size = new System.Drawing.Size(121, 21);
this.cbEncoding.TabIndex = 13;
//
+ // panel1
+ //
+ this.panel1.Controls.Add(this.pbChar2);
+ this.panel1.Controls.Add(this.pbChar1);
+ this.panel1.Location = new System.Drawing.Point(6, 24);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(200, 124);
+ this.panel1.TabIndex = 14;
+ //
+ // pbChar2
+ //
+ this.pbChar2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.pbChar2.Location = new System.Drawing.Point(100, 0);
+ this.pbChar2.Name = "pbChar2";
+ this.pbChar2.Size = new System.Drawing.Size(100, 124);
+ this.pbChar2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+ this.pbChar2.TabIndex = 1;
+ this.pbChar2.TabStop = false;
+ //
+ // pbChar1
+ //
+ this.pbChar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.pbChar1.Location = new System.Drawing.Point(0, 0);
+ this.pbChar1.Name = "pbChar1";
+ this.pbChar1.Size = new System.Drawing.Size(100, 124);
+ this.pbChar1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+ this.pbChar1.TabIndex = 0;
+ this.pbChar1.TabStop = false;
+ //
+ // btnFont
+ //
+ this.btnFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.btnFont.Location = new System.Drawing.Point(6, 178);
+ this.btnFont.Name = "btnFont";
+ this.btnFont.Size = new System.Drawing.Size(71, 23);
+ this.btnFont.TabIndex = 15;
+ this.btnFont.Text = "Font ...";
+ this.btnFont.UseVisualStyleBackColor = true;
+ this.btnFont.Click += new System.EventHandler(this.btnFont_Click);
+ //
+ // dlgFont
+ //
+ this.dlgFont.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
+ this.dlgFont.ShowEffects = false;
+ //
+ // cbFontBased
+ //
+ this.cbFontBased.AutoSize = true;
+ this.cbFontBased.Location = new System.Drawing.Point(24, 130);
+ this.cbFontBased.Name = "cbFontBased";
+ this.cbFontBased.Size = new System.Drawing.Size(101, 17);
+ this.cbFontBased.TabIndex = 16;
+ this.cbFontBased.Text = "Based on a font";
+ this.cbFontBased.UseVisualStyleBackColor = true;
+ this.cbFontBased.CheckedChanged += new System.EventHandler(this.cbFontBased_CheckedChanged);
+ //
+ // lblFont
+ //
+ this.lblFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.lblFont.Location = new System.Drawing.Point(83, 183);
+ this.lblFont.Name = "lblFont";
+ this.lblFont.Size = new System.Drawing.Size(123, 18);
+ this.lblFont.TabIndex = 17;
+ this.lblFont.Text = "font";
+ //
+ // nudShiftX
+ //
+ this.nudShiftX.Location = new System.Drawing.Point(61, 2);
+ this.nudShiftX.Minimum = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ -2147483648});
+ this.nudShiftX.Name = "nudShiftX";
+ this.nudShiftX.Size = new System.Drawing.Size(45, 20);
+ this.nudShiftX.TabIndex = 18;
+ this.nudShiftX.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
+ //
+ // nudShiftY
+ //
+ this.nudShiftY.Location = new System.Drawing.Point(161, 2);
+ this.nudShiftY.Minimum = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ -2147483648});
+ this.nudShiftY.Name = "nudShiftY";
+ this.nudShiftY.Size = new System.Drawing.Size(45, 20);
+ this.nudShiftY.TabIndex = 19;
+ this.nudShiftY.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
+ //
+ // lblShiftX
+ //
+ this.lblShiftX.AutoSize = true;
+ this.lblShiftX.Location = new System.Drawing.Point(14, 4);
+ this.lblShiftX.Name = "lblShiftX";
+ this.lblShiftX.Size = new System.Drawing.Size(41, 13);
+ this.lblShiftX.TabIndex = 20;
+ this.lblShiftX.Text = "Shift X:";
+ this.lblShiftX.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblShiftY
+ //
+ this.lblShiftY.AutoSize = true;
+ this.lblShiftY.Location = new System.Drawing.Point(114, 4);
+ this.lblShiftY.Name = "lblShiftY";
+ this.lblShiftY.Size = new System.Drawing.Size(41, 13);
+ this.lblShiftY.TabIndex = 21;
+ this.lblShiftY.Text = "Shift Y:";
+ this.lblShiftY.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // pnlFont
+ //
+ this.pnlFont.Controls.Add(this.label4);
+ this.pnlFont.Controls.Add(this.label3);
+ this.pnlFont.Controls.Add(this.nudChar2);
+ this.pnlFont.Controls.Add(this.nudChar1);
+ this.pnlFont.Controls.Add(this.lblShiftX);
+ this.pnlFont.Controls.Add(this.lblShiftY);
+ this.pnlFont.Controls.Add(this.panel1);
+ this.pnlFont.Controls.Add(this.btnFont);
+ this.pnlFont.Controls.Add(this.nudShiftY);
+ this.pnlFont.Controls.Add(this.lblFont);
+ this.pnlFont.Controls.Add(this.nudShiftX);
+ this.pnlFont.Dock = System.Windows.Forms.DockStyle.Right;
+ this.pnlFont.Location = new System.Drawing.Point(270, 0);
+ this.pnlFont.Name = "pnlFont";
+ this.pnlFont.Size = new System.Drawing.Size(214, 211);
+ this.pnlFont.TabIndex = 22;
+ this.pnlFont.Visible = false;
+ //
+ // nudChar2
+ //
+ this.nudChar2.Location = new System.Drawing.Point(161, 149);
+ this.nudChar2.Maximum = new decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+ this.nudChar2.Name = "nudChar2";
+ this.nudChar2.Size = new System.Drawing.Size(45, 20);
+ this.nudChar2.TabIndex = 23;
+ this.nudChar2.Value = new decimal(new int[] {
+ 97,
+ 0,
+ 0,
+ 0});
+ this.nudChar2.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
+ //
+ // nudChar1
+ //
+ this.nudChar1.Location = new System.Drawing.Point(61, 149);
+ this.nudChar1.Maximum = new decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+ this.nudChar1.Name = "nudChar1";
+ this.nudChar1.Size = new System.Drawing.Size(45, 20);
+ this.nudChar1.TabIndex = 22;
+ this.nudChar1.Value = new decimal(new int[] {
+ 65,
+ 0,
+ 0,
+ 0});
+ this.nudChar1.ValueChanged += new System.EventHandler(this.nudNewX_ValueChanged);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(14, 152);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(45, 13);
+ this.label3.TabIndex = 24;
+ this.label3.Text = "Sample:";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(112, 152);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(45, 13);
+ this.label4.TabIndex = 25;
+ this.label4.Text = "Sample:";
+ this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
// New
//
this.AcceptButton = this.btnOK;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(284, 181);
+ this.ClientSize = new System.Drawing.Size(484, 211);
+ this.Controls.Add(this.pnlFont);
+ this.Controls.Add(this.cbFontBased);
this.Controls.Add(this.cbEncoding);
this.Controls.Add(this.cbSingle);
this.Controls.Add(this.btnCancel);
@@ -233,7 +450,6 @@
this.Controls.Add(this.nudNewX);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(300, 220);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(300, 220);
this.Name = "New";
@@ -244,6 +460,15 @@
this.Load += new System.EventHandler(this.New_Load);
((System.ComponentModel.ISupportInitialize)(this.nudNewX)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudNewY)).EndInit();
+ this.panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pbChar2)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pbChar1)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudShiftX)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudShiftY)).EndInit();
+ this.pnlFont.ResumeLayout(false);
+ this.pnlFont.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nudChar2)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nudChar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -265,5 +490,21 @@
public System.Windows.Forms.CheckBox cbSingle;
private System.Windows.Forms.ToolTip toolTip1;
public System.Windows.Forms.ComboBox cbEncoding;
+ public System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.PictureBox pbChar2;
+ private System.Windows.Forms.PictureBox pbChar1;
+ private System.Windows.Forms.Button btnFont;
+ public System.Windows.Forms.FontDialog dlgFont;
+ public System.Windows.Forms.CheckBox cbFontBased;
+ private System.Windows.Forms.Label lblFont;
+ public System.Windows.Forms.NumericUpDown nudShiftX;
+ public System.Windows.Forms.NumericUpDown nudShiftY;
+ private System.Windows.Forms.Label lblShiftX;
+ private System.Windows.Forms.Label lblShiftY;
+ private System.Windows.Forms.Panel pnlFont;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label3;
+ public System.Windows.Forms.NumericUpDown nudChar2;
+ public System.Windows.Forms.NumericUpDown nudChar1;
}
}
\ No newline at end of file
diff --git a/McBitFont/New.cs b/McBitFont/New.cs
index 674982f..add3740 100644
--- a/McBitFont/New.cs
+++ b/McBitFont/New.cs
@@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using static System.Net.Mime.MediaTypeNames;
namespace McBitFont {
public partial class New : Form {
@@ -25,18 +27,26 @@ namespace McBitFont {
}
}
+ private MainForm mainForm;
- public New() {
+
+ public New(MainForm form) {
InitializeComponent();
+ mainForm = form;
+ this.Width = 300; this.Height = 250;
}
private void cbSingle_CheckedChanged(object sender, EventArgs e) {
bool c = !cbSingle.Checked;
+ bool f = cbFontBased.Checked;
cbNotPrintable.Enabled = c;
cbLatin.Enabled = c;
cbExtended.Enabled = c;
+ cbFontBased.Enabled = c;
rbMono.Enabled = c;
rbVar.Enabled = c;
+ pnlFont.Visible = c && f;
+ this.Width = c && f ? 500 : 300;
}
private void New_Load(object sender, EventArgs e) {
@@ -59,6 +69,78 @@ namespace McBitFont {
cbEncoding.Items.Add(new EncodingItem(1256, "Arabic"));
cbEncoding.Items.Add(new EncodingItem(1257, "Baltic"));
cbEncoding.SelectedIndex = 1;
+
+ lblFont.Text = dlgFont.Font.Name + " " + dlgFont.Font.Size.ToString();
+ updateChars();
+ }
+
+ private void updateChars() {
+ int neww, newh;
+ const int pbw = 100;
+ const int pbh = 124;
+ int w = (int)nudNewX.Value;
+ int h = (int)nudNewY.Value;
+ int difw = pbw - w;
+ int difh = pbh - h;
+ string[] chars = { "A", "a" };
+ PictureBox[] pbs = { pbChar1, pbChar2 };
+
+ if (difw > 0) {
+ if (difh > 0) {
+ //not wider, not taller
+ if (difw < difh) {
+ neww = pbw;
+ newh = h * pbw / w;
+ } else {
+ newh = pbh;
+ neww = w * pbh / h;
+ }
+ } else {
+ // not wider, taller
+ newh = pbh;
+ neww = w * pbh / h;
+ }
+ } else {
+ if (difh > 0) {
+ //wider, not taller
+ neww = pbw;
+ newh = h * pbw / w;
+ } else {
+ // wider, taller
+ if (difw > difh) {
+ neww = pbw;
+ newh = h * pbw / w;
+ } else {
+ newh = pbh;
+ neww = w * pbh / h;
+ }
+ }
+ }
+
+
+ Bitmap bmp, result;
+ Graphics g;
+ chars[0] = mainForm.decodeSymbol((int)nudChar1.Value);
+ chars[1] = mainForm.decodeSymbol((int)nudChar2.Value);
+ for (int i = 0; i < 2; i++) {
+ bmp = new Bitmap((int)nudNewX.Value, (int)nudNewY.Value);
+ g = Graphics.FromImage(bmp);
+ g.Clear(Color.White);
+ g.SmoothingMode = SmoothingMode.None;
+ g.InterpolationMode = InterpolationMode.NearestNeighbor;
+ g.PixelOffsetMode = PixelOffsetMode.Half;
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ g.DrawString(chars[i], dlgFont.Font, Brushes.Black, (int)nudShiftX.Value, (int)nudShiftY.Value);
+ g.Flush();
+
+ result = new Bitmap(neww, newh);
+ using (Graphics gr = Graphics.FromImage(result)) {
+ gr.InterpolationMode = InterpolationMode.NearestNeighbor;
+ gr.PixelOffsetMode = PixelOffsetMode.Half;
+ gr.DrawImage(bmp, 0, 0, neww, newh);
+ }
+ pbs[i].Image = result;
+ }
}
private void btnCancel_Click(object sender, EventArgs e) {
@@ -78,5 +160,23 @@ namespace McBitFont {
private void cbExtended_CheckedChanged(object sender, EventArgs e) {
cbEncoding.Enabled = cbExtended.Checked;
}
+
+ private void cbFontBased_CheckedChanged(object sender, EventArgs e) {
+ bool c = !cbSingle.Checked;
+ bool f = cbFontBased.Checked;
+ pnlFont.Visible = c && f;
+ this.Width = c && f ? 500 : 300;
+ }
+
+ private void btnFont_Click(object sender, EventArgs e) {
+ if (dlgFont.ShowDialog() == DialogResult.OK) {
+ lblFont.Text = dlgFont.Font.Name + " " + dlgFont.Font.Size.ToString();
+ updateChars();
+ }
+ }
+
+ private void nudNewX_ValueChanged(object sender, EventArgs e) {
+ updateChars();
+ }
}
}
diff --git a/McBitFont/New.resx b/McBitFont/New.resx
index df8339b..5f989c5 100644
--- a/McBitFont/New.resx
+++ b/McBitFont/New.resx
@@ -120,4 +120,7 @@
17, 17
+
+ 114, 17
+
\ No newline at end of file
diff --git a/icons_9x9.mbf b/examples/icons_9x9.mbf
similarity index 100%
rename from icons_9x9.mbf
rename to examples/icons_9x9.mbf