Font Exists Function
Posted: Fri Jan 06, 2006 8:59 pm
Code updated for 5.20+
I messed with some code from El_Choni ( viewtopic.php?t=2732 ) in order to change it from a simple enumeration function into a function to test whether a font name exists. Nothing special but here you go.
I messed with some code from El_Choni ( viewtopic.php?t=2732 ) in order to change it from a simple enumeration function into a function to test whether a font name exists. Nothing special but here you go.
Code: Select all
Procedure EnumFontExists(*lpelf.ENUMLOGFONT, *lpntm.NEWTEXTMETRIC, FontType, lParam)
;
If LCase(PeekS(lParam)) = LCase(PeekS(@*lpelf\elfLogFont\lfFaceName[0])) : ProcedureReturn 0 : EndIf
;
ProcedureReturn #True
;
EndProcedure
Procedure.b ExistsFont(FontName.s)
;
hWnd = GetDesktopWindow_()
;
hDC = GetDC_(hWnd)
;
lResult = EnumFontFamilies_(hDC, 0, @EnumFontExists(), @FontName)
;
ReleaseDC_ (hWnd, hDC)
;
If lResult : ProcedureReturn #False : Else : ProcedureReturn #True : EndIf
;
EndProcedure
Debug ExistsFont("Arial")
Debug ExistsFont("Test")