graphics alternative to GDI+ in c#?

  • Thread starter Thread starter Tarren
  • Start date Start date
T

Tarren

Hi:

I need to render text graphics using custome font.

I am running into issues where PrivateFontCollection will hang sometimes
when I instantiate it.

PrivateFontCollection fc = new PrivateFontCollection();

The annoying part is that it hangs IIS, but does not through any error so
there is nothing to try / catch.

Any thoughts?

Are there 3rd party libraries available to render text to graphics using my
own provided ttfs?

Thanks
 
What on earth do fonts have to do with IIS?

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
 
This sounds vaguely to me as if you may be attempting to do something that is
windows-forms specific in a web application, and that could be the cause of
your issue.
Peter
 
Just in support of the OP; Kevin and Peter seem to imply that it would
be unreasonable to do anything with GDI in a web app; to me it seems
perfectly reasonable to be e.g. creating real-time graphics (e.g. a
charting app) and then (for instance) streaming the image to the
client. I have no idea why PrivateFontCollection may cause
difficulties; it is in the System.Drawing assembly (and namespace), so
it should be completely independent of Forms code.

My advice would probably be look at the System.Drawing assembly via
Roeder's Reflector (perhaps with the FileDisassembler plugin), to see
exactly what this class does at the point when it hangs (the default
ctor?). It may be trying to access some random mutex, registry, file
system, or something freaky.

http://www.aisto.com/roeder/dotnet/

Marc
 
| Just in support of the OP; Kevin and Peter seem to imply that it would
| be unreasonable to do anything with GDI in a web app; to me it seems
| perfectly reasonable to be e.g. creating real-time graphics (e.g. a
| charting app) and then (for instance) streaming the image to the
| client. I have no idea why PrivateFontCollection may cause
| difficulties; it is in the System.Drawing assembly (and namespace), so
| it should be completely independent of Forms code.
|
| My advice would probably be look at the System.Drawing assembly via
| Roeder's Reflector (perhaps with the FileDisassembler plugin), to see
| exactly what this class does at the point when it hangs (the default
| ctor?). It may be trying to access some random mutex, registry, file
| system, or something freaky.
|
| http://www.aisto.com/roeder/dotnet/
|
| Marc

Marc , IMO its' best to start reading the documentation on this namespace
http://msdn2.microsoft.com/en-us/library/system.drawing.aspx (see :
caution)before you dive into this, The System.Drawing class is not supported
in service based applications like ASP.NET for the simple reason that it
encapsulates GDI/GDI+ and as such, uses Window handles (HWND), these handles
have thread affinity which is really hard to get right in a multi-threaded
environment like ASP.NET, where you are (mostly) out-of-control of the
threads your code is running on.
There are other problems to expect when using this namespace in a service,
(depending on the class), without going into these, it should be clear that
GDI/GDI+ wasn't designed to be used in a service application, reason enough
to stay away from it.

Willy.
 
Marc,
Not really, I've used GDI+ to create stock charts for display on web pages.
What I meant was that I got the sense that the OP may have been attempting to
do something windows forms specific that might not be possible in an Page
class lifecycle. But since we haven't any sample code to go on, we can only
guess.
Peter
 
Thank you Willy; a clear answer with good supporting documentation. I
have learned something, and I happily concede that you are entirely
right. Apologies to all for my adding confusion.

Marc
 
Back
Top