Width of spaces

SyntaxEditor for WPF Forum

Posted 8 years ago by Martin - Blaise - Statistics Netherlands
Version: 16.1.0632
Avatar

Hi

 

For some reason it looks like spaces are not in the same width displayed as normal characters. This way the documents look a little messy.

In our application we have an option to choose fonts type and font size, so the fonts are set manually. Default is Consolas which has the same problem.

            this.FontFamily = family;
            this.FontSize = size;

All the fonts the user can select are monospaced. Should i refresh something, in short do you know what is the problem?

Thanks in advanced,

Martin

Comments (5)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Martin,

That shouldn't be happening on a monospace font and we haven't seen it happen.  Are you able to repro this in our own samples and are you on our latest version/build?  If you can't repro it in our samples, please make a new simple sample project that shows the issue and email that to our support address.  In your email, reference this thread and be sure to rename the .zip file extension of what you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 8 years ago by Martin - Blaise - Statistics Netherlands
Avatar

Hmm,

        protected void SetFont(System.Windows.Media.FontFamily family, double size) {
            this.FontFamily = family;
            this.FontSize = size;
            this.LineNumberMarginFontSize = Math.Max(6, Math.Min(20, Base.Properties.IDE.Default.EditorFontSize));
            //foreach (IHighlightingStyle hls in AmbientHighlightingStyleRegistry.Instance.HighlightingStyles) {
            //    hls.FontSize = this.FontSize;
            //}
        }

 is better with the ambient registry changing commented out. It seems setting the fontsizes in the Ambient Registry is not the best thing to do.

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Martin,

I tried this code and it's working fine for me, either way.  Could you tell us exactly how to modify one of our samples to see the problem occur?  Thanks!


Actipro Software Support

Posted 6 years ago by Reinhard Gruber
Avatar

Hi,

we ran into a similar problem that the spaces did not match the text when changing font size. I want to share our solution in case someone else is searching here:

We changed the fonts via ClassificationTypeProvider. So we iterated all registered ClassificationProviders and re-registered with the updated IHighlightingStyle. We used a custom language created by geneating code with the LangugageDesigner. We took one of the free langugages (pascal) and extended it to our needs.

The pitfall then was, that in the langugage definition every token had a ClassifictationType assigned, but only WhiteSpace and LineTermination did have null as ClassificationType. And therefore none of the changes in font of the registered IHighlightingStyles applied to the spaces.

The solution was to add a new ClassificationType in the language, assign the Whitespace and LineTermination to this ClassificationType and then when updating the font/fontsize this new ClassificationType has been updated too and everything worked fine.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you are using the highlighting style registry to set the editor font family/size, you only need to set them for the Plain Text classification type.  That will inherit to everything else if you leave the others as their defaults.

So for instance, this code will ensure that the entire editor (including spaces) is sized to a large new font:

var plainText = new DisplayItemClassificationTypeProvider().PlainText;
AmbientHighlightingStyleRegistry.Instance[plainText].FontFamilyName = "Calibri";
AmbientHighlightingStyleRegistry.Instance[plainText].FontSize = 100;


Actipro Software Support

The latest build of this product (v24.1.3) was released 29 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.