Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix letter avatar alignment on macOS (#39597)

Penar Musaraj744d69965354
diff --git a/lib/letter_avatar.rb b/lib/letter_avatar.rb
index 1853015f97f..1081c886eaf 100644
--- a/lib/letter_avatar.rb
+++ b/lib/letter_avatar.rb
@@ -71,6 +71,11 @@ class LetterAvatar
filename = fullsize_path(identity)
+ # Use NimbusSans-Regular, except for macOS where it is unavailable, use Helvetica there
+ font = RbConfig::CONFIG["host_os"].match?(/darwin/i) ? "Helvetica" : "NimbusSans-Regular"
+ # and adjust vertical offset accordingly
+ vertical_offset = font == "Helvetica" ? 26 : 34
+
instructions = %W[
-size
#{FULLSIZE}x#{FULLSIZE}
@@ -80,11 +85,11 @@ class LetterAvatar
-fill
#FFFFFFCC
-font
- NimbusSans-Regular
+ #{font}
-gravity
Center
-annotate
- -0+34
+ -0+#{vertical_offset}
#{letter}
-depth
8