Skip to content

Commit 9cb95f0

Browse files
authored
Merge pull request #94 from approvers/fix-download-font-sh
feat: 壊れた `download_font.sh` を再作成
2 parents 52c9014 + 85aaef9 commit 9cb95f0

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
toolchain: ${{ steps.parse-toolchain.outputs.spec }}
2121
- uses: Swatinem/rust-cache@v2
2222
- name: install native deps
23-
run: sudo apt update && sudo apt install clang llvm pkg-config nettle-dev
23+
run: sudo apt update && sudo apt install clang llvm pkg-config nettle-dev fontforge
2424
- run: cargo install cargo-udeps --locked
2525

2626
- run: cargo fmt -- --check

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
.env
33
/db/
44
/db_config/
5-
/NotoSansJP-Medium.ttf
6-
/OFL.txt
7-
/Noto.zip
5+
/NotoSansCJKjp-Medium.ttf

download_font.sh

+73-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,76 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
set -exu
3+
set -e
44

5-
cd $(dirname "$0")
5+
function failed () {
6+
info 0
7+
info 2 "unexpected exitcode! exiting..."
8+
}
69

7-
mkdir tmp
8-
cd tmp
9-
wget --https-only -O Noto.zip 'https://fonts.google.com/download?family=Noto%20Sans%20JP'
10-
unzip Noto.zip static/NotoSansJP-Medium.ttf OFL.txt
11-
mv static/NotoSansJP-Medium.ttf OFL.txt ../
12-
cd ../
13-
rm -rf tmp
10+
trap failed ERR
11+
12+
export TERM="${TERM:-xterm-256color}"
13+
14+
function info () {
15+
local SUFFIX=$(tput sgr0)
16+
17+
if [ $1 -eq 0 ]; then
18+
local PREFIX
19+
elif [ $1 -eq 1 ]; then
20+
local PREFIX="$(tput bold)==> "
21+
elif [ $1 -eq 2 ]; then
22+
local PREFIX=" -> "
23+
fi
24+
25+
echo -E "${PREFIX}${2}${SUFFIX}" >> /dev/stderr
26+
}
27+
28+
function findtools () {
29+
info 1 "find ${1} ..."
30+
31+
if which ${1} &> /dev/null; then
32+
local LOCATION=$(which ${1})
33+
info 2 "found! (${LOCATION})"
34+
info 0
35+
36+
echo -n "${LOCATION}"
37+
else
38+
info 2 "not found! exiting..."
39+
fi
40+
41+
}
42+
43+
cd $(dirname "${0}")
44+
45+
OTF_VARIANT="Sans"
46+
OTF_FILENAME="Noto${OTF_VARIANT}CJKjp-Medium.otf"
47+
OTF_URL="https://raw.githubusercontent.com/notofonts/noto-cjk/main/${OTF_VARIANT}/OTF/Japanese/${OTF_FILENAME}"
48+
49+
TTF_FILENAME="${OTF_FILENAME%.*}.ttf"
50+
51+
if [ -e "${TTF_FILENAME}" ]; then
52+
info 1 "${TTF_FILENAME} is exists! exiting..."
53+
exit
54+
fi
55+
56+
WGET=$(findtools wget)
57+
[ ! ${WGET} ] && exit 1
58+
59+
FONTFORGE=$(findtools fontforge)
60+
[ ! ${FONTFORGE} ] && exit 1
61+
62+
info 1 "download ${OTF_FILENAME}"
63+
$WGET --https-only --output-document "${OTF_FILENAME}" "${OTF_URL}"
64+
# info 0
65+
66+
info 1 "convert ${OTF_FILENAME} to ${TTF_FILENAME}"
67+
$FONTFORGE -lang=ff -c 'Open($1); Generate($2)' "${OTF_FILENAME}" "${TTF_FILENAME}"
68+
info 0
69+
70+
info 1 "remove unnecessary file"
71+
info 2 "delete ${OTF_FILENAME}"
72+
rm -f "${OTF_FILENAME}"
73+
info 0
74+
75+
info 1 "complete! font file is now available"
76+
info 2 "at ${TTF_FILENAME}"

src/bot/genkai_point/plot/plotters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Plotters {
1919
plotters::style::register_font(
2020
"sans-serif",
2121
FontStyle::Normal,
22-
include_bytes!("../../../../NotoSansJP-Medium.ttf"), // RUN download_font.sh IF YOU GOT THE NOT FOUND ERROR HERE
22+
include_bytes!("../../../../NotoSansCJKjp-Medium.ttf"), // RUN download_font.sh IF YOU GOT THE NOT FOUND ERROR HERE
2323
)
2424
// this error doesn't implement Debug
2525
.map_err(|_| panic!("failed to load embedded font"))

0 commit comments

Comments
 (0)