40 lines
2.0 KiB
PowerShell
40 lines
2.0 KiB
PowerShell
Write-Output '=== TRACE: lmroman10-regular.otf record-by-record ==='
|
|
function R16([byte[]]$b, [int]$p) { return [int]($b[$p]) -shl 8 -bor [int]$b[$p+1] }
|
|
function R32([byte[]]$b, [int]$p) { return ([int]$b[$p] -shl 24) -bor ([int]$b[$p+1] -shl 16) -bor ([int]$b[$p+2] -shl 8) -bor [int]$b[$p+3] }
|
|
|
|
$p = "c:\Users\fdavalos\OneDrive - up.edu.mx\microtracking\MicrotrackingFer\tools\fonts\lm\fonts\opentype\public\lm\lmroman10-regular.otf"
|
|
$b = [IO.File]::ReadAllBytes($p)
|
|
$nameOff = -1
|
|
$numTables = R16 $b 4
|
|
for ($i = 0; $i -lt $numTables; $i++) {
|
|
$rec = 12 + $i * 16
|
|
$tag = [Text.Encoding]::ASCII.GetString($b, $rec, 4)
|
|
if ($tag -eq 'name') { $nameOff = R32 $b ($rec + 8) }
|
|
}
|
|
$base = $nameOff
|
|
$count = R16 $b ($base + 2)
|
|
$recordsEnd = 6 + $count * 12
|
|
$strOff32 = R32 $b ($base + 4)
|
|
if ($strOff32 -ge $recordsEnd -and ($base + $strOff32) -le $b.Length) { $strOff = $strOff32; $how = '32bit' } else { $strOff = R16 $b ($base + 4); $how = '16bit' }
|
|
$strBase = $base + $strOff
|
|
Write-Output ("base={0} count={1} strOff32={2} strOff={3} ({4}) strBase={5} fileSize={6}" -f $base, $count, $strOff32, $strOff, $how, $strBase, $b.Length)
|
|
for ($i = 0; $i -lt $count; $i++) {
|
|
$r = $base + 6 + $i * 12
|
|
$raw = ''
|
|
for ($k = 0; $k -lt 12; $k++) { $raw += ('{0:x2} ' -f $b[$r+$k]) }
|
|
$plat = R16 $b $r
|
|
$lang = R16 $b ($r + 4)
|
|
$id = R16 $b ($r + 6)
|
|
$len = R16 $b ($r + 8)
|
|
$off = R16 $b ($r + 10)
|
|
$route = 'ignored'
|
|
if ($plat -eq 3 -and $lang -eq 0x0409) { $route = 'WIN' } elseif ($plat -eq 1) { $route = 'MAC' }
|
|
$cu = ''
|
|
if ($len -gt 0 -and ($strBase + $off + $len) -le $b.Length) {
|
|
$b2 = New-Object byte[] $len
|
|
[Array]::Copy($b, $strBase + $off, $b2, 0, $len)
|
|
$t = [Text.Encoding]::Unicode.GetString($b2)
|
|
for ($k = 0; $k -lt $t.Length -and $k -lt 12; $k++) { $cu += ('{0:x4} ' -f [int]$t[$k]) }
|
|
}
|
|
Write-Output ("[{0,2}] raw={1}| plat={2} lang={3} id={4} len={5} off={6} -> {7} | codeunits: {8}" -f $i, $raw, $plat, $lang, $id, $len, $off, $route, $cu)
|
|
} |