Install a font from program code?

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Install a font from program code?

Post by Roberto Lopez »

Hi All,

I want to install a font automatically from an HMG program (this way I must not install it manually).

Someone has done that?

Any help is welcome.

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Install a font from program code?

Post by dragancesu »

Maybe help https://community.spiceworks.com/topic/ ... s-remotely

One post is

Copy and paste is by far the easiest option for only 15 computers.
Here I had to install a few fonts on a couple of hundred PC's, so I followed these steps:
http://egilhansen.com/2010/09/29/how-pa ... deployment
Make sure to read comments as the program has been updated since the how-to. Its a bit of faffing around but it works.
Last edited by dragancesu on Sat Apr 20, 2019 3:16 pm, edited 1 time in total.
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Install a font from program code?

Post by edk »

I do it this way:
1. At first, it extracts the font file from the resources:

Code: Select all

IF !FILE( 'saxmono.ttf' )
	STRFILE ( HMG_LoadResourceRawFile ( 'saxmono', RT_RCDATA ), 'saxmono.ttf' )
ENDIF
2. Next, I install the font for private use (the font is available only for my application):

Code: Select all

AddFont ( 'saxmono.ttf' )
SET FONT TO "saxMono", 13

*---------------------------------* 
 FUNCTION AddFont( cfontfile )
*---------------------------------* 
   #define FR_PRIVATE 0x10
   #define FR_NOT_ENUM 0x20
   Return WAPI_ADDFONTRESOURCEEX( cfontfile, FR_PRIVATE + FR_NOT_ENUM, 0 )
3. When I exit the program, I uninstall the font

Code: Select all


RemoveFont ( 'saxmono.ttf' )

*---------------------------------*   
 FUNCTION RemoveFont( cfontfile )
*---------------------------------*
   #define FR_PRIVATE 0x10
   #define FR_NOT_ENUM 0x20
   Return WAPI_REMOVEFONTRESOURCEEX( cfontfile, FR_PRIVATE + FR_NOT_ENUM, 0 )
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Install a font from program code?

Post by mustafa »

+1
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Install a font from program code?

Post by Roberto Lopez »

edk wrote: Fri Apr 19, 2019 8:55 pm I do it this way:
1. At first, it extracts the font file from the resources:

Code: Select all

IF !FILE( 'saxmono.ttf' )
	STRFILE ( HMG_LoadResourceRawFile ( 'saxmono', RT_RCDATA ), 'saxmono.ttf' )
ENDIF
2. Next, I install the font for private use (the font is available only for my application):

Code: Select all

AddFont ( 'saxmono.ttf' )
SET FONT TO "saxMono", 13

*---------------------------------* 
 FUNCTION AddFont( cfontfile )
*---------------------------------* 
   #define FR_PRIVATE 0x10
   #define FR_NOT_ENUM 0x20
   Return WAPI_ADDFONTRESOURCEEX( cfontfile, FR_PRIVATE + FR_NOT_ENUM, 0 )
3. When I exit the program, I uninstall the font

Code: Select all


RemoveFont ( 'saxmono.ttf' )

*---------------------------------*   
 FUNCTION RemoveFont( cfontfile )
*---------------------------------*
   #define FR_PRIVATE 0x10
   #define FR_NOT_ENUM 0x20
   Return WAPI_REMOVEFONTRESOURCEEX( cfontfile, FR_PRIVATE + FR_NOT_ENUM, 0 )
At first, thanks for the response.

I've forgot to take a look at hbwin :oops:
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Install a font from program code?

Post by Roberto Lopez »

dragancesu wrote: Fri Apr 19, 2019 7:48 pm Maybe help [url]https://community.spiceworks.com/t ... s-remotely[/url]

One post is

Copy and paste is by far the easiest option for only 15 computers.
Here I had to install a few fonts on a couple of hundred PC's, so I followed these steps:
http://egilhansen.com/2010/09/29/how-pa ... deployment
Make sure to read comments as the program has been updated since the how-to. Its a bit of faffing around but it works.
Thanks for the response too. This is a very good alternative.

And... the first link says: "404" :(
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Install a font from program code?

Post by dragancesu »

Ops, wrong link, look now
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Install a font from program code?

Post by Roberto Lopez »

dragancesu wrote: Sat Apr 20, 2019 3:17 pm Ops, wrong link, look now
Thanks. It's ok now!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
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 »

mmmmm.....
Algo estoy haciendo mal, no logro que se muestre en la aplicación este tipo de font.
*------------------------------------------------------------------------------------------------------
mmmmm .....
Something I'm doing wrong, I can not get this kind of font to show on the application.
demofont.zip
(22.92 KiB) Downloaded 153 times
demofont.png
demofont.png (234.19 KiB) Viewed 3005 times
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply