Skip to content

Commit e9417df

Browse files
committed
add font
1 parent 7ea83b3 commit e9417df

3 files changed

Lines changed: 62 additions & 87 deletions

File tree

scripts/conf.sh

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -44,70 +44,6 @@ install_theme() {
4444
"$tmp_dir/Qogir-icon-theme/install.sh"
4545
}
4646

47-
install_nerd_fonts() {
48-
FONT_VERSION="v3.4.0"
49-
50-
FONT_NAMES=("FiraCode" "Hack" "JetBrainsMono" "RobotoMono" "SourceCodePro" "NotoMono")
51-
52-
echo "Downloading and installing Nerd Fonts..."
53-
54-
mkdir -p "$FONT_DIR"
55-
56-
for FONT_NAME in "${FONT_NAMES[@]}"; do
57-
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/$FONT_VERSION/$FONT_NAME.zip"
58-
59-
curl -fL "$FONT_URL" -o "$HOME/$FONT_NAME.zip"
60-
if [[ $? -ne 0 ]]; then
61-
echo "Download failed for $FONT_NAME. Please check your network connection or font name!"
62-
continue
63-
fi
64-
65-
unzip -o "$HOME/$FONT_NAME.zip" -d "$FONT_DIR"
66-
rm -f "$HOME/$FONT_NAME.zip"
67-
68-
echo "$FONT_NAME font installed to $FONT_DIR."
69-
done
70-
71-
echo "All Nerd Fonts installation completed!"
72-
}
73-
74-
install_linux_fonts() {
75-
FONT_DIR="$HOME/.local/share/fonts"
76-
install_nerd_fonts
77-
fc-cache -fv
78-
}
79-
80-
install_macos_fonts() {
81-
FONT_DIR="$HOME/Library/Fonts"
82-
install_nerd_fonts
83-
}
84-
85-
install_windows_fonts() {
86-
FONT_DIR="$LOCALAPPDATA/Microsoft/Windows/Fonts"
87-
install_nerd_fonts
88-
register_windows_fonts
89-
}
90-
91-
register_windows_fonts() {
92-
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command '
93-
$ErrorActionPreference = "Stop"
94-
95-
$fontDir = Join-Path $env:LOCALAPPDATA "Microsoft\Windows\Fonts"
96-
$registryPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
97-
98-
Get-ChildItem -Path $fontDir -Include *.ttf,*.otf -Recurse | ForEach-Object {
99-
$fontType = if ($_.Extension -ieq ".otf") { "OpenType" } else { "TrueType" }
100-
$name = "$($_.BaseName) ($fontType)"
101-
New-ItemProperty `
102-
-Path $registryPath `
103-
-Name $name `
104-
-Value $_.FullName `
105-
-PropertyType String `
106-
-Force | Out-Null
107-
}
108-
'
109-
}
110-
11147
link_linux_configs() {
11248
mkdir -p "$HOME/.config" "$HOME/.local/share/fcitx5" "$HOME/.config/environment.d"
11349

scripts/font.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
install_nerd_fonts() {
2+
FONT_VERSION="v3.4.0"
3+
FONT_NAMES=("FiraCode" "Hack" "JetBrainsMono" "RobotoMono" "SourceCodePro" "NotoMono")
4+
echo "Downloading and installing Nerd Fonts..."
5+
mkdir -p "$FONT_DIR"
6+
for FONT_NAME in "${FONT_NAMES[@]}"; do
7+
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/$FONT_VERSION/$FONT_NAME.zip"
8+
curl -fL "$FONT_URL" -o "$HOME/$FONT_NAME.zip"
9+
if [[ $? -ne 0 ]]; then
10+
echo "Download failed for $FONT_NAME. Please check your network connection or font name!"
11+
continue
12+
fi
13+
unzip -o "$HOME/$FONT_NAME.zip" -d "$FONT_DIR"
14+
rm -f "$HOME/$FONT_NAME.zip"
15+
echo "$FONT_NAME font installed to $FONT_DIR."
16+
done
17+
echo "All Nerd Fonts installation completed!"
18+
}
19+
20+
install_linux_fonts() {
21+
FONT_DIR="$HOME/.local/share/fonts"
22+
install_nerd_fonts
23+
fc-cache -fv
24+
}
25+
26+
install_macos_fonts() {
27+
FONT_DIR="$HOME/Library/Fonts"
28+
install_nerd_fonts
29+
}
30+
31+
install_windows_fonts() {
32+
FONT_DIR="$LOCALAPPDATA/Microsoft/Windows/Fonts"
33+
install_nerd_fonts
34+
register_windows_fonts
35+
}
36+
37+
register_windows_fonts() {
38+
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command '
39+
$ErrorActionPreference = "Stop"
40+
$fontDir = Join-Path $env:LOCALAPPDATA "Microsoft\Windows\Fonts"
41+
$registryPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
42+
Get-ChildItem -Path $fontDir -Include *.ttf,*.otf -Recurse | ForEach-Object {
43+
$fontType = if ($_.Extension -ieq ".otf") { "OpenType" } else { "TrueType" }
44+
$name = "$($_.BaseName) ($fontType)"
45+
New-ItemProperty -Path $registryPath -Name $name -Value $_.FullName -PropertyType String -Force | Out-Null
46+
}
47+
'
48+
}
49+
50+
install_fonts() {
51+
local target="${1:-}"
52+
[[ -n "$target" ]] || target="$(default_pkg_target)"
53+
case "$target" in
54+
deepin|arch|termux) install_linux_fonts ;;
55+
windows) install_windows_fonts ;;
56+
macos) install_macos_fonts ;;
57+
*)
58+
echo "error: unknown font target: $target" >&2
59+
return 1
60+
;;
61+
esac
62+
}

scripts/pkg.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -274,29 +274,6 @@ install_packages() {
274274
esac
275275
}
276276

277-
run_fonts() {
278-
local target="${1:-}"
279-
if [[ -z "$target" ]]; then
280-
target="$(default_pkg_target)"
281-
fi
282-
283-
case "$target" in
284-
deepin|arch|termux)
285-
install_linux_fonts
286-
;;
287-
windows)
288-
install_windows_fonts
289-
;;
290-
macos)
291-
install_macos_fonts || return 1
292-
;;
293-
*)
294-
echo "error: unknown font target: $target" >&2
295-
exit 1
296-
;;
297-
esac
298-
}
299-
300277
run_pkg() {
301278
local target="${1:-}"
302279
if [[ -z "$target" ]]; then

0 commit comments

Comments
 (0)