0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arch Linux + GNOME + IBus-Mozc 環境でデフォルトの句読点を半角ピリオド + スペースにする

Last updated at Posted at 2025-07-01

環境

  • OS: Arch Linux
  • デスクトップ環境: GNOME (Wayland)
  • IME: Mozc (IBus-Mozc)
  • プロトコル定義: protobuf

背景

日本語入力時に「、」「。」キーを押すと, 期待する「,␠(半角カンマ+半角スペース)」「.␠(半角ピリオド+半角スペース)」ではなく, 全角スペース(U+3000)が挿入される.
GUI設定だけでは半角化できず, 最終的にプロトコル定義を直接編集して解決した.

試した手順(すべて GUI +ローマ字テーブル)

  1. Mozc 設定 GUI

    • 全般タブ → スペースの入力 → 半角
    • 入力補助タブ → 変換前/後文字列 → 半角統一
  2. ローマ字テーブル編集

    • 先頭に , → ,␠ / . → .␠ を追加・優先化
  3. スペースの書き換え

    protoc decode < config1.db > cfg.txt
    
    • space_character_form: FUNDAMENTAL_HALF_WIDTH へ変更

いずれも句読点直後のスペースだけ全角化され, 解決には至らなかった.

character_form_rules の修正

Mozc の設定には優先評価される character_form_rules テーブルがあり, 「句読点グループ(“、。”/UTF-8: \343\200\202\343\200\201)」の conversion_character_form が依然 FULL_WIDTH のまま残っていたため, 最終段で全角化されていた.

手順

  1. 設定ディレクトリへ移動

    cd ~/.config/mozc
    
  2. proto 定義を取得

    wget -O config.proto https://raw.githubusercontent.com/google/mozc/master/src/protocol/config.proto
    
  3. config1.dbcfg.txt へデコード

    protoc -I. --decode=mozc.config.Config config.proto < config1.db > cfg.txt
    
  4. スペースを編集

    • group: "、。" のブロックを探し,

      - conversion_character_form: FULL_WIDTH
      + conversion_character_form: HALF_WIDTH
      
    • 同様に group: " "(全角スペース)があれば両方 HALF_WIDTH に統一

    • ない場合は下記を参照に追加:

      character_form_rules {
        group: " "       # 全角スペース(U+3000
        preedit_character_form: HALF_WIDTH
        conversion_character_form: HALF_WIDTH
      }
      
  5. 再エンコード → config1.db へ上書き

    protoc -I. --encode=mozc.config.Config config.proto < cfg.txt > config1.new \
      && mv config1.new config1.db
    
  6. Mozc 再起動

    pkill mozc_server
    ibus restart    # ログアウトでも可
    

結果

echo -n ', ' | hexdump -C

00000000  2c 20                                             |, |
00000002
  • 「、」キー → ,␠
  • 「。」キー → .␠
  • どちらも後続のスペースが ASCII U+0020(半角)になった.

まとめ

GUI設定のみでは実現することが出来ず, character_form_rules を直接書き換えることで解決した.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?