1

When I move to different places on a line in Visual Studio, I notice that the thickness of the cursor changes. I am not referring to going into Insert mode, or changing any settings of either the operating system or VS itself.

The same variable thickness of the cursor happens if the cursor is between two whitespace characters, between whitespace and non-whitespace characters, or between multiple non-whitespace characters (such as in the middle of a variable name).

With limited investigation, it seems as though the same location in a file has the same thickness, even if the file is closed and reopened or Visual Studio is restarted.

I am currently running 2022, Version 17.6.2, but I believe this behaviour is not unique to this version.

Below are two screenshots taken from the same line of code.

thin, sharp cursor thick, fuzzy cursor

This behaviour only seems to occur in the text editor. Places like the Output window, the search pane, the Immediate window, and the Command window all display a normal sharp cursor.

If I zoom in to 380% in the editor, the cursor still appears to my eye to be slightly inconsistent, but the degree of that inconsistency is lesser.

sharp zoomed in cursor slightly fuzzy zoomed in cursor

1 Answers1

1

It appears that at some point, the text renderer in the Visual Studio editor view was changed. You can now toggle the rendering mode under OptionsText EditorAdvancedText formatting method:

visual studio options

By selecting “Display” (as visible in the screenshot) you can get pixel-adjusted rendering. The cursor will then be the same in every column (and the blue dots and characters and whatnot, too).

(These options correspond to the TextFormattingMode enum.)

Quoting from this old blog post about the difference:

Ideal – Ideal text metrics are the metrics which have been used to format text since the introduction of WPF. These metrics result in glyphs’ shapes maintaining high fidelity with their outlines from the font file. The glyphs’ final placement is not taken into account when creating glyph bitmaps or positioning the glyphs relative to each other.

Display – In this new formatting mode, WPF uses GDI compatible text metrics. This ensures that every glyph has a width of multiple whole pixels and is positioned on whole pixels. The use of GDI compatible text metrics also means that glyph sizes and line breaking is similar to GDI based frameworks. That said, glyph sizes are not the only input into the line breaking algorithm used by WPF. Even though we use the same metrics as GDI, our line breaking will not be exactly the same.

The most important part being: This ensures that every glyph has a width of multiple whole pixels and is positioned on whole pixels.


My personal opinion: Ideal rendering looks great at high PPI (think “Retina” displays). It sucks at 96 PPI.

user219095
  • 65,551