[scribus] SCRIPT : Using different Fonts in the same text frame

Gregory Pittman gpittman at iglou.com
Sat Feb 25 14:35:26 UTC 2017


On 02/25/2017 06:15 AM, Victor / tokiop wrote:
> Hi Gael,
> 
> an example to set some characters' font :
> 
> frame = "TextFrame"
> scribus.insertText("hello bold world", -1, frame)
> scribus.selectText(6, 4, frame)
> scribus.setFont("Liberation Sans Bold")
> 
> 
> to set the current paragraph's style, and create it if it
> doesn't exist :
> 
> frame = "TextFrame"
> stylename = "MyParaStyle"
> scribus.insertText("hello world", -1, frame)
> try:
> 	scribus.setStyle(stylename, frame)
> except scribus.NotFoundError:
> 	scribus.createParagraphStyle(stylename)
> 	scribus.setStyle(stylename, frame)
> 
> 
> An instructive and complete example for styling via scripts :
> https://wiki.scribus.net/canvas/Automatic_story_formatting
> 
> The full scripter api is available in :
> Scribus > Help > Scribus Manual > For Developers > Scripter API
> 
> Have fun ! :)
> 
> Victor
> 
> 
> On 25/02/2017 01:27, Gael Grissonnanche wrote:
>> Hi everyone,
>>
>>  
>>
>> I was wondering if it was possible to make a script that would use different
>> Fonts in the same text frame? I haven't found support on the web for it,
>> besides I am wondering if createParagraphe Style has this purpose, but I
>> cannot find help with that neither.
>>
>>  

The tricky part of this is that to apply text to part of the contents of
a frame, you have to select the text, which is a bit cumbersome, since
it requires specifying a starting point and ending point of your
selection. For many situations, it's going to be easier to do this by
highlighting text in Edit Contents mode, or using the Story Editor,
where you can select text or apply to a paragraph at a time.

Greg



More information about the scribus mailing list