新买了一台手机,是高通骁龙8至尊版的,操作系统是安卓15,为了测试它的性能,忙不迭地安装了termux, 结果界面是这个样子,

以前在别的平板上也有过类似字体,换一下系统字体就行了,这个机器只有两种字体,换了另一种思源黑体,还是老样子。
那个小写l一个有两个宽,太不协调,我在网上搜,结果有人遇到一样的问题, 没错,就是这个丑样子,很难忍。
张泽鹏先生建议“安装termux style,在屏幕中间长按,出来的菜单上,有个more,再点有个 style,点了之后提示安装 termux style plugin,可能有用”。
我试了,结果跳到f-droid,打不开了,虽然可以到主页下载,但我不需要那么多功能,我只要一个默认的字体,不想这么麻烦。
又看到一条 https://github.com/termux/termux-app/discussions/3529
里面的这条回帖很吸引人,要是能这么解决就方便了。
dzabel-deon Oct 31, 2024
Maybe this helps somebody:
I have been using Termux since I own this phone (motorola edge 30 lite), which came with Android 11. Uprdade to Android 12 worked more or less well (afair there were some problems due to stricter file system permissions, not quite sure, though). But after upgrade to Android 13, termux had a real ugly font, the lower case letters i and l showing up very thick. Ther was no file ~/.termux.font.ttf.
I did a “cp /system/fonts/DroidSansMono.ttf ~/.termux/font.ttf” and now it looks fine again!
再exit关闭termux重启, 果然好了,为了强调,我把这个命令重复贴在上面,并高亮显示。

希望termux能自动做这一步就好了。
其他文章也说到了这种办法,记录一下
Termux 的一些小技巧
发表于2024-08-18|更新于2024-08-18
总字数:1.1k|阅读时长:4分钟|浏览量:34|评论数:0
这篇文章已经有 459 天没有更新了喵, 所以内容可能是过时的喵…
WIP
Termux 作为 Android 上最知名的终端软件,它所包含的内容超乎你的想象。不如来看看这些小技巧,有哪些是你不知道的?
自定义终端字体
Termux 默认使用系统字体,但你也可以自定义它。自定义字体的路径在 /data/data/com.termux/files/home/.termux/font.ttf 。你可以更改它为一个 NerdFont 来获取更好的终端体验。
自定义终端配色
Termux 还支持用户自定义终端配色。配色文件在 /data/data/com.termux/files/home/.termux/color.properties 。虽然笔者更喜欢原版配色。
自定义终端配置
Termux 的终端配置主要集中在 /data/data/com.termux/files/home/.termux/termux.properties。
本小章内容都是对于此文件的修改。
黑色UI主题
找到 use-black-ui 行,将其取消注释改为 true 即可启动黑暗模式主题。
当系统为安卓9+且开启了暗黑模式时,此选项自动为 true
终端切换快捷键
# Open a new terminal with ctrl + t (volume down + t)
shortcut.create-session=ctrl + t
# Go one session down with (for example) ctrl + 2
shortcut.next-session=ctrl + 2
# Go one session up with (for example) ctrl + 1
shortcut.previous-session=ctrl + 1
# Rename a session with (for example) ctrl + n
shortcut.rename-session=ctrl + n
自定义欢迎辞
Termux 的欢迎辞存储在/data/data/com.termux/files/usr/etc/motd。你可以随意修改它,但请注意,它仅作为一格文本文件,其中的命令不会被执行。
要想要打开Termux自动执行命令,你可以修改/data/data/com.termux/files/usr/etc/profile,就和正常Linux发行版一样。
当然,你还有一个选择: /data/data/com.termux/files/usr/etc/termux-login.sh。正如它的名字一样,你也可以修改它来实现自动执行命令。
termux-login.sh会在profile之前执行。
自定义登录shell
Termux支持使用chsh来切换默认shell。
chsh -s zsh # 指定shell
Termux的chsh并不是真正意义上的chsh。
通过分析chsh命令,可以发现它其实是一个shell脚本:
#!/data/data/com.termux/files/usr/bin/sh
set -e -u
show_usage () {
echo "usage: chsh [-s shell]"
echo "Change the login shell."
}
set_shell () {
if [ "$1" = login ]; then
echo "login is not a valid shell"
exit 1
fi
mkdir -p $HOME/.termux
NEW_SHELL=/data/data/com.termux/files/usr/bin/$1
if test -x $NEW_SHELL -a ! -d $NEW_SHELL; then
ln -f -s $NEW_SHELL $HOME/.termux/shell
else
echo "$NEW_SHELL is not an executable file!"
fi
}
O=`getopt -l help -- hs: "$@"`
eval set -- "$O"
while true; do
case "$1" in
-h|--help) show_usage; exit 0;;
-s) set_shell $2; exit 0;;
--) shift; break;;
*) echo Error; show_usage; exit 1;;
esac
done
DEFAULT_SHELL=bash
if [ ! -x /data/data/com.termux/files/usr/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=sh; fi
echo Changing the login shell
echo Enter the new value, or press ENTER for the default
printf " Login Shell [$DEFAULT_SHELL]: "
read shell
if [ -z "$shell" ]; then shell=$DEFAULT_SHELL; fi
set_shell $shell
分析此脚本我们可以得知,更改shell其实就是创建了一个软链接/data/data/com.termux/files/home/.termux/shell并链接到可执行的shell上。因此你其实可以自己更改默认shell。
此外,Termux的sh并不是sh,而是dash。
软件源更换
Termux 的强大离不开其支持安装软件包的功能。在国内我们可以选择使用国内的软件源。
Termux 提供了一个命令termux-change-repo,可以快速更改软件源。
一些版本说明
也许你知道Termux分为三个版本,分别为GitHub版、F-Droid版、Google Play版。
但是你需要知道的是,Google Play版本不被认为是Termux官方版本,即使它于2024-06-04重新恢复更新。
具体为何,不会在这里说明。
插件
Termux 有多个插件。
termux-api
termux-x11
termux-boot
termux-tasker
termux-styling
termux-widget
绝对不要混装不同来源的插件!
例如,从GitHub安装Termux,再从F-Droid安装termux-styling,你会得到一个无法安装的错误。
再例如,卸载了Termux想更换为其他版本,却发现安装不了并提示已有软件被安装。
以上都是常见的问题。
这是因为Termux使用ShareUID,不同版本的主体/插件不可以混装!
软件包问题
Termux是开源的,你可以随意更改它,作出自己的修改。但是一定不能更改包名!
Termux有一个GitHub仓库存储软件包: termux-packages。
由于elf不支持变量的特性,所有软件包在打包编译时会将PREFIX写死为${PREFIX},即/data/data/com.termux/files/usr。
更改包名后将无法安装新软件包甚至是termux bootstrap包。
文章作者: Arkria
记录几个开源字体下载
Noto 系列字体(貌似由 Google 主导开源)
https://fonts.google.com/noto/use
Noto Sans CJK:https://github.com/notofonts/noto-cjk/tree/main/Sans(含 Mono 等宽版本)
Noto Serif CJK:https://github.com/notofonts/noto-cjk/tree/main/Serif
思源字体(貌似由 Adobe 主导开源):
黑体:https://github.com/adobe-fonts/source-han-sans(含 HW 半宽版本)
宋体:https://github.com/adobe-fonts/source-han-serif
思源黑体 + Source Code Pro 的 Mono 等宽版本:https://github.com/adobe-fonts/source-han-mono
更纱黑体(貌似是组合了前两种字体):https://github.com/be5invis/Sarasa-Gothic
阿里巴巴普惠体:https://alibabafont.taobao.com/wow/alibabafont/act/alifont
以下的字体虽然开源,但使用时貌似都需要标明字体名称:
MiSans:https://hyperos.mi.com/font/download
HarmonyOS Sans:https://developer.huawei.com/consumer/cn/design/resource-V1
OPPO Sans:https://www.coloros.com/article/A00000050/
vivo Sans:https://developers.vivo.com/doc/d/314fa33cbaec4a93be351cd44757d9d9
更多链接:
【三個常見字型】TTF. / OTF. / TTC. 副檔名的差異:https://www.mindscmyk.com/2021/02/26/project-knowledge-27-ttf-otf-ttc/
Serif, Sans, Script & Slab:了解4种字体类型:https://www.clhweb.com/news/tech/20180308/font_types_explained_serif_sans_script_slab.html
Microsoft Typography documentation:https://learn.microsoft.com/zh-cn/typography/

被折叠的 条评论
为什么被折叠?



