CONST HKEY_CLASSES_ROOT
= &H80000000~&
CONST HKEY_CURRENT_USER
= &H80000001~&
CONST HKEY_LOCAL_MACHINE
= &H80000002~&
CONST HKEY_USERS
= &H80000003~&
CONST HKEY_PERFORMANCE_DATA
= &H80000004~&
CONST HKEY_CURRENT_CONFIG
= &H80000005~&
CONST HKEY_DYN_DATA
= &H80000006~&
CONST REG_OPTION_VOLATILE
= 1 CONST REG_OPTION_NON_VOLATILE
= 0 CONST REG_CREATED_NEW_KEY
= 1 CONST REG_OPENED_EXISTING_KEY
= 2 CONST REG_DWORD_LITTLE_ENDIAN
= 4 ' value is defined REG_DWORD in Windows header files CONST REG_DWORD
= 4 ' 32-bit number CONST REG_DWORD_BIG_ENDIAN
= 5 ' some UNIX systems support big-endian architectures CONST REG_RESOURCE_LIST
= 8 CONST REG_FULL_RESOURCE_DESCRIPTOR
= 9 CONST REG_RESOURCE_REQUIREMENTS_LIST
= 10 CONST REG_QWORD_LITTLE_ENDIAN
= 11 ' 64-bit number in little-endian format CONST REG_QWORD
= 11 ' 64-bit number CONST REG_NOTIFY_CHANGE_NAME
= 1 CONST REG_NOTIFY_CHANGE_ATTRIBUTES
= 2 CONST REG_NOTIFY_CHANGE_LAST_SET
= 4 CONST REG_NOTIFY_CHANGE_SECURITY
= 8 CONST KEY_ALL_ACCESS
= &HF003F&
CONST KEY_CREATE_LINK
= &H0020&
CONST KEY_CREATE_SUB_KEY
= &H0004&
CONST KEY_ENUMERATE_SUB_KEYS
= &H0008&
CONST KEY_EXECUTE
= &H20019&
CONST KEY_NOTIFY
= &H0010&
CONST KEY_QUERY_VALUE
= &H0001&
CONST KEY_READ
= &H20019&
CONST KEY_SET_VALUE
= &H0002&
CONST KEY_WOW64_32KEY
= &H0200&
CONST KEY_WOW64_64KEY
= &H0100&
CONST KEY_WRITE
= &H20006&
CONST ERROR_FILE_NOT_FOUND
= &H2&
CONST ERROR_INVALID_HANDLE
= &H6&
CONST ERROR_MORE_DATA
= &HEA&
CONST ERROR_NO_MORE_ITEMS
= &H103&
CONST CF_APPLY
= &H200&
' Displays Apply button CONST CF_ANSIONLY
= &H400&
' list ANSI fonts only CONST CF_BOTH
= &H3&
' list both Screen and Printer fonts CONST CF_EFFECTS
= &H100&
' Display Underline and Strike Through boxes CONST CF_ENABLEHOOK
= &H8&
' set hook to custom template CONST CF_ENABLETEMPLATE
= &H10&
' enable custom template CONST CF_ENABLETEMPLATEHANDLE
= &H20&
CONST CF_FIXEDPITCHONLY
= &H4000&
' list only fixed-pitch fonts CONST CF_FORCEFONTEXIST
= &H10000&
' indicate error when font not listed is chosen CONST CF_INACTIVEFONTS
= &H2000000&
' display hidden fonts in Win 7 only CONST CF_INITTOLOGFONTSTRUCT
= &H40&
'use the structure pointed to by the lpLogFont member CONST CF_LIMITSIZE
= &H2000&
' select font sizes only within nSizeMin and nSizeMax members CONST CF_NOOEMFONTS
= &H800&
' should not allow vector font selections CONST CF_NOFACESEL
= &H80000&
' prevent displaying initial selection in font name combo box. CONST CF_NOSCRIPTSEL
= &H800000&
' Disables the Script combo box CONST CF_NOSIMULATIONS
= &H1000&
' Disables selection of font simulations CONST CF_NOSIZESEL
= &H200000&
' Disables Point Size selection CONST CF_NOSTYLESEL
= &H100000&
' Disables Style selection CONST CF_NOVECTORFONTS
= &H800&
CONST CF_NOVERTFONTS
= &H1000000&
CONST CF_PRINTERFONTS
= &H2&
' list fonts only supported by printer associated with the device CONST CF_SCALABLEONLY
= &H20000&
' select only vector fonts, scalable printer fonts, and TrueType fonts CONST CF_SCREENFONTS
= &H1&
' lists only the screen fonts supported by system CONST CF_SCRIPTSONLY
= &H400&
' lists all non-OEM, Symbol and ANSI sets only CONST CF_SELECTSCRIPT
= &H400000&
' can only use set specified in the Scripts combo box CONST CF_SHOWHELP
= &H4&
' displays Help button reference CONST CF_TTONLY
= &H40000&
' True Type only CONST CF_USESTYLE
= &H80&
' copies style data for the user's selection to lpszStyle buffer CONST CF_WYSIWYG
= &H8000&
' only list fonts available on both the printer and display CONST BOLD_FONTTYPE
= &H100&
CONST ITALIC_FONTTYPE
= &H200&
CONST PRINTER_FONTTYPE
= &H4000&
CONST REGULAR_FONTTYPE
= &H400&
CONST SCREEN_FONTTYPE
= &H2000&
CONST SIMULATED_FONTTYPE
= &H8000&
CONST FW_ULTRALIGHT
= 200 CONST DEFAULT_CHARSET
= 1 CONST GMEM_MOVEABLE
= &H2 CONST GMEM_ZEROINIT
= &H40 FUNCTION CommDlgExtendedError&
() ' 'dialog box error checking procedure nFontType
AS LONG ' if used as Unsigned Integer add Integer padder below lfItalic
AS _BYTE ' not 0 when user selected lfUnderline
AS _BYTE ' not 0 when user selected lfStrikeOut
AS _BYTE ' not 0 when user selected lfFaceName
AS STRING * 32 'contains name listed in dialog
'MAIN MODULE
_TITLE "LoadFont Test with Accurate Search" AGAIN:
_FONT16
f& = LoadFont
PRINT "This is "; FontName;
", loaded from "; selectedfont;
" in"; PointSize&;
"points" 'END MAIN MODULE
OPEN "F0NTList.INF" FOR OUTPUT AS #FONTFILE
'create a new file for font data Ky = HKEY_LOCAL_MACHINE
SubKey
= "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" + CHR$(0) Value
= SPACE$(261) 'ANSI Value name limit 260 chars + 1 null bData
= SPACE$(&H7FFF) 'arbitrary dwIndex = 0
PRINT #FONTFILE
, LEFT$(Value
, numTchars
) + "=" + formatData
(dwType
, numBytes
, bData
) dwIndex = dwIndex + 1
l = RegCloseKey(hKey)
CASE REG_SZ: whatType
= "REG_SZ" CASE REG_EXPAND_SZ: whatType
= "REG_EXPAND_SZ" CASE REG_BINARY: whatType
= "REG_BINARY" CASE REG_DWORD: whatType
= "REG_DWORD" CASE REG_DWORD_BIG_ENDIAN: whatType
= "REG_DWORD_BIG_ENDIAN" CASE REG_LINK: whatType
= "REG_LINK" CASE REG_MULTI_SZ: whatType
= "REG_MULTI_SZ" CASE REG_RESOURCE_LIST: whatType
= "REG_RESOURCE_LIST" CASE REG_FULL_RESOURCE_DESCRIPTOR: whatType
= "REG_FULL_RESOURCE_DESCRIPTOR" CASE REG_RESOURCE_REQUIREMENTS_LIST: whatType
= "REG_RESOURCE_REQUIREMENTS_LIST" CASE REG_QWORD: whatType
= "REG_QWORD" CASE HKEY_CLASSES_ROOT: whatKey
= "HKEY_CLASSES_ROOT" CASE HKEY_CURRENT_USER: whatKey
= "HKEY_CURRENT_USER" CASE HKEY_LOCAL_MACHINE: whatKey
= "HKEY_LOCAL_MACHINE" CASE HKEY_USERS: whatKey
= "HKEY_USERS" CASE HKEY_PERFORMANCE_DATA: whatKey
= "HKEY_PERFORMANCE_DATA" CASE HKEY_CURRENT_CONFIG: whatKey
= "HKEY_CURRENT_CONFIG" CASE HKEY_DYN_DATA: whatKey
= "HKEY_DYN_DATA" CASE REG_SZ
, REG_EXPAND_SZ
, REG_MULTI_SZ
formatData
= LEFT$(bData
, numBytes
- 1) formatData = t
SHARED FontColor&
, FontType$
, FontEff$
, PointSize
AS LONG 'shared with main program lfont.lfHeight = LF_DEFAULT ' determine default height ' set dailog box defaults
lfont.lfWidth = LF_DEFAULT ' determine default width
lfont.lfEscapement = LF_DEFAULT ' angle between baseline and escapement vector
lfont.lfOrientation = LF_DEFAULT ' angle between baseline and orientation vector
lfont.lfWeight = FW_REGULAR ' normal weight i.e. not bold
lfont.lfCharSet = DEFAULT_CHARSET ' use default character set
lfont.lfOutPrecision = LF_DEFAULT ' default precision mapping
lfont.lfClipPrecision = LF_DEFAULT ' default clipping precision
lfont.lfQuality = LF_DEFAULT ' default quality setting
lfont.lfPitchAndFamily
= LF_DEFAULT
OR FF_ROMAN
' default pitch, proportional with serifs lfont.lfFaceName
= "Calibri" + CHR$(0) ' string must be null-terminated cf.lStructSize
= LEN(cf
) ' size of structure cf.hwndOwner = hWnd ' window opening the dialog box
cf.iPointSize = 120 ' 12 point font (in units of 1/10 point)
cf.Flags
= CF_BOTH
OR CF_EFFECTS
OR CF_FORCEFONTEXIST
OR CF_INITTOLOGFONTSTRUCT
OR CF_LIMITSIZE
cf.rgbColors
= _RGB(238, 161, 50) cf.nFontType = REGULAR_FONTTYPE ' regular font type i.e. not bold or anything
cf.nSizeMin = 10 ' minimum point size
cf.nSizeMax = 72 ' maximum point size
IF ChooseFontA&
(_OFFSET(cf
)) <> 0 THEN ' 'Initiate Dialog and Read user selections ShowFont
= LEFT$(lfont.lfFaceName
, INSTR(lfont.lfFaceName
, CHR$(0)) - 1) IF cf.nFontType
AND BOLD_FONTTYPE
THEN FontType$
= "Bold" IF cf.nFontType
AND ITALIC_FONTTYPE
THEN FontType$
= FontType$
+ " Italic" IF cf.nFontType
AND REGULAR_FONTTYPE
THEN FontType$
= "Regular" IF lfont.lfUnderline
THEN FontEff$
= "Underline" IF lfont.lfStrikeOut
THEN FontEff$
= FontEff$
+ "Strikeout" PointSize = cf.iPointSize \ 10
ShowFont = ""
Font$
= ShowFont
(_WINDOWHANDLE) ' call Dialog Box and get the font selection i = i + 1
fontlist(i) = regfont$
FFont$ = Font$
a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
+ " " + FontType$
), Results
(), 1) 'test1 PRINT "="; Font$;
" "; FontType$
PRINT "Couldn't find it with first search, broadening" a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
+ " " + FontType$
), Results
(), 0) 'test2 PRINT "%"; Font$;
" "; FontType$
PRINT "Couldn't find it with second search, broadening" a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
+ " " + FontType$
), Results
(), 1) 'test3 a
= Array_String.FindAny
(fontlist
(), LEFT$(Font$
, INSTR(Font$
, " ")) + FontType$
, Results
(), 1) 'test3 PRINT "Couldn't find it with third search, broadening" a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
+ " " + FontType$
), Results
(), 0) 'test4 a
= Array_String.FindAny
(fontlist
(), LEFT$(Font$
, INSTR(Font$
, " ")) + FontType$
, Results
(), 0) 'test4 PRINT "Couldn't find it with fourth search, broadening" a = Array_String.FindAny(fontlist(), Font$, Results(), 1) 'test5
PRINT "Couldn't find it with fifth search, broadening" a = Array_String.FindAny(fontlist(), Font$, Results(), 0) 'test6
PRINT "Couldn't find it with sixth search, broadening" a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
), Results
(), 1) 'test7 a
= Array_String.FindAny
(fontlist
(), LEFT$(Font$
, INSTR(Font$
, " ")), Results
(), 1) 'test7 PRINT "Couldn't find it with seventh search, broadening" a
= Array_String.FindAny
(fontlist
(), String.Trim
(Font$
), Results
(), 0) 'test8 a
= Array_String.FindAny
(fontlist
(), LEFT$(Font$
, INSTR(Font$
, " ")), Results
(), 0) 'test8 PRINT "Couldn't find a suitable font matching that search term in all 8 searches" PRINT "Last ditch effort to find font" LastDitchEffort$
= LastDitch
(fontlist
(), String.Trim
(Font$
)) 'test9 LastDitchEffort$
= LastDitch
(fontlist
(), LEFT$(Font$
, INSTR(Font$
, " "))) 'test9 PRINT "Cannot find the font." 'PRINT "TRUE1"
'PRINT "TRUE2"
'PRINT "TRUE3"
'PRINT "TRUE4"
'PRINT "TRUE5"
'PRINT "TRUE5"
IF LastDitchEffort$
<> "" THEN selectedfont$ = fontlist(Array_String.FirstOrDefault(fontlist(), LastDitchEffort$, 1))
selectedfont$ = fontlist(Array_String.FirstOrDefault(fontlist(), Results(y).Result, 1))
FontName$
= LEFT$(selectedfont$
, INSTR(selectedfont$
, "=") - 1) selectedfont$
= RIGHT$(selectedfont$
, LEN(selectedfont$
) - INSTR(selectedfont$
, "=")) fontpath$
= ENVIRON$("SYSTEMROOT") + "\Fonts\" font&
= _LOADFONT(fontpath$
+ selectedfont$
, PointSize&
) font&
= _LOADFONT(fontpath$
+ selectedfont$
, PointSize&
, "BOLD,ITALIC") font&
= _LOADFONT(fontpath$
+ selectedfont$
, PointSize&
, "BOLD") font&
= _LOADFONT(fontpath$
+ selectedfont$
, PointSize&
, "ITALIC") font&
= _LOADFONT(fontpath$
+ selectedfont$
, PointSize&
) LoadFont = font&
LoadFont = 0
searchFont = Font
searchFont
= String.Insert
(searchFont
, " ", i
) a = Array_String.FirstOrDefault(fontlist(), searchFont, 1)
LastDitch$ = fontlist(a)
newchange$ = toChange
newchange$
= MID$(newchange$
, 1, position
- 1) + insert
+ MID$(newchange$
, position
, LEN(newchange$
) - position
+ 1) Results(x).Result = SearchArray(i)
Results(x).SearchArrayPosition = i
x = x + 1
IF SearchArray
(i
) = SearchString
THEN Results(x).Result = SearchArray(i)
Results(x).SearchArrayPosition = i
x = x + 1
Array_String.FindAny = x
Array_String.FirstOrDefault = i
IF SearchArray
(i
) = SearchString
THEN Array_String.FirstOrDefault = i