PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

PdfShareCore: System.IO.FileNotFoundException: No Fonts installed on this device

Open mMarcos208 opened this issue 3 years ago • 3 comments

I have a application in .Net 5 running in docker.

When i testing in windows it's working well, but when running in docker cotaineirs I've an error:

System.IO.FileNotFoundException: No Fonts installed on this device! at PdfSharpCore.Utils.FontResolver.ResolveTypeface(String familyName, Boolean isBold, Boolean isItalic) at PdfSharpCore.Fonts.FontFactory.ResolveTypeface(String familyName, FontResolvingOptions fontResolvingOptions, String typefaceKey) at PdfSharpCore.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharpCore.Drawing.XFont.Initialize() at PdfSharpCore.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyle style, XPdfFontOptions pdfOptions)

I should to install fonts in debian container? What should I do?

I add the following in my code:

RUN apt-get update \
    && apt-get install -y libfontconfig1 \
    && rm -rf /var/lib/apt/lists/*

But isn't working.

mMarcos208 avatar May 14 '21 15:05 mMarcos208

I have add this

# Install Microsoft core fonts
RUN echo "deb http://deb.debian.org/debian stable main contrib non-free" > /etc/apt/sources.list \
    && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
    && apt-get update \
    && apt-get install -y \
        ttf-mscorefonts-installer \
    && apt-get clean \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/*

and it works for me.

Bezolt avatar Jun 21 '21 19:06 Bezolt

You basically just need to install the font(s) you want to use. I included the font in my source files, then I did the following with the Red Hat UBI 8 dotnet runtime image:

COPY data/my-font.ttf /usr/local/share/fonts/
RUN dnf install -y fontconfig && fc-cache -f -v

bmreading avatar Sep 20 '22 23:09 bmreading

For me, the best aprroach is to use in Docker 23.0.1 and Ubuntu server 20.04 (LTS) x64

RUN apt-get update; apt-get install -y fontconfig fonts-liberation
RUN fc-cache -f -v

brutalzinn avatar May 13 '23 17:05 brutalzinn