How to make text / labels smooth?

Does anyone know how to make labels or text smoother? At the moment they look pretty jagged. Since I want to make the shortcut dynamic, I cannot just paste text from Photoshop.

+4
source share
3 answers

You will need to dynamically generate images representing your text if you want to smooth it. Here is an example in msdn: http://msdn.microsoft.com/en-us/library/a619zh6z.aspx

EDIT: Editing for the comment below.

The link describes the use of the OnPaint event of your control to use another TextRenderingHint. If you want something even more reusable, then you can create a custom label class that extends the Label class and uses it in your forms:

public partial class CustomLabel : Label { private TextRenderingHint _hint = TextRenderingHint.SystemDefault; public TextRenderingHint TextRenderingHint { get { return this._hint; } set { this._hint = value; } } protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.TextRenderingHint = TextRenderingHint; base.OnPaint(pe); } } 

Add a new custom control called CustomLabel (or whatever you want to name) and use the code above. Rebuild your project and you should see how the CustomLabel control appears in the toolbar at the top, under the "MyProject Components" section. In the properties panel of this custom shortcut, you will see the new TextRenderingHint property. Set this to "AntiAlias". Add another tag to your form and compare how they look.

If you want to use AntiAlias ​​by default, just change the default value for the private variable.

+14
source

Do you mean ClearType? Then ClearType should be enabled on Windows, and you should use a modern font such as Tahoma or Segoe UI, not MS Sans Serif.

Update

You sent an example of a problem. I increased it to 400% . ClearType subpixel anti-aliasing is clear. Personally, I don’t think the text looks jagged. If you want to get better text on the screen, you can buy a screen with a higher physical resolution (pixels per inch), and then draw the text in size (respectively) of a larger size. Then the text will have the same size on your screen, but it will look much smoother.

You can also refuse ClearType and use a different font smoothing algorithm, but this is far from trivial, because ClearType is a font smoothing system in Windows.

Update 2

If you are using Windows 7, you can fine tune ClearType. Just open the Start menu, write “ClearType” and start the manual. I think there are manuals for Vista and XP too, but may not be installed by default, but available as PowerToys or something like that ...

+5
source

Make sure ClearType is enabled.

0
source

Source: https://habr.com/ru/post/1306497/


All Articles