diff --git a/.gitignore b/.gitignore index 1fcf3ed..5363177 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ # Go workspace file go.work +bin/ + *.syso *.apk *.idsig diff --git a/Makefile b/Makefile index fca6149..3889a4f 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,48 @@ -.PHONY: linux +# https://gioui.org/doc/install -linux: - GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build +NAME=gost-plus +BINDIR=bin +VERSION=$(shell cat version/version.go | grep 'Version =' | sed 's/.*\"\(.*\)\".*/\1/g') +GOBUILD=CGO_ENABLED=0 go build --ldflags="-s -w" -v -x -a +GOFILES=*.go + +PLATFORM_LIST = \ + darwin-amd64 \ + darwin-arm64 \ + linux-amd64 + +WINDOWS_ARCH_LIST = \ + windows-amd64 + +linux-amd64: + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build --ldflags="-s -w" -v -x -a -win: - GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-H windowsgui" +darwin-amd64: + GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES) -arm: - GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build +darwin-arm64: + GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES) +# https://github.com/tc-hib/go-winres +windows-amd64: winres + go-winres make + GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -H windowsgui" -o $(BINDIR)/$(NAME)-$@.exe $(GOFILES) + +# go install gioui.org/cmd/gogio@latest android: - gogio -x -work -target android -minsdk 22 -version 1 -appid gost.plus github.com/go-gost/gost-plus + gogio -x -work -target android -minsdk 22 -version 1 -appid gost.plus -o $(BINDIR)/$(NAME)-$(VERSION).apk . + +gz_releases=$(addsuffix .gz, $(PLATFORM_LIST)) +zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST)) + +$(gz_releases): %.gz : % + chmod +x $(BINDIR)/$(NAME)-$(basename $@) + gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-$(basename $@) + +$(zip_releases): %.zip : % + zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(VERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe + +releases: $(gz_releases) $(zip_releases) clean: - rm gost-plus.exe gost-plus gost-plus.apk + rm $(BINDIR)/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a68a2d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# GOST-PLUS + +A cross-platform GUI client for [GOST.PLUS](https://gost.plus) built with [gioui](https://gioui.org). diff --git a/ui/fonts/NotoSansSC-Bold.ttf b/ui/fonts/NotoSansSC-Bold.ttf new file mode 100644 index 0000000..b9010df Binary files /dev/null and b/ui/fonts/NotoSansSC-Bold.ttf differ diff --git a/ui/fonts/NotoSansSC-Regular.ttf b/ui/fonts/NotoSansSC-Regular.ttf new file mode 100644 index 0000000..4d4cadb Binary files /dev/null and b/ui/fonts/NotoSansSC-Regular.ttf differ diff --git a/ui/fonts/font.go b/ui/fonts/font.go new file mode 100644 index 0000000..40f154c --- /dev/null +++ b/ui/fonts/font.go @@ -0,0 +1,36 @@ +package fonts + +import ( + _ "embed" + "fmt" + + "gioui.org/font" + "gioui.org/font/opentype" +) + +//go:embed NotoSansSC-Regular.ttf +var fontNotoRegular []byte + +//go:embed NotoSansSC-Bold.ttf +var fontNotoBold []byte + +var ( + collection []font.FontFace +) + +func init() { + register(fontNotoRegular) + register(fontNotoBold) +} + +func Collection() []font.FontFace { + return collection +} + +func register(ttf []byte) { + faces, err := opentype.ParseCollection(ttf) + if err != nil { + panic(fmt.Errorf("failed to parse font: %v", err)) + } + collection = append(collection, faces[0]) +} diff --git a/ui/page/menu.go b/ui/page/menu.go index 464e600..972ebba 100644 --- a/ui/page/menu.go +++ b/ui/page/menu.go @@ -72,7 +72,7 @@ func (p *menuPage) Layout(gtx C, th *material.Theme) D { Axis: layout.Vertical, }.Layout(gtx, layout.Rigid(func(gtx C) D { - label := material.H6(th, "Services") + label := material.H6(th, "Tunnels") label.Font.Weight = font.Bold return layout.Inset{Top: 5, Bottom: 5}.Layout(gtx, label.Layout) }), diff --git a/ui/ui.go b/ui/ui.go index c212658..e901c13 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -1,10 +1,10 @@ package ui import ( - "gioui.org/font/gofont" "gioui.org/layout" "gioui.org/text" "gioui.org/widget/material" + "github.com/go-gost/gost-plus/ui/fonts" "github.com/go-gost/gost-plus/ui/page" ) @@ -18,7 +18,8 @@ type UI struct { func NewUI() *UI { th := material.NewTheme() - th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection())) + // th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection())) + th.Shaper = text.NewShaper(text.WithCollection(fonts.Collection())) // th.Bg = color.NRGBA(colornames.Brown800) // th.Fg = color.NRGBA(colornames.Grey50)