Skip to content
Open
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
7 changes: 7 additions & 0 deletions assets/fonts/fontforge-ufo-to-ttf.pe
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/local/bin/fontforge
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shebang hardcodes /usr/local/bin/fontforge, which is not portable (and it’s unnecessary when this file is executed via fontforge -script). Consider removing the shebang entirely, or switching to an env-based shebang if you intend the script to be directly executable on Unix-like systems.

Suggested change
#!/usr/local/bin/fontforge
#!/usr/bin/env fontforge

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken straight from the FontForge scripting documentation, it does say "(or wherever fontforge happens to reside on your system)".

Either way, it's inconsequential for us. I think...

i=1
while ( i<$argc )
Open($argv[i])
Generate($argv[i]:r + ".ttf","",0x10|0x80|0x8000|4)
i = i+1
endloop
73 changes: 73 additions & 0 deletions scripts/Generate-Fonts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<#
.SYNOPSIS
Generate TrueType (.ttf) fonts from UFO packages using FontForge.
.DESCRIPTION
Lightweight wrapper that invokes `assets/fonts/fontforge-ufo-to-ttf.pe`
to generate .ttf files.
.PARAMETER Publish
Specifies whether generated .ttf files should be moved from the
source assets folder into the application assets folder. If not specified,
generated .ttf files remain in the source assets folder.
.EXAMPLE
PS> .\scripts\Generate-Fonts.ps1
.EXAMPLE
PS> .\scripts\Generate-Fonts.ps1 -Publish
.NOTES
FontForge must be installed and included in the PATH environment variable.
#>

[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[switch]
$Publish
)

New-Variable -Name 'ScriptFileName' -Value 'fontforge-ufo-to-ttf.pe' -Option Constant

$repositoryPath = Split-Path -Parent $PSScriptRoot
$fontsPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts"
$publishPath = Join-Path -Path $repositoryPath -ChildPath "Screenbox\Assets\Fonts"

if (-not (Get-Command "fontforge" -ErrorAction SilentlyContinue)) {
Write-Error "Install the latest version of FontForge.`nAfter FontForge is installed, make sure that the location of the 'fontforge.exe' is included in the PATH environment variable." -Category NotInstalled
exit 1
}

if (-not (Test-Path (Join-Path -Path $fontsPath -ChildPath $ScriptFileName))) {
Write-Error "The script file $ScriptFileName was not found." -Category ObjectNotFound
exit 1
}

$ufoDirs = @(Get-ChildItem -Path $fontsPath -Filter '*.ufo' -Directory -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName)

if ($ufoDirs.Count -gt 0) {
Write-Output "Found UFO packages:`n$($ufoDirs -join "`n")"

# Build argument list: -script <scriptFile> <ufo#1> <ufo#2> ...
$cmdArgs = @('-script', (Join-Path -Path $fontsPath -ChildPath $ScriptFileName)) + $ufoDirs
& "fontforge" @cmdArgs

if ($Publish) {
try {
$ttfFiles = @(Get-ChildItem -Path $fontsPath -Filter '*.ttf' -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName)

if ($ttfFiles.Count -eq 0) {
Write-Error "No .ttf files found in the folder: $fontsPath" -Category ObjectNotFound
exit 1
}

Comment on lines +51 to +59
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script invokes FontForge but never checks whether the external process succeeded. As written, it will exit 0 even if fontforge fails (and with -Publish omitted, it also doesn’t verify that any .ttf outputs were produced). Capture and validate the FontForge exit code (e.g., $LASTEXITCODE) and/or check for expected output files before returning success.

Suggested change
if ($Publish) {
try {
$ttfFiles = @(Get-ChildItem -Path $fontsPath -Filter '*.ttf' -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName)
if ($ttfFiles.Count -eq 0) {
Write-Error "No .ttf files found in the folder: $fontsPath" -Category ObjectNotFound
exit 1
}
$fontForgeExitCode = $LASTEXITCODE
if ($fontForgeExitCode -ne 0) {
Write-Error "FontForge failed with exit code $fontForgeExitCode." -Category InvalidOperation
exit $fontForgeExitCode
}
$ttfFiles = @(Get-ChildItem -Path $fontsPath -Filter '*.ttf' -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName)
if ($ttfFiles.Count -eq 0) {
Write-Error "No .ttf files found in the folder: $fontsPath" -Category ObjectNotFound
exit 1
}
if ($Publish) {
try {

Copilot uses AI. Check for mistakes.
Move-Item -Path $ttfFiles -Destination $publishPath -Force -ErrorAction Stop
}
catch {
Write-Error $_.Exception.Message
exit 1
}
}

exit 0
}
else {
Write-Error "No UFO packages found in the folder: $fontsPath" -Category ObjectNotFound
exit 1
}