diff options
| author | David <daullmer@gmail.com> | 2020-08-22 14:31:28 +0200 |
|---|---|---|
| committer | David <daullmer@gmail.com> | 2020-08-22 14:31:28 +0200 |
| commit | 9165dc3b3a94714da307079413f62326d5e585ef (patch) | |
| tree | b4897a0b37d89dfa17de21d2bb407b7eccbebbc8 | |
| parent | d740e7aee6582d576c5bc2688df3c356203f5974 (diff) | |
Scale down text if too long
| -rw-r--r-- | Jellyfin.Drawing.Skia/StripCollageBuilder.cs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs index 09036b9f9..0e94f87f6 100644 --- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs +++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs @@ -128,6 +128,14 @@ namespace Jellyfin.Drawing.Skia Typeface = SKTypeface.FromFamilyName("sans-serif", SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright), IsAntialias = true }; + + // scale down text to 90% of the width if text is larger than 95% of the width + var textWidth = textPaint.MeasureText(libraryName); + if (textWidth > width * 0.95) + { + textPaint.TextSize = 0.9f * width * textPaint.TextSize / textWidth; + } + canvas.DrawText(libraryName, width / 2f, (height / 2f) + (textPaint.FontMetrics.XHeight / 2), textPaint); return bitmap; |
