Commit 15d350a
committed
fix(text): draw Fabric text with grayscale antialiasing on transparent surfaces
RenderText calls ID2D1RenderTarget::DrawTextLayout without setting a text
antialias mode, so the draw inherits the device context default - ClearType
subpixel antialiasing on a normal machine. The target it draws onto is
transparent: ParagraphComponentView creates the drawing surface with
DirectXAlphaMode::Premultiplied and clears it to ColorF(Black, 0.0f) when the
view has no backgroundColor.
ClearType computes independent R/G/B coverage and needs an opaque, known
background to filter against. With none, that per-channel coverage lands in the
surface colour channels and shows as dark or colour-tinted fringes along thin
glyph stems once composited. D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE is the
documented mode for transparent render targets.
Saves the current mode, sets GRAYSCALE for the draw, and restores it - mirroring
the GetAntialiasMode/SetAntialiasMode and GetDpi/SetDpi save/restore idioms
already used in this function.
Neither SetTextAntialiasMode nor D2D1_TEXT_ANTIALIAS_MODE appeared anywhere in
the tree before this change.
Addresses #16340.1 parent c69cf55 commit 15d350a
2 files changed
Lines changed: 19 additions & 0 deletions
File tree
- change
- vnext/Microsoft.ReactNative/Fabric/Composition
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
172 | 182 | | |
173 | 183 | | |
| 184 | + | |
| 185 | + | |
174 | 186 | | |
175 | 187 | | |
176 | 188 | | |
| |||
0 commit comments