PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

No Fonts installed on this device

Open darzid opened this issue 4 years ago • 1 comments

I ran into this exception when trying to generate a PDF on Linux, CentOS 7. Initially I thought I ran into issue #125, and hoped to resolve it by upgrading from v.1.2.11 to v1.2.12.

However, v1.2.12 still raised the same exception: No Fonts installed on this device!

I've tried the following:

  1. After reading issue #125, I looked into my etc/fonts/fonts.conf file, to determine where fonts could be located on this Linux server. The fonts.conf file included ~/.fonts. Because I had read/write access to that directory, I copied a single .ttf file into ~/.fonts. Still I got the same message. This rules out the "non recursive folder search" (as described in #125) as the root cause for my problem.
  2. I downgraded to v1.2.6, the version that didn't have the issue reported in #125. However, 1.2.6 gave another exception: "Could not find a part of the path '/usr/share/fonts/truetype'."

So I reverted that downgrade, because it didn't solve my problem. Based on my findings, the exception message is the same as #125, but has another root cause. If there's anything I can check on my CentOS 7 system, let me know.

Stack trace from v1.2.12:

Exception: No Fonts installed on this device! Stack trace: at PdfSharpCore.Utils.FontResolver.ResolveTypeface(String familyName, Boolean isBold, Boolean isItalic) at PdfSharpCore.Fonts.FontFactory.ResolveTypeface(String familyName, FontResolvingOptions fontResolvingOptions, String typefaceKey) at PdfSharpCore.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharpCore.Drawing.XFont.Initialize() at CTS.CertificateGenerator.CertificateGenerator.Generate(CertificateElements certificateElements, CertificateElementValues certificateElementValues, String fontName, Int32 fontSize, String filePath) at CTS.CTSService.PrerequisiteChecker.GenerateTestCertificate(AppSettings appSettings) at CTS.CTSService.PrerequisiteChecker.<>c__DisplayClass0_0.<CheckPrerequisites>b__0() Unhandled exception. System.IO.FileNotFoundException: No Fonts installed on this device!s, ILogger logger, String scopeName, String check, Action checkMethod) at PdfSharpCore.Utils.FontResolver.ResolveTypeface(String familyName, Boolean isBold, Boolean isItalic) at PdfSharpCore.Fonts.FontFactory.ResolveTypeface(String familyName, FontResolvingOptions fontResolvingOptions, String typefaceKey) at PdfSharpCore.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharpCore.Drawing.XFont.Initialize()

Stack trace from v1.2.6:

Exception: The type initializer for 'PdfSharpCore.Utils.FontResolver' threw an exception. Stack trace:
at PdfSharpCore.Utils.FontResolver..ctor() at PdfSharpCore.Fonts.GlobalFontSettings.get_FontResolver() at PdfSharpCore.Fonts.FontFactory.ResolveTypeface(String familyName, FontResolvingOptions fontResolvingOptions, String typefaceKey) at PdfSharpCore.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharpCore.Drawing.XFont.Initialize() at CTS.CertificateGenerator.CertificateGenerator.Generate(CertificateElements certificateElements, CertificateElementValues certificateElementValues, String fontName, Int32 fontSize, String filePath) at CTS.CTSService.PrerequisiteChecker.GenerateTestCertificate(AppSettings appSettings) at CTS.CTSService.PrerequisiteChecker.<>c__DisplayClass0_0.<CheckPrerequisites>b__0()

Unhandled exception. System.TypeInitializationException: The type initializer for 'PdfSharpCore.Utils.FontResolver' threw an exception.ck, Action checkMethod) ---> System.IO.DirectoryNotFoundException: Could not find a part of the path '/usr/share/fonts/truetype'. at System.IO.Enumeration.FileSystemEnumerator1.CreateDirectoryHandle(String path, Boolean ignoreNotFound) at System.IO.Enumeration.FileSystemEnumerator1.Init() at System.IO.Enumeration.FileSystemEnumerator1..ctor(String directory, Boolean isNormalized, EnumerationOptions options) at System.IO.Enumeration.FileSystemEnumerable1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized) at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options) at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options) at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) at PdfSharpCore.Utils.FontResolver..cctor() --- End of inner exception stack trace --- at PdfSharpCore.Utils.FontResolver..ctor() at PdfSharpCore.Fonts.GlobalFontSettings.get_FontResolver() at PdfSharpCore.Fonts.FontFactory.ResolveTypeface(String familyName, FontResolvingOptions fontResolvingOptions, String typefaceKey) at PdfSharpCore.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharpCore.Drawing.XFont.Initialize()

darzid avatar Mar 02 '21 20:03 darzid

Duplicate of https://github.com/ststeiger/PdfSharpCore/issues/161

Lure5134 avatar Jun 21 '21 19:06 Lure5134