Skip to content

Commit

Permalink
afs.core: log pyft version
Browse files Browse the repository at this point in the history
  • Loading branch information
MIRIMIRIM committed Jun 13, 2024
1 parent fbd7e61 commit 2eee4eb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions AssFontSubset.Core/src/PyFontTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PyFontTools(string pyftsubset, string ttx, ILogger? logger)

public void SubsetFonts(List<SubsetFont> subsetFonts, string outputFolder)
{
GetFontToolsVersion();
var randoms = SubsetFont.GenerateRandomStrings(8, subsetFonts.Count);
var num = 0;
foreach (var subsetFont in subsetFonts)
Expand All @@ -45,6 +46,7 @@ public void SubsetFonts(List<SubsetFont> subsetFonts, string outputFolder)
public void SubsetFonts(Dictionary<string, List<SubsetFont>> subsetFonts, string outputFolder, out Dictionary<string, string> nameMap)
{
_logger?.ZLogInformation($"开始字体子集化");
GetFontToolsVersion();
nameMap = [];
_logger?.ZLogDebug($"生成随机不重复的字体名");
var randoms = SubsetFont.GenerateRandomStrings(8, subsetFonts.Keys.Count);
Expand Down Expand Up @@ -284,4 +286,21 @@ private ProcessStartInfo GetCompileFontCmd(SubsetFont ssf)
startInfo.EnvironmentVariables["PYTHONIOENCODING"] = "utf-8";
return startInfo;
}

private void GetFontToolsVersion()
{
var startInfo = GetSimpleCmd(_ttx);
startInfo.ArgumentList.Add("--version");
using var process = Process.Start(startInfo);
if (process != null)
{
var output = process.StandardOutput.ReadToEnd().Trim('\n');
process.WaitForExit();
_logger?.ZLogInformation($"使用的 pyFontTools 版本为:{output}");
}
else
{
throw new Exception($"命令执行失败:{startInfo.FileName} {string.Join(' ', startInfo.ArgumentList)}");
}
}
}

0 comments on commit 2eee4eb

Please sign in to comment.