TextAreaRTF Change text attributes

Hi,
I have an RTF TextArea named textpagina, and I am able to load an RTF file with various text attributes: (such as color, normal, bold, italic, and underlined) using the following code:

Dim tis as TextInputStream
Dim d As OpenDialog
d = New OpenDialog
d.Filter = (DemoFiletypes.FTC_RTF )
fi= d.ShowModal
If fi <> Nil Then
tis= TextInputStream.Open(fi)
textpagina.StyledText.RTFData = tis.ReadAll
tis.Close

If I try to change the font size or name

(for example:
textpagina.FontSize = 10
textpagina.FontName = “Arial”)
the text retains only the color and loses all other attributes.
How can I fix this?

Are these attributes known by Xojo ?
a.k.a: can you modify these in Xojo ?

If no, these atrtibutes are not supported even if you can see these when charging an rtf file; I am quite sure they are lost at save rtf file time….

Bonjour,

You have to use textpagina.StyledText.Size and textpagina.StyledText.FontName.

See the doc of StyledText.

I copied a bunch of text from Firefox with colors, links, etc. (Style bold and I do not know what).

I pasted that in a TextArea (small height, not meant to do that).

The styles seems to be there (bold, yellow, …) and even the links are there, and worked fine.

But the StyleRun in the Documentation does not have entries for links (as an example).

StyleRun in the documentation.

There is a way to add features in Xojo with Declare (seach in the xojo site for DeclareSub (I think it is its name).
I used it long time ago. With time I lost the idea to use the TextArea RTF styles.

I’ve had good results setting attributes using

myDesktopTextArea.SelectionStart = vStart
myDesktopTextArea.SelectionLength = vLen
myDesktopTextArea.SelectionFontSize = vSize

Eric Pousse Thank you very much; by checking the StyledText, as you had advised me, I solved it this way:

testo=textpagina.text
textpagina.StyledText.Size(1,testo.Length)=10

Keith Culotta Thanks to you too; I didn’t try your method, but I think it would work.