PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
FailsafeFontResolver understanding http://forum.pdfsharp.de/viewtopic.php?f=2&t=4435 |
Page 1 of 1 |
Author: | qurious [ Tue May 02, 2023 1:54 pm ] |
Post subject: | FailsafeFontResolver understanding |
Hello, I'm asking for help to understand how the FailsafeFontResolver class works. PDFsharp-MigraDoc 6.0.0-preview-2 on Windows is used. Does this line of code Code: var result = PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic); load the specified font if it is installed in the system? In other words, if Arial is specified for the document and Arial is installed, can I use FailsafeFontResolver to load it? Link to GItHub: https://github.com/empira/PDFsharp/blob ... ver.cs#L24 |
Author: | TH-Soft [ Tue May 02, 2023 2:21 pm ] |
Post subject: | Re: FailsafeFontResolver understanding |
Some background information: When your code is used under Windows only, you can use the GDI build or the WPF build and the default font resolver will load Arial from the Windows folder without any preparations in your code. The Core build can run under Linux, Windows, Mac, you name it. To use Arial, you must provide the Arial files in some form. The idea of the FailsafeFontResolver is that it will not throw exceptions. It will not load "Arial" or "Donald" or "Comic Sans", but it will return a font for any name you are asking. See also: viewtopic.php?f=8&t=3244 viewtopic.php?f=8&t=3073 |
Author: | qurious [ Wed May 03, 2023 6:32 am ] |
Post subject: | Re: FailsafeFontResolver understanding |
So, if I understand the answer correctly, FailsafeFontResolver returns the built-in Segoe WP font for any requested font name. My code have to work on Windows and Linux. For testing, Windows and Arial are used to ensure that the font is installed. The desired resolver should behave as follows: 1. Work on Windows and Linux. 2. Load fonts used in a particular MigraDoc.DocumentObjectModel.Document, or according to the list of font names. 3. Provide the built-in default font if the requested fonts cannot be loaded. If there currently a resolver that works like that or closely? Is it a part of PDFsharp library on .NET6? |
Author: | TH-Soft [ Wed May 03, 2023 6:41 am ] |
Post subject: | Re: FailsafeFontResolver understanding |
qurious wrote: In other words, if Arial is specified for the document and Arial is installed, can I use FailsafeFontResolver to load it? Maybe try NewFontResolver. Name and/or behaviour may change with future releases.But note that the behaviour of NewFontResolver is platform-dependent. If your app is for Windows only, then consider using the WPF or GDI build. If your app is for all platforms, then NewFontResolver will lead to problems with Linux and Mac. So test everywhere and come up with a fallback strategy. |
Author: | qurious [ Wed May 03, 2023 7:19 am ] |
Post subject: | Re: FailsafeFontResolver understanding |
Thank you! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |