Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Commitda6647b
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 parentde00c49 commitda6647b
1 file changed
+12
-1
lines changedLines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
107 | 117 |
| |
108 | 118 |
| |
109 | 119 |
| |
| |||
124 | 134 |
| |
125 | 135 |
| |
126 | 136 |
| |
127 |
| - | |
| 137 | + | |
| 138 | + | |
128 | 139 |
| |
129 | 140 |
| |
130 | 141 |
| |
|
0 commit comments
Comments
(0)