Getting a list of available fonts in WinRT
-
Tuesday, April 10, 2012 2:37 PM
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?
All Replies
-
Tuesday, April 10, 2012 5:34 PMModerator
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
- Marked As Answer by Richard Garside Tuesday, April 10, 2012 9:55 PM
-
Tuesday, April 10, 2012 9:42 PM
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 .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#.
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.- Edited by Richard Garside Tuesday, April 10, 2012 9:46 PM More detail
-
Tuesday, April 10, 2012 9:45 PMModerator
You could pinvoke it, but it'd be easier to create a C++ WinRT component.
--Rob
-
Tuesday, April 10, 2012 9:55 PM
Thanks for the answer.
Seems like I have some more docs to read.
-
Monday, September 17, 2012 10:48 AM
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 Wille Monday, September 17, 2012 10:49 AM link


