11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
16#if PROMEKI_ENABLE_FREETYPE
23PROMEKI_NAMESPACE_BEGIN
26class UncompressedVideoPayload;
84class SubtitleRenderer {
89 SubtitleRenderer(
const SubtitleRenderer &) =
delete;
90 SubtitleRenderer &operator=(
const SubtitleRenderer &) =
delete;
95 void setFontFilename(
const String &val);
99 void setFontSize(
int val);
103 void setDefaultForeground(
const Color &c);
107 void setDefaultBackground(
const Color &c);
111 void setDrawBackground(
bool v);
115 void setMargin(
int v);
122 void setAnchorOverride(
const SubtitleAnchor &v);
127 void setTopReserved(
int lines);
131 void setBottomReserved(
int lines);
135 const String &fontFilename()
const {
return _fontFilename; }
136 int fontSize()
const {
return _fontSize; }
137 const Color &defaultForeground()
const {
return _defaultFg; }
138 const Color &defaultBackground()
const {
return _defaultBg; }
139 bool drawBackground()
const {
return _drawBackground; }
140 int margin()
const {
return _margin; }
141 const SubtitleAnchor &anchorOverride()
const {
return _anchorOverride; }
142 int topReserved()
const {
return _topReserved; }
143 int bottomReserved()
const {
return _bottomReserved; }
160 Error render(
const Subtitle &subtitle, UncompressedVideoPayload &target);
169 using StyledRunList = List<StyledRun>;
171 using StyledLineList = List<StyledRunList>;
175 SubtitleAnchor effectiveAnchor(
const SubtitleAnchor &cueAnchor)
const;
180 void layoutSpans(
const SubtitleSpan::List &spans, StyledLineList &lines);
185 void computePosition(
const SubtitleAnchor &anchor,
const Rect2Di32 &bounds,
int maxLineWidth,
186 int totalHeight,
int ascender,
int &outX,
int &outBaselineY)
const;
188#if PROMEKI_ENABLE_FREETYPE
191 FastFont::DrawStyle styleFor(
const SubtitleSpan &span)
const;
194 String _fontFilename;
196 Color _defaultFg = Color::White;
197 Color _defaultBg = Color::Black;
198 bool _drawBackground =
true;
200 SubtitleAnchor _anchorOverride;
201 int _topReserved = 0;
202 int _bottomReserved = 0;
207#if PROMEKI_ENABLE_FREETYPE
208 FastFont::UPtr _font;
210 int _effectiveFontSize = 0;
211 bool _fontDirty =
true;