Skip to content

Linux Fonts and SkiaSharp

Peter Gill edited this page Jun 7, 2026 · 1 revision

Linux — PDF Export and Fonts

Majorsilence Reporting v5 uses SkiaSharp as its rendering backend on Linux and macOS. SkiaSharp requires:

  1. Native SkiaSharp libraries (included via NuGet, see below)
  2. Fonts installed on the host system

NuGet packages

Use the .SkiaSharp variants for Linux/macOS:

dotnet add package Majorsilence.Reporting.RdlEngine.SkiaSharp
dotnet add package Majorsilence.Reporting.RdlCri.SkiaSharp

These 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.NoDependencies

Fonts

SkiaSharp 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.

Option 1 — Microsoft core fonts (Ubuntu / Debian)

sudo apt-get update
sudo apt-get install -y ttf-mscorefonts-installer fontconfig
sudo fc-cache -f -v

ttf-mscorefonts-installer requires accepting a EULA during installation. In non-interactive environments (CI, Docker) set DEBIAN_FRONTEND=noninteractive and 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

Option 2 — Liberation fonts (free alternative, Ubuntu / Debian)

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 -v

Fedora / RHEL

Microsoft 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.rpm

Or use the Liberation fonts from the standard repos:

sudo dnf install -y liberation-fonts fontconfig

Docker

Add 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" />

Verifying font availability

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.

Clone this wiki locally