fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.21k stars 1.4k forks source link

font load error #5179

Open aohanhongzhi opened 1 month ago

aohanhongzhi commented 1 month ago

Checklist

Describe the bug

runtime error: slice bounds out of range [-7494:]
========
goroutine 1 [running, locked to thread]:
runtime/debug.Stack()
    C:/app/go1.20.14.windows-386/go/src/runtime/debug/stack.go:24 +0x83
kuaima/src/utils.PanicHandler()
    C:/Users/Eric/Project/Go/chrome-driver/src/utils/panic_handler.go:42 +0x3ff
panic({0x1b94320, 0xd99c130})
    C:/app/go1.20.14.windows-386/go/src/runtime/panic.go:884 +0x1b7
github.com/go-text/typesetting/opentype/api.newCmap4({0x4, 0x75b0, 0x0, 0x1d68, 0x1000, 0xb, 0xd68, {0xf5d8000, 0xeb4, 0xeb4}, ...})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/opentype/api/cmap.go:235 +0x2c0
github.com/go-text/typesetting/opentype/api.ProcessCmap({0x0, 0x2, {0xd582c48, 0x2, 0x2}}, 0x0)
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/opentype/api/cmap.go:59 +0x918
github.com/go-text/typesetting/fontscan.newFootprintFromLoader(0xebbf890, 0x0, {{0xeb00000, 0x3d3, 0x48278}, {0xec00000, 0x90, 0x4839}})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/footprint.go:84 +0x213
github.com/go-text/typesetting/fontscan.(*footprintScanner).consume(0xde87380, {0xf192f00, 0x3b}, {0x1dedaec, 0xf313aa0})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/scan.go:258 +0x30d
github.com/go-text/typesetting/fontscan.(*footprintScanner).scanDirectory.func1({0xf192f00, 0x3b}, {0x1decbf4, 0xe663ce0}, {0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/scandir.go:38 +0x22d
path/filepath.walkDir({0xf192f00, 0x3b}, {0x1decbf4, 0xe663ce0}, 0xde872dc)
    C:/app/go1.20.14.windows-386/go/src/path/filepath/path.go:438 +0x50
path/filepath.walkDir({0xd930640, 0x30}, {0x1decb54, 0xd584510}, 0xde872dc)
    C:/app/go1.20.14.windows-386/go/src/path/filepath/path.go:460 +0x2c7
path/filepath.WalkDir({0xd930640, 0x30}, 0xde872dc)
    C:/app/go1.20.14.windows-386/go/src/path/filepath/path.go:528 +0xeb
github.com/go-text/typesetting/fontscan.(*footprintScanner).scanDirectory(0xde87380, {0x1de8528, 0x24d586c}, {0xd930640, 0x30}, 0xde8733c)
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/scandir.go:43 +0x66
github.com/go-text/typesetting/fontscan.scanFontFootprints({0x1de8528, 0x24d586c}, {0xe63a000, 0x162, 0x249}, {0xd5885c0, 0x2, 0x2})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/scan.go:296 +0x196
github.com/go-text/typesetting/fontscan.refreshSystemFontsIndex({0x1de8528, 0x24d586c}, {0xd4e6540, 0x2c})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/fontmap.go:195 +0x1a8
github.com/go-text/typesetting/fontscan.initSystemFonts.func1()
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/fontmap.go:179 +0x157
sync.(*Once).doSlow(0x24d5ad8, 0xde874fc)
    C:/app/go1.20.14.windows-386/go/src/sync/once.go:74 +0xb3
sync.(*Once).Do(0x24d5ad8, 0xde874fc)
    C:/app/go1.20.14.windows-386/go/src/sync/once.go:65 +0x3f
github.com/go-text/typesetting/fontscan.initSystemFonts({0x1de8528, 0x24d586c}, {0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/fontmap.go:167 +0x78
github.com/go-text/typesetting/fontscan.(*FontMap).UseSystemFonts(0xd46e630, {0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/fontmap.go:106 +0x51
fyne.io/fyne/v2/internal/painter.loadSystemFonts(...)
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font_prod.go:20
fyne.io/fyne/v2/internal/painter.loadMap()
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:41 +0x6d
sync.(*Once).doSlow(0x24d5ab8, 0x1c8dba0)
    C:/app/go1.20.14.windows-386/go/src/sync/once.go:74 +0xb3
sync.(*Once).Do(0x24d5ab8, 0x1c8dba0)
    C:/app/go1.20.14.windows-386/go/src/sync/once.go:65 +0x3f
fyne.io/fyne/v2/internal/painter.lookupLangFont({0x1c0fce7, 0xa}, {0x1, 0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:50 +0x86
fyne.io/fyne/v2/internal/painter.lookupFaces({0x1dea508, 0xd5820d8}, {0x1dea508, 0x19f8b70}, {0x1dea508, 0x19f8b50}, {0x1c0fce7, 0xa}, {0x0, 0x0, ...})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:93 +0x2d3
fyne.io/fyne/v2/internal/painter.CachedFontFace({0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:154 +0x64c
fyne.io/fyne/v2/internal/painter.measureText({0xd5a0000, 0x12}, 0x41600000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:233 +0x4a
fyne.io/fyne/v2/internal/painter.RenderedTextSize({0xd5a0000, 0x12}, 0x41600000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/painter/font.go:219 +0xc5
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).RenderedTextSize(0xd5ba180, {0xd5a0000, 0x12}, 0x41600000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, ...)
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/internal/driver/glfw/driver.go:72 +0x52
fyne.io/fyne/v2.MeasureText({0xd5a0000, 0x12}, 0x41600000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/text.go:72 +0x72
fyne.io/fyne/v2/widget.(*RichText).updateRowBounds.func1({0xd5843f8, 0x1, 0x1})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/widget/richtext.go:481 +0x7a9
fyne.io/fyne/v2/widget.(*RichText).updateRowBounds(0xd990370)
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/widget/richtext.go:495 +0x1d2
fyne.io/fyne/v2/widget.(*Entry).SetPlaceHolder(0xd990240, {0x1c29419, 0x12})
    C:/Users/Eric/go/pkg/mod/fyne.io/fyne/v2@v2.5.1/widget/entry.go:529 +0xd7
main.fyneUI()
    C:/Users/Eric/Project/Go/chrome-driver/main.go:316 +0x37c
main.main()
    C:/Users/Eric/Project/Go/chrome-driver/main.go:88 +0x2b7

How to reproduce

I dont know how reproduce it

Screenshots

No response

Example code

no code

Fyne version

v2.5.1

Go compiler version

go1.23.2

Operating system and version

windows 11

Additional Information

No response

andydotxyz commented 1 month ago

Can you please add a break point to C:/Users/Eric/go/pkg/mod/github.com/go-text/typesetting@v0.1.0/fontscan/scandir.go:38 to find out what font is being loaded and report that here (uploading if possible)? All we can tell from the error stack is that a font on your computer is causing a crash when it loads...