Skip to content

fix(cask): parse font artifacts in Homebrew API JSON - #332

Open
olegdizus wants to merge 1 commit into
justrach:mainfrom
olegdizus:fix/font-artifact-parser
Open

fix(cask): parse font artifacts in Homebrew API JSON#332
olegdizus wants to merge 1 commit into
justrach:mainfrom
olegdizus:fix/font-artifact-parser

Conversation

@olegdizus

@olegdizus olegdizus commented Jun 17, 2026

Copy link
Copy Markdown

Fixes #331

The artifact-parsing if/else chain in parseCaskJsonArch (src/api/client.zig) handled app, binary, pkg, uninstall, suite, and artifact stanzas but had no branch for font. Font artifact objects (e.g. {"font":["ttf/FiraCode-Bold.ttf"],...}) fell through silently, leaving the parsed Cask with an empty artifacts array. Font casks then reported install success while copying no files to ~/Library/Fonts/.

PR #306 fixed the same class of bug for suite and artifact (issue #303); font was missed. The downstream install code (installCask, installZipFontsDirect, fontArtifactsOnly) already handles .font artifacts correctly — this branch makes them reachable.

Fix

Add a font branch to the artifact-parsing chain, following the same pattern as app/pkg:

} else if (obj.get("font")) |font_val| {
    if (font_val == .array) {
        for (font_val.array.items) |f| {
            if (f == .string) {
                try artifacts.append(alloc, .{ .font = try rewriteVersion(alloc, f.string, root_version, version) });
            }
        }
    }
}

Verification

Built and tested locally on v0.1.198 with Zig 0.16.0.

Before the fix, nb install --cask font-fira-code reported success but phase=artifacts ms=0.00 (empty loop) and no files landed in ~/Library/Fonts/.

After the fix, the fast path fires (phase=fast_install) and all fonts are extracted:

$ nb install --cask font-fira-code
==> Installed Fira Code 6.2
==> Done in 513.0ms

$ ls ~/Library/Fonts/Fira*
FiraCode-Bold.ttf    FiraCode-Light.ttf   FiraCode-Medium.ttf
FiraCode-Regular.ttf FiraCode-Retina.ttf  FiraCode-SemiBold.ttf
FiraCode-VF.ttf

$ nb info --cask font-fira-code
  artifacts:
    font: ttf/FiraCode-Bold.ttf
    font: ttf/FiraCode-Light.ttf
    font: ttf/FiraCode-Medium.ttf
    font: ttf/FiraCode-Regular.ttf
    font: ttf/FiraCode-Retina.ttf
    font: ttf/FiraCode-SemiBold.ttf
    font: variable_ttf/FiraCode-VF.ttf

Also verified with font-cascadia-code-nf.

zig build test passes, including a new regression test for multi-stanza font cask parsing.

…llow-up)

The artifact-parsing if/else chain in parseCaskJsonArch handled
app, binary, pkg, uninstall, suite, and artifact stanzas but had no
branch for font. Font artifact objects (e.g.
{"font":["ttf/FiraCode-Bold.ttf"],...}) fell through silently,
leaving the parsed Cask with an empty artifacts array. Font casks
then reported install success while copying no files to
~/Library/Fonts/.

PR justrach#306 fixed the same class of bug for suite and artifact; font
was missed. The downstream install code (installCask,
installZipFontsDirect, fontArtifactsOnly) already handles .font
artifacts correctly — this branch makes them reachable.

Adds a regression test covering multi-stanza font cask parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font casks install successfully but no font files are placed in ~/Library/Fonts/

1 participant