Blogger :
MSDN Blogs
All posts :
All posts by MSDN Blogs
Category :
SAPscript
Blogged date : 2008 Dec 24
Get-Font
Synopsis:
Gets the fonts currently loaded on the system
Syntax:
Get-Font [[-font] [<Object>]] [<CommonParameters>]
Detailed Description:
Uses the type System.Windows.Media.Fonts static property SystemFontFamilies,
to retrieve all of the fonts loaded by the system. If the Fonts type is not found,
the PresentationCore assembly will be automatically loaded
Examples:
-------------------------- EXAMPLE 1 --------------------------
# Get All Fonts
Get-Font
-------------------------- EXAMPLE 2 --------------------------
# Get All Lucida Fonts
Get-Font *Lucida*
Command Parameters:
| Name |
Description |
| font |
A wildcard to search for font names |
Here's Get-Font:
function Get-Font {
<#
.Synopsis
Gets the fonts currently loaded on the system
.Description
Uses the type System.Windows.Media.Fonts static property SystemFontFamilies,
to retrieve all of the fonts loaded by the system. If the Fonts type is not found,
the PresentationCore assembly will be automatically loaded
.Parameter font
A wildcard to search for font names
.Example
# Get All Fonts
Get-Font
.Example
# Get All Lucida Fonts
Get-Font *Lucida*
#>
param($font = "*")
if (-not ("Windows.Media.Fonts" -as [Type])) {
Add-Type -AssemblyName "PresentationCore"
}
[Windows.Media.Fonts]::SystemFontFamilies |
Where-Object { $_.Source -like "$font" }
}
Automatically generated with Write-CommandBlogPost