Skip to content

Commit

Permalink
afs.core, cmd: not truncate style fontname and print log (fix #11), n…
Browse files Browse the repository at this point in the history
…ow ava not support print log
  • Loading branch information
MIRIMIRIM committed May 9, 2024
1 parent 406d16b commit dda4319
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
8 changes: 7 additions & 1 deletion AssFontSubset.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ static void Subset(FileInfo[] path, DirectoryInfo? fontPath, DirectoryInfo? outp
{
// \u001b[31m => Red(ANSI Escape Code)
// \u001b[0m => Reset
var escapeSequence = info.LogLevel >= LogLevel.Error? "\u001b[31m" : "\u001b[0m";
var escapeSequence = info.LogLevel switch
{
LogLevel.Warning => "\u001b[33m",
> LogLevel.Warning => "\u001b[31m",
_ => "\u001b[0m",
};
template.Format(escapeSequence, info.Timestamp, info.LogLevel);
});
Expand Down
2 changes: 1 addition & 1 deletion AssFontSubset.Core/AssFontSubset.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mobsub.SubtitleParse" Version="0.3.1" />
<PackageReference Include="Mobsub.SubtitleParse" Version="0.3.3" />
<PackageReference Include="OTFontFile" Version="1.0.1-beta" />
</ItemGroup>

Expand Down
7 changes: 4 additions & 3 deletions AssFontSubset.Core/src/AssFont.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Mobsub.SubtitleParse;
using Microsoft.Extensions.Logging;
using Mobsub.SubtitleParse;
using Mobsub.SubtitleParse.AssTypes;
using System.Text;

namespace AssFontSubset.Core;

public class AssFont
{
public static Dictionary<AssFontInfo, List<Rune>> GetAssFonts(string file, out AssData ass)
public static Dictionary<AssFontInfo, List<Rune>> GetAssFonts(string file, out AssData ass, ILogger? logger = null)
{
ass = new AssData();
ass = new AssData(logger);
ass.ReadAssFile(file);

var usedStyles = GetUsedStyles(ass.Events.Collection);
Expand Down
4 changes: 2 additions & 2 deletions AssFontSubset.Core/src/SubsetByPyFT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ Dictionary<AssFontInfo, List<Rune>> GetAssFontInfoFromFiles(FileInfo[] assFiles,

foreach (var assFile in assFiles)
{
_logger?.ZLogInformation($"{assFile.FullName}");
//_logger?.ZLogInformation($"{assFile.FullName}");
var assFileNew = Path.Combine(optDir, assFile.Name);
var assFonts = AssFont.GetAssFonts(assFile.FullName, out var ass);
var assFonts = AssFont.GetAssFonts(assFile.FullName, out var ass, _logger);

foreach (var kv in assFonts)
{
Expand Down
2 changes: 1 addition & 1 deletion AssFontSubset.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssFontSubset.Core", "AssFo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssFontSubset.Avalonia", "AssFontSubset.Avalonia\AssFontSubset.Avalonia.csproj", "{228541CF-C1A6-48C5-8B60-95538E049C25}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssFontSubset.Core.Tests", "AssFontSubset.CoreTests\AssFontSubset.Core.Tests.csproj", "{E003AA3B-7C95-4FA3-AB7D-529B71BBD85D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssFontSubset.Core.Tests", "AssFontSubset.CoreTests\AssFontSubset.Core.Tests.csproj", "{E003AA3B-7C95-4FA3-AB7D-529B71BBD85D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit dda4319

Please sign in to comment.