
LightningBit
Members-
Posts
8 -
Joined
-
Last visited
LightningBit's Achievements

Seeker (1/7)
0
Reputation
-
I found the problem I had this piece of code in my script $sFont = _WinAPI_GetFontResourceInfo($sFile, 1) If Not $sFont Then Exit Else ConsoleWrite("Debug : Found a good font!" & $sFile & @LF) EndIf this caused the script to exit with some fonts, although the font itself seemed fine I took it out and even the fonts on which the script did the exit, can be processed ok, so case closed for now I guess The complete testscript: #Include <Array.au3> #Include <File.au3> #Include <WinAPIEx.au3> #include <GUIConstantsEx.au3> #Include <FontConstants.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> Opt('MustDeclareVars', 1) ; Variable Declaration Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1, True) Global $FontList[UBound($FileList) - 1][2] Global $sFile = "" Global $sFont = "" ; Functions Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) If @error Then ConsoleWrite ("ERROR!!!") EndFunc ;==>FontGetInfoFromFile ;Main Application ConsoleWrite(" Testing filelist : " & UBound($FileList) & @LF) For $i = 1 To $FileList[0] $sFile = $FileList[$i] $sFont = _WinAPI_GetFontResourceInfo($sFile, 1) If Not $sFont Then Exit Else ConsoleWrite("Debug : Found a good font!" & $sFile & @LF) EndIf ConsoleWrite("Debug : Getting the data .... " & $i & @LF) FontGetInfoFromFile($sFile, 0, "Copyright") FontGetInfoFromFile($sFile, 1, "Font Family name") FontGetInfoFromFile($sFile, 2, "Font SubFamily name") FontGetInfoFromFile($sFile, 3, "Unique font identifier") FontGetInfoFromFile($sFile, 4, "Font full name") FontGetInfoFromFile($sFile, 5, "Version string") FontGetInfoFromFile($sFile, 6, "Postscript name") FontGetInfoFromFile($sFile, 7, "Trademark") FontGetInfoFromFile($sFile, 8, "Manufacturer Name") FontGetInfoFromFile($sFile, 9, "Designer") FontGetInfoFromFile($sFile, 10, "Description") FontGetInfoFromFile($sFile, 11, "URL Vendor") FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)") FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)") FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)") FontGetInfoFromFile($sFile, 19, "Sample text") FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name") FontGetInfoFromFile($sFile, 256, "Font-specific names") ConsoleWrite("Debug : Done getting the data .... " & @LF & @CRLF) ConsoleWrite(_WinAPI_GetLastError & @LF) Next
-
Hi, Thanks for looking into it the error is gone, but is it possible that it now exits the script completely (without error) when it comes across a font with an issue? when I ran the script, it just stopped after 24 fonts (here are over 4000 in the folder) I'll try to get more data the next few days --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Testing total number of fonts : 4799 Debug : Found a font!C:\DEV\TEST\FONTS\AbductionIV.ttf Debug : Getting the data .... 1 Font Family name = Abduction IV Font SubFamily name = Regular Debug : Done getting the data .... Debug : Found a font!C:\DEV\TEST\FONTS\Abe Regular.ttf Debug : Getting the data .... 2 Font Family name = Abe Font SubFamily name = Regular Debug : Done getting the data .... +>23:22:38 AutoIt3.exe ended.rc:0 +>23:22:38 AutoIt3Wrapper Finished. >Exit code: 0 Time: 2.065 Olivier
-
Hi, I attached 2 example fonts with the problem to my Original post here is my "test" script" #Include <Array.au3> #Include <File.au3> #Include <WinAPIEx.au3> #include <GUIConstantsEx.au3> #Include <FontConstants.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> Opt('MustDeclareVars', 1) ; Variable Declaration Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1, True) Global $FontList[UBound($FileList) - 1][2] Global $sFile = "" Global $sFont = "" ; Functions Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) If @error Then ConsoleWrite ("ERROR!!!") EndFunc ;==>FontGetInfoFromFile ;Main Application For $i = 1 To $FileList[0] $sFile = $FileList[$i] $sFont = _WinAPI_GetFontResourceInfo($sFile, 1) If Not $sFont Then Exit Else ConsoleWrite("Debug : Found a font!" & $sFile & @LF) EndIf ConsoleWrite("Debug : Getting the data .... " & @LF) FontGetInfoFromFile($sFile, 0, "Copyright") FontGetInfoFromFile($sFile, 1, "Font Family name") FontGetInfoFromFile($sFile, 2, "Font SubFamily name") FontGetInfoFromFile($sFile, 3, "Unique font identifier") FontGetInfoFromFile($sFile, 4, "Font full name") FontGetInfoFromFile($sFile, 5, "Version string") FontGetInfoFromFile($sFile, 6, "Postscript name") FontGetInfoFromFile($sFile, 7, "Trademark") FontGetInfoFromFile($sFile, 8, "Manufacturer Name") FontGetInfoFromFile($sFile, 9, "Designer") FontGetInfoFromFile($sFile, 10, "Description") FontGetInfoFromFile($sFile, 11, "URL Vendor") FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)") FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)") FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)") FontGetInfoFromFile($sFile, 19, "Sample text") FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name") FontGetInfoFromFile($sFile, 256, "Font-specific names") ConsoleWrite("Debug : Done getting the data .... " & @LF & @CRLF) ConsoleWrite(_WinAPI_GetLastError & @LF) Next
-
Hi, I've a script, using WinAPIGdi, checking info on font files for some files, I get the error "C:\DEV\AutoIt3\Include\WinAPIGdi.au3" (2480) : ==> Variable must be of type "Object".: and then the script stops. Is there a way I can either "catch" that error, and let my script continue with the next file or improve something in the WinAPIGdi script? I've searched the forums on error handling, but couldn't immediately find something related tho errors like these which are hardstopping the script P.S. : I'm an AutoIT script newbie..... snippet from WinAPIGdi, line 2480 from the error is this one: $sResult = $tResult.szTTFName ; #FUNCTION# ==================================================================================================================== ; Author ........: funkey ; Modified ......: UEZ, jpm ; =============================================================================================================================== Func _WinAPI_GetFontMemoryResourceInfo($pMemory, $iFlag = 1) Local Const $tagTT_OFFSET_TABLE = "USHORT uMajorVersion;USHORT uMinorVersion;USHORT uNumOfTables;USHORT uSearchRange;USHORT uEntrySelector;USHORT uRangeShift" Local Const $tagTT_TABLE_DIRECTORY = "char szTag[4];ULONG uCheckSum;ULONG uOffset;ULONG uLength" Local Const $tagTT_NAME_TABLE_HEADER = "USHORT uFSelector;USHORT uNRCount;USHORT uStorageOffset" Local Const $tagTT_NAME_RECORD = "USHORT uPlatformID;USHORT uEncodingID;USHORT uLanguageID;USHORT uNameID;USHORT uStringLength;USHORT uStringOffset" Local $tTTOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pMemory) Local $iNumOfTables = _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uNumOfTables")) ;check is this is a true type font and the version is 1.0 If Not (_WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMajorVersion")) = 1 And _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMinorVersion")) = 0) Then Return SetError(1, 0, "") Local $iTblDirSize = DllStructGetSize(DllStructCreate($tagTT_TABLE_DIRECTORY)) Local $bFound = False, $iOffset, $tTblDir For $i = 0 To $iNumOfTables - 1 $tTblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pMemory + DllStructGetSize($tTTOffsetTable) + $i * $iTblDirSize) If StringLeft(DllStructGetData($tTblDir, "szTag"), 4) = "name" Then $bFound = True $iOffset = _WinAPI_SwapDWord(DllStructGetData($tTblDir, "uOffset")) ExitLoop EndIf Next If Not $bFound Then Return SetError(2, 0, "") Local $tNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pMemory + $iOffset) Local $iNTHeaderSize = DllStructGetSize($tNTHeader) Local $iNRCount = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uNRCount")) Local $iStorageOffset = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uStorageOffset")) Local $iTTRecordSize = DllStructGetSize(DllStructCreate($tagTT_NAME_RECORD)) Local $tResult, $sResult, $iStringLength, $iStringOffset, $iEncodingID, $tTTRecord For $i = 0 To $iNRCount - 1 $tTTRecord = DllStructCreate($tagTT_NAME_RECORD, $pMemory + $iOffset + $iNTHeaderSize + $i * $iTTRecordSize) If _WinAPI_SwapWord($tTTRecord.uNameID) = $iFlag Then ;1 says that this is font name. 0 for example determines copyright info $iStringLength = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringLength")) $iStringOffset = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringOffset")) $iEncodingID = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uEncodingID")) Local $sWchar = "char" If $iEncodingID = 1 Then $sWchar = "word" $iStringLength = $iStringLength / 2 EndIf $tResult = DllStructCreate($sWchar & " szTTFName[" & $iStringLength & "]", $pMemory + $iOffset + $iStringOffset + $iStorageOffset) If $iEncodingID = 1 Then $sResult = "" For $j = 1 To $iStringLength $sResult &= ChrW(_WinAPI_SwapWord(DllStructGetData($tResult, 1, $j))) Next Else $sResult = $tResult.szTTFName EndIf If StringLen($sResult) > 0 Then ExitLoop EndIf Next Return $sResult EndFunc ;==>_WinAPI_GetFontMemoryResourceInfo the function in my script: Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) If @error Then ConsoleWrite ("ERROR!!!") EndFunc ;==>FontGetInfoFromFile and _WinAPI_GetFontResourceInfo uses _WinAPI_GetFontMemoryResourceInfo as you know any help or hints are welcome Babylon5.ttf Bahamas.ttf
-
Jos, I was thinking the same, changing it like this works also: I tested witn one file, but there I realized, I was indeed using the full path, so I looked at the options for the FileListToArray function, and I saw you it defaults to "return the filename only" (= the False setting) so adding "True", it now returns the full path & filename $bReturnPath [optional] If True the full path is appended to the file\folder path, otherwise it is relative to the $sFilePath folder. Default is False. Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1, True) Thanks for helping! Now I came across the next issue : some fonts seem to give issues when extracting certain data : ConsoleWrite("Debug : Getting the data .... " & @LF) ;~ FontGetInfoFromFile($sFile, 0, "Copyright") FontGetInfoFromFile($sFile, 1, "Font Family name") FontGetInfoFromFile($sFile, 2, "Font SubFamily name") FontGetInfoFromFile($sFile, 3, "Unique font identifier") FontGetInfoFromFile($sFile, 4, "Font full name") ;~ FontGetInfoFromFile($sFile, 5, "Version string") FontGetInfoFromFile($sFile, 6, "Postscript name") FontGetInfoFromFile($sFile, 7, "Trademark") FontGetInfoFromFile($sFile, 8, "Manufacturer Name") FontGetInfoFromFile($sFile, 9, "Designer") FontGetInfoFromFile($sFile, 10, "Description") FontGetInfoFromFile($sFile, 11, "URL Vendor") FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)") FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)") FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)") FontGetInfoFromFile($sFile, 19, "Sample text") FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name") FontGetInfoFromFile($sFile, 256, "Font-specific names") ConsoleWrite("Debug : Done getting the data .... " & @LF & @CRLF) ConsoleWrite(_WinAPI_GetLastError & @LF) this is the function Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) EndFunc ;==>FontGetInfoFromFile notice the 2 lines commented out : this works fine on a list of fonts this is the result : Debug : Found a font!C:\DEV\TEST\FONTS\Badmann.ttf Debug : Getting the data .... Font Family name = Badmann Font SubFamily name = Regular Unique font identifier = ALLTYPE:Badmann Regular:ATECH Font full name = Badmann Postscript name = Badmann Debug : Done getting the data .... Debug : Found a font!C:\DEV\TEST\FONTS\Bahamas.ttf Debug : Getting the data .... Font Family name = Bahamas Font SubFamily name = Plain Unique font identifier = Bahamas Plain Font full name = Bahamas Plain: Postscript name = BahamasPlain Debug : Done getting the data .... when I uncomment any of those 2 lines : Debug : Found a font!C:\DEV\TEST\FONTS\Badmann.ttf Debug : Getting the data .... Font Family name = Badmann Font SubFamily name = Regular Unique font identifier = ALLTYPE:Badmann Regular:ATECH Font full name = Badmann Version string = Converted from C:\TTFONTS\Badmann.TF1 by ALLTYPE Postscript name = Badmann Debug : Done getting the data .... Debug : Found a font!C:\DEV\TEST\FONTS\Bahamas.ttf Debug : Getting the data .... Font Family name = Bahamas Font SubFamily name = Plain Unique font identifier = Bahamas Plain Font full name = Bahamas Plain: "C:\DEV\AutoIt3\Include\WinAPIGdi.au3" (2480) : ==> Variable must be of type "Object".: $sResult = $tResult.szTTFName $sResult = $tResult^ ERROR Anyone any idea? I attached 2 fonts which are having the issue, if you want to test it yourself thanks L. Bahamas.ttf Babylon5.ttf
-
Hi, I've a collection of folders with fonts, which are not installed What I wanted todo is to extra some of the font information from each font file file. I found the WinAPIEx and the example scripts, and they work nicely on the installed fonts, but not on a directory of non-installed fonts when I use the below (for the installed fonts) the array contains the filename and fontname as expected #Include <Array.au3> #Include <File.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $FileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1) Global $FontList[UBound($FileList) - 1][2] For $i = 1 To $FileList[0] $FontList[$i - 1][0] = $FileList[$i] $FontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($FileList[$i], 1) Next _ArrayDisplay($FontList, '_WinAPI_GetFontResourceInfo')when I change the path to a local folder Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1) then the array contains only the filename, the fontname remains empty I also tried with the other examples (example 3 here: https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_GetFontResourceInfo.htm ) but the same result, the rest of the info remains empty anyone who can help a little? the test machine : - autoit-v3.3.15.0-beta - with WinAPIEx built in - Windows 8.1 Pro x64 Thank you