Skip to content

Instantly share code, notes, and snippets.

@jenskutilek
Last active June 19, 2026 16:32
Show Gist options
  • Select an option

  • Save jenskutilek/153e7b115cb10d82e88588b61d0736b4 to your computer and use it in GitHub Desktop.

Select an option

Save jenskutilek/153e7b115cb10d82e88588b61d0736b4 to your computer and use it in GitHub Desktop.
TrueType Collection template for Hex Fiend
big_endian
section "Header"
ascii 4 ttcTag
set majorVersion [uint16 "majorVersion"]
uint16 minorVersion
set numFonts [uint32 "Number of Fonts"]
section "Font Offsets"
# -collapsed
set fonts {}
for {set idx 0} {$idx < $numFonts} {incr idx} {
section $idx
set offset [uint32 tableDirectoryOffset]
lappend fonts [list $idx $offset]
endsection
}
endsection
if {$majorVersion == 2} {
ascii 4 dsigTag
set dsig_length [uint32 dsigLength]
set offset [uint32 dsigOffset]
lappend fonts [list $idx $offset]
}
endsection
section "Fonts"
set previous_offset 0
set first 1
foreach font $fonts {
if {$first == 1} {
set first 0
set offset [lindex $font 1]
continue
}
set fontIndex [lindex $font 0]
section [expr $fontIndex - 1]
set next_offset [lindex $font 1]
goto $offset
set length [expr $next_offset - $offset]
entry "Offset" $offset
if {$length < 0} {
set length [expr [len] - $offset]
}
entry "Length" $length
hex $length "Data"
set offset $next_offset
endsection
}
endsection
if {$dsig_length != 0} {
section "DSIG Table"
goto $offset
uint32 version
set numSignatures [uint16 numSignatures]
uint16 flags
section "Signatures"
for {set idx 0} {$idx < $numSignatures} {incr idx} {
section [expr $idx]
uint32 format
uint32 length
set signatureBlockOffset [uint32 signatureBlockOffset]
goto [expr $offset + $signatureBlockOffset]
uint16 reserved1
uint16 reserved2
set signatureLength [uint32 signatureLength]
hex $signatureLength "ASN.1 Structure"
endsection
}
endsection
endsection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment