Get windows font details
Posted: Wed May 01, 2024 7:37 pm
I'd like to see all variations (and their names for LoadFont) of one (or all) installed font(s). Some font fmilies do have different types like bold, black, semibold, light, italics, etc.
The font family 'Courier New' has 4 types (regular, italics, bold, bold+italics) which is displayed in the windows font settings.
When enumerating this font family I do get a list of around 20 entries missing also more detailed information (see code)
The font family 'Courier New' has 4 types (regular, italics, bold, bold+italics) which is displayed in the windows font settings.
When enumerating this font family I do get a list of around 20 entries missing also more detailed information (see code)
Code: Select all
Procedure EnumFontInfo(*elfx.ENUMLOGFONTEX,*ntmx.NEWTEXTMETRICEX,FontType.i,lParam.i)
Debug Str(*ntmx\ntmTm\tmPitchAndFamily)+", "+Str(*ntmx\ntmTm\tmAveCharWidth)+"*"+Str(*ntmx\ntmTm\tmHeight)+", "+Str(*ntmx\ntmTm\tmWeight)+" : "+PeekS(@*elfx\elfLogFont\lfFaceName[0])
ProcedureReturn #True
EndProcedure
Procedure EnumFontList(font.s)
Protected FontLog.LOGFONT
Protected FontHDC
Protected Fontname.s
FontHDC=GetDC_(WinID)
FillMemory(@FontLog,SizeOf(LOGFONT))
FontLog\lfCharSet=#DEFAULT_CHARSET
PokeS(@FontLog\lfFaceName,font)
If EnumFontFamiliesEx_(FontHDC,@FontLog,@EnumFontInfo(),0,0)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
;Debug EnumFontList("")
Debug EnumFontList("Courier New")