From 908b55482e826f0de6958164cfa4b31254ee71dd Mon Sep 17 00:00:00 2001 From: Anna BIllstrom Date: Fri, 11 Aug 2023 17:35:30 -0700 Subject: [PATCH 1/2] Fix one-letter-initials --- avatar_initials.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avatar_initials.go b/avatar_initials.go index 4ac9ac2..39abeb5 100644 --- a/avatar_initials.go +++ b/avatar_initials.go @@ -151,7 +151,8 @@ func getFontSizeThatFits(text []byte, imgWidth float64, ftFont *truetype.Font) f tw := float64(drawer.MeasureBytes(text) >> 6) - ratio := fontSize / tw + correction := float64(len(text)) / 2 + ratio := fontSize / tw * correction return ratio * (imgWidth - (40./100)*imgWidth) } From 5d65af0cf560857d235cdbfdb34a4e07f71496a0 Mon Sep 17 00:00:00 2001 From: Anna BIllstrom Date: Wed, 23 Aug 2023 19:31:38 -0700 Subject: [PATCH 2/2] Using goki/freestyle --- avatar_initials.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avatar_initials.go b/avatar_initials.go index 39abeb5..40dd09f 100644 --- a/avatar_initials.go +++ b/avatar_initials.go @@ -10,8 +10,8 @@ import ( "strings" "unicode" - "github.com/golang/freetype" - "github.com/golang/freetype/truetype" + "github.com/goki/freetype" + "github.com/goki/freetype/truetype" "golang.org/x/image/font" "golang.org/x/image/math/fixed" )