Skip to content

Commit

Permalink
feat: refactor font registration logic using fonthelper
Browse files Browse the repository at this point in the history
- add font registration using `fonthelper` to workflow
- update font registration method to use `fonthelper` for windows os
- change font registration logic output message
  • Loading branch information
falcucci committed Sep 19, 2024
1 parent a78432b commit ba6f9f5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,32 @@ jobs:
if: matrix.os == 'windows-2022'
shell: powershell
run: |
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class FontHelper {
[DllImport("gdi32.dll")]
public static extern int AddFontResource(string lpFileName);
}
"@
$fontPaths = @(
"$env:USERPROFILE\scoop\apps\FiraCode-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\ProFont-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\Cascadia-Code\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaMono-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF-Mono\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF-Propo\current\*.ttf",
"$env:USERPROFILE\scoop\apps\Noto-NF\current\*.ttf"
"$env:USERPROFILE\scoop\apps\FiraCode-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\ProFont-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\Cascadia-Code\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaMono-NF\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF-Mono\current\*.ttf",
"$env:USERPROFILE\scoop\apps\CascadiaCode-NF-Propo\current\*.ttf",
"$env:USERPROFILE\scoop\apps\Noto-NF\current\*.ttf"
)
foreach ($path in $fontPaths) {
if (Test-Path -Path $path) {
foreach ($font in Get-ChildItem -Path $path) {
Add-FontResource -FilePath $font.FullName
[FontHelper]::AddFontResource($font.FullName) | Out-Null
}
}
}
Write-Output "Fonts have been registered."
- name: Install Fonts
run: |
Expand Down

0 comments on commit ba6f9f5

Please sign in to comment.