How can I specify letter spacing or kerning, in a WPF TextBox?

前端 未结 3 631
既然无缘
既然无缘 2020-12-05 11:07

I\'d like to modify the spacing between characters in a WPF TextBox.
Something like the letter-spacing: 5px thing that is available in CSS.
I think it i

3条回答
  •  独厮守ぢ
    2020-12-05 11:51

    For what its worth . . .

    If you have the option to switch your implementation to RichTextBox, this might be easier than the work-around you found Sept 2013. I just tried it for my own needs and it works for what I need. I do not see a way with RichTextBox to control kerning of individual spaces like typesetters do. But TextBox was eating additional spaces (consolidating multiple adjacent spaces to a single space) like HTML. I needed for the spaces to display the same amount of spacing as is in my text String, and RichTextBox does this.

    
    

    I'm no expert, but it seems you can't specify the text content in XAML. I had to specify it in a code-behind event:

    this.MyRichTextBox.AppendText("V A R I E D      S P A C E S");
    

提交回复
热议问题