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. https://bugzilla.gnome.org/show_bug.cgi?id=724101 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 top menu Dutchy 1 579 Feb 7, 2019 12:23
Last Post: paynekj
  python-fu file_dds_save wrong number of paramters ? Thial 1 822 Jan 14, 2019 09:28
Last Post: paynekj
  How were these lines added between the text? KennethG 1 242 Dec 3, 2018 09:16
Last Post: paynekj
  Run Deskew plugin from Python-Fu console ramonvaldezz 12 3,702 Nov 18, 2018 21:48
Last Post: paynekj
  Run script on action rchav 2 1,540 Aug 13, 2018 14:57
Last Post: rchav

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS