Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CueStyler: Fix outline rendering of TimedTextCue elements #9224

Open
wants to merge 1 commit into
base: winui3/release/1.5-stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 11 additions & 26 deletions dxaml/xcp/dxaml/lib/CueStyler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,44 +1436,29 @@ CCueStyler::CreateOutline(_In_ wmc::ITimedTextLine* pLine,

wmc::TimedTextDouble thickness = {};
double fontSize = {};
double offset = {};
double outlineWidth = {};

IFC(CalculateFontSize(pStyle, &fontSize));

IFC(pStyle->get_OutlineThickness(&thickness));

if (thickness.Unit == wmc::TimedTextUnit_Percentage)
{
offset = (thickness.Value / 100) * fontSize;
outlineWidth = (thickness.Value / 100) * fontSize;
}
else
{
offset = thickness.Value;
outlineWidth = thickness.Value;
}

// Upper left
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, -offset));

// Upper center
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, -offset));

// Upper right
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, -offset));

// Left
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, 0));

// Right
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, 0));

// Lower left
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, offset));

// Lower center
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, offset));
const int iterations = 32;
for (int i = 0; i < iterations; ++i)
{
double fraction = static_cast<double>(i) / iterations;
double offsetX = std::sin(fraction * 2 * M_PI) * outlineWidth;
double offsetY = std::cos(fraction * 2 * M_PI) * outlineWidth;

// Lower right
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, offset));
IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offsetX, offsetY));
}

Cleanup:
return hr;
Expand Down