2

我有一个从 xml 获取文本的文本字段。我添加了一个用于更改所选文本字体大小的功能,并且在我再次加载文本之前它工作正常。然后它只是忽略除第一个之外的所有其他尺寸。

这是 tekst 的 html 文本:

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="PresentationOnline_text" SIZE="63" COLOR="#FF9999" LETTERSPACING="0" KERNING="0">a<FONT SIZE="33">b</FONT></FONT></P></TEXTFORMAT>

我只是将 txtText.htmlText 设置为那个。一个文本字段中不可能有多种字体大小吗?

当我改变尺寸时,我这样做:

textFormat = txtText.getTextFormat(start, end);
textFormat.size = Number(textFormat.size) - 1;
txtText.setTextFormat(textFormat, start, end);

有什么我想念的吗?

谢谢!

编辑

当我按以下顺序执行时有效:

txtText.defaultTextFormat = textFormat;
txtText.setTextFormat(textFormat);
txtText.htmlText = text;

但我知道我是出于某种我记不起的好理由反其道而行之。

4

1 回答 1

1

I added a function for changing font size for a selected text and it works fine until I load the text again.

setTextFormat() affects the format of the text that is already there. Any text inserted after setTextFormat() has beed applied, either manually, or by using replaceSelectedText(), will be formatted with the default text format of the textfield.

To set the default text format of the textfield, you must use defaultTextFormat property, which is read/write.

Does this info help?

于 2010-11-24T17:28:23.913 回答