Note that there are some explanatory texts on larger screens.

plurals
  1. POPlugins usually don't work, how do I debug?
    primarykey
    data
    text
    <p>I am trying to write a plugin that will create a bitmap font. However, this is very frustrating to learn... while I am not familiar with python, it is not that hard to pick up and have not had problems with it outside of GIMP.</p> <p>Copied some of the code from: <a href="https://github.com/sole/snippets/blob/master/gimp/generate_bitmap_font/sole_generate_bitmap_font.py" rel="nofollow">https://github.com/sole/snippets/blob/master/gimp/generate_bitmap_font/sole_generate_bitmap_font.py</a> and from <a href="http://gimpbook.com/scripting/" rel="nofollow">http://gimpbook.com/scripting/</a></p> <p>Does work:</p> <pre><code>#!/usr/bin/env python # Hello World in GIMP Python from gimpfu import * def create_font(cwidth, cheight, font, size, color) : #Set GLOBAL char_begin = 32 char_end = 127 num_chars = char_end - char_begin # Figure out total width &amp; height """twidth = cwidth * 10 theight = cheight * 10 # Create Image img = gimp.Image(cwidth * 10, cheight * 10, RGB) img.disable_undo() # Save the current foreground color: pdb.gimp_context_push() # Set the text color &amp; background color gimp.set_foreground(color) gimp.set_background(0, 0, 0) # Create All Layers &amp; Position Accordingly for i in range(char_begin, char_end): string = '%c' % i offset = i - char_begin x_pos = offset * cwidth y_pos = offset * cheight text_layer = pdb.gimp_text_fontname(img, None, x_pos, y_pos, string, -1, False, size, PIXELS, font) gimp.progress_update(float(offset) / float(num_chars)) pdb.gimp_image_flatten(img) img.enable_undo() # Create a new image window gimp.Display(img) # Show the new image window gimp.displays_flush() # Restore the old foreground color: pdb.gimp_context_pop()""" register( "python_fu_bitmap_font", "Bitmap Font", "Create a new bitmap font", "*****", "*****", "2013", "Bitmap Font (Py)...", "", # Create a new image, don't work on an existing one [ (PF_SPINNER, "cwidth", "Cell Width", 24, (1, 3000, 1)), (PF_SPINNER, "cheight", "Cell Height", 51, (1, 3000, 1)), (PF_FONT, "font", "Font face", "Consolas"), (PF_SPINNER, "size", "Font size", 50, (1, 3000, 1)), (PF_COLOR, "color", "Text color", (1.0, 0.0, 0.0)) ], [], create_font, menu="&lt;Image&gt;/File/Create") main() </code></pre> <p>Does not work:</p> <pre><code>#!/usr/bin/env python # Hello World in GIMP Python from gimpfu import * def create_font(cwidth, cheight, font, size, color) : #Set GLOBAL char_begin = 32 char_end = 127 num_chars = char_end - char_begin # Figure out total width &amp; height twidth = cwidth * 10 theight = cheight * 10 # Create Image """img = gimp.Image(cwidth * 10, cheight * 10, RGB) img.disable_undo() # Save the current foreground color: pdb.gimp_context_push() # Set the text color &amp; background color gimp.set_foreground(color) gimp.set_background(0, 0, 0) # Create All Layers &amp; Position Accordingly for i in range(char_begin, char_end): string = '%c' % i offset = i - char_begin x_pos = offset * cwidth y_pos = offset * cheight text_layer = pdb.gimp_text_fontname(img, None, x_pos, y_pos, string, -1, False, size, PIXELS, font) gimp.progress_update(float(offset) / float(num_chars)) pdb.gimp_image_flatten(img) img.enable_undo() # Create a new image window gimp.Display(img) # Show the new image window gimp.displays_flush() # Restore the old foreground color: pdb.gimp_context_pop()""" register( "python_fu_bitmap_font", "Bitmap Font", "Create a new bitmap font", "*****", "*****", "2013", "Bitmap Font (Py)...", "", # Create a new image, don't work on an existing one [ (PF_SPINNER, "cwidth", "Cell Width", 24, (1, 3000, 1)), (PF_SPINNER, "cheight", "Cell Height", 51, (1, 3000, 1)), (PF_FONT, "font", "Font face", "Consolas"), (PF_SPINNER, "size", "Font size", 50, (1, 3000, 1)), (PF_COLOR, "color", "Text color", (1.0, 0.0, 0.0)) ], [], create_font, menu="&lt;Image&gt;/File/Create") main() </code></pre> <p>It seems that the after changing the beginning comment from line 15 to line 19 that everything goes to hell. And to be honest, I am not even sure how to debug this. I tried using the console under Filters>Python-Fu>Console - however this kept telling me line 1 was the issue... which I think we can all agree is not the case.</p> <p>I tried running pieces of this code in a python script and works perfectly fine.</p> <p>What should I do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload