GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — Apply hinting factor rcParam in all cases. by QuLogic · Pull Request #9481 · matplotlib/matplotlib Conversation
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 random 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThis 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
previously approved these changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conditional on CI
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
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. for hinting_factor in map(int, sys.argv[1:]): plt.rcParams['text.hinting_factor'] = hinting_factor fig, 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 PR does fix, if you add a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@QuLogic but I guess that caching was already present before, in which case this PR does not really make things worse, does it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anntzer True, it just makes it more difficult to write a test. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Static initializers are only applied the first time, so any subsequent calls with alternate hinting_factor would use the first value. FreeType copies the matrix values into an internal structure, so these do not really need to be static.
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah, the static was tricky... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
test failures look real though |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
b61fbd7 to
df5558c
Compare
df5558c to
6a685d2
Compare
|
Not sure why I needed the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
Is not it equals to?
@lru_cache(64) def get_font(filename, hinting_factor=None): if hinting_factor is None: hinting_factor = rcParams['text.hinting_factor'] return ft2font.FT2Font(filename, hinting_factor)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That would cache hinting_factor=None with whatever the value of the rcParam was at first call.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
thanks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.