Baseline support

This commit is contained in:
2023-05-17 04:32:44 +03:00
parent 703e8d91ef
commit 11b268a350
3 changed files with 62 additions and 9 deletions

View File

@@ -73,6 +73,7 @@
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dlgSave = new System.Windows.Forms.SaveFileDialog(); this.dlgSave = new System.Windows.Forms.SaveFileDialog();
this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
this.btnBaseline = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
@@ -122,7 +123,7 @@
// nudY // nudY
// //
this.nudY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.nudY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.nudY.Location = new System.Drawing.Point(717, 53); this.nudY.Location = new System.Drawing.Point(717, 49);
this.nudY.Maximum = new decimal(new int[] { this.nudY.Maximum = new decimal(new int[] {
255, 255,
0, 0,
@@ -157,7 +158,7 @@
// //
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(670, 55); this.label2.Location = new System.Drawing.Point(670, 51);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 13); this.label2.Size = new System.Drawing.Size(41, 13);
this.label2.TabIndex = 4; this.label2.TabIndex = 4;
@@ -202,7 +203,7 @@
// //
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(602, 29); this.label4.Location = new System.Drawing.Point(604, 29);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(62, 13); this.label4.Size = new System.Drawing.Size(62, 13);
this.label4.TabIndex = 7; this.label4.TabIndex = 7;
@@ -304,7 +305,7 @@
// btnExport // btnExport
// //
this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnExport.Location = new System.Drawing.Point(696, 99); this.btnExport.Location = new System.Drawing.Point(696, 109);
this.btnExport.Name = "btnExport"; this.btnExport.Name = "btnExport";
this.btnExport.Size = new System.Drawing.Size(75, 23); this.btnExport.Size = new System.Drawing.Size(75, 23);
this.btnExport.TabIndex = 10; this.btnExport.TabIndex = 10;
@@ -343,7 +344,7 @@
// btnApply // btnApply
// //
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnApply.Location = new System.Drawing.Point(589, 99); this.btnApply.Location = new System.Drawing.Point(615, 109);
this.btnApply.Name = "btnApply"; this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(75, 23); this.btnApply.Size = new System.Drawing.Size(75, 23);
this.btnApply.TabIndex = 13; this.btnApply.TabIndex = 13;
@@ -376,7 +377,7 @@
// //
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label5.AutoSize = true; this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(640, 71); this.label5.Location = new System.Drawing.Point(554, 114);
this.label5.Name = "label5"; this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(24, 13); this.label5.Size = new System.Drawing.Size(24, 13);
this.label5.TabIndex = 16; this.label5.TabIndex = 16;
@@ -636,11 +637,23 @@
this.dlgOpen.DefaultExt = "mbf"; this.dlgOpen.DefaultExt = "mbf";
this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*"; this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*";
// //
// btnBaseline
//
this.btnBaseline.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBaseline.Location = new System.Drawing.Point(615, 80);
this.btnBaseline.Name = "btnBaseline";
this.btnBaseline.Size = new System.Drawing.Size(75, 23);
this.btnBaseline.TabIndex = 18;
this.btnBaseline.Text = "Baseline";
this.btnBaseline.UseVisualStyleBackColor = true;
this.btnBaseline.Click += new System.EventHandler(this.btnBaseline_Click);
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 561); this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.btnBaseline);
this.Controls.Add(this.btnApply); this.Controls.Add(this.btnApply);
this.Controls.Add(this.btnExport); this.Controls.Add(this.btnExport);
this.Controls.Add(this.label5); this.Controls.Add(this.label5);
@@ -725,6 +738,7 @@
private System.Windows.Forms.ToolStripMenuItem appendSymbolToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem appendSymbolToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
private System.Windows.Forms.Button btnBaseline;
} }
} }

View File

@@ -37,6 +37,7 @@ namespace McBitFont {
public struct SaveBlock { public struct SaveBlock {
public bool monospaced; public bool monospaced;
public int codepage; public int codepage;
public int baseline;
public List<FrameMiniature> frames; public List<FrameMiniature> frames;
} }
@@ -50,11 +51,13 @@ namespace McBitFont {
public bool monospaced = false; public bool monospaced = false;
bool modified = false; bool modified = false;
bool prjModified = false; bool prjModified = false;
public const string version = "1.2"; public const string version = "1.3";
public string prjName = "Untitled"; public string prjName = "Untitled";
public int codepage = 1251; public int codepage = 1251;
private FrameMiniature fbuf; private FrameMiniature fbuf;
private bool fbuffer = false; private bool fbuffer = false;
public int baseline = 0;
public bool set_base = false;
public MainForm() { public MainForm() {
InitializeComponent(); InitializeComponent();
@@ -275,6 +278,26 @@ namespace McBitFont {
} }
private void dotPanel_MouseMove(object sender, MouseEventArgs e) { private void dotPanel_MouseMove(object sender, MouseEventArgs e) {
if (set_base) {
int yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1;
Rectangle rect1 = new Rectangle(pixelOffset, yy, w, 3);
baseline = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap);
if (baseline >= dotHeight) baseline = dotHeight - 1;
if (baseline < 0) baseline = 0;
yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1;
Rectangle rect2 = new Rectangle(pixelOffset, yy, w, 3);
dotPanel.Invalidate(rect1);
dotPanel.Invalidate(rect2);
if (e.Button == MouseButtons.Left) {
set_base = false;
return;
}
}
if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return; if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return;
int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap); int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap);
int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap); int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap);
@@ -453,6 +476,16 @@ namespace McBitFont {
g.FillRectangle(sb, x, y, cellSize, cellSize); g.FillRectangle(sb, x, y, cellSize, cellSize);
} }
} }
if (baseline > 0 && gap > 0) {
x = pixelOffset - hScroll.Value;
y = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1;
g.DrawLine(
new Pen(Color.Blue, 2),
x, y,
w, y
);
}
} }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) { private void exitToolStripMenuItem_Click(object sender, EventArgs e) {
@@ -597,6 +630,7 @@ namespace McBitFont {
sav.monospaced = monospaced; sav.monospaced = monospaced;
sav.frames = frames; sav.frames = frames;
sav.codepage = codepage; sav.codepage = codepage;
sav.baseline = baseline;
BinaryFormatter formatter = new BinaryFormatter(); BinaryFormatter formatter = new BinaryFormatter();
using (Stream ms = File.OpenWrite(dlgSave.FileName)) { using (Stream ms = File.OpenWrite(dlgSave.FileName)) {
formatter.Serialize(ms, sav); formatter.Serialize(ms, sav);
@@ -625,6 +659,7 @@ namespace McBitFont {
} }
monospaced = sav.monospaced; monospaced = sav.monospaced;
codepage = sav.codepage; codepage = sav.codepage;
baseline = sav.baseline;
lblType.Text = monospaced ? "Monospaced" : "Variable width / Single"; lblType.Text = monospaced ? "Monospaced" : "Variable width / Single";
frames = sav.frames; frames = sav.frames;
miniList.Items.Clear(); miniList.Items.Clear();
@@ -713,6 +748,10 @@ namespace McBitFont {
form.ShowDialog(); form.ShowDialog();
} }
private void btnBaseline_Click(object sender, EventArgs e) {
set_base = !set_base;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
if (prjModified) { if (prjModified) {
if (MessageBox.Show("The project is modified.\nAre you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { if (MessageBox.Show("The project is modified.\nAre you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Можно задать все значения или принять номера сборки и редакции по умолчанию // Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже: // используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")] [assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyFileVersion("1.3.0.0")]