From 44fbca5e799d210044183b3ad7748736318c08e7 Mon Sep 17 00:00:00 2001 From: United600 Date: Tue, 27 Jan 2026 20:28:48 +0000 Subject: [PATCH 1/5] add scripts to convert ufo packages to ttf --- assets/fonts/fontforge-ufo-to-ttf.pe | 5 +++++ scripts/Generate-Fonts.ps1 | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 assets/fonts/fontforge-ufo-to-ttf.pe create mode 100644 scripts/Generate-Fonts.ps1 diff --git a/assets/fonts/fontforge-ufo-to-ttf.pe b/assets/fonts/fontforge-ufo-to-ttf.pe new file mode 100644 index 000000000..88a9eff99 --- /dev/null +++ b/assets/fonts/fontforge-ufo-to-ttf.pe @@ -0,0 +1,5 @@ +#!/usr/local/bin/fontforge +Open($1) +Generate($1:r + ".ttf","",0x10|0x80|0x8000|4) +Open($2) +Generate($2:r + ".ttf","",0x10|0x80|0x8000|4) diff --git a/scripts/Generate-Fonts.ps1 b/scripts/Generate-Fonts.ps1 new file mode 100644 index 000000000..12febe19b --- /dev/null +++ b/scripts/Generate-Fonts.ps1 @@ -0,0 +1,6 @@ +$repositoryPath = Split-Path -Parent $PSScriptRoot +$scriptPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\fontforge-ufo-to-ttf.pe" +$mdl2PackagePath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\ScreenboxMDL2Assets.ufo" +$fluentPackagePath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\ScreenboxFluentIcons.ufo" + +& "fontforge" -script $scriptPath $mdl2PackagePath $fluentPackagePath From 916cec2f40395bd0f7d9b24e967ee713b2758806 Mon Sep 17 00:00:00 2001 From: United600 Date: Tue, 27 Jan 2026 21:24:47 +0000 Subject: [PATCH 2/5] refactor font gen scripts for dynamic font discovery --- assets/fonts/fontforge-ufo-to-ttf.pe | 10 ++++++---- scripts/Generate-Fonts.ps1 | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/assets/fonts/fontforge-ufo-to-ttf.pe b/assets/fonts/fontforge-ufo-to-ttf.pe index 88a9eff99..a35047da4 100644 --- a/assets/fonts/fontforge-ufo-to-ttf.pe +++ b/assets/fonts/fontforge-ufo-to-ttf.pe @@ -1,5 +1,7 @@ #!/usr/local/bin/fontforge -Open($1) -Generate($1:r + ".ttf","",0x10|0x80|0x8000|4) -Open($2) -Generate($2:r + ".ttf","",0x10|0x80|0x8000|4) +i=1 +while ( i<$argc ) + Open($argv[i]) + Generate($argv[i]:r + ".ttf","",0x10|0x80|0x8000|4) + i = i+1 +endloop diff --git a/scripts/Generate-Fonts.ps1 b/scripts/Generate-Fonts.ps1 index 12febe19b..3d53ec9b3 100644 --- a/scripts/Generate-Fonts.ps1 +++ b/scripts/Generate-Fonts.ps1 @@ -1,6 +1,22 @@ $repositoryPath = Split-Path -Parent $PSScriptRoot +$fontsPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts" $scriptPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\fontforge-ufo-to-ttf.pe" -$mdl2PackagePath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\ScreenboxMDL2Assets.ufo" -$fluentPackagePath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\ScreenboxFluentIcons.ufo" -& "fontforge" -script $scriptPath $mdl2PackagePath $fluentPackagePath +# Check if FontForge is installed. +if (-not (Get-Command "fontforge" -ErrorAction SilentlyContinue)) { + Write-Error "FontForge is not installed or not in PATH environment variable." + exit 1 +} + +$ufoDirs = @(Get-ChildItem -Path $fontsPath -Filter '*.ufo' -Directory -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName) + +if ($ufoDirs.Count -gt 0) { + Write-Host "Found UFO packages:`n$($ufoDirs -join "`n")" + + # Build argument list: -script ... + $cmdArgs = @('-script', $scriptPath) + $ufoDirs + & "fontforge" @cmdArgs +} else { + Write-Host "No UFO packages found in the folder $fontsPath" + exit 0 +} From 7f864b76b63672cad25381f1a99e4341eb44cc04 Mon Sep 17 00:00:00 2001 From: United600 Date: Tue, 27 Jan 2026 22:38:40 +0000 Subject: [PATCH 3/5] add publish option and help to font gen script --- scripts/Generate-Fonts.ps1 | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/Generate-Fonts.ps1 b/scripts/Generate-Fonts.ps1 index 3d53ec9b3..91892277c 100644 --- a/scripts/Generate-Fonts.ps1 +++ b/scripts/Generate-Fonts.ps1 @@ -1,8 +1,34 @@ +<# +.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 + (Optional) 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 on the system PATH environment + variables. +#> + +[CmdletBinding()] +param( + [Parameter(Mandatory=$false)] + [switch] + $Publish +) + $repositoryPath = Split-Path -Parent $PSScriptRoot $fontsPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts" $scriptPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\fontforge-ufo-to-ttf.pe" +$publishPath = Join-Path -Path $repositoryPath -ChildPath "Screenbox\Assets\Fonts" -# Check if FontForge is installed. if (-not (Get-Command "fontforge" -ErrorAction SilentlyContinue)) { Write-Error "FontForge is not installed or not in PATH environment variable." exit 1 @@ -16,7 +42,19 @@ if ($ufoDirs.Count -gt 0) { # Build argument list: -script ... $cmdArgs = @('-script', $scriptPath) + $ufoDirs & "fontforge" @cmdArgs + + if ($Publish) { + try { + Move-Item -Path (Join-Path $fontsPath '*.ttf') -Destination $publishPath -Force -ErrorAction Stop + } catch [System.Management.Automation.ItemNotFoundException] { + Write-Host "No .ttf files found in the folder $fontsPath." + } catch { + Write-Error $_.Exception.Message + exit 1 + } + } + } else { - Write-Host "No UFO packages found in the folder $fontsPath" + Write-Host "No UFO packages found in the folder $fontsPath." exit 0 } From 53226c8dc81447ada3707213f5a82431ffdd1250 Mon Sep 17 00:00:00 2001 From: United600 Date: Tue, 27 Jan 2026 23:01:47 +0000 Subject: [PATCH 4/5] refactor script path handling in font gen script --- scripts/Generate-Fonts.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Generate-Fonts.ps1 b/scripts/Generate-Fonts.ps1 index 91892277c..3ee4ad62f 100644 --- a/scripts/Generate-Fonts.ps1 +++ b/scripts/Generate-Fonts.ps1 @@ -24,9 +24,10 @@ param( $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" -$scriptPath = Join-Path -Path $repositoryPath -ChildPath "assets\fonts\fontforge-ufo-to-ttf.pe" $publishPath = Join-Path -Path $repositoryPath -ChildPath "Screenbox\Assets\Fonts" if (-not (Get-Command "fontforge" -ErrorAction SilentlyContinue)) { @@ -40,7 +41,7 @@ if ($ufoDirs.Count -gt 0) { Write-Host "Found UFO packages:`n$($ufoDirs -join "`n")" # Build argument list: -script ... - $cmdArgs = @('-script', $scriptPath) + $ufoDirs + $cmdArgs = @('-script', (Join-Path -Path $fontsPath -ChildPath $ScriptFileName)) + $ufoDirs & "fontforge" @cmdArgs if ($Publish) { From c248a0851d36e9ddf1480fa8c5664405921597cc Mon Sep 17 00:00:00 2001 From: United600 Date: Wed, 28 Jan 2026 18:15:37 +0000 Subject: [PATCH 5/5] improve error handling and formatting in font gen script --- scripts/Generate-Fonts.ps1 | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/scripts/Generate-Fonts.ps1 b/scripts/Generate-Fonts.ps1 index 3ee4ad62f..b11a5c9b0 100644 --- a/scripts/Generate-Fonts.ps1 +++ b/scripts/Generate-Fonts.ps1 @@ -5,7 +5,7 @@ Lightweight wrapper that invokes `assets/fonts/fontforge-ufo-to-ttf.pe` to generate .ttf files. .PARAMETER Publish - (Optional) Specifies whether generated .ttf files should be moved from the + 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 @@ -13,8 +13,7 @@ .EXAMPLE PS> .\scripts\Generate-Fonts.ps1 -Publish .NOTES - FontForge must be installed and included on the system PATH environment - variables. + FontForge must be installed and included in the PATH environment variable. #> [CmdletBinding()] @@ -31,14 +30,19 @@ $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 "FontForge is not installed or not in PATH environment variable." + 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-Host "Found UFO packages:`n$($ufoDirs -join "`n")" + Write-Output "Found UFO packages:`n$($ufoDirs -join "`n")" # Build argument list: -script ... $cmdArgs = @('-script', (Join-Path -Path $fontsPath -ChildPath $ScriptFileName)) + $ufoDirs @@ -46,16 +50,24 @@ if ($ufoDirs.Count -gt 0) { if ($Publish) { try { - Move-Item -Path (Join-Path $fontsPath '*.ttf') -Destination $publishPath -Force -ErrorAction Stop - } catch [System.Management.Automation.ItemNotFoundException] { - Write-Host "No .ttf files found in the folder $fontsPath." - } catch { + $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 + } + + Move-Item -Path $ttfFiles -Destination $publishPath -Force -ErrorAction Stop + } + catch { Write-Error $_.Exception.Message exit 1 } } -} else { - Write-Host "No UFO packages found in the folder $fontsPath." exit 0 } +else { + Write-Error "No UFO packages found in the folder: $fontsPath" -Category ObjectNotFound + exit 1 +}