Bumped SourceCodePro to 1.017

- Totally overhauled font install process since the previous version
 required lots of interaction / prompting to upgrade existing fonts
 AND had a clunky UI dialog when installing fonts for the first time
 - Leveraging Windows Powershell sample script that compiles C# on
 the fly to call Win32 APIs that deal with fonts
 - Elevate to admin to run the new stuff - no reboot required
This commit is contained in:
Iristyle
2013-03-07 14:22:07 -05:00
parent dda4898b0d
commit 03d686432d
3 changed files with 598 additions and 5 deletions

View File

@@ -1,7 +1,16 @@
function Get-CurrentDirectory
{
$thisName = $MyInvocation.MyCommand.Name
[IO.Path]::GetDirectoryName((Get-Content function:$thisName).File)
}
try {
$package = 'SourceCodePro'
$fontUrl = 'https://github.com/downloads/adobe/Source-Code-Pro/SourceCodePro_FontsOnly-1.010.zip'
$fontHelpersPath = (Join-Path (Get-CurrentDirectory) 'FontHelpers.ps1')
. $fontHelpersPath
$fontUrl = 'http://sourceforge.net/projects/sourcecodepro.adobe/files/SourceCodePro_FontsOnly-1.017.zip/download'
$destination = Join-Path $Env:Temp 'SourceCodePro'
Install-ChocolateyZipPackage -url $fontUrl -unzipLocation $destination
@@ -9,8 +18,22 @@ try {
$shell = New-Object -ComObject Shell.Application
$fontsFolder = $shell.Namespace(0x14)
Get-ChildItem $destination -Recurse -Filter *.otf |
% { $fontsFolder.CopyHere($_.FullName) }
$fontFiles = Get-ChildItem $destination -Recurse -Filter *.otf
# unfortunately the font install process totally ignores shell flags :(
# http://social.technet.microsoft.com/Forums/en-IE/winserverpowershell/thread/fcc98ba5-6ce4-466b-a927-bb2cc3851b59
# so resort to a nasty hack of compiling some C#, and running as admin instead of just using CopyHere(file, options)
$commands = $fontFiles |
% { Join-Path $fontsFolder.Self.Path $_.Name } |
? { Test-Path $_ } |
% { "Remove-SingleFont '$_' -Force;" }
# http://blogs.technet.com/b/deploymentguys/archive/2010/12/04/adding-and-removing-fonts-with-windows-powershell.aspx
$fontFiles |
% { $commands += "Add-SingleFont '$($_.FullName)';" }
$toExecute = ". $fontHelpersPath;" + ($commands -join ';')
Start-ChocolateyProcessAsAdmin $toExecute
Remove-Item $destination -Recurse