Initial source release
This commit is contained in:
commit
11301fae04
55 files changed
+2652
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# Подбор шрифта по ширине строки "Kaspersky Rescue Disk 18" на Main1.bmp.
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
$img = [System.Drawing.Image]::FromFile('F:\efi\Paravis\Boot\xor\Main1.bmp')
|
||||
$bmp = New-Object System.Drawing.Bitmap $img
|
||||
|
||||
# область строки Kaspersky (y 478..505), без хоткея (x до 415)
|
||||
$minX = 9999; $maxX = -1; $minY = 9999; $maxY = -1
|
||||
for ($y = 476; $y -le 506; $y++) {
|
||||
for ($x = 40; $x -le 415; $x++) {
|
||||
$c = $bmp.GetPixel($x, $y)
|
||||
if ($c.R + $c.G + $c.B -lt 500) {
|
||||
if ($x -lt $minX) { $minX = $x }; if ($x -gt $maxX) { $maxX = $x }
|
||||
if ($y -lt $minY) { $minY = $y }; if ($y -gt $maxY) { $maxY = $y }
|
||||
}
|
||||
}
|
||||
}
|
||||
"--- текст 'Kaspersky Rescue Disk 18': x {0}..{1} (ширина {2}), y {3}..{4}" -f $minX,$maxX,($maxX-$minX+1),$minY,$maxY
|
||||
$targetW = $maxX - $minX + 1
|
||||
|
||||
$text = 'Kaspersky Rescue Disk 18'
|
||||
$emSizes = 21.63, 22.0, 21.0, 22.95
|
||||
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||
$g.TextRenderingHint = 'AntiAlias'
|
||||
$fmt = [System.Drawing.StringFormat]::GenericTypographic
|
||||
$res = @()
|
||||
foreach ($fam in [System.Drawing.FontFamily]::Families) {
|
||||
foreach ($style in @('Regular','Bold')) {
|
||||
try {
|
||||
$f = New-Object System.Drawing.Font $fam, 21.63, ([System.Drawing.FontStyle]::$style), ([System.Drawing.GraphicsUnit]::Pixel)
|
||||
$sz = $g.MeasureString($text, $f, 10000, $fmt)
|
||||
$res += [pscustomobject]@{ Family = $fam.Name; Style = $style; Width = [math]::Round($sz.Width,1); Diff = [math]::Round([math]::Abs($sz.Width - $targetW),1) }
|
||||
$f.Dispose()
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
$g.Dispose(); $bmp.Dispose(); $img.Dispose()
|
||||
"--- цель: {0} px" -f $targetW
|
||||
$res | Sort-Object Diff | Select-Object -First 12 | Format-Table -AutoSize
|
||||
Reference in new issue
Block a user