Differing char spacing in a WPF RichTextBox

我们两清 提交于 2019-12-11 06:32:48

问题


I have a custom control I have made. It extends a RichTextBox.

I have code that sets the width of the Document so that the number of chars is limited. (I am using Courier New, so I have a fixed width font.)

This all works fine.

But once I put the control in my application, the limit starts failing. After comparing the two, I noted that the spacing between my test application and my real application is different.

Here is an example:

As you can see my spacing for the Test App is larger than the spacing for the Real App.

I don't have any any spacing, kerning, typography or gliph settings (that I can find) in either app. Also, I have checked every setting starting with "Font" (FontSpacing, FontSize...) they are all exactly the same.

What else could cause the text to apply different spacing in one app as opposed to another?

NOTE:

In case it is relevant, the xaml that inserts the control into my test app is the same as the xaml that inserts the control into my real app. I will post it if someone wants to see it.


回答1:


It probably has to do with the differences between the Ideal and Display TextFormatting Modes. See this SO Question for a good explanation from Hans.



来源:https://stackoverflow.com/questions/14512687/differing-char-spacing-in-a-wpf-richtextbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!