Thursday, April 14, 2011

WPF analogy for 'em' unit

What is the WPF analogy for the CSS em unit?

From stackoverflow
  • AFAIK, there isn't one right now. But you can make your desire for this known here.

    One alternative (and I don't know if this is possible either) would be to measure how big the desired font is, then take that as your "ems" unit, then scale using those "units" instead.

  • <ScaleTransform ScaleX="1.2" ScaleY="1.2"></ScaleTransform>
    

    seems to be more or less the 1.2em alternative.

  • Unfortunately, there is no equivalent in WPF of the em unit. All your font sizes, etc are always set in Pixels.

  • em size is the width of the uppercase letter M in the current font, there is no font-dependent sizing method in Wpf

    Btw, WPF uses "device independent pixels" that are always 1/96 of an inch (because that's one pixels on today's monitors) so:

    • 1 pixel is 1/96 inches
    • 96 pixels in an inch
    • 1.33333 pixels is a point
    • 3.779 pixels is a mm

    Those are extremely inaccurate on monitors because almost all monitors report a 96DPI resolution and ignore the real pixel size, but are very useful when printing.

0 comments:

Post a Comment