Navigation Menu

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

SegFault while loading Japanese Fonts #1200

Closed
JohnPiwinski opened this issue Jul 21, 2020 · 2 comments
Closed

SegFault while loading Japanese Fonts #1200

JohnPiwinski opened this issue Jul 21, 2020 · 2 comments
Labels
bug Something isn't working question A question has been asked
Milestone

Comments

@JohnPiwinski
Copy link

When trying to display a kanji character via the FYNE_FONT environment variable, my program reaches a segmentation fault and exits. The root of the error appears to reside in the goki truetype font loading system. Removing the environment variable allows my program to execute normally; however, blank rectangles are displayed instead of kanji as mentioned in issue #63. I pulled the ttf files from https://github.com/minoryorg/Noto-Sans-CJK-JP.

To Reproduce:
FYNE_FONT=NotoSansCJKjp-Regular.ttf ./my_fyne_executable

Device:

  • OS: Ubuntu
  • Version: Eoan 19.10
  • Go version: go1.14.6
  • Fyne version: Latest

Verbatim Output:

Fyne error: font load error

Cause: freetype: invalid TrueType format: bad TTF version
At: /go/src/fyne.io/fyne/internal/painter/font.go:20
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1d4 pc=0x7676a1]

goroutine 1 [running, locked to thread]:
fyne.io/fyne/vendor/github.com/goki/freetype/truetype.(*Font).Bounds(0x0, 0xc0000003cb, 0x200, 0xc000644000)
/go/src/fyne.io/fyne/vendor/github.com/goki/freetype/truetype/truetype.go:386 +0x11
fyne.io/fyne/vendor/github.com/goki/freetype/truetype.NewFace(0x0, 0xc00063ba88, 0xc00063ba88, 0x10bbca0)
/go/src/fyne.io/fyne/vendor/github.com/goki/freetype/truetype/face.go:205 +0x2d7
fyne.io/fyne/internal/painter.CachedFontFace(0xc000000000, 0xc00063ba88, 0x0, 0x0)
/go/src/fyne.io/fyne/internal/painter/font.go:164 +0x177
fyne.io/fyne/internal/painter.RenderedTextSize(0x97b0e2, 0x1, 0xe, 0x0, 0x10bae60, 0x9a7bc0)
/go/src/fyne.io/fyne/internal/painter/font.go:32 +0xa6
fyne.io/fyne/internal/driver/glfw.(*gLDriver).RenderedTextSize(0xc0000b80f0, 0x97b0e2, 0x1, 0xe, 0x0, 0xc0000c26c0, 0xe)
/go/src/fyne.io/fyne/internal/driver/glfw/driver.go:33 +0x5a
fyne.io/fyne.MeasureText(0x97b0e2, 0x1, 0xe, 0x0, 0xc0000c26c0, 0xc000609ba8)
/go/src/fyne.io/fyne/text.go:40 +0x86
fyne.io/fyne/widget.(*textProvider).charMinSize(0xc00051e090, 0xc000609c18, 0x7e43e4)
/go/src/fyne.io/fyne/widget/text.go:217 +0xbb
fyne.io/fyne/widget.(*textRenderer).Layout(0xc000034040, 0x0, 0x0)
/go/src/fyne.io/fyne/widget/text.go:284 +0x8d
fyne.io/fyne/widget.(*textRenderer).Refresh(0xc000034040)
/go/src/fyne.io/fyne/widget/text.go:354 +0x569
fyne.io/fyne/widget.(*textProvider).CreateRenderer(0xc00051e090, 0xc00051e090, 0x5)
/go/src/fyne.io/fyne/widget/text.go:69 +0xda
fyne.io/fyne/widget.(*Label).CreateRenderer(0xc000122080, 0x9611c0, 0xc000122080)
/go/src/fyne.io/fyne/widget/label.go:104 +0x10c
fyne.io/fyne/internal/cache.Renderer(0xa343c0, 0xc000122080, 0xc000122080, 0x9a7bc8)
/go/src/fyne.io/fyne/internal/cache/widget.go:29 +0x112
fyne.io/fyne/widget.(*BaseWidget).MinSize(0xc000122080, 0xa343c0, 0xc000122080)
/go/src/fyne.io/fyne/widget/widget.go:84 +0x43
fyne.io/fyne/widget.(*Label).MinSize(0xc000122080, 0xa33920, 0xc000122080)
/go/src/fyne.io/fyne/widget/label.go:110 +0x4c
fyne.io/fyne/layout.(*boxLayout).MinSize(0xc0000e1f5a, 0xc00000e080, 0x2, 0x2, 0x8b8da0, 0xc0000c2801)
/go/src/fyne.io/fyne/layout/boxlayout.go:128 +0x1d0
fyne.io/fyne.NewContainerWithLayout(0xa2ad80, 0xc0000e1f5a, 0xc00000e080, 0x2, 0x2, 0x0)
/go/src/fyne.io/fyne/container.go:130 +0x9b
main.generate_text_question_form(0x97c5db, 0x5, 0x18b62)
/Desktop/tmk/final.go:66 +0x13f
main.main()
/Desktop/tmk/final.go:82 +0xfa

@andydotxyz
Copy link
Member

I can't replicate here unfortunately, but the bug needs fixed.
Can you please try adding the following lines at internal/painter/font.go line 158 (immediately above the &fontCacheItem line:

		if f1 == nil {
			f1 = f2
		}

Let me know if that helps, if so we can apply it to next release...

@andydotxyz andydotxyz added bug Something isn't working question A question has been asked labels Jul 21, 2020
@andydotxyz
Copy link
Member

Should be fixed on develop now, commit 5db0633 - will try to get it in 1.3.3 as well

@andydotxyz andydotxyz added this to the 1.3.x milestone Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question A question has been asked
Projects
None yet
Development

No branches or pull requests

2 participants