Install a font from program code?

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

edk
Posts: 443
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 129 times
Been thanked: 364 times

Re: Install a font from program code?

Post by edk » Sun Apr 21, 2019 9:52 am

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 281 times

User avatar
andyglezl
Posts: 1123
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 32 times
Been thanked: 68 times
Contact:

Post by andyglezl » Sun Apr 21, 2019 3:14 pm

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