Skip to content

Commit

Permalink
feat: Add support for newline insertion on specific symbols in title tex
Browse files Browse the repository at this point in the history
This feature introduces the ability to automatically insert newline characters in title text based on specified symbols. The new NewLineOnSpecificSymbols setting allows users to enable this functionality, and the NewLineSymbols setting lets them define which symbols should trigger a newline. This enhancement is particularly useful for formatting titles that include separators like dashes or colons, ensuring better visual presentation on generated posters and title cards. Additionally, this feature maintains consistency with the existing configuration settings and integrates seamlessly with the poster generation process.
  • Loading branch information
fscorrupt committed Aug 16, 2024
1 parent a0d8b00 commit 8be251c
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 2 deletions.
4 changes: 4 additions & 0 deletions MyPersonalConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"SkipJapTitle": "true",
"AssetCleanup": "true",
"AutoUpdateIM": "false",
"NewLineOnSpecificSymbols": "true",
"NewLineSymbols": [
"-"
],
"seasonoverlayfile": "bottom-up-fade.png"
},
"OverlayPart": {
Expand Down
117 changes: 116 additions & 1 deletion Posterizarr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[string]$mediatype
)

$CurrentScriptVersion = "1.3.6"
$CurrentScriptVersion = "1.3.7"
$global:HeaderWritten = $false
$ProgressPreference = 'SilentlyContinue'

Expand Down Expand Up @@ -3929,6 +3929,8 @@ $global:TitleCards = $config.PrerequisitePart.TitleCards.tolower()
$SkipTBA = $config.PrerequisitePart.SkipTBA.tolower()
$SkipJapTitle = $config.PrerequisitePart.SkipJapTitle.tolower()
$AssetCleanup = $config.PrerequisitePart.AssetCleanup.tolower()
$NewLineOnSpecificSymbols = $config.PrerequisitePart.NewLineOnSpecificSymbols.tolower()
$NewLineSymbols = $config.PrerequisitePart.NewLineSymbols

# Poster Overlay Part
$global:ImageProcessing = $config.OverlayPart.ImageProcessing.tolower()
Expand Down Expand Up @@ -4442,6 +4444,14 @@ if ($Manual) {

if ($AddText -eq 'true') {
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}

$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
Write-Entry -Subtext "Optimal font size set to: '$optimalFontSize'" -Path $global:ScriptRoot\Logs\Manuallog.log -Color White -log Info
Expand Down Expand Up @@ -6056,6 +6066,13 @@ Elseif ($Tautulli) {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -6380,6 +6397,13 @@ Elseif ($Tautulli) {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $backgroundfontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -6779,6 +6803,13 @@ Elseif ($Tautulli) {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -7113,6 +7144,13 @@ Elseif ($Tautulli) {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $backgroundfontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -7482,6 +7520,13 @@ Elseif ($Tautulli) {

if ($AddSeasonText -eq 'true') {
$global:seasonTitle = $global:seasonTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:seasonTitle = $global:seasonTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:seasonTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $SeasonMaxWidth -box_height $SeasonMaxHeight -min_pointsize $SeasonminPointSize -max_pointsize $SeasonmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -7697,6 +7742,13 @@ Elseif ($Tautulli) {

if ($AddSeasonText -eq 'true') {
$global:seasonTitle = $global:seasonTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:seasonTitle = $global:seasonTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:seasonTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $SeasonMaxWidth -box_height $SeasonMaxHeight -min_pointsize $SeasonminPointSize -max_pointsize $SeasonmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -8150,6 +8202,13 @@ Elseif ($Tautulli) {
}
}
$global:EPTitle = $global:EPTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:EPTitle = $global:EPTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
if ($global:direction -eq "RTL") {
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $RTLfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
Expand Down Expand Up @@ -8621,6 +8680,13 @@ Elseif ($Tautulli) {
}
}
$global:EPTitle = $global:EPTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:EPTitle = $global:EPTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
if ($global:direction -eq "RTL") {
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $RTLfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
Expand Down Expand Up @@ -9561,6 +9627,13 @@ else {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -9870,6 +9943,13 @@ else {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $backgroundfontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -10258,6 +10338,13 @@ else {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $MaxWidth -box_height $MaxHeight -min_pointsize $minPointSize -max_pointsize $maxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -10576,6 +10663,13 @@ else {
}
}
$joinedTitle = $joinedTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$joinedTitle = $joinedTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $joinedTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $backgroundfontImagemagick -box_width $BackgroundMaxWidth -box_height $BackgroundMaxHeight -min_pointsize $BackgroundminPointSize -max_pointsize $BackgroundmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -10928,6 +11022,13 @@ else {

if ($AddSeasonText -eq 'true') {
$global:seasonTitle = $global:seasonTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:seasonTitle = $global:seasonTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:seasonTitle -replace '""', '""""'
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $fontImagemagick -box_width $SeasonMaxWidth -box_height $SeasonMaxHeight -min_pointsize $SeasonminPointSize -max_pointsize $SeasonmaxPointSize
if (!$global:IsTruncated) {
Expand Down Expand Up @@ -11364,6 +11465,13 @@ else {
}
}
$global:EPTitle = $global:EPTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:EPTitle = $global:EPTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
if ($global:direction -eq "RTL") {
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $RTLfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
Expand Down Expand Up @@ -11819,6 +11927,13 @@ else {
}
}
$global:EPTitle = $global:EPTitle -replace '"', '""'

# Loop through each symbol and replace it with a newline
if ($NewLineOnSpecificSymbols -eq 'true'){
foreach ($symbol in $NewLineSymbols) {
$global:EPTitle = $global:EPTitle -replace [regex]::Escape($symbol), "`n"
}
}
$joinedTitlePointSize = $global:EPTitle -replace '""', '""""'
if ($global:direction -eq "RTL") {
$optimalFontSize = Get-OptimalPointSize -text $joinedTitlePointSize -font $RTLfontImagemagick -box_width $TitleCardEPTitleMaxWidth -box_height $TitleCardEPTitleMaxHeight -min_pointsize $TitleCardEPTitleminPointSize -max_pointsize $TitleCardEPTitlemaxPointSize
Expand Down
Loading

0 comments on commit 8be251c

Please sign in to comment.