LindDotNetCore ~ docker in the image generation Chinese garbage problem

Original: LindDotNetCore ~ Docker in the image generation Chinese garbage problem

Back to Top

Because most of the mirror on the docker are based on linux system, so when the image writing Chinese need to consider Chinese font problems, such as microsoft / aspnetcore2.0 this image, which is based on debian system, which has only one top English font, so there will be when the Chinese garbled output, this is normal, our solution also requires the following steps to pressing!

Performance issues

  1. The system linux
  2. The docker container
  3. On dotnetcore System.Drawing text output

Solutions

  1. dockerfile in the dynamic Chinese fonts installed, activate fonts
  2. dotnetcore in the new font added, many of the online presentation is WenQuanYi being black, note its name, not a mistake, you can also use the alphabetical name WenQuanYi Zen Hei, note that there is a space
  3. docker build --no-cache. Run your dockerfile generate a new image, docker run your image to

Specific code

Dockerfile in a dynamically add fonts and refresh

Copy the code
FROM microsoft/aspnetcore:2.0
WORKDIR /app
EXPOSE 80
RUN ls
COPY  publish  .
COPY sources.list /etc/apt/sources.list
RUN apt-get update && apt-get -y install libgdiplus 
RUN apt-get -y install fonts-wqy-zenhei && apt-get clean &&  fc-cache -fv
ENTRYPOINT ["dotnet", "FileUpload.dll"]
Copy the code

Production of two Chinese fonts in System.Drawing

= FTitle font new new font ( " WenQuanYi n-black " , 16 ); 
font ftext = new new font ( " WenQuanYi Zen Hei " , . 9 );

Three simultaneous access to container, see already installed Chinese fonts

 fc-list: lang = zh //: a space in front of No. 

In fact, by displaying the current linux it is the container where the operating system supports Chinese font, the output of Chinese when you need to use the font on the image above!

System.Drawing environment to build on dotnetcore can see my article: DotNetCore cross-platform ~ System.DrawingCore deploy Linux Note

Thanks for reading!

Back to Top

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/12533219.html
Recommended