1

I want to render some text on DrawingContext object, which should have font size, specified in pt units. For this purpose I am using FormattedText object. But this object has weird (for me) constructor:

public FormattedText(string textToFormat, CultureInfo culture, FlowDirection flowDirection, Typeface typeface, double emSize, Brush foreground);

It requires that font size should be in em units. But as far as I know, one em unit equals the current font size. How can I know that font size?

Alex Aparin
  • 4,393
  • 5
  • 25
  • 51
  • 1
    Do you want to convert pixels to em or what? See [this](http://stackoverflow.com/q/4474107/1997232). – Sinatr Aug 17 '16 at 12:44
  • Which entity has a "current font"? A `DrawingContext` object does not have a current font. – Matthew Watson Aug 17 '16 at 12:49
  • I took this definition from short and well descriptive for me article: http://kyleschaeffer.com/development/css-font-size-em-vs-px-vs-pt-vs/ – Alex Aparin Aug 17 '16 at 12:53
  • 1
    According to the help for that constructor, the em size is `The font size for the text's em measure, provided in device-independent units (1/96th inch per unit).` [See here for an example of converting from em size to points](https://msdn.microsoft.com/en-us/library/ms752098(v=vs.110).aspx). – Matthew Watson Aug 17 '16 at 12:59
  • Thanks, both articles helped me – Alex Aparin Aug 17 '16 at 13:07

0 Answers0