#Include Class_CustomFont.ahk #NoEnv #SingleInstance Force SetWorkingDir %A_ScriptDir% SetBatchLines -1 ListLines Off OnExit, ExitSub Gui, Color, Black Gui, Add, Text, hwndhText w600 h50 c00FF00 Center, AutoHotkey CustomFont.AddFromResource(hText, "moonhouse.ttf", "", 50, hFont1) ; 解释: ; CustomFont.AddFromResource(控件的句柄, 字体文件, [字体名称], [字体大小=30], 字体句柄) ; 字体名称如果没有指定,则会自动获取。但是只限于 *.ttf 文件。 Gui, Add, Text, hwndhText w600 h50 c00FF00 Center, Class_CustomFont CustomFont.AddFromResource(hText, "moonhouse.ttf", "", 50, hFont1) ; 解释: ; 如果使用了相同的句柄,则不会再次添加字体,脚本会直接调用之前的。 Gui, Add, Text, hwndhText w600 h50 cWhite Center, http://ahkscript.org/boards/ CustomFont.AddFromResource(hText, "trench100free.otf", "Trench", 20, hFont2) ; 解释: ; 如果要用不同的字体大小,或者字体文件,请指定不同的字体句柄,即最后一个参数 ; 这里用的是 otf 字体文件,所以需要自己指定字体名称 Gui, Show,, 示例1 - 嵌入字体到 exe 中 Return GuiClose: ExitApp ExitSub: CustomFont.Remove() ExitApp FileInstall, moonhouse.ttf, - FileInstall, trench100free.otf, -