Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 [Patch]: Enhance documentation for functions #37

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions src/functions/public/Get-Font.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,73 @@
function Get-Font {
<#
.SYNOPSIS
Retrieves the installed fonts.
Retrieves the installed fonts.

.DESCRIPTION
Retrieves the installed fonts.
Retrieves a list of installed fonts for the current user or all users, depending on the specified scope.
Supports filtering by font name using wildcards.

.EXAMPLE
Get-Font
Get-Font

Gets all the fonts installed for the current user.
Output:
```powershell
Name Path Scope
---- ---- -----
Arial C:\Windows\Fonts\arial.ttf CurrentUser
```

Gets all the fonts installed for the current user.

.EXAMPLE
Get-Font -Name 'Arial*'
Get-Font -Name 'Arial*'

Output:
```powershell
Name Path Scope
---- ---- -----
Arial C:\Windows\Fonts\arial.ttf CurrentUser
Arial Bold C:\Windows\Fonts\arialbd.ttf CurrentUser
```

Gets all the fonts installed for the current user that start with 'Arial'.
Gets all the fonts installed for the current user that start with 'Arial'.

.EXAMPLE
Get-Font -Scope 'AllUsers'
Get-Font -Scope 'AllUsers'

Output:
```powershell
Name Path Scope
---- ---- -----
Calibri C:\Windows\Fonts\calibri.ttf AllUsers
```

Gets all the fonts installed for all users.
Gets all the fonts installed for all users.

.EXAMPLE
Get-Font -Name 'Calibri' -Scope 'AllUsers'
Get-Font -Name 'Calibri' -Scope 'AllUsers'

Gets the font with the name 'Calibri' for all users.
Output:
```powershell
Name Path Scope
---- ---- -----
Calibri C:\Windows\Fonts\calibri.ttf AllUsers
```

Gets the font with the name 'Calibri' for all users.

.OUTPUTS
[System.Collections.Generic.List[PSCustomObject]]
System.Collections.Generic.List[PSCustomObject]

.NOTES
Returns a list of installed fonts.
Each font object contains properties:
- Name: The font name.
- Path: The full file path to the font.
- Scope: The scope from which the font is retrieved.

.LINK
https://psmodule.io/Font/Functions/Get-Font
#>
[Alias('Get-Fonts')]
[OutputType([System.Collections.Generic.List[PSCustomObject]])]
Expand Down
103 changes: 76 additions & 27 deletions src/functions/public/Install-Font.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,105 @@
function Install-Font {
<#
.SYNOPSIS
Installs a font in the system
Installs a font in the system.

.DESCRIPTION
Installs a font in the system
Installs a font in the system, either for the current user or all users, depending on the specified scope.
If the font is already installed, it can be optionally overwritten using the `-Force` parameter.
The function supports both single file installations and batch installations via pipeline input.

Installing fonts for all users requires administrator privileges.

.EXAMPLE
Install-Font -Path C:\FontFiles\Arial.ttf
Install-Font -Path C:\FontFiles\Arial.ttf

Output:
```powershell
Arial.ttf installed for the current user.
```

Installs the font file 'C:\FontFiles\Arial.ttf' to the current user profile.
Installs the font file `Arial.ttf` for the current user.

.EXAMPLE
Install-Font -Path C:\FontFiles\Arial.ttf -Scope AllUsers
Install-Font -Path C:\FontFiles\Arial.ttf -Scope AllUsers

Output:
```powershell
Arial.ttf installed for all users.
```

Installs the font file 'C:\FontFiles\Arial.ttf' so it is available for all users.
This requires administrator rights.
Installs the font file `Arial.ttf` system-wide, making it available to all users.
This requires administrator rights.

.EXAMPLE
Install-Font -Path C:\FontFiles\Arial.ttf -Force
Install-Font -Path C:\FontFiles\Arial.ttf -Force

Installs the font file 'C:\FontFiles\Arial.ttf' to the current user profile.
If the font already exists, it will be overwritten.
Output:
```powershell
Arial.ttf reinstalled for the current user.
```

Installs the font file `Arial.ttf` for the current user. If it already exists, it will be overwritten.

.EXAMPLE
Install-Font -Path C:\FontFiles\Arial.ttf -Scope AllUsers -Force
Install-Font -Path C:\FontFiles\Arial.ttf -Scope AllUsers -Force

Output:
```powershell
Arial.ttf reinstalled for all users.
```

Installs the font file 'C:\FontFiles\Arial.ttf' so it is available for all users.
This requires administrator rights. If the font already exists, it will be overwritten.
Installs the font file `Arial.ttf` system-wide and overwrites the existing font if present.

.EXAMPLE
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font

Gets all font files in the folder 'C:\FontFiles\' and installs them to the current user profile.
Output:
```powershell
Found 3 font files.
Arial.ttf installed for the current user.
Verdana.ttf installed for the current user.
TimesNewRoman.ttf installed for the current user.
```

Installs all `.ttf` font files found in `C:\FontFiles\` for the current user.

.EXAMPLE
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font -Scope AllUsers
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font -Scope AllUsers

Output:
```powershell
Found 3 font files.
Arial.ttf installed for all users.
Verdana.ttf installed for all users.
TimesNewRoman.ttf installed for all users.
```

Gets all font files in the folder 'C:\FontFiles\' and installs them so it is available for all users.
This requires administrator rights.
Installs all `.ttf` font files found in `C:\FontFiles\` system-wide.
This requires administrator rights.

.EXAMPLE
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font -Force
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font -Scope AllUsers -Force

Gets all font files in the folder 'C:\FontFiles\' and installs them to the current user profile.
If the font already exists, it will be overwritten.
Output:
```powershell
Found 3 font files.
Arial.ttf reinstalled for all users.
Verdana.ttf reinstalled for all users.
TimesNewRoman.ttf reinstalled for all users.
```

.EXAMPLE
Get-ChildItem -Path C:\FontFiles\ -Filter *.ttf | Install-Font -Scope AllUsers -Force
Installs all `.ttf` font files found in `C:\FontFiles\` system-wide, overwriting existing fonts.
This requires administrator rights.

.OUTPUTS
System.String

.NOTES
Returns messages indicating success or failure of font installation.

Gets all font files in the folder 'C:\FontFiles\' and installs them so it is available for all users.
This requires administrator rights. If the font already exists, it will be overwritten.
.LINK
https://psmodule.io/Admin/Functions/Install-Font/
#>
[Alias('Install-Fonts')]
[CmdletBinding(SupportsShouldProcess)]
Expand All @@ -70,13 +119,13 @@ function Install-Font {
# CurrentUser will install the font for the current user only.
# AllUsers will install the font so it is available for all users on the system.
[Parameter(ValueFromPipelineByPropertyName)]
[Scope[]] $Scope = 'CurrentUser',
[string] $Scope = 'CurrentUser',

# Recurse will install all fonts in the specified folder and subfolders.
[Parameter()]
[switch] $Recurse,

# Force will overwrite existing fonts
# Force will overwrite existing fonts.
[Parameter()]
[switch] $Force
)
Expand Down
42 changes: 32 additions & 10 deletions src/functions/public/Uninstall-Font.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,47 @@
#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.3' }

function Uninstall-Font {
function Uninstall-Font {
<#
.SYNOPSIS
Uninstalls a font from the system.
Uninstalls a font from the system.

.DESCRIPTION
Uninstalls a font from the system.
Uninstalls a font from the system. The function supports removing fonts for either the current user
or all users. If attempting to remove a font for all users, administrative privileges are required.
The function ensures font files are deleted, and if on Windows, it also unregisters fonts from the registry.

.EXAMPLE
Uninstall-Font -Name 'Courier New'
Uninstall-Font -Name 'Courier New'

Output:
```powershell
VERBOSE: [Uninstall-Font] - [CurrentUser] - [Courier New] - Processing
VERBOSE: [Uninstall-Font] - [CurrentUser] - [Courier New] - Removing file [C:\Windows\Fonts\cour.ttf]
VERBOSE: [Uninstall-Font] - [CurrentUser] - [Courier New] - Unregistering font [Courier New]
VERBOSE: [Uninstall-Font] - [CurrentUser] - [Courier New] - Done
```

Uninstalls the 'Courier New' font from the system for the current user.
Uninstalls the 'Courier New' font from the system for the current user.

.EXAMPLE
Uninstall-Font -Name 'Courier New' -Scope AllUsers
Uninstall-Font -Name 'Courier New' -Scope AllUsers

Output:
```powershell
VERBOSE: [Uninstall-Font] - [AllUsers] - [Courier New] - Processing
VERBOSE: [Uninstall-Font] - [AllUsers] - [Courier New] - Removing file [C:\Windows\Fonts\cour.ttf]
VERBOSE: [Uninstall-Font] - [AllUsers] - [Courier New] - Unregistering font [Courier New]
VERBOSE: [Uninstall-Font] - [AllUsers] - [Courier New] - Done
```

Uninstalls the Courier New font from the system for all users.
Uninstalls the 'Courier New' font from the system for all users. Requires administrative privileges.

.OUTPUTS
None
None

.NOTES
The function does not return any objects.

.LINK
https://psmodule.io/Admin/Functions/Uninstall-Font/
#>
[Alias('Uninstall-Fonts')]
[CmdletBinding()]
Expand Down
Loading