Skip to content

Commit 9d53409

Browse files
docs: Get-Font Help ( Fixes #2 )
1 parent dbe7a57 commit 9d53409

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Commands/Get-Font.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,30 @@ function Get-Font {
44
Gets Fonts
55
.DESCRIPTION
66
Gets currently installed fonts
7+
.EXAMPLE
8+
Get-Font
79
#>
810
param()
911

12+
# Fonts will be in different places, depending on the operating system
1013
$fontPaths =
1114
if ($IsLinux) {
1215
"/usr/share/fonts"
13-
"$home/.local/share/fonts"
16+
"~/.local/share/fonts"
1417
} elseif ($IsMacOS) {
1518
"/Library/Fonts"
16-
"$home/Library/Fonts"
19+
"~/Library/Fonts"
1720
} else {
1821
"$env:WinDir\Fonts"
1922
"$($env:AppData |
2023
Split-Path |
2124
Join-Path -ChildPath 'Local\Microsoft\Windows\Fonts')"
2225
}
2326

27+
# If we have fc-list, it will be quicker and more authoritative
2428
$fcList = $ExecutionContext.SessionState.invokecommand.GetCommand('fc-list', 'Application')
2529

30+
# Collect all of the font files
2631
$fontFiles =
2732
if ($fcList) {
2833
& $fcList |
@@ -38,13 +43,16 @@ function Get-Font {
3843
}
3944

4045

46+
# Walk thru each list of collected files
4147
foreach ($fontFile in $fontFiles) {
42-
if ($fontFile.Extension -notin '.svg','.ttf','.otf') {
48+
# and as long as they appear to be a font
49+
if ($fontFile.Extension -notin '.svg', '.ttf', '.otf', '.t1', '.pfb') {
4350
continue
4451
}
52+
# decorate them as a `Font.File`
4553
$fontFile.pstypenames.add('Font.File')
54+
# and output the font.
4655
$fontFile
47-
}
48-
56+
}
4957
}
5058

0 commit comments

Comments
 (0)