diff --git a/_sources/FontGen/FontGenForm.Console.cs b/_sources/FontGen/FontGenForm.Console.cs index 4dabde2..a819a03 100644 --- a/_sources/FontGen/FontGenForm.Console.cs +++ b/_sources/FontGen/FontGenForm.Console.cs @@ -143,24 +143,24 @@ public static int MainConsole() { case 1: { - Char32[] s = argv[0].ToLower().ToUTF32(); + string s = argv[0].ToLower(); if (s.Length != 4) throw new ArgumentException(string.Join(",", opt.Arguments)); for (int n = 0; n <= 3; n++) { - switch (n.ToString()) + switch (s[n]) { - case "0": + case '0': { ChannelPatterns[n] = ChannelPattern.Zero; break; } - case "x": + case 'x': { ChannelPatterns[n] = ChannelPattern.Draw; break; } - case "1": + case '1': { ChannelPatterns[n] = ChannelPattern.One; break; @@ -168,7 +168,7 @@ public static int MainConsole() default: { - throw new ArgumentException(string.Join(",", opt.Arguments)); + throw new ArgumentException(n.ToString()); } } } diff --git a/_sources/FontGen/FontGenForm.Designer.cs b/_sources/FontGen/FontGenForm.Designer.cs index f29b8f9..1dcf45a 100644 --- a/_sources/FontGen/FontGenForm.Designer.cs +++ b/_sources/FontGen/FontGenForm.Designer.cs @@ -31,7 +31,6 @@ protected override void Dispose(bool disposing) [System.Diagnostics.DebuggerStepThrough()] private void InitializeComponent() { - System.Windows.Forms.Label label1; System.Windows.Forms.Label label2; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FontGenForm)); this.Label_FontName = new System.Windows.Forms.Label(); @@ -65,16 +64,13 @@ private void InitializeComponent() this.NumericUpDown_VirtualDeltaWidth = new System.Windows.Forms.NumericUpDown(); this.NumericUpDown_VirtualDeltaHeight = new System.Windows.Forms.NumericUpDown(); this.Button_Generate = new System.Windows.Forms.Button(); - this.Button_CmdToClipboard = new System.Windows.Forms.Button(); this.CheckBox_AnchorLeft = new System.Windows.Forms.CheckBox(); - this.ddlBPP = new System.Windows.Forms.ComboBox(); - this.chkDrawAlpha = new System.Windows.Forms.CheckBox(); + this.chkCopMode = new System.Windows.Forms.CheckBox(); this.btnCustomFont = new System.Windows.Forms.Button(); this.txtTargetPath = new System.Windows.Forms.TextBox(); - this.chkDelTemp = new System.Windows.Forms.CheckBox(); + this.chkUTF8 = 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(); ((System.ComponentModel.ISupportInitialize)(this.NumericUpDown_PhysicalWidth)).BeginInit(); @@ -95,17 +91,6 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.NumericUpDown_VirtualDeltaHeight)).BeginInit(); this.SuspendLayout(); // - // label1 - // - label1.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - label1.Location = new System.Drawing.Point(8, 559); - label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - label1.Name = "label1"; - label1.Size = new System.Drawing.Size(113, 31); - label1.TabIndex = 10; - label1.Text = "BitPerPixel"; - label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // label2 // label2.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); @@ -340,8 +325,8 @@ private void InitializeComponent() // this.SplitContainer_Main.Panel2.AutoScroll = true; this.SplitContainer_Main.Panel2.Controls.Add(this.panel2); - this.SplitContainer_Main.Size = new System.Drawing.Size(1103, 787); - this.SplitContainer_Main.SplitterDistance = 253; + this.SplitContainer_Main.Size = new System.Drawing.Size(1103, 819); + this.SplitContainer_Main.SplitterDistance = 262; this.SplitContainer_Main.SplitterWidth = 5; this.SplitContainer_Main.TabIndex = 5; // @@ -354,7 +339,7 @@ private void InitializeComponent() this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Margin = new System.Windows.Forms.Padding(4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(1103, 253); + this.panel1.Size = new System.Drawing.Size(1103, 262); this.panel1.TabIndex = 0; // // PictureBox_Preview @@ -363,8 +348,7 @@ private void InitializeComponent() this.PictureBox_Preview.Location = new System.Drawing.Point(0, 0); this.PictureBox_Preview.Margin = new System.Windows.Forms.Padding(4); this.PictureBox_Preview.Name = "PictureBox_Preview"; - this.PictureBox_Preview.Size = new System.Drawing.Size(827, 190); - this.PictureBox_Preview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.PictureBox_Preview.Size = new System.Drawing.Size(1103, 259); this.PictureBox_Preview.TabIndex = 5; this.PictureBox_Preview.TabStop = false; // @@ -377,7 +361,7 @@ private void InitializeComponent() this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Margin = new System.Windows.Forms.Padding(4); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(1103, 529); + this.panel2.Size = new System.Drawing.Size(1103, 552); this.panel2.TabIndex = 0; // // PictureBox_Preview2x @@ -386,7 +370,7 @@ private void InitializeComponent() this.PictureBox_Preview2x.Location = new System.Drawing.Point(0, 0); this.PictureBox_Preview2x.Margin = new System.Windows.Forms.Padding(4); this.PictureBox_Preview2x.Name = "PictureBox_Preview2x"; - this.PictureBox_Preview2x.Size = new System.Drawing.Size(1103, 525); + this.PictureBox_Preview2x.Size = new System.Drawing.Size(1103, 552); this.PictureBox_Preview2x.TabIndex = 5; this.PictureBox_Preview2x.TabStop = false; // @@ -585,7 +569,7 @@ private void InitializeComponent() // Button_Generate // this.Button_Generate.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.Button_Generate.Location = new System.Drawing.Point(8, 684); + this.Button_Generate.Location = new System.Drawing.Point(8, 815); this.Button_Generate.Margin = new System.Windows.Forms.Padding(4); this.Button_Generate.Name = "Button_Generate"; this.Button_Generate.Size = new System.Drawing.Size(269, 41); @@ -594,18 +578,6 @@ private void InitializeComponent() this.Button_Generate.UseVisualStyleBackColor = true; this.Button_Generate.Click += new System.EventHandler(this.Button_Generate_Click); // - // Button_CmdToClipboard - // - this.Button_CmdToClipboard.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.Button_CmdToClipboard.Location = new System.Drawing.Point(8, 635); - this.Button_CmdToClipboard.Margin = new System.Windows.Forms.Padding(4); - this.Button_CmdToClipboard.Name = "Button_CmdToClipboard"; - this.Button_CmdToClipboard.Size = new System.Drawing.Size(269, 41); - this.Button_CmdToClipboard.TabIndex = 8; - this.Button_CmdToClipboard.Text = "Commandline to the clipboard"; - this.Button_CmdToClipboard.UseVisualStyleBackColor = true; - this.Button_CmdToClipboard.Click += new System.EventHandler(this.Button_CmdToClipboard_Click); - // // CheckBox_AnchorLeft // this.CheckBox_AnchorLeft.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); @@ -618,33 +590,19 @@ private void InitializeComponent() this.CheckBox_AnchorLeft.UseVisualStyleBackColor = true; this.CheckBox_AnchorLeft.CheckedChanged += new System.EventHandler(this.CheckBox_DoubleSample_CheckedChanged); // - // ddlBPP - // - this.ddlBPP.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ddlBPP.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.ddlBPP.FormattingEnabled = true; - this.ddlBPP.Items.AddRange(new object[] { - "8", - "32"}); - this.ddlBPP.Location = new System.Drawing.Point(8, 594); - this.ddlBPP.Margin = new System.Windows.Forms.Padding(4); - this.ddlBPP.Name = "ddlBPP"; - this.ddlBPP.Size = new System.Drawing.Size(113, 27); - this.ddlBPP.TabIndex = 11; - // - // chkDrawAlpha - // - this.chkDrawAlpha.Checked = true; - this.chkDrawAlpha.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkDrawAlpha.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.chkDrawAlpha.Location = new System.Drawing.Point(8, 784); - this.chkDrawAlpha.Margin = new System.Windows.Forms.Padding(4); - this.chkDrawAlpha.Name = "chkDrawAlpha"; - this.chkDrawAlpha.Size = new System.Drawing.Size(269, 40); - this.chkDrawAlpha.TabIndex = 12; - this.chkDrawAlpha.Text = "DrawAlpha (NON CoP)"; - this.chkDrawAlpha.UseVisualStyleBackColor = true; - this.chkDrawAlpha.CheckedChanged += new System.EventHandler(this.chkDrawAlpha_CheckedChanged); + // chkCopMode + // + this.chkCopMode.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.chkCopMode.Location = new System.Drawing.Point(8, 629); + this.chkCopMode.Margin = new System.Windows.Forms.Padding(4); + this.chkCopMode.Name = "chkCopMode"; + this.chkCopMode.Size = new System.Drawing.Size(269, 111); + this.chkCopMode.TabIndex = 12; + this.chkCopMode.Text = "COP-style font texture (not recommended, SHOC-style has better quality, but needs" + + " use \'font\' shader in \'fonts.ltx\')"; + this.chkCopMode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.chkCopMode.UseVisualStyleBackColor = true; + this.chkCopMode.CheckedChanged += new System.EventHandler(this.chkDrawAlpha_CheckedChanged); // // btnCustomFont // @@ -652,7 +610,7 @@ private void InitializeComponent() this.btnCustomFont.Location = new System.Drawing.Point(8, 87); this.btnCustomFont.Margin = new System.Windows.Forms.Padding(4); this.btnCustomFont.Name = "btnCustomFont"; - this.btnCustomFont.Size = new System.Drawing.Size(269, 33); + this.btnCustomFont.Size = new System.Drawing.Size(269, 41); this.btnCustomFont.TabIndex = 13; this.btnCustomFont.Text = "CustomFont"; this.btnCustomFont.UseVisualStyleBackColor = true; @@ -667,28 +625,29 @@ private void InitializeComponent() this.txtTargetPath.Size = new System.Drawing.Size(896, 27); this.txtTargetPath.TabIndex = 16; // - // chkDelTemp + // chkUTF8 // - this.chkDelTemp.Checked = true; - this.chkDelTemp.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkDelTemp.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.chkDelTemp.Location = new System.Drawing.Point(8, 736); - this.chkDelTemp.Margin = new System.Windows.Forms.Padding(4); - this.chkDelTemp.Name = "chkDelTemp"; - this.chkDelTemp.Size = new System.Drawing.Size(269, 40); - this.chkDelTemp.TabIndex = 17; - this.chkDelTemp.Text = "Remove temp files"; - this.chkDelTemp.UseVisualStyleBackColor = true; + this.chkUTF8.Checked = true; + this.chkUTF8.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkUTF8.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.chkUTF8.Location = new System.Drawing.Point(8, 748); + this.chkUTF8.Margin = new System.Windows.Forms.Padding(4); + this.chkUTF8.Name = "chkUTF8"; + this.chkUTF8.Size = new System.Drawing.Size(269, 59); + this.chkUTF8.TabIndex = 17; + this.chkUTF8.Text = "UTF-8 font (full support only in OGSR Engine)"; + this.chkUTF8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.chkUTF8.UseVisualStyleBackColor = true; // // btnEditText // this.btnEditText.Font = new System.Drawing.Font("Arial", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.btnEditText.Location = new System.Drawing.Point(157, 580); + this.btnEditText.Location = new System.Drawing.Point(8, 580); this.btnEditText.Margin = new System.Windows.Forms.Padding(4); this.btnEditText.Name = "btnEditText"; - this.btnEditText.Size = new System.Drawing.Size(120, 41); + this.btnEditText.Size = new System.Drawing.Size(269, 41); this.btnEditText.TabIndex = 18; - this.btnEditText.Text = "Edit content"; + this.btnEditText.Text = "Edit symbols"; this.btnEditText.UseVisualStyleBackColor = true; this.btnEditText.Click += new System.EventHandler(this.btnEditText_Click); // @@ -708,17 +667,14 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1413, 837); + this.ClientSize = new System.Drawing.Size(1413, 869); this.Controls.Add(this.btnAutosize); + this.Controls.Add(this.chkUTF8); this.Controls.Add(this.btnEditText); - this.Controls.Add(this.chkDelTemp); this.Controls.Add(this.txtTargetPath); this.Controls.Add(label2); this.Controls.Add(this.btnCustomFont); - this.Controls.Add(this.chkDrawAlpha); - this.Controls.Add(this.ddlBPP); - this.Controls.Add(label1); - this.Controls.Add(this.Button_CmdToClipboard); + this.Controls.Add(this.chkCopMode); this.Controls.Add(this.Button_Generate); this.Controls.Add(this.SplitContainer_Main); this.Controls.Add(this.NumericUpDown_VirtualDeltaHeight); @@ -766,7 +722,6 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.SplitContainer_Main)).EndInit(); this.SplitContainer_Main.ResumeLayout(false); this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.PictureBox_Preview)).EndInit(); this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.PictureBox_Preview2x)).EndInit(); @@ -807,17 +762,15 @@ private void InitializeComponent() internal System.Windows.Forms.NumericUpDown NumericUpDown_VirtualDeltaWidth; internal System.Windows.Forms.NumericUpDown NumericUpDown_VirtualDeltaHeight; internal System.Windows.Forms.Button Button_Generate; - internal System.Windows.Forms.Button Button_CmdToClipboard; internal System.Windows.Forms.CheckBox CheckBox_AnchorLeft; - private System.Windows.Forms.ComboBox ddlBPP; - private System.Windows.Forms.CheckBox chkDrawAlpha; + private System.Windows.Forms.CheckBox chkCopMode; private System.Windows.Forms.Button btnCustomFont; private System.Windows.Forms.TextBox txtTargetPath; private System.Windows.Forms.Panel panel1; internal System.Windows.Forms.PictureBox PictureBox_Preview; private System.Windows.Forms.Panel panel2; internal System.Windows.Forms.PictureBox PictureBox_Preview2x; - private System.Windows.Forms.CheckBox chkDelTemp; + private System.Windows.Forms.CheckBox chkUTF8; private System.Windows.Forms.Button btnEditText; private System.Windows.Forms.Button btnAutosize; } diff --git a/_sources/FontGen/FontGenForm.cs b/_sources/FontGen/FontGenForm.cs index 27d75d1..bab968c 100644 --- a/_sources/FontGen/FontGenForm.cs +++ b/_sources/FontGen/FontGenForm.cs @@ -15,6 +15,7 @@ using System.Drawing.Text; using System.IO; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using Firefly; @@ -23,6 +24,13 @@ using Firefly.TextEncoding; using Firefly.Texting; +[assembly: AssemblyTitle("Fonts generator for the X-Ray Engine")] +[assembly: AssemblyDescription("Fonts generator for the X-Ray Engine")] +[assembly: AssemblyCompany("OGSR")] +[assembly: AssemblyProduct("Fonts Generator")] +[assembly: AssemblyCopyright("OGSR © 2024")] +[assembly: AssemblyVersion("1.0")] + namespace FontGen { public partial class FontGenForm @@ -383,7 +391,7 @@ private void ReDraw() ChannelPattern[] ChannelPatterns = [ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw]; - if (!chkDrawAlpha.Checked) + if (chkCopMode.Checked) ChannelPatterns[0] = ChannelPattern.One; IGlyphProvider gg; @@ -470,8 +478,6 @@ private void FontGen_Load(object sender, EventArgs e) ComboBox_FontName.DataSource = FontFamily.Families.ToList(); ComboBox_FontName.SelectedIndex = 0; ReDraw(); - - ddlBPP.SelectedItem = "32"; } private void FontGen_Shown(object sender, EventArgs e) @@ -600,13 +606,9 @@ private void Button_Generate_Click(object sender, EventArgs e) ChannelPattern[] ChannelPatterns = [ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw, ChannelPattern.Draw]; - bool copMode = !chkDrawAlpha.Checked; - - if (copMode) + if (chkCopMode.Checked) ChannelPatterns[0] = ChannelPattern.One; - int bpp = int.Parse(ddlBPP.SelectedItem.ToString()); - IEnumerable glyphs = GenerateFont( "", GetSelectedFont(), Style, @@ -648,19 +650,21 @@ private void Button_Generate_Click(object sender, EventArgs e) string fdFilePath = FileNameHandling.ChangeExtension(path, "fd"); string bmpFilePath = FileNameHandling.ChangeExtension(path, "bmp"); + int bpp = chkCopMode.Checked ? 8 : 32; + SaveFont(glyphs, fdFilePath, -1, -1, bpp, false, false); string toolDir = AppDomain.CurrentDomain.BaseDirectory + "\\Bins"; string ddsFormat = bpp == 32 ? "-32" : "-8"; ddsFormat += " "; - ddsFormat += copMode ? "A8" : "u8888"; + ddsFormat += chkCopMode.Checked ? "A8" : "u8888"; FbToIni(fdFilePath); RunAndWait(wortDir, Path.Combine(toolDir, "nvdxt.exe"), $"-file \"{Path.GetFileName(bmpFilePath)}\" -outdir \"{wortDir}\" -nomipmap {ddsFormat}"); - if (chkDelTemp.Checked) + //if (chkDelTemp.Checked) { string iniFilePath = FileNameHandling.ChangeExtension(path, "ini"); string ddsFilePath = FileNameHandling.ChangeExtension(path, "dds"); @@ -683,7 +687,7 @@ private void FbToIni(string fdFilePath) if (File.Exists(fdFilePath)) { string[] lines = File.ReadAllLines(fdFilePath); - + Dictionary chars_map = new Dictionary(); List result = new List(); int height = -1; @@ -693,6 +697,81 @@ private void FbToIni(string fdFilePath) int charCode = int.Parse(parts[0].Substring(2), System.Globalization.NumberStyles.HexNumber); + if (!chkUTF8.Checked) + { + switch (charCode) + { + case 0x401: // Ё + { + charCode = 0xA8; + break; + } + case 0x451: // ё + { + charCode = 0xB8; + break; + } + case 0x2116: // № + { + charCode = 0xB9; + break; + } + case 0x2014: // — + { + charCode = 0x97; + break; + } + case 0x490: // Ґ + { + charCode = 0xA5; + break; + } + case 0x491: // ґ + { + charCode = 0xB4; + break; + } + case 0x404: // Є + { + charCode = 0xAA; + break; + } + case 0x454: // є + { + charCode = 0xBA; + break; + } + case 0x406: // І + { + charCode = 0xB2; + break; + } + case 0x456: // і + { + charCode = 0xB3; + break; + } + case 0x407: // Ї + { + charCode = 0xAF; + break; + } + case 0x457: // ї + { + charCode = 0xBF; + break; + } + default: + { + if (charCode >= 0x410 && charCode < (0x410 + 256)) + { + charCode -= 848; + } + break; + } + } + } + int x1, y1; x1 = int.Parse(parts[2]); @@ -710,11 +789,27 @@ private void FbToIni(string fdFilePath) height = i_y2; - result.Add($"{charCode:D5} = {x1 + i_x1}, {y1 + i_y1}, {x1 + i_x1 + i_x2}, {y1 + i_y1 + i_y2}"); + if (chkUTF8.Checked || charCode <= 0xff) + { + if (chkUTF8.Checked) + result.Add($"{charCode:D5} = {x1 + i_x1}, {y1 + i_y1}, {x1 + i_x1 + i_x2}, {y1 + i_y1 + i_y2}"); + else + result.Add($"{charCode:D3} = {x1 + i_x1}, {y1 + i_y1}, {x1 + i_x1 + i_x2}, {y1 + i_y1 + i_y2}"); + chars_map[charCode] = true; + } + } + + if (!chkUTF8.Checked) + { + for (int i = 0; i <= 0xff; i++) + { + if (!chars_map.ContainsKey(i)) + result.Add($"{i:D3} = {0}, {0}, {0}, {0}"); + } } result.Insert(0, $"height = {height}"); - result.Insert(0, "[mb_symbol_coords]"); + result.Insert(0, chkUTF8.Checked ? "[mb_symbol_coords]" : "[symbol_coords]"); if (File.Exists(iniFilePath)) { diff --git a/_sources/FontGen/FontGenForm.resx b/_sources/FontGen/FontGenForm.resx index 3d93f20..f95f094 100644 --- a/_sources/FontGen/FontGenForm.resx +++ b/_sources/FontGen/FontGenForm.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - False - False