PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Enumerate Installed Fonts
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Enumerate Installed Fonts
![]() |
Enumerate Installed Fonts |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Is it possible to enumerate the installed fonts on a device using .NET
CF 2? On the desktop you can simply use the InstalledFontCollection object but this is unavailable on the Compact Framework. Thanks! j --- http://csharponphone.blogspot.com/ |
|
|
|
#2 |
|
Guest
Posts: n/a
|
On Mar 3, 9:15 am, "jonfroehlich" <jonfroehl...@gmail.com> wrote:
> Is it possible to enumerate the installed fonts on a device using .NET > CF 2? On the desktop you can simply use the InstalledFontCollection > object but this is unavailable on the Compact Framework. > > Thanks! > > j > > ---http://csharponphone.blogspot.com/ The good news is yes, it is possible. I haven't tried it myself, but I've seen mentions of how to do so. You need to make use of the native Win32 EnumFontFamilies function (documented at http://msdn2.microsoft.com/en-us/library/ms901123.aspx ). Notice that one of the parameters is a FONTENUMPROC. This is a callback function that you need to supply to EnumFontFamilies. Each time EnumFontFamilies finds a font, it calls your callback and passes in the information about the font. Under CF 1.0, it was effectively impossible to use this function, since CF 1.0 didn't support native callbacks. Happily, CF 2.0 did add that support. The trick is to create a delegate whose signature matches that of FONTENUMPROC and create a C# function that matches the delegate. Then, when you write the P/Invoke definition for EnumFontFamilies, replace FONTENUMPROC with IntPtr. Finally, use Marshal.CreateFunctionPointerForDelegate(myCallbackFunction) and pass the result to EnumFontFamilies. I dug up a couple of links that ought to help demonstrate things: In the first one, a guy was trying to do this under the desktop framework and couldn't quite get it to work. Not sure why he had problems, but it looks like most of his code is usable. That's at http://groups.google.com/group/micr...91baad463f5b9e6 .. The second link is a sample for how to use EnumFontFamilies from within VB6, available at http://vbnet.mvps.org/index.html?co...s/enumfonts.htm .. Again, I haven't actually tried this out myself, but I'm pretty sure it's correct based on what I've read. If nothing else, it oughta get you pointed in the right direction. Hope this helps! Mark Erikson http://www.isquaredsoftware.com |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

