Hello,
I am using the ClosedXML library in my project and everything works with no issues locally but when I push and publish the app, I receive the following error when I try to access a page that uses the library's functionality.
This is what I get:
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")'. Additional information is available at https://closedxml.readthedocs.io/en/latest/tips/missing-font.html page.
I understand that the font used by the library exists only on windows machines. I followed the link in the error message and I saw what options I have to fix this.
At first, I wanted to choose a different font as mentioned in the link but I couldn't find where I am supposed to copy the following to in my code:
using (var fallbackFontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Carlito.ttf"))
{
LoadOptions.DefaultGraphicEngine = DefaultGraphicEngine.CreateOnlyWithFonts(fallbackFontStream);
}
I didn't find any place with these keywords to replace or something similar to add this line to. So where can I define the fallback font?
What I have tried:
I also have tried to install the calibri font to the host environment by adding the following lines:
sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
This didn't work because I got an error that I didn't know how to solve, this is the error in the logs:
023-11-16 10:36:11 Step 16/25 : RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
2023-11-16 10:36:11 ---> Running in 5d254a2c2ec7
2023-11-16 10:36:12 Removing intermediate container 5d254a2c2ec7
2023-11-16 10:36:12 ---> 11327f83bdb8
2023-11-16 10:36:12 Step 17/25 : RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
2023-11-16 10:36:12 ---> Running in f20c530df6fc
2023-11-16 10:36:12 [91mE: Malformed line 5 in source list /etc/apt/sources.list (type)
2023-11-16 10:36:12 E: The list of sources could not be read.
2023-11-16 10:36:12 [0m[91mE: Malformed line 5 in source list /etc/apt/sources.list (type)
2023-11-16 10:36:12 E: The list of sources could not be read.
2023-11-16 10:36:12 E: Malformed line 5 in source list /etc/apt/sources.list (type)
2023-11-16 10:36:12 E: The list of sources could not be read.
2023-11-16 10:36:12 [0mThe command '/bin/sh -c apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig' returned a non-zero code: 100
Can someone help me in fixing this issue, either the 1st or the 2nd problem, much appreciated.