简体   繁体   English

如何在WPF RichTextBox中设置字距间距?

[英]How to set Kerning Character Spacing in WPF RichTextBox?

I cannot find how to set horizontal character spacing in a RichTextBox. 我找不到如何在RichTextBox中设置水平字符间距。

Hello, World! H ello , W orld !


I can only set vertical Line Height using C#. 我只能使用C#设置垂直线高。

Paragraph p = new Paragraph();
p.LineHeight = 50;

rtb1.Document = new FlowDocument(p);

p.Inlines.Add(new Run("Hello, World!"));

And outer margin with XAML. XAML的外部优势。

<RichTextBox x:Name="rtb1" 
       HorizontalAlignment="Left"
       Height="600"
       Width="300" 
       Margin="188,61,0,0" 
       VerticalAlignment="Top">
     <RichTextBox.Resources>
         <Style TargetType="{x:Type Paragraph}">
             <Setter Property="Margin" Value="50"/>
         </Style>
     </RichTextBox.Resources>
 </RichTextBox>

The most common options you have are: 您最常用的选项是:

but here on SO a user found a nice (although potentially performance intensive) alternative to both (read the accepted answer): 但是在这里,用户发现了两者的不错选择(尽管可能会提高性能)(请阅读公认的答案):

How can I specify letter spacing or kerning, in a WPF TextBox? 如何在WPF文本框中指定字母间距或字距调整?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM