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
Implementation of Issue #3418 - Auto-wrapping text #4342
Conversation
Nice. I don't really understand what is causing the failures though. I assume it is some issue with freetype versions... |
@tacaswell Anyway to pull the image out of Travis and compare? @sptm Do you have any rcParams set different from defaults? For example |
@tacaswell Freetype2 is the version I've been using to generate the test images on several computers. Is there a version to conform to? @OceanWolf In development, rcParams remained the same. It's been recently updated to the MPL source code though when preparing for PR. Would that make a difference? @sptm Remove the font test case and check? |
exactly which version of freetype2 matters. All of the current test images are generated with freetype 2.5.3-21 on Fedora 21 (per #4031 (comment)). The failed images on non-PR builds are uploaded to AWS but there is no way to get the images from failed PR build.s |
Also see #4345 |
Oooh, brainwave, as part of the testing infrastructure we could catch the test failure email the graphic to the owner of the PR (or something similar) and then re-raise the error. See http://stackoverflow.com/questions/3362600/how-to-send-email-attachments-with-python for emailing attachments! |
@OceanWolf: That's a good idea, and one I've certainly thought about. The problem is that to e-mail you need e-mail credentials to some mail transport server. And to use e-mail credentials in a pull request, you are basically exposing those credentials to anyone who wants to submit a pull request (i.e. anyone with a github account). It won't be long until someone uses those credentials to just send spam. What we do do is upload the images to an Amazon S3 account, and those images are then publically downloadable. But we can only do it on the main fork (because the only people who can put code in master are "trusted" people), not in any PR. As a workaround, of course, an author of a PR can ask someone with developer priviledges to push the source branch on the PR to a temporary branch on the main fork. That causes Travis-CI to test the branch and upload the failed images to Amazon S3. |
Hmm, re the security issues of email, I can think of two methods:
|
For (1) -- you'd still need Github credentials for that, even if that were possible. For (2) -- where do you store the credentials to the S3 server? That server would cost real money if someone took it over to share files on or something. See the problem? Any build of a PR by necessity has exposes the keys to the castle to anyone who can make a PR. Doing any sort of network operation (other than read-only downloading) requires those keys. The workaround involves a trusted person (i.e. a matplotlib developer) to take an affirmative action after reading the PR for anything nefarious. As long as PRs are open to anyone on the internet, I don't see a way around that... |
@mdboom Actually no I don't see the problem. Method 1While probably not possible at the moment, I wondered how Travis communicates back to github to tell it that the build has succeeded/failed. For instance how it seems to work at the moment.
I suggest here that we tap into the messaging stream which occurs with step 2. and/or 3. operates to have Travis on failure ask github to message the owner of the PR in the same way that github messages the owner of the PR whenever someone posts a message on the PR. The secure communication aspect for this seems to exist, I just don't know about the API. If not, then it seems logical that it should and thus could get implemented. Of course I may completely misunderstand how the communication occurs between Travis and Github, apologies if I have. Method 2You don't need to store the credentials for the S3 server, you send a normal request, http
Because we keep all the credentials and perform all of the validation on the S3 server, we never expose any secure information, we only show publicly the information in the HTTP POST which contains only data that exists in the public domain anyway (and we can even encrypt using HTTPS, but I don't think we need to). |
Sorry for the late reply, the freetype version of the most recent one was 2.4.0. |
Can you also re-base so that the commits with the bad images are not in the history? We are trying to keep the size of the repo down as much as possible. |
So it looks like they don't have Times New Roman... thanks for the info. |
Iirc, there are licensing issues with it. We could probably install it, but On Sun, Apr 19, 2015, 00:12 sptm notifications@github.com wrote:
|
Looking into the Travis logs there are currently there are 3 missing fonts
|
- Auto-wrapping text enabled/disabled through new argument 'wrap' - PEP8 changes - Added test cases
It looks like it builds now. Any updates or suggestions regarding the PR? |
@ joferkington Any comments as this is based on your SO answer? |
tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp', | ||
self._fontproperties, | ||
ismath=False) | ||
tmp, lp_h, lp_bl = renderer.get_text_width_height_descent( |
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.
can you discard this change?
Newest commits uses a context manager to save the old text. Not sure if this is the correct way, as it's my first time using it. |
gc.set_alpha(self.get_alpha()) | ||
gc.set_url(self._url) | ||
self._set_gc_clip(gc) | ||
with _wrap_text(self) as self: |
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 would not yield this as self
, that is a bit terrifying.
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 can rename this to text
? textobj
?
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.
Yes
@sptm This definitely needs an entry in Putting an example in the gallery would also be a good idea. |
Documentation added. The example is the same one from the test case. |
Awesome! Thanks for your work. |
ENH : Implement auto-wrapping text closes #3418
No problem! Thanks for all the help. |
Thank you for adding this. |
Shouldn't the |
Well there are 218 closed PRs with needs review so whats special about this one. I don't really think thats important since github always does |
Ahh, didn't realise, nothing special, just the only one I have seen, I feel so used to seeing the |
I think the automatic removal is a relatively new thing so it will be missing from older merges. |
Implementation of Issue #3418 - Auto-wrapping text.
This is done by adding a new parameter 'wrap' to Text.
When enabled, it incrementally builds a temporary line and re-estimates the dimensions of the line for each word added, inserting new lines when needed.
Currently works for any rotated text, different modes of alignment, and for text that are either labels or titles.