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
  script-fu argument/parameter formats dhugg 2 165 Mar 13, 2018 00:50
Last Post: dhugg
  Request for script chlebna 1 335 Sep 13, 2017 09:35
Last Post: ythgilb
  Request for script - Guillotine + Watermark sunslick 1 417 Sep 4, 2017 08:51
Last Post: ythgilb
  Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer Bertholomäus 1 462 Aug 31, 2017 14:32
Last Post: Bertholomäus
  How to modify this script-fu? Zakary81 1 366 Aug 23, 2017 12:48
Last Post: paynekj

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS