Skip to content

Commit

Permalink
Use go-graphviz 0.0.6 / Include mplus-1p-light.ttf font file
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jun 30, 2020
1 parent 1dc5cde commit 130c4d1
Show file tree
Hide file tree
Showing 116 changed files with 644 additions and 644 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ require (
cloud.google.com/go/bigquery v1.6.0
cloud.google.com/go/spanner v1.5.1
github.com/aws/aws-sdk-go v1.30.9
github.com/beta/freetype v0.0.1
github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e
github.com/fatih/color v1.9.0 // indirect
github.com/go-sql-driver/mysql v1.5.0
github.com/gobuffalo/packr/v2 v2.8.0
github.com/gocarina/gocsv v0.0.0-20200330101823-46266ca37bd3
github.com/goccy/go-graphviz v0.0.5
github.com/goccy/go-graphviz v0.0.6
github.com/goccy/go-yaml v1.4.3
github.com/google/go-cmp v0.4.0
github.com/karrick/godirwalk v1.15.6 // indirect
Expand All @@ -26,6 +27,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/xo/dburl v0.0.0-20200124232849-e9ec94f52bc3
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904 // indirect
golang.org/x/image v0.0.0-20200119044424-58c23975cae1
golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 // indirect
google.golang.org/api v0.21.0
google.golang.org/genproto v0.0.0-20200417142217-fb6d0575620b // indirect
Expand Down
36 changes: 5 additions & 31 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion output/dot/templates/schema.dot.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ digraph "{{ .Schema.Name }}" {
// Tables
{{- range $i, $t := .Schema.Tables }}
"{{ $t.Name }}" [shape=none, label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="6">
<tr><td bgcolor="#EFEFEF"><font face="Arial Bold" point-size="18">{{ $t.Name | html }}</font> <font color="#666666">[{{ $t.Type | html }}]</font>{{ if $sc }}{{ if ne $t.Comment "" }}<br /><font color="#333333">{{ $t.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
<tr><td bgcolor="#EFEFEF"><font face="Bold" point-size="18">{{ $t.Name | html }}</font> <font color="#666666">[{{ $t.Type | html }}]</font>{{ if $sc }}{{ if ne $t.Comment "" }}<br /><font color="#333333">{{ $t.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
{{- range $ii, $c := $t.Columns }}
<tr><td port="{{ $c.Name | html }}" align="left">{{ $c.Name | html }} <font color="#666666">[{{ $c.Type | html }}]</font>{{ if $sc }}{{ if ne $c.Comment "" }} {{ $c.Comment | html | nl2space }}{{ end }}{{ end }}</td></tr>
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions output/dot/templates/table.dot.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ digraph "{{ .Table.Name }}" {

// Tables
"{{ .Table.Name }}" [shape=none, label=<<table border="3" cellborder="1" cellspacing="0" cellpadding="6">
<tr><td bgcolor="#EFEFEF"><font face="Arial Bold" point-size="18">{{ .Table.Name | html }}</font> <font color="#666666">[{{ .Table.Type | html }}]</font>{{ if $sc }}{{ if ne .Table.Comment "" }}<br /><font color="#333333">{{ .Table.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
<tr><td bgcolor="#EFEFEF"><font face="Bold" point-size="18">{{ .Table.Name | html }}</font> <font color="#666666">[{{ .Table.Type | html }}]</font>{{ if $sc }}{{ if ne .Table.Comment "" }}<br /><font color="#333333">{{ .Table.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
{{- range $ii, $c := .Table.Columns }}
<tr><td port="{{ $c.Name | html }}" align="left">{{ $c.Name | html }} <font color="#666666">[{{ $c.Type | html }}]</font>{{ if $sc }}{{ if ne $c.Comment "" }} {{ $c.Comment | html | nl2space }}{{ end }}{{ end }}</td></tr>
{{- end }}
</table>>];
{{- range $i, $t := .Tables }}
"{{ $t.Name }}" [shape=none, label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="6">
<tr><td bgcolor="#EFEFEF"><font face="Arial Bold" point-size="18">{{ $t.Name | html }}</font> <font color="#666666">[{{ $t.Type | html }}]</font>{{ if $sc }}{{ if ne $t.Comment "" }}<br /><font color="#333333">{{ $t.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
<tr><td bgcolor="#EFEFEF"><font face="Bold" point-size="18">{{ $t.Name | html }}</font> <font color="#666666">[{{ $t.Type | html }}]</font>{{ if $sc }}{{ if ne $t.Comment "" }}<br /><font color="#333333">{{ $t.Comment | html | nl2br_slash }}</font>{{ end }}{{ end }}</td></tr>
{{- range $ii, $c := $t.Columns }}
<tr><td port="{{ $c.Name | html }}" align="left">{{ $c.Name | html }} <font color="#666666">[{{ $c.Type | html }}]</font>{{ if $sc }}{{ if ne $c.Comment "" }} {{ $c.Comment | html | nl2space }}{{ end }}{{ end }}</td></tr>
{{- end }}
Expand Down
Binary file added output/gviz/font/mplus-1p-light.ttf
Binary file not shown.
24 changes: 24 additions & 0 deletions output/gviz/gviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@ import (
"bytes"
"io"

"github.com/beta/freetype/truetype"
"github.com/gobuffalo/packr/v2"
"github.com/goccy/go-graphviz"
"github.com/k1LoW/tbls/config"
"github.com/k1LoW/tbls/output/dot"
"github.com/k1LoW/tbls/schema"
"github.com/pkg/errors"
"golang.org/x/image/font"
)

// Gviz struct
type Gviz struct {
config *config.Config
dot *dot.Dot
box *packr.Box
}

// New return Gviz
func New(c *config.Config) *Gviz {
return &Gviz{
config: c,
dot: dot.New(c),
box: packr.New("font", "./font"),
}
}

Expand All @@ -46,7 +51,26 @@ func (g *Gviz) OutputTable(wr io.Writer, t *schema.Table) error {
}

func (g *Gviz) render(wr io.Writer, b []byte) (e error) {
fb, err := g.box.Find("mplus-1p-light.ttf")
if err != nil {
return errors.WithStack(err)
}
ft, err := truetype.Parse(fb)
if err != nil {
return errors.WithStack(err)
}
gviz := graphviz.New()
gviz.SetFontFace(func(size float64) (font.Face, error) {
opt := &truetype.Options{
Size: size,
DPI: 0,
Hinting: 0,
GlyphCacheEntries: 0,
SubPixelsX: 0,
SubPixelsY: 0,
}
return truetype.NewFace(ft, opt), nil
})
graph, err := graphviz.ParseBytes(b)
if err != nil {
return errors.WithStack(err)
Expand Down
Binary file modified sample/adjust/administrator.blogs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/backup.blog_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/backup.blogs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.CamelizeTable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.comment_stars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.hyphen-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.post_comment_stars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.post_comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.posts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.user_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/public.users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/time.bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/time.hyphenated-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/adjust/time.referencing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/CamelizeTable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/comment_stars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/hyphen-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/post_comments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/posts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sample/dict/user_options.png
Binary file modified sample/dict/users.png
Binary file modified sample/dynamodb/Forum.png
Binary file modified sample/dynamodb/ProductCatalog.png
Binary file modified sample/dynamodb/Reply.png
Binary file modified sample/dynamodb/Thread.png
Binary file modified sample/dynamodb/schema.png
Binary file modified sample/exclude/comment_stars.png
Binary file modified sample/exclude/comments.png
Binary file modified sample/exclude/hyphen-table.png
Binary file modified sample/exclude/post_comments.png
Binary file modified sample/exclude/posts.png
Binary file modified sample/exclude/schema.png
Binary file modified sample/exclude/user_options.png
Binary file modified sample/exclude/users.png
Binary file modified sample/mssql/CamelizeTable.png
Binary file modified sample/mssql/comment_stars.png
Binary file modified sample/mssql/comments.png
Binary file modified sample/mssql/hyphen-table.png
Binary file modified sample/mssql/logs.png
Binary file modified sample/mssql/post_comments.png
Binary file modified sample/mssql/posts.png
Binary file modified sample/mssql/schema.png
Binary file modified sample/mssql/user_options.png
Binary file modified sample/mssql/users.png
Binary file modified sample/mysql/CamelizeTable.png
Binary file modified sample/mysql/comment_stars.png
Binary file modified sample/mysql/comments.png
Binary file modified sample/mysql/hyphen-table.png
Binary file modified sample/mysql/logs.png
Binary file modified sample/mysql/post_comments.png
Binary file modified sample/mysql/posts.png
Binary file modified sample/mysql/schema.png
Binary file modified sample/mysql/user_options.png
Binary file modified sample/mysql/users.png
Binary file modified sample/mysql8/CamelizeTable.png
Binary file modified sample/mysql8/comment_stars.png
Binary file modified sample/mysql8/comments.png
Binary file modified sample/mysql8/hyphen-table.png
Binary file modified sample/mysql8/logs.png
Binary file modified sample/mysql8/post_comments.png
Binary file modified sample/mysql8/posts.png
Binary file modified sample/mysql8/schema.png
Binary file modified sample/mysql8/user_options.png
Binary file modified sample/mysql8/users.png
Binary file modified sample/postgres/administrator.blogs.png
Binary file modified sample/postgres/backup.blog_options.png
Binary file modified sample/postgres/backup.blogs.png
Binary file modified sample/postgres/public.CamelizeTable.png
Binary file modified sample/postgres/public.comment_stars.png
Binary file modified sample/postgres/public.comments.png
Binary file modified sample/postgres/public.hyphen-table.png
Binary file modified sample/postgres/public.logs.png
Binary file modified sample/postgres/public.post_comment_stars.png
Binary file modified sample/postgres/public.post_comments.png
Binary file modified sample/postgres/public.posts.png
Binary file modified sample/postgres/public.user_options.png
Binary file modified sample/postgres/public.users.png
Binary file modified sample/postgres/schema.png
Binary file modified sample/postgres/time.bar.png
Binary file modified sample/postgres/time.hyphenated-table.png
Binary file modified sample/postgres/time.referencing.png
Binary file modified sample/sqlite/CamelizeTable.png
Binary file modified sample/sqlite/access_log.png
Binary file modified sample/sqlite/check_constraints.png
Binary file modified sample/sqlite/comment_stars.png
Binary file modified sample/sqlite/comments.png
Binary file modified sample/sqlite/hyphen-table.png
Binary file modified sample/sqlite/logs.png
Binary file modified sample/sqlite/post_comments.png
Binary file modified sample/sqlite/posts.png
Binary file modified sample/sqlite/schema.png
Binary file modified sample/sqlite/syslog.png
Binary file modified sample/sqlite/user_options.png
Binary file modified sample/sqlite/users.png
30 changes: 15 additions & 15 deletions sample/svg/CamelizeTable.svg
Loading

0 comments on commit 130c4d1

Please sign in to comment.