Skip to content

Commit b6e16a4

Browse files
committed
CueStyler: Fix outline rendering of TimedTextCue elements
1 parent 93742a1 commit b6e16a4

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

dxaml/xcp/dxaml/lib/CueStyler.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,44 +1436,29 @@ CCueStyler::CreateOutline(_In_ wmc::ITimedTextLine* pLine,
14361436

14371437
wmc::TimedTextDouble thickness = {};
14381438
double fontSize = {};
1439-
double offset = {};
1439+
double outlineWidth = {};
14401440

14411441
IFC(CalculateFontSize(pStyle, &fontSize));
1442-
14431442
IFC(pStyle->get_OutlineThickness(&thickness));
14441443

14451444
if (thickness.Unit == wmc::TimedTextUnit_Percentage)
14461445
{
1447-
offset = (thickness.Value / 100) * fontSize;
1446+
outlineWidth = (thickness.Value / 100) * fontSize;
14481447
}
14491448
else
14501449
{
1451-
offset = thickness.Value;
1450+
outlineWidth = thickness.Value;
14521451
}
14531452

1454-
// Upper left
1455-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, -offset));
1456-
1457-
// Upper center
1458-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, -offset));
1459-
1460-
// Upper right
1461-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, -offset));
1462-
1463-
// Left
1464-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, 0));
1465-
1466-
// Right
1467-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, 0));
1468-
1469-
// Lower left
1470-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, offset));
1471-
1472-
// Lower center
1473-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, offset));
1453+
const int iterations = 32;
1454+
for (int i = 0; i < iterations; ++i)
1455+
{
1456+
double fraction = static_cast<double>(i) / iterations;
1457+
double offsetX = std::sin(fraction * 2 * M_PI) * outlineWidth;
1458+
double offsetY = std::cos(fraction * 2 * M_PI) * outlineWidth;
14741459

1475-
// Lower right
1476-
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, offset));
1460+
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offsetX, offsetY));
1461+
}
14771462

14781463
Cleanup:
14791464
return hr;

0 commit comments

Comments
 (0)