Skip to content
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

Text positioning fixes for odd fonts #1915

Closed
wants to merge 5 commits into from
Closed

Text positioning fixes for odd fonts #1915

wants to merge 5 commits into from

Conversation

micahcc
Copy link

@micahcc micahcc commented May 19, 2016

PR for #1660

@micahcc micahcc mentioned this pull request May 19, 2016
@coveralls
Copy link

coveralls commented May 19, 2016

Coverage Status

Changes Unknown when pulling 599c3d0 on MicahChambers:issue-1660-text-bb into * on python-pillow:master*.

lineHeightPercent = 100
try:
lineHeight = font.font.height
except Exception as exc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exc is assigned to but unused.

Do we want to catch all exceptions, or would it be better just to catch some and let others go up?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v-python what got raised here? An AttributeError I'm guessing?

Copy link

@v-python v-python May 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. When integrated with Pillow, that try/except may not be needed. The code was dealing with whether or not font.font.height was defined, which was a recent addition, but of course not quite as recent as this code is being added, so you can probably scoot line 333 to the left and drop the try and the whole except block.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see. Thanks.

@hugovk
Copy link
Member

hugovk commented May 21, 2016

@MicahChambers Thanks for the PR.

Please can you summarise what this actually fixes/adds, and include unit tests?

(It'd be nice for the code to follow pep8 standards where suitable:
https://travis-ci.org/python-pillow/Pillow/jobs/131565393#L4686 )

font = self.getfont()
ink, fill = self._getink( fill )
if ink is None:
inx = fill
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inx is assigned to but unused.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo. Should be ink.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@micahcc
Copy link
Author

micahcc commented May 23, 2016

Thanks for the review! I'll look over it tonight.

@micahcc
Copy link
Author

micahcc commented May 24, 2016

@v-python @hugovk I'll go through and do a little cleanup. I'll

  1. change variable names to be more descriptive
  2. Add tests
  3. add docstrings describing the arguments to things.

The reason I didn't do this before when I was dumping @v-python 's code into a PR is that I have submitted PR's to open source projects in the past and gotten no response -- so I didn't want to spend a bunch of time if it wasn't going to get picked up. @hugovk you can probably ignore this for a week and I'll ping you when things are more "pythonic"

@coveralls
Copy link

coveralls commented Jun 3, 2016

Coverage Status

Changes Unknown when pulling e3ad94e on MicahChambers:issue-1660-text-bb into * on python-pillow:master*.

@micahcc
Copy link
Author

micahcc commented Jun 3, 2016

@hugovk @v-python I need to add tests, would it make sense to just replace the current draw text function?

@hugovk
Copy link
Member

hugovk commented Jun 3, 2016

Which function?

It's better to add new tests than replace existing ones. We want to keep existing ones to guard against regressions (but of course update any where functionality has changed).

@micahcc
Copy link
Author

micahcc commented Jun 3, 2016

Oh, I mean, draw_at_pos is basically doing the same thing as text(), so maybe this should just be an updated of text() to draw lines more accurately?

@v-python
Copy link

v-python commented Jun 3, 2016

Current text() tests might be revised to test draw_at_pos(). But IIRC, text doesn't let you specify a baseline... it positions the top left corner, which is not totally useless, but it makes it really hard to line things up that don't want to all be the same font or same font size. So updating text() to have the function of draw_at_pos() would require a significant rework of the code of either or both... and it would lose the ease-of-use of having things be aligned on a particular baseline.

@radarhere radarhere changed the title issue-1660 Text positioning fixes for odd fonts Text positioning fixes for odd fonts Aug 7, 2016
@aclark4life aclark4life added this to the 3.5.0 milestone Oct 3, 2016
@radarhere radarhere modified the milestones: 4.1.0, 4.0.0 Jan 7, 2017
@wiredfool wiredfool modified the milestones: 4.1.0, 4.2.0 Apr 1, 2017
@radarhere radarhere removed this from the 4.2.0 milestone Oct 4, 2017
@v-python
Copy link

I'm sorry this effort seems to have stalled, and bit-rotted. But now it seems Pillow doesn't even support text on Windows anymore. #3407

@micahcc micahcc closed this Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants