lock
This commit is contained in:
parent
724ee2c90b
commit
b1983d6777
4
table.go
4
table.go
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"image/color"
|
||||
"math"
|
||||
"sync"
|
||||
|
||||
"github.com/fogleman/gg"
|
||||
)
|
||||
|
@ -39,6 +40,7 @@ type TableConfig struct {
|
|||
}
|
||||
|
||||
type TableGenerator struct {
|
||||
lock sync.RWMutex
|
||||
config *TableConfig
|
||||
dc *gg.Context
|
||||
}
|
||||
|
@ -279,6 +281,8 @@ func (g *TableGenerator) drawTitle(dc *gg.Context, margin, tableWidth float64, t
|
|||
|
||||
// 生成自适应表格(高清版本)
|
||||
func (g *TableGenerator) Generate(data *TableData, filename string) error {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
// 先创建一个临时上下文来测量文本
|
||||
tempDC := gg.NewContext(1, 1)
|
||||
if err := g.loadHDFont(tempDC, g.config.FontSize); err != nil {
|
||||
|
|
Loading…
Reference in New Issue