forked from pawalan/adobe-fonts-liberator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adobe-fonts-liberator.ps1
61 lines (43 loc) · 2.12 KB
/
adobe-fonts-liberator.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#################################################################################
# Edit to allow for getting adobe fonts without using often broken otfinfo.exe
#
# https://github.com/pawalan/adobe-fonts-liberator
# kudos to Steven Kalinke <https://github.com/kalaschnik/adobe-fonts-revealer>
# kudos to Sven Goettner <https://github.com/pawalan/adobe-fonts-liberator>
#
################################################################################
# Configuration - usually no need to change something, but suit yourself
$AdobeFontsDir = "$env:APPDATA\Adobe\CoreSync\plugins\livetype\r"
$DesktopDir = [Environment]::GetFolderPath("Desktop")
$DestinationDir = Join-Path -Path $DesktopDir -ChildPath 'Adobe Fonts'
######################### script code - don't change unless you know what you do! ###############################################
Clear-Host
Add-Type -AssemblyName System.Drawing
Write-Output "`n`rLiberating Adobe Fonts`n`r`n`rfrom`t$AdobeFontsDir`n`rto`t`t$DestinationDir`n`r`n`r"
if ( Test-Path -Path "$DestinationDir\*" ) {
Write-Error "Destination directory is not empty, aborting."
exit 1
} else {
New-Item -Path $DestinationDir -ItemType Directory -Force | Out-Null
}
Get-ChildItem -Path $AdobeFontsDir -Force | ForEach-Object {
try {
$fontCollection = New-Object System.Drawing.Text.PrivateFontCollection
$fontCollection.AddFontFile($_.FullName)
$fontName = $fontCollection.Families[-1].Name
$originalName = $_.Name
$uniqueFontName = "$fontName - $originalName"
# Ensure the unique name ends with .otf
if (-not $uniqueFontName.EndsWith(".otf")) {
$uniqueFontName += ".otf"
}
$fontFile = Join-Path -Path $DestinationDir -ChildPath $uniqueFontName
Copy-Item -Path $_.FullName -Destination $fontFile
Write-Output "Liberated`t$_`tto`t$uniqueFontName"
} catch {
Write-Error "Failed to process`t$_`tError: $($_.Exception.Message)"
}
}
Write-Output "`n`r`n`rLong live the free fonts!`n`r`n`rBye!`n`r"
# Keep the window open until a key is pressed
Read-Host -Prompt "Press any key to exit..."