passgo/cmd/passgo-gui/impl_darwin.go

68 lines
1.3 KiB
Go
Raw Normal View History

2019-09-06 11:43:14 -04:00
//+build darwin
package main
import (
"os"
"os/user"
"path"
"gioui.org/font/opentype"
"gioui.org/text"
)
2019-11-20 15:48:56 -05:00
var (
noidLabelText = "No GPG ids available. Please create a private key or enter a key ID above"
)
func setFont() error {
f, err := os.Open("/System/Library/Fonts/AppleSDGothicNeo.ttc")
if err != nil {
log(Info, "Cannot open system font collection")
return err
2019-09-06 10:46:23 -04:00
}
fnts, err := opentype.ParseCollectionReaderAt(f)
if err != nil {
log(Info, "Cannot parse font collection")
return err
}
fnt, err := fnts.Font(0)
if err != nil {
log(Info, "Cannot get font from collection")
return err
}
collection = append(collection, text.FontFace{Font: text.Font{}, Face: fnt})
if err != nil {
log(Info, "Cannot access font from font collection")
return err
}
//font.Register(text.Font{}, face)
return nil
}
func init() {
fontSize = 16
setFont()
}
func getConfDir() (string, error) {
usr, err := user.Current()
if err != nil {
log(Error, "Cannot get current user: ", err)
return "", err
}
ret := path.Join(usr.HomeDir, ".config/passgo")
if _, err := os.Stat(ret); os.IsNotExist(err) {
err = os.MkdirAll(ret, 0700)
if err != nil {
2019-09-06 10:46:23 -04:00
log(Info, "Cannot create configuration directory ", confDir)
return "", err
} else {
log(Info, "Configuration directory created")
return ret, nil
}
}
return ret, nil
}