也没有FormattedTextOptions类型
时间: 2024-03-03 13:53:12 浏览: 15
非常抱歉,我的回答还是有误。在.NET 6中,确实没有FormattedTextOptions类。您可以直接在FormattedText构造函数中设置TypographyProperties属性来设置字符间距。以下是一个示例:
```csharp
FormattedText formattedText = new FormattedText(
"Hello, world!",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface("Arial"),
12,
Brushes.Black,
new TextFormatter(new TextParagraphProperties(), new TextRunProperties() { Typography = new Typography() { Variants = FontVariants.Superscript } }));
formattedText.SetFontSize(18);
formattedText.SetForegroundBrush(Brushes.Red);
// 设置字符间距
formattedText.SetTypographyProperties(new TypographyProperties() { CharacterSpacing = 2 });
// 绘制 formattedText 对象
```
请注意,您仍然需要使用TextFormatter类来创建FormattedText对象,并使用TextRunProperties类来设置其他属性,例如字体变体。TypographyProperties属性的类型是TypographyProperties,它表示字符间距和其他排版属性。在上面的示例中,我们使用了SetTypographyProperties方法来设置字符间距。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)