11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
21PROMEKI_NAMESPACE_BEGIN
24class UncompressedVideoPayload;
82class SubtitleRenderer {
87 SubtitleRenderer(
const SubtitleRenderer &) =
delete;
88 SubtitleRenderer &operator=(
const SubtitleRenderer &) =
delete;
93 void setFontFilename(
const String &val);
97 void setFontSize(
int val);
101 void setDefaultForeground(
const Color &c);
105 void setDefaultBackground(
const Color &c);
109 void setDrawBackground(
bool v);
113 void setMargin(
int v);
120 void setAnchorOverride(
const SubtitleAnchor &v);
125 void setTopReserved(
int lines);
129 void setBottomReserved(
int lines);
133 const String &fontFilename()
const {
return _fontFilename; }
134 int fontSize()
const {
return _fontSize; }
135 const Color &defaultForeground()
const {
return _defaultFg; }
136 const Color &defaultBackground()
const {
return _defaultBg; }
137 bool drawBackground()
const {
return _drawBackground; }
138 int margin()
const {
return _margin; }
139 const SubtitleAnchor &anchorOverride()
const {
return _anchorOverride; }
140 int topReserved()
const {
return _topReserved; }
141 int bottomReserved()
const {
return _bottomReserved; }
158 Error render(
const Subtitle &subtitle, UncompressedVideoPayload &target);
167 using StyledRunList = List<StyledRun>;
169 using StyledLineList = List<StyledRunList>;
173 SubtitleAnchor effectiveAnchor(
const SubtitleAnchor &cueAnchor)
const;
178 void layoutSpans(
const SubtitleSpan::List &spans, StyledLineList &lines);
183 void computePosition(
const SubtitleAnchor &anchor,
const Rect2Di32 &bounds,
int maxLineWidth,
184 int totalHeight,
int ascender,
int &outX,
int &outBaselineY)
const;
188 FastFont::DrawStyle styleFor(
const SubtitleSpan &span)
const;
190 String _fontFilename;
192 Color _defaultFg = Color::White;
193 Color _defaultBg = Color::Black;
194 bool _drawBackground =
true;
196 SubtitleAnchor _anchorOverride;
197 int _topReserved = 0;
198 int _bottomReserved = 0;
201 FastFont::UPtr _font;
202 int _effectiveFontSize = 0;
203 bool _fontDirty =
true;