* UFontAwesomeV6: 减小文件大小

This commit is contained in:
Sunny 2024-06-27 09:57:15 +08:00
parent 3f2bdd86e5
commit 688ff477d1
2 changed files with 2061 additions and 4538 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
@ -202,23 +203,22 @@ namespace Sunny.UI
if (isStart) break; if (isStart) break;
} }
sb.AppendLine("namespace Sunny.UI;"); ConcurrentDictionary<string, string> pairs = new ConcurrentDictionary<string, string>();
sb.AppendLine("");
sb.AppendLine("public static class FontAweSomeV6_Variables");
sb.AppendLine("{");
for (int i = startLine; i < lines.Length; i++) for (int i = startLine; i < lines.Length; i++)
{ {
if (lines[i].Contains("(")) break; if (lines[i].Contains("(")) break;
if (lines[i].IsNullOrEmpty()) continue; if (lines[i].IsNullOrEmpty()) continue;
string line = lines[i]; string line = lines[i];
line = line.Replace("$", " public const int "); line = line.Replace("$fa-var-", "_");
line = line.Replace(": \\", " = 0x"); line = line.Replace(": \\", "=0x");
line = line.Replace("-", "_"); line = line.Replace("-", "_");
sb.AppendLine(line); line = line.Trim();
string[] strs = line.Split('=');
pairs.TryAdd(strs[0], strs[1]);
} }
sb.AppendLine("}"); sb.AppendLine("namespace Sunny.UI;");
sb.AppendLine(""); sb.AppendLine("");
string frpath = path + @"svgs\regular\"; string frpath = path + @"svgs\regular\";
@ -236,7 +236,8 @@ namespace Sunny.UI
FileInfo fileInfo = new FileInfo(files[i]); FileInfo fileInfo = new FileInfo(files[i]);
string line = fileInfo.NameWithoutExt(); string line = fileInfo.NameWithoutExt();
line = line.Replace("-", "_"); line = line.Replace("-", "_");
line = " public const int fa_" + line + " = FontAweSomeV6_Variables.fa_var_" + line + ";"; string value = pairs["_" + line];
line = " public const int fa_" + line + " = " + value;
sb.AppendLine(line); sb.AppendLine(line);
} }
sb.AppendLine("}"); sb.AppendLine("}");
@ -256,7 +257,8 @@ namespace Sunny.UI
FileInfo fileInfo = new FileInfo(files[i]); FileInfo fileInfo = new FileInfo(files[i]);
string line = fileInfo.NameWithoutExt(); string line = fileInfo.NameWithoutExt();
line = line.Replace("-", "_"); line = line.Replace("-", "_");
line = " public const int fa_" + line + " = FontAweSomeV6_Variables.fa_var_" + line + ";"; string value = pairs["_" + line];
line = " public const int fa_" + line + " = " + value;
sb.AppendLine(line); sb.AppendLine(line);
} }
sb.AppendLine("}"); sb.AppendLine("}");
@ -276,7 +278,8 @@ namespace Sunny.UI
FileInfo fileInfo = new FileInfo(files[i]); FileInfo fileInfo = new FileInfo(files[i]);
string line = fileInfo.NameWithoutExt(); string line = fileInfo.NameWithoutExt();
line = line.Replace("-", "_"); line = line.Replace("-", "_");
line = " public const int fa_" + line + " = FontAweSomeV6_Variables.fa_var_" + line + ";"; string value = pairs["_" + line];
line = " public const int fa_" + line + " = " + value;
sb.AppendLine(line); sb.AppendLine(line);
} }
sb.AppendLine("}"); sb.AppendLine("}");