Advertisement
Guest User

Untitled

a guest
May 4th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. font := FileOpen("C:\Users\Jonny\Downloads\blasad\ACaslonPro-BoldItalic.otf", "r")
  2. otf := 1 ; set to 1 if using otf file, 0 for ttf
  3.  
  4. if !font ; error catching
  5. MsgBox % "Error " A_LastError
  6.  
  7. while font.ReadUInt() != 0x656D616E ; "name" table
  8. continue
  9. ;font.seek(0xCC)
  10. ;msgbox % font.ReadUInt()
  11.  
  12. font.Seek(4, 1) ; move to position of offset
  13.  
  14. offsetTable := font.ReadUInt() ; read offset of table
  15. offsetTable := DllCall("ntdll\RtlUlongByteSwap", "Uint", offsetTable, "Uint") ; fix endianness of bytes
  16.  
  17. font.Seek(offsetTable+4, 0) ; move to offset of name table entriees
  18. offsetEntries := font.ReadUShort() ; read offset of entries
  19. offsetEntries := DllCall("ntdll\RtlUshortByteSwap", "Ushort", offsetEntries, "Ushort")
  20.  
  21.  
  22. loop
  23. {
  24. font.Seek(6, 1) ; move to next nameID
  25. nameID := font.ReadUShort() ; read nameID
  26. nameID := DllCall("ntdll\RtlUshortByteSwap", "Uint", nameID, "Ushort")
  27. if (nameID = 0x00) ; act accordingly on nameID
  28. {
  29. font.seek(4, 1)
  30. continue
  31. }
  32. else if (nameID = 0x01) ; font family name
  33. nameLength := font.ReadUShort(), nameOffset := font.ReadUShort()
  34. else if (nameID = 0x02)
  35. subnameLength := font.ReadUShort(), subnameOffset := font.ReadUShort() ; font subfamily name
  36. else
  37. break
  38. }
  39.  
  40. nameLength := DllCall("ntdll\RtlUshortByteSwap", "Ushort", nameLength, "Ushort")
  41. nameOffset := DllCall("ntdll\RtlUshortByteSwap", "Ushort", nameOffset, "Ushort")
  42. subnameLength := DllCall("ntdll\RtlUshortByteSwap", "Ushort", subnameLength, "Ushort")
  43. subnameOffset := DllCall("ntdll\RtlUshortByteSwap", "Ushort", subnameOffset, "Ushort")
  44.  
  45. if otf {
  46. font.seek(offsetTable+offsetEntries+nameOffset, 0) ; move to name
  47. famName := font.Read(nameLength)
  48. font.seek(offsetTable+offsetEntries+subnameOffset, 0) ; move to subname
  49. subfamName := font.Read(subnameLength)
  50. } else {
  51. font.seek(offsetTable+offsetEntries+nameOffset+1, 0) ; move to name
  52. font.RawRead(name, nameLength)
  53. famName := StrGet(&name, nameLength, "utf-16")
  54. font.seek(offsetTable+offsetEntries+subnameOffset+1, 0) ; move to subname
  55. font.RawRead(subname, subnameLength)
  56. subfamName := StrGet(&subname, subnameLength, "utf-16")
  57. }
  58.  
  59. font.close()
  60.  
  61. MsgBox % "Name: " famName "`nSubname: " subfamName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement