Re: Resource availability: fonts

2009-05-06 Thread Lars T. Kyllingstad

grauzone wrote:

Use
ubyte[] fontbytes = cast(ubyte[])import(yourfont.ttf);


That is so cool.

I've seen the import() expression mentioned here on the NG before. It 
returns a string containing the imported source file, right? Is it 
mentioned anywhere in the docs? I can't seem to find it.


-Lars


Re: Resource availability: fonts

2009-05-06 Thread grauzone

http://digitalmars.com/d/1.0/expression.html#ImportExpression

It returns a char[], which is a misdesign, because the loaded file can 
be binary data as well. I think.


Re: Resource availability: fonts

2009-05-06 Thread Tyro[a.c.edwards]

On 5/6/2009 1:39 PM, grauzone wrote:

Use
ubyte[] fontbytes = cast(ubyte[])import(yourfont.ttf);


This will take care of making sure the font is available. How do you 
instruct the library (DFL in this case) that this variable contains the 
font or that after you write it back to the hard drive to refer to the 
file? A font that is not installed, but instead, simply residing in a 
folder of your choosing?


Re: Resource availability: fonts

2009-05-06 Thread John C
Tyro[a.c.edwards] Wrote:

 When I do this, how do I ensure that the program is able to locate the 
 font after extraction without installing it?
 

I think AddFontResource from the SDK will do that. 
http://msdn.microsoft.com/en-us/library/dd183326(VS.85).aspx


Re: Resource availability: fonts

2009-05-06 Thread Tyro[a.c.edwards]

On 5/6/2009 9:50 PM, John C wrote:

Tyro[a.c.edwards] Wrote:


When I do this, how do I ensure that the program is able to locate the
font after extraction without installing it?



I think AddFontResource from the SDK will do that. 
http://msdn.microsoft.com/en-us/library/dd183326(VS.85).aspx


That was it... Aswesome! Thank you all very much for your assistance.


Re: Resource availability: fonts

2009-05-05 Thread Daniel Keep


Tyro[a.c.edwards] wrote:
 One cannot necessarily rely on particular font being available on a system, 
 and for security reasons asminsistrators restrict instalation of fonts (among 
 other things) onto systems in a network. I would like to know if it is 
 possible to embed a font into my code so that I know that it will always be 
 there, or can I provide it with the exe but not have to rely on it being 
 installed (i.e. use it from the same folder in which the exe resides)? 
 
 Thanks,
 Andrew

That depends.  What are you using the font for?

If you're using a library that requires a family name, then probably
not.  If you're using a library that can accept a file name, then
probably yes.

Remember that the system doesn't care if you append crap to the end of
an executable.  One trick you can use is to just append whatever files
you want to the end of the executable, and then have a little 1K block
at the end that tells you where the files are and how big they are; you
can then extract the files at run time and delete them when you terminate.


  -- Daniel


Re: Resource availability: fonts

2009-05-05 Thread grauzone

Use
ubyte[] fontbytes = cast(ubyte[])import(yourfont.ttf);