I need to convert a GDI Font in a WPF "Font".
myGdiFont As System.Drawing.Font
in
_Family As Windows.Media.FontFamily
_Style As Windows.FontStyle
_Weight As Windows.FontWeight
_Size As Double
In particularry, I need to Convert
_Size = myGdiFont.Size (???)
The size in WinForms font is in Units or Points... In WPF is in Pixels... How to convert from one to another?
PS.
Follwing the Clemens indications, is it correct?
Dim myDrawingFont As New System.Drawing.Font("Arial", 10)
Dim myWpfLabel As New Windows.Controls.Label
myWpfLabel.FontSize = myDrawingFont.SizeInPoints * 72 / 96
Fixed:
myWpfLabel.FontSize = myDrawingFont.SizeInPoints * 96 / 72
By multiplication. A point is 1/72th of an inch, whereas WPF device-independent units ("WPF pixels") are 1/96th of an inch.
You can verify this by specifying a WPF control's FontSize property in XAML as for example "24" and "18pt". You will realize that both values result in the same actual font size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With