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 script to conversion pdf to image 4ever 12 4,470 Jul 17, 2018 16:01
Last Post: paynekj
  Problems with a bat script :( ThaUnknown_ 1 379 Mar 26, 2018 21:14
Last Post: paynekj
  Script-fu ordered file list vnicent 1 220 Mar 19, 2018 17:33
Last Post: paynekj
  script-fu argument/parameter formats dhugg 2 357 Mar 13, 2018 00:50
Last Post: dhugg
  Request for script chlebna 1 522 Sep 13, 2017 09:35
Last Post: ythgilb

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS