Compare commits

..

2 Commits

Author SHA1 Message Date
Chris Sexton 21ce66fc15 font: remove debug 2023-03-16 13:39:55 -04:00
Chris Sexton 295d9fef77 tap: maybe fix font locations 2023-03-16 13:39:55 -04:00
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
for _, s := range config {
err := m.LoadFontFace(getFont(c, fontLocation), 12)
err := m.LoadFontFace(GetFont(c, fontLocation), 12)
if err != nil {
log.Error().Err(err).Msg("could not load font")
return fontSize
@ -343,7 +343,7 @@ func FindFontSize(c *config.Config, config []string, fontLocation string, w, h i
}
for _, sz := range sizes {
err := m.LoadFontFace(getFont(c, fontLocation), sz) // problem
err := m.LoadFontFace(GetFont(c, fontLocation), sz) // problem
if err != nil {
log.Error().Err(err).Msg("could not load font")
return fontSize
@ -476,7 +476,7 @@ func (p *MemePlugin) genMeme(spec specification) ([]byte, error) {
if fontLocation == "" {
fontLocation = defaultFont
}
m.LoadFontFace(getFont(p.c, fontLocation), fontSize)
m.LoadFontFace(GetFont(p.c, fontLocation), fontSize)
x := float64(w)*c.XPerc + float64(dx)
y := float64(h)*c.YPerc + float64(dy)
m.DrawStringAnchored(c.Text, x, y, 0.5, 0.5)
@ -491,7 +491,7 @@ func (p *MemePlugin) genMeme(spec specification) ([]byte, error) {
if fontLocation == "" {
fontLocation = defaultFont
}
m.LoadFontFace(getFont(p.c, fontLocation), fontSize)
m.LoadFontFace(GetFont(p.c, fontLocation), fontSize)
x := float64(w) * c.XPerc
y := float64(h) * c.YPerc
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
}
func getFont(c *config.Config, name string) string {
func GetFont(c *config.Config, name string) string {
location := c.Get("meme.fontLocation", "")
fontShortcuts := c.GetMap("meme.fontShortcuts", map[string]string{"impact": "impact.ttf"})
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) {
font := p.c.Get("meme.font", "impact.ttf")
font := meme.GetFont(p.c, p.c.Get("meme.font", "impact.ttf"))
fontSizes := []float64{48, 36, 24, 16, 12}
r := img.Bounds()
w := r.Dx()