From ec0206ff018126d07afb50a61b5f29ec284c7e17 Mon Sep 17 00:00:00 2001
From: Matthew Chen <matthew@signal.org>
Date: Thu, 27 Sep 2018 10:44:29 -0400
Subject: [PATCH] Adapt text size of default avatars to avatar size.

---
 SignalMessaging/utils/OWSAvatarBuilder.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/SignalMessaging/utils/OWSAvatarBuilder.m b/SignalMessaging/utils/OWSAvatarBuilder.m
index ecfaba7ca..4043f3814 100644
--- a/SignalMessaging/utils/OWSAvatarBuilder.m
+++ b/SignalMessaging/utils/OWSAvatarBuilder.m
@@ -64,7 +64,7 @@ typedef void (^OWSAvatarDrawBlock)(CGContextRef context);
 
                                    [self drawInitialsInAvatar:face
                                                     textColor:self.avatarForegroundColor
-                                                         font:self.avatarTextFont
+                                                         font:[self avatarTextFontForDiameter:diameter]
                                                      diameter:diameter];
                                }];
 }
@@ -74,9 +74,11 @@ typedef void (^OWSAvatarDrawBlock)(CGContextRef context);
     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray05Color : UIColor.ows_whiteColor);
 }
 
-+ (UIFont *)avatarTextFont
++ (UIFont *)avatarTextFontForDiameter:(NSUInteger)diameter
 {
-    return [UIFont ows_mediumFontWithSize:20.f];
+    // Adapt the font size to reflect the diameter.
+    CGFloat fontSize = 20.f * diameter / kStandardAvatarSize;
+    return [UIFont ows_mediumFontWithSize:fontSize];
 }
 
 + (nullable UIImage *)avatarImageWithInitials:(NSString *)initials
@@ -86,7 +88,7 @@ typedef void (^OWSAvatarDrawBlock)(CGContextRef context);
     return [self avatarImageWithInitials:initials
                          backgroundColor:backgroundColor
                                textColor:self.avatarForegroundColor
-                                    font:self.avatarTextFont
+                                    font:[self avatarTextFontForDiameter:diameter]
                                 diameter:diameter];
 }