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

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

    in mac run fc-list :lang=zh|grep ttf got a list of chinese font , but it does not work:

    2023/06/04 12:55:03 Fyne error:  font load error
    2023/06/04 12:55:03   Cause: freetype: invalid TrueType format: bad TTF version
    2023/06/04 12:55:03   At: /tmp/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:186
    2023/06/04 12:55:03 Fyne error:  font load error
    2023/06/04 12:55:03   Cause: collections not allowed
    2023/06/04 12:55:03   At: /tmp/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:150
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1003bf9a9]
    

    How to reproduce

    in mac run fc-list :lang=zh|grep ttf got a list of chinese font ,

    Screenshots

    No response

    Example code

    	fontPaths := findfont.List()
    	for _, path := range fontPaths {
    		if strings.Contains(path, "simhei.ttf") || strings.Contains(path, "NISC18030.ttf") {
    			os.Setenv("FYNE_FONT", path)
    			break
    

    Fyne version

    2.3.4

    Go compiler version

    lastest

    Operating system and version

    macos 13.4

    Additional Information

    my stardard mac font list :

    /System/Library/Fonts/STHeiti Medium.ttc: 黑体\-简,Heiti SC,黑體\-簡,黒体\-簡,Heiti\-간체:style=中等,Medium,中黑,Halbfett,Normaali,Moyen,Medio,ミディアム,중간체,Médio,Средний,Normal,Media
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=常规体,Regular,標準體
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=常规体,Regular,標準體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=常规体,Regular,標準體
    /System/Library/Fonts/STHeiti Light.ttc: 黑体\-繁,Heiti TC,黑體\-繁,黒体\-繁,Heiti\-번체:style=细体,Light,細體,Mager,Fein,Ohut,Fin,Leggero,ライト,가는체,Licht,Tynn,Leve,Светлый,Fina
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-简,Songti SC,宋體\-簡:style=细体,Light,細體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-繁,Songti TC,宋體\-繁:style=常规体,Regular,標準體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-简,Songti SC,宋體\-簡:style=常规体,Regular,標準體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=中黑体,Medium,中黑體
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=中黑体,Medium,中黑體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-繁,Songti TC,宋體\-繁:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=中粗体,Semibold,中粗體
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=中粗体,Semibold,中粗體
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=中黑体,Medium,中黑體
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=常规体,Regular,標準體
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=中粗体,Semibold,中粗體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=常规体,Regular,標準體
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=常规体,Regular,標準體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-简,Songti SC,宋體\-簡:style=黑体,Black,黑體
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=极细体,Ultralight,極細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=极细体,Ultralight,極細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=极细体,Ultralight,極細體
    /Library/Fonts/Arial Unicode.ttf: Arial Unicode MS:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=极细体,Ultralight,極細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=极细体,Ultralight,極細體
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=极细体,Ultralight,極細體
    /System/Library/Fonts/Hiragino Sans GB.ttc: .Hiragino Sans GB Interface:style=W6
    /System/Library/Fonts/Hiragino Sans GB.ttc: .Hiragino Sans GB Interface:style=W3
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=细体,Light,細體
    /System/Library/Fonts/Hiragino Sans GB.ttc: 冬青黑体简体中文,Hiragino Sans GB,冬青黑體簡體中文,ヒラギノ角ゴ 簡体中文,Hiragino Sans GB W3,冬青黑體簡體中文 W3,ヒラギノ角ゴ 簡体中文 W3,冬青黑体简体中文 W3:style=W3,Regular
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=纤细体,Thin,纖細體
    /System/Library/Fonts/Supplemental/Arial Unicode.ttf: Arial Unicode MS:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=中黑体,Medium,中黑體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=中黑体,Medium,中黑體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=纤细体,Thin,纖細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=纤细体,Thin,纖細體
    /System/Library/Fonts/STHeiti Medium.ttc: 黑体\-繁,Heiti TC,黑體\-繁,黒体\-繁,Heiti\-번체:style=中等,Medium,中黑,Halbfett,Normaali,Moyen,Medio,ミディアム,중간체,Médio,Средний,Normal,Media
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=细体,Light,細體
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=中黑体,Medium,中黑體
    /System/Library/Fonts/PingFang.ttc: .苹方\-繁,.PingFang TC,.蘋方\-繁:style=纤细体,Thin,纖細體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-简,Songti SC,宋體\-簡:style=粗体,Bold,粗體
    /System/Library/Fonts/STHeiti Light.ttc: 黑体\-简,Heiti SC,黑體\-簡,黒体\-簡,Heiti\-간체:style=细体,Light,細體,Mager,Fein,Ohut,Fin,Leggero,ライト,가는체,Licht,Tynn,Leve,Светлый,Fina
    /System/Library/Fonts/PingFang.ttc: .苹方\-港,.PingFang HK,.蘋方\-港:style=纤细体,Thin,纖細體
    /System/Library/Fonts/PingFang.ttc: .苹方\-简,.PingFang SC,.蘋方\-簡:style=纤细体,Thin,纖細體
    /System/Library/Fonts/Supplemental/Songti.ttc: 宋体\-繁,Songti TC,宋體\-繁:style=粗体,Bold,粗體
    /System/Library/Fonts/Supplemental/Songti.ttc: STSong:style=常规体,Regular,標準體,Ordinær,Normal,Normaali,Regolare,レギュラー,일반체,Regulier,Обычный
    /System/Library/Fonts/Supplemental/NISC18030.ttf: GB18030 Bitmap:style=常规体,Regular,標準體,Ordinær,Normal,Normaali,Regolare,レギュラー,일반체,Regulier,Обычный
    /System/Library/Fonts/PingFang.ttc: 苹方\-简,PingFang SC,蘋方\-簡:style=中粗体,Semibold,中粗體
    /System/Library/Fonts/PingFang.ttc: 苹方\-港,PingFang HK,蘋方\-港:style=中粗体,Semibold,中粗體
    /System/Library/Fonts/LastResort.otf: .LastResort:style=Regular
    /System/Library/Fonts/Hiragino Sans GB.ttc: 冬青黑体简体中文,Hiragino Sans GB,冬青黑體簡體中文,ヒラギノ角ゴ 簡体中文,Hiragino Sans GB W6,冬青黑體簡體中文 W6,ヒラギノ角ゴ 簡体中文 W6,冬青黑体简体中文 W6:style=W6,Bold
    /System/Library/Fonts/PingFang.ttc: 苹方\-繁,PingFang TC,蘋方\-繁:style=中粗体,Semibold,中粗體
    

    I choose STHeiti Light.ttc:

    2023/06/05 10:37:47 Fyne error:  font load error
    2023/06/05 10:37:47   Cause: collections not allowed
    2023/06/05 10:37:47   At: /tmp/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:150
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1003bfa69]
    

    I choose /System/Library/Fonts/Supplemental/NISC18030.ttf:

    2023/06/04 12:55:03 Fyne error:  font load error
    2023/06/04 12:55:03   Cause: freetype: invalid TrueType format: bad TTF version
    2023/06/04 12:55:03   At: /tmp/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:186
    2023/06/04 12:55:03 Fyne error:  font load error
    2023/06/04 12:55:03   Cause: collections not allowed
    2023/06/04 12:55:03   At: /tmp/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/font.go:150
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1003bf9a9]
    

    As I read a issue , fyne will not support *.ttc anymore, so I attach only *.ttf attachment.

    NISC18030.ttf.gz