Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix incorrect color blending for overlapping glyphs #7497
Fix incorrect color blending for overlapping glyphs #7497
Changes from 18 commits
f97570f
49fd211
76f758e
bb0eff4
a7f805d
e1aaec3
b15b2d4
fdecfca
8ecf2e9
11bea8f
d127600
0a33b30
29ca3fc
f3b3442
0cef9f2
38992f6
9c60e85
78f78d2
e800026
bd2977c
a6a612c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 35 in src/PIL/ImageDraw.py
Codecov / codecov/patch
src/PIL/ImageDraw.py#L35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching through Pillow's existing code, the tradition has been to use native mode implicitly rather than explicitly.
Pillow/src/PIL/SpiderImagePlugin.py
Line 259 in 76446ee
Pillow/src/PIL/SgiImagePlugin.py
Lines 184 to 188 in 76446ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default is
@
mode, which is not equivalent to=
.From https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment:
The
s
andf
formats are the same for both@
and=
.l
is platform dependent with@
, but is used with>
in the quoted code above.i
is platform dependent, so changing=
to@
can change the behavior here.However, in the C code, I see that
int
is assumed to be at least 4 bytes, so it is likely the same on all currently supported platforms even if it is not the same in general.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radarhere what do you think? Happy to adjust as needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't read the linked documentation in enough detailed to notice the distinction before I made my suggestion. Thanks nulano for catching that.
I don't have strong feelings, I was just trying to follow a convention. If there is a preference to future proof this code by using
=
, that's fine with me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, @nulano let us know if you want to be sure to include this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking more specifically at the
_draw_ink
function which provides theink
value, the ink is created in anINT32
type (which corresponds to a=i
format), but is cast to a Cint
(corresponding to@i
ori
format) before returning it (for future reference, the cast should probably be along
instead):Pillow/src/_imaging.c
Lines 2848 to 2861 in 80d0ed4
When it is later received in
font_render
, it is stored in along long
and converted tounsigned int
before being read as bytes:Pillow/src/_imagingft.c
Lines 805 to 806 in b51dcc0
Pillow/src/_imagingft.c
Line 842 in b51dcc0
Pillow/src/_imagingft.c
Line 847 in b51dcc0
So if
int
is smaller than 4 bytes, thegetink
function will discard data, and ifint
is larger than 4 bytes, the ink will be read as black on a big-endian platform. Either way, there will be an issue before this code is reached.Therefore, I think it's fine to leave the format specifier as
i
and leave this thread "unresolved" to document it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nulano, just marked this thread as unresolved.
Check warning on line 547 in src/PIL/ImageDraw.py
Codecov / codecov/patch
src/PIL/ImageDraw.py#L546-L547