Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Fix blank text in rhwp PDFs on Linux
Perricheno26fed6f7174e
diff --git a/src/Filee.Engines/Hwp/RhwpInput.cs b/src/Filee.Engines/Hwp/RhwpInput.csindex d690b10d..e64e05e1 100644--- a/src/Filee.Engines/Hwp/RhwpInput.cs+++ b/src/Filee.Engines/Hwp/RhwpInput.cs@@ -128,14 +128,33 @@ internal static partial class RhwpInput}/// <summary>- /// Options for <c>rhwp export-pdf</c>: Cambria Math for equations when none of the fonts rhwp draws their symbols- /// with is installed.+ /// Options for <c>rhwp export-pdf</c>: installed generic fallback families (some Linux installations do not have+ /// rhwp's Korean defaults, which otherwise leaves every missing-font run blank), and Cambria Math for equations+ /// when none of the fonts rhwp draws their symbols with is installed./// </summary>public static IReadOnlyList<string> PdfOptions(Func<string, InstalledFont?>? lookup = null){lookup ??= RhwpFonts.Find;+ var options = new List<string>();+ AddFallback("--fallback-serif", ["Times New Roman", "Noto Serif", "DejaVu Serif", "Georgia", "Liberation Serif"]);+ AddFallback("--fallback-sans", ["Segoe UI", "Tahoma", "Arial", "Noto Sans", "DejaVu Sans", "Helvetica", "Liberation Sans"]);+ AddFallback("--fallback-mono", ["Cascadia Mono", "Consolas", "SF Mono", "Menlo", "Noto Sans Mono", "DejaVu Sans Mono", "Liberation Mono"]);+var hasSymbols = new[] { "Latin Modern Math", "STIX Two Math", "Arial Unicode MS" }.Any(f => lookup(f) is { Usable: true });- return !hasSymbols && lookup("Cambria Math") is { Usable: true } ? ["--equation-font", "Cambria Math"] : [];+ if (!hasSymbols && lookup("Cambria Math") is { Usable: true })+ {+ options.Add("--equation-font");+ options.Add("Cambria Math");+ }+ return options;++ void AddFallback(string option, IReadOnlyList<string> families)+ {+ if (families.FirstOrDefault(f => lookup(f) is { Usable: true }) is not { } family)+ return;+ options.Add(option);+ options.Add(family);+ }}private static XDocument Load(ZipArchiveEntry entry)diff --git a/tests/Filee.Engines.Tests/RhwpInputTests.cs b/tests/Filee.Engines.Tests/RhwpInputTests.csindex e01c31dd..e71d0682 100644--- a/tests/Filee.Engines.Tests/RhwpInputTests.cs+++ b/tests/Filee.Engines.Tests/RhwpInputTests.cs@@ -138,6 +138,20 @@ public class RhwpInputTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.Empty(RhwpInput.PdfOptions(_ => null));}+ [Fact]+ public void Installed_generic_fonts_are_passed_to_rhwp_as_pdf_fallbacks()+ {+ static InstalledFont? Lookup(string name) => name is "Noto Serif" or "Noto Sans" or "Noto Sans Mono"+ ? new InstalledFont(true, _ => true)+ : null;++ Assert.Equal([+ "--fallback-serif", "Noto Serif",+ "--fallback-sans", "Noto Sans",+ "--fallback-mono", "Noto Sans Mono",+ ], RhwpInput.PdfOptions(Lookup));+ }+/// <summary>/// The #49 form in a package of Filee's HWPX writer: "Before", then the tall outer table. With/// <paramref name="fromHwp"/> it carries the marker rhwp's export-hwpx writes.