File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function Export-Font {
2+ param (
3+ [Parameter (Mandatory , ValueFromPipelineByPropertyName )]
4+ [Alias (' FullName' )]
5+ [string ]
6+ $FontPath ,
7+
8+ [string ]
9+ $DestinationPath
10+ )
11+
12+
13+ begin {
14+ $fontForgeCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand (' fontforge' , ' Application' )
15+
16+ $progressId = Get-Random
17+ $outputQueue = [Collections.Queue ]::new()
18+ filter showProgress {
19+ $output = $_
20+ Write-Progress - Id $progressId " $line " " $fontPath "
21+ $outputQueue.Enqueue ($output )
22+ }
23+ }
24+
25+ process {
26+ $fontFile = Get-Item - Path $FontPath
27+
28+ if (-not $PSBoundParameters.DestinationPath ) {
29+ $destinationPath = $PSBoundParameters.DestinationPath = " ./$ ( $ ($fontFile | Split-Path - Leaf)) "
30+ }
31+
32+ if ($DestinationPath -like ' *.*' -and
33+ $DestinationPath -notlike ' *.zip'
34+ ) {
35+
36+ $fontForgeArgs = @ (
37+ ' -lang=ff'
38+
39+ ' -c'
40+
41+ @ (
42+ ' Open($1)'
43+ ' SelectWorthOutputting()'
44+ ' Generate($2)'
45+ ) -join ' ;'
46+
47+ $FontPath
48+
49+ $DestinationPath
50+ )
51+ & $fontForgeCommand @fontForgeArgs * > & 1 | showProgress
52+
53+ Get-Item - Path $DestinationPath
54+ } else {
55+ $exists = Get-Item - Path $DestinationPath - ErrorAction Ignore
56+ if (-not $exists ) {
57+ $exists = New-Item - ItemType Directory - Path $DestinationPath - Force
58+ }
59+ if ($exists -is [IO.FileInfo ]) {
60+ return
61+ }
62+ Push-Location $exists.FullName
63+ $fontForgeArgs = @ (
64+ ' -lang=ff'
65+
66+ ' -c'
67+
68+ @ (
69+ ' Open($1)'
70+ ' SelectWorthOutputting()'
71+ ' foreach Export("svg")'
72+ ' endloop'
73+ ) -join ' ;'
74+
75+ $FontPath
76+ )
77+ & $fontForgeCommand @fontForgeArgs * > & 1 | showProgress
78+ Get-Item - Path .
79+ Pop-Location
80+ }
81+ }
82+ end {
83+ Write-Progress - id $progressId - Completed
84+ }
85+ }
You can’t perform that action at this time.
0 commit comments