Linux Mint下fcitx5-rime粤语输入法安装教程(解决候选框错位问题)

本文将介绍如何在Linux Mint下安装fcitx5-rime与其对应的rime-cantonese

问题说明

最近想要(再次)尝试下linux,就选择了Linux Mint系统。由于在Windows习惯了用小狼毫(rime)的粤语输入法,因此就直接按照官网推荐安装了ibus-rime。

然而在使用时,发现Ibus输入法对于高分屏的支持不佳,在缩放比例为200%时,在一些应用(例如Firefox)中候选框显示错位。

在网上搜索了一些相关讨论 https://github.com/ibus/ibus/issues/2221 ,提到这是ibus上游的问题,也没有什么较好的解决方法。如果将缩放比例调整至100%则显示正常,但用起来非常难受;或者就可以改用基于fcitx5的输入法,就不会出现这些问题。

然而,rime-cantonese官方对于Debain系提供的是ibus的安装脚本,而其fcitx5版本并没有在Linux Mint的仓库中。幸运的是,我们可以通过从其Github仓库下载文件的方法实现手动安装。

安装教程

首先,安装fcitx5-rime:

1
sudo apt install fcitx5-rime -y

接下来为rime安装粤语输入法(rime-cantonese),执行以下命令

1
2
3
4
5
6
7
8
9
10
11
12
# 克隆 粤语输入法、emoji显示、两分输入的仓库
git clone https://github.com/rime/rime-cantonese.git ~/.rime-cantonese
git clone https://github.com/rime/rime-emoji-cantonese.git ~/.rime-emoji-cantonese
git clone https://github.com/CanCLID/rime-loengfan.git ~/.rime-loengfan

# 建立fcitx5-rime配置文件夹到粤语输入文件的软链接
mkdir -p ~/.local/share/fcitx5/rime/opencc
ln -s ~/.rime-cantonese/*.yaml ~/.local/share/fcitx5/rime
ln -s ~/.rime-cantonese/*.txt ~/.local/share/fcitx5/rime # 注意没有这句话会导致候选词频混乱
ln -s ~/.rime-cantonese/opencc/* ~/.local/share/fcitx5/rime/opencc
ln -s ~/.rime-emoji-cantonese/*.yaml ~/.local/share/fcitx5/rime
ln -s ~/.rime-emoji-cantonese/opencc/* ~/.local/share/fcitx5/rime/opencc

再新建 ~/.local/share/fcitx5/rime/default.custom.yaml,配置rime

1
2
3
4
5
6
patch:
schema_list:
- schema: jyut6ping3
- schema: luna_pinyin_simp
# 以及其他需要的输入方案
"menu/page_size": 9

打开fcitx5,在fcitx5配置中增加「中州韵」输入法(如果有则忽略本步)。

如果配置未生效,则可以右键任务栏的fcitx5按钮,选择重新启动,等待rime重新部署完成即可。

配置教程

配置输入法

用nano等编辑器打开jyut6ping3.schema.yaml文件
修改ascii_punct上面的reset后数字为3即可默认输入法为简体
删除states: [ 冇 Emoji, 有 Emoji ]上面一行reset前面的#号,即可启用emoji🤨输入。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
switches:
- name: ascii_mode
reset: 0
states: [ , ]
- name: full_shape
states: [ 半角, 全角 ]
- options: [ noop, variants_hk, trad_tw, simplification ]
states: [ 傳統漢字, 香港傳統漢字, 臺灣傳統漢字, 大陆简化汉字 ]
# 修改下面箭嘴指住嘅數字以改變預設用字(數字 [0, 1, 2, 3] 分別對應上表)
# 例如「reset: 0」會將用字預設為 OpenCC 傳統漢字,如此類推
# Edit the number indicated by the arrow below to change the default character style
# [0 = OpenCC Traditional Chinese; 1 = Hong Kong TC; 2 = Taiwan TC; 3 = Mainland Simplified Chinese]
# 或刪除下行以記住用户設定 Or remove the following line to remember user setting
reset: 3 # <-- 此數字 this number
- name: ascii_punct
states: [ 。,, ., ]
- name: emoji_cantonese_suggestion
# 取消下行註釋(移除 # 號),預設啓動 emoji
reset: 1
states: [ Emoji, Emoji ]

安装皮肤

默认的rime并不美观,可以通过安装皮肤的方法来美化,以 https://github.com/thep0y/fcitx5-themes-candlelight 为例:

首先下载皮肤,并将皮肤文件复制到fcitx5的皮肤文件夹中:

1
2
3
git clone https://github.com/thep0y/fcitx5-themes.git
cd fcitx5-themes
cp spring ~/.local/share/fcitx5/themes -r

再修改fcitx5的皮肤配置文件(若没有配置文件则自动创建):

1
vim ~/.config/fcitx5/conf/classicui.conf

将下面的参数复制进去(记得修改字体):

1
2
3
4
5
6
7
8
9
10
11
# 垂直候选列表
Vertical Candidate List=False

# 按屏幕 DPI 使用
PerScreenDPI=True

# Font (设置成你喜欢的字体)
Font="Smartisan Compact CNS 13"

# 主题(这里要改成你想要使用的主题名,主题名就在下面)
Theme=spring

搞掂晒(