Blazor Wasm Clientside , does not read fonts
See original GitHub issueDo you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
Version of ClosedXML
0.97
What is the current behavior?
When using the Library on clientside blazor . The Default Graphics Engine Cannot Find any fonts . The Constructor of the Engine uses LoadFont Method , which in turn gets the SystemFontCollection.Collection from SixLabors But six labors checks for fonts only in Windows/Linux/MAC platforms and returns an empty array when in browser
What is the expected behavior or new feature?
Maybe , be able to load one or more fonts manually to the Default Graphics Engine ? Is there any other way except implementing a new IXLGrapgicsEngine?
Is this a regression from the previous version?
This problem was not present in 0.96.1 Preview There where two engines and the default one was not using SixLabors Library
Reproducibility
Running the Library in a Blazor application in the Client .
throws exception Unhandled exception rendering component: Unable to find font Calibri or fallback font Microsoft Sans Serif. Install missing fonts or specify a different fallback font through ‘LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine(“Fallback font name”)’. System.ArgumentException: Unable to find font Calibri or fallback font Microsoft Sans Serif. Install missing fonts or specify a different fallback font through ‘LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine(“Fallback font name”)’.
Method that produces above exception (When using AdjustToContents())
public static byte[] GetReport()
{
using var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("testSheet");
ws.Cell("B3").Value = "test";
ws.Cell("B8").Value = "test";
ws.Columns().AdjustToContents();
using MemoryStream stream = new();
wb.SaveAs(stream);
stream.Position = 0;
return stream.ToArray();
}
Issue Analytics
- State:
- Created a year ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
You’re not understanding. What I did worked. It is being read into a stream.
This didn’t work for me because I don’t know how you’re embedding the font file in the assembly.
Thank you, I appreciate the help! I didn’t know you could do that. I’m new to the .net platform so that’s a neat trick to have.