Jump to content

How to use font without install it?


Recommended Posts

With this fonts doen't work! Why? I try on Windows 10 64bit. Thx

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

_WinAPI_AddFontResourceEx(@ScriptDir&"\font\Android.ttf", $FR_PRIVATE,False)


GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 100)
GUICtrlCreateLabel('Simple Text', 10, 25, 380, 50, $SS_CENTER)
GUICtrlSetFont(-1, 38, -1, -1, 'Android')
GUICtrlSetColor(-1, 0xF06000)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

http://www.dafont.com/it/android.font

 

Link to comment
Share on other sites

I assume you double checked the path you specified is correct?
You should try and add a check to see if the font is loaded or not. Like so:

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

$iSuccess = _WinAPI_AddFontResourceEx(@ScriptDir&"\font\Android.ttf", $FR_PRIVATE,False)
If $iSuccess=0 Then Exit MsgBox(0, "", "Font did not load successfully")


GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 100)
GUICtrlCreateLabel('Simple Text', 10, 25, 380, 50, $SS_CENTER)
GUICtrlSetFont(-1, 38, -1, -1, 'Android')
GUICtrlSetColor(-1, 0xF06000)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

I have no problems with the script, but i am currently testing on my Windows 7 Ultimate 64bit, but if my answer do not help you, i can try it on my win10 machine also.

Thanks for the link to the font, helps a lot ;)

Link to comment
Share on other sites

Seems to be a weird one. I would suggest trying this: Unable to install fonts on Windows 10

It seems some people experience problems with fonts on removable media. Guess it's something that will be fixed at some point...

A solution for your application could be to use FileInstall to the @TempDir. I would imagine it would help, but with the firewall strangeness also being a possibility, who knows.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...