Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Apply hinting factor rcParam in all cases.#9481

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
anntzer merged 3 commits intomatplotlib:masterfromQuLogic:fix-hinting-factor
Nov 4, 2017

Conversation

QuLogic
Copy link
Member

This is only explicitly used in Agg, so any other users get the default in the C++ code. Thus if you modify this setting and use some other backend, you get very weird behaviour. Positioning sometimes breaks and glyphs are shrunk or cropped.

@anntzer this is why just changing a randomhinting_factor produced super-weird results yesterday.

Don't know if it's worth backporting; I guess no-one ever tried modifying this setting or they would have complained. Also, trying to see if a simple test of some sort can be done.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [?] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

This is only explicitly used in Agg, so any other users get the defaultin the C++ code. Thus if you modify this setting and use some otherbackend, you get very weird behaviour. Positioning sometimes breaks andglyphs are shrunk or cropped.
anntzer
anntzer previously approved these changesOct 19, 2017
Copy link
Contributor

@anntzeranntzer left a comment

Choose a reason for hiding this comment

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

conditional on CI

@QuLogic
Copy link
MemberAuthor

QuLogic commentedOct 19, 2017
edited
Loading

Hmm, something might still be cached somewhere as changing the hinting factor in the middle of a script causes all text to be the wrong width.

forhinting_factorinmap(int,sys.argv[1:]):plt.rcParams['text.hinting_factor']=hinting_factorfig,ax=plt.subplots()ax.text(0.5,0.5,'text')plt.show()

Opens figures with progressively smaller text (or wider depending on what you specify), but it's fine if you specify anything other than 8 in a separate run.

As an example of something this PRdoes fix, if you add afig.savefig('test.svg') before show (to switch backends), you get broken text for anything other than 8 onmaster.

@anntzer
Copy link
Contributor

@QuLogic but I guess that caching was already present before, in which case this PR does not really make things worse, does it?

@QuLogic
Copy link
MemberAuthor

@anntzer True, it just makes it more difficult to write a test.

@anntzeranntzer dismissed theirstale reviewOctober 19, 2017 22:25

let me investigate the caching first...

Static initializers are only applied the first time, so any subsequentcalls with alternate hinting_factor would use the first value. FreeTypecopies the matrix values into an internal structure, so these do notreally need to be static.
@QuLogic
Copy link
MemberAuthor

QuLogic commentedOct 20, 2017
edited
Loading

I think that should fix the caching issue, and it even fixes the SVG+Agg save from above, without the first change. I guess the first change can still go in for consistency.

But thinking about it, SVG and PDF render text externally, so it may be better to have those usehinting_factor=1 since that's the most likely method to be used by external renderers. Maybe can discuss that in a separate issue where we also might decide to turn it off entirely.

@anntzer
Copy link
Contributor

Ah, the static was tricky...
I would favor moving the discussion of entirely dropping hinting_factor (which I agree with) to a separate issue, not clear there's much gain of doing so in a piecemeal fashion.

@anntzer
Copy link
Contributor

test failures look real though

@QuLogicQuLogicforce-pushed thefix-hinting-factor branch 3 times, most recently fromb61fbd7 todf5558cCompareOctober 21, 2017 08:54
@QuLogic
Copy link
MemberAuthor

Not sure why I needed theclear andset_size as I thought the same stuff is done in the constructor, but it matches what's done in normal rendering code and it works, so...

def get_font(filename, hinting_factor=None):
if hinting_factor is None:
hinting_factor = rcParams['text.hinting_factor']
return _get_font(filename, hinting_factor)
Copy link
Member

Choose a reason for hiding this comment

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

Is not it equals to?

@lru_cache(64)defget_font(filename,hinting_factor=None):ifhinting_factorisNone:hinting_factor=rcParams['text.hinting_factor']returnft2font.FT2Font(filename,hinting_factor)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

That would cachehinting_factor=None with whatever the value of the rcParam was at first call.

@tacaswelltacaswell added this to thev2.2 milestoneOct 29, 2017
@anntzer
Copy link
Contributor

thanks

@anntzeranntzer merged commitb2bbbfd intomatplotlib:masterNov 4, 2017
@QuLogicQuLogic deleted the fix-hinting-factor branchNovember 4, 2017 23:26
@QuLogicQuLogic modified the milestones:needs sorting,v2.2.0Feb 12, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@KojoleyKojoleyKojoley left review comments

@dopplershiftdopplershiftdopplershift approved these changes

@anntzeranntzeranntzer left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.2.0
Development

Successfully merging this pull request may close these issues.

5 participants
@QuLogic@anntzer@dopplershift@Kojoley@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp