Hi Bob!
I had tried your code and for some reason got this error…
An unhandled exeption of type ‘System.NullReferenceException’ occurred in
EmbedTTF.exe
Additional information: Object reference not set to an instance of an object.
I got the error on the Dim data line (see below) but I think the problem lay
with the previous line not picking up the Radio font properly. I think this
because I watched debug autos and it looked like the
“EmbedTTF.vb.Radio___.TTF” did not work since the fontStream was “Nothing”
after it left that line.
Yes. I added the reference for Radio___.TTF just like you show in your
example. Am I right in thinking that the culprit is the fontStream not being
loaded properly since if it’s value is “Nothing”??
Any ideas?
'load the resource
Dim fontStream As Stream =
Me.GetType().Assembly.GetManifestResourceStream("E mbedTTF.vb.RADIO___.TTF")
'create an unsafe memory block for the data
Dim data As System.IntPtr = Marshal.AllocCoTaskMem(fontStream.Length)
Bob
"Bob Powell [MVP]" wrote:
In addition to Ken's suggestion you might want to read the article on
embedding true type fonts in Windows Forms Tips and Tricks.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"BobAchgill" <Bo********@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Has anyone had success with writing text using a private font that was not
already installed to the system?
When I try the example code in NET Framework Developer's Guide called
"Creating a Private Font Collection"
... I only see a default font written to the form NOT the private font
that
was loaded. Ofcourse I see the right font written if the font is already
one
that is installed in the system. But if the private font that I load with
the AddFontFile method is one that has not been already installed in the
Windows system then the example text is written in a default font.
I am guessing this is my problem and not a bug in the Visual Basic .Net
class. Can you set me straight as to what I might be doing wrong?
Thanks!
Bob