Page 1 of 2
Install a font from program code?
Posted: Fri Apr 19, 2019 7:27 pm
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.
Re: Install a font from program code?
Posted: Fri Apr 19, 2019 7:48 pm
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.
Re: Install a font from program code?
Posted: Fri Apr 19, 2019 8:55 pm
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 )
Re: Install a font from program code?
Posted: Fri Apr 19, 2019 9:37 pm
by mol
+1
Re: Install a font from program code?
Posted: Sat Apr 20, 2019 1:51 pm
by mustafa
+1
Re: Install a font from program code?
Posted: Sat Apr 20, 2019 2:50 pm
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
Re: Install a font from program code?
Posted: Sat Apr 20, 2019 2:53 pm
by Roberto Lopez
Thanks for the response too. This is a very good alternative.
And... the first link says: "404"
Re: Install a font from program code?
Posted: Sat Apr 20, 2019 3:17 pm
by dragancesu
Ops, wrong link, look now
Re: Install a font from program code?
Posted: Sat Apr 20, 2019 6:49 pm
by Roberto Lopez
dragancesu wrote: ↑Sat Apr 20, 2019 3:17 pm
Ops, wrong link, look now
Thanks. It's ok now!
Re: Install a font from program code?
Posted: Sun Apr 21, 2019 6:13 am
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.png (234.19 KiB) Viewed 3026 times