Compare commits

..

No commits in common. "21ce66fc15bd97c4e59d519582e4f59a5c286428" and "6707902caff66dc1e7a2686548e942c199b6afeb" have entirely different histories.

2 changed files with 6 additions and 6 deletions

View File

@ -329,7 +329,7 @@ func FindFontSize(c *config.Config, config []string, fontLocation string, w, h i
longestStr, longestW := "", 0.0 longestStr, longestW := "", 0.0
for _, s := range config { for _, s := range config {
err := m.LoadFontFace(GetFont(c, fontLocation), 12) err := m.LoadFontFace(getFont(c, fontLocation), 12)
if err != nil { if err != nil {
log.Error().Err(err).Msg("could not load font") log.Error().Err(err).Msg("could not load font")
return fontSize return fontSize
@ -343,7 +343,7 @@ func FindFontSize(c *config.Config, config []string, fontLocation string, w, h i
} }
for _, sz := range sizes { for _, sz := range sizes {
err := m.LoadFontFace(GetFont(c, fontLocation), sz) // problem err := m.LoadFontFace(getFont(c, fontLocation), sz) // problem
if err != nil { if err != nil {
log.Error().Err(err).Msg("could not load font") log.Error().Err(err).Msg("could not load font")
return fontSize return fontSize
@ -476,7 +476,7 @@ func (p *MemePlugin) genMeme(spec specification) ([]byte, error) {
if fontLocation == "" { if fontLocation == "" {
fontLocation = defaultFont fontLocation = defaultFont
} }
m.LoadFontFace(GetFont(p.c, fontLocation), fontSize) m.LoadFontFace(getFont(p.c, fontLocation), fontSize)
x := float64(w)*c.XPerc + float64(dx) x := float64(w)*c.XPerc + float64(dx)
y := float64(h)*c.YPerc + float64(dy) y := float64(h)*c.YPerc + float64(dy)
m.DrawStringAnchored(c.Text, x, y, 0.5, 0.5) m.DrawStringAnchored(c.Text, x, y, 0.5, 0.5)
@ -491,7 +491,7 @@ func (p *MemePlugin) genMeme(spec specification) ([]byte, error) {
if fontLocation == "" { if fontLocation == "" {
fontLocation = defaultFont fontLocation = defaultFont
} }
m.LoadFontFace(GetFont(p.c, fontLocation), fontSize) m.LoadFontFace(getFont(p.c, fontLocation), fontSize)
x := float64(w) * c.XPerc x := float64(w) * c.XPerc
y := float64(h) * c.YPerc y := float64(h) * c.YPerc
m.DrawStringAnchored(c.Text, x, y, 0.5, 0.5) m.DrawStringAnchored(c.Text, x, y, 0.5, 0.5)
@ -506,7 +506,7 @@ func (p *MemePlugin) genMeme(spec specification) ([]byte, error) {
return p.images[jsonSpec].repr, nil return p.images[jsonSpec].repr, nil
} }
func GetFont(c *config.Config, name string) string { func getFont(c *config.Config, name string) string {
location := c.Get("meme.fontLocation", "") location := c.Get("meme.fontLocation", "")
fontShortcuts := c.GetMap("meme.fontShortcuts", map[string]string{"impact": "impact.ttf"}) fontShortcuts := c.GetMap("meme.fontShortcuts", map[string]string{"impact": "impact.ttf"})
if file, ok := fontShortcuts[name]; ok { if file, ok := fontShortcuts[name]; ok {

View File

@ -67,7 +67,7 @@ func defaultSpec() textSpec {
} }
func (p *Tappd) overlay(img image.Image, texts []textSpec) ([]byte, error) { func (p *Tappd) overlay(img image.Image, texts []textSpec) ([]byte, error) {
font := meme.GetFont(p.c, p.c.Get("meme.font", "impact.ttf")) font := p.c.Get("meme.font", "impact.ttf")
fontSizes := []float64{48, 36, 24, 16, 12} fontSizes := []float64{48, 36, 24, 16, 12}
r := img.Bounds() r := img.Bounds()
w := r.Dx() w := r.Dx()