dotnet / dotnet/wpf

Text rendering with alpha in Color renders incorrectly

Open
#7,711 1 comment 1 reaction 1 assignee Claimed by @dipeshmsft View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

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 `` and `` as well.

### Discussed in https://github.com/dotnet/wpf/discussions/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](https://user-images.githubusercontent.com/1231765/231280155-d32f2c70-b563-4bc7-b1aa-e10208978ae8.png)

```


```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.