Skip to content

Commit

Permalink
Update protoc
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <[email protected]>
  • Loading branch information
gmlewis committed Nov 23, 2023
1 parent aaac2ca commit 006f573
Show file tree
Hide file tree
Showing 11 changed files with 357 additions and 206 deletions.
15 changes: 7 additions & 8 deletions cmd/font2go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"flag"
"fmt"
"go/format"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand All @@ -21,7 +20,7 @@ import (

"github.com/gmlewis/go-fonts/pb/glyphs"
"github.com/gmlewis/go-fonts/webfont"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

const (
Expand Down Expand Up @@ -49,7 +48,7 @@ func main() {
log.Printf("Processing file %q ...", arg)

fontData := &webfont.FontData{}
if buf, err := ioutil.ReadFile(arg); err != nil {
if buf, err := os.ReadFile(arg); err != nil {
log.Fatal(err)
} else {
if err := xml.Unmarshal(buf, fontData); err != nil {
Expand Down Expand Up @@ -149,11 +148,11 @@ func writeFont(fontData *webfont.FontData, fontDir string) {
filename := filepath.Join(fontDir, "font.go")
fmtBuf, err := format.Source(buf.Bytes())
if err != nil {
ioutil.WriteFile(filename, buf.Bytes(), 0644) // Dump the unformatted output.
os.WriteFile(filename, buf.Bytes(), 0644) // Dump the unformatted output.
log.Fatalf("error formating generated Go code: %v : %v", filename, err)
}

if err := ioutil.WriteFile(filename, fmtBuf, 0644); err != nil {
if err := os.WriteFile(filename, fmtBuf, 0644); err != nil {
log.Fatal(err)
}
}
Expand All @@ -165,7 +164,7 @@ func writeReadme(fontData *webfont.FontData, fontDir string) {
log.Fatal(err)
}
readmeName := filepath.Join(fontDir, "README.md")
if err := ioutil.WriteFile(readmeName, buf.Bytes(), 0644); err != nil {
if err := os.WriteFile(readmeName, buf.Bytes(), 0644); err != nil {
log.Printf("WARNING: unable to write %v : %v", readmeName, err)
}
}
Expand All @@ -178,14 +177,14 @@ func writeLicense(srcDir, fontDir string) {
return
}
for _, txtFile := range txtFiles {
buf, err := ioutil.ReadFile(txtFile)
buf, err := os.ReadFile(txtFile)
if err != nil {
log.Printf("WARNING: unable to read text file %v : %v", txtFile, err)
continue
}
baseName := filepath.Base(txtFile)
dstName := filepath.Join(fontDir, baseName)
if err := ioutil.WriteFile(dstName, buf, 0644); err != nil {
if err := os.WriteFile(dstName, buf, 0644); err != nil {
log.Printf("WARNING: unable to write text file %v : %v", dstName, err)
continue
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/font2irmf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"regexp"
Expand Down Expand Up @@ -41,7 +40,7 @@ func main() {
log.Printf("\n\nProcessing file %q ...", arg)

fontData := &webfont.FontData{}
if buf, err := ioutil.ReadFile(arg); err != nil {
if buf, err := os.ReadFile(arg); err != nil {
log.Fatal(err)
} else {
if err := xml.Unmarshal(buf, fontData); err != nil {
Expand Down
4 changes: 0 additions & 4 deletions cmd/font2lua/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import (
"golang.org/x/exp/maps"
)

const (
prefix = "fonts"
)

var (
debug = flag.Bool("debug", false, "Turn on debugging info")

Expand Down
16 changes: 9 additions & 7 deletions fonts/fonts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
// For example:
//
// import (
// "github.com/gmlewis/go-fonts/fonts"
// _ "github.com/gmlewis/go-fonts/fonts/znikomitno24"
//
// "github.com/gmlewis/go-fonts/fonts"
// _ "github.com/gmlewis/go-fonts/fonts/znikomitno24"
//
// )
//
// func main() {
// polys := fonts.Text(x, y, xs, ys, "znikomitno24")
// //...
// }
// func main() {
// polys := fonts.Text(x, y, xs, ys, "znikomitno24")
// //...
// }
//
// Default units are in "em"s which typically represent the width of the
// character "M" in the font. Note that positive X is to the right
Expand All @@ -33,7 +35,7 @@ import (
"unicode/utf8"

"github.com/gmlewis/go-fonts/pb/glyphs"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

// Font represents a webfont.
Expand Down
2 changes: 1 addition & 1 deletion fonts/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (p *Polygon) Area() float64 {

func getFont(fontName string) (*Font, error) {
if len(Fonts) == 0 {
return nil, errors.New("No fonts available")
return nil, errors.New("no fonts available")
}

font, ok := Fonts[fontName]
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ require (
github.com/fogleman/gg v1.3.0
github.com/gmlewis/go3d v0.0.4
github.com/gmlewis/ponoko2d v0.0.0-20190404133045-d77d370bec9a
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.5.8
github.com/yofu/dxf v0.0.0-20190710012328-5a6d1e83f16c
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
google.golang.org/protobuf v1.26.0
)

require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
golang.org/x/image v0.10.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ github.com/gmlewis/ponoko2d v0.0.0-20190404133045-d77d370bec9a/go.mod h1:0DMFM3a
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
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.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand Down
Loading

0 comments on commit 006f573

Please sign in to comment.