How to use fonts from wwwroot/fonts folder with NewFontsResolver

127 Views Asked by At

ASP.NET MVC application has fonts in ots wwwroot/fonts subfolder.

How to force NewFontResolver to use fors from this directory in both Linux and windows?

In Linux NewFontResolver searches also directory sptecified in FONTCONFIG_PATH environment variable

https://github.com/empira/PDFsharp/blob/a8fe9093a1d0d0b4639d5c412e959cbb796228f9/src/foundation/src/shared/src/PdfSharp.Snippets/Font/fontresolving/NewFontResolver.cs#L195C41-L195C41

but this requires setting environment externally and does not work in windows.

How to add additional font directory from application so so that this or only this directory is also searched ?

1

There are 1 best solutions below

0
On BEST ANSWER

Implement your own IFontResolver.

Maybe copy NewFontResolver and make all the changes you need.
Might be better to write your own IFontResolver that reads font files from app folder. Or from assembly resources.