$regexColor = New-Object Text.RegularExpressions.Regex -ArgumentList "([\\d\\.]+\\s){3}C"
$regexEmptyShape = New-Object Text.RegularExpressions.Regex -ArgumentList "([\\d\\.]+\\s){2}(\\w+)E"
$script:newColor = $false
function f($l)
{
# マイナス記号の修正
$l = ($l -replace "\\(-([\\d\\.]+)\\)","(ア`$1)")
# /CircE は都合が悪いので CircleE に変更
$l = ($l -replace "CircE","CircleE")
# 色の更新があるかどうか
$m = $regexColor.Match($l)
if ($m.Success)
{
$script:color = $m.Captures[0].Value
$script:newColor = $true
}
# 空の図形があれば先に塗潰し図形を描画するように変更
$m = $regexEmptyShape.Match($l)
if ($m.Success)
{
$b = New-Object Text.StringBuilder
if ($script:newColor)
{
"closepath stroke"
$script:newColor = $false
}
"1 1 1 C"
$m.Groups[1].Captures[0].Value + $m.Groups[1].Captures[1].Value + $m.Groups[2].Captures[0].Value + "F"
$script:color
$m.Captures[0].Value
return
}
return $l
}
$tmp = "out.eps.tmp"
$eps = "out.eps"
Get-Content $eps | %{ f($_) } | Set-Content $tmp -Encoding Default
Move-Item $tmp $eps -Force