add noto font

This commit is contained in:
ginuerzh
2023-12-14 16:56:48 +08:00
parent 905c6363ff
commit bc140c76e2
8 changed files with 86 additions and 12 deletions
+2
View File
@@ -20,6 +20,8 @@
# Go workspace file
go.work
bin/
*.syso
*.apk
*.idsig
+41 -9
View File
@@ -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)/*
+3
View File
@@ -0,0 +1,3 @@
# GOST-PLUS
A cross-platform GUI client for [GOST.PLUS](https://gost.plus) built with [gioui](https://gioui.org).
Binary file not shown.
Binary file not shown.
+36
View File
@@ -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])
}
+1 -1
View File
@@ -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)
}),
+3 -2
View File
@@ -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)