Words.NET not finding fonts in Linux Docker container

I have read the help articles here, here, and here as well as all the existing forum posts but it’s still not working. We have this code:

Document doc = new Document(formDoc);
DocumentBuilder builder = new DocumentBuilder(doc);

string contentRootPath = _env.ContentRootPath;
formFonts = Path.Combine(contentRootPath, "fonts");

FolderFontSource folderFontSource = new FolderFontSource(formFonts, false, 1);
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] { folderFontSource });

The formFonts folder is a folder in the application itself. But it still only will fall back to the default fonts because it can’t find this folder.

Also, this all works perfectly using Docker Desktop on my development machine. It’s only when we deploy it to AWS ECS that it breaks. We also tried copying the files to a folder in the container in the Dockerfile, but that did not work either.

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["web3.csproj", "."]
COPY . .
COPY ./protected/fonts/* /usr/share/fonts/
RUN apt-get update && apt-get install -y libfontconfig1

RUN dotnet restore "./././web3.csproj"
WORKDIR "/src/."
RUN dotnet build "./web3.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./web3.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "web3.dll"]

Any help is appreciated.

@thomas948 Please make sure the fonts folder is accessible from the application. Also, please make sure you specified an absolute path to the fonts folder. In addition, you can try specifying FontSourceBase.WarningCallback property to get notification when there are problems with loading fonts from the fonts source.