diff --git a/_sources/FireflyCore/Core/StringDescape.cs b/_sources/FireflyCore/Core/StringDescape.cs
index a5ce37d..95c906c 100644
--- a/_sources/FireflyCore/Core/StringDescape.cs
+++ b/_sources/FireflyCore/Core/StringDescape.cs
@@ -153,7 +153,7 @@ public static string Formats(this string This, object arg0, object arg1, object
return string.Format(This, arg0, arg1, arg2);
}
/// 将指定 String 中的格式项替换为指定数组中相应 Object 实例的值的文本等效项。
- public static string Formats(this string This, params object[] args)
+ public static string Formats(this string This, params string[][] args)
{
return string.Format(This, args);
}
diff --git a/_sources/FontGen/FontGenForm.Designer.cs b/_sources/FontGen/FontGenForm.Designer.cs
index 39fce73..ed42d59 100644
--- a/_sources/FontGen/FontGenForm.Designer.cs
+++ b/_sources/FontGen/FontGenForm.Designer.cs
@@ -75,6 +75,7 @@ private void InitializeComponent()
this.FileSelectBox_File = new FontGen.FileSelectBox();
this.chkDelTemp = new System.Windows.Forms.CheckBox();
this.btnEditText = new System.Windows.Forms.Button();
+ this.btnAutosize = new System.Windows.Forms.Button();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.NumericUpDown_Size)).BeginInit();
@@ -99,7 +100,7 @@ private void InitializeComponent()
// label1
//
label1.AutoSize = true;
- label1.Location = new System.Drawing.Point(12, 410);
+ label1.Location = new System.Drawing.Point(12, 424);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(57, 13);
label1.TabIndex = 10;
@@ -145,7 +146,7 @@ private void InitializeComponent()
// CheckBox_Bold
//
this.CheckBox_Bold.AutoSize = true;
- this.CheckBox_Bold.Location = new System.Drawing.Point(14, 166);
+ this.CheckBox_Bold.Location = new System.Drawing.Point(14, 152);
this.CheckBox_Bold.Name = "CheckBox_Bold";
this.CheckBox_Bold.Size = new System.Drawing.Size(47, 17);
this.CheckBox_Bold.TabIndex = 2;
@@ -156,7 +157,7 @@ private void InitializeComponent()
// CheckBox_Italic
//
this.CheckBox_Italic.AutoSize = true;
- this.CheckBox_Italic.Location = new System.Drawing.Point(102, 166);
+ this.CheckBox_Italic.Location = new System.Drawing.Point(102, 152);
this.CheckBox_Italic.Name = "CheckBox_Italic";
this.CheckBox_Italic.Size = new System.Drawing.Size(48, 17);
this.CheckBox_Italic.TabIndex = 2;
@@ -167,7 +168,7 @@ private void InitializeComponent()
// CheckBox_Underline
//
this.CheckBox_Underline.AutoSize = true;
- this.CheckBox_Underline.Location = new System.Drawing.Point(14, 190);
+ this.CheckBox_Underline.Location = new System.Drawing.Point(14, 176);
this.CheckBox_Underline.Name = "CheckBox_Underline";
this.CheckBox_Underline.Size = new System.Drawing.Size(71, 17);
this.CheckBox_Underline.TabIndex = 2;
@@ -178,7 +179,7 @@ private void InitializeComponent()
// CheckBox_Strikeout
//
this.CheckBox_Strikeout.AutoSize = true;
- this.CheckBox_Strikeout.Location = new System.Drawing.Point(102, 190);
+ this.CheckBox_Strikeout.Location = new System.Drawing.Point(102, 176);
this.CheckBox_Strikeout.Name = "CheckBox_Strikeout";
this.CheckBox_Strikeout.Size = new System.Drawing.Size(68, 17);
this.CheckBox_Strikeout.TabIndex = 2;
@@ -188,7 +189,7 @@ private void InitializeComponent()
//
// NumericUpDown_Size
//
- this.NumericUpDown_Size.Location = new System.Drawing.Point(14, 136);
+ this.NumericUpDown_Size.Location = new System.Drawing.Point(14, 122);
this.NumericUpDown_Size.Maximum = new decimal(new int[] {
65536,
0,
@@ -204,7 +205,7 @@ private void InitializeComponent()
this.NumericUpDown_Size.TabIndex = 3;
this.NumericUpDown_Size.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.NumericUpDown_Size.Value = new decimal(new int[] {
- 16,
+ 48,
0,
0,
0});
@@ -213,7 +214,7 @@ private void InitializeComponent()
// Label_Size
//
this.Label_Size.AutoSize = true;
- this.Label_Size.Location = new System.Drawing.Point(12, 120);
+ this.Label_Size.Location = new System.Drawing.Point(12, 106);
this.Label_Size.Name = "Label_Size";
this.Label_Size.Size = new System.Drawing.Size(27, 13);
this.Label_Size.TabIndex = 0;
@@ -222,7 +223,9 @@ private void InitializeComponent()
// CheckBox_DoubleSample
//
this.CheckBox_DoubleSample.AutoSize = true;
- this.CheckBox_DoubleSample.Location = new System.Drawing.Point(14, 214);
+ this.CheckBox_DoubleSample.Checked = true;
+ this.CheckBox_DoubleSample.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.CheckBox_DoubleSample.Location = new System.Drawing.Point(14, 228);
this.CheckBox_DoubleSample.Name = "CheckBox_DoubleSample";
this.CheckBox_DoubleSample.Size = new System.Drawing.Size(78, 17);
this.CheckBox_DoubleSample.TabIndex = 2;
@@ -233,7 +236,7 @@ private void InitializeComponent()
// Label_PhysicalWidth
//
this.Label_PhysicalWidth.AutoSize = true;
- this.Label_PhysicalWidth.Location = new System.Drawing.Point(12, 234);
+ this.Label_PhysicalWidth.Location = new System.Drawing.Point(12, 248);
this.Label_PhysicalWidth.Name = "Label_PhysicalWidth";
this.Label_PhysicalWidth.Size = new System.Drawing.Size(74, 13);
this.Label_PhysicalWidth.TabIndex = 0;
@@ -241,7 +244,7 @@ private void InitializeComponent()
//
// NumericUpDown_PhysicalWidth
//
- this.NumericUpDown_PhysicalWidth.Location = new System.Drawing.Point(14, 249);
+ this.NumericUpDown_PhysicalWidth.Location = new System.Drawing.Point(14, 263);
this.NumericUpDown_PhysicalWidth.Maximum = new decimal(new int[] {
65536,
0,
@@ -257,7 +260,7 @@ private void InitializeComponent()
this.NumericUpDown_PhysicalWidth.TabIndex = 3;
this.NumericUpDown_PhysicalWidth.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.NumericUpDown_PhysicalWidth.Value = new decimal(new int[] {
- 16,
+ 40,
0,
0,
0});
@@ -266,7 +269,7 @@ private void InitializeComponent()
// Label_PhysicalHeight
//
this.Label_PhysicalHeight.AutoSize = true;
- this.Label_PhysicalHeight.Location = new System.Drawing.Point(100, 234);
+ this.Label_PhysicalHeight.Location = new System.Drawing.Point(100, 248);
this.Label_PhysicalHeight.Name = "Label_PhysicalHeight";
this.Label_PhysicalHeight.Size = new System.Drawing.Size(77, 13);
this.Label_PhysicalHeight.TabIndex = 0;
@@ -274,7 +277,7 @@ private void InitializeComponent()
//
// NumericUpDown_PhysicalHeight
//
- this.NumericUpDown_PhysicalHeight.Location = new System.Drawing.Point(102, 250);
+ this.NumericUpDown_PhysicalHeight.Location = new System.Drawing.Point(102, 264);
this.NumericUpDown_PhysicalHeight.Maximum = new decimal(new int[] {
65536,
0,
@@ -290,7 +293,7 @@ private void InitializeComponent()
this.NumericUpDown_PhysicalHeight.TabIndex = 3;
this.NumericUpDown_PhysicalHeight.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.NumericUpDown_PhysicalHeight.Value = new decimal(new int[] {
- 16,
+ 42,
0,
0,
0});
@@ -362,7 +365,7 @@ private void InitializeComponent()
// Label_DrawOffsetX
//
this.Label_DrawOffsetX.AutoSize = true;
- this.Label_DrawOffsetX.Location = new System.Drawing.Point(12, 276);
+ this.Label_DrawOffsetX.Location = new System.Drawing.Point(12, 290);
this.Label_DrawOffsetX.Name = "Label_DrawOffsetX";
this.Label_DrawOffsetX.Size = new System.Drawing.Size(67, 13);
this.Label_DrawOffsetX.TabIndex = 0;
@@ -371,7 +374,7 @@ private void InitializeComponent()
// Label_DrawOffsetY
//
this.Label_DrawOffsetY.AutoSize = true;
- this.Label_DrawOffsetY.Location = new System.Drawing.Point(100, 276);
+ this.Label_DrawOffsetY.Location = new System.Drawing.Point(100, 290);
this.Label_DrawOffsetY.Name = "Label_DrawOffsetY";
this.Label_DrawOffsetY.Size = new System.Drawing.Size(67, 13);
this.Label_DrawOffsetY.TabIndex = 0;
@@ -379,7 +382,7 @@ private void InitializeComponent()
//
// NumericUpDown_DrawOffsetX
//
- this.NumericUpDown_DrawOffsetX.Location = new System.Drawing.Point(14, 293);
+ this.NumericUpDown_DrawOffsetX.Location = new System.Drawing.Point(14, 307);
this.NumericUpDown_DrawOffsetX.Maximum = new decimal(new int[] {
65536,
0,
@@ -398,7 +401,7 @@ private void InitializeComponent()
//
// NumericUpDown_DrawOffsetY
//
- this.NumericUpDown_DrawOffsetY.Location = new System.Drawing.Point(102, 293);
+ this.NumericUpDown_DrawOffsetY.Location = new System.Drawing.Point(102, 307);
this.NumericUpDown_DrawOffsetY.Maximum = new decimal(new int[] {
65536,
0,
@@ -418,7 +421,7 @@ private void InitializeComponent()
// Label_VirtualOffsetX
//
this.Label_VirtualOffsetX.AutoSize = true;
- this.Label_VirtualOffsetX.Location = new System.Drawing.Point(12, 319);
+ this.Label_VirtualOffsetX.Location = new System.Drawing.Point(12, 333);
this.Label_VirtualOffsetX.Name = "Label_VirtualOffsetX";
this.Label_VirtualOffsetX.Size = new System.Drawing.Size(71, 13);
this.Label_VirtualOffsetX.TabIndex = 0;
@@ -427,7 +430,7 @@ private void InitializeComponent()
// Label_VirtualOffsetY
//
this.Label_VirtualOffsetY.AutoSize = true;
- this.Label_VirtualOffsetY.Location = new System.Drawing.Point(100, 319);
+ this.Label_VirtualOffsetY.Location = new System.Drawing.Point(100, 333);
this.Label_VirtualOffsetY.Name = "Label_VirtualOffsetY";
this.Label_VirtualOffsetY.Size = new System.Drawing.Size(71, 13);
this.Label_VirtualOffsetY.TabIndex = 0;
@@ -435,7 +438,7 @@ private void InitializeComponent()
//
// NumericUpDown_VirtualOffsetX
//
- this.NumericUpDown_VirtualOffsetX.Location = new System.Drawing.Point(14, 335);
+ this.NumericUpDown_VirtualOffsetX.Location = new System.Drawing.Point(14, 349);
this.NumericUpDown_VirtualOffsetX.Maximum = new decimal(new int[] {
65536,
0,
@@ -454,7 +457,7 @@ private void InitializeComponent()
//
// NumericUpDown_VirtualOffsetY
//
- this.NumericUpDown_VirtualOffsetY.Location = new System.Drawing.Point(102, 335);
+ this.NumericUpDown_VirtualOffsetY.Location = new System.Drawing.Point(102, 349);
this.NumericUpDown_VirtualOffsetY.Maximum = new decimal(new int[] {
65536,
0,
@@ -474,24 +477,24 @@ private void InitializeComponent()
// Label_VirtualDeltaWidth
//
this.Label_VirtualDeltaWidth.AutoSize = true;
- this.Label_VirtualDeltaWidth.Location = new System.Drawing.Point(12, 361);
+ this.Label_VirtualDeltaWidth.Location = new System.Drawing.Point(12, 375);
this.Label_VirtualDeltaWidth.Name = "Label_VirtualDeltaWidth";
- this.Label_VirtualDeltaWidth.Size = new System.Drawing.Size(89, 13);
+ this.Label_VirtualDeltaWidth.Size = new System.Drawing.Size(67, 13);
this.Label_VirtualDeltaWidth.TabIndex = 0;
- this.Label_VirtualDeltaWidth.Text = "VirtualDeltaWidth";
+ this.Label_VirtualDeltaWidth.Text = "Virtual Width";
//
// Label_VirtualDeltaHeight
//
this.Label_VirtualDeltaHeight.AutoSize = true;
- this.Label_VirtualDeltaHeight.Location = new System.Drawing.Point(100, 361);
+ this.Label_VirtualDeltaHeight.Location = new System.Drawing.Point(100, 375);
this.Label_VirtualDeltaHeight.Name = "Label_VirtualDeltaHeight";
- this.Label_VirtualDeltaHeight.Size = new System.Drawing.Size(92, 13);
+ this.Label_VirtualDeltaHeight.Size = new System.Drawing.Size(70, 13);
this.Label_VirtualDeltaHeight.TabIndex = 0;
- this.Label_VirtualDeltaHeight.Text = "VirtualDeltaHeight";
+ this.Label_VirtualDeltaHeight.Text = "Virtual Height";
//
// NumericUpDown_VirtualDeltaWidth
//
- this.NumericUpDown_VirtualDeltaWidth.Location = new System.Drawing.Point(14, 377);
+ this.NumericUpDown_VirtualDeltaWidth.Location = new System.Drawing.Point(14, 391);
this.NumericUpDown_VirtualDeltaWidth.Maximum = new decimal(new int[] {
65536,
0,
@@ -510,7 +513,7 @@ private void InitializeComponent()
//
// NumericUpDown_VirtualDeltaHeight
//
- this.NumericUpDown_VirtualDeltaHeight.Location = new System.Drawing.Point(102, 377);
+ this.NumericUpDown_VirtualDeltaHeight.Location = new System.Drawing.Point(102, 391);
this.NumericUpDown_VirtualDeltaHeight.Maximum = new decimal(new int[] {
65536,
0,
@@ -529,7 +532,7 @@ private void InitializeComponent()
//
// Button_Generate
//
- this.Button_Generate.Location = new System.Drawing.Point(12, 486);
+ this.Button_Generate.Location = new System.Drawing.Point(12, 500);
this.Button_Generate.Name = "Button_Generate";
this.Button_Generate.Size = new System.Drawing.Size(202, 25);
this.Button_Generate.TabIndex = 7;
@@ -539,7 +542,7 @@ private void InitializeComponent()
//
// Button_CmdToClipboard
//
- this.Button_CmdToClipboard.Location = new System.Drawing.Point(12, 454);
+ this.Button_CmdToClipboard.Location = new System.Drawing.Point(12, 468);
this.Button_CmdToClipboard.Name = "Button_CmdToClipboard";
this.Button_CmdToClipboard.Size = new System.Drawing.Size(201, 25);
this.Button_CmdToClipboard.TabIndex = 8;
@@ -550,7 +553,7 @@ private void InitializeComponent()
// CheckBox_AnchorLeft
//
this.CheckBox_AnchorLeft.AutoSize = true;
- this.CheckBox_AnchorLeft.Location = new System.Drawing.Point(102, 214);
+ this.CheckBox_AnchorLeft.Location = new System.Drawing.Point(102, 228);
this.CheckBox_AnchorLeft.Name = "CheckBox_AnchorLeft";
this.CheckBox_AnchorLeft.Size = new System.Drawing.Size(92, 17);
this.CheckBox_AnchorLeft.TabIndex = 2;
@@ -565,7 +568,7 @@ private void InitializeComponent()
this.ddlBPP.Items.AddRange(new object[] {
"8",
"32"});
- this.ddlBPP.Location = new System.Drawing.Point(15, 426);
+ this.ddlBPP.Location = new System.Drawing.Point(15, 440);
this.ddlBPP.Name = "ddlBPP";
this.ddlBPP.Size = new System.Drawing.Size(58, 21);
this.ddlBPP.TabIndex = 11;
@@ -575,7 +578,7 @@ private void InitializeComponent()
this.chkDrawAlpha.AutoSize = true;
this.chkDrawAlpha.Checked = true;
this.chkDrawAlpha.CheckState = System.Windows.Forms.CheckState.Checked;
- this.chkDrawAlpha.Location = new System.Drawing.Point(14, 541);
+ this.chkDrawAlpha.Location = new System.Drawing.Point(14, 555);
this.chkDrawAlpha.Name = "chkDrawAlpha";
this.chkDrawAlpha.Size = new System.Drawing.Size(134, 17);
this.chkDrawAlpha.TabIndex = 12;
@@ -627,7 +630,7 @@ private void InitializeComponent()
this.chkDelTemp.AutoSize = true;
this.chkDelTemp.Checked = true;
this.chkDelTemp.CheckState = System.Windows.Forms.CheckState.Checked;
- this.chkDelTemp.Location = new System.Drawing.Point(14, 518);
+ this.chkDelTemp.Location = new System.Drawing.Point(14, 532);
this.chkDelTemp.Name = "chkDelTemp";
this.chkDelTemp.Size = new System.Drawing.Size(113, 17);
this.chkDelTemp.TabIndex = 17;
@@ -644,11 +647,22 @@ private void InitializeComponent()
this.btnEditText.UseVisualStyleBackColor = true;
this.btnEditText.Click += new System.EventHandler(this.btnEditText_Click);
//
+ // btnAutosize
+ //
+ this.btnAutosize.Location = new System.Drawing.Point(102, 122);
+ this.btnAutosize.Name = "btnAutosize";
+ this.btnAutosize.Size = new System.Drawing.Size(75, 23);
+ this.btnAutosize.TabIndex = 19;
+ this.btnAutosize.Text = "Autosize";
+ this.btnAutosize.UseVisualStyleBackColor = true;
+ this.btnAutosize.Click += new System.EventHandler(this.btnAutosize_Click);
+ //
// FontGenForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1060, 680);
+ this.Controls.Add(this.btnAutosize);
this.Controls.Add(this.btnEditText);
this.Controls.Add(this.chkDelTemp);
this.Controls.Add(this.txtTargetPath);
@@ -692,6 +706,7 @@ private void InitializeComponent()
this.Name = "FontGenForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Font image generator";
+ this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.FontGen_Load);
this.Shown += new System.EventHandler(this.FontGen_Shown);
this.SizeChanged += new System.EventHandler(this.FontGen_SizeChanged);
@@ -760,5 +775,6 @@ private void InitializeComponent()
internal System.Windows.Forms.PictureBox PictureBox_Preview2x;
private System.Windows.Forms.CheckBox chkDelTemp;
private System.Windows.Forms.Button btnEditText;
+ private System.Windows.Forms.Button btnAutosize;
}
}
\ No newline at end of file
diff --git a/_sources/FontGen/FontGenForm.cs b/_sources/FontGen/FontGenForm.cs
index c8de6df..82588e8 100644
--- a/_sources/FontGen/FontGenForm.cs
+++ b/_sources/FontGen/FontGenForm.cs
@@ -27,9 +27,9 @@ namespace FontGen
{
public partial class FontGenForm
{
- PrivateFontCollection collection = new PrivateFontCollection();
+ PrivateFontCollection Collection = new PrivateFontCollection();
- static string[] TestStrings = [
+ static string[] _testStrings = [
"йцукенгшщзхъфывапролджэячсмитьбюё",
"ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮЁ",
"qwertyuiop[]asdfghjklzxcvbnm",
@@ -115,25 +115,25 @@ public static int MainWindow()
return 0;
}
- public static IEnumerable GenerateFont(string SourcePath, string FontName, FontStyle FontStyle, int FontSize, int PhysicalWidth, int PhysicalHeight, int DrawOffsetX, int DrawOffsetY, int VirtualOffsetX, int VirtualOffsetY, int VirtualDeltaWidth, int VirtualDeltaHeight, bool EnableDoubleSample, bool AnchorLeft, ChannelPattern[] ChannelPatterns)
+ public static IEnumerable GenerateFont(string sourcePath, string fontName, FontStyle fontStyle, int fontSize, int physicalWidth, int physicalHeight, int drawOffsetX, int drawOffsetY, int virtualOffsetX, int virtualOffsetY, int virtualDeltaWidth, int virtualDeltaHeight, bool enableDoubleSample, bool anchorLeft, ChannelPattern[] channelPatterns)
{
StringCode[] StringCodes;
- if (!string.IsNullOrWhiteSpace(SourcePath) && File.Exists(SourcePath))
+ if (!string.IsNullOrWhiteSpace(sourcePath) && File.Exists(sourcePath))
{
- string Ext = FileNameHandling.GetExtendedFileName(SourcePath);
+ string Ext = FileNameHandling.GetExtendedFileName(sourcePath);
if (Ext.Equals("tbl", StringComparison.OrdinalIgnoreCase))
{
- StringCodes = TblCharMappingFile.ReadFile(SourcePath).ToArray();
+ StringCodes = TblCharMappingFile.ReadFile(sourcePath).ToArray();
}
else if (Ext.Equals("fd", StringComparison.OrdinalIgnoreCase))
{
- StringCodes = (from d in FdGlyphDescriptionFile.ReadFile(SourcePath)
+ StringCodes = (from d in FdGlyphDescriptionFile.ReadFile(sourcePath)
select d.c).ToArray();
}
else if (Ext.Equals("txt", StringComparison.OrdinalIgnoreCase))
{
- StringCodes = (from c in Txt.ReadFile(SourcePath).ToUTF32()
+ StringCodes = (from c in Txt.ReadFile(sourcePath).ToUTF32()
select StringCode.FromUniChar(c)).ToArray();
}
else
@@ -143,45 +143,45 @@ public static IEnumerable GenerateFont(string SourcePath, string FontNam
}
else
{
- StringCodes = TestStrings.SelectMany(l => l.ToUTF32()).Select(c => StringCode.FromUniChar(c))
+ StringCodes = _testStrings.SelectMany(l => l.ToUTF32()).Select(c => StringCode.FromUniChar(c))
.Distinct()
.ToArray();
}
IGlyphProvider gg;
- if (EnableDoubleSample)
+ if (enableDoubleSample)
{
gg = new GlyphGeneratorDoubleSample(
- FontName,
- FontStyle,
- FontSize,
- PhysicalWidth,
- PhysicalHeight,
- DrawOffsetX,
- DrawOffsetY,
- VirtualOffsetX,
- VirtualOffsetY,
- VirtualDeltaWidth,
- VirtualDeltaHeight,
- AnchorLeft,
- ChannelPatterns);
+ fontName,
+ fontStyle,
+ fontSize,
+ physicalWidth,
+ physicalHeight,
+ drawOffsetX,
+ drawOffsetY,
+ virtualOffsetX,
+ virtualOffsetY,
+ virtualDeltaWidth,
+ virtualDeltaHeight,
+ anchorLeft,
+ channelPatterns);
}
else
{
gg = new GlyphGenerator(
- FontName,
- FontStyle,
- FontSize,
- PhysicalWidth,
- PhysicalHeight,
- DrawOffsetX,
- DrawOffsetY,
- VirtualOffsetX,
- VirtualOffsetY,
- VirtualDeltaWidth,
- VirtualDeltaHeight,
- AnchorLeft,
- ChannelPatterns);
+ fontName,
+ fontStyle,
+ fontSize,
+ physicalWidth,
+ physicalHeight,
+ drawOffsetX,
+ drawOffsetY,
+ virtualOffsetX,
+ virtualOffsetY,
+ virtualDeltaWidth,
+ virtualDeltaHeight,
+ anchorLeft,
+ channelPatterns);
}
using (gg)
@@ -189,15 +189,15 @@ public static IEnumerable GenerateFont(string SourcePath, string FontNam
select gg.GetGlyph(c)).ToArray();
}
- public static void SaveFont(IEnumerable Glyphs, string TargetPath, int PicWidth, int PicHeight, int BitPerPixel, bool Multiple, bool Compact)
+ public static void SaveFont(IEnumerable glyphs, string targetPath, int picWidth, int picHeight, int bitPerPixel, bool multiple, bool compact)
{
- IGlyph[] gl = Glyphs.ToArray();
+ IGlyph[] gl = glyphs.ToArray();
int PhysicalWidth = (from g in gl
select g.PhysicalWidth).Max();
int PhysicalHeight = (from g in gl
select g.PhysicalHeight).Max();
IGlyphArranger ga;
- if (Compact)
+ if (compact)
{
ga = new GlyphArrangerCompact(PhysicalWidth, PhysicalHeight);
}
@@ -206,42 +206,42 @@ public static void SaveFont(IEnumerable Glyphs, string TargetPath, int P
ga = new GlyphArranger(PhysicalWidth, PhysicalHeight);
}
- if (PicWidth < 0 || PicHeight < 0)
+ if (picWidth < 0 || picHeight < 0)
{
var Size = ga.GetPreferredSize(gl);
- PicWidth = Size.Width;
- PicHeight = ga.GetPreferredHeight(gl, Size.Width);
+ picWidth = Size.Width;
+ picHeight = ga.GetPreferredHeight(gl, Size.Width);
}
- if (Multiple)
+ if (multiple)
{
int n = 0;
int GlyphIndex = 0;
while (GlyphIndex < gl.Length)
{
- string FdPath = FileNameHandling.ChangeExtension(TargetPath, "{0}.{1}".Formats(n, FileNameHandling.GetExtendedFileName(TargetPath)));
- var PartGlyphDescriptors = ga.GetGlyphArrangement(gl, PicWidth, PicHeight);
+ string FdPath = FileNameHandling.ChangeExtension(targetPath, "{0}.{1}".Formats(n, FileNameHandling.GetExtendedFileName(targetPath)));
+ var PartGlyphDescriptors = ga.GetGlyphArrangement(gl, picWidth, picHeight);
GlyphDescriptor[] pgd = PartGlyphDescriptors.ToArray();
if (pgd.Length == 0)
throw new InvalidDataException("PicSizeTooSmallForGlyphOfChar:{0}".Formats(gl[GlyphIndex].c.ToString()));
IGlyph[] pgl = gl.SubArray(GlyphIndex, pgd.Length);
- using (BmpFontImageWriter imageWriter = new BmpFontImageWriter(FileNameHandling.ChangeExtension(FdPath, "bmp"), BitPerPixel))
+ using (BmpFontImageWriter imageWriter = new BmpFontImageWriter(FileNameHandling.ChangeExtension(FdPath, "bmp"), bitPerPixel))
{
- FdGlyphDescriptionFile.WriteFont(FdPath, TextEncoding.WritingDefault, pgl, pgd, imageWriter, PicWidth, PicHeight);
+ FdGlyphDescriptionFile.WriteFont(FdPath, TextEncoding.WritingDefault, pgl, pgd, imageWriter, picWidth, picHeight);
}
GlyphIndex += pgd.Length;
}
}
else
{
- using (BmpFontImageWriter imageWriter = new BmpFontImageWriter(FileNameHandling.ChangeExtension(TargetPath, "bmp"), BitPerPixel))
+ using (BmpFontImageWriter imageWriter = new BmpFontImageWriter(FileNameHandling.ChangeExtension(targetPath, "bmp"), bitPerPixel))
{
- FdGlyphDescriptionFile.WriteFont(TargetPath, TextEncoding.WritingDefault, gl, imageWriter, ga, PicWidth, PicHeight);
+ FdGlyphDescriptionFile.WriteFont(targetPath, TextEncoding.WritingDefault, gl, imageWriter, ga, picWidth, picHeight);
}
}
}
- private bool Initialized = false;
+ private bool Initialized;
private void ReDraw()
{
@@ -253,181 +253,191 @@ private void ReDraw()
// Try
var Image = new Bitmap(PhysicalWidth * 64 + 32 * 8, PhysicalHeight * 32 + 32 * 8, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
- var Image2x = new Bitmap(PhysicalWidth * 64 * 2 + 32 * 8 * 2, PhysicalHeight * 32 * 2 + 32 * 8 * 2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ var image2X = new Bitmap(PhysicalWidth * 64 * 2 + 32 * 8 * 2, PhysicalHeight * 32 * 2 + 32 * 8 * 2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Try
using (var g = Graphics.FromImage(Image))
- using (var g2x = Graphics.FromImage(Image2x))
+ using (var g2X = Graphics.FromImage(image2X))
{
g.Clear(Color.White);
- g2x.Clear(Color.LightGray);
-
- FontStyle Style = GetSelectedStyles();
+ g2X.Clear(Color.LightGray);
- bool EnableDoubleSample = CheckBox_DoubleSample.Checked;
- bool AnchorLeft = CheckBox_AnchorLeft.Checked;
-
- ChannelPattern[] ChannelPatterns = [ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw];
-
- if (!chkDrawAlpha.Checked)
- ChannelPatterns[0] = ChannelPattern.One;
-
- IGlyphProvider gg;
- if (EnableDoubleSample)
- {
- gg = new GlyphGeneratorDoubleSample(
- GetSelectedFont(),
- Style,
- (int)Math.Round(NumericUpDown_Size.Value),
- PhysicalWidth,
- PhysicalHeight,
- (int)Math.Round(NumericUpDown_DrawOffsetX.Value),
- (int)Math.Round(NumericUpDown_DrawOffsetY.Value),
- (int)Math.Round(NumericUpDown_VirtualOffsetX.Value),
- (int)Math.Round(NumericUpDown_VirtualOffsetY.Value),
- (int)Math.Round(NumericUpDown_VirtualDeltaWidth.Value),
- (int)Math.Round(NumericUpDown_VirtualDeltaHeight.Value),
- AnchorLeft,
- ChannelPatterns);
- }
- else
- {
- gg = new GlyphGenerator(
- GetSelectedFont(), Style,
- (int)Math.Round(NumericUpDown_Size.Value),
- PhysicalWidth,
- PhysicalHeight,
- (int)Math.Round(NumericUpDown_DrawOffsetX.Value),
- (int)Math.Round(NumericUpDown_DrawOffsetY.Value),
- (int)Math.Round(NumericUpDown_VirtualOffsetX.Value),
- (int)Math.Round(NumericUpDown_VirtualOffsetY.Value),
- (int)Math.Round(NumericUpDown_VirtualDeltaWidth.Value),
- (int)Math.Round(NumericUpDown_VirtualDeltaHeight.Value),
- AnchorLeft,
- ChannelPatterns);
- }
+ var (lines, glyphs) = GetChars(PhysicalWidth, PhysicalHeight);
List<(int y0, int x0)> range = Enumerable
.Range(0, PhysicalHeight)
.SelectMany(y0 => Enumerable.Range(0, PhysicalWidth).Select(x0 => (y0, x0)))
.ToList();
- IEnumerable lines = TestStrings
- .Select(l => l.ToUTF32());
-
- using (gg)
+ using (var b = new Bmp(PhysicalWidth, PhysicalHeight, 32))
+ using (var b2X = new Bmp(PhysicalWidth * 2, PhysicalHeight * 2, 32))
{
- IGlyph[] glyphs = lines
- .SelectMany(l => l)
- //.AsParallel()
- .Select(c => gg.GetGlyph(StringCode.FromUniChar(c)))
- .ToArray();
+ int[,] block2X = new int[(PhysicalWidth * 2), (PhysicalHeight * 2)];
+ //int[,] Block = new int[(PhysicalWidth), (PhysicalHeight)];
- using (var b = new Bmp(PhysicalWidth, PhysicalHeight, 32))
- using (var b2x = new Bmp(PhysicalWidth * 2, PhysicalHeight * 2, 32))
- {
- int[,] Block2x = new int[(PhysicalWidth * 2), (PhysicalHeight * 2)];
- //int[,] Block = new int[(PhysicalWidth), (PhysicalHeight)];
+ int gIndex = 0;
- int g_index = 0;
-
- int l = 0;
- foreach (var t in lines)
+ int l = 0;
+ foreach (var t in lines)
+ {
+ int k = 0;
+ foreach (Char32 c in t)
{
- int k = 0;
- foreach (Char32 c in t)
- {
- IGlyph glyph = glyphs[g_index++];
-
- int x = k * (PhysicalWidth + 4);
- int y = l * (PhysicalHeight + 4);
-
- int[,] Block = glyph.Block;
-
- Parallel.ForEach(range, pair =>
- {
- var x0 = pair.x0;
- var y0 = pair.y0;
-
- Block[x0, y0] = Block[x0, y0] ^ 0xFFFFFF;
+ IGlyph glyph = glyphs[gIndex++];
- if (!glyph.IsValid)
- {
- Block[x0, y0] = Color.Red.ToArgb();
- }
- });
+ int x = k * (PhysicalWidth + 4);
+ int y = l * (PhysicalHeight + 4);
- //for (int y0 = 0; y0 <= PhysicalHeight - 1; y0++)
- //for (int x0 = 0; x0 <= PhysicalWidth - 1; x0++)
- //{
- // Block[x0, y0] = Block[x0, y0] ^ 0xFFFFFF;
+ int[,] Block = glyph.Block;
- // if (!glyph.IsValid)
- // {
- // //int ARGB = BitOperations.ConcatBits(GetChannel(ChannelPatterns[0], L), 8, GetChannel(ChannelPatterns[1], L), 8, GetChannel(ChannelPatterns[2], L), 8, GetChannel(ChannelPatterns[3], L), 8);
+ Parallel.ForEach(range, pair =>
+ {
+ var x0 = pair.x0;
+ var y0 = pair.y0;
- // Block[x0, y0] = Color.Red.ToArgb();
- // }
- //}
+ Block[x0, y0] = Block[x0, y0] ^ 0xFFFFFF;
- b.SetRectangle(0, 0, Block);
- using (var bb = b.ToBitmap())
+ if (!glyph.IsValid)
{
- var PhysicalRect = new Rectangle(x, y, PhysicalWidth, PhysicalHeight);
- g.DrawImage(bb, PhysicalRect);
+ Block[x0, y0] = Color.Red.ToArgb();
}
+ });
- Parallel.ForEach(range, pair =>
- {
- var x0 = pair.x0;
- var y0 = pair.y0;
-
- Block2x[x0 * 2, y0 * 2] = Block[x0, y0];
- Block2x[x0 * 2 + 1, y0 * 2] = Block[x0, y0];
- Block2x[x0 * 2, y0 * 2 + 1] = Block[x0, y0];
- Block2x[x0 * 2 + 1, y0 * 2 + 1] = Block[x0, y0];
- });
-
- //for (int y0 = 0; y0 <= PhysicalHeight - 1; y0++)
- //for (int x0 = 0; x0 <= PhysicalWidth - 1; x0++)
- //{
- // Block2x[x0 * 2, y0 * 2] = Block[x0, y0];
- // Block2x[x0 * 2 + 1, y0 * 2] = Block[x0, y0];
- // Block2x[x0 * 2, y0 * 2 + 1] = Block[x0, y0];
- // Block2x[x0 * 2 + 1, y0 * 2 + 1] = Block[x0, y0];
- //}
-
- b2x.SetRectangle(0, 0, Block2x);
- using (var bb2x = b2x.ToBitmap())
- {
- var PhysicalRect2x = new Rectangle(x * 2, y * 2, PhysicalWidth * 2, PhysicalHeight * 2);
- g2x.DrawImage(bb2x, PhysicalRect2x);
- }
+ //for (int y0 = 0; y0 <= PhysicalHeight - 1; y0++)
+ //for (int x0 = 0; x0 <= PhysicalWidth - 1; x0++)
+ //{
+ // Block[x0, y0] = Block[x0, y0] ^ 0xFFFFFF;
+
+ // if (!glyph.IsValid)
+ // {
+ // //int ARGB = BitOperations.ConcatBits(GetChannel(ChannelPatterns[0], L), 8, GetChannel(ChannelPatterns[1], L), 8, GetChannel(ChannelPatterns[2], L), 8, GetChannel(ChannelPatterns[3], L), 8);
- var VirtualRect = glyph.VirtualBox;
- g2x.DrawRectangle(Pens.Red, new Rectangle(x * 2 + VirtualRect.X * 2, y * 2 + VirtualRect.Y * 2, VirtualRect.Width * 2 - 1, VirtualRect.Height * 2 - 1));
+ // Block[x0, y0] = Color.Red.ToArgb();
+ // }
+ //}
- k += 1;
+ b.SetRectangle(0, 0, Block);
+ using (var bb = b.ToBitmap())
+ {
+ var PhysicalRect = new Rectangle(x, y, PhysicalWidth, PhysicalHeight);
+ g.DrawImage(bb, PhysicalRect);
+ }
+
+ Parallel.ForEach(range, pair =>
+ {
+ var x0 = pair.x0;
+ var y0 = pair.y0;
+
+ block2X[x0 * 2, y0 * 2] = Block[x0, y0];
+ block2X[x0 * 2 + 1, y0 * 2] = Block[x0, y0];
+ block2X[x0 * 2, y0 * 2 + 1] = Block[x0, y0];
+ block2X[x0 * 2 + 1, y0 * 2 + 1] = Block[x0, y0];
+ });
+
+ //for (int y0 = 0; y0 <= PhysicalHeight - 1; y0++)
+ //for (int x0 = 0; x0 <= PhysicalWidth - 1; x0++)
+ //{
+ // Block2x[x0 * 2, y0 * 2] = Block[x0, y0];
+ // Block2x[x0 * 2 + 1, y0 * 2] = Block[x0, y0];
+ // Block2x[x0 * 2, y0 * 2 + 1] = Block[x0, y0];
+ // Block2x[x0 * 2 + 1, y0 * 2 + 1] = Block[x0, y0];
+ //}
+
+ b2X.SetRectangle(0, 0, block2X);
+ using (var bb2X = b2X.ToBitmap())
+ {
+ var physicalRect2X = new Rectangle(x * 2, y * 2, PhysicalWidth * 2, PhysicalHeight * 2);
+ g2X.DrawImage(bb2X, physicalRect2X);
}
- l += 1;
+ var VirtualRect = glyph.VirtualBox;
+ g2X.DrawRectangle(Pens.Red, new Rectangle(x * 2 + VirtualRect.X * 2, y * 2 + VirtualRect.Y * 2, VirtualRect.Width * 2 - 1, VirtualRect.Height * 2 - 1));
+
+ k += 1;
}
- }
+ l += 1;
+ }
}
+
+
}
// Catch
// End Try
PictureBox_Preview.Image = Image;
PictureBox_Preview.ClientSize = Image.Size;
- PictureBox_Preview2x.Image = Image2x;
- PictureBox_Preview2x.ClientSize = Image2x.Size;
+ PictureBox_Preview2x.Image = image2X;
+ PictureBox_Preview2x.ClientSize = image2X.Size;
PictureBox_Preview.Invalidate();
PictureBox_Preview2x.Invalidate();
// Catch
// End Try
}
+ private (IEnumerable lines, IGlyph[] glyphs) GetChars(int physicalWidth, int physicalHeight)
+ {
+ FontStyle Style = GetSelectedStyles();
+
+ bool EnableDoubleSample = CheckBox_DoubleSample.Checked;
+ bool AnchorLeft = CheckBox_AnchorLeft.Checked;
+
+ ChannelPattern[] ChannelPatterns = [ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw];
+
+ if (!chkDrawAlpha.Checked)
+ ChannelPatterns[0] = ChannelPattern.One;
+
+ IGlyphProvider gg;
+ if (EnableDoubleSample)
+ {
+ gg = new GlyphGeneratorDoubleSample(
+ GetSelectedFont(),
+ Style,
+ (int)Math.Round(NumericUpDown_Size.Value),
+ physicalWidth,
+ physicalHeight,
+ (int)Math.Round(NumericUpDown_DrawOffsetX.Value),
+ (int)Math.Round(NumericUpDown_DrawOffsetY.Value),
+ (int)Math.Round(NumericUpDown_VirtualOffsetX.Value),
+ (int)Math.Round(NumericUpDown_VirtualOffsetY.Value),
+ (int)Math.Round(NumericUpDown_VirtualDeltaWidth.Value),
+ (int)Math.Round(NumericUpDown_VirtualDeltaHeight.Value),
+ AnchorLeft,
+ ChannelPatterns);
+ }
+ else
+ {
+ gg = new GlyphGenerator(
+ GetSelectedFont(), Style,
+ (int)Math.Round(NumericUpDown_Size.Value),
+ physicalWidth,
+ physicalHeight,
+ (int)Math.Round(NumericUpDown_DrawOffsetX.Value),
+ (int)Math.Round(NumericUpDown_DrawOffsetY.Value),
+ (int)Math.Round(NumericUpDown_VirtualOffsetX.Value),
+ (int)Math.Round(NumericUpDown_VirtualOffsetY.Value),
+ (int)Math.Round(NumericUpDown_VirtualDeltaWidth.Value),
+ (int)Math.Round(NumericUpDown_VirtualDeltaHeight.Value),
+ AnchorLeft,
+ ChannelPatterns);
+ }
+
+ IEnumerable lines = _testStrings
+ .Select(l => l.ToUTF32()).ToArray();
+
+ IGlyph[] glyphs;
+
+ using (gg)
+ {
+ glyphs = lines
+ .SelectMany(l => l)
+ //.AsParallel()
+ .Select(c => gg.GetGlyph(StringCode.FromUniChar(c)))
+ .ToArray();
+ }
+
+ return (lines, glyphs);
+ }
+
private FontStyle GetSelectedStyles()
{
var Style = FontStyle.Regular;
@@ -442,13 +452,13 @@ private FontStyle GetSelectedStyles()
return Style;
}
- private string customFontPath;
+ private string CustomFontPath;
private string GetSelectedFont()
{
- if (!string.IsNullOrEmpty(customFontPath))
+ if (!string.IsNullOrEmpty(CustomFontPath))
{
- return customFontPath;
+ return CustomFontPath;
}
return ((FontFamily)ComboBox_FontName.SelectedItem).Name;
@@ -471,7 +481,7 @@ private void ComboBox_FontName_SelectedValueChanged(object sender, EventArgs e)
{
if (ComboBox_FontName.SelectedIndex >= 0)
{
- customFontPath = string.Empty;
+ CustomFontPath = string.Empty;
ReDraw();
@@ -518,21 +528,20 @@ private void chkDrawAlpha_CheckedChanged(object sender, EventArgs e)
//ReDraw();
}
- private string Esc(string Parameter)
+ private string Esc(string parameter)
{
- if (string.IsNullOrEmpty(Parameter))
+ if (string.IsNullOrEmpty(parameter))
return "\"\"";
- if (Parameter.Contains(" "))
- return "\"" + Parameter + "\"";
- if (Parameter.Contains(" "))
- return "\"" + Parameter + "\"";
- return Parameter;
+ if (parameter.Contains(" "))
+ return "\"" + parameter + "\"";
+ if (parameter.Contains(" "))
+ return "\"" + parameter + "\"";
+ return parameter;
}
- private string FormatEsc(string Format, params object[] args)
+ private string FormatEsc(string format, params object[] args)
{
- return Format.Formats((from arg in args
- select Esc(arg.ToString())).ToArray());
+ return format.Formats(args.Select(arg => Esc(arg.ToString())).ToArray());
}
private void Button_CmdToClipboard_Click(object sender, EventArgs e)
@@ -594,9 +603,9 @@ private void Button_Generate_Click(object sender, EventArgs e)
ChannelPattern[] ChannelPatterns = [ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw];
- bool cop_mode = !chkDrawAlpha.Checked;
+ bool copMode = !chkDrawAlpha.Checked;
- if (cop_mode)
+ if (copMode)
ChannelPatterns[0] = ChannelPattern.One;
int bpp = int.Parse(ddlBPP.SelectedItem.ToString());
@@ -639,46 +648,46 @@ private void Button_Generate_Click(object sender, EventArgs e)
string path = Path.Combine(wortDir, Path.GetFileName(GetSelectedFont()));
- string fd_filePath = FileNameHandling.ChangeExtension(path, "fd");
- string bmp_filePath = FileNameHandling.ChangeExtension(path, "bmp");
+ string fdFilePath = FileNameHandling.ChangeExtension(path, "fd");
+ string bmpFilePath = FileNameHandling.ChangeExtension(path, "bmp");
- SaveFont(glyphs, fd_filePath, -1, -1, bpp, false, false);
+ SaveFont(glyphs, fdFilePath, -1, -1, bpp, false, false);
string toolDir = AppDomain.CurrentDomain.BaseDirectory + "\\Bins";
- string dds_format = bpp == 32 ? "-32" : "-8";
- dds_format += " ";
- dds_format += cop_mode ? "A8" : "u8888";
+ string ddsFormat = bpp == 32 ? "-32" : "-8";
+ ddsFormat += " ";
+ ddsFormat += copMode ? "A8" : "u8888";
- FbToIni(wortDir, fd_filePath);
+ FbToIni(fdFilePath);
//RunAndWait(wortDir, Path.Combine(toolDir, "FD2INI.exe"), $"\"{Path.GetFileName(fd_filePath)}\"");
//RunAndWait(wortDir, Path.Combine(toolDir, "BmpCuter.exe"), Path.GetFileName(bmp_filePath));
- RunAndWait(wortDir, Path.Combine(toolDir, "nvdxt.exe"), $"-file \"{Path.GetFileName(bmp_filePath)}\" -outdir \"{wortDir}\" -nomipmap {dds_format}");
+ RunAndWait(wortDir, Path.Combine(toolDir, "nvdxt.exe"), $"-file \"{Path.GetFileName(bmpFilePath)}\" -outdir \"{wortDir}\" -nomipmap {ddsFormat}");
if (chkDelTemp.Checked)
{
- string ini_filePath = FileNameHandling.ChangeExtension(path, "ini");
- string dds_filePath = FileNameHandling.ChangeExtension(path, "dds");
+ string iniFilePath = FileNameHandling.ChangeExtension(path, "ini");
+ string ddsFilePath = FileNameHandling.ChangeExtension(path, "dds");
// if all good
- if (File.Exists(ini_filePath) && File.Exists(dds_filePath))
+ if (File.Exists(iniFilePath) && File.Exists(ddsFilePath))
{
- File.Delete(fd_filePath);
- File.Delete(bmp_filePath);
+ File.Delete(fdFilePath);
+ File.Delete(bmpFilePath);
}
}
MessageBox.Show("Generation completed!", Text);
}
- private void FbToIni(string wortDir, string fd_filePath)
+ private void FbToIni(string fdFilePath)
{
- string ini_filePath = FileNameHandling.ChangeExtension(fd_filePath, "ini");
+ string iniFilePath = FileNameHandling.ChangeExtension(fdFilePath, "ini");
- if (File.Exists(fd_filePath))
+ if (File.Exists(fdFilePath))
{
- string[] lines = File.ReadAllLines(fd_filePath);
+ string[] lines = File.ReadAllLines(fdFilePath);
List result = new List();
int height = -1;
@@ -694,31 +703,31 @@ private void FbToIni(string wortDir, string fd_filePath)
x1 = int.Parse(parts[2]);
y1 = int.Parse(parts[3]);
- int _x1, _y1;
+ int i_x1, i_y1;
- _x1 = int.Parse(parts[6]);
- _y1 = int.Parse(parts[7]);
+ i_x1 = int.Parse(parts[6]);
+ i_y1 = int.Parse(parts[7]);
- int _x2, _y2;
+ int i_x2, i_y2;
- _x2 = int.Parse(parts[8]);
- _y2 = int.Parse(parts[9]);
+ i_x2 = int.Parse(parts[8]);
+ i_y2 = int.Parse(parts[9]);
- height = _y2;
+ height = i_y2;
- result.Add($"{charCode:D5} = {x1 + _x1}, {y1 + _y1}, {x1 + _x1 + _x2}, {y1 + _y1 + _y2}");
+ result.Add($"{charCode:D5} = {x1 + i_x1}, {y1 + i_y1}, {x1 + i_x1 + i_x2}, {y1 + i_y1 + i_y2}");
}
result.Insert(0, $"height = {height}");
result.Insert(0, "[mb_symbol_coords]");
- if (File.Exists(ini_filePath))
+ if (File.Exists(iniFilePath))
{
- File.SetAttributes(ini_filePath, FileAttributes.Normal);
- File.Delete(ini_filePath);
+ File.SetAttributes(iniFilePath, FileAttributes.Normal);
+ File.Delete(iniFilePath);
}
- File.WriteAllLines(ini_filePath, result);
+ File.WriteAllLines(iniFilePath, result);
}
}
@@ -730,7 +739,7 @@ private void btnCustomFont_Click(object sender, EventArgs e)
if (fd.ShowDialog() == DialogResult.OK)
{
- customFontPath = fd.FileName;
+ CustomFontPath = fd.FileName;
if (ComboBox_FontName.SelectedIndex != -1)
{
ComboBox_FontName.SelectedIndex = -1;
@@ -738,10 +747,10 @@ private void btnCustomFont_Click(object sender, EventArgs e)
ReDraw();
- lblCustomFontName.Text = Path.GetFileName(customFontPath);
+ lblCustomFontName.Text = Path.GetFileName(CustomFontPath);
- collection.AddFontFile(customFontPath);
- lblCustomFontName.Font = new Font(collection.Families[collection.Families.Length - 1], (int)Math.Round(NumericUpDown_Size.Value), GetSelectedStyles(), GraphicsUnit.Pixel);
+ Collection.AddFontFile(CustomFontPath);
+ lblCustomFontName.Font = new Font(Collection.Families[Collection.Families.Length - 1], (int)Math.Round(NumericUpDown_Size.Value), GetSelectedStyles(), GraphicsUnit.Pixel);
}
}
}
@@ -788,15 +797,31 @@ private void btnEditText_Click(object sender, EventArgs e)
else
{
FontGenContent.Show();
- FontGenContent.SetText(TestStrings);
+ FontGenContent.SetText(_testStrings);
}
}
public void SetContent(string[] lines)
{
- TestStrings = lines;
+ _testStrings = lines;
ReDraw();
}
+
+ private void btnAutosize_Click(object sender, EventArgs e)
+ {
+ int PhysicalWidth = (int)Math.Round(NumericUpDown_PhysicalWidth.Value);
+ int PhysicalHeight = (int)Math.Round(NumericUpDown_PhysicalHeight.Value);
+
+ var (_, gl) = GetChars(PhysicalWidth, PhysicalHeight);
+
+ PhysicalWidth = (from g in gl
+ select g.VirtualBox.Width + 4).Max();
+ PhysicalHeight = (from g in gl
+ select g.VirtualBox.Height + 4).Max();
+
+ NumericUpDown_PhysicalWidth.Value = PhysicalWidth;
+ NumericUpDown_PhysicalHeight.Value = PhysicalHeight;
+ }
}
}
\ No newline at end of file