Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
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.
conditional on CI
QuLogic commentedOct 19, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 a |
@QuLogic but I guess that caching was already present before, in which case this PR does not really make things worse, does it? |
@anntzer True, it just makes it more difficult to write a test. |
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 commentedOct 20, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 use |
Ah, the static was tricky... |
test failures look real though |
b61fbd7
todf5558c
CompareNot sure why I needed the |
def get_font(filename, hinting_factor=None): | ||
if hinting_factor is None: | ||
hinting_factor = rcParams['text.hinting_factor'] | ||
return _get_font(filename, hinting_factor) |
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.
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)
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.
That would cachehinting_factor=None
with whatever the value of the rcParam was at first call.
thanks |
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 random
hinting_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