From 74655b4ec52617898a6857e718b802cf43fd673c Mon Sep 17 00:00:00 2001 From: BobLd <38405645+BobLd@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:33:07 +0100 Subject: [PATCH] Add early version of BrowserSystemFontLister --- .../SystemFonts/BrowserSystemFontLister.cs | 16 ++++++++++++++++ .../SystemFonts/SystemFontFinder.cs | 6 +++++- .../SystemFonts/WindowsSystemFontLister.cs | 2 -- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/UglyToad.PdfPig.Fonts/SystemFonts/BrowserSystemFontLister.cs diff --git a/src/UglyToad.PdfPig.Fonts/SystemFonts/BrowserSystemFontLister.cs b/src/UglyToad.PdfPig.Fonts/SystemFonts/BrowserSystemFontLister.cs new file mode 100644 index 000000000..b0cf6849d --- /dev/null +++ b/src/UglyToad.PdfPig.Fonts/SystemFonts/BrowserSystemFontLister.cs @@ -0,0 +1,16 @@ +namespace UglyToad.PdfPig.Fonts.SystemFonts +{ +#if NET + using System.Collections.Generic; + + internal sealed class BrowserSystemFontLister : ISystemFontLister + { + // Very early version, intended to help developing support for browser + + public IEnumerable GetAllFonts() + { + yield break; + } + } +#endif +} diff --git a/src/UglyToad.PdfPig.Fonts/SystemFonts/SystemFontFinder.cs b/src/UglyToad.PdfPig.Fonts/SystemFonts/SystemFontFinder.cs index 8482ef798..0bbc1e65f 100644 --- a/src/UglyToad.PdfPig.Fonts/SystemFonts/SystemFontFinder.cs +++ b/src/UglyToad.PdfPig.Fonts/SystemFonts/SystemFontFinder.cs @@ -92,7 +92,11 @@ static SystemFontFinder() #if NET else if (OperatingSystem.IsAndroid()) { - lister = new AndroidSystemFontLister(); + lister = new AndroidSystemFontLister(); + } + else if (OperatingSystem.IsBrowser()) + { + lister = new BrowserSystemFontLister(); } #endif else diff --git a/src/UglyToad.PdfPig.Fonts/SystemFonts/WindowsSystemFontLister.cs b/src/UglyToad.PdfPig.Fonts/SystemFonts/WindowsSystemFontLister.cs index a8dc6b8ca..ef6fe5c47 100644 --- a/src/UglyToad.PdfPig.Fonts/SystemFonts/WindowsSystemFontLister.cs +++ b/src/UglyToad.PdfPig.Fonts/SystemFonts/WindowsSystemFontLister.cs @@ -8,8 +8,6 @@ internal sealed class WindowsSystemFontLister : ISystemFontLister { public IEnumerable GetAllFonts() { - // TODO: Could use System.Drawing InstalledFontCollection to do this? - var winDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var fonts = Path.Combine(winDir, "Fonts");