has someone an idea how to use .ttf fonts from the resource section?
also i can't add .ttf fonts under FONT in the resource. i have to add it as RCDATA else the resource linker didn't compile.

102 FONT "xxxxxx.ttf"
this one didn't work!

Posted on 2002-03-29 07:04:14 by adapix
Sorry, but it does work :grin:

Here is a working solution... But there is one drawback that I spent some time reseaching on: You *have* to write the truetype file back to disk at one point to install it properly. There is a cool api that would get around this, but its only available to window NT/2000/XP...

The only *adding* api's require a *file path*, not a handle, to the font being temporarily loaded. The api's also talk about haveing to place this ttf file ONLY in the windows system directory to work, but i found this to be wrong on windows 98SE. I can temporarily save this font file in the local directory the EXE is found in and still work fine! However, since Microsoft doesnt feel this is correct it may not work on all platforms if you do choose to use the local directory over the system directory.

Anyways, if you unpack into window/system, its more likely people wont look there for it (rather look at windows/temp ).

Last thought on this is the unpacked fill *MUST* remain undeleted while the font is in use (ie, while the program is still running). This means if you run this program, then load Word 97, you can select the "Joy Circuit" font for use ~ as windows realizes its part of its system at that moment. There is a way to make fonts private and not recognizable, but i didnt dig that deep... (Requires some hearer or somthing)...

Anywho there it is, thanx for the problem ~ I enjoyed hacking at it...

Posted on 2002-03-29 23:14:27 by NaN
hey nan nice work. you saved me some time. i wanted to use some ttf font in one of my future apps.
Posted on 2002-03-30 00:20:05 by smurf
Same, its something i knew i would need to fuss with sooner or later, and since adapix was asking, i felt compelled to procrastinate some more (trying to write up my 4th year technical report on robotics ~ i hate writing in engish, ASM is far better ;) )

Posted on 2002-03-30 00:37:56 by NaN
nan did it again!

big thanks nan it works. keeping the font unrecognizable would be great so i will look at this problem and if i found a way i will tell you.
i thought there is a way to use it direct from the resource but it seems that writing the file back to disk is the only way to implement it in an aplication.
saving the file in the local directory works also on winXP maybe it doesnt work on NT/2K platforms. i have to test it!

thanks :alright:
Posted on 2002-03-30 03:31:46 by adapix
Ya... you might be able to do this on XP. The API that looked like the one to use was AddFontMemResourceEx.

Found Here. Unfortunately, its only available for XP/2000/NT.

As for the 9x tradeoff, the way i have it written is if you chose to place it in WINDOWS/SYSTEM, users wont know its there unless they know to look there for it.. (and the dir itself is quite cluttered as is! If you name it something crazy in there, they will have a poor chance of seeing it ~~ Unless your f0dder ;) ) When the program quits, it simply cleans it up outa there and all is well, effectively you've hidden your font.

Best of luck!
Posted on 2002-03-30 03:49:58 by NaN
this 'AddFontMemResourceEx' is realy the api i was looking for. so i can first check which system is running and if 9x is running i do it your way else i can use the api.
Posted on 2002-03-31 02:26:09 by adapix
Ya its too bad you have to do this... :rolleyes:

Posted on 2002-03-31 03:02:41 by NaN