On Wed, Mar 10, 2021, at 17:25, Gregory Pittman wrote:
> On 3/10/21 5:22 PM, Matt Miller wrote:
> > I want to use the API to replace the text of a frame with new text, but I 
> > can't empty the text out of the frame without reverting many of the frame's 
> > attributes.  The main attribute that's causing problems at this point is 
> > the font size.  For example:
> > 
> > dummy = newDocument((5, 3), (0, 0, 0, 0), PORTRAIT, 1, UNIT_INCHES, PAGE_1, 
> > 0, 1)
> > 
> > frame_1 = createText (1, 1, 1, 1)
> > 
> > setFontSize (24, frame_1)
> > 
> > 
> > 
> > deleteText (frame_1)
> > 
> > 
> > 
> > After executing the first three lines of code above and then loading (or 
> > typing) text into the frame all looks fine.  In particular, the text is 24 
> > point.  Also, I see from the "Text Properties" window that the font size 
> > shows as "24 pt."  However, after executing the "deleteText (frame_1)" call 
> > above I see from the "Text Properties" window that the font size shows as 
> > "12 pt," which is the default point size I have set for text frames in the 
> > "Document Setup" window.  Also, entering text into the frame confirms that 
> > it's now 12 pt.  (As an aside, it seems that "getFontSize()" always returns 
> > "12.0" regardless of the frame's actual font size.)
> > 
> > deleteText() is reverting other properties, too, like Paragraph Style and 
> > Character Style.
> > 
> > As a workaround it seems I can first append my new text to the end of the 
> > frame, and then select and delete the original text, which is only a few 
> > extra steps, but I didn't want to adopt that as a standard without checking 
> > first.
> > 
> 
> Hi Matt,
> 
> What's happening, I think, is that when you delete the text, the frame 
> reverts to its default font size setting.

Right.  When I use deleteText() I see now that every property that can be set 
in the "Text Properties" window reverts to what it was when I initially created 
the frame.

> I don't see why you want to 
> do that. In a script, you should be adding/replacing text, then setting 
> the font size. 

Okay.  I had been thinking that once I set some of the frame's text properties 
then those properties would stay that way until I changed them, even if I 
replaced all the text.  I can work around this.
 
> Greg
> 
> 
> ___
> Scribus Mailing List: scribus@lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>

-- 

  Matt Miller
  mailto:matt.mil...@fastmail.com

___
Scribus Mailing List: scribus@lists.scribus.net
Edit your options or unsubscribe:
http://lists.scribus.net/mailman/listinfo/scribus
See also:
http://wiki.scribus.net
http://forums.scribus.net

Reply via email to