Skip to content

Commit

Permalink
add noto fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Jun 3, 2024
1 parent 64838e2 commit 42846b8
Show file tree
Hide file tree
Showing 33 changed files with 514 additions and 130 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ windows-arm64:

# go install gioui.org/cmd/gogio@latest
android:
gogio -x -work -target android -minsdk 22 -version $(VERSION).7 -name GOST+ -signkey build/sign.keystore -signpass android -appid gost.plus -o $(BINDIR)/$(NAME)-$(VERSION).aab .
gogio -x -work -target android -minsdk 22 -version $(VERSION).8 -name GOST+ -signkey build/sign.keystore -signpass android -appid gost.plus -o $(BINDIR)/$(NAME)-$(VERSION).aab .
gogio -x -work -target android -minsdk 22 -version $(VERSION).8 -name GOST+ -signkey build/sign.keystore -signpass android -appid gost.plus -o $(BINDIR)/$(NAME)-$(VERSION).apk .

gz_releases=$(addsuffix .gz, $(PLATFORM_LIST))
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
Expand Down
20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/go-gost/gost.plus

go 1.22.0
go 1.22

toolchain go1.22.2

require (
gioui.org v0.6.0
Expand All @@ -26,7 +28,7 @@ require (
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-text/typesetting v0.1.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -36,7 +38,7 @@ require (
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pires/go-proxyproto v0.7.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rs/xid v1.3.0 // indirect
Expand All @@ -52,14 +54,14 @@ require (
github.com/xtaci/smux v1.5.24 // indirect
github.com/yl2chen/cidranger v1.0.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/image v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)
41 changes: 18 additions & 23 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04/go.mod h
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
Expand Down Expand Up @@ -83,8 +81,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
Expand Down Expand Up @@ -126,29 +124,26 @@ github.com/yl2chen/cidranger v1.0.2 h1:lbOWZVCG1tCRX4u24kuM1Tb4nHqWkDxwLdoS+Seva
github.com/yl2chen/cidranger v1.0.2/go.mod h1:9U1yz7WPYDwf0vpNWFaeRh0bjwz5RVgRy/9UEQfHl0g=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw=
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/exp/shiny v0.0.0-20240103183307-be819d1f06fc h1:OG+uKOKt/BW+ydf/M7gym7ONo8U+dyIlLazys3du298=
golang.org/x/exp/shiny v0.0.0-20240103183307-be819d1f06fc/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
53 changes: 39 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"context"
"fmt"
"log/slog"
_ "net"
"os"
"time"
Expand All @@ -16,35 +18,30 @@ import (
"github.com/go-gost/gost.plus/tunnel"
"github.com/go-gost/gost.plus/tunnel/entrypoint"
"github.com/go-gost/gost.plus/ui"
"github.com/go-gost/gost.plus/ui/page"
"github.com/go-gost/gost.plus/ui/theme"
"github.com/go-gost/gost.plus/ui/widget"
_ "github.com/go-gost/gost.plus/winres"
)

func main() {
Init()

go func() {
var w app.Window
w.Option(app.Title("GOST+"))
w.Option(app.MinSize(800, 600))
err := run(&w)
if err != nil {
if err := run(); err != nil {
logger.Default().Fatal(err)
}
os.Exit(0)
}()
app.Main()
}

func run(w *app.Window) error {
go func() {
for e := range runner.Event() {
if e.TaskID == runner.TaskUpdateStats {
w.Invalidate()
}
}
}()

func run() error {
ui := ui.NewUI()

go handleEvent(ui)

w := ui.Window()
var ops op.Ops
for {
switch e := w.Event().(type) {
Expand All @@ -60,6 +57,34 @@ func run(w *app.Window) error {
}
}

func handleEvent(ui *ui.UI) {
for {
select {
case e := <-ui.Router().Event():
switch e.ID {
case page.EventThemeChanged:
slog.Debug("theme changed", "event", e.ID)
ui.Window().Option(app.StatusColor(theme.Current().Material.Bg))
}

case e := <-runner.Event():
switch e.TaskID {
case runner.TaskUpdateStats:
ui.Window().Invalidate()

default:
if e.Err != nil {
slog.Error(fmt.Sprintf("task: %s", e.Err), "task", e.TaskID)
ui.Router().Notify(widget.Message{
Type: widget.Error,
Content: e.Err.Error(),
})
}
}
}
}
}

func Init() {
config.Init()
tunnel.LoadConfig()
Expand Down
Binary file added ui/fonts/NotoSans-Bold.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSans-Regular.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSans-SemiBold.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSansMono-Regular.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSansSC-Bold.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSansSC-Regular.ttf
Binary file not shown.
Binary file added ui/fonts/NotoSansSC-SemiBold.ttf
Binary file not shown.
45 changes: 45 additions & 0 deletions ui/fonts/font.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package fonts

import (
_ "embed"
"fmt"

"gioui.org/font"
"gioui.org/font/opentype"
)

var (

//go:embed NotoSans-Regular.ttf
notoSansRegular []byte
//go:embed NotoSans-SemiBold.ttf
notoSansSemiBold []byte

//go:embed NotoSansSC-Regular.ttf
notoSansSCRegular []byte
//go:embed NotoSansSC-SemiBold.ttf
notoSansSCSemiBold []byte
)

var (
collection []font.FontFace
)

func init() {
register(notoSansRegular)
register(notoSansSemiBold)
register(notoSansSCRegular)
register(notoSansSCSemiBold)
}

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...)
}
1 change: 1 addition & 0 deletions ui/icons/icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var (
IconActionUpdate = mustIcon(icons.ActionUpdate)
IconActionHourGlassEmpty = mustIcon(icons.ActionHourglassEmpty)
IconInfo = mustIcon(icons.ActionInfo)
IconAlert = mustIcon(icons.AlertErrorOutline)
)

func mustIcon(data []byte) *widget.Icon {
Expand Down
8 changes: 8 additions & 0 deletions ui/page/entrypoint/tcp/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func (p *tcpPage) create() error {

if err := ep.Run(); err != nil {
ep.Close()
p.router.Notify(ui_widget.Message{
Type: ui_widget.Error,
Content: err.Error(),
})
return err
}

Expand All @@ -368,6 +372,10 @@ func (p *tcpPage) update(opts ...tunnel.Option) tunnel.Tunnel {

if err := ep.Run(); err != nil {
ep.Close()
p.router.Notify(ui_widget.Message{
Type: ui_widget.Error,
Content: err.Error(),
})
logger.Default().Error(err)
}

Expand Down
8 changes: 8 additions & 0 deletions ui/page/entrypoint/udp/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ func (p *udpPage) create() error {

if err := ep.Run(); err != nil {
ep.Close()
p.router.Notify(ui_widget.Message{
Type: ui_widget.Error,
Content: err.Error(),
})
return err
}

Expand Down Expand Up @@ -429,6 +433,10 @@ func (p *udpPage) update(opts ...tunnel.Option) tunnel.Tunnel {

if err := ep.Run(); err != nil {
ep.Close()
p.router.Notify(ui_widget.Message{
Type: ui_widget.Error,
Content: err.Error(),
})
logger.Default().Error(err)
}

Expand Down
11 changes: 11 additions & 0 deletions ui/page/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package page

type EventID string

const (
EventThemeChanged EventID = "event.theme.changed"
)

type Event struct {
ID EventID
}
10 changes: 1 addition & 9 deletions ui/page/home/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"image/color"
"sync/atomic"

"gioui.org/font"
"gioui.org/layout"
"gioui.org/widget"
"gioui.org/widget/material"
Expand Down Expand Up @@ -90,14 +89,7 @@ func (p *homePage) Layout(gtx C) D {
gtx.Constraints.Max.X = gtx.Dp(50)
return icons.IconApp.Layout(gtx)
}),
layout.Rigid(layout.Spacer{Width: 8}.Layout),
layout.Flexed(1, func(gtx C) D {
label := material.H6(th, "GOST+")
label.Font.Weight = font.SemiBold
return label.Layout(gtx)
}),
layout.Rigid(layout.Spacer{Width: 8}.Layout),

layout.Flexed(1, layout.Spacer{Width: 8}.Layout),
layout.Rigid(func(gtx C) D {
if p.btnFavorite.Clicked(gtx) {
p.favorite.Store(!p.favorite.Load())
Expand Down
5 changes: 5 additions & 0 deletions ui/page/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package page

import (
"gioui.org/layout"
"gioui.org/widget/material"
)

type PagePath string
Expand All @@ -27,6 +28,10 @@ type PageOptions struct {

type PageOption func(opts *PageOptions)

type C = layout.Context
type D = layout.Dimensions
type T = material.Theme

func WithPageID(id string) PageOption {
return func(opts *PageOptions) {
opts.ID = id
Expand Down
Loading

0 comments on commit 42846b8

Please sign in to comment.