Jump to content

Search the Community

Showing results for tags 'Truetype font fontname'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi, I needed a function to get the fontname by a pointer to the ttf file. Here is the solution: #include <WinAPIEx.au3> #include <Memory.au3> Global $hFile, $lFile, $tBuffer, $pBuffer, $iFile Global $sFile = FileOpenDialog("Choose Truetype Font", @ScriptDir, "Truetype Font (*.ttf)", 3) If @error Then Exit 1 $hFile = _WinAPI_CreateFile($sFile, 2, 2) If $hFile = 0 Then Exit 2 $lFile = FileGetSize($sFile) $tBuffer = DllStructCreate("byte[" & $lFile + 1 & "]") $pBuffer = DllStructGetPtr($tBuffer) _WinAPI_ReadFile($hFile, $pBuffer, $lFile, $iFile) _WinAPI_CloseHandle($hFile) MsgBox(64, "Font info", _ 'Filename: "' & $sFile & '"' & @CRLF & @CRLF & _ "Copyright notice: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 0) & @CRLF & _ "Font Family name: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 1) & @CRLF & _ "Font Subfamily name: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 2) & @CRLF & _ "Unique font identifier: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 3) & @CRLF & _ "Full font name: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 4) & @CRLF & _ "Version string: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 5) & @CRLF & _ "Postscript name for the font: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 6) & @CRLF & _ "Description: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 10) & @CRLF & _ "URL Vendor: " & _GetFontInfoFromFilePtr($pBuffer, $lFile, 11) & @CRLF) #cs Table 'name' Id Meaning 0 Copyright notice 1 Font Family name. 2 Font Subfamily name. Font style (italic, oblique) and weight (light, bold, black, etc.). A font with no particular differences in weight or style (e.g. medium weight, not italic) should have the string "Regular" stored in this position. 3 Unique font identifier. Usually similar to 4 but with enough additional information to be globally unique. Often includes information from Id 8 and Id 0. 4 Full font name. This should be a combination of strings 1 and 2. Exception: if the font is “Regular” as indicated in string 2, then use only the family name contained in string 1. This is the font name that Windows will expose to users. 5 Version string. Must begin with the syntax ‘Version n.nn ‘ (upper case, lower case, or mixed, with a space following the number). 6 Postscript name for the font. 7 Trademark. Used to save any trademark notice/information for this font. Such information should be based on legal advice. This is distinctly separate from the copyright. 8 Manufacturer Name. 9 Designer. Name of the designer of the typeface. 10 Description. Description of the typeface. Can contain revision information, usage recommendations, history, features, etc. 11 URL Vendor. URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font. 12 URL Designer. URL of typeface designer (with protocol, e.g., http://, ftp://). 13 License description. Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese. 14 License information URL. Where additional licensing information can be found. 15 Reserved; Set to zero. 16 Preferred Family (Windows only). In Windows, the Family name is displayed in the font menu. The Subfamily name is presented as the Style name. For historical reasons, font families have contained a maximum of four styles, but font designers may group more than four fonts to a single family. The Preferred Family and Preferred Subfamily IDs allow font designers to include the preferred family/subfamily groupings. These IDs are only present if they are different from IDs 1 and 2. 17 Preferred Subfamily (Windows only). See above. 18 Compatible Full (Mac OS only). On the Mac OS, the menu name is constructed using the FOND resource. This usually matches the Full Name. If you want the name of the font to appear differently than the Full Name, you can insert the Compatible Full Name here. 19 Sample text. This can be the font name, or any other text that the designer thinks is the best sample text to show what the font looks like. 20 PostScript CID findfont name. 21-255 Reserved for future expansion. 256-32767 Font-specific names. http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08 #ce Func _GetFontInfoFromFilePtr($pData, $iLen, $iID = 1) ;funkey 2012, May 15 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 $tFile = DllStructCreate("byte[" & $iLen & "]") Local $pFile = DllStructGetPtr($tFile) _MemMoveMemory($pData, $pFile, $iLen) ;copy data to new memory area Local $ttOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pFile) DllStructSetData($ttOffsetTable, "uNumOfTables", _SWAPWORD(DllStructGetData($ttOffsetTable, "uNumOfTables"))) DllStructSetData($ttOffsetTable, "uMajorVersion", _SWAPWORD(DllStructGetData($ttOffsetTable, "uMajorVersion"))) DllStructSetData($ttOffsetTable, "uMinorVersion", _SWAPWORD(DllStructGetData($ttOffsetTable, "uMinorVersion"))) ;check is this is a true type font and the version is 1.0 If StringFormat("%i.%i", DllStructGetData($ttOffsetTable, "uMajorVersion"), DllStructGetData($ttOffsetTable, "uMinorVersion")) <> "1.0" Then Return SetError(1) EndIf Local $tblDir = DllStructCreate($tagTT_TABLE_DIRECTORY) Local $bFound = False Local $sTemp For $i = 0 To DllStructGetData($ttOffsetTable, "uNumOfTables") - 1 $tblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pFile + DllStructGetSize($ttOffsetTable) + $i * DllStructGetSize($tblDir)) If StringLeft(DllStructGetData($tblDir, "szTag"), 4) = "name" Then $bFound = True DllStructSetData($tblDir, "uLength", _SWAPLONG(DllStructGetData($tblDir, "uLength"))) DllStructSetData($tblDir, "uOffset", _SWAPLONG(DllStructGetData($tblDir, "uOffset"))) ExitLoop EndIf Next If Not $bFound Then Return SetError(2) Local $ttNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pFile + DllStructGetData($tblDir, "uOffset")) DllStructSetData($ttNTHeader, "uNRCount", _SWAPWORD(DllStructGetData($ttNTHeader, "uNRCount"))) DllStructSetData($ttNTHeader, "uStorageOffset", _SWAPWORD(DllStructGetData($ttNTHeader, "uStorageOffset"))) Local $ttRecord = DllStructCreate($tagTT_NAME_RECORD) Local $tResult, $sResult For $i = 0 To DllStructGetData($ttNTHeader, "uNRCount") - 1 $ttRecord = DllStructCreate($tagTT_NAME_RECORD, $pFile + DllStructGetData($tblDir, "uOffset") + DllStructGetSize($ttNTHeader) + $i * DllStructGetSize($ttRecord)) DllStructSetData($ttRecord, "uNameID", _SWAPWORD(DllStructGetData($ttRecord, "uNameID"))) If DllStructGetData($ttRecord, "uNameID") = $iID Then DllStructSetData($ttRecord, "uStringLength", _SWAPWORD(DllStructGetData($ttRecord, "uStringLength"))) DllStructSetData($ttRecord, "uStringOffset", _SWAPWORD(DllStructGetData($ttRecord, "uStringOffset"))) $tResult = DllStructCreate("char [" & DllStructGetData($ttRecord, "uStringLength") & "]", $pFile + _ DllStructGetData($tblDir, "uOffset") + DllStructGetData($ttRecord, "uStringOffset") + _ DllStructGetData($ttNTHeader, "uStorageOffset")) $sResult = DllStructGetData($tResult, 1) If StringLen($sResult) > 0 Then ExitLoop EndIf Next Return $sResult EndFunc ;==>_GetFontInfoFromFilePtr Func _SWAPWORD($x) Return _WinAPI_MakeWord(_WinAPI_LoByte($x), _WinAPI_HiByte($x)) EndFunc ;==>_SWAPWORD Func _SWAPLONG($x) Return _WinAPI_MakeLong(_SWAPWORD(_WinAPI_HiWord($x)), _SWAPWORD(_WinAPI_LoWord($x))) EndFunc ;==>_SWAPLONG Edit: Added additional information
×
×
  • Create New...