指定したフォントで指定した数のテキストボックスをランダムな位置に追加します。
縦書きか横書きか選べるようにしました。
テキストレイヤーが4の時はなんとなくきれいに並びます(自分が使いたかったので)。
GIMPで漫画を描いている人がいるのかはなはだ疑問だけど、自分が漫画用に使いたいので作りました。
テキストレイヤーの文字の先頭に■がついているのは選択して移動する際に面積がある文字があった方が楽に選択できるから。
インストール方法
以下をコピペしてファイル名をadd_tategaki_text_rand.pyにしてutf-8で保存後、GIMPのプラグインフォルダーに入れる。
GIMPのメニューの「レイヤー」→「add tategaki text」をクリックすると動作する。
プラグインフォルダーはGIMPを起動し「編集」→「設定」→「フォルダー」→「プラグイン」で確認の事。
初回のフォント指定(MSゴシック)を変更するにはプラグイン下の方の行の"MS Gothic"のところを好きなフォント名に書き換えればよい。
フォント名はGIMPでテキストボックスを選択してツールオプションの好みのフォントを設定する時の名前をコピペすればよい。
#!/usr/bin/python # -*- coding: utf-8 -*- import random from gimpfu import * def tategaki_text_rand(text_number , font , font_size , tategaki): #一番下のレイヤーの情報取得 image = gimp.image_list()[0] if text_number == 4: new_left_up_x_4 = [image.width / 8 , image.width / 8 , 5 * image.width / 8 , 5 * image.width / 8] new_left_up_y_4 = [image.height / 8 , 5 * image.height / 8 , image.height / 8 , 5 * image.height / 8] for i in range(text_number): #テキストレイヤーを追加する text = unicode("■テキストレイヤー" , "utf-8") text_layer = pdb.gimp_text_layer_new(image, text, font, font_size, 0) # #テキストレイヤーの位置指定 if text_number == 4: new_left_up_x = new_left_up_x_4[i] new_left_up_y = new_left_up_y_4[i] else: new_left_up_x = random.randint(image.width / 4, 3 * image.width / 4) new_left_up_y = random.randint(image.height / 4 , 3 * image.height / 4) text_layer.set_offsets(new_left_up_x, new_left_up_y) # #新規作成したテキストレイヤーを有効にする image.add_layer(text_layer) # #テキストレイヤーを縦書きにする。横書きにしたければ末尾の2を0にすること。 if tategaki == True: pdb.gimp_text_layer_set_base_direction(text_layer,2) else: pdb.gimp_text_layer_set_base_direction(text_layer,0) #テキストレイヤーのサイズを変更する text_layer_height = image.height / 4 text_layer_width = image.width / 6 pdb.gimp_text_layer_resize(text_layer, text_layer_width, text_layer_height) # register( "add_tategaki_text", "add tategaki text", "add tategaki text", "katsumi", "katsumi", "2022", "add tategaki text", "", [ (PF_INT, "text_number", "テキストレイヤー数", 4), #源暎アンチックを使いたい人はフォントをインストール後に #"MS Gothic"のところを"GenEi Antique Pv5 Medium"に書き換える (PF_FONT, "font", "フォント", "MS Gothic"), (PF_INT, "font_size", "フォントサイズ", 20), (PF_BOOL , "tategaki", "縦書きにする", True), ], [], tategaki_text_rand, menu = "<Image>/Layer" ) main()