Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic with unsuported font #3646

Closed
2 tasks done
hq-zhonger opened this issue Feb 10, 2023 · 9 comments
Closed
2 tasks done

panic with unsuported font #3646

hq-zhonger opened this issue Feb 10, 2023 · 9 comments
Labels
unverified A bug that has been reported but not verified

Comments

@hq-zhonger
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Projects that run normally before version 2.3.0 will run incorrectly after compiling with 2.3.0

How to reproduce

type App struct {
Proxy.Proxy // 继承 代理类
a fyne.App
w fyne.Window
AddrEntry *widget.Entry // 目标地址
TimeOutEntry *widget.Entry // 超时设置
ThreadEntry *widget.Entry // 线程设置
ProductSelectionMenu *widget.Select // 支持产品选择框
VulnerabilitiesSelectionMenu *widget.Select // 漏洞选择框
UtilizationModeEntry *widget.Entry // 利用方式输入框
DnsLogAddrEntry *widget.Entry // DnsLog地址输入框
StartButton *widget.Button // 开始按钮
StopButton *widget.Button // 结束按钮
}

// 全局初始化 基本控件
func (MyApp *App) Init() {
MyApp.AddrEntry = widget.NewEntry()
MyApp.ThreadEntry = widget.NewEntry()
MyApp.ThreadEntry.SetText("1")
MyApp.TimeOutEntry = widget.NewEntry()
MyApp.TimeOutEntry.SetText("5")

MyApp.ProductSelectionMenu = widget.NewSelect([]string{"test"}, func(s string) {

})

MyApp.VulnerabilitiesSelectionMenu = widget.NewSelect([]string{"test"}, func(s string) {

})

MyApp.UtilizationModeEntry = widget.NewEntry()
MyApp.DnsLogAddrEntry = widget.NewEntry()

MyApp.StartButton = widget.NewButtonWithIcon("开始POC", theme.MediaPlayIcon(), func() {
	MyApp.StartButton.Disable()
	MyApp.StopButton.Enable()
})

MyApp.StopButton = widget.NewButtonWithIcon("停止POC", theme.MediaStopIcon(), func() {
	MyApp.StopButton.Disable()
	MyApp.StartButton.Enable()
})
MyApp.StopButton.Disable()

}

Screenshots

11
12

Example code

2023/02/10 08:17:27 Fyne error: font load error
2023/02/10 08:17:27 Cause: unsupported font format
2023/02/10 08:17:27 At: C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:150
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x4ec pc=0x7ff7fd7549e0]

goroutine 1 [running, locked to thread]:
github.com/benoitkugler/textlayout/fonts/truetype.(*Font).Upem(0x1?)
C:/Users/zhonger/go/pkg/mod/github.com/benoitkugler/[email protected]/fonts/truetype/metrics.go:34
github.com/benoitkugler/textlayout/harfbuzz.NewFont({0x7ff7fdf2b078?, 0x0})
C:/Users/zhonger/go/pkg/mod/github.com/benoitkugler/[email protected]/harfbuzz/fonts.go:98 +0x9c
github.com/go-text/typesetting/shaping.(*HarfbuzzShaper).Shape(0xc0000ef6e0, {{0xc000026770, 0x1, 0x1}, 0x0, 0x1, 0x0, {0x7ff7fdf2b078, 0x0}, 0x340, ...})
C:/Users/zhonger/go/pkg/mod/github.com/go-text/[email protected]/shaping/shaper.go:77 +0x1d6
fyne.io/fyne/v2/internal/painter.walkString({0x7ff7fdf2b078?, 0x0}, {0xc000026074?, 0xc00047a780?}, 0x340, 0x1a4803e3e58?, 0xc0000ef8ac, 0x3f800000, 0x7ff7fde44010)
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:223 +0x185
fyne.io/fyne/v2/internal/painter.MeasureString({0x7ff7fdf2b078?, 0x0?}, {0xc000026074?, 0x1?}, 0x41500000?, 0x0?)
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:159 +0x5d
fyne.io/fyne/v2/internal/painter.measureText({0xc000026074, 0x1}, 0x26074?, {0x0, 0x0, 0x0, 0x0, 0x0})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:194 +0x8a
fyne.io/fyne/v2/internal/painter.RenderedTextSize({0xc000026074, 0x1}, 0xfd3fcff4?, {0x0, 0x0, 0x0, 0x0, 0x0})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:170 +0x9d
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).RenderedTextSize(0xc0004b4000?, {0xc000026074?, 0xc00019f9d0?}, 0xfd90d09e?, {0x0, 0x0, 0x0, 0x0, 0x0})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/driver.go:73 +0x57
fyne.io/fyne/v2.MeasureText({0xc000026074, 0x1}, 0x1?, {0x0, 0x0, 0x0, 0x0, 0x0})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/text.go:47 +0x88
fyne.io/fyne/v2/widget.(*RichText).updateRowBounds.func1({0xc000406320?, 0x1, 0x1a4d8beb298?})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/widget/richtext.go:412 +0x745
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/widget/entry.go:1187 +0x96
fyne.io/fyne/v2/widget.(*BaseWidget).setFieldsAndRefresh(0xc00047a3c0, 0xc00019fe10)
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/widget/widget.go:145 +0x3b
fyne.io/fyne/v2/widget.(*Entry).updateText(0xc00047a3c0, {0x7ff7fdde6f21, 0x1})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/widget/entry.go:1184 +0x73
fyne.io/fyne/v2/widget.(*Entry).SetText(0xc00047a3c0?, {0x7ff7fdde6f21?, 0xc00047a3c0?})
C:/Users/zhonger/go/pkg/mod/fyne.io/fyne/[email protected]/widget/entry.go:470 +0x25
go/ExploitToolsGo/Gui.(*App).Init(0xc000440000)
D:/go/ExploitToolsGo/Gui/Gui.go:185 +0xfc
go/ExploitToolsGo/Gui.(*App).ShowGui(0xc000440000)
D:/go/ExploitToolsGo/Gui/Gui.go:330 +0xa5
main.main()
D:/go/ExploitToolsGo/main.go:34 +0x2a

Fyne version

2.3.0 -> 2.2.4

Go compiler version

go 1.19.5

Operating system

Windows

Operating system version

windows 10

Additional Information

No response

@hq-zhonger hq-zhonger added the unverified A bug that has been reported but not verified label Feb 10, 2023
@andydotxyz
Copy link
Member

The error states that this is an unsupported font, but your code and steps do not mention what font you are using...

Please provide that information so it can be explored.

@andydotxyz andydotxyz changed the title panic: runtime error: invalid memory address or nil pointer dereference panic with unsuported font Feb 10, 2023
@hq-zhonger
Copy link
Author

hq-zhonger commented Feb 10, 2023

Oh, sorry, if the font is wrong before, it will run normally with garbled characters. I didn't care too much about the font error. The font I used is msyh.ttc
github.com/flopp/go-findfont

// Set Chinese environment variables
paths := findfont. List()
for _, path := range paths {
// msyh.ttc
if strings.Contains(path, "msyh.ttc") {
os. Setenv("FYNE_FONT", path)
break
}
}

@andydotxyz
Copy link
Member

Oh, sorry, if the font is wrong before, it will run normally with garbled characters. I didn't care too much about the font error. The font I used is msyh.ttc github.com/flopp/go-findfont

Thanks this now makes sense. .ttc is not supported and before it would do nothing but now it will crash. We should certainly fix this!

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Feb 11, 2023
@SpeakingShi
Copy link

Oh, sorry, if the font is wrong before, it will run normally with garbled characters. I didn't care too much about the font error. The font I used is msyh.ttc github.com/flopp/go-findfont

Thanks this now makes sense. .ttc is not supported and before it would do nothing but now it will crash. We should certainly fix this!

I used .ttc font file, too, and ran into the same problem with v2.3.0.
had to downgrade to v2.2.3 to make it work correctly.
Could it possible that .ttc font be supported in future versions?

@andydotxyz
Copy link
Member

Just for clarity Fyne has never supported .ttc fonts. The regression here is that it now crashes. This will be fixed in the next point release.

A future version should add font collection support - the go-text project we are working with is adding that so we will be able to make use of the feature soon.

@dweymouth
Copy link
Contributor

Just commenting to subscribe to this issue and .ttc support - looking forward to it!

@andydotxyz
Copy link
Member

You should really follow the feature request for .ttc. This ticket was reporting a crash regression which has since been fixed.

@dweymouth
Copy link
Contributor

You should really follow the feature request for .ttc. This ticket was reporting a crash regression which has since been fixed.

I only see a ticket tracking .otf support. Should I open a new one for .ttc or repurpose the existing one to track both font formats?

@andydotxyz
Copy link
Member

I'm sorry I meant to paste the link and somehow forgot.

#3245

andydotxyz added a commit that referenced this issue May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

4 participants