Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows forms font weight

Tags:

c#

winforms

I want to use a thin font weight in my win forms window. The only thing I've been able to find is FontStyle, but I can only choose from Bold, Italic, Regular, Strikeout and underline. No possibility to make my font thin. Preferably, I'd like to be able to specify the font weight (100, 200 etc).

like image 490
Inrego Avatar asked Apr 25 '26 23:04

Inrego


2 Answers

I've not tried it, but looking through CreateFont function I believe it can certainly be done via P/Invoking CreateFont function.

It takes a parameter fnWeight which is font weight. Then you could call Font.FromHFont method to get the instance of Font.

like image 159
Sriram Sakthivel Avatar answered May 01 '26 04:05

Sriram Sakthivel


You will have to include a font file of a thin weight font in your deployment.

Then you can use it within your app.

This will likely cost you licensing I'm afraid. Wpf does make it easier so might be a more viable option depending on how great the need and how great the budget.

like image 40
kidshaw Avatar answered May 01 '26 02:05

kidshaw