Skip to content

font extract Panic: Index Out of Range in cz2.go:69 During CZ2 Decompression on Modified Font Files #32

@abdalgani1

Description

@abdalgani1

Hi team,
I'm reporting a reproducible runtime panic in the font extract command when processing CZ2 font images (.cz files) generated or modified via font edit. The error occurs specifically during the decompression step in CZ2 files, and it happens consistently on files with exact-length data boundaries. This prevents extracting images or info from edited fonts, blocking workflows like font modification for game localization (e.g., adding Arabic glyphs to Japanese fonts in LucaSystem-based games like Kanon steam).

Im using mac. and this problem only happen in the fonts i edit by the tool. when i add arabic characters, it will output everthing correctly but when i try to make png and txt to see the result it just make this error

/Users/abdalganiallaham/Downloads/LuckSystem_mac_x86_64/LuckSystem_mac font extract -s /Users/abdalganiallaham/Documents/Games/Kanon/files/newarfont/ゴシック24 -S /Users/abdalganiallaham/Documents/Games/Kanon/files/newarfont/info24.txt -o /Users/abdalganiallaham/Documents/Games/Kanon/files/newarfont/new.png -O /Users/abdalganiallaham/Documents/Games/Kanon/files/newarfont/new.txt
fontExtract called
panic: runtime error: index out of range [4607423] with length 4607423

goroutine 1 [running]:
lucksystem/czimage.(*Cz2Image).decompress(0xc00018e630)
/home/runner/work/LuckSystem/LuckSystem/czimage/cz2.go:69 +0x345
lucksystem/czimage.(*Cz2Image).GetImage(0xc00018e630, 0x1eec2e, 0x1eec2f)
/home/runner/work/LuckSystem/LuckSystem/czimage/cz2.go:84 +0x4e
lucksystem/font.LoadLucaFont(0xc000200000, 0x45451, 0x45452, 0xc000246000, 0x1eec2e, 0x1eec2f, 0x0)
/home/runner/work/LuckSystem/LuckSystem/font/font.go:75 +0xd4
lucksystem/font.LoadLucaFontFile(0x205be18d7, 0x48, 0x205be1887, 0x4c, 0x1)
/home/runner/work/LuckSystem/LuckSystem/font/font.go:60 +0x1b1
lucksystem/cmd.glob..func4(0x17acf00, 0xc000175600, 0x0, 0x8)
/home/runner/work/LuckSystem/LuckSystem/cmd/fontExtract.go:25 +0xce
github.com/spf13/cobra.(*Command).execute(0x17acf00, 0xc000175580, 0x8, 0x8, 0x17acf00, 0xc000175580)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 +0x2ec
github.com/spf13/cobra.(*Command).ExecuteC(0x17ac280, 0xc000134010, 0xa, 0xa)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
lucksystem/cmd.Execute()
/home/runner/work/LuckSystem/LuckSystem/cmd/root.go:39 +0x3a
main.main()
/home/runner/work/LuckSystem/LuckSystem/main.go:12 +0x25

if i used font that have only arabic support and no english or japanease it will work by showing only arabic characters in the photo but by font support all. it will give correct sized file. but never work. i tried to cut last bit but didnt work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions