Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

panic: Cannot create a label with a nil font #13

Closed
ShawnMilo opened this issue Mar 18, 2015 · 13 comments
Closed

panic: Cannot create a label with a nil font #13

ShawnMilo opened this issue Mar 18, 2015 · 13 comments

Comments

@ShawnMilo
Copy link
Contributor

I was able to succesfully build the progress_bar binary from the samples folder using the Dockerfile described in #7. However, when I run the binary on my machine I receive the following panic:

$ ./progress_bar 
Warning: Failed to load default font - Unable to find font 'Arial.ttf'
panic: Cannot create a label with a nil font

goroutine 5 [running]:
github.com/google/gxui/mixins.(*Label).Init(0xc20807e000, 0x7f9925c2cdd8, 0xc20807e000, 0x7f9925c2cd20, 0xc20807c000, 0x0, 0x0, 0x3f4ccccd3f4ccccd, 0x3f8000003f4ccccd)
    /go/src/github.com/google/gxui/mixins/label.go:32 +0x6f
github.com/google/gxui/themes/dark.CreateLabel(0xc20807c000, 0x0, 0x0)
    /go/src/github.com/google/gxui/themes/dark/label.go:15 +0x141
github.com/google/gxui/themes/dark.(*Theme).CreateLabel(0xc20807c000, 0x0, 0x0)
    /go/src/github.com/google/gxui/themes/dark/theme.go:130 +0x3a
main.appMain(0x7f9925c2cc40, 0xc20803a3c0)
    /go/src/github.com/google/gxui/samples/progress_bar/main.go:22 +0x85
created by github.com/google/gxui/drivers/gl.StartDriver
    /go/src/github.com/google/gxui/drivers/gl/driver.go:52 +0x20a

goroutine 1 [runnable, locked to thread]:
github.com/go-gl/glfw/v3.1/glfw._Cfunc_glfwWaitEvents()
    /go/src/github.com/go-gl/glfw/v3.1/glfw/:874 +0x45
github.com/go-gl/glfw/v3.1/glfw.WaitEvents()
    /go/src/github.com/go-gl/glfw/v3.1/glfw/window.go:642 +0x1b
github.com/google/gxui/drivers/gl.(*Driver).run(0xc20803a3c0)
    /go/src/github.com/google/gxui/drivers/gl/driver.go:95 +0x81
github.com/google/gxui/drivers/gl.StartDriver(0x0, 0x0, 0x9077a0)
    /go/src/github.com/google/gxui/drivers/gl/driver.go:53 +0x21a
main.main()
    /go/src/github.com/google/gxui/samples/progress_bar/main.go:54 +0x48

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/src/go/src/runtime/asm_amd64.s:2232 +0x1
@ben-clayton
Copy link
Contributor

argh. So I added some code to look for fonts in the directories specified by FontPaths, I'm guessing Arial.ttf isn't in any of those places? Maybe it is, but has the wrong case?
I'm guessing your system has an arial font somewhere, do you know where it might be found?

@ShawnMilo
Copy link
Contributor Author

Evidently I have no Arial.ttf.

Run as root:
$ find / -iname arial.ttf
No results

I'm running Xubuntu 14.04.

I do have a bunch of fonts in /usr/share/fonts/truetype/.

 $ pwd
/usr/share/fonts/truetype

 $ find . -iname '*.ttf'
./kacst-one/KacstOne-Bold.ttf
./kacst-one/KacstOne.ttf
./liberation/LiberationSerif-Bold.ttf
./liberation/LiberationMono-BoldItalic.ttf
./liberation/LiberationSerif-BoldItalic.ttf
./liberation/LiberationSans-Italic.ttf
./liberation/LiberationSansNarrow-Regular.ttf
./liberation/LiberationSans-Regular.ttf
./liberation/LiberationSansNarrow-Italic.ttf
./liberation/LiberationMono-Regular.ttf
./liberation/LiberationSansNarrow-BoldItalic.ttf
./liberation/LiberationSansNarrow-Bold.ttf
./liberation/LiberationSans-BoldItalic.ttf
./liberation/LiberationMono-Bold.ttf
./liberation/LiberationSerif-Italic.ttf
./liberation/LiberationMono-Italic.ttf
./liberation/LiberationSans-Bold.ttf
./liberation/LiberationSerif-Regular.ttf
./ttf-punjabi-fonts/lohit_pa.ttf
./ttf-punjabi-fonts/Saab.ttf
./fonts-japanese-gothic.ttf
./lyx/msbm10.ttf
./lyx/cmr10.ttf
./lyx/eufm10.ttf
./lyx/cmsy10.ttf
./lyx/msam10.ttf
./lyx/rsfs10.ttf
./lyx/esint10.ttf
./lyx/cmex10.ttf
./lyx/cmmi10.ttf
./lyx/wasy10.ttf
./freefont/FreeSerifBoldItalic.ttf
./freefont/FreeSerifBold.ttf
./freefont/FreeSansOblique.ttf
./freefont/FreeMono.ttf
./freefont/FreeSans.ttf
./freefont/FreeSansBoldOblique.ttf
./freefont/FreeSansBold.ttf
./freefont/FreeSerif.ttf
./freefont/FreeMonoBoldOblique.ttf
./freefont/FreeMonoOblique.ttf
./freefont/FreeMonoBold.ttf
./freefont/FreeSerifItalic.ttf
./takao-gothic/TakaoPGothic.ttf
./kacst/KacstDigital.ttf
./kacst/KacstLetter.ttf
./kacst/KacstScreen.ttf
./kacst/KacstPoster.ttf
./kacst/KacstArt.ttf
./kacst/KacstQurn.ttf
./kacst/KacstNaskh.ttf
./kacst/KacstDecorative.ttf
./kacst/KacstTitleL.ttf
./kacst/KacstTitle.ttf
./kacst/KacstPen.ttf
./kacst/mry_KacstQurn.ttf
./kacst/KacstBook.ttf
./kacst/KacstFarsi.ttf
./kacst/KacstOffice.ttf
./lao/Phetsarath_OT.ttf
./tibetan-machine/TibetanMachineUni.ttf
./sinhala/lklug.ttf
./abyssinica/AbyssinicaSIL-R.ttf
./tlwg/Norasi-BoldItalic.ttf
./tlwg/Garuda.ttf
./tlwg/TlwgMono.ttf
./tlwg/TlwgTypewriter-Bold.ttf
./tlwg/Garuda-Bold.ttf
./tlwg/TlwgTypist-Oblique.ttf
./tlwg/TlwgTypist.ttf
./tlwg/Umpush-LightOblique.ttf
./tlwg/Waree-Bold.ttf
./tlwg/Kinnari-Bold.ttf
./tlwg/Norasi.ttf
./tlwg/Kinnari.ttf
./tlwg/Umpush-Bold.ttf
./tlwg/Kinnari-BoldOblique.ttf
./tlwg/Kinnari-Italic.ttf
./tlwg/TlwgTypo-Bold.ttf
./tlwg/TlwgMono-Oblique.ttf
./tlwg/TlwgTypewriter-BoldOblique.ttf
./tlwg/Norasi-BoldOblique.ttf
./tlwg/Norasi-Bold.ttf
./tlwg/TlwgTypist-BoldOblique.ttf
./tlwg/TlwgTypist-Bold.ttf
./tlwg/Umpush-Light.ttf
./tlwg/Garuda-BoldOblique.ttf
./tlwg/Norasi-Italic.ttf
./tlwg/Purisa.ttf
./tlwg/Sawasdee-Bold.ttf
./tlwg/TlwgTypo-BoldOblique.ttf
./tlwg/Purisa-Bold.ttf
./tlwg/Kinnari-Oblique.ttf
./tlwg/Umpush-BoldOblique.ttf
./tlwg/Loma-Oblique.ttf
./tlwg/TlwgTypewriter-Oblique.ttf
./tlwg/Kinnari-BoldItalic.ttf
./tlwg/Purisa-Oblique.ttf
./tlwg/Garuda-Oblique.ttf
./tlwg/TlwgTypo.ttf
./tlwg/Umpush-Oblique.ttf
./tlwg/TlwgMono-Bold.ttf
./tlwg/Purisa-BoldOblique.ttf
./tlwg/Waree-Oblique.ttf
./tlwg/Sawasdee-Oblique.ttf
./tlwg/Norasi-Oblique.ttf
./tlwg/Loma.ttf
./tlwg/TlwgTypewriter.ttf
./tlwg/TlwgMono-BoldOblique.ttf
./tlwg/Umpush.ttf
./tlwg/TlwgTypo-Oblique.ttf
./tlwg/Loma-BoldOblique.ttf
./tlwg/Sawasdee.ttf
./tlwg/Loma-Bold.ttf
./tlwg/Waree-BoldOblique.ttf
./tlwg/Waree.ttf
./tlwg/Sawasdee-BoldOblique.ttf
./ttf-khmeros-core/KhmerOSsys.ttf
./ttf-khmeros-core/KhmerOS.ttf
./padauk/Padauk.ttf
./padauk/Padauk-bold.ttf
./padauk/Padauk-book.ttf
./padauk/Padauk-bookbold.ttf
./nanum/NanumGothicBold.ttf
./nanum/NanumGothic.ttf
./nanum/NanumMyeongjoBold.ttf
./nanum/NanumMyeongjo.ttf
./nanum/NanumBarunGothic.ttf
./nanum/NanumBarunGothicBold.ttf
./droid/DroidSerif-BoldItalic.ttf
./droid/DroidSerif-Bold.ttf
./droid/DroidSerif-Italic.ttf
./droid/DroidSans.ttf
./droid/DroidNaskh-Bold.ttf
./droid/DroidSansEthiopic-Regular.ttf
./droid/DroidSansArmenian.ttf
./droid/DroidSansFallbackFull.ttf
./droid/DroidSans-Bold.ttf
./droid/DroidSansHebrew-Bold.ttf
./droid/DroidSansMono.ttf
./droid/DroidSansGeorgian.ttf
./droid/DroidNaskh-Regular.ttf
./droid/DroidSansEthiopic-Bold.ttf
./droid/DroidSansJapanese.ttf
./droid/DroidSerif-Regular.ttf
./droid/DroidSansThai.ttf
./droid/DroidSansHebrew-Regular.ttf
./openoffice/opens___.ttf
./dejavu/DejaVuSerif.ttf
./dejavu/DejaVuSans.ttf
./dejavu/DejaVuSansMono-Bold.ttf
./dejavu/DejaVuSans-Bold.ttf
./dejavu/DejaVuSerif-Bold.ttf
./dejavu/DejaVuSansMono.ttf
./ubuntu-font-family/UbuntuMono-R.ttf
./ubuntu-font-family/UbuntuMono-B.ttf
./ubuntu-font-family/Ubuntu-RI.ttf
./ubuntu-font-family/Ubuntu-LI.ttf
./ubuntu-font-family/Ubuntu-MI.ttf
./ubuntu-font-family/Ubuntu-C.ttf
./ubuntu-font-family/Ubuntu-R.ttf
./ubuntu-font-family/UbuntuMono-BI.ttf
./ubuntu-font-family/Ubuntu-M.ttf
./ubuntu-font-family/Ubuntu-L.ttf
./ubuntu-font-family/Ubuntu-BI.ttf
./ubuntu-font-family/Ubuntu-B.ttf
./ubuntu-font-family/UbuntuMono-RI.ttf
./ttf-indic-fonts-core/lohit_gu.ttf
./ttf-indic-fonts-core/lohit_hi.ttf
./ttf-indic-fonts-core/lohit_ta.ttf
./ttf-indic-fonts-core/Vemana.ttf
./ttf-indic-fonts-core/lohit_bn.ttf
./ttf-indic-fonts-core/Malige-n.ttf
./ttf-indic-fonts-core/utkal.ttf
./ttf-indic-fonts-core/gargi.ttf
./ttf-indic-fonts-core/Rekha.ttf
./ttf-indic-fonts-core/Kedage-b.ttf
./ttf-indic-fonts-core/Kedage-n.ttf
./ttf-indic-fonts-core/Malige-b.ttf
./ttf-indic-fonts-core/Rachana_04.ttf
./ttf-indic-fonts-core/MuktiNarrow.ttf
./ttf-indic-fonts-core/Pothana2000.ttf
./ttf-indic-fonts-core/MuktiNarrowBold.ttf
./ttf-indic-fonts-core/Meera_04.ttf

@StefanSchroeder
Copy link

You should consider installing the ttf-mscorefonts package.

@ShawnMilo
Copy link
Contributor Author

@StefanSchroeder: I'd rather not if I can avoid it, because it requires accepting a Microsoft EULA. I'll leave it up to @ben-clayton -- if you want me to leave my machine in its current state to test a potential fix, I'll leave it alone. If you want me to install the Microsoft package so no further work is needed, I'll do that to save the effort, since it's not my effort.

@ben-clayton
Copy link
Contributor

I'm not sure what the best option is in this case.
Obviously any text rendering requires a font. With e441085, the driver scans the known OS font directories, but if we're trying to support a set of operating systems that have no common fonts, then this approach just isn't going to work.
The only real option would be to include a font with the GXUI library - which is doable, but has its own problems:

  • We'd have to find a font that looks good and doesn't have any licensing issues.
  • GXUI will have to be told the directory of this font. This is effectively what the --data command line argument does, but I was hoping to try and remove this as it is additional complexity to getting something on the screen.

I can start investigating what our options are with a bundled font. In the meantime, to run the samples you should be able to take any font you like, rename it to Arial.ttf and set --data to the directory that it sits in. For applications you develop yourself, you are always free to call Theme.SetDefaultFont before any text controls are created.

@ShawnMilo
Copy link
Contributor Author

Thanks for that info, @ben-clayton. I'm sure I can make it work by installing the font, using the workaround you suggested, or forking and adding a font I have as an option. Feel free to close this issue if you think it's a narrow part of the bigger --data issue you're dealing with separately.

@ryanseys
Copy link

I am attempting to run on Mac 10.10.2 and getting the same error. I definitely have Arial on my machine.

@ShawnMilo
Copy link
Contributor Author

@ryanseys Please report the full path to Arial.ttf. Did you check the things @ben-clayton suggested above in this thread? I happened to have a Mac lying around so I checked, and my Arial.ttf is in /Library/Fonts/Arial.ttf, which isn't in the FontPaths slice mentioned above. I'm sure you can make it work by adding that /Library path to FontPaths.

@ryanseys
Copy link

I copied Arial.ttf into /Library/Fonts and that worked. However changing the FontPaths list to include /Library/Fonts/Microsoft/ (where Arial.ttf resides) didn't work. I'm not sure why that is the case.

@ben-clayton
Copy link
Contributor

I'll keep this issue open as a 'we need bundle a font' issue. It's good to keep the context why.

@ben-clayton
Copy link
Contributor

This should now be fixed as we bundle a font. Please let us know if you have more issues.

@ShawnMilo
Copy link
Contributor Author

Confirmed: The progress_bar sample runs on my Xbuntu 14.04 machine, without the MS font package. Thanks!

@ben-clayton
Copy link
Contributor

That's great news - thank you for confirming!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants