Install a font from program code?

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Install a font from program code?

Post by edk »

Hi Andrés.
You should add a font before setting it, not after. The ON INIT event starts later than SET FONT and therefore does not work.

Code: Select all

(...)
IF ! FILE( CMedia + 'Fonts\tecnico.fino.ttf' )
	MSGBOX( "No existe el archivo")
*	 STRFILE ( HMG_LoadResourceRawFile ( 'tecnico', RT_RCDATA ), 'tecnico.fino.ttf' )
ENDIF
	
AddFont( CMedia + 'Fonts\tecnico.fino.ttf' )
	
DEFINE WINDOW Form_1 AT 0 , 0 WIDTH 640 HEIGHT 480 NOSIZE MAIN BACKCOLOR { 000, 023, 052 }  ;	
				 ON INIT msgbox ("ON INIT")  ;
				 ON RELEASE RemoveFont( CMedia + 'Fonts\tecnico.fino.ttf' )
		SET FONT TO "tecnico", 13	
		msgbox ("Set font")
		*----------------------------------------------------------------------------------- 		
(...)

Bez tytułu.png
Bez tytułu.png (6.57 KiB) Viewed 1311 times
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Install a font from program code?

Post by andyglezl »

Muchas gracias EDK, funciona OK.
+-------------------------------------------
Thank you very much EDK, it works OK.
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply