(同じ利用者による、間の13版が非表示)
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>
<br>
==== ソースコードからインストール ====
<u>また、Fcitx関連のソフトウェアは、全てfcitxで始まるため、fcitxを検索すると表示される。</u><br>
===== Mozcのインストール =====
<br><br>
 
== Fcitxのインストール (リポジトリを追加してインストール) ==
SUSEの公式リポジトリからM17Nリポジトリを追加する。<br>
# SLE / openSUSE Leap
sudo zypper addrepo 'https://download.opensuse.org/repositories/M17N/$releasever/M17N.repo' M17N
<br>
追加したリポジトリを更新する。<br>
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>
通常のLinux環境でMozcを構築する場合は、以下のファイルを修正する必要がある。<br>
* src/config.bzl
*: インストールパス等の指定する。
* src/.bazelrc
*: コンパイラのフラグ等を指定する。
* src/WORKSPACE.bazel
*: ビルドの依存関係。
<br>
==== インストールディレクトリの設定 ====
必要ならば、srcディレクトリにあるconfig.bzlファイルを編集して、インストールディレクトリを変更する。<br>
vi mozc/src/config.bzl
<br>
# 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"
<br>
==== Bazelの設定ファイルの作成と変更 ====
===== WORKSPACEの編集 =====
src/WORKSPACE.bazelファイルを編集して、以下に示す設定を追記する。<br>
vi src/WORKSPACE.bazel
<br>
* パッケージ管理システムから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",
)
<br>
* ソースコードからFcitxをインストールしている場合
# src/WORKSPACE.bazelファイル
## 138行目あたり
# Fcitx
new_local_repository(
  name = "fcitx",
  path = "/<Fcitxのインストールディレクトリ>",
  build_file = "BUILD.fcitx.bazel",
)
<br>
src/BUILD.fcitx.bazelファイルを作成する。<br>
vi src/BUILD.fcitx.bazel
<br>
# 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",
    ],
)
<br>
 
===== Python 3.6を使用している場合 =====
vi src/base/gen_config_file_stream_data.py
<br>
<syntaxhighlight lang="python">
# 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')
</syntaxhighlight>
<br>
===== Mozcのウインドウレンダリングの変更 =====
vi src/renderer/qt/qt_window_manager.cc
<br>
<syntaxhighlight lang="c++">
// 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"
</syntaxhighlight>
<br>
<syntaxhighlight lang="c++">
// 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);
}
</syntaxhighlight>
<br>
<syntaxhighlight lang="c++">
// 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;
}
</syntaxhighlight>
<br>
===== IBus-Mozcの設定 =====
vi src/unix/ibus/gen_mozc_xml.py
<br>
<syntaxhighlight lang="python">
# 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,
}]
</syntaxhighlight>
<br>
 
==== Mozcのビルド ====
Fcitx-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。<br>
<br>
<syntaxhighlight lang="sh">
# 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"
</syntaxhighlight>
<br>
<br>
Fcitx-Mozc、Mozcサーバ、Mozcツール、Mozcレンダラーをビルドする。<br>
  bazel build package --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \
  bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> -c opt --copt=-fPIC --config oss_linux \
            //unix/fcitx:fcitx-mozc.so            \
             unix/fcitx:fcitx-mozc.so server:mozc_server gui/tool:mozc_tool renderer:mozc_renderer \
            -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
             --verbose_failures
<br>
<br>
生成したmozcファイルを、以下に示す場所に配置する。<br>
ビルドされたMozcファイル群が、src/bazel-binディレクトリに出力される。<br>
<br>
Mozcファイル群を、以下に示すディレクトリに配置する。<br>
<u>ただし、Mozcのインストールディレクトリを変更している場合は、変更した設定に合わせてMozcファイル群を配置する必要がある。</u><br>
# デフォルトのインストールディレクトリ
  sudo cp bazel-bin/unix/fcitx/fcitx-mozc.so /usr/lib64/fcitx/
  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/server/mozc_server       /usr/lib/mozc/
  sudo cp bazel-bin/gui/tool/mozc_tool /usr/lib64/mozc/
  sudo cp bazel-bin/gui/tool/mozc_tool       /usr/lib/mozc/
  sudo cp bazel-bin/renderer/mozc_renderer /usr/lib64/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/
<br>
<br>
次に、Fcitx-mozcの設定ファイルを作成する。<br>
<u>※注意</u><br>
<u>必要であれば、src/scripts/install_fcitx_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。</u><br>
<br>
 
==== Mozcの設定ファイルの作成 ====
Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。<br>
vi /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
# または
  sudo vi /usr/share/fcitx/addon/fcitx-mozc.conf
  sudo vi /usr/share/fcitx/addon/fcitx-mozc.conf
<br>
<br>
<syntaxhighlight lang="ini">
# /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
# または
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
   
   
83行目: 421行目:
  Enabled=True
  Enabled=True
  SubConfig=
  SubConfig=
</syntaxhighlight>
<br>
<br>
次に、Fcitx-mozcのインプットメソッド設定ファイルを作成する。<br>
次に、Fcitx-mozcのインプットメソッド設定ファイルを作成する。<br>
vi /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
# または
  sudo vi /usr/share/fcitx/inputmethod/mozc.conf
  sudo vi /usr/share/fcitx/inputmethod/mozc.conf
<br>
<br>
<syntaxhighlight lang="ini">
# /<Mozcのインストールディレクトリ>/share/fcitx/inputmethod/mozc.conf
# または
  # /usr/share/fcitx/inputmethod/mozc.confファイル
  # /usr/share/fcitx/inputmethod/mozc.confファイル
   
   
96行目: 440行目:
  LangCode=ja
  LangCode=ja
  Parent=fcitx-mozc
  Parent=fcitx-mozc
</syntaxhighlight>
<br>
<br>
最後に、[https://download.fcitx-im.org/fcitx-mozc/ Fcitxの公式Webサイト]にアクセスして、Fcitx-mozcアイコンをダウンロードする。<br>
[https://download.fcitx-im.org/fcitx-mozc/ Fcitxの公式Webサイト]にアクセスして、Fcitx-mozcアイコンをダウンロードする。<br>
または、<code>wget</code>コマンドを実行して、Fcitx-mozcアイコンをダウンロードする。<br>
または、<code>wget</code>コマンドを実行して、Fcitx-mozcアイコンをダウンロードする。<br>
  wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz
  wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz
105行目: 450行目:
<br>
<br>
Fcitx-mozcアイコンを、/usr/share/fcitx/mozc/iconディレクトリに配置する。<br>
Fcitx-mozcアイコンを、/usr/share/fcitx/mozc/iconディレクトリに配置する。<br>
  mkdir -p /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
  sudo cp fcitx-mozc-icons/*  /usr/share/fcitx/mozc/icon
<br><br>
<br><br>
266行目: 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__
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]