從圖片目錄裡取得特定文字檔案

為什麼要學這個?

與使用「人工」手動去處理相比,用程式去取出想更新的文字有效率。


前置作業

Max腳本檔案下載:
https://github.com/max32002/MaxFontScripts/blob/master/copy_selected_image_out.py


使用方法

copy_selected_image_out.py --input INPUT --string STRING --output OUTPUT

參數說明:

  • --input 要處理的字體專案目錄。
  • --string 要取出的字串。
  • --output 要輸出的路徑,預設是執行指令的現行目錄下。

操作範例:

copy_selected_image_out.py --input sp --string 屠廬愈 捲楢榊榔槌

執行結果:

source folder: sp
output: output
string length: 8
length source folder: 77
length selected string: 8
length intersection: 8
copy lost glyph file to path: output
copy count: 8

說明:

  • 來源目錄: sp
  • 目的目錄: output
  • 目的字串: 8 個.
  • 在 sp 目錄, 有 77張圖片, 是以 unicode int 的方式命名.
  • 最後結果: 複製了 8個檔案

進階參數說明

  • --file 目的字串的文字檔。
  • --range 目的字元的範圍, 使用16進制, 例如: –range AC00,D7AF
  • --range_int 目的字元的範圍, 使用10進制.

常見的 range

  • 2E80 – 2EFF: CJK Radicals Supplement
  • 3400 – 4DBF: 中日韓統一表意文字擴充區A,
  • 4E00 – 9FFF: CJK Unified Ideographs,
  • AC00 — D7AF: 諺文音節 (Hangul Syllables), Hangul音節是一個Unicode塊,其中包含用於現代韓語的預先編寫的Hangul音節塊。音節可以通過算法直接映射到韓文字母Unicode塊中的兩個或三個字符的序列: U + 1100–U + 1112之一:19個現代韓文字母領先的輔音字母; U + 1161–U + 1175之一:21種現代韓文元音字母;
  • F900 – FAFF: CJK Compatibility Ideographs
  • 20000 – 2A6DF: 中日韓統一表意文字擴充區B
  • 30000 – 3134F: 中日韓統一表意文字擴展區G

相關文章: