Convert System.Drawing.Font.Size to WPF FontSize

I need to convert a GDI font to 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 particular, I need to convert

 _Size = myGdiFont.Size (???) 

WinForms font size is in units or dots ... In WPF it is in pixels ... How to convert from one to another?

PS.
Follwing Clementes testimony, is this right?

  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 
+4
source share
1 answer

By multiplication. The point is 1/72 of an inch, while WPF-independent devices (โ€œWPF pixelsโ€) are 1/96 of an inch.

You can verify this by specifying the FontSize WPF control in XAML, for example, as "24" and "18pt". You will realize that both values โ€‹โ€‹result in the same actual font size.

+8
source

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


All Articles