Files
ersatztv/ErsatzTV.Core/Graphics/TextGraphicsElement.cs
T
timothy 04ff11f854 test(732): cover the three clauses a cold review measured as having no red
Round 5 enumerated the guards independently and ran the full suite against each: `HaloBlur` and
`LineHeight` in FitTextBlock's rebuilt style, and the per-style `HaloBlur` override in
BuildTextStyles, could all be deleted with 2062 tests green. All three were added by the round-4 fix
commit - the same commit that rewrote the mutation-coverage paragraph and warned that adding a guard
without its row makes that paragraph false. It did exactly that, three times, in itself.

The blanket claim is already gone. These three now have differential tests and measured rows, so they
are covered rather than merely unclaimed. The existing halo rows were written at whole-block
granularity, which is what hid the per-field gap: HaloColor and HaloWidth were reachable, HaloBlur was
not.

Also disclosed: the per-style halo fix and the Scale path now carrying line_height are
operator-visible changes for custom templates, which belongs in the release notes rather than only in
a commit message. And a comment on the schema still said an unset background_color means no box at
all, which the border-only path and its own test contradict.

Refs: #732
2026-08-26 20:37:06 +02:00

118 lines
4.1 KiB
C#

using ErsatzTV.FFmpeg.State;
using YamlDotNet.Serialization;
namespace ErsatzTV.Core.Graphics;
public class TextGraphicsElement : BaseGraphicsElement
{
[YamlMember(Alias = "opacity_percent", ApplyNamingConventions = false)]
public int? OpacityPercent { get; set; }
[YamlMember(Alias = "opacity_expression", ApplyNamingConventions = false)]
public string OpacityExpression { get; set; }
public WatermarkLocation Location { get; set; }
[YamlMember(Alias = "horizontal_margin_percent", ApplyNamingConventions = false)]
public double? HorizontalMarginPercent { get; set; }
[YamlMember(Alias = "vertical_margin_percent", ApplyNamingConventions = false)]
public double? VerticalMarginPercent { get; set; }
[YamlMember(Alias = "width_percent", ApplyNamingConventions = false)]
public double? WidthPercent { get; set; }
[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; }
// Background box (ersatztv#732). Element-level, not per-style: the graphics engine renders one
// TextBlock into one bitmap, so a single box behind the whole element is the only shape the
// renderer can express. Unset background_color means no FILL; a border_color alone still draws
// an outlined box. With neither there is no box and no insets -- the pre-#732 geometry.
[YamlMember(Alias = "background_color", ApplyNamingConventions = false)]
public string BackgroundColor { get; set; }
[YamlMember(Alias = "background_opacity_percent", ApplyNamingConventions = false)]
public int? BackgroundOpacityPercent { get; set; }
[YamlMember(Alias = "background_padding", ApplyNamingConventions = false)]
public double? BackgroundPadding { get; set; }
[YamlMember(Alias = "background_corner_radius", ApplyNamingConventions = false)]
public double? BackgroundCornerRadius { get; set; }
[YamlMember(Alias = "border_color", ApplyNamingConventions = false)]
public string BorderColor { get; set; }
[YamlMember(Alias = "border_width", ApplyNamingConventions = false)]
public double? BorderWidth { get; set; }
public List<StyleDefinition> Styles { get; set; } = [];
[YamlMember(Alias = "base_style", ApplyNamingConventions = false)]
public string BaseStyle { get; set; }
[YamlMember(Alias = "include_fonts_from", ApplyNamingConventions = false)]
public string IncludeFontsFrom { get; set; }
[YamlMember(Alias = "epg_entries", ApplyNamingConventions = false)]
public int EpgEntries { get; set; }
public string Text { get; set; }
}
public enum TextFit
{
None,
Wrap,
Scale
}
public enum TextAlignment
{
Left,
Center,
Right
}
public class StyleDefinition
{
public string Name { get; set; }
[YamlMember(Alias = "font_size", ApplyNamingConventions = false)]
public float? FontSize { get; set; }
[YamlMember(Alias = "font_weight", ApplyNamingConventions = false)]
public int? FontWeight { get; set; }
[YamlMember(Alias = "font_italic", ApplyNamingConventions = false)]
public bool? FontItalic { get; set; }
[YamlMember(Alias = "font_family", ApplyNamingConventions = false)]
public string FontFamily { get; set; }
[YamlMember(Alias = "text_color", ApplyNamingConventions = false)]
public string TextColor { get; set; }
[YamlMember(Alias = "letter_spacing", ApplyNamingConventions = false)]
public float? LetterSpacing { get; set; }
[YamlMember(Alias = "line_height", ApplyNamingConventions = false)]
public float? LineHeight { get; set; }
[YamlMember(Alias = "halo_color", ApplyNamingConventions = false)]
public string HaloColor { get; set; }
[YamlMember(Alias = "halo_width", ApplyNamingConventions = false)]
public float? HaloWidth { get; set; }
[YamlMember(Alias = "halo_blur", ApplyNamingConventions = false)]
public float? HaloBlur { get; set; }
}