Get Font Name From TTF

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Get Font Name From TTF

Post by TheDewd » 20 Mar 2023, 15:24

How can I get the font name from a font file?

For example, I'm using AddFontResourceEx to load an external font file:
DllCall("Gdi32.dll\AddFontResourceEx", "Str", "font.ttf", "UInt", 0x10, "Int", 0)

However, I will not know which fonts will be provided by the end user, so I can't hardcode in the font filename and font name.

I need to be able to find the font files, and automatically retrieve the name to be used in the Gui:
DllCall("Gdi32.dll\AddFontResourceEx", "Str", "Exo-2-Bold-Italic_Universal.ttf", "UInt", 0x10, "Int", 0)
Gui, Font, s30 cFFFFFF, Exo 2

I can get the filenames, but I don't know how to retrieve the name of the font file. Is there a DllCall I can use?

Also, how can I use this private font with Gdip with example function Gdip_TextToGraphics()?

Return to “Ask for Help (v1)”