WIP: working on text formats
This commit is contained in:
1
McBitFont/Export.Designer.cs
generated
1
McBitFont/Export.Designer.cs
generated
@@ -65,6 +65,7 @@
|
|||||||
this.txtOutput.Size = new System.Drawing.Size(529, 507);
|
this.txtOutput.Size = new System.Drawing.Size(529, 507);
|
||||||
this.txtOutput.TabIndex = 0;
|
this.txtOutput.TabIndex = 0;
|
||||||
this.txtOutput.Text = "";
|
this.txtOutput.Text = "";
|
||||||
|
this.txtOutput.WordWrap = false;
|
||||||
//
|
//
|
||||||
// gbScan
|
// gbScan
|
||||||
//
|
//
|
||||||
|
@@ -81,6 +81,9 @@ namespace McBitFont {
|
|||||||
bool hdr = cbHeader.Checked;
|
bool hdr = cbHeader.Checked;
|
||||||
int lines = cbLines.SelectedIndex;
|
int lines = cbLines.SelectedIndex;
|
||||||
int format = cbFormat.SelectedIndex;
|
int format = cbFormat.SelectedIndex;
|
||||||
|
bool mono = mainForm.monospaced;
|
||||||
|
|
||||||
|
int imin, jmin, imax, jmax, idir, jdir;
|
||||||
|
|
||||||
if (com) {
|
if (com) {
|
||||||
//Header comments
|
//Header comments
|
||||||
@@ -102,7 +105,7 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int imin, jmin, imax, jmax, idir, jdir;
|
//Figure out mins and maxes
|
||||||
if (cbOrder.SelectedIndex == 0) {
|
if (cbOrder.SelectedIndex == 0) {
|
||||||
if (cbHDir.SelectedIndex == 0) {
|
if (cbHDir.SelectedIndex == 0) {
|
||||||
// Columns; Left to right
|
// Columns; Left to right
|
||||||
@@ -192,7 +195,19 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Array definition
|
// Array definition
|
||||||
if ( format == 0 || format == 1 ) output += "const " + dataType + " " + mainForm.prjName + "[] = {\n";
|
if ( format == 0 || format == 1 ) output += "const " + dataType + " " + mainForm.prjName + "[]" + (format==1?"[]":"") + " = {\n";
|
||||||
|
|
||||||
|
// Should we add the meta header?
|
||||||
|
if (hdr) {
|
||||||
|
output +=
|
||||||
|
" // Meta header\n" +
|
||||||
|
" " + (mono ? mainForm.frames.First().width.ToString() : "0") + ", // Font width in pixels; 0 - variable width\n" +
|
||||||
|
" " + mainForm.frames.First().height.ToString() + ", // Font height in pixels\n" +
|
||||||
|
" 0, // Font space (between symbols) in pixels\n" +
|
||||||
|
" " + mainForm.frames.First().code.ToString() + ", // First character code\n" +
|
||||||
|
" " + mainForm.frames.Last().code.ToString() + ", // Last character code\n"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
// Brackets for 2D array definition
|
// Brackets for 2D array definition
|
||||||
string obracket = format == 1 ? "{ " : "";
|
string obracket = format == 1 ? "{ " : "";
|
||||||
@@ -202,9 +217,9 @@ namespace McBitFont {
|
|||||||
int numcount = 0;
|
int numcount = 0;
|
||||||
|
|
||||||
if (com) output += " // Data:\n";
|
if (com) output += " // Data:\n";
|
||||||
|
MainForm.FrameMiniature flast = mainForm.frames.Last();
|
||||||
foreach ( MainForm.FrameMiniature f in mainForm.frames) {
|
foreach ( MainForm.FrameMiniature f in mainForm.frames) {
|
||||||
// For each frame
|
// For each frame
|
||||||
string str;
|
|
||||||
uint b = 0; // current number bits
|
uint b = 0; // current number bits
|
||||||
int t, x, y; // t - calculated bit number; x - actual x; y - actual y
|
int t, x, y; // t - calculated bit number; x - actual x; y - actual y
|
||||||
|
|
||||||
@@ -218,6 +233,49 @@ namespace McBitFont {
|
|||||||
output += " ";
|
output += " ";
|
||||||
numcount = 0;
|
numcount = 0;
|
||||||
}
|
}
|
||||||
|
if (!mono && mainForm.frames.Count > 1) {
|
||||||
|
// Not a single image; Variable width font - lets post the width as a 1st number
|
||||||
|
|
||||||
|
// Should we post a prefix to the number?
|
||||||
|
pref = (!cbZeroes.Checked && ((f.width < 10 && nbase == 16) || (f.width < 2 && nbase == 2))) ? "" : prefix;
|
||||||
|
output += " " + pref + Convert.ToString(f.width, nbase).PadLeft(pad, '0') + "," + (lines == 1 ? " " : "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Figure out mins and maxes for variable width fonts
|
||||||
|
if (!mono) {
|
||||||
|
if (cbOrder.SelectedIndex == 0) {
|
||||||
|
if (cbHDir.SelectedIndex == 0) {
|
||||||
|
// Columns; Left to right
|
||||||
|
imax = f.width;
|
||||||
|
} else {
|
||||||
|
// Columns; Right to left
|
||||||
|
imin = f.width - 1;
|
||||||
|
}
|
||||||
|
if (cbVDir.SelectedIndex == 0) {
|
||||||
|
// Columns; Top to bottom
|
||||||
|
jmax = f.height;
|
||||||
|
} else {
|
||||||
|
// Columns; Bottom to top
|
||||||
|
jmin = f.height - 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cbHDir.SelectedIndex == 0) {
|
||||||
|
// Rows; Left to right
|
||||||
|
jmax = f.height;
|
||||||
|
} else {
|
||||||
|
// Rows; Right to left
|
||||||
|
jmin = f.height - 1;
|
||||||
|
}
|
||||||
|
if (cbVDir.SelectedIndex == 0) {
|
||||||
|
// Rows; Top to bottom
|
||||||
|
imax = f.width;
|
||||||
|
} else {
|
||||||
|
// Rows; Bottom to top
|
||||||
|
imin = f.width - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = imin; i != imax; i += idir) {
|
for (int i = imin; i != imax; i += idir) {
|
||||||
if (lines == 0) {
|
if (lines == 0) {
|
||||||
// "Column/Row per line" - new line offset
|
// "Column/Row per line" - new line offset
|
||||||
@@ -261,11 +319,12 @@ namespace McBitFont {
|
|||||||
}
|
}
|
||||||
if (lines == 0) {
|
if (lines == 0) {
|
||||||
// "Column/Row per line" - closing line
|
// "Column/Row per line" - closing line
|
||||||
output += cbracket + (i+idir!=imax ? "," : "") + "\n";
|
output += cbracket + ((i+idir==imax) && f.Equals(flast) ? "" : ",") + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lines == 1) {
|
if (lines == 1) {
|
||||||
// "1 symbol per line" - closing line
|
// "1 symbol per line" - closing line
|
||||||
|
if (!f.Equals(flast)) output += ",";
|
||||||
if (com) {
|
if (com) {
|
||||||
//...with a comment
|
//...with a comment
|
||||||
output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code);
|
output += " // " + f.code.ToString() + " --> " + mainForm.decodeSymbol(f.code);
|
||||||
@@ -286,6 +345,10 @@ namespace McBitFont {
|
|||||||
MessageBox.Show("Cannot pack the font meta header into 2D array!\nChoose 1D array or disable the meta header.\n(Setting array format to 1D array)", "No header in 2D array!", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Cannot pack the font meta header into 2D array!\nChoose 1D array or disable the meta header.\n(Setting array format to 1D array)", "No header in 2D array!", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
cbFormat.SelectedIndex = 0;
|
cbFormat.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
if (!mainForm.monospaced && cbFormat.SelectedIndex == 1) {
|
||||||
|
MessageBox.Show("Cannot pack the variable width font into 2D array!\n(Setting array format to 1D array)", "2D arrays are for monospaced fonts only!", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
cbFormat.SelectedIndex = 0;
|
||||||
|
}
|
||||||
if (cbFormat.SelectedIndex == 1) {
|
if (cbFormat.SelectedIndex == 1) {
|
||||||
cbLines.SelectedIndex = 0;
|
cbLines.SelectedIndex = 0;
|
||||||
cbLines.Enabled = false;
|
cbLines.Enabled = false;
|
||||||
|
@@ -46,7 +46,7 @@ namespace McBitFont {
|
|||||||
private int pixelOffset = 5;
|
private int pixelOffset = 5;
|
||||||
private int gap;
|
private int gap;
|
||||||
private int w, h;
|
private int w, h;
|
||||||
bool monospaced = false;
|
public bool monospaced = false;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
bool prjModified = false;
|
bool prjModified = false;
|
||||||
public const string version = "1.0";
|
public const string version = "1.0";
|
||||||
|
Reference in New Issue
Block a user