v 1.7 dev release

Application:
V Implement "Save" menu
V Implement new saved font file format

Functionality:
V "Only numbers" range in the New dialog
V "Specify range" in the New dialog
V "Single frame", "only numbers" and "specify range" as radio buttons
V Button to Clear/Fill a block
V Copy-paste to a symbol with different size
V Change height of variable width fonts with ability to choose which side to add pixels to
V Make it possible to have zero width chars in VarWidth fonts
V Tooltips on main form

Bugs:
V Every char changes its width to default on VarWidth font height change!
V App allows to create fonts with a gap in symbol cequence!
V File -> New does not check for unsaveed changes!
This commit is contained in:
2025-05-20 04:45:45 +03:00
parent f2b01d4a27
commit 5fc69e9992
8 changed files with 206 additions and 36 deletions

View File

@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -34,6 +34,7 @@
this.cbZoom = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.btnClear = new System.Windows.Forms.Button();
this.btnMirrorY = new System.Windows.Forms.Button();
this.btnMirrorX = new System.Windows.Forms.Button();
this.btnInvert = new System.Windows.Forms.Button();
@@ -52,6 +53,7 @@
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveDEVToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -63,6 +65,7 @@
this.removeSymbolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.applyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ClearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shiftUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shiftDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shiftLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -76,10 +79,9 @@
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
this.btnBaseline = new System.Windows.Forms.Button();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.btnClear = new System.Windows.Forms.Button();
this.ClearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.chkLeftSide = new System.Windows.Forms.CheckBox();
this.chkTopSide = new System.Windows.Forms.CheckBox();
this.openDEVToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
this.panel1.SuspendLayout();
@@ -230,6 +232,18 @@
this.panel1.Size = new System.Drawing.Size(120, 121);
this.panel1.TabIndex = 9;
//
// btnClear
//
this.btnClear.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.btnClear.Location = new System.Drawing.Point(7, 8);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(30, 30);
this.btnClear.TabIndex = 7;
this.btnClear.Text = "○";
this.toolTip1.SetToolTip(this.btnClear, "Clear canvas");
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// btnMirrorY
//
this.btnMirrorY.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
@@ -416,6 +430,8 @@
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.openToolStripMenuItem,
this.openDEVToolStripMenuItem,
this.saveDEVToolStripMenuItem,
this.saveToolStripMenuItem,
this.saveAsToolStripMenuItem,
this.exitToolStripMenuItem});
@@ -443,6 +459,13 @@
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveDEVToolStripMenuItem
//
this.saveDEVToolStripMenuItem.Name = "saveDEVToolStripMenuItem";
this.saveDEVToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
this.saveDEVToolStripMenuItem.Text = "Save as (new format)";
this.saveDEVToolStripMenuItem.Click += new System.EventHandler(this.saveJSONToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Image = global::McBitFont.Properties.Resources.Famfamfam_Silk_Disk_16;
@@ -568,6 +591,15 @@
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.toolsToolStripMenuItem.Text = "Tools";
//
// ClearToolStripMenuItem
//
this.ClearToolStripMenuItem.Name = "ClearToolStripMenuItem";
this.ClearToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+W";
this.ClearToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W)));
this.ClearToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.ClearToolStripMenuItem.Text = "Clear canvas";
this.ClearToolStripMenuItem.Click += new System.EventHandler(this.btnClear_Click);
//
// shiftUpToolStripMenuItem
//
this.shiftUpToolStripMenuItem.Image = global::McBitFont.Properties.Resources.arrow_top;
@@ -657,7 +689,7 @@
// dlgSave
//
this.dlgSave.DefaultExt = "mbf";
this.dlgSave.Filter = "McBitFont files|*.mbf|All files|*.*";
this.dlgSave.Filter = "McBitFont files|*.mbf|McBitFont new format|*.mbfont|All files|*.*";
//
// dlgOpen
//
@@ -682,27 +714,6 @@
this.toolTip1.InitialDelay = 500;
this.toolTip1.ReshowDelay = 100;
//
// btnClear
//
this.btnClear.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.btnClear.Location = new System.Drawing.Point(7, 8);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(30, 30);
this.btnClear.TabIndex = 7;
this.btnClear.Text = "○";
this.toolTip1.SetToolTip(this.btnClear, "Clear canvas");
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// ClearToolStripMenuItem
//
this.ClearToolStripMenuItem.Name = "ClearToolStripMenuItem";
this.ClearToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+W";
this.ClearToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W)));
this.ClearToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.ClearToolStripMenuItem.Text = "Clear canvas";
this.ClearToolStripMenuItem.Click += new System.EventHandler(this.btnClear_Click);
//
// chkLeftSide
//
this.chkLeftSide.AutoSize = true;
@@ -725,6 +736,14 @@
this.toolTip1.SetToolTip(this.chkTopSide, "Height changes will be made on Top/Bottom side");
this.chkTopSide.UseVisualStyleBackColor = true;
//
// openDEVToolStripMenuItem
//
this.openDEVToolStripMenuItem.Name = "openDEVToolStripMenuItem";
this.openDEVToolStripMenuItem.Size = new System.Drawing.Size(184, 22);
this.openDEVToolStripMenuItem.Text = "Open DEV";
this.openDEVToolStripMenuItem.Visible = false;
this.openDEVToolStripMenuItem.Click += new System.EventHandler(this.openDEVToolStripMenuItem_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -824,6 +843,8 @@
private System.Windows.Forms.ToolStripMenuItem ClearToolStripMenuItem;
private System.Windows.Forms.CheckBox chkLeftSide;
private System.Windows.Forms.CheckBox chkTopSide;
private System.Windows.Forms.ToolStripMenuItem saveDEVToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openDEVToolStripMenuItem;
}
}

View File

@@ -1,25 +1,29 @@
using System;
using MessagePack;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Runtime.InteropServices;
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 {
[Serializable]
[MessagePackObject]
public struct FrameMiniature {
public FrameMiniature(int cc, int ww, int hh) {
code = cc;
@@ -27,17 +31,26 @@ namespace McBitFont {
height = hh;
data = new bool[ww, hh];
}
[Key(0)]
public int code;
[Key(1)]
public int width;
[Key(2)]
public int height;
[Key(3)]
public bool[,] data;
};
[Serializable]
[MessagePackObject]
public struct SaveBlock {
[Key(4)]
public bool monospaced;
[Key(5)]
public int codepage;
[Key(6)]
public int baseline;
[Key(7)]
public List<FrameMiniature> frames;
}
@@ -51,7 +64,7 @@ namespace McBitFont {
public bool monospaced = false;
bool modified = false;
bool prjModified = false;
public const string version = "1.6";
public const string version = "1.7";
public string prjName = "Untitled";
public string prjFileName = "";
public int codepage = 1251;
@@ -810,6 +823,75 @@ namespace McBitFont {
dotPanel.Refresh();
}
private void saveJSONToolStripMenuItem_Click(object sender, EventArgs e) {
checkModifiedFrame();
if (dlgSave.ShowDialog() == DialogResult.OK) {
SaveBlock sav;
sav.monospaced = monospaced;
sav.frames = frames;
sav.codepage = codepage;
sav.baseline = baseline;
using (Stream ms = File.OpenWrite(dlgSave.FileName)) {
// TODO: Serializer here
MessagePackSerializer.Serialize(ms, sav);
ms.Close();
}
prjModified = false;
prjName = Path.GetFileNameWithoutExtension(dlgSave.FileName);
prjFileName = dlgSave.FileName;
this.Text = "McBitFont " + version + " - " + prjName;
}
}
private void openDEVToolStripMenuItem_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) == DialogResult.Yes) {
saveAsToolStripMenuItem.PerformClick();
return;
}
}
if (dlgOpen.ShowDialog() == DialogResult.OK) {
SaveBlock sav;
var filename = dlgOpen.FileName;
using (FileStream fs = File.Open(filename, FileMode.Open)) {
sav = MessagePackSerializer.Deserialize<SaveBlock>(fs);
fs.Close();
}
monospaced = sav.monospaced;
codepage = sav.codepage;
baseline = sav.baseline;
lblType.Text = monospaced ? "Monospaced" : "Variable width / Single";
frames = sav.frames;
miniList.Items.Clear();
ilMiniatures.Images.Clear();
foreach (FrameMiniature ff in frames) {
var s = ff.code.ToString().PadLeft(3, '0');
var sss = decodeSymbol(ff.code);
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
miniList.Items.Add(s, s + ' ' + sss, s);
}
nudX.ValueChanged -= nudX_ValueChanged;
nudY.ValueChanged -= nudY_ValueChanged;
nudX.Value = frames.First().width;
nudY.Value = frames.First().height;
dotResize((int)nudX.Value, (int)nudY.Value);
nudX.ValueChanged += nudX_ValueChanged;
nudY.ValueChanged += nudY_ValueChanged;
f = copyFrame(frames.First());
dotPanel.Refresh();
miniList.Refresh();
modified = false;
prjModified = false;
prjFileName = filename;
prjName = Path.GetFileNameWithoutExtension(filename);
this.Text = "McBitFont " + version + " - " + prjName;
checkForAdd();
fbuffer = false;
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
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) {

View File

@@ -132,6 +132,9 @@
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>336, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>436, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@@ -27,6 +27,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -51,8 +53,39 @@
<ApplicationIcon>icon_64.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="MessagePack, Version=3.1.3.0, Culture=neutral, PublicKeyToken=b4a0369545f0a1be, processorArchitecture=MSIL">
<HintPath>..\packages\MessagePack.3.1.3\lib\net472\MessagePack.dll</HintPath>
</Reference>
<Reference Include="MessagePack.Annotations, Version=3.1.3.0, Culture=neutral, PublicKeyToken=b4a0369545f0a1be, processorArchitecture=MSIL">
<HintPath>..\packages\MessagePack.Annotations.3.1.3\lib\netstandard2.0\MessagePack.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.NET.StringTools.17.11.4\lib\net472\Microsoft.NET.StringTools.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.8.0.0\lib\net462\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -112,6 +145,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -205,4 +239,11 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MessagePackAnalyzer.3.1.3\build\MessagePackAnalyzer.targets" Condition="Exists('..\packages\MessagePackAnalyzer.3.1.3\build\MessagePackAnalyzer.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MessagePackAnalyzer.3.1.3\build\MessagePackAnalyzer.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MessagePackAnalyzer.3.1.3\build\MessagePackAnalyzer.targets'))" />
</Target>
</Project>

View File

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

14
McBitFont/packages.config Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MessagePack" version="3.1.3" targetFramework="net472" />
<package id="MessagePack.Annotations" version="3.1.3" targetFramework="net472" />
<package id="MessagePackAnalyzer" version="3.1.3" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.NET.StringTools" version="17.11.4" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Collections.Immutable" version="8.0.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages>

View File

@@ -1,5 +1,6 @@
Application:
v Implement "Save" menu
V Implement "Save" menu
V Implement new saved font file format
Functionality:
- Context menu in symbol navigator