Trying to generate text in a blazor webassembly context, failing to load fonts #258
-
I'm trying to use imagesharp in a blazor webassembly application, I tried to load a provided ttf font (I don't know if there's any other way to do it) but when I try to add it to a FontCollection I just get the following error:
I made a small project with the code I used here: Am I doing this completely wrong? I just want to draw text to an image (among other things), what is the proper way if this isn't it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
That error would generally imply its an unsupported font file version that has features our library doesn't know how to process. If you could try using one of the fonts from our test suite (I would suggest OpenSans), That would help verify if its an issue with the version of the the version font your using or the library when ran from webassembly. FYI Nothing in your code jumping out as fundamentally wrong... I do feel it prudent to warn you however that we can't promise you will find ImageSharp will be particularly performant when run in webassembly (.net is missing a lot of the optimisation we rely on when run in the browser) |
Beta Was this translation helpful? Give feedback.
-
@MaddoScientisto is the Arial.ttf font in your sample the one that was failing? Class Definition tables support only 2 formats https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#class-definition-table-format-1 so I’m curious to see if there’s something else causing us to read the font incorrectly |
Beta Was this translation helpful? Give feedback.
That error would generally imply its an unsupported font file version that has features our library doesn't know how to process.
If you could try using one of the fonts from our test suite (I would suggest OpenSans), That would help verify if its an issue with the version of the the version font your using or the library when ran from webassembly.
FYI Nothing in your code jumping out as fundamentally wrong... I do feel it prudent to warn you however that we can't promise you will find ImageSharp will be particularly performant when run in webassembly (.net is missing a lot of the optimisation we rely on when run in the browser)