Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-28-2007, 01:25 AM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default font trouble

hello....
i'm using swfkit pro 3.1 to convert my swfs to exes but i'm having trouble with font setting on the app...
i was trying to put my own custom fonts on the exe but it doesnt seems to load if the remote computer doesnt have the fonts installed in their systems...
i already tried to include the fonts under the Windows --> Fonts (inside swfkit) but the fonts doesnt seems to load....
is there any solution to this maybe a script or something....

thanks
Reply With Quote
  #2 (permalink)  
Old 12-28-2007, 08:04 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: font trouble

The files under "Windows" only work for installers. That is, the files are only packed into the installers. However, there is a way to load a font at runtime so that you need not an installer:

1. in the "initialize" script load the font
2. in the "initialize" script handle the onClose method of the main window to remove the font

Code:
dllimport "gdi32.dll" stdcall int AddFontResourceA(String) as AddFontResource;
dllimport "gdi32.dll" stdcall int RemoveFontResourceA(String) as RemoveFontResource;

trace(AddFontResource);
trace(RemoveFontResource);

var fontfile = "c:\\myfont.ttf";
AddFontResource(fontfile);

getMainWnd().onClose() = function () {
	RemoveFontResource(fontfile);
}
See also: http://www.devx.com/tips/Tip/14736
Reply With Quote
  #3 (permalink)  
Old 12-28-2007, 10:50 AM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default Re: font trouble

thanks but can i embed the font inside the exe?? not using the external var as "c:\\myfont.ttf"...
and also how to embed 2 fonts with that method??

thanks
Reply With Quote
  #4 (permalink)  
Old 12-28-2007, 12:42 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: font trouble

Sure, add the font files into the "Resources" panel. In the "initialize" script to copy them into the temporary folder

Code:
var fonts = ["font1.ttf", "font2.ttf", "font3.ttf"];

for (var i = 0; i < fonts.length; i++) {
	var src = getAdditionalFile(fonts[i]);
	var dest = Shell.getSpecialFolder("temp") + "\\" + fonts[i];
	
	(new File(src)).copy(dest);
	
	AddFontResource(dest);
}

getMainWnd().onClose() = function () {
	for (var i = 0; i < fonts.length; i++) {
		var dest = Shell.getSpecialFolder("temp") + "\\" + fonts[i];
		RemoveFontResource(dest);
	}
}
Reply With Quote
  #5 (permalink)  
Old 12-28-2007, 04:57 PM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default Re: font trouble

it doesnt work...can you tell me where have i done wrong

in the resource panel
[img width=700 height=189]http://h1.ripway.com/ptemondous/swf/resource.JPG[/img]

and in the initialize script
[img width=700 height=370]http://h1.ripway.com/ptemondous/swf/script.JPG[/img]
Reply With Quote
  #6 (permalink)  
Old 12-28-2007, 08:34 PM
Member
 
Join Date: May 2004
Posts: 78
Default Re: font trouble

Just as another thought - do you need to embed the font on the user's own computer? How about embedding the font within Flash itself - when the swf is converted to an .exe by SWFKit that font will be fully available in your application.
__________________
:)
Reply With Quote
  #7 (permalink)  
Old 12-28-2007, 08:42 PM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default Re: font trouble

there's some unicode characters that neede to be displayed correctly...

can you teach me how to do that??
Reply With Quote
  #8 (permalink)  
Old 12-28-2007, 09:34 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: font trouble

the code should be

Code:
getAdditionalFile();

dllimport "gdi32.dll" stdcall int AddFontResourceA(String) as AddFontResource;
dllimport "gdi32.dll" stdcall int RemoveFontResourceA(String) as RemoveFontResource;

var fonts = ["CODE2000.ttf", "BLEEDING_COWBOYS.ttf", "ALBUM-AVANTQUELOMBRE.ttf"];

for (var i = 0; i < fonts.length; i++) {
	var src = getAdditionalFile(fonts[i]);
	var dest = Shell.getSpecialFolder("temp") + "\\" + fonts[i];
	
	(new File(src)).copy(dest);
	
	AddFontResource(dest);
}

getMainWnd().onClose() = function () {
	for (var i = 0; i < fonts.length; i++) {
		var dest = Shell.getSpecialFolder("temp") + "\\" + fonts[i];
		RemoveFontResource(dest);
	}
}

return true;
and please make sure that you are using swfkit pro. Don't put code after the return clause, which means the end of a script.
Reply With Quote
  #9 (permalink)  
Old 12-28-2007, 10:42 PM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default Re: font trouble

;D ;D ;D ;D ;D ;D it worked...thanks for the help.... : :
Reply With Quote
  #10 (permalink)  
Old 12-29-2007, 02:24 PM
Junior Member
 
Join Date: Dec 2007
Posts: 10
Default Re: font trouble

i found another problem.....after a certain launch the fonts not showing on the swf...is there any way to fix this issue??? cos i was just about to publish my exe but got delayed because of this....

thanks
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:44 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.