@@ -221,7 +221,7 @@ function utf8Strlen(string $string): int
221
221
function splitLines (string $ text , int $ maxChars , int $ line1Offset ): string
222
222
{
223
223
// if too many characters, insert \n before a " " or "-" if possible
224
- if (utf8Strlen ($ text ) > $ maxChars && strpos ($ text , "\n" ) === false ) {
224
+ if ($ maxChars > 0 && utf8Strlen ($ text ) > $ maxChars && strpos ($ text , "\n" ) === false ) {
225
225
// prefer splitting at " - " if possible
226
226
if (strpos ($ text , " - " ) !== false ) {
227
227
$ text = str_replace (" - " , "\n- " , $ text );
@@ -393,7 +393,7 @@ function generateCard(array $stats, array $params = null): string
393
393
}
394
394
395
395
// if the translations contain over max characters or a newline, split the text into two tspan elements
396
- $ maxCharsPerLineLabels = intval (floor ($ cardWidth / $ numColumns / 7.5 ));
396
+ $ maxCharsPerLineLabels = $ numColumns > 0 ? intval (floor ($ cardWidth / $ numColumns / 7.5 )) : 0 ;
397
397
$ totalContributionsText = splitLines ($ localeTranslations ["Total Contributions " ], $ maxCharsPerLineLabels , -9 );
398
398
if ($ stats ["mode " ] === "weekly " ) {
399
399
$ currentStreakText = splitLines ($ localeTranslations ["Week Streak " ], $ maxCharsPerLineLabels , -9 );
@@ -404,7 +404,7 @@ function generateCard(array $stats, array $params = null): string
404
404
}
405
405
406
406
// if the ranges contain over max characters, split the text into two tspan elements
407
- $ maxCharsPerLineDates = intval (floor ($ cardWidth / $ numColumns / 6 ));
407
+ $ maxCharsPerLineDates = $ numColumns > 0 ? intval (floor ($ cardWidth / $ numColumns / 6 )) : 0 ;
408
408
$ totalContributionsRange = splitLines ($ totalContributionsRange , $ maxCharsPerLineDates , 0 );
409
409
$ currentStreakRange = splitLines ($ currentStreakRange , $ maxCharsPerLineDates , 0 );
410
410
$ longestStreakRange = splitLines ($ longestStreakRange , $ maxCharsPerLineDates , 0 );
0 commit comments