-
Notifications
You must be signed in to change notification settings - Fork 204
Linux Fonts and SkiaSharp
Majorsilence Reporting v5 uses SkiaSharp as its rendering backend on Linux and macOS. SkiaSharp requires:
- Native SkiaSharp libraries (included via NuGet, see below)
- Fonts installed on the host system
Use the .SkiaSharp variants for Linux/macOS:
dotnet add package Majorsilence.Reporting.RdlEngine.SkiaSharp
dotnet add package Majorsilence.Reporting.RdlCri.SkiaSharpThese packages pull in SkiaSharp.NativeAssets.Linux automatically for glibc-based systems (Ubuntu, Debian, Fedora, RHEL). For Alpine Linux (musl libc) add:
dotnet add package SkiaSharp.NativeAssets.Linux.NoDependenciesSkiaSharp resolves fonts through the system font stack (fontconfig). Reports that use Arial, Times New Roman, or Courier New require those fonts to be installed — they are not bundled with the OS on most Linux distributions.
sudo apt-get update
sudo apt-get install -y ttf-mscorefonts-installer fontconfig
sudo fc-cache -f -v
ttf-mscorefonts-installerrequires accepting a EULA during installation. In non-interactive environments (CI, Docker) setDEBIAN_FRONTEND=noninteractiveand pre-accept the licence:echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections sudo apt-get install -y ttf-mscorefonts-installer fontconfig
fonts-liberation provides metrically identical replacements for Times New Roman, Arial, and Courier New and is available in the standard repositories without a EULA.
sudo apt-get install -y fonts-liberation fontconfig
sudo fc-cache -f -vMicrosoft fonts require a third-party repository (e.g. RPM Fusion):
sudo dnf install -y curl cabextract xorg-x11-font-utils fontconfig
sudo rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpmOr use the Liberation fonts from the standard repos:
sudo dnf install -y liberation-fonts fontconfigAdd font installation to your Dockerfile before copying your application:
FROM mcr.microsoft.com/dotnet/runtime:8.0
# Install fonts and fontconfig
RUN apt-get update \
&& echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
&& apt-get install -y --no-install-recommends \
ttf-mscorefonts-installer \
fontconfig \
&& fc-cache -f -v \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "YourApp.dll"]For Alpine-based images (mcr.microsoft.com/dotnet/runtime:8.0-alpine) use Liberation fonts and the no-dependencies SkiaSharp asset:
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine
RUN apk add --no-cache fontconfig ttf-liberation \
&& fc-cache -f -v
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "YourApp.dll"]And add to your .csproj:
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" />After installation, confirm the fonts SkiaSharp will find:
fc-list | grep -i "arial\|times\|courier\|liberation"If the list is empty, run fc-cache -f -v to rebuild the font cache and try again.