E1M1 Posted June 3, 2011 Share Posted June 3, 2011 (edited) I am trying to load font from file because this way I dont have to install it (install requires admin rights but my program must be able to run nonadmin). System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection(); privateFonts.AddFontFile("c:\myapplication\mycustomfont.ttf"); System.Drawing.Font font = new Font(privateFonts.Families[0], 12); this.textBox1.Font = font; AddFontFile (.NET) = AddFontResourceEx (API) For some reason @error is 1. does anyone know what has that function $something = _WinAPI_AddFontResourceEx("File.tff") but how translate rest of program to Autoit? System.Drawing.Font font = new Font(privateFonts.Families[0], 12); this.textBox1.Font = font; My goal is to use that font with control I created with GUICtrlCreate*. Thanks in advance. Edited June 3, 2011 by E1M1 edited Link to comment Share on other sites More sharing options...
UEZ Posted June 3, 2011 Share Posted June 3, 2011 From WinAPIEx.au3: #Include <StaticConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) _WinAPI_AddFontResourceEx(@ScriptDir & '\Extras\SF Square Head Bold.ttf', $FR_PRIVATE) GUICreate('MyGUI', 400, 100) GUICtrlCreateLabel('Simple Text', 10, 25, 380, 50, $SS_CENTER) GUICtrlSetFont(-1, 38, -1, -1, 'SF Square Head Bold') GUICtrlSetColor(-1, 0xF06000) GUISetState() Do Until GUIGetMsg() = -3 Do you mean something like this? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
E1M1 Posted June 3, 2011 Author Share Posted June 3, 2011 (edited) thank you. I didnt think it's that easy. C# has 3 lines to do what autoit does in 1 line I actually thought I need some API calls but it's that easy. Exactly what I was looking for. Edited June 3, 2011 by E1M1 edited Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now