Closed dancebear closed 7 hours ago
Hi,
Thank you for the bug report. To resolve the issue, I need the font file causing the crash. Could you post it as well ?
To find it, you could for example add a print statement to textprocessing/fontconfig.scanOneFontFile
.
By the way, this module has been superseded by go-text/typesetting
: you should use it instead if possible.
I've fixed the bug in the upstream textlayout
repo.
go version go1.23.1 darwin/arm64
Scanning fonts... 2024/11/14 19:41:30 invalid font dir /Network/Library/Fonts stat /Network/Library/Fonts: no such file or directory 2024/11/14 19:41:30 invalid font dir /System/Library/Assets/com_apple_MobileAsset_Font3 stat /System/Library/Assets/com_apple_MobileAsset_Font3: no such file or directory 2024/11/14 19:41:30 invalid font dir /System/Library/Assets/com_apple_MobileAsset_Font4 stat /System/Library/Assets/com_apple_MobileAsset_Font4: no such file or directory 2024/11/14 19:41:30 invalid font dir /System/Library/Assets/com_apple_MobileAsset_Font5 stat /System/Library/Assets/com_apple_MobileAsset_Font5: no such file or directory panic: runtime error: slice bounds out of range [65512:18]
goroutine 1 [running]: github.com/benoitkugler/textlayout/fonts/truetype.parseTableName({0x14000558000, 0x112b0, 0x112b0}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textlayout@v0.3.0/fonts/truetype/table_name.go:344 +0x3bc github.com/benoitkugler/textlayout/fonts/truetype.(FontParser).tryAndLoadNameTable(0x14000547360) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textlayout@v0.3.0/fonts/truetype/parser.go:172 +0x18c github.com/benoitkugler/textlayout/fonts/truetype.(FontParser).loadTables(0x14000547360) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textlayout@v0.3.0/fonts/truetype/parser.go:670 +0x398 github.com/benoitkugler/textlayout/fonts/truetype.Load({0x105ac8fc8, 0x140000740d0}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textlayout@v0.3.0/fonts/truetype/parser.go:763 +0x174 github.com/benoitkugler/textprocessing/fontconfig.ReadFontFile({0x105ac8fc8, 0x140000740d0}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/scan.go:122 +0xf8 github.com/benoitkugler/textprocessing/fontconfig.scanOneFontFile({0x105ac8fc8, 0x140000740d0}, {0x140001493e0, 0x24}, 0x10629e720) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/scan.go:64 +0x5c github.com/benoitkugler/textprocessing/fontconfig.(Config).readDir.func1({0x140001493e0, 0x24}, {0x105acbc60, 0x14000554270}, {0x0, 0x0}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/config.go:240 +0x350 path/filepath.walk({0x140001493e0, 0x24}, {0x105acbc60, 0x14000554270}, 0x14000047970) /usr/local/go/src/path/filepath/path.go:345 +0x1a0 path/filepath.walk({0x105302b5c, 0x15}, {0x105acbc60, 0x140005541a0}, 0x14000047970) /usr/local/go/src/path/filepath/path.go:369 +0x3dc path/filepath.Walk({0x105302b5c, 0x15}, 0x14000047970) /usr/local/go/src/path/filepath/path.go:427 +0xd8 github.com/benoitkugler/textprocessing/fontconfig.(Config).readDir(0x10629e720, {0x105302b5c, 0x15}, 0x14000047b68) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/config.go:258 +0x118 github.com/benoitkugler/textprocessing/fontconfig.(*Config).ScanFontDirectories(0x10629e720, {0x14000547320, 0x2, 0x2}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/config.go:159 +0x154 github.com/benoitkugler/textprocessing/fontconfig.ScanAndCache({0x1052ee8b9, 0x8}) /Users/x/GolandProjects/pkg/mod/github.com/benoitkugler/textprocessing@v0.0.3/fontconfig/cache.go:452 +0x104 main.main() /Users/x/GolandProjects/demo/main.go:45 +0xac Exiting.
调试器 已完成,退出代码为 0