J
JT
Hi,
Here's my problem. I am using an obscure font in my Windows Form
application, so I want to ensure that people using the application
will have the text displayed as intended. I've included the ttf font
file in my resources file and I want to write it to disk so that I can
then use PrivateFontCollection.AddFontFile(string filename) to make it
available. This seems like a horrible way to do it but I haven't
figured out another way. I would love to use the .AddMemoryFont()
method, but I'm not sure how to do that either.
So here are my questions,
1) How can I read the font file from the resources file and write it
to disk? I've tried reading it a byte at a time and writing it with a
stream writer, but I can't figure out the encoding and so the file
winds up being twice or more times the size that it should be and is
not considered a valid font file format.
2) How can I read the font file from the resources file and then load
it from memory with the AddMemoryFont(IntPtr memory, int Length).
When I try to obtain the address of either the resource or the byte
array it returns, I'm told that not only is it only possible using the
unsafe keyword, but it can't be done anyway (Compiler Error CS0208).
I don't want to have to use a setup application to place the font file
on the disk because a setup app is otherwise not necessary for the
application and I'd still like to avoid needing to write the file to
the disk.
Thanks,
JT
Here's my problem. I am using an obscure font in my Windows Form
application, so I want to ensure that people using the application
will have the text displayed as intended. I've included the ttf font
file in my resources file and I want to write it to disk so that I can
then use PrivateFontCollection.AddFontFile(string filename) to make it
available. This seems like a horrible way to do it but I haven't
figured out another way. I would love to use the .AddMemoryFont()
method, but I'm not sure how to do that either.
So here are my questions,
1) How can I read the font file from the resources file and write it
to disk? I've tried reading it a byte at a time and writing it with a
stream writer, but I can't figure out the encoding and so the file
winds up being twice or more times the size that it should be and is
not considered a valid font file format.
2) How can I read the font file from the resources file and then load
it from memory with the AddMemoryFont(IntPtr memory, int Length).
When I try to obtain the address of either the resource or the byte
array it returns, I'm told that not only is it only possible using the
unsafe keyword, but it can't be done anyway (Compiler Error CS0208).
I don't want to have to use a setup application to place the font file
on the disk because a setup app is otherwise not necessary for the
application and I'd still like to avoid needing to write the file to
the disk.
Thanks,
JT