mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
chore(docs): tips for installing CN fonts (#14189)
### What problem does this PR solve? Add tips for installing Chinse fonts under code sandbox. Otherwise, `matplotlib `won't render Chinese correctly. <img width="2082" height="1186" alt="sales_analysis" src="https://github.com/user-attachments/assets/57e675ab-1e92-4662-9aeb-ad72a6121eb5" /> ### Type of change - [x] Documentation Update
This commit is contained in:
@@ -192,6 +192,14 @@ Currently, the following languages are officially supported:
|
||||
Pre-installed packages: `requests`, `numpy`, `pandas`, `matplotlib`.
|
||||
|
||||
> `matplotlib` uses the `Agg` (non-interactive) backend by default in the sandbox (`MPLBACKEND=Agg`). No display server is available, so always save figures to files (e.g. `fig.savefig("artifacts/chart.png")`) rather than calling `plt.show()`.
|
||||
>
|
||||
> Tip: if Chinese text renders as missing boxes/squares in `matplotlib`, install Debian package `fonts-noto-cjk` in your custom image. We do not preinstall it by default to keep the base image smaller. The sandbox base image ships a `matplotlibrc` that already lists common CJK fonts in the `font.sans-serif` fallback chain, so no code-level font configuration is needed — just install the font package and rebuild the image.
|
||||
>
|
||||
> Example:
|
||||
>
|
||||
> ```dockerfile
|
||||
> RUN apt-get update && apt-get install -y --no-install-recommends fonts-noto-cjk && rm -rf /var/lib/apt/lists/*
|
||||
> ```
|
||||
|
||||
To add more dependencies, edit:
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ COPY --from=ghcr.io/astral-sh/uv:0.7.5 /uv /uvx /bin/
|
||||
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
ENV MPLBACKEND=Agg
|
||||
ENV MPLCONFIGDIR=/tmp/matplotlib
|
||||
ENV MATPLOTLIBRC=/usr/local/etc/matplotlibrc
|
||||
|
||||
COPY requirements.txt .
|
||||
COPY matplotlibrc /usr/local/etc/matplotlibrc
|
||||
|
||||
RUN grep -rl 'deb.debian.org' /etc/apt/ | xargs sed -i 's|http[s]*://deb.debian.org|https://mirrors.tuna.tsinghua.edu.cn|g' && \
|
||||
apt-get update && \
|
||||
|
||||
11
agent/sandbox/sandbox_base_image/python/matplotlibrc
Normal file
11
agent/sandbox/sandbox_base_image/python/matplotlibrc
Normal file
@@ -0,0 +1,11 @@
|
||||
## RAGFlow sandbox – matplotlib defaults
|
||||
## Only overrides are listed; all other settings use matplotlib built-in defaults.
|
||||
|
||||
# Prefer CJK-capable fonts so Chinese / Japanese / Korean text renders correctly.
|
||||
# matplotlib silently skips fonts that are not installed, falling back to the
|
||||
# next entry in the list, so this is safe even without any CJK font package.
|
||||
font.family: sans-serif
|
||||
font.sans-serif: Noto Sans CJK SC, Noto Sans CJK TC, Noto Sans CJK JP, Noto Sans CJK KR, Source Han Sans SC, Source Han Sans CN, WenQuanYi Zen Hei, Microsoft YaHei, SimHei, PingFang SC, Heiti SC, STHeiti, Arial Unicode MS, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
|
||||
|
||||
# Use ASCII hyphen-minus for the minus sign so it renders correctly with any font.
|
||||
axes.unicode_minus: False
|
||||
Reference in New Issue
Block a user