Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, what you are looking for is <code>FormattedText</code> [MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.formattedtext.aspx" rel="nofollow noreferrer">1</a> <a href="http://msdn.microsoft.com/en-us/library/ms752098.aspx" rel="nofollow noreferrer">2</a> ] that exists in WPF and doesn't exist in WinRT (i don't even think it's even in silverlight yet).</p> <p>It will probably be included in a future version because it seems to be a very sought after feature, is sorely missed and the team is aware of it omission. See here: <a href="http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/380b4b7b-72e2-4435-b7f7-0d2afca4eac0/#db8a49dc-b252-4ffb-a128-02ed14ded2af" rel="nofollow noreferrer">http://social.msdn.microsoft.com</a>.</p> <p>If you are interested or are really, really in need of a way to measure the specifics of a type face you can try writing a wrapper for <strong>DirectWrite</strong> which to my knowledge is inside the WinRT available technology stack, however it is only accessible via C++</p> <p>here is a couple of jumping off points for you, if you want to try:</p> <ul> <li><p><a href="https://bitbucket.org/nyamatongwe/metrosci/src/5c2b93bda000/Skeen/winrt/PlatWin.cxx" rel="nofollow noreferrer">these guys seem to actually be using DirectWrite in a WinRT app</a></p></li> <li><p><a href="http://directxwinrt.codeplex.com/" rel="nofollow noreferrer">this is a wrapper for C++ making DX available, DirectWrite would be much of the same</a></p></li> </ul> <p>hope this helps, good luck -ck</p> <p><strong><em>update</em></strong></p> <p>I thought about this for a bit and remembered that <code>TextBlock</code>s have the oft forgotten property <code>BaselineOffset</code> which gives you the baseline drop from the top of the box for the selected type face! So you can use the same hack everyone is using to replace <code>MeasureString</code> to replace a loss of <code>FormattedText</code>. Here the sauce:</p> <pre><code> private double GetBaselineOffset(double size, FontFamily family = null, FontWeight? weight = null, FontStyle? style = null, FontStretch? stretch = null) { var temp = new TextBlock(); temp.FontSize = size; temp.FontFamily = family ?? temp.FontFamily; temp.FontStretch = stretch ?? temp.FontStretch; temp.FontStyle = style ?? temp.FontStyle; temp.FontWeight = weight ?? temp.FontWeight; var _size = new Size(10000, 10000); var location = new Point(0, 0); temp.Measure(_size); temp.Arrange(new Rect(location, _size)); return temp.BaselineOffset; } </code></pre> <p>and i used that to do this: <img src="https://i.stack.imgur.com/uyKuV.png" alt="screenshot"></p> <p>perfect! right? hope this helps -ck</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload