none
Getting a list of available fonts in WinRT

    Question

  • I've searched through the WinRT API reference, but can't find how to get a list of available font families?

    Where should I be looking?

    Tuesday, April 10, 2012 2:37 PM

Answers

  • The .Net namespaces don't provide a list of available fonts, but you can enumerate the fonts with DirectWrite.  You'll probably want to encapsulate this in your own WinRT component to call from C#.

    There is sample code at http://msdn.microsoft.com/en-us/library/dd756582(v=VS.85).aspx on how to enumerate the fonts with DirectWrite.  This isn't a Metro style sample, but the enumeration code itself should be essentially the same.

    --Rob

    Tuesday, April 10, 2012 5:34 PM

All replies

  • The .Net namespaces don't provide a list of available fonts, but you can enumerate the fonts with DirectWrite.  You'll probably want to encapsulate this in your own WinRT component to call from C#.

    There is sample code at http://msdn.microsoft.com/en-us/library/dd756582(v=VS.85).aspx on how to enumerate the fonts with DirectWrite.  This isn't a Metro style sample, but the enumeration code itself should be essentially the same.

    --Rob

    Tuesday, April 10, 2012 5:34 PM
  • The .Net namespaces don't provide a list of available fonts, but you can enumerate the fonts with DirectWrite.  You'll probably want to encapsulate this in your own WinRT component to call from C#.

    Is it possible to use DirectWrite from a c# metro app, or do I need to create a separate C++ WinRT component? I can't find a way to pull DirectWrite namespaces into my app, so I'm assuming it needs to be a separate thing.

    The most likely project type I've found is 'C++ WinRT Component DLL'. Is that the only way to get this functionality in my app. If it is, I'm going to have to dust off my C++ books.
    Tuesday, April 10, 2012 9:42 PM
  • You could pinvoke it, but it'd be easier to create a C++ WinRT component.

    --Rob

    Tuesday, April 10, 2012 9:45 PM
  • Thanks for the answer.

    Seems like I have some more docs to read.

    Tuesday, April 10, 2012 9:55 PM
  • I had to list fonts too, and decided to post the respective code:

    https://github.com/christophwille/winrt-snippets

    Note that there is no C++ involved thanks to SharpDX.

    Chris


    Christoph Wille - Glengamoi Alumni - Realnamen sind ein Gebot der Höflichkeit in der Community


    • Edited by Christoph WilleMVP Monday, September 17, 2012 10:49 AM link
    • Proposed as answer by zee_patel Tuesday, January 28, 2014 9:12 AM
    Monday, September 17, 2012 10:48 AM