PC Review


Reply
Thread Tools Rate Thread

Enumerate Installed Fonts

 
 
jonfroehlich
Guest
Posts: n/a
 
      3rd Mar 2007
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/

 
Reply With Quote
 
 
 
 
Mark Erikson
Guest
Posts: n/a
 
      3rd Mar 2007
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/micro...1baad463f5b9e6
..

The second link is a sample for how to use EnumFontFamilies from
within VB6, available at http://vbnet.mvps.org/index.html?cod.../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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I enumerate all installed frameworks ... AA2e72E Microsoft C# .NET 4 4th Jun 2010 01:26 PM
How to enumerate Fonts in WM5.0 ... Tery Microsoft Dot NET Compact Framework 0 9th Aug 2006 12:50 AM
Re: Enumerate Installed Software Sergey Bogdanov Microsoft Dot NET Compact Framework 2 23rd Jul 2005 07:13 PM
Enumerate Installed Software Miguel Sanders Microsoft Dot NET Compact Framework 0 22nd Jul 2005 10:51 AM
Re: Enumerate Fonts Paul G. Tobey [eMVP] Microsoft Dot NET Compact Framework 0 8th Sep 2003 05:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 PM.