「インストール - Fcitx」の版間の差分

提供:MochiuWiki - SUSE, Electronic Circuit, PCB
ナビゲーションに移動 検索に移動
 
(同じ利用者による、間の22版が非表示)
5行目: 5行目:
<br><br>
<br><br>


== Fcitxのインストール ==
== Fcitxのインストール (パッケージ管理システムからインストール) ==
==== パッケージ管理システムからインストール ====
==== RHEL ====
===== CentOS =====
 
<br>
===== SUSE =====
Fcitx Input Method Frameworkにおいて、サポートされているエンジンおよびその派生物は、SUSEの公式OSSリポジトリのM17Nリポジトリで開発されている。<br>
リポジトリにおいて、M17N、M17N:Develはそれぞれ別のリポジトリであることに注意すること。<br>
<br>
<br>
==== SUSE ====
  # KKCを使用する場合
  # KKCを使用する場合
  sudo zypper install fcitx-kkc fcitx-table-other
  sudo zypper install fcitx-kkc fcitx-table-other
23行目: 18行目:
  sudo zypper install fcitx-mozc fcitx-table-other
  sudo zypper install fcitx-mozc fcitx-table-other
   
   
  # Anthyを使用する場合(Anthyは開発停止しているため、使用しないこと)
  # Anthyを使用する場合
# 2021年からプロジェクトが再開されており、2023年以降からAnthy Unicodeとしてパッケージが配布されている
  sudo zypper install fcitx-anthy fcitx-table-other
  sudo zypper install fcitx-anthy fcitx-table-other
<br>
<br>
34行目: 30行目:
<br>
<br>
<u>※注意</u><br>
<u>※注意</u><br>
<u>パッケージ管理システムを使用して、Fcitxをインストールすることを推奨する。</u><br>
<u>2023年10月現在、パッケージ管理システムからFcitx-Mozcが削除された。</u><br>
<u>Fcitx関連のソフトウェアは、全てfcitxで始まるため、fcitxを検索すると表示される。</u><br>
<br>
<u>また、Fcitx関連のソフトウェアは、全てfcitxで始まるため、fcitxを検索すると表示される。</u><br>
<br><br>
 
== Fcitxのインストール (リポジトリを追加してインストール) ==
SUSEの公式リポジトリからM17Nリポジトリを追加する。<br>
# SLE / openSUSE Leap
sudo zypper addrepo 'https://download.opensuse.org/repositories/M17N/$releasever/M17N.repo' M17N
<br>
<br>
==== ソースコードからインストール ====
追加したリポジトリを更新する。<br>
===== Mozcのインストール =====
sudo zypper refresh
<br>
Fcitxをインストールする。<br>
# KKCを使用する場合
sudo zypper install fcitx-kkc fcitx-table-other
# SKKを使用する場合
sudo zypper install fcitx-skk fcitx-table-other
# Mozcを使用する場合
sudo zypper install fcitx-mozc fcitx-table-other
# Anthyを使用する場合
# 2021年からプロジェクトが再開されており、2023年以降からAnthy Unicodeとしてパッケージが配布されている
sudo zypper install fcitx-anthy fcitx-table-other
<br><br>
 
== Mozcのインストール (ソースコードからインストール) ==
==== ソースコードのダウンロード ====
SLE 15において、現在、パッケージ管理システムにFcitx-mozcが存在しない。<br>
SLE 15において、現在、パッケージ管理システムにFcitx-mozcが存在しない。<br>
そのため、Fcitxでmozcを使用する場合はソースコードからビルドおよびインストールする必要がある。<br>
そのため、FcitxでMozcを使用する場合は、ソースコードからビルドおよびインストールする必要がある。<br>
<br>
<br>
Mozcのソースコードをダウンロードする。<br>
Mozcのソースコードをダウンロードする。<br>
48行目: 69行目:
  git submodule update --init --recursive
  git submodule update --init --recursive
  cd src
  cd src
# または
git clone <nowiki>https://github.com/google/mozc.git</nowiki> -b master --single-branch --recursive
cd mozc/src
<br>
<br>
Mozcのビルドに必要な依存関係のライブラリをインストールする。<br>
Mozcのビルドに必要な依存関係のライブラリをインストールする。<br>
  sudo zypper install make cmake gcc-c++ intltool libicu-devel dbus-1-devel dbus-1-glib-devel cairo-devel pango-devel opencc-devel \
  sudo zypper install git curl unzip bzip2 update-desktop-files pkg-config make ninja gcc10-c++ zlib-devel protobuf-devel \
                     enchant-devel enchant-1-devel libpresage-devel gtk2-devel gtk3-devel gobject-introspection-devel \
                    bazel6 bazel-rules-cc-source bazel-apple-support-source bazel-workspaces \
                     fcitx-devel libXrender-devel libXfixes-devel libxkbfile-devel \
                     bazel-rules-java-source bazel-rules-proto-source                        \
                     libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel libQt5DBus-devel libQt5Concurrent-devel \
                     bazel-rules-python-source bazel-rules-swift-source bazel-skylib-source  \
                     libqt5-qtbase-devel libqt5-qtbase-private-headers-devel
                     qt6-core-devel qt6-gui-devel qt6-widgets-devel                           \
                     ibus-devel
                    fcitx-devel # Fcitxをパッケージ管理システムからインストールしている場合
<br>
<br>
Fcitx-Mozc、Mozcサーバ、Mozcツール、Mozcレンダラーをビルドする。<br>
通常のLinux環境でMozcを構築する場合は、以下のファイルを修正する必要がある。<br>
bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> -c opt --copt=-fPIC --config oss_linux \
* src/config.bzl
            unix/fcitx:fcitx-mozc.so server:mozc_server gui/tool:mozc_tool renderer:mozc_renderer \
*: インストールパス等の指定する。
            --verbose_failures
* src/.bazelrc
<br>
*: コンパイラのフラグ等を指定する。
生成したmozcファイルを、以下に示す場所に配置する。<br>
* src/WORKSPACE.bazel
sudo cp bazel-bin/unix/fcitx/fcitx-mozc.so /usr/lib64/fcitx/
*: ビルドの依存関係。
sudo cp bazel-bin/server/mozc_server /usr/lib64/mozc/
sudo cp bazel-bin/gui/tool/mozc_tool /usr/lib64/mozc/
sudo cp bazel-bin/renderer/mozc_renderer /usr/lib64/mozc/
<br>
<br>
次に、Fcitx-mozcの設定ファイルを作成する。<br>
==== インストールディレクトリの設定 ====
  sudo vi /usr/share/fcitx/addon/fcitx-mozc.conf
必要ならば、srcディレクトリにあるconfig.bzlファイルを編集して、インストールディレクトリを変更する。<br>
  vi mozc/src/config.bzl
<br>
<br>
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
  # mozc/src/config.bzlファイル
   
   
  [Addon]
  LINUX_MOZC_BROWSER_COMMAND = "/usr/bin/xdg-open"
  Type=SharedLibrary
  LINUX_MOZC_ICONS_DIR = "/<Mozcのインストールディクトリ>/share/icons/mozc"
  Name=fcitx-mozc
  LINUX_MOZC_SERVER_DIR = "/<Mozcのインストールディクトリ>/lib/mozc"
  GeneralName=Mozc
  LINUX_MOZC_DOCUMENT_DIR = LINUX_MOZC_SERVER_DIR + "/documents"
  Comment=Mozc support for Fcitx
  IBUS_COMPONENT_DIR = "/<Mozcのインストールディクトリ>/share/ibus/component"
  Library=fcitx-mozc.so
  IBUS_MOZC_INSTALL_DIR = "/<Mozcのインストールディクトリ>/share/ibus-mozc"
  IMRegisterMethod=ConfigFile
  IBUS_MOZC_ICON_PATH = IBUS_MOZC_INSTALL_DIR + "/product_icon.png"
  LoadLocal=True
  IBUS_MOZC_PATH = "/<Mozcのインストールディクトリ>/lib/ibus-mozc/ibus-engine-mozc"
  Category=InputMethod
  EMACS_MOZC_CLIENT_DIR = "/<Mozcのインストールディクトリ>/share/emacs/site-lisp/emacs-mozc"
Enabled=True
  EMACS_MOZC_HELPER_DIR = "/<Mozcのインストールディクトリ>/bin"
  SubConfig=
<br>
<br>
次に、Fcitx-mozcのインプットメソッド設定ファイルを作成する。<br>
==== Bazelの設定ファイルの作成と変更 ====
  sudo vi /usr/share/fcitx/inputmethod/mozc.conf
===== WORKSPACEの編集 =====
src/WORKSPACE.bazelファイルを編集して、以下に示す設定を追記する。<br>
  vi src/WORKSPACE.bazel
<br>
<br>
  # /usr/share/fcitx/inputmethod/mozc.confファイル
* パッケージ管理システムからFcitxをインストールしている場合
  # src/WORKSPACE.bazelファイル
## 138行目あたり
   
   
  [InputMethod]
  # Fcitx
  UniqueName=mozc
  # pkg_config_repository does not work because pkgconfig --cflags-only-I fcitx returns nothing
  Name=Mozc
  new_local_repository(
IconName=/usr/share/fcitx/mozc/icon/mozc.png
  name = "fcitx",
  Priority=1
  # This path should be updated per the environment.
LangCode=ja
  path = "/usr", # For Debian
  Parent=fcitx-mozc
  build_file = "BUILD.fcitx.bazel",
  )
<br>
<br>
最後に、[https://download.fcitx-im.org/fcitx-mozc/ Fcitxの公式Webサイト]にアクセスして、Fcitx-mozcアイコンをダウンロードする。<br>
* ソースコードからFcitxをインストールしている場合
または、<code>wget</code>コマンドを実行して、Fcitx-mozcアイコンをダウンロードする。<br>
  # src/WORKSPACE.bazelファイル
  wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz
  ## 138行目あたり
<br>
ダウンロードしたファイルを解凍する。<br>
tar xf fcitx-mozc-icon.tar.gz
<br>
Fcitx-mozcアイコンを、/usr/share/fcitx/mozc/iconディレクトリに配置する。<br>
mkdir -p /usr/share/fcitx/mozc/icon
sudo cp fcitx-mozc-icons/*  /usr/share/fcitx/mozc/icon
<br><br>
 
== Fcitx5のインストール ==
==== リポジトリを追加してインストール ====
SUSEの公式リポジトリからM17Nリポジトリを追加する。<br>
  # SUSE 15.4
sudo zypper addrepo -cfp 90 https://download.opensuse.org/repositories/M17N/15.4/ M17N
   
   
  # SUSE 15.3
  # Fcitx
  sudo zypper addrepo -cfp 90 https://download.opensuse.org/repositories/M17N/15.3/ M17N
  new_local_repository(
  name = "fcitx",
  path = "/<Fcitxのインストールディレクトリ>",
  build_file = "BUILD.fcitx.bazel",
)
<br>
<br>
追加したリポジトリを更新する。<br>
src/BUILD.fcitx.bazelファイルを作成する。<br>
  sudo zypper refresh
  vi src/BUILD.fcitx.bazel
<br>
<br>
Fcitx5をインストールする。<br>
  # src/BUILD.fcitx.bazelファイル
Fcitx5の設定ツールは自動的にインストールされる。<br>
  # KKCを使用する場合
sudo zypper install fcitx5-kkc fcitx5-table-other
   
   
  # SKKを使用する場合
  package(
  sudo zypper install fcitx5-skk fcitx5-table-other
    default_visibility = ["//visibility:public"],
  )
   
   
  # Mozcを使用する場合
  cc_library(
sudo zypper install fcitx5-mozc fcitx5-table-other
    name = "fcitx",
    hdrs = glob([
# Anthyを使用する場合(Anthyは開発を再開している)
        "include/fcitx/**",
sudo zypper install fcitx5-anthy fcitx5-table-other
        "include/fcitx-config/**",
        "include/fcitx-utils/**",
    ]),
    copts = ["-pthread"],
    includes = [
        "include",
    ],
    linkopts = [
        "-lfcitx-core",
        "-lfcitx-config",
        "-lfcitx-utils",
    ],
)
<br>
<br>


==== ソースコードからインストール ====
===== Python 3.6を使用している場合 =====
===== XCB-IMDKitのインストール =====
  vi src/base/gen_config_file_stream_data.py
まず、XCB-IMDKitを[https://github.com/fcitx/xcb-imdkit Github]からダウンロードする。<br>
  git clone https://github.com/fcitx/xcb-imdkit.git
cd xcb-imdkit
<br>
<br>
XCB-IMDKitのビルドに必要なライブラリをインストールする。<br>
<syntaxhighlight lang="python">
  sudo zypper install libxcb-devel xcb-util-devel xcb-util-keysyms-devel libut2 uthash-devel
  # src/base/gen_config_file_stream_data.pyファイル
<br>
# 68行目あたり
XCB IMDkitをビルドおよびインストールする。<br>
  mkdir build && cd build
## 編集前
output.write('constexpr FileData kFileData[] = {\n')
for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
      while (byte := stream.read(1)):
          output.write(r'\x' + byte.hex())
    output.write('"},\n')
  output.write('};\n')
   
   
  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> ..
  ## 編集後
  make -j $(nproc)
output.write('constexpr FileData kFileData[] = {\n')
  make install
for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
      byte = stream.read(1)
      while (byte):
          output.write(r'\x' + byte.hex())
          byte = stream.read(1)
    output.write('"},\n')
  output.write('};\n')
  </syntaxhighlight>
<br>
<br>
===== Emojiモジュールのインストール =====
===== Mozcのウインドウレンダリングの変更 =====
[https://github.com/fujiwarat/cldr-emoji-annotation/releases EmojiモジュールのGithub]にアクセスして、Emojiモジュールのソースコードをダウンロードする。<br>
vi src/renderer/qt/qt_window_manager.cc
tar xf cldr-emoji-annotation-<バージョン>.tar.gz
cd cldr-emoji-annotation-<バージョン>
<br>
<br>
または、<code>git clone</code>コマンドを使用して、Emojiモジュールのソースコードをダウンロードする。<br>
<syntaxhighlight lang="c++">
  git clone https://github.com/fujiwarat/cldr-emoji-annotation.git
// src/renderer/qt/qt_window_manager.ccファイル
  cd cldr-emoji-annotation
// 35行目あたり
// 編集前
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "absl/strings/str_cat.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
// 編集後
#include "absl/strings/str_cat.h"
  #include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
  </syntaxhighlight>
<br>
<br>
Emojiモジュールをビルドおよびインストールする。<br>
<syntaxhighlight lang="c++">
  # Tarballからビルドする場合
  // src/renderer/qt/qt_window_manager.ccファイル
  mkdir build && cd build
// 344行目あたり
// 追加
struct VirtualRect {
    const QScreen* screen;
    const Rect rect;
    VirtualRect(const QScreen* screen, const Rect rect): screen(screen), rect(rect) {}
};
  Rect TranslateToVirtualRectWithScreen(const QScreen *screen, const Rect& native_rect) {
    const double device_pixel_ratio = screen->devicePixelRatio();
    // screen_left, screen_top have the save value in both virtual and native coordinate
    const int screen_left = screen->geometry().x();
    const int screen_top = screen->geometry().y();
    const int vx = (native_rect.Left() - screen_left) / device_pixel_ratio + screen_left;
    const int vy = (native_rect.Top() - screen_top) / device_pixel_ratio + screen_top;
   
   
../configure --prefix=<Fcitxのインストールディレクトリ> --enable-dtd
    return Rect(vx, vy, native_rect.Width() / device_pixel_ratio, native_rect.Height() / device_pixel_ratio);
make -j $(nproc)
  }
  make install
   
   
  # Githubのソースコードからビルドする場合
  VirtualRect TranslateToVirtualRect(const Rect& native_rect) {
./autogen.sh
    for (const QScreen *screen: QGuiApplication::screens()) {
      Rect rect = TranslateToVirtualRectWithScreen(screen, native_rect);
      const QRect screen_rect = screen->geometry();
   
   
mkdir build && cd build
      // Use (top left) to locate a screen
      if (screen_rect.contains(rect.Left(), rect.Top())) {
          return VirtualRect(screen, rect);
      }
    }
   
   
../configure --prefix=<Fcitxのインストールディレクトリ>
    // fall back to primary screen
make -j $(nproc)
    const QScreen *screen = QGuiApplication::primaryScreen();
  make install
    Rect point = TranslateToVirtualRectWithScreen(screen, native_rect);
    return VirtualRect(screen, point);
}
  </syntaxhighlight>
<br>
<br>
XCB IMDkitおよびEmojiモジュールを読み込むため、~/.profileファイル等に環境変数を追記する。<br>
<syntaxhighlight lang="c++">
  export LD_LIBRARY_PATH="/<Fcitxのインストールディレクトリ>/lib64"
// src/renderer/qt/qt_window_manager.ccファイル
  export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)"
// 379行目あたり
  export PKG_CONFIG_PATH="/<Fcitxのインストールディレクトリ>/lib64/pkgconfig:/<Fcitxのインストールディレクトリ>/share/pkgconfig:$PKG_CONFIG_PATH"
<br>
  // 編集前
===== Fcitx5のインストール =====
Point QtWindowManager::GetWindowPosition(
次に、Fcitx5のビルドに必要なライブラリをインストールする。<br>
    const commands::RendererCommand &command, const Size &win_size) {
# CentOS
   
sudo yum install cairo-devel pango-devel dbus-devel dbus-glib-devel qt-devel intltool cmake gtk3-devel gtk2-devel \
    const Rect preedit_rect = GetRect(command.preedit_rectangle());
                  gcc-c++ libicu-devel opencc-devel
    const Point win_pos = Point(preedit_rect.Left(), preedit_rect.Bottom());
    const Rect monitor_rect = GetMonitorRect(win_pos.x, win_pos.y);
    const Point offset_to_column1(kColumn0Width, 0);
   
    const Rect adjusted_win_geometry =
      WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
          win_pos, preedit_rect, win_size, offset_to_column1, monitor_rect,
          /* vertical */ false);  // Only support horizontal window yet.
    return adjusted_win_geometry.origin;
}
// 編集後
Point QtWindowManager::GetWindowPosition(
    const commands::RendererCommand &command, const Size &win_size) {
    const Rect native_preedit_rect = GetRect(command.preedit_rectangle());
    const VirtualRect preedit_rect = TranslateToVirtualRect(native_preedit_rect);
    const Point win_pos = Point(preedit_rect.rect.Left(), preedit_rect.rect.Bottom());
    const Rect monitor_rect = GetRect(preedit_rect.screen->geometry());
    const Point offset_to_column1(kColumn0Width, 0);
   
   
# SUSE
    const Rect adjusted_win_geometry =
  sudo zypper install cairo-devel pango-devel dbus-1-devel dbus-1-glib-devel intltool cmake extra-cmake-modules libexpat-devel \
      WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
                    gtk3-devel gtk2-devel gdk-pixbuf-devel gcc-c++ libicu-devel opencc-devel libevent-devel fmt-devel xcb-util-wm-devel \
          win_pos, preedit_rect.rect, win_size, offset_to_column1, monitor_rect,
                    libxkbcommon-x11-devel libxkbfile-devel iso-codes-devel enchant-1-devel enchant-devel libjson-c-devel \
          /* vertical */ false); // Only support horizontal window yet.
                    systemd-devel libtevent-devel libxkbcommon-devel wayland-protocols-devel
    return adjusted_win_geometry.origin;
}
</syntaxhighlight>
<br>
<br>
[https://github.com/fcitx/fcitx5/tags Fcitx5のGithub]から、Fcitx5のソースコードをダウンロードする。<br>
===== IBus-Mozcの設定 =====
ダウンロードしたファイルを解凍する。<br>
vi src/unix/ibus/gen_mozc_xml.py
tar xf <バージョン>.tar.gz
cd <バージョン>
<br>
<br>
または、<code>git clone</code>コマンドを実行して、ソースコードをダウンロードする。<br>
<syntaxhighlight lang="python">
  git clone https://github.com/fcitx/fcitx5.git
  # src/unix/ibus/gen_mozc_xml.pyファイル
  cd fcitx5
# 261行目あたり
# 編集前
}, {
    'name': 'mozc-off',
    'longname': product_name + ':A_',
    'layout': 'default',
    'layout_variant': '',
    'layout_option': '',
    'rank': 99,
    'symbol': 'A',
    'composition_mode': 'DIRECT',
}]
# 編集後
}, {
    'name': 'mozc-off',
    'longname': product_name + ':A_',
    'layout': 'default',
    'layout_variant': '',
    'layout_option': '',
    'rank': 99,
    'symbol': 'A',
    'composition_mode': 'DIRECT',
  }, {
    'name': 'mozc-jp-jp',
    'longname': product_name + " - JP layout",
    'layout': 'jp',
    'layout_variant': '',
    'layout_option': '',
    'rank': 0,
}, {
    'name': 'mozc-us',
    'longname': product_name + " - US layout",
    'layout': 'us',
    'layout_variant': '',
    'layout_option': '',
    'rank': 0,
}, {
    'name': 'mozc-dv',
    'longname': product_name + " - US Dvorak layout",
    'layout': 'us',
    'layout_variant': 'dvorak',
    'layout_option': '',
    'rank': 0,
}]
</syntaxhighlight>
<br>
<br>
Fcitxのビルドディレクトリを作成する。<br>
 
cd <Fcitxのソースコードがあるディレクトリ>
==== Mozcのビルド ====
mkdir build && cd build
Fcitx-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。<br>
<br>
<br>
Fcitxをビルドおよびインストールする。<br>
  <syntaxhighlight lang="sh">
  cmake .. -DCMAKE_CXX_COMPILER=<G++8.5以降のG++のフルパス> \
# Fcitxをソースコードからインストールしている場合
          -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> \
          -DCMAKE_BUILD_TYPE=Release \
          -DENABLE_GTK3_IM_MODULE=ON \
          -DENABLE_QT_IM_MODULE=ON \
          -DENABLE_WAYLAND=Off          # Waylandで使用しない場合
   
   
  make -j $(nproc)
  FCITX_DIR="<Fcitxのインストールディレクトリ>"; \
  make install
export PATH="$FCITX_DIR/bin:$PATH";    \
export LD_LIBRARY_PATH="$FCITX_DIR/lib64:$FCITX_DIR/lib:$LD_LIBRARY_PATH";                    \
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)";        \
export PKG_CONFIG_PATH="$FCITX_DIR/lib64/pkgconfig:$FCITX_DIR/lib/pkgconfig:$PKG_CONFIG_PATH"
  </syntaxhighlight>
<br>
<br>
もし、FcitxおよびFcitxライブラリをホームディレクトリ等にインストールする場合、~/.profileファイルに環境変数の設定を追記する。<br>
bazel build package --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
export PATH="/<Fcitxのインストールディレクトリ>/bin:$PATH"
            //unix/fcitx:fcitx-mozc.so            \
export LD_LIBRARY_PATH="/<Fcitxのインストールディレクトリ>/lib:$LD_LIBRARY_PATH"
            -c opt --force_pic --config oss_linux \
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)"
            --jobs $(nproc)                      \
  export PKG_CONFIG_PATH="/<Fcitxのインストールディレクトリ>/lib/pkgconfig:$PKG_CONFIG_PATH"
            --strip=never                        \
            --sandbox_debug                      \
            --verbose_failures                    \
            -s
# または
  bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
            unix/fcitx5:fcitx5-mozc.so server:mozc_server gui/tool:mozc_tool renderer:gtk_mozc_renderer \
            -c opt --copt=-fPIC --config oss_linux \
            --jobs $(nproc)                        \
            --verbose_failures
<br>
<br>
===== Fcitx5-qtのインストール =====
ビルドされたMozcファイル群が、src/bazel-binディレクトリに出力される。<br>
[https://github.com/fcitx/fcitx5-qt/tags Fcitx5-qtのGithub]にアクセスして、ソースコードをダウンロードする。<br>
tar xf <バージョン>.tar.gz
cd <バージョン>
<br>
<br>
または、<code>git clone</code>コマンドを使用して、Fcitx5-qtのソースコードをダウンロードする。
Mozcファイル群を、以下に示すディレクトリに配置する。<br>
git clone https://github.com/fcitx/fcitx5-qt.git
<u>ただし、Mozcのインストールディレクトリを変更している場合は、変更した設定に合わせてMozcファイル群を配置する必要がある。</u><br>
cd fcitx5-qt
  # デフォルトのインストールディレクトリ
<br>
  sudo cp bazel-bin/unix/fcitx/fcitx-mozc.so /usr/lib64/fcitx/
Fcitx5-qtのビルドに必要なライブラリをインストールする。<br>
  sudo cp bazel-bin/server/mozc_server      /usr/lib/mozc/
sudo zypper install libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel libQt5DBus-devel libQt5Concurrent-devel \
  sudo cp bazel-bin/gui/tool/mozc_tool      /usr/lib/mozc/
                    libqt5-qtbase-devel libqt5-qtbase-private-headers-devel
  sudo cp bazel-bin/renderer/mozc_renderer  /usr/lib/mozc/
<br>
Fcitx5-qtをビルドおよびインストールする。<br>
  cmake -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release \
      -DENABLE_QT4=off -DENABLE_QT6=off ..
  make -j $(nproc)
make install
<br>
===== Fcitx5-gtkのインストール =====
[https://github.com/fcitx/fcitx5-gtk/tags Fcitx5-gtkのGithub]にアクセスして、ソースコードをダウンロードする。<br>
tar xf <バージョン>.tar.gz
cd <バージョン>
<br>
または、<code>git clone</code>コマンドを使用して、Fcitx5-gtkのソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5-gtk.git
cd fcitx5-gtk
<br>
Fcitx5-gtkのビルドに必要なライブラリをインストールする。<br>
  sudo zypper install gobject-introspection-devel
<br>
Fcitx5-gtkをビルドおよびインストールする。<br>
cmake -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release \
      -DENABLE_GTK2_IM_MODULE=off -DENABLE_GTK4_IM_MODULE=off ..
make -j $(nproc)
make install
<br>
===== Marisaのインストール =====
[https://github.com/s-yata/marisa-trie.git MarisaのGithub]にアクセスして、ソースコードをダウンロードする。<br>
tar xf v<バージョン>.tar.gz
cd v<バージョン>
<br>
または、<code>git clone</code>コマンドを使用して、Marisaのソースコードをダウンロードする。<br>
git clone https://github.com/s-yata/marisa-trie.git
cd marisa-trie
<br>
Marisaのビルドに必要なライブラリをダウンロードする。<br>
  sudo zypper install python-devel
<br>
Marisaをビルドおよびインストールする。<br>
<u>この時、ビルドディレクトリは作成しないことに注意する。</u>
autoreconf -i
./configure --prefix=<Fcitx5のインストールディレクトリ> --enable-native-code
make -j $(nproc)
make install
<br>
MarisaのPython向けのライブラリも併せてインストールする。<br>
cd bindings/python
python setup.py build
python setup.py install --prefix=<Fcitx5のインストールディレクトリ>
<br>
===== libKKCおよびlibKKC Dataのインストール =====
[https://github.com/ueno/libkkc.git libKKCのGithub]にアクセスして、ソースコードをダウンロードする。<br>
tar xf libkkc-<バージョン>.tar.gz
cd libkkc-<バージョン>
<br>
または、<code>git clone</code>コマンドを使用して、libKKCのソースコードをダウンロードする。<br>
git clone https://github.com/ueno/libkkc.git
cd libKKC
<br>
libKKCのビルドに必要なライブラリをダウンロードする。<br>
  sudo zypper install intltool libgee-devel json-glib-devel gobject-introspection-devel \
                    vala libvala-0_54-0 libvala-0_54-devel python3-marisa marisa-devel xcb-util-wm-devel
<br>
libKKCをビルドおよびインストールする。<br>
export PATH="/<Fcitx5のインストールディレクトリ>/bin:$PATH"; \
export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib64:$LD_LIBRARY_PATH"; \
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)" \
export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib64/pkgconfig:$PKG_CONFIG_PATH"; \
export PYTHONPATH="/<Fcitx5のインストールディレクトリ>/lib64/python2.7/site-packages:$PYTHONPATH"
   
   
  ./autogen.sh --prefix=<Fcitx5のインストールディレクトリ>
  # インストールディレクトリを変更している場合
  make -j $(nproc)
cp bazel-bin/unix/fcitx/fcitx-mozc.so /<Mozcのインストールディレクトリ>/lib64/fcitx/
  make install
cp bazel-bin/server/mozc_server      /<Mozcのインストールディレクトリ>/lib/mozc/
  cp bazel-bin/gui/tool/mozc_tool      /<Mozcのインストールディレクトリ>/lib/mozc/
  cp bazel-bin/renderer/mozc_renderer  /<Mozcのインストールディレクトリ>/lib/mozc/
<br>
<br>
次に、[https://github.com/ueno/libkkc.git libKKC DataのGithub]にアクセスして、ソースコードをダウンロードする。<br>
<u>※注意</u><br>
tar xf libkkc-data-<バージョン>.tar.gz
<u>必要であれば、src/scripts/install_fcitx_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。</u><br>
cd libkkc-data-<バージョン>
<br>
libKKC Dataをビルドおよびインストールする。<br>
./configure --prefix=<Fcitx5のインストールディレクトリ>
make -j $(nproc)
make install
<br>
Fcitx5-KKCの動作に必要な依存関係のライブラリをインストールする。<br>
sudo zypper install libgee-0_8-2 typelib-1_0-Gee-0_8 libxcb-ewmh2
<br>
<br>


===== Fcitx5-KKCのインストール =====
==== Mozcの設定ファイルの作成 ====
[https://github.com/fcitx/fcitx5-kkc/tags/ Fcitx5-KKCのGithub]にアクセスして、ソースコードをダウンロードする。<br>
Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。<br>
  tar xf <バージョン>.tar.gz
vi /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
  cd <バージョン>
  # または
  sudo vi /usr/share/fcitx/addon/fcitx-mozc.conf
<br>
<br>
または、<code>git clone</code>コマンドを使用して、Fcitx5-gtkのソースコードをダウンロードする。
  <syntaxhighlight lang="ini">
git clone https://github.com/fcitx/fcitx5-kkc.git
  # /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
  cd fcitx5-kkc
  # または
<br>
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
Fcitx-KKCのビルドに必要なライブラリをインストールする。<br>
sudo zypper install gettext libgee-devel json-glib-devel pkg-config libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel
<br>
Fcitx5-KKCをビルドおよびインストールする。<br>
cmake -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release ..
  make -j $(nproc)
make install
<br>
===== Fcitx5-ConfigToolのインストール =====
[https://github.com/fcitx/fcitx5-configtool/tags Fcitx5-ConfigToolのGithub]にアクセスして、ソースコードをダウンロードする。<br>
tar xf <バージョン>.tar.gz
  cd <バージョン>
<br>
または、<code>git clone</code>コマンドを使用して、Fcitx5-ConfigToolのソースコードをダウンロードする。<br>
  git clone https://github.com/fcitx/fcitx5-configtool.git
cd fcitx5-configtool
<br>
Fcitx-ConfigToolのビルドに必要なライブラリをインストールする。<br>
sudo zypper install gettext libgee-devel json-glib-devel pkg-config \
                    libxkbcommon-devel libxkbfile-devel iso-codes-devel plasma-framework-devel kiconthemes-devel \
                    kcoreaddons-devel ki18n-devel kirigami2-devel kpackage-devel kwidgetsaddons-devel kitemviews-devel kdeclarative-devel \
                    libqt5-qtsvg-devel libQt5QuickControls2-devel libQt5Concurrent-devel libqt5-qtx11extras-devel
   
   
[Addon]
Type=SharedLibrary
Name=fcitx-mozc
GeneralName=Mozc
Comment=Mozc support for Fcitx
Library=fcitx-mozc.so
IMRegisterMethod=ConfigFile
LoadLocal=True
Category=InputMethod
Enabled=True
SubConfig=
</syntaxhighlight>
<br>
<br>
Fcitx5-ConfigToolをビルドおよびインストールする。<br>
次に、Fcitx-mozcのインプットメソッド設定ファイルを作成する。<br>
  cmake -DCMAKE_INSTALL_PREFIX=<Fcitxのインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release ..
  vi /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
  make -j $(nproc)
  # または
  make install
  sudo vi /usr/share/fcitx/inputmethod/mozc.conf
<br>
<br>
===== Mozcのインストール =====
<syntaxhighlight lang="ini">
Mozcのソースコードをダウンロードする。<br>
# /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
Mozcをビルドするには、GCC 8以降が必要となる。<br>
  # または
git clone --depth 1 https://github.com/fcitx/mozc.git
  # /usr/share/fcitx/inputmethod/mozc.confファイル
cd mozc
git submodule update --init --recursive
  cd src
<br>
Mozcのビルドに必要な依存関係のライブラリをインストールする。<br>
  sudo zypper install libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel libQt5DBus-devel libQt5Concurrent-devel \
                    libqt5-qtbase-devel libqt5-qtbase-private-headers-devel
<br>
Fcitx5のパスが通っているかどうかを確認する。<br>
export PATH="/<Fcitx5のインストールディレクトリ>/bin:$PATH"
export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib64:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)"
export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib64/pkgconfig:$PKG_CONFIG_PATH"
   
   
  export CPATH="/<Fcitx5のインストールディレクトリ>/include/Fcitx5/Core:/<Fcitx5のインストールディレクトリ>/include/Fcitx5/Config:/<Fcitx5のインストールディレクトリ>/include/Fcitx5/Module:/<Fcitx5のインストールディレクトリ>/include/Fcitx5/Utils"
  [InputMethod]
UniqueName=mozc
Name=Mozc
IconName=/usr/share/fcitx/mozc/icon/mozc.png
Priority=1
LangCode=ja
Parent=fcitx-mozc
</syntaxhighlight>
<br>
<br>
Fcitx5-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。<br>
[https://download.fcitx-im.org/fcitx-mozc/ Fcitxの公式Webサイト]にアクセスして、Fcitx-mozcアイコンをダウンロードする。<br>
bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
または、<code>wget</code>コマンドを実行して、Fcitx-mozcアイコンをダウンロードする。<br>
            -c opt --copt=-fPIC --config oss_linux \
wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz
            unix/fcitx5:fcitx5-mozc.so server:mozc_server gui/tool:mozc_tool renderer:mozc_renderer \
            --verbose_failures
<br>
<br>
上記のファイルを、以下に示す場所に配置する。<br>
ダウンロードしたファイルを解凍する。<br>
  cp bazel-bin/unix/fcitx5/fcitx5-mozc.so /<Fcitx5のインストールディレクトリ>/lib64/fcitx5/
  tar xf fcitx-mozc-icon.tar.gz
sudo cp bazel-bin/server/mozc_server /usr/lib64/mozc/
sudo cp bazel-bin/gui/tool/mozc_tool /usr/lib64/mozc/
<br>
<br>
BUILD.fcitx5.bazelファイルおよびWORKSPACE.bazelファイルは、ユーザに合わせて更新する必要があるかもしれない。<br>
Fcitx-mozcアイコンを、/usr/share/fcitx/mozc/iconディレクトリに配置する。<br>
カスタムプレフィックスが必要な場合は、config.bzlファイルを編集して、mozcサーバのパスを調整する必要がある。<br>
  cp fcitx-mozc-icons/* /<Mozcのインストールディレクトリ>/share/fcitx/mozc/icon
<br>
  # または
また、必要であれば、src/scripts/install_fcitx5_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。<br>
  sudo mkdir -p /usr/share/fcitx/mozc/icon
<br>
  sudo cp fcitx-mozc-icons/* /usr/share/fcitx/mozc/icon
 
==== Fcitx5の有効化 ====
Fcitx5を有効にするには、~/.ximファイルを編集する。<br>
  # SUSE
  vi ~/.xim
<br>
~/.ximファイル
   
  export INPUT_METHOD="fcitx5"
  export XMODIFIERS="@im=fcitx5"
  export GTK_IM_MODULE="fcitx5"
export QT_IM_MODULE="fcitx5"
fcitx5 &
<br><br>
<br><br>


427行目: 470行目:


== Fcitxの設定 ==
== Fcitxの設定 ==
==== GNOME ====
==== GNOME (X11) ====
/etc/sysconfig/languageファイルを、以下のように編集する。<br>
/etc/sysconfig/languageファイルを、以下のように編集する。<br>
  sudo vi /etc/sysconfig/language
  sudo vi /etc/sysconfig/language
459行目: 502行目:
これにより、[Ctrl] + [Space]キーを同時押下して、Fcitxのインプットメソッドを呼び出すことができる。<br>
これにより、[Ctrl] + [Space]キーを同時押下して、Fcitxのインプットメソッドを呼び出すことができる。<br>
<br>
<br>
==== KDE ====
==== KDE (X11) ====
~/.profileファイルまたは~/.ximファイルに、以下の設定を追記する。<br>
~/.profileファイルまたは~/.ximファイルに、以下の設定を追記する。<br>
  vi ~/.profile
  vi ~/.profile
501行目: 544行目:
  QT_IM_MODULE=fcitx
  QT_IM_MODULE=fcitx
  DefaultIMModule=fcitx
  DefaultIMModule=fcitx
# Fcitx5を使用する場合
INPUT_METHOD=fcitx5
XMODIFIERS=@im=fcitx5
GTK_IM_MODULE=fcitx5
QT_IM_MODULE=fcitx5
# iBusを使用する場合
INPUT_METHOD=ibus
GTK_IM_MODULE=ibus
QT_IM_MODULE=ibus
XMODIFIERS=@im=ibus
<br>
<br>
最後に、PCを再起動する。<br>
最後に、PCを再起動する。<br>
520行目: 551行目:
==== 単語登録 ====
==== 単語登録 ====
KKCにおいて、単語登録する手順を以下に示す。<br>
KKCにおいて、単語登録する手順を以下に示す。<br>
# ~/.config/fcitx/kkc/dictionary/segmentファイルを開く。
#* Fcitxの場合
#*: ~/.config/fcitx/kkc/dictionary/segmentファイルを開く。
#* Fcitx5の場合
#*: ~/.local/share/fcitx5/kkc/dictionary/segmentファイルを開く。
# segmentファイルの最下行に、以下の内容を追記する。
# segmentファイルの最下行に、以下の内容を追記する。
#* 1つの読みがなで1つの単語を登録する場合 : <code><読みがな> /<登録する単語>;<登録する単語の種類>/</code>
#* 1つの読みがなで1つの単語を登録する場合 : <code><読みがな> /<登録する単語>;<登録する単語の種類>/</code>
528行目: 562行目:
#: <code>めーる /hoge@piyo.com;メール/</code>
#: <code>めーる /hoge@piyo.com;メール/</code>
#: <br>
#: <br>
# Fcitxにおいて、[Reload Config]または[再起動]を選択する。
# Fcitx / Fcitx 5において、[Reload Config]または[再起動]を選択する。
# 正常に単語登録されているかどうかを確認する。
# 正常に単語登録されているかどうかを確認する。
# 登録された単語を削除する場合は、該当単語の行を削除して、[Reload Config]または[再起動]を選択する。
# 登録された単語を削除する場合は、該当単語の行を削除して、[Reload Config]または[再起動]を選択する。
579行目: 613行目:
再ログインまたはPCを再起動する。<br>
再ログインまたはPCを再起動する。<br>
<br><br>
<br><br>
{{#seo:
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux
|image=/resources/assets/MochiuLogo_Single_Blue.png
}}


__FORCETOC__
__FORCETOC__
[[カテゴリ:CentOS]][[カテゴリ:SUSE]]
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]

2024年10月27日 (日) 01:34時点における最新版

概要

Fcitxは、拡張機能をサポートした入力メソッドフレームワークである。

Fcitxには、3つの入力メソッドエンジン、Pinyin、QuWei、テーブルベースの入力メソッドが内蔵されている。


Fcitxのインストール (パッケージ管理システムからインストール)

RHEL


SUSE

# KKCを使用する場合
sudo zypper install fcitx-kkc fcitx-table-other

# SKKを使用する場合
sudo zypper install fcitx-skk fcitx-table-other

# Mozcを使用する場合
sudo zypper install fcitx-mozc fcitx-table-other

# Anthyを使用する場合
# 2021年からプロジェクトが再開されており、2023年以降からAnthy Unicodeとしてパッケージが配布されている
sudo zypper install fcitx-anthy fcitx-table-other


次に、Fcitxの設定ツールをインストールする。

# GNOME
sudo zypper install fcitx-configtool fcitx-config-gtk3

# KDE
sudo zypper install fcitx-config-kde4 (以前は、kcm-fcitxと呼ばれていた)


※注意
2023年10月現在、パッケージ管理システムからFcitx-Mozcが削除された。

また、Fcitx関連のソフトウェアは、全てfcitxで始まるため、fcitxを検索すると表示される。


Fcitxのインストール (リポジトリを追加してインストール)

SUSEの公式リポジトリからM17Nリポジトリを追加する。

# SLE / openSUSE Leap
sudo zypper addrepo 'https://download.opensuse.org/repositories/M17N/$releasever/M17N.repo' M17N


追加したリポジトリを更新する。

sudo zypper refresh


Fcitxをインストールする。

# KKCを使用する場合
sudo zypper install fcitx-kkc fcitx-table-other

# SKKを使用する場合
sudo zypper install fcitx-skk fcitx-table-other

# Mozcを使用する場合
sudo zypper install fcitx-mozc fcitx-table-other

# Anthyを使用する場合
# 2021年からプロジェクトが再開されており、2023年以降からAnthy Unicodeとしてパッケージが配布されている
sudo zypper install fcitx-anthy fcitx-table-other



Mozcのインストール (ソースコードからインストール)

ソースコードのダウンロード

SLE 15において、現在、パッケージ管理システムにFcitx-mozcが存在しない。
そのため、FcitxでMozcを使用する場合は、ソースコードからビルドおよびインストールする必要がある。

Mozcのソースコードをダウンロードする。
Mozcをビルドするには、GCC 8以降が必要となる。

git clone --depth 1 https://github.com/fcitx/mozc.git
cd mozc
git submodule update --init --recursive
cd src

# または

git clone https://github.com/google/mozc.git -b master --single-branch --recursive
cd mozc/src


Mozcのビルドに必要な依存関係のライブラリをインストールする。

sudo zypper install git curl unzip bzip2 update-desktop-files pkg-config make ninja gcc10-c++ zlib-devel protobuf-devel \
                    bazel6 bazel-rules-cc-source bazel-apple-support-source bazel-workspaces \
                    bazel-rules-java-source bazel-rules-proto-source                         \
                    bazel-rules-python-source bazel-rules-swift-source bazel-skylib-source   \
                    qt6-core-devel qt6-gui-devel qt6-widgets-devel                           \
                    ibus-devel
                    fcitx-devel  # Fcitxをパッケージ管理システムからインストールしている場合


通常のLinux環境でMozcを構築する場合は、以下のファイルを修正する必要がある。

  • src/config.bzl
    インストールパス等の指定する。
  • src/.bazelrc
    コンパイラのフラグ等を指定する。
  • src/WORKSPACE.bazel
    ビルドの依存関係。


インストールディレクトリの設定

必要ならば、srcディレクトリにあるconfig.bzlファイルを編集して、インストールディレクトリを変更する。

vi mozc/src/config.bzl


# mozc/src/config.bzlファイル

LINUX_MOZC_BROWSER_COMMAND = "/usr/bin/xdg-open"
LINUX_MOZC_ICONS_DIR = "/<Mozcのインストールディクトリ>/share/icons/mozc"
LINUX_MOZC_SERVER_DIR = "/<Mozcのインストールディクトリ>/lib/mozc"
LINUX_MOZC_DOCUMENT_DIR = LINUX_MOZC_SERVER_DIR + "/documents"
IBUS_COMPONENT_DIR = "/<Mozcのインストールディクトリ>/share/ibus/component"
IBUS_MOZC_INSTALL_DIR = "/<Mozcのインストールディクトリ>/share/ibus-mozc"
IBUS_MOZC_ICON_PATH = IBUS_MOZC_INSTALL_DIR + "/product_icon.png"
IBUS_MOZC_PATH = "/<Mozcのインストールディクトリ>/lib/ibus-mozc/ibus-engine-mozc"
EMACS_MOZC_CLIENT_DIR = "/<Mozcのインストールディクトリ>/share/emacs/site-lisp/emacs-mozc"
EMACS_MOZC_HELPER_DIR = "/<Mozcのインストールディクトリ>/bin"


Bazelの設定ファイルの作成と変更

WORKSPACEの編集

src/WORKSPACE.bazelファイルを編集して、以下に示す設定を追記する。

vi src/WORKSPACE.bazel


  • パッケージ管理システムからFcitxをインストールしている場合
# src/WORKSPACE.bazelファイル
## 138行目あたり

# Fcitx
# pkg_config_repository does not work because pkgconfig --cflags-only-I fcitx returns nothing
new_local_repository(
  name = "fcitx",
  # This path should be updated per the environment.
  path = "/usr",  # For Debian
  build_file = "BUILD.fcitx.bazel",
)


  • ソースコードからFcitxをインストールしている場合
# src/WORKSPACE.bazelファイル
## 138行目あたり

# Fcitx
new_local_repository(
  name = "fcitx",
  path = "/<Fcitxのインストールディレクトリ>",
  build_file = "BUILD.fcitx.bazel",
)


src/BUILD.fcitx.bazelファイルを作成する。

vi src/BUILD.fcitx.bazel


# src/BUILD.fcitx.bazelファイル

package(
   default_visibility = ["//visibility:public"],
)

cc_library(
   name = "fcitx",
   hdrs = glob([
       "include/fcitx/**",
       "include/fcitx-config/**",
       "include/fcitx-utils/**",
   ]),
   copts = ["-pthread"],
   includes = [
       "include",
   ],
   linkopts = [
       "-lfcitx-core",
       "-lfcitx-config",
       "-lfcitx-utils",
   ],
)


Python 3.6を使用している場合
vi src/base/gen_config_file_stream_data.py


 # src/base/gen_config_file_stream_data.pyファイル
 # 68行目あたり
 
 ## 編集前
 output.write('constexpr FileData kFileData[] = {\n')
 for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
       while (byte := stream.read(1)):
          output.write(r'\x' + byte.hex())
    output.write('"},\n')
 output.write('};\n')
 
 ## 編集後
 output.write('constexpr FileData kFileData[] = {\n')
 for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
       byte = stream.read(1)
       while (byte):
          output.write(r'\x' + byte.hex())
          byte = stream.read(1)
    output.write('"},\n')
 output.write('};\n')


Mozcのウインドウレンダリングの変更
vi src/renderer/qt/qt_window_manager.cc


 // src/renderer/qt/qt_window_manager.ccファイル
 // 35行目あたり
 
 // 編集前
 #include "base/logging.h"
 #include "protocol/candidates.pb.h"
 #include "absl/strings/str_cat.h"
 #include "renderer/renderer_style_handler.h"
 #include "renderer/window_util.h"
 
 // 編集後
 #include "absl/strings/str_cat.h"
 #include "base/logging.h"
 #include "protocol/candidates.pb.h"
 #include "renderer/renderer_style_handler.h"
 #include "renderer/window_util.h"


 // src/renderer/qt/qt_window_manager.ccファイル
 // 344行目あたり
 
 // 追加
 struct VirtualRect {
    const QScreen* screen;
    const Rect rect;
 
    VirtualRect(const QScreen* screen, const Rect rect): screen(screen), rect(rect) {}
 };
 
 Rect TranslateToVirtualRectWithScreen(const QScreen *screen, const Rect& native_rect) {
    const double device_pixel_ratio = screen->devicePixelRatio();
    // screen_left, screen_top have the save value in both virtual and native coordinate
    const int screen_left = screen->geometry().x();
    const int screen_top = screen->geometry().y();
    const int vx = (native_rect.Left() - screen_left) / device_pixel_ratio + screen_left;
    const int vy = (native_rect.Top() - screen_top) / device_pixel_ratio + screen_top;
 
    return Rect(vx, vy, native_rect.Width() / device_pixel_ratio, native_rect.Height() / device_pixel_ratio);
 }
 
 VirtualRect TranslateToVirtualRect(const Rect& native_rect) {
    for (const QScreen *screen: QGuiApplication::screens()) {
       Rect rect = TranslateToVirtualRectWithScreen(screen, native_rect);
       const QRect screen_rect = screen->geometry();
 
       // Use (top left) to locate a screen
       if (screen_rect.contains(rect.Left(), rect.Top())) {
          return VirtualRect(screen, rect);
       }
    }
 
    // fall back to primary screen
    const QScreen *screen = QGuiApplication::primaryScreen();
    Rect point = TranslateToVirtualRectWithScreen(screen, native_rect);
    return VirtualRect(screen, point);
 }


 // src/renderer/qt/qt_window_manager.ccファイル
 // 379行目あたり
 
 // 編集前
 Point QtWindowManager::GetWindowPosition(
    const commands::RendererCommand &command, const Size &win_size) {
 
    const Rect preedit_rect = GetRect(command.preedit_rectangle());
    const Point win_pos = Point(preedit_rect.Left(), preedit_rect.Bottom());
    const Rect monitor_rect = GetMonitorRect(win_pos.x, win_pos.y);
    const Point offset_to_column1(kColumn0Width, 0);
 
    const Rect adjusted_win_geometry =
       WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
          win_pos, preedit_rect, win_size, offset_to_column1, monitor_rect,
          /* vertical */ false);  // Only support horizontal window yet.
    return adjusted_win_geometry.origin;
 }
 
 // 編集後
 Point QtWindowManager::GetWindowPosition(
    const commands::RendererCommand &command, const Size &win_size) {
 
    const Rect native_preedit_rect = GetRect(command.preedit_rectangle());
    const VirtualRect preedit_rect = TranslateToVirtualRect(native_preedit_rect);
    const Point win_pos = Point(preedit_rect.rect.Left(), preedit_rect.rect.Bottom());
    const Rect monitor_rect = GetRect(preedit_rect.screen->geometry());
    const Point offset_to_column1(kColumn0Width, 0);
 
    const Rect adjusted_win_geometry =
       WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
          win_pos, preedit_rect.rect, win_size, offset_to_column1, monitor_rect,
          /* vertical */ false);  // Only support horizontal window yet.
    return adjusted_win_geometry.origin;
 }


IBus-Mozcの設定
vi src/unix/ibus/gen_mozc_xml.py


 # src/unix/ibus/gen_mozc_xml.pyファイル
 # 261行目あたり
 
 # 編集前
 }, {
     'name': 'mozc-off',
     'longname': product_name + ':A_',
     'layout': 'default',
     'layout_variant': '',
     'layout_option': '',
     'rank': 99,
     'symbol': 'A',
     'composition_mode': 'DIRECT',
 }]
 
 # 編集後
 }, {
     'name': 'mozc-off',
     'longname': product_name + ':A_',
     'layout': 'default',
     'layout_variant': '',
     'layout_option': '',
     'rank': 99,
     'symbol': 'A',
     'composition_mode': 'DIRECT',
 }, {
     'name': 'mozc-jp-jp',
     'longname': product_name + " - JP layout",
     'layout': 'jp',
     'layout_variant': '',
     'layout_option': '',
     'rank': 0,
 }, {
     'name': 'mozc-us',
     'longname': product_name + " - US layout",
     'layout': 'us',
     'layout_variant': '',
     'layout_option': '',
     'rank': 0,
 }, {
     'name': 'mozc-dv',
     'longname': product_name + " - US Dvorak layout",
     'layout': 'us',
     'layout_variant': 'dvorak',
     'layout_option': '',
     'rank': 0,
 }]


Mozcのビルド

Fcitx-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。

 # Fcitxをソースコードからインストールしている場合
 
 FCITX_DIR="<Fcitxのインストールディレクトリ>"; \
 export PATH="$FCITX_DIR/bin:$PATH";    \
 export LD_LIBRARY_PATH="$FCITX_DIR/lib64:$FCITX_DIR/lib:$LD_LIBRARY_PATH";                     \
 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)";         \
 export PKG_CONFIG_PATH="$FCITX_DIR/lib64/pkgconfig:$FCITX_DIR/lib/pkgconfig:$PKG_CONFIG_PATH"


bazel build package --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
            //unix/fcitx:fcitx-mozc.so            \
            -c opt --force_pic --config oss_linux \
            --jobs $(nproc)                       \
            --strip=never                         \
            --sandbox_debug                       \
            --verbose_failures                    \
            -s
# または
bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
            unix/fcitx5:fcitx5-mozc.so server:mozc_server gui/tool:mozc_tool renderer:gtk_mozc_renderer \
            -c opt --copt=-fPIC --config oss_linux \
            --jobs $(nproc)                        \
            --verbose_failures


ビルドされたMozcファイル群が、src/bazel-binディレクトリに出力される。

Mozcファイル群を、以下に示すディレクトリに配置する。
ただし、Mozcのインストールディレクトリを変更している場合は、変更した設定に合わせてMozcファイル群を配置する必要がある。

# デフォルトのインストールディレクトリ
sudo cp bazel-bin/unix/fcitx/fcitx-mozc.so /usr/lib64/fcitx/
sudo cp bazel-bin/server/mozc_server       /usr/lib/mozc/
sudo cp bazel-bin/gui/tool/mozc_tool       /usr/lib/mozc/
sudo cp bazel-bin/renderer/mozc_renderer   /usr/lib/mozc/

# インストールディレクトリを変更している場合
cp bazel-bin/unix/fcitx/fcitx-mozc.so /<Mozcのインストールディレクトリ>/lib64/fcitx/
cp bazel-bin/server/mozc_server       /<Mozcのインストールディレクトリ>/lib/mozc/
cp bazel-bin/gui/tool/mozc_tool       /<Mozcのインストールディレクトリ>/lib/mozc/
cp bazel-bin/renderer/mozc_renderer   /<Mozcのインストールディレクトリ>/lib/mozc/


※注意
必要であれば、src/scripts/install_fcitx_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。

Mozcの設定ファイルの作成

Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。

vi /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
# または
sudo vi /usr/share/fcitx/addon/fcitx-mozc.conf


 # /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
 # または
 # /usr/share/fcitx/addon/fcitx-mozc.confファイル
 
 [Addon]
 Type=SharedLibrary
 Name=fcitx-mozc
 GeneralName=Mozc
 Comment=Mozc support for Fcitx
 Library=fcitx-mozc.so
 IMRegisterMethod=ConfigFile
 LoadLocal=True
 Category=InputMethod
 Enabled=True
 SubConfig=


次に、Fcitx-mozcのインプットメソッド設定ファイルを作成する。

vi /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
# または
sudo vi /usr/share/fcitx/inputmethod/mozc.conf


 # /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
 # または
 # /usr/share/fcitx/inputmethod/mozc.confファイル
 
 [InputMethod]
 UniqueName=mozc
 Name=Mozc
 IconName=/usr/share/fcitx/mozc/icon/mozc.png
 Priority=1
 LangCode=ja
 Parent=fcitx-mozc


Fcitxの公式Webサイトにアクセスして、Fcitx-mozcアイコンをダウンロードする。
または、wgetコマンドを実行して、Fcitx-mozcアイコンをダウンロードする。

wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz


ダウンロードしたファイルを解凍する。

tar xf fcitx-mozc-icon.tar.gz


Fcitx-mozcアイコンを、/usr/share/fcitx/mozc/iconディレクトリに配置する。

cp fcitx-mozc-icons/*  /<Mozcのインストールディレクトリ>/share/fcitx/mozc/icon
# または
sudo mkdir -p /usr/share/fcitx/mozc/icon
sudo cp fcitx-mozc-icons/*  /usr/share/fcitx/mozc/icon



拡張機能のインストール

GNOME

https://extensions.gnome.org にアクセスし、検索項目にfcitxと入力・検索して、その拡張機能をインストールする。

KDE

Input Method Panelと呼ばれるプラズモイドを追加できる。
これは、KDE Plasmaアドオンのkimpanelである。
標準でインストールされているので、必要なことは、そのプラズモイドを追加することだけである。

他には、M17Nには、kimtoyと呼ばれるサードパーティ製ソフトウェアが存在する。(Qtで記述されている)
nepomuk等を有効にすることができる。(ただし、KDEの反応が悪くなる)


Fcitxの設定

GNOME (X11)

/etc/sysconfig/languageファイルを、以下のように編集する。

sudo vi /etc/sysconfig/language


# /etc/sysconfig/languageファイル

# 変更前
INPUT_METHOD=""

# 変更後
INPUT_METHOD="fcitx"


~/.profileファイルに、以下の設定を追記する。

vi ~/.profile


# ~/.profile

export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx


PCを再ログインまたは再起動する。

次に、以下のコマンドを実行して、Fcitxの設定ツールを起動する。

fcitx-config-gtk3


Fcitxの設定ツール画面左下にある[+]アイコンを選択して、入力メソッドを追加する。
インプットメソッドの追加画面下部にある[only show current language]チェックボックスのチェックを外して、"Japan"と検索する。
目的のインプットメソッドを選択して、[OK]ボタンを押下する。
これにより、[Ctrl] + [Space]キーを同時押下して、Fcitxのインプットメソッドを呼び出すことができる。

KDE (X11)

~/.profileファイルまたは~/.ximファイルに、以下の設定を追記する。

vi ~/.profile
または
vi ~/.xim


# ~/.profileファイルまたは~/.ximファイル

export INPUT_METHOD="fcitx"
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx


PCを再ログインまたは再起動する。

次に、以下のコマンドを実行して、設定ツールを起動する。
または、システムトレイから起動する。

# GNOME
fcitx-config-gtk

# KDE
fcitx-config-kde


Wayland

最新のFcitxとiBusでは、Xのプロトコルアダプタを介して、基本的なWaylandサポートを備えている。
今後は、Waylandを直接サポートする予定である。

Waylandで入力メソッドを有効にするには、/etc/environmentファイル、または、~/.pam_environmentファイルに以下の内容を追記する。
なお、~/.xprofileファイル、~/.profileファイル、~/.bashrcファイル、~/.xinitrcファイルは設定不要である。

sudo vi /etc/environment
または
vi ~/.pam_environment


# /etc/environmentファイル または ~/.pam_environmentファイル

# Fcitxを使用する場合
LANG=en_US.UTF-8
INPUT_METHOD=fcitx
XMODIFIERS=@im=fcitx
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
DefaultIMModule=fcitx


最後に、PCを再起動する。


KKC

単語登録

KKCにおいて、単語登録する手順を以下に示す。

    • Fcitxの場合
      ~/.config/fcitx/kkc/dictionary/segmentファイルを開く。
    • Fcitx5の場合
      ~/.local/share/fcitx5/kkc/dictionary/segmentファイルを開く。
  1. segmentファイルの最下行に、以下の内容を追記する。
    • 1つの読みがなで1つの単語を登録する場合 : <読みがな> /<登録する単語>;<登録する単語の種類>/
    • 1つの読みがなで3つの単語を登録する場合 : <読みがな> /<登録する単語>;<登録する単語の種類>/<登録する単語>;<登録する単語の種類>/<登録する単語>;<登録する単語の種類>/

    例えば、"hoge@piyo.com"という単語を"めーる"という読みで登録する時は、以下の手順を行う。
    めーる /hoge@piyo.com;メール/

  2. Fcitx / Fcitx 5において、[Reload Config]または[再起動]を選択する。
  3. 正常に単語登録されているかどうかを確認する。
  4. 登録された単語を削除する場合は、該当単語の行を削除して、[Reload Config]または[再起動]を選択する。



その他

Fcitxの再起動

Fcitx関連のソフトウェアのインストール後、設定等を反映させるため、Fcitxを再起動する必要がある。
Fcitxを再起動するには、以下のコマンドを実行する。

fcitx -r


一部の入力メソッドは標準でリストに追加される。(通常、内部に入力メソッドが1つしかないパッケージの場合)
入力メソッドが追加されない場合、設定ツールを使用してそれらをリストに追加して、ニーズに合わせていくつかのオプションを調整することを推奨する。

ibusからfcitxへの切り替え

GNOME以外では、切り替え操作は不要である。
Fcitxを導入して再ログインすると、インプットメソッドがfcitxに自動的に切り替わる。

GNOMEの場合、ibusとの統合を解除する必要があるかもしれない。
もし、自動的に切り替わらない場合は、以下コマンドを実行する。

gsettings set org.gnome.settings-daemon.plugins.keyboard active false


以下のコマンドを実行して、ibusからFcitxへ切り替える。

imsetting-switch fcitx


日本語入力できない場合 1

以下のコマンドを実行する。

sudo mv /usr/share/ibus/component/kimpanel.xml /usr/share/ibus/component/kimpanel_org.xml


日本語入力できない場合 2

Fcitxより先に起動したソフトウェアにおいて、日本語入力できない場合がある。
その時、~/.ximファイルを作成して、以下の内容を記述する。

vi ~/.xim


export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx

LANG=ja_JP.UTF-8 fcitx -r



Fcitxのアンインストール

以下のコマンドを実行して、Fcitxをアンインストールする。

# GNOME
sudo zypper remove fcitx fcitx-kkc fcitx-skk fcitx-mozc fcitx-anthy fcitx-m17n fcitx-table-other fcitx-config-gtk3 

# KDE
sudo zypper remove fcitx fcitx-kkc fcitx-skk fcitx-mozc fcitx-anthy fcitx-m17n fcitx-table-other fcitx-config-kde4


再ログインまたはPCを再起動する。