/usr/lib/gimp/2.0/plug-ins/text-brush.py is in gimp 2.8.10-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/usr/bin/env python
# coding: utf-8
# Author: João Sebastião de Oliveira Bueno
# Copyright: João S. O. Bueno (2009), licensed under the GPL v 3.0
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gimpfu import *
import os
gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
def text_brush(font_name, font_size, text):
pdb.gimp_context_push()
pdb.gimp_context_set_default_colors()
font_size_int = int(font_size)
padding = font_size_int // 4
img = gimp.Image(font_size_int + padding, font_size_int + padding, GRAY)
img.undo_freeze()
text = text.decode("utf-8")
for letter in reversed(text):
layer = img.new_layer(fill_mode=BACKGROUND_FILL)
text_floating_sel = \
pdb.gimp_text_fontname(img, layer,
padding // 2,
padding // 2,
letter.encode("utf-8"),
0,
True,
font_size,
PIXELS,
font_name)
if text_floating_sel:
#whitespace don't generate a floating sel.
pdb.gimp_edit_bucket_fill(text_floating_sel,
FG_BUCKET_FILL,
NORMAL_MODE, 100, 1.0,
False,0 ,0)
pdb.gimp_floating_sel_anchor(text_floating_sel)
file_name = text.lower().replace(" ", "_") + ".gih"
file_path = os.path.join(gimp.directory, 'brushes', file_name)
pdb.file_gih_save(img, img.layers[0],
file_path, file_path,
100, #spacing
text, #description,
img.width, img.height,
1, 1,
1, #dimension
[len(text)], #rank - number of cells
1, # dimension again - actual size for the
# array of the selection mode
["incremental"])
pdb.gimp_brushes_refresh()
pdb.gimp_image_delete(img)
pdb.gimp_context_pop()
register(
"brush-from-text",
N_("Create a new brush with characters from a text sequence"),
"""New dynamic brush where each cell is a character from
the input text in the chosen font """,
"Joao S. O. Bueno",
"Copyright Joao S.O. Bueno 2009. GPL v3.0",
"2009",
N_("New Brush from _Text..."),
"",
[
(PF_FONT, "font", _("Font"), "Sans"),
(PF_SPINNER, "size", _("Pixel Size"), 50, (1, 8000, 1)),
(PF_STRING, "text", _("Text"), "GNU Image Manipulation Program")
],
[],
text_brush,
menu="<Image>/File/Create",
domain=("gimp20-python", gimp.locale_directory)
)
main()
|