add text element formatting options (#2517)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
Scale
|
||||
}
|
||||
|
||||
public enum TextAlignment
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
}
|
||||
|
||||
public class StyleDefinition
|
||||
{
|
||||
public string Name { get; set; }
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ public enum WatermarkLocation
|
||||
TopMiddle = 4,
|
||||
RightMiddle = 5,
|
||||
BottomMiddle = 6,
|
||||
LeftMiddle = 7
|
||||
LeftMiddle = 7,
|
||||
MiddleCenter = 8
|
||||
}
|
||||
|
||||
public enum WatermarkSize
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
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(
|
||||
style.LetterSpacing = letterSpacing;
|
||||
}
|
||||
|
||||
foreach (float lineHeight in Optional(def.LineHeight))
|
||||
{
|
||||
style.LineHeight = lineHeight;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user