Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Commitaa1f4cb
committed
Fix alpha compositing in ft2font's draw_bitmap.
The old formula (`*dst |= *src`) works fine when either dst or src isfull transparent or fully opaque, but not for compositing intermediatevalues. Fix that (while keeping a fast-path for the common case ofwriting on an empty buffer).Example (note the more uniform gray zone between the two letters):```from matplotlib import pyplot as plt, ft2font as f, cbookimport numpy as npfont = f.FT2Font(str(cbook._get_data_path("fonts/ttf/DejaVuSans.ttf")))font.set_size(24, 72)im = f.FT2Image(30, 30)ga = font.load_char(ord("A"))gv = font.load_char(ord("V"))font.draw_glyph_to_bitmap(im, 2, 2, ga)font.draw_glyph_to_bitmap(im, 12, 2, gv)(plt.figure(layout="constrained", figsize=(3, 3)) .add_subplot(xticks=[], yticks=[]) .imshow(np.asarray(im), cmap="gray"))plt.show()```1 parentdef8fa4 commitaa1f4cb
1 file changed
+14
-4
lines changedLines changed: 14 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
73 | 73 |
| |
74 | 74 |
| |
75 | 75 |
| |
76 |
| - | |
77 |
| - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 |
| |
79 | 89 |
| |
80 |
| - | |
81 | 90 |
| |
82 | 91 |
| |
83 | 92 |
| |
| |||
96 | 105 |
| |
97 | 106 |
| |
98 | 107 |
| |
99 |
| - | |
| 108 | + | |
| 109 | + | |
100 | 110 |
| |
101 | 111 |
| |
102 | 112 |
| |
|
0 commit comments
Comments
(0)