Jump to content

Font: obtain info from file


Recommended Posts

Hello,

script some code that align font on my lan computers.

Is there any Autoit code to obtain info about font file?

(not Windows machine installed ones, but for given file, eg: fontinfo.exe AdobeSongStd-Light.otf)

thank you,

m.

Link to comment
Share on other sites

  • Moderators

What info are you after? Look in the help file under FileGet...

Ex:

FileGetAttrib
FileGetEncoding
FileGetLongName
FileGetSize
FileGetTime
FileGetVersion

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Are you looking for:

_WinAPI_GetFontResourceInfo

? :)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Thank you both for reply,

_WinAPI_GetFontResourceInfo it's what i need to obtain 'internal' font name

which are supported font ?

Can post any working code for guide tip :

To retrieve a fontname whose information comes from several resource files, they must be separated by a "|" .
For example, abcxxxxx.pfm | abcxxxxx.pfb.

Sorry for bad request and thank you again for support,

m.

Link to comment
Share on other sites

No problem. :)

Have you looked at the example in the helpfile?

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Hello,

I can not guess the syntax.... :

#include <APIShellExConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <MsgBoxConstants.au3>


Local Const $sMessage = "Select FONTs folder"
Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
If @error Then
    ; Display the error message.
    MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
EndIf



Dim $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
$sourcedir = $sFileSelectFolder & "\"

Local $sFileList = _FileListToArray($sourcedir, '*.*', 1)
Local $aFontList[UBound($sFileList) - 1][2]

For $i = 1 To $sFileList[0]
    Local $aPathSplit = _PathSplit($sourcedir & $sFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)


    if $sExtension = ".pfb" Then
        MsgBox(0,"[" & $sourcedir & "] " & $sExtension & " : " & $sFileList[$i], $sFilename & ".pfm | " & $sFilename & ".pfb")
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFilename & ".pfm | " & $sFilename & ".pfb", 1)

    Else

        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], 1)
    EndIf
Next

_ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo')

doesn't works for .pfb | .pfm fonts. Anyone can correct script please ?

Link to comment
Share on other sites

You probably can't get the font information from those files, they're postscript files and aren't standard Windows fonts.

BTW, the PFB and PFM files are two parts of the same font, you need both together, they're not individual font files.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What is the error received back from _WinAPI_GetFontResourceInfo when it fails?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hello,

@error is set to 20. Can't find any explanation in guide:

#include <APIShellExConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <MsgBoxConstants.au3>


Local Const $sMessage = "Select FONTs folder"
Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
If @error Then
    ; Display the error message.
    MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
EndIf



Dim $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
$sourcedir = $sFileSelectFolder & "\"

Local $sFileList = _FileListToArray($sourcedir, '*.*', 1)
Local $aFontList[UBound($sFileList) - 1][2]

For $i = 1 To $sFileList[0]
    Local $aPathSplit = _PathSplit($sourcedir & $sFileList[$i], $sDrive, $sDir, $sFilename, $sExtension)

    if $sExtension = ".pfb" Then
        MsgBox(0,"[" & $sourcedir & "] " & $sExtension & " : " & $sFileList[$i], $sFilename & ".pfm | " & $sFilename & ".pfb")
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFilename & ".pfm | " & $sFilename & ".pfb", 1)
        if @error then MsgBox(0,"",@error)

    Else

        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], 1)
    EndIf
Next

_ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo')

m.

Link to comment
Share on other sites

Use:

_WinAPI_GetLastError

Returns the calling thread's last error code value. 

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...