-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (34 loc) · 1.21 KB
/
Program.cs
File metadata and controls
45 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Diagnostics;
using System.Text;
using SixLabors.Fonts;
using TRPEFontGen;
namespace Example;
internal static class Program
{
public static void Main()
{
var stopwatch = new Stopwatch();
stopwatch.Start();
GenFont();
stopwatch.Stop();
Console.WriteLine($"Generate font took {stopwatch.Elapsed.TotalSeconds:F3}s");
}
private static void GenFont()
{
var chars = new HashSet<char>();
// 字符集
AddChar(chars, 0x0020, 0x007E);
AddChar(chars, 0x4E00, 0x9FA5);
AddChar(chars, 0xFF01, 0xFF5E);
// 字体,字体大小,字体样式 (需要自己电脑安装)
var font = SystemFonts.CreateFont("Microsoft YaHei", 15, FontStyle.Regular);
var fontFile = Generator.Generate(font, chars.ToArray(),"Death_Text");
var savePath = Path.Combine("font", "Death_Text");
fontFile.SaveMetaData(savePath);
fontFile.SaveTextures(savePath);
}
private static void AddChar(HashSet<char> chars, int start, int end)
{
for (var i = start; i <= end; i++) chars.Add(Encoding.Unicode.GetChars(BitConverter.GetBytes(i))[0]);
}
}