Installed Font Names

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Installed Font Names

11 Mar 2016, 02:14

I know how to loop through teh installed fonts folder but is there a way to get the actual font name from the file name? Thanks.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Installed Font Names

11 Mar 2016, 08:42

Thanks, I was hoping there might be an ahk solution, also doesn't seem to deal with ttf type fonts?
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Installed Font Names

11 Mar 2016, 08:45

well this from user tmplinshi
https://autohotkey.com/boards/viewtopic.php?f=6&t=813
[Class] CustomFont - Load font from file or resource, without needed install to system.


here example with otfinfo

Code: Select all

#NoEnv                        ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input                ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
setformat,float,0.2
transform,S,chr,32     ;space

ifnotexist,otfinfo.exe
    {
    msgbox,download otfinfo.exe from=`nhttp://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
    ;https://autohotkey.com/boards/viewtopic.php?f=22&t=824
    ;https://autohotkey.com/boards/viewtopic.php?f=6&t=813     ;- classcustomfont tmplinshi
    ;http://www.lcdf.org/type/otfinfo.1.html
    exitapp
    }

SetBatchLines, -1

extensions:="otf,ttf"
F4=%a_scriptdir%\Fontnames.txt
T1:=31
fdx=C:\windows\fonts
Loop,%fdx%\*.*
{
If A_LoopFileExt in %Extensions%
  {
  f1=%A_loopfilefullpath%
  if f1=
     continue
  f5=%a_loopfilename%
  pr=otfinfo -a "%f1%"
  pr:=pr
  F2:=StdoutToVar_CreateProcess(pr)
  stringtrimright,f2,f2,2
  F5:= LP(F5,T1,S,"L")       ;-
  F2:= LP(F2,T1,S,"L")
  e4x .= F2 . " " .  F5 . "`r`n"
  }
}
if e4x<>
 {
 ifexist,%f4%
    filedelete,%f4%
 fileappend,%fdx%`r`n----------------------------`r`n%e4x%,%f4%
 }
e4x=
run,%f4%
return


;=======================================================================================

;------------- functionx von BoBo Linepaddingx --------------------------
LP(String,FieldLen,ToAppend,Justification)
 {
   StringLen, StringLen, String
   LCnt := FieldLen-StringLen
   Loop, % LCnt
     Appended := (Appended . ToAppend)
   If Justification = R
      Return (Appended . String)
   If Justification = L
      Return (String . Appended)
 }
return
;=======================================================================




;--------- http://ahkscript.org/boards/viewtopic.php?f=6&t=791 ---
;--        from user cyruz
;-- Last edited by cyruz on Sun Mar 09, 2014 12:51 pm, edited 6 times in total
StdoutToVar_CreateProcess(sCmd, sDir:="", ByRef nExitCode:=0) {
    DllCall( "CreatePipe",           PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
    DllCall( "SetHandleInformation", Ptr,hStdOutWr,  UInt,1,         UInt,1        )

            VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24,  0 )
    siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
    NumPut( siSz,      si,  0,                          "UInt" )
    NumPut( 0x100,     si,  (A_PtrSize == 4) ? 44 : 60, "UInt" )
    NumPut( hStdInRd,  si,  (A_PtrSize == 4) ? 56 : 80, "Ptr"  )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 60 : 88, "Ptr"  )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 64 : 96, "Ptr"  )

    If ( !DllCall( "CreateProcess", Ptr,0, Ptr,&sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
                                  , Ptr,0, Ptr,sDir?&sDir:0, Ptr,&si, Ptr,&pi ) )
        Return ""
      , DllCall( "CloseHandle", Ptr,hStdOutWr )
      , DllCall( "CloseHandle", Ptr,hStdOutRd )

    DllCall( "CloseHandle", Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
    VarSetCapacity(sTemp, 4095)
    While ( DllCall( "ReadFile", Ptr,hStdOutRd, Ptr,&sTemp, UInt,4095, PtrP,nSize, Ptr,0 ) )
        sOutput .= StrGet(&sTemp, nSize, A_FileEncoding)

    DllCall( "GetExitCodeProcess", Ptr,NumGet(pi,0), Ptr,&nExitCode ), nExitCode := NumGet(nExitCode)
    DllCall( "CloseHandle",        Ptr,NumGet(pi,0)                 )
    DllCall( "CloseHandle",        Ptr,NumGet(pi,A_PtrSize)         )
    DllCall( "CloseHandle",        Ptr,hStdOutRd                    )
    Return sOutput
}
;------------------------------------------------------------------------------------------------------
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Installed Font Names

11 Mar 2016, 09:47

script from tmplinshi with otfinfo.exe , check C:\windows\fonts

Code: Select all

/*
https://autohotkey.com/boards/viewtopic.php?f=6&t=813
CustomFont v2.00 (2016-2-24)
Description: Load font from file or resource, without needed install to system.
*/

#NoEnv                        ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input                ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1

ifnotexist,otfinfo.exe
    {
    msgbox,download otfinfo.exe from=`nhttp://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
    ;https://autohotkey.com/boards/viewtopic.php?f=22&t=824
    ;https://autohotkey.com/boards/viewtopic.php?f=6&t=813     ;- classcustomfont tmplinshi
    ;http://www.lcdf.org/type/otfinfo.1.html
    exitapp
    }

extensions:="otf,ttf"


Gui,3:Color, Black
Gui,3:Color, ControlColor, Black
Gui,3:Font,,FixedSys
Gui,3:show ,x10 y10 h250 w500,FONTS_TEST
Gui,3:add,edit,x10 y10 h180 w470 vED1 hwndhText cYellow,Line1_Test`nLine2_Test`nLine3_Test
Gui,3:add,edit,x10 y200 h25 w470 readonly cRed vED2
gosub,a2
return
;---------------------------------------------------------------
3Guiclose:
exitapp
;---------------------------------------------------------------

;---- example-2 --------------------------------------------------------
a2:
Gui,3:submit,nohide
fdx=C:\WINDOWS\Fonts
;fdx=%a_scriptdir%
ifexist,%fdx%
{
Loop,%fdx%\*.*
{
If A_LoopFileExt in %Extensions%
  {
  f1=%A_loopfilefullpath%
  if f1=
     continue
  pr=otfinfo -a "%f1%"
  pr:=pr
  F2:=StdoutToVar_CreateProcess(pr)
  stringtrimright,f2,f2,2
  font1:=""
  fontx=res:%f1%
  fontx:=fontx
  ;msgbox,F2=%f2%`nFONTX=%fontx%
  ;font1 := New CustomFont("res:moonhouse.ttf", "moonhouse", 50)
  font1 := New CustomFont(fontx,F2, 50)
  font1.applyTo(hText)
  guicontrol,3: ,ED2,%f2%
  fontx:=""
  F2:=""
  sleep,1600
  }
}
}
return
;================================================================


/*
#Include Class_CustomFont.ahk
Font1 := New CustomFont("CHOCD TRIAL___.otf")
Gui, Margin, 30, 10
Gui, Color, DECFB2
Gui, Font, s100 c510B01, Chocolate Dealer
Gui, Add, Text, w400, Chocolate
Gui, Show
Return

GuiClose:
ExitApp
*/


/*
;sample-2
#Include Class_CustomFont.ahk
font1 := New CustomFont("res:moonhouse.ttf", "moonhouse", 50)
font2 := New CustomFont("res:Selavy.otf", "Selavy-Regular", 20)

Gui, Color, Black
Gui, Add, Text, hwndhText1 w500 h50 c00FF00 Center, AutoHotkey
Gui, Add, Text, hwndhText2 wp hp cWhite Center, https://www.autohotkey.com/
Gui, Add, Button, xm gRemoveFont1, Remove Font1

font1.applyTo(hText1)
font2.applyTo(hText2)

Gui, Show
Return

RemoveFont1:
	font1 := ""
	WinSet, Redraw,, A
Return

GuiClose:
ExitApp

FileInstall, moonhouse.ttf, -
FileInstall, Selavy.otf, -
*/



;==================================================================
/*
	CustomFont v2.00 (2016-2-24)
	---------------------------------------------------------
	Description: Load font from file or resource, without needed install to system.
	---------------------------------------------------------
	Useage Examples:

		* Load From File
			font1 := New CustomFont("ewatch.ttf")
			Gui, Font, s100, ewatch

		* Load From Resource
			Gui, Add, Text, HWNDhCtrl w400 h200, 12345
			font2 := New CustomFont("res:ewatch.ttf", "ewatch", 80) ; <- Add a res: prefix to the resource name.
			font2.ApplyTo(hCtrl)

		* The fonts will removed automatically when script exits.
		  To remove a font manually, just clear the variable (e.g. font1 := "").
*/
Class CustomFont
{
	static FR_PRIVATE  := 0x10

	__New(FontFile, FontName="", FontSize=30) {
		if RegExMatch(FontFile, "i)res:\K.*", _FontFile) {
			this.AddFromResource(_FontFile, FontName, FontSize)
		} else {
			this.AddFromFile(FontFile)
		}
	}

	AddFromFile(FontFile) {
		DllCall( "AddFontResourceEx", "Str", FontFile, "UInt", this.FR_PRIVATE, "UInt", 0 )
		this.data := FontFile
	}

	AddFromResource(ResourceName, FontName, FontSize = 30) {
		static FW_NORMAL := 400, DEFAULT_CHARSET := 0x1

		nSize    := this.ResRead(fData, ResourceName)
		fh       := DllCall( "AddFontMemResourceEx", "Ptr", &fData, "UInt", nSize, "UInt", 0, "UIntP", nFonts )
		hFont    := DllCall( "CreateFont", Int,FontSize, Int,0, Int,0, Int,0, UInt,FW_NORMAL, UInt,0
		            , Int,0, Int,0, UInt,DEFAULT_CHARSET, Int,0, Int,0, Int,0, Int,0, Str,FontName )

		this.data := {fh: fh, hFont: hFont}
	}

	ApplyTo(hCtrl) {
		SendMessage, 0x30, this.data.hFont, 1,, ahk_id %hCtrl%
	}

	__Delete() {
		if IsObject(this.data) {
			DllCall( "RemoveFontMemResourceEx", "UInt", this.data.fh    )
			DllCall( "DeleteObject"           , "UInt", this.data.hFont )
		} else {
			DllCall( "RemoveFontResourceEx"   , "Str", this.data, "UInt", this.FR_PRIVATE, "UInt", 0 )
		}
	}

	; ResRead() By SKAN, from http://www.autohotkey.com/board/topic/57631-crazy-scripting-resource-only-dll-for-dummies-36l-v07/?p=609282
	ResRead( ByRef Var, Key ) {
		VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
		If ! ( A_IsCompiled ) {
			FileGetSize, nSize, %Key%
			FileRead, Var, *c %Key%
			Return nSize
		}

		If hMod := DllCall( "GetModuleHandle", UInt,0 )
			If hRes := DllCall( "FindResource", UInt,hMod, Str,Key, UInt,10 )
				If hData := DllCall( "LoadResource", UInt,hMod, UInt,hRes )
					If pData := DllCall( "LockResource", UInt,hData )
						Return VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
							,  DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
		Return 0
	}
}
;=========================================================================



;--------- http://ahkscript.org/boards/viewtopic.php?f=6&t=791 ---
;--        from user cyruz
;-- Last edited by cyruz on Sun Mar 09, 2014 12:51 pm, edited 6 times in total
StdoutToVar_CreateProcess(sCmd, sDir:="", ByRef nExitCode:=0) {
    DllCall( "CreatePipe",           PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
    DllCall( "SetHandleInformation", Ptr,hStdOutWr,  UInt,1,         UInt,1        )

            VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24,  0 )
    siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
    NumPut( siSz,      si,  0,                          "UInt" )
    NumPut( 0x100,     si,  (A_PtrSize == 4) ? 44 : 60, "UInt" )
    NumPut( hStdInRd,  si,  (A_PtrSize == 4) ? 56 : 80, "Ptr"  )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 60 : 88, "Ptr"  )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 64 : 96, "Ptr"  )

    If ( !DllCall( "CreateProcess", Ptr,0, Ptr,&sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
                                  , Ptr,0, Ptr,sDir?&sDir:0, Ptr,&si, Ptr,&pi ) )
        Return ""
      , DllCall( "CloseHandle", Ptr,hStdOutWr )
      , DllCall( "CloseHandle", Ptr,hStdOutRd )

    DllCall( "CloseHandle", Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
    VarSetCapacity(sTemp, 4095)
    While ( DllCall( "ReadFile", Ptr,hStdOutRd, Ptr,&sTemp, UInt,4095, PtrP,nSize, Ptr,0 ) )
        sOutput .= StrGet(&sTemp, nSize, A_FileEncoding)

    DllCall( "GetExitCodeProcess", Ptr,NumGet(pi,0), Ptr,&nExitCode ), nExitCode := NumGet(nExitCode)
    DllCall( "CloseHandle",        Ptr,NumGet(pi,0)                 )
    DllCall( "CloseHandle",        Ptr,NumGet(pi,A_PtrSize)         )
    DllCall( "CloseHandle",        Ptr,hStdOutRd                    )
    Return sOutput
}
;------------------------------------------------------------------------------------------------------
;======================================================================================================
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: Installed Font Names

11 Mar 2016, 13:54

The following script displays a list of fonts:

Code: Select all

#NoEnv
#Warn

Gui Add, ListView, x8 y8 w273 h362, Font name
LV_ModifyCol(1, 250)

Global FontList := []

EnumFonts() {
    hDC := DllCall("GetDC", "UInt", DllCall("GetDesktopWindow"))
    Callback := RegisterCallback("EnumFontsCallback", "F")
    DllCall("EnumFontFamilies", "UInt", hDC, "UInt", 0, "Ptr", Callback, "UInt", lParam := 0)
    DllCall("ReleaseDC", "UInt", hDC)
}

EnumFontsCallback(lpelf) {
    FontList.Push(StrGet(lpelf + 28, 32))
    Return True
}

EnumFonts()

Loop % FontList.MaxIndex() {
	LV_Add("", FontList[A_Index])
}

Gui Show, w290 h379, Fonts
Return

GuiEscape:
GuiClose:
    ExitApp
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Installed Font Names

12 Mar 2016, 04:10

Thanks for the replies, and especially Alguimist. That works perfectly. How long did it take you get to grips with DllCall? How to learn about it. Brilliant. Thanks again.
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Installed Font Names

12 Mar 2016, 06:26

thank you Alguimist for script
tmplinshi's idea was to add a special font to an ahk script , I was just playing with fonts

Code: Select all

;-------- saved at Samstag, 12. März 2016 09:24:30 --------------
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=14838 ---
#NoEnv
#Warn

Gui Add, ListView, x8 y8 w273 h362 sort, Font name
LV_ModifyCol(1, 250)

Global FontList := []

EnumFonts() {
    hDC := DllCall("GetDC", "UInt", DllCall("GetDesktopWindow"))
    Callback := RegisterCallback("EnumFontsCallback", "F")
    DllCall("EnumFontFamilies", "UInt", hDC, "UInt", 0, "Ptr", Callback, "UInt", lParam := 0)
    DllCall("ReleaseDC", "UInt", hDC)
}

EnumFontsCallback(lpelf) {
    FontList.Push(StrGet(lpelf + 28, 32))
    Return True
}

EnumFonts()

Loop, % FontList.MaxIndex()
   LV_Add("", FontList[A_Index])

Gui Show, w290 h379, Fonts
aa:=FontList.MaxIndex()
msgbox,Total= %aa%        ;- 217 / 343 in C:\windows\fonts
Return

GuiEscape:
GuiClose:
ExitApp


here with otfinfo.exe

Code: Select all

C:\windows\fonts
----------------------------
Agency FB                       AGENCYB.TTF
Agency FB                       AGENCYR.TTF
Algerian                        ALGER.TTF
Book Antiqua                    ANTQUAB.TTF
Book Antiqua                    ANTQUABI.TTF
Book Antiqua                    ANTQUAI.TTF
Arial                           arial.ttf
Arial Alternative Symbol        Arialals.ttf
Arial Alternative               Arialalt.ttf
Arial                           arialbd.ttf
Arial                           arialbi.ttf
Arial                           ariali.ttf
Arial Narrow                    ARIALN.TTF
Arial Narrow                    ARIALNB.TTF
Arial Narrow                    ARIALNBI.TTF
Arial Narrow                    ARIALNI.TTF
Arial Unicode MS                ARIALUNI.TTF
Arial Black                     ariblk.ttf
Arimo                           Arimo-Bold.ttf
Arimo                           Arimo-BoldItalic.ttf
Arimo                           Arimo-Italic.ttf
Arimo                           Arimo-Regular.ttf
Arial Rounded MT Bold           ARLRDBD.TTF
Baskerville Old Face            BASKVILL.TTF
Bauhaus 93                      BAUHS93.TTF
Bell MT                         BELL.TTF
Bell MT                         BELLB.TTF
Bell MT                         BELLI.TTF
Bernard MT Condensed            BERNHC.TTF
Book Antiqua                    BKANT.TTF
Bodoni MT                       BOD_B.TTF
Bodoni MT                       BOD_BI.TTF
Bodoni MT Black                 BOD_BLAI.TTF
Bodoni MT Black                 BOD_BLAR.TTF
Bodoni MT Condensed             BOD_CB.TTF
Bodoni MT Condensed             BOD_CBI.TTF
Bodoni MT Condensed             BOD_CI.TTF
Bodoni MT Condensed             BOD_CR.TTF
Bodoni MT                       BOD_I.TTF
Bodoni MT Poster Compressed     BOD_PSTC.TTF
Bodoni MT                       BOD_R.TTF
Bookman Old Style               BOOKOS.TTF
Bookman Old Style               BOOKOSB.TTF
Bookman Old Style               BOOKOSBI.TTF
Bookman Old Style               BOOKOSI.TTF
Bradley Hand ITC                BRADHITC.TTF
Britannic Bold                  BRITANIC.TTF
Berlin Sans FB                  BRLNSB.TTF
Berlin Sans FB Demi             BRLNSDB.TTF
Berlin Sans FB                  BRLNSR.TTF
Broadway                        BROADW.TTF
Brush Script MT                 BRUSHSCI.TTF
Bookshelf Symbol 7              BSSYM7.TTF
Calibri                         CALIBRI.TTF
Calibri                         CALIBRIB.TTF
Calibri                         CALIBRII.TTF
Calibri                         CALIBRIZ.TTF
Californian FB                  CALIFB.TTF
Californian FB                  CALIFI.TTF
Californian FB                  CALIFR.TTF
Calisto MT                      CALIST.TTF
Calisto MT                      CALISTB.TTF
Calisto MT                      CALISTBI.TTF
Calisto MT                      CALISTI.TTF
Cambria                         CAMBRIA0.ttf
Cambria Math                    CAMBRIA1.ttf
Cambria                         CAMBRIAB.TTF
Cambria                         CAMBRIAI.TTF
Cambria                         CAMBRIAZ.TTF
Candara                         CANDARA.TTF
Candara                         CANDARAB.TTF
Candara                         CANDARAI.TTF
Candara                         CANDARAZ.TTF
Castellar                       CASTELAR.TTF
Century Schoolbook              CENSCBK.TTF
Centaur                         CENTAUR.TTF
Century                         CENTURY.TTF
Chiller                         CHILLER.TTF
Colonna MT                      COLONNA.TTF
Comic Sans MS                   comic.ttf
Comic Sans MS                   comicbd.ttf
Consolas                        CONSOLA.TTF
Consolas                        CONSOLAB.TTF
Consolas                        CONSOLAI.TTF
Consolas                        CONSOLAZ.TTF
Constantia                      CONSTAN.TTF
Constantia                      CONSTANB.TTF
Constantia                      CONSTANI.TTF
Constantia                      CONSTANZ.TTF
Cooper Black                    COOPBL.TTF
Copperplate Gothic Bold         COPRGTB.TTF
Copperplate Gothic Light        COPRGTL.TTF
Corbel                          CORBEL.TTF
Corbel                          CORBELB.TTF
Corbel                          CORBELI.TTF
Corbel                          CORBELZ.TTF
Courier New                     cour.ttf
Courier New                     courbd.ttf
Courier New                     courbi.ttf
Courier New                     couri.ttf
Curlz MT                        CURLZ___.TTF
DejaVu Sans Condensed           DejaVuCondensedSans.ttf
DejaVu Sans Condensed           DejaVuCondensedSansBold.ttf
DejaVu Sans Condensed           DejaVuCondensedSansBoldOblique.ttf
DejaVu Sans Condensed           DejaVuCondensedSansOblique.ttf
DejaVu Serif Condensed          DejaVuCondensedSerif.ttf
DejaVu Serif Condensed          DejaVuCondensedSerifBold.ttf
DejaVu Serif Condensed          DejaVuCondensedSerifBoldItalic.ttf
DejaVu Serif Condensed          DejaVuCondensedSerifItalic.ttf
DejaVu Sans Mono                DejaVuMonoSans.ttf
DejaVu Sans Mono                DejaVuMonoSansBold.ttf
DejaVu Sans Mono                DejaVuMonoSansBoldOblique.ttf
DejaVu Sans Mono                DejaVuMonoSansOblique.ttf
DejaVu Sans                     DejaVuSans-Bold.ttf
DejaVu Sans                     DejaVuSans-BoldOblique.ttf
DejaVu Sans Light               DejaVuSans-ExtraLight.ttf
DejaVu Sans                     DejaVuSans-Oblique.ttf
DejaVu Sans                     DejaVuSans.ttf
DejaVu Sans                     DejaVuSansBold.ttf
DejaVu Sans                     DejaVuSansBoldOblique.ttf
DejaVu Sans Condensed           DejaVuSansCondensed-Bold.ttf
DejaVu Sans Condensed           DejaVuSansCondensed-BoldOblique.ttf
DejaVu Sans Condensed           DejaVuSansCondensed-Oblique.ttf
DejaVu Sans Condensed           DejaVuSansCondensed.ttf
DejaVu Sans Light               DejaVuSansExtraLight.ttf
DejaVu Sans Mono                DejaVuSansMono-Bold.ttf
DejaVu Sans Mono                DejaVuSansMono-BoldOblique.ttf
DejaVu Sans Mono                DejaVuSansMono-Oblique.ttf
DejaVu Sans Mono                DejaVuSansMono.ttf
DejaVu Sans                     DejaVuSansOblique.ttf
DejaVu Serif                    DejaVuSerif-Bold.ttf
DejaVu Serif                    DejaVuSerif-BoldItalic.ttf
DejaVu Serif                    DejaVuSerif-Italic.ttf
DejaVu Serif                    DejaVuSerif.ttf
DejaVu Serif                    DejaVuSerifBold.ttf
DejaVu Serif                    DejaVuSerifBoldItalic.ttf
DejaVu Serif Condensed          DejaVuSerifCondensed-Bold.ttf
DejaVu Serif Condensed          DejaVuSerifCondensed-BoldItalic.ttf
DejaVu Serif Condensed          DejaVuSerifCondensed-Italic.ttf
DejaVu Serif Condensed          DejaVuSerifCondensed.ttf
DejaVu Serif                    DejaVuSerifItalic.ttf
Elephant                        ELEPHNT.TTF
Elephant                        ELEPHNTI.TTF
Engravers MT                    ENGR.TTF
Eras Bold ITC                   ERASBD.TTF
Eras Demi ITC                   ERASDEMI.TTF
Eras Light ITC                  ERASLGHT.TTF
Eras Medium ITC                 ERASMD.TTF
Estrangelo Edessa               estre.ttf
Felix Titling                   FELIXTI.TTF
FixedsysTTF                     Fixedsys500c.ttf
Forte                           FORTE.TTF
Franklin Gothic Book            FRABK.TTF
Franklin Gothic Book            FRABKIT.TTF
Franklin Gothic Demi            FRADM.TTF
Franklin Gothic Demi Cond       FRADMCN.TTF
Franklin Gothic Demi            FRADMIT.TTF
Franklin Gothic Heavy           FRAHV.TTF
Franklin Gothic Heavy           FRAHVIT.TTF
Franklin Gothic Medium          framd.ttf
Franklin Gothic Medium Cond     FRAMDCN.TTF
Franklin Gothic Medium          framdit.ttf
Freestyle Script                FREESCPT.TTF
French Script MT                FRSCRIPT.TTF
Footlight MT Light              FTLTLT.TTF
Garamond                        GARA.TTF
Garamond                        GARABD.TTF
Garamond                        GARAIT.TTF
Gautami                         gautami.ttf
Gentium Basic                   GenBasB.ttf
Gentium Basic                   GenBasBI.ttf
Gentium Basic                   GenBasI.ttf
Gentium Basic                   GenBasR.ttf
Gentium Book Basic              GenBkBasB.ttf
Gentium Book Basic              GenBkBasBI.ttf
Gentium Book Basic              GenBkBasI.ttf
Gentium Book Basic              GenBkBasR.ttf
Georgia                         georgia.ttf
Georgia                         georgiab.ttf
Georgia                         georgiai.ttf
Georgia                         georgiaz.ttf
Gigi                            GIGI.TTF
Gill Sans MT                    GILBI___.TTF
Gill Sans MT                    GILB____.TTF
Gill Sans MT Condensed          GILC____.TTF
Gill Sans MT                    GILI____.TTF
Gill Sans Ultra Bold Condensed  GILLUBCD.TTF
Gill Sans Ultra Bold            GILSANUB.TTF
Gill Sans MT                    GIL_____.TTF
Gloucester MT Extra Condensed   GLECB.TTF
Gill Sans MT Ext Condensed Bold GLSNECB.TTF
Century Gothic                  GOTHIC.TTF
Century Gothic                  GOTHICB.TTF
Century Gothic                  GOTHICBI.TTF
Century Gothic                  GOTHICI.TTF
Goudy Old Style                 GOUDOS.TTF
Goudy Old Style                 GOUDOSB.TTF
Goudy Old Style                 GOUDOSI.TTF
Goudy Stout                     GOUDYSTO.TTF
Harlow Solid Italic             HARLOWSI.TTF
Harrington                      HARNGTON.TTF
Haettenschweiler                HATTEN.TTF
High Tower Text                 HTOWERT.TTF
High Tower Text                 HTOWERTI.TTF
Impact                          impact.ttf
Imprint MT Shadow               IMPRISHA.TTF
Informal Roman                  INFROMAN.TTF
Blackadder ITC                  ITCBLKAD.TTF
Edwardian Script ITC            ITCEDSCR.TTF
Kristen ITC                     ITCKRIST.TTF
Jokerman                        JOKERMAN.TTF
Juice ITC                       JUICE___.TTF
Kartika                         kartika.ttf
Kunstler Script                 KUNSTLER.TTF
Latha                           latha.ttf
Wide Latin                      LATINWD.TTF
Lucida Bright                   LBRITE.TTF
Lucida Bright                   LBRITED.TTF
Lucida Bright                   LBRITEDI.TTF
Lucida Bright                   LBRITEI.TTF
Lucida Calligraphy              LCALLIG.TTF
Lucida Fax                      LFAX.TTF
Lucida Fax                      LFAXD.TTF
Lucida Fax                      LFAXDI.TTF
Lucida Fax                      LFAXI.TTF
Lucida Handwriting              LHANDW.TTF
Liberation Sans Narrow          LiberationSansNarrow-Bold.ttf
Liberation Sans Narrow          LiberationSansNarrow-BoldItalic.ttf
Liberation Sans Narrow          LiberationSansNarrow-Italic.ttf
Liberation Sans Narrow          LiberationSansNarrow-Regular.ttf
Lucida Sans                     LSANS.TTF
Lucida Sans                     LSANSD.TTF
Lucida Sans                     LSANSDI.TTF
Lucida Sans                     LSANSI.TTF
Lucida Sans Typewriter          LTYPE.TTF
Lucida Sans Typewriter          LTYPEB.TTF
Lucida Sans Typewriter          LTYPEBO.TTF
Lucida Sans Typewriter          LTYPEO.TTF
Lucida Console                  lucon.ttf
Lucida Sans Unicode             l_10646.ttf
Magneto                         MAGNETOB.TTF
Maiandra GD                     MAIAN.TTF
Mangal                          mangal.ttf
                                marlett.ttf
Matura MT Script Capitals       MATURASC.TTF
Microsoft Sans Serif            micross.ttf
Mistral                         MISTRAL.TTF
Modern No. 20                   MOD20.TTF
moonhouse                       moonhouse.ttf
MS Mincho                       MSMINCHO.TTF
Monotype Corsiva                MTCORSVA.TTF
MV Boli                         mvboli.ttf
Niagara Engraved                NIAGENG.TTF
Niagara Solid                   NIAGSOL.TTF
OCR A Extended                  OCRAEXT.TTF
Old English Text MT             OLDENGL.TTF
Onyx                            ONYX.TTF
OpenSymbol                      opens___.ttf
MS Outlook                      OUTLOOK.TTF
Palatino Linotype               pala.ttf
Palatino Linotype               palab.ttf
Palatino Linotype               palabi.ttf
Palatino Linotype               palai.ttf
Palace Script MT                PALSCRI.TTF
Papyrus                         PAPYRUS.TTF
Parchment                       PARCHM.TTF
Perpetua                        PERBI___.TTF
Perpetua                        PERB____.TTF
Perpetua                        PERI____.TTF
Perpetua Titling MT             PERTIBD.TTF
Perpetua Titling MT             PERTILI.TTF
Perpetua                        PER_____.TTF
Playbill                        PLAYBILL.TTF
Poor Richard                    POORICH.TTF
Pristina                        PRISTINA.TTF
PT Sans Caption                 PTC55F.ttf
PT Sans Caption                 PTC75F.ttf
PT Sans Narrow                  PTN57F.ttf
PT Sans Narrow                  PTN77F.ttf
PT Sans                         PTS55F.ttf
PT Sans                         PTS56F.ttf
PT Sans                         PTS75F.ttf
PT Sans                         PTS76F.ttf
Raavi                           raavi.ttf
Rage Italic                     RAGE.TTF
Ravie                           RAVIE.TTF
MS Reference Sans Serif         REFSAN.TTF
MS Reference Specialty          REFSPCL.TTF
Rockwell Condensed              ROCCB___.TTF
Rockwell Condensed              ROCC____.TTF
Rockwell                        ROCK.TTF
Rockwell                        ROCKB.TTF
Rockwell                        ROCKBI.TTF
Rockwell Extra Bold             ROCKEB.TTF
Rockwell                        ROCKI.TTF
Century Schoolbook              SCHLBKB.TTF
Century Schoolbook              SCHLBKBI.TTF
Century Schoolbook              SCHLBKI.TTF
Script MT Bold                  SCRIPTBL.TTF
Segoe UI                        SEGOEUI.TTF
Segoe UI                        SEGOEUIB.TTF
Segoe UI                        SEGOEUII.TTF
Segoe UI                        SEGOEUIZ.TTF
Selavy Regular                  Selavy.otf
Showcard Gothic                 SHOWG.TTF
Shruti                          shruti.ttf
Snap ITC                        SNAP____.TTF
Stencil                         STENCIL.TTF
Sylfaen                         sylfaen.ttf
Symbol                          symbol.ttf
Tahoma                          tahoma.ttf
Tahoma                          tahomabd.ttf
Tw Cen MT                       TCBI____.TTF
Tw Cen MT                       TCB_____.TTF
Tw Cen MT Condensed             TCCB____.TTF
Tw Cen MT Condensed Extra Bold  TCCEB.TTF
Tw Cen MT Condensed             TCCM____.TTF
Tw Cen MT                       TCMI____.TTF
Tw Cen MT                       TCM_____.TTF
Tempus Sans ITC                 TEMPSITC.TTF
Times New Roman                 times.ttf
Times New Roman                 timesbd.ttf
Times New Roman                 timesbi.ttf
Times New Roman                 timesi.ttf
Trebuchet MS                    trebuc.ttf
Trebuchet MS                    trebucbd.ttf
Trebuchet MS                    trebucbi.ttf
Trebuchet MS                    trebucit.ttf
Tunga                           tunga.ttf
Verdana                         verdana.ttf
Verdana                         verdanab.ttf
Verdana                         verdanai.ttf
Verdana                         verdanaz.ttf
Viner Hand ITC                  VINERITC.TTF
Vivaldi                         VIVALDII.TTF
Vladimir Script                 VLADIMIR.TTF
Vrinda                          vrinda.ttf
Webdings                        webdings.ttf
Wingdings                       wingding.ttf
Wingdings 2                     WINGDNG2.TTF
Wingdings 3                     WINGDNG3.TTF
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Installed Font Names

13 Mar 2016, 07:37

example with script from Alguimist , to show how FONT's look like
click column or button START

Code: Select all

;-------- saved at Sonntag, 13. März 2016 11:14:50 --------------
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=14838 ---
;-------- from user = Alguimist

#NoEnv                        ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn
SendMode Input                ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1


Gui,3: default
Gui,3:Color, Black
Gui,3:Color, ControlColor, Black
Gui,3:Font,,FixedSys


   Menu,S1,add,Script_tmplinshi  ,MH1
   Menu,S1,add,Script_Source     ,MH1
   Menu,S1,add,Script_ZIP        ,MH1
   Menu,S1,add,Script_alguimist  ,MH1
   Menu,S1,add,Ahk_Font_Help     ,MH1
   Menu,S1,add,OTFINFO_HELP      ,MH1
   Menu,S1,add,OTFINFO_Download  ,MH1
   Menu,S1,add,SKAN              ,MH1
   Menu,S1,add,Latofonts         ,MH1
   Menu,S1,add,FontsOldSchool    ,MH1
   Menu,S1,add,Fontsquirrel      ,MH1


   Menu,S2,add,AHK_Version       ,MH2
   Menu,S3,add,WindowsFonts      ,MH3
   ;----------------------------
   menu,myMenuBar,Add,Font_Links    ,:S1
   menu,myMenuBar,Add,AHK_Version   ,:S2
   menu,myMenuBar,Add,WindowsFonts  ,:S3
   ;----------------------------
   gui,3:menu,MyMenuBar
   ;----------------------------


Gui,3: Add, ListView, x10 y10 w270 h360 sort gLV1 vLVA1 cYellow +hscroll altsubmit, Font name
LV_ModifyCol(1, 250)

gosub,functionx

Loop, % FontList.MaxIndex()
   LV_Add("", FontList[A_Index])

e4x:=""
loop,15
 e4x .= "This is a testline. This is Line- #@-" . a_index . "`r`n"

Gui,3:add,edit   ,x290  y10  h360 w470 vED1 hwndhText cTeal,%e4x%
Gui,3:add,edit   ,x290  y380 h25  w470 readonly cRed    vED2,Fixedsys
Gui,3:add,button ,x10   y380 h25  w80 gStart1 vSt1,Start
Gui,3:add,button ,x100  y380 h25  w80 gStop1 ,Stop
Gui,3:show ,x10 y10 h420 w800,WINDOWS-FONTS_TEST
Guicontrol,3:focus,st1
return
;---------------------------------------------------------------
3Guiclose:
exitapp
;---------------------------------------------------------------


LV1:
Gui,3:default
Gui,3:ListView,LVA1
Gui,3:submit,nohide

;RN:=LV_GetNext("C") ;2 selected checked
;RF:=LV_GetNext("F") ;2 selected focused
;GC:=LV_GetCount()   ;4 total

if A_GuiEvent = Normal
{
LV_GetText(C1,A_EventInfo,1)
;Gui,3: font, s14 cF16400 strike, %c1%           ;- change text-COLOR / SIZE / FONT
Gui,3: font, s12 cYellow normal , %c1%
Guicontrol,3: ,ED2,%c1%
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1%                        ;- maybe CHANGE TEXT
}
return
;----------------------------------------


;----------------------------------------
start1:
breakloop=0
Gui,3:ListView,LVA1
i=0
loop,
{
if (breakloop=1)
   break

LV_Modify(I, "-Select -Focus")
i++
LV_Modify(I, "+Select +Focus")
RF:=LV_GetNext("F") ;2 selected focused
LV_GetText(C1,RF,1)
LV_Modify(RF, "Vis")    ;- scrolltox

Gui,3: font, s16 cF16400, %c1%                    ;- change text-COLOR / SIZE / FONT
Guicontrol,3: ,ED2,%c1%
Guicontrol,3: Font, ED1
Guicontrol,3: ,ED1,%ed1%                          ;- maybe CHANGE TEXT
sleep,1000
}
return
;-----------------------------

;----------------
stop1:
breakloop=1
return
;----------------

;--------------------------------------------------------------
mh1:


if A_thisMenuItem=Script_tmplinshi
   run,https://autohotkey.com/boards/viewtopic.php?f=6&t=813     ;- classcustomfont tmplinshi
if A_thisMenuItem=Script_Source
    run,https://gist.github.com/tmplinshi/7717340
if A_thisMenuItem=Script_ZIP
    run,https://www.dropbox.com/s/4h4e559tggvk1cq/Class_CustomFont_Samples.7z?raw=1
if A_thisMenuItem=Script_alguimist
    run,https://autohotkey.com/boards/viewtopic.php?f=5&t=14838
if A_thisMenuItem=Ahk_Font_Help
   run,https://autohotkey.com/docs/misc/FontsStandard.htm
if A_thisMenuItem=otfinfo_Help
   run,http://www.lcdf.org/type/otfinfo.1.html
if A_thisMenuItem=otfinfo_Download
   run,http://math.sut.ac.th/lab/software/texlive/bin/win32/otfinfo.exe
if A_thisMenuItem=SKAN
   run,https://autohotkey.com/board/topic/29396-crazy-scripting-include-and-use-truetype-font-from-script/
if A_thisMenuItem=Latofonts
   run,http://www.latofonts.com/lato-free-fonts/
if A_thisMenuItem=Fontsquirrel
   run,http://www.fontsquirrel.com/tools/webfont-generator
if A_thisMenuItem=FontsOldSchool
   run,http://int10h.org/oldschool-pc-fonts/

Guicontrol,3:focus,st1
return

mh2:
if A_thisMenuItem=AHK_version
  msgbox, 262208,AHK_Version ,Ahk-Version =%A_AHKVERSION%
Guicontrol,3:focus,st1
return

mh3:
ifexist,C:\windows\fonts
    run,C:\windows\fonts
Guicontrol,3:focus,st1
return
;--------------------------------------------------------------


;----------- from user alguimist ------------------------------
;-https://autohotkey.com/boards/viewtopic.php?f=5&t=14838
functionx:
Global FontList := []
EnumFonts() {
    hDC := DllCall("GetDC", "UInt", DllCall("GetDesktopWindow"))
    Callback := RegisterCallback("EnumFontsCallback", "F")
    DllCall("EnumFontFamilies", "UInt", hDC, "UInt", 0, "Ptr", Callback, "UInt", lParam := 0)
    DllCall("ReleaseDC", "UInt", hDC)
}

EnumFontsCallback(lpelf) {
    FontList.Push(StrGet(lpelf + 28, 32))
    Return True
}

EnumFonts()
aa:=FontList.MaxIndex()
return
;--------------------------------------------------------------
;==============================================================
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: Installed Font Names

13 Mar 2016, 13:59

This is a modified version of the font dialog present in AutoGUI:

Code: Select all

; Alternative Font Dialog
#NoEnv
#Warn

Global hFontDlg := 0
Global FontList := []

Menu Tray, Icon, main.cpl, 4

GoSub ShowFontDialog
Return

ShowFontDialog:
    Gui FontDlg: New, LabelFontDlg hWndhFontDlg
    Gui Color, 0xFEFEFE

    Gui Add, CheckBox, vChkFontName gPreviewFont x10 y12 w152 h23, Font name:
    Gui Add, Edit, vEdtFontName gDisplayFontName x10 y38 w152 h23, Ms Shell Dlg
    Gui Add, ListBox, vLbxFontName gDisplayFontName x10 y66 w152 h160 -HScroll Sort

    Gui Add, CheckBox, vChkFontWeight gPreviewFont x170 y12 w100 h23, Weight:
    Gui Add, Edit, vEdtFontWeight gDisplayFontWeight x170 y38 w100 h23, Norm
    Gui Add, ListBox, vLbxFontWeight gDisplayFontWeight x170 y66 w100 h43, Regular|Semibold|Bold

    Gui Add, CheckBox, vChkFontSize gPreviewFont x278 y12 w60 h23, Size:
    Gui Add, Edit, vEdtFontSize gDisplayFontSize x278 y38 w60 h23, 8
    Gui Add, ListBox, vLbxFontSize gDisplayFontSize x278 y66 w60 h160, 8|9|10|11|12|13|14|15|16|17|18|20

    Gui Add, CheckBox, vChkFontColor gPreviewFont x346 y12 w60 h23, Color:
    Gui Add, ListView, vFontColorPreview gChooseFontColor x434 y14 w16 h16 -Hdr +Border AltSubmit
    Gui Add, ComboBox, vCbxFontColor gDisplayFontColor x346 y38 w106, 0x003399|0x0066CC|0x3399FF|0x1E75BB|0x0090B3|0x00AEFF
    Gui Add, ListBox, vLbxFontColor gDisplayFontColor x346 y66 w107 h160
    , Black|Blue|Navy|Green|Teal|Olive|Maroon|Red|Purple|Fuchsia|Lime|Yellow|Aqua|Gray|Silver|White

    Gui Add, CheckBox, vChkItalic gPreviewFont x170 y112 w100 h23, Italic
    Gui Add, CheckBox, vChkUnderline gPreviewFont x170 y134 w100 h23, Underline
    Gui Add, CheckBox, vChkStrikeout gPreviewFont x170 y156 w100 h23, Strikeout
    Gui Add, CheckBox, vChkQuality gPreviewFont x170 y180 w100 h21, Quality:
    Gui Add, DropDownList, vCbxQuality gCheckQuality x170 y205 w100 AltSubmit, Default||Draft|Proof|Non-antialiased|Antialiased|Cleartype

    Gui Add, Text, vSampleText gSetSampleText x10 y234 w443 h44 +0x201 +E0x200

    Gui Add, ListView, x-1 y286 w467 h49 Disabled
    Gui Add, Button, gFontDlgOK x154 y299 w75 h23 Default, &OK
    Gui Add, Button, gFontDlgClose x234 y299 w75 h23, &Cancel

    Gui Show, w464 h334, Font

    LoadFonts()

    PopulateDialogFields("Segoe UI", "s12 c0x003399", "Automation. Hotkeys. Scripting")
Return

FontDlgEscape:
FontDlgClose:
    ;Gui FontDlg: Cancel
    ExitApp
Return

LoadFonts() {
    EnumFonts()

    Loop % FontList.MaxIndex() {
        GuiControl,, LbxFontName, % FontList[A_Index]
    }

    GuiControl,, LbxFontName, Ms Shell Dlg
    GuiControl,, LbxFontName, Ms Shell Dlg 2
}

EnumFonts() {
    hDC := DllCall("GetDC", "UInt", DllCall("GetDesktopWindow"))
    Callback := RegisterCallback("EnumFontsCallback", "F")
    DllCall("EnumFontFamilies", "UInt", hDC, "UInt", 0, "Ptr", Callback, "UInt", lParam := 0)
    DllCall("ReleaseDC", "UInt", hDC)
}

EnumFontsCallback(lpelf) {
    FontList.Push(StrGet(lpelf + 28, 32))
    Return True
}

PreviewFont:
    Gui FontDlg: Default

    Gui Font ; Reset
    GuiControl Font, SampleText

    GetFontOptions(FontName, Options)

    Separator := ""
    If (Options != "" && FontName != "") {
        Separator := ", "
    }

    WinSetTitle % "Font: " . FontName . Separator . Options

    If (Options != "" || FontName != "") {
        Gui Font, %Options%, %FontName%
        GuiControl Font, SampleText
    }
Return

DisplayFontName:
    Gui FontDlg: Submit, NoHide

    GuiControl,, ChkFontName, 1
    If (A_GuiControl != "EdtFontName") {
        GuiControl,, EdtFontName, % LbxFontName
    } Else {
        GuiControl ChooseString, LbxFontName, % EdtFontName
    }

    GoSub PreviewFont
Return

DisplayFontWeight:
    Gui FontDlg: Submit, NoHide

    GuiControl,, ChkFontWeight, 1
    If (A_GuiControl != "EdtFontWeight") {
        Weight := LbxFontWeight
        If (Weight = "Regular") {
            Weight := "Norm"
        } Else If (Weight = "Semibold") {
            Weight := "600"
        } Else {
            Weight := "Bold"
        }
        GuiControl,, EdtFontWeight, % Weight
    } Else {
        Weight := EdtFontWeight
        If Weight is Integer
        {
            If (Weight < 551) {
                Weight := "Regular"
            } Else If (Weight > 550 && Weight < 612) {
                Weight := "Semibold"
            } Else {
                Weight := "Bold"
            }
        }
        GuiControl ChooseString, LbxFontWeight, % Weight
    }

    GoSub PreviewFont
Return

CheckQuality:
    GuiControl,, ChkQuality, 1
    GoSub PreviewFont
Return

DisplayFontSize:
    Gui FontDlg: Submit, NoHide

    GuiControl,, ChkFontSize, 1
    If (A_GuiControl != "EdtFontSize") {
        GuiControl,, EdtFontSize, % LbxFontSize
    } Else {
        GuiControl ChooseString, LbxFontSize, % EdtFontSize
    }

    GoSub PreviewFont
Return

DisplayFontColor:
    Gui FontDlg: Submit, NoHide

    GuiControl,, ChkFontColor, 1
    If (A_GuiControl != "CbxFontColor") {
        GuiControl Text, CbxFontColor, %LbxFontColor%
    }

    GoSub PreviewFont
Return

ChooseFontColor:
    If (A_GuiEvent = "Normal") {
        Color := "0x0080C0"
        If (ChooseColor(Color, hFontDlg)) {
            Gui FontDlg: Default
            GuiControl +Background%Color%, FontColorPreview
            GuiControl Text, CbxFontColor, %Color%
            GuiControl,, ChkFontColor, 1
            GoSub PreviewFont
        }
    }
Return

GetFontOptions(ByRef FontName, ByRef Options) {
    Global

    Gui FontDlg: Default
    Gui Submit, NoHide

    FontName := "", Options := ""

    If (ChkFontName) {
        FontName := EdtFontName
    }
    If (ChkFontSize) {
        If (EdtFontSize != "") {
            Options .= "s" . EdtFontSize . " "
        }
    }
    If (ChkFontWeight) {
        If EdtFontWeight is Integer
            Options .= "w"
        Options .= EdtFontWeight . " "
    }
    If (ChkItalic) {
        Options .= "Italic "
    }
    If (ChkUnderline) {
        Options .= "Underline "
    }
    If (ChkStrikeout) {
        Options .= "Strike "
    }
    If (ChkQuality) {
        Options .= "q" . (CbxQuality - 1) . " "
    }
    If (ChkFontColor) {
        If (CbxFontColor != "") {
            Options .= "c" . CbxFontColor
            GuiControl +Background%CbxFontColor%, FontColorPreview
        }
    }

    Options := RTrim(Options)
}

FontDlgOK:
    GetFontOptions(FontName, FontOptions)

    If (FontOptions != "") {
        FontOptions := " " . FontOptions
    }

    If (FontName != "") {
        FontName := ", " . FontName
    }

    Output := % "Gui Font," . FontOptions . FontName

    Clipboard := Output
    MsgBox 0, Font, Copied to the Clipboard:`n`n%Output%

    ;GoSub FontDlgClose
Return

SetSampleText:
    Gui +OwnDialogs
    InputBox, NewSampleText, Sample Text, New Text:,,,,,,,, Sample Text
    If (!ErrorLevel && NewSampleText != "") {
        GuiControl,, SampleText, %NewSampleText%
    }
Return

PopulateDialogFields(FontName, Options, Text := "Sample Text") {
    If (FontName != "") {
        GuiControl,, ChkFontName, 1
        GuiControl,, EdtFontName, % FontName
        GuiControl ChooseString, LbxFontName, % FontName
    }

    If (Options != "") {
        Options := StrSplit(Options, " ")
        Loop % Options.MaxIndex() {
            If (Options[A_Index] ~= "^w") {
                FontWeight := SubStr(Options[A_Index], 2)
                GuiControl,, ChkFontWeight, 1
                GuiControl,, EdtFontWeight, % FontWeight
                If (FontWeight < 551) {
                    GuiControl ChooseString, LbxFontWeight, Regular
                } Else If (FontWeight > 550 && FontWeight < 612) {
                    GuiControl ChooseString, LbxFontWeight, Semibold
                } Else {
                    GuiControl ChooseString, LbxFontWeight, Bold
                }
            }
            If (Options[A_Index] = "Bold") {
                GuiControl,, ChkFontWeight, 1
                GuiControl,, EdtFontWeight, Bold
                GuiControl ChooseString, LbxFontWeight, Bold
            }
            If (Options[A_Index] = "Italic") {
                GuiControl,, ChkItalic, 1
            }
            If (Options[A_Index] = "Underline") {
                GuiControl,, ChkUnderline, 1
            }
            If (Options[A_Index] = "Strike") {
                GuiControl,, ChkStrikeout, 1
            }
            If (Options[A_Index] ~= "^q") {
                FontQuality := SubStr(Options[A_Index], 2)
                GuiControl,, ChkQuality, 1
                GuiControl Choose, CbxQuality, % (FontQuality + 1)
            }
            If (Options[A_Index] ~= "^s") {
                FontSize := SubStr(Options[A_Index], 2)
                GuiControl,, ChkFontSize, 1
                GuiControl,, EdtFontSize, % FontSize
                GuiControl ChooseString, LbxFontSize, % FontSize
            }
            If (Options[A_Index] ~= "^c") {
                FontColor := SubStr(Options[A_Index], 2)
                GuiControl,, ChkFontColor, 1
                GuiControl ChooseString, LbxFontColor, % FontColor
                GuiControl Text, CbxFontColor, %FontColor%
            }
        }
    }

    If (Text != "") {
        GuiControl,, SampleText, %Text%
    }

    GoSub PreviewFont
}

ChooseColor(ByRef Color, hOwner := 0) {
    rgbResult := ((Color & 0xFF) << 16) + (Color & 0xFF00) + ((Color >> 16) & 0xFF)

    VarSetCapacity(CHOOSECOLOR, 36, 0)
    VarSetCapacity(CUSTOM, 64, 0)
    NumPut(36, CHOOSECOLOR, 0) ; DWORD lStructSize
    NumPut(hOwner, CHOOSECOLOR, 4)
    NumPut(rgbResult, CHOOSECOLOR, 12)
    NumPut(&CUSTOM, CHOOSECOLOR, 16) ; COLORREF *lpCustColors
    NumPut(0x103, CHOOSECOLOR, 20) ; Flags: CC_ANYCOLOR || CC_RGBINIT

    RetVal := DllCall("comdlg32\ChooseColorA", "Str", CHOOSECOLOR)
    If (ErrorLevel != 0) || (RetVal = 0) {
        Return False
    }

    rgbResult := NumGet(CHOOSECOLOR, 12)

    OldFormat := A_FormatInteger
    SetFormat Integer, Hex
    Color := (rgbResult & 0xFF00) + ((rgbResult & 0xFF0000) >> 16) + ((rgbResult & 0xFF) << 16)
    StringTrimLeft Color, Color, 2
    Loop % 6 - StrLen(Color) {
        Color := "0" . Color
    }
    Color := "0x" . Color
    SetFormat Integer, %OldFormat%
    Return True
}
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Installed Font Names

13 Mar 2016, 17:33

Wow! Thank you both. You've given me some ideas.

Further investigation has shown me that the "Too many fonts" error is still there. It takes a while to show up but it does. What I don't understand with my own experimentation is that even though a Gui is destroyed the font object is retained so I guess the only way is to create the Gui using a whole other script so that when the Gui is terminated the script is terminated. It would be useful if there were an easy way to terminate font objects. Hope I'm using the right terminology.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Shifted_Right and 190 guests