Browse Source

add text element formatting options (#2517)

pull/2518/head
Jason Dove 7 months ago committed by GitHub
parent
commit
fb9ca8953e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 13
      ErsatzTV.Core/Graphics/TextGraphicsElement.cs
  3. 3
      ErsatzTV.FFmpeg/State/WatermarkState.cs
  4. 3
      ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs
  5. 18
      ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs

5
CHANGELOG.md

@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add template data (like `MediaItem_Title`) for other video files
- Add `MediaItem_Path` for movies, episodes, music videos and other videos
- Add `get_directory_name` and `get_filename_without_extension` functions for path processing
- Add `text_align` property to text graphics elements (values: `left`, `right` and `center`)
- Add `MiddleCenter` value to `location` property on all graphics elements
- Positive and negative margins can be used to offset from center as desired
- Add `line_height` property to text element style definition
- This is a multiplier that defaults to 1.0 when unspecified
- Add `Block Playout Troubleshooting` tool to help investigate block playout history
- Add sequential schedule file and scripted schedule file names to playouts table
- Add empty (but already up-to-date) sqlite3 database to greatly speed up initial startup for fresh installs

13
ErsatzTV.Core/Graphics/TextGraphicsElement.cs

@ -25,6 +25,9 @@ public class TextGraphicsElement @@ -25,6 +25,9 @@ public class TextGraphicsElement
[YamlMember(Alias = "text_fit", ApplyNamingConventions = false)]
public TextFit Fit { get; set; } = TextFit.None;
[YamlMember(Alias = "text_align", ApplyNamingConventions = false)]
public TextAlignment Align { get; set; } = TextAlignment.Left;
[YamlMember(Alias = "z_index", ApplyNamingConventions = false)]
public int? ZIndex { get; set; }
@ -49,6 +52,13 @@ public enum TextFit @@ -49,6 +52,13 @@ public enum TextFit
Scale
}
public enum TextAlignment
{
Left,
Center,
Right
}
public class StyleDefinition
{
public string Name { get; set; }
@ -70,4 +80,7 @@ public class StyleDefinition @@ -70,4 +80,7 @@ public class StyleDefinition
[YamlMember(Alias = "letter_spacing", ApplyNamingConventions = false)]
public float? LetterSpacing { get; set; }
[YamlMember(Alias = "line_height", ApplyNamingConventions = false)]
public float? LineHeight { get; set; }
}

3
ErsatzTV.FFmpeg/State/WatermarkState.cs

@ -31,7 +31,8 @@ public enum WatermarkLocation @@ -31,7 +31,8 @@ public enum WatermarkLocation
TopMiddle = 4,
RightMiddle = 5,
BottomMiddle = 6,
LeftMiddle = 7
LeftMiddle = 7,
MiddleCenter = 8
}
public enum WatermarkSize

3
ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs

@ -41,6 +41,9 @@ public abstract class GraphicsElement : IGraphicsElement @@ -41,6 +41,9 @@ public abstract class GraphicsElement : IGraphicsElement
(frameWidth - imageWidth) / 2,
frameHeight - imageHeight - verticalMargin),
WatermarkLocation.LeftMiddle => new SKPointI(horizontalMargin, (frameHeight - imageHeight) / 2),
WatermarkLocation.MiddleCenter => new SKPointI(
(frameWidth - imageWidth) / 2 + horizontalMargin,
(frameHeight - imageHeight) / 2 + verticalMargin),
_ => new SKPointI(
frameWidth - imageWidth - horizontalMargin,
frameHeight - imageHeight - verticalMargin)

18
ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs

@ -134,7 +134,17 @@ public partial class TextElement( @@ -134,7 +134,17 @@ public partial class TextElement(
private RichTextKit.TextBlock BuildTextBlock(string textToRender)
{
var textBlock = new RichTextKit.TextBlock { FontMapper = graphicsEngineFonts.Mapper };
var textBlock = new RichTextKit.TextBlock
{
FontMapper = graphicsEngineFonts.Mapper,
Alignment = textElement.Align switch
{
TextAlignment.Center => RichTextKit.TextAlignment.Center,
TextAlignment.Right => RichTextKit.TextAlignment.Right,
TextAlignment.Left => RichTextKit.TextAlignment.Left,
_ => RichTextKit.TextAlignment.Auto
}
};
(Dictionary<string, RichTextKit.Style> styles, RichTextKit.Style baseStyle) = BuildTextStyles();
@ -192,6 +202,7 @@ public partial class TextElement( @@ -192,6 +202,7 @@ public partial class TextElement(
finalStyle.FontSize = s.FontSize ?? finalStyle.FontSize;
finalStyle.FontWeight = s.FontWeight ?? finalStyle.FontWeight;
finalStyle.LetterSpacing = s.LetterSpacing ?? finalStyle.LetterSpacing;
finalStyle.LineHeight = s.LineHeight ?? finalStyle.LineHeight;
if (s.TextColor != null && SKColor.TryParse(s.TextColor, out SKColor parsedColor))
{
@ -227,6 +238,11 @@ public partial class TextElement( @@ -227,6 +238,11 @@ public partial class TextElement(
style.LetterSpacing = letterSpacing;
}
foreach (float lineHeight in Optional(def.LineHeight))
{
style.LineHeight = lineHeight;
}
return style;
}
}

Loading…
Cancel
Save