Files

75 lines
3.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = "c:\Users\fdavalos\OneDrive - up.edu.mx\microtracking\MicrotrackingFer"
function BE16($b, $o) { ($b[$o] -shl 8) + $b[$o+1] }
function BE32($b, $o) { ($b[$o] -shl 24) + ($b[$o+1] -shl 16) + ($b[$o+2] -shl 8) + $b[$o+3] }
function Get-NameTable($path) {
$bytes = [IO.File]::ReadAllBytes($path)
$out = [PSCustomObject]@{ File = (Split-Path $path -Leaf); Size = $bytes.Length; NumTables='?'; NameOff='?'; Count='?'; FirstRecords='?'; Family='?'; Subfamily='?'; TyposFamily='?'; TyposSubfamily='?' }
if ($bytes.Length -lt 16) { $out.NumTables = 'toosmall'; return $out }
$num = BE16 $bytes 4
$out.NumTables = $num
$off = 12
$nameOff = -1
if ($num -gt 64) { $num = 64 }
for ($i=0; $i -lt $num; $i++) {
if ([Text.Encoding]::ASCII.GetString($bytes, $off, 4) -eq 'name') { $nameOff = BE32 $bytes ($off+8) }
$off += 16
}
$out.NameOff = $nameOff
if ($nameOff -lt 0) { $out.Count = 'none'; return $out }
$count = BE16 $bytes ($nameOff+2)
$strOff = BE16 $bytes ($nameOff+4)
$base = $nameOff + $strOff
$out.Count = $count
$res = @{}
$roff = $nameOff + 6
$shown = @()
for ($i=0; $i -lt $count; $i++) {
if ($roff + 12 -gt $bytes.Length) { break }
$pid_ = BE16 $bytes $roff
$eid = BE16 $bytes ($roff+2)
$lid = BE16 $bytes ($roff+4)
$nid = BE16 $bytes ($roff+6)
$len = BE16 $bytes ($roff+8)
$soff = BE16 $bytes ($roff+10)
if ($i -lt 10) { $shown += ("p=$pid_ e=$eid l=$lid n=$nid len=$len off=$soff") }
if ($pid_ -eq 3 -and $lid -eq 0x0409 -and $len -gt 0 -and ($base+$soff+$len) -le $bytes.Length) {
$s = [Text.Encoding]::Unicode.GetString($bytes, $base+$soff, $len)
$key = switch ($nid) { 1 {'Family'} 2 {'Subfamily'} 16 {'TyposFamily'} 17 {'TyposSubfamily'} default { $null } }
if ($key -and -not $res.ContainsKey($key)) { $res[$key] = $s }
}
$roff += 12
}
$out.FirstRecords = ($shown -join ' | ')
foreach ($k in $res.Keys) { if ($out.$k -eq '?') { $out.$k = $res[$k] } }
$out
}
$otfDir = "$root\tools\fonts\lm\fonts\opentype\public\lm"
Write-Output '=== [1] debug: key OTFs (raw first records + parsed names) ==='
@('lmroman10-regular.otf','lmroman10-italic.otf','lmmath.otf') | ForEach-Object {
$p = Join-Path $otfDir $_
if (Test-Path $p) { Get-NameTable $p | Format-List | Out-String -Width 200 | Write-Output }
else { Write-Output ("{0} : NOT PRESENT" -f $_) }
}
Write-Output '=== [2] families across all local OTFs ==='
Get-ChildItem $otfDir -Filter *.otf | ForEach-Object {
$r = Get-NameTable $_.FullName
"{0} / {1}" -f $r.Family, $r.Subfamily
} | Group-Object | Sort-Object Name | ForEach-Object { "{0} (x$($_.Count))" -f $_.Name }
Write-Output ''
Write-Output '=== [3] elsarticle/times .cls/.sty present in repo? ==='
Get-ChildItem $root -Include *.cls,*.sty -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match 'elsarticle|times' } |
Select-Object -ExpandProperty FullName
Write-Output ''
Write-Output '=== [4] bundle top structure (depth 3) ==='
Get-ChildItem (Join-Path $root 'tools\tectonic-src\bundle') -Depth 3 -ErrorAction SilentlyContinue |
Select-Object @{n='Rel';e={$_.FullName.Substring($root.Length+1)}}, PSIsContainer, Length |
Select-Object -First 45 Rel, PSIsContainer, Length |
Format-Table -AutoSize | Out-String -Width 170 | Write-Output