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

Text rendering with alpha in Color renders incorrectly #7711

Open
brinko99 opened this issue Apr 12, 2023 Discussed in #7710 · 1 comment
Open

Text rendering with alpha in Color renders incorrectly #7711

brinko99 opened this issue Apr 12, 2023 Discussed in #7710 · 1 comment
Assignees
Labels
Investigate Requires further investigation by the WPF team.

Comments

@brinko99
Copy link

There appears to be a bug with the rendering of text where the associated color contains an opacity (alpha). See the linked discussion.

@miloush noted that the issue is dependent on the font size and affects <Glyph> and <GlyphRunDrawing> as well.

Discussed in #7710

Originally posted by brinko99 April 11, 2023
I’m trying to implement a text color in WPF that matches CSS RGBA of #00,00,00,0.72 on a white background. I’d expect that to be a color of #B8000000 (alpha of dec 184 ≈ .72), yet the result is much lighter than expected. Applying opacity to the control itself works as expected.

I'm expecting the composite color to be #474747 as produced by CSS and paint.net, but I'm getting #8C8C8C. Does WPF render alpha on a brush differently somehow?

Here is an example:
image

<StackPanel Background="White">
    <TextBlock Text="Medium Contrast (#B8000000)" Foreground="#B8000000" Style="{x:Null}" />
    <TextBlock Text="Medium Contrast (Opacity .72)" Foreground="#FF000000" Opacity=".72"  Style="{x:Null}"/>
</StackPanel>
@singhashish-wpf singhashish-wpf added the Investigate Requires further investigation by the WPF team. label Apr 12, 2023
@wstaelens
Copy link
Contributor

This explains why XPS colors are sometimes diffent..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

4 participants