Install a font from program code?

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 3966
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 23 times
Been thanked: 160 times

Install a font from program code?

Post by Roberto Lopez » Fri Apr 19, 2019 7:27 pm

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: 670
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 20 times
Been thanked: 135 times

Post by dragancesu » Fri Apr 19, 2019 7:48 pm

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: 460
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 135 times
Been thanked: 376 times

Post by edk » 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 )


User avatar
mustafa
Posts: 829
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 117 times
Contact:

Post by mustafa » Sat Apr 20, 2019 1:51 pm

+1

User avatar
Roberto Lopez
HMG Founder
Posts: 3966
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 23 times
Been thanked: 160 times

Post by Roberto Lopez » Sat Apr 20, 2019 2:50 pm

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: 3966
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 23 times
Been thanked: 160 times

Post by Roberto Lopez » Sat Apr 20, 2019 2:53 pm

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: 670
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 20 times
Been thanked: 135 times

Post by dragancesu » Sat Apr 20, 2019 3:17 pm

Ops, wrong link, look now

User avatar
Roberto Lopez
HMG Founder
Posts: 3966
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 23 times
Been thanked: 160 times

Post by Roberto Lopez » Sat Apr 20, 2019 6:49 pm

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: 1149
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 68 times
Contact:

Post by andyglezl » Sun Apr 21, 2019 6:13 am

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 21 times
demofont.png
demofont.png (234.19 KiB) Viewed 472 times
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply