Get font handle from file (HFONT) [solved]

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Get font handle from file (HFONT) [solved]

03 Jan 2015, 23:22

Quick question, I need to know how to get the wParam of WM_SETFONT (the font handle) of a TrueType font file (*.ttf) that is not installed. I'm using it for a PostMessage. It may be very obvious, but I don't have the time right now to figure it out.

Any help is appreciated.
Last edited by Masonjar13 on 06 Jan 2015, 13:48, edited 1 time in total.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
Ronins
Posts: 85
Joined: 02 Oct 2013, 11:38

Re: Get font handle from file (HFONT)

04 Jan 2015, 13:28

Here is the MSDN link for CreateFont function. Return value gives hFont
http://msdn.microsoft.com/en-us/library ... s.85).aspx

usage

Code: Select all

hFont := DllCall("CreateFont", "int", nHeight, "int", 0, "int", 0, "int", 0, "int", 400 + 300 * bBold, "Uint", bItalic, "Uint", bUnderline, "Uint", bStrikeOut, "Uint", nCharSet, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0, "str", sFaceName)
sFaceName is the name of font, variables with b as prefix are booleans. Refer to MSDN link provided
Try out CMD class
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Get font handle from file (HFONT)

04 Jan 2015, 20:41

Thanks for the reply.

The function you suggest isn't exact to what I said; I need to get hFont from a non-installed *.ttf file, based on it's file address. As far as I can tell, this function requires entries that should be handled completely by the file and also requires a typeface name, which implies an installed font.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Get font handle from file (HFONT)

06 Jan 2015, 13:48

tmplinshi wrote:Class_CustomFont - Load font from font file
http://ahkscript.org/boards/viewtopic.php?f=6&t=813
Exactly what I was looking for, thank you.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: macromint, peter_ahk, Rauvagol and 331 guests