Post Reply 

Setting text markup from python script

Sep 16, 2014, 06:20
Post: #1
Setting text markup from python script
[Working on WinXP/Win 8, GIMP 2.8.14, Python 2.7.5 started via GIMP's menu.]

I'm using Python scripting to create a large number of GIMP images from templates. The images contain some text fields, and some words in the paragraphs of text need markup applied (e.g. bold, or colour). AFAICS, since gimp-text-layer-set-markup isn't available in the pdb, there's no way to do this. (Cf. for more context -- as I'm working on Windows, I unfortunately can't just apply the patch.)

I think I'm going to have to write my own mini text-formatting algorithm -- use GIMP to insert a word (with appropriate formatting), measure its dimensions, move a space's width to the right, insert the next word, and so on, until there's no more room for the next word, at which point you wrap a line + start again. But before implementing that I thought it was asking if there was any workaround that would just let me use markup!

thanks, Mohan
Find all posts by this user
Quote this message in a reply
Sep 16, 2014, 12:29 (This post was last modified: Sep 16, 2014 12:33 by Burbly.)
Post: #2
RE: Setting text markup from python script
Thanks for the reply. Regarding the first suggestion: Are you talking about the case where all the text fits on one line?

Let me explain what I'm trying to do, to clarify… I'm creating many cards like the two shown here, each from a line of text.


The input text (which completely specifies what the card looks like) is like this:

Veteran,X3,Skill,Skill,"When [Refreshing], you may take up to four cards.",4.

I actually need multiple fonts, to insert certain symbols into the text, as well as occasional colouring.

Imagemagick is an interesting idea. The main drawback is as follows: I often find that I have a line and a half of text. My plan was to repeatedly re-set the text with narrower and narrower widths, proceeding until The height increased, at which point I would step back one. That should give me two lines with roughly equal amount of text on. Unfortunately it's very tricky to do that via external images, at least without generating a bucketload of them.
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to modify this script-fu? Zakary81 1 31 Yesterday 12:48
Last Post: paynekj
  Loading PythonFu Plugin: ImportError for .../python/ (GIMP 2.8.22/OSX/Py2.7.9) joroek 1 126 Jul 11, 2017 07:26
Last Post: ythgilb
  Need help in running a gui script-fu via command line eyalzek 2 227 Oct 4, 2014 14:05
Last Post: eyalzek
  Color menuitems in script or plugin Barbie 4 387 Sep 29, 2014 09:51
Last Post: paynekj
  script-fu ok in gimp, not in commad line dominique 1 265 Sep 28, 2014 03:18
Last Post: dominique

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS