Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Chinese (multi-byte characters) are not displayed correctly #1208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions scripts/daily_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
df_plt = df # Default to use the whole Dbase

# Add every font at the specified location
font_dir = [userDir + '/BirdNET-Pi/homepage/static']
font_dir = [userDir + '/BirdNET-Pi/homepage/static', '/usr/share/fonts/truetype']
for font in font_manager.findSystemFonts(font_dir):
font_manager.fontManager.addfont(font)

# Set font family globally
rcParams['font.family'] = 'Roboto Flex'
db_lang = os.environ.get('DATABASE_LANG')
if db_lang == 'zh':
rcParams['font.family'] = 'WenQuanYi Zen Hei'
rcParams['font.sans-serif'] = ['WenQuanYi Zen Hei']
rcParams['axes.unicode_minus'] = False # 解决保存图像是负号—'显示为方块的问题
else:
rcParams['font.family'] = 'Roboto Flex'

# Get todays readings
now = datetime.now()
Expand Down
11 changes: 11 additions & 0 deletions scripts/install_language_label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ unzip -o $HOME/BirdNET-Pi/model/labels_l18n.zip $label_file_name_flickr \
&& mv -f $HOME/BirdNET-Pi/model/$label_file_name_flickr $HOME/BirdNET-Pi/model/labels_flickr.txt \
&& logger "[$0] Set Flickr labels '$label_file_name_flickr'";

# install corresponding fonts for display characters in daily_plot
case "${lang}" in
zh)
sudo apt install -y fonts-wqy-zenhei \
&& logger "[$0] Install language:${zh} needed fonts";
;;
*)
true
;;
esac

exit 0
11 changes: 11 additions & 0 deletions scripts/install_language_label_nm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ unzip -o $HOME/BirdNET-Pi/model/labels_nm.zip $label_file_name_flickr \
&& mv -f $HOME/BirdNET-Pi/model/$label_file_name_flickr $HOME/BirdNET-Pi/model/labels_flickr.txt \
&& logger "[$0] Set Flickr labels '$label_file_name_flickr'";

# install corresponding fonts for display characters in daily_plot
case "${lang}" in
zh)
sudo apt install -y fonts-wqy-zenhei \
&& logger "[$0] Install language:${zh} needed fonts";
;;
*)
true
;;
esac

exit 0
1 change: 1 addition & 0 deletions scripts/install_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ Restart=always
RestartSec=120
Type=simple
User=$USER
EnvironmentFile=${config_file}
ExecStart=$PYTHON_VIRTUAL_ENV /usr/local/bin/daily_plot.py
[Install]
WantedBy=multi-user.target
Expand Down