Repository navigation
Fix FontProperties conversion to/from strings #15601
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,11 +178,15 @@ def _property(self, s, loc, tokens): | |
|
|
||
|
|
||
| def _escape_val(val, escape_func): | ||
| if type(val) == list: | ||
| """ | ||
| Given a string value or a list of string values, run each value through | ||
| the input escape function to make the values into legal font config | ||
| strings. The result is returned as a string. | ||
| """ | ||
| if isinstance(val, list): | ||
|
Member
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. This could be further simplified to:
Contributor
Author
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. Sorry - that doesn't work. strings are iterable so that test is incorrect. I appreciate what you're doing here but I have a suggestion (I'm not trying to be snarky so hopefuly this doesn't come across that way). When I make a PR, I try to change as little as possible to fix the bug. I agree that you're suggestions are improvements but they are not related to the bug fix, they're just general code improvements. Rather than telling me what to do, me doing it, merging it, and waiting for more reviews, it seems like it would be simpler and more efficient to merge the PR to fix the bug and then you can make whatever code improvements you want and commit them.
Member
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. Good catch. Thanks for seeing that, and thanks for your feedback on the process! Thinking of it, it should rather be My philosophy of PR reviewing (skip if you're not interested): In summary, I still would like to see the change with the str-check-variation above. Please let me know if you feel that's too cumbersome. I would then pick up from here myself. We're really grateful for your contribution. I'd also happy to hear from you if you feel this back-and-forth review is too annoying. That may help me to better judge how far to go and what to accept in future reviews.
Contributor
Author
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. OK, fair enough. I think I was feeling that way because I felt like that function wasn't really new code, just a refactoring of the existing code. I don't think that testing for str will work either since some of the properties are integers (font size). Those get converted to string in the non-list path. So we would need to do something like I've updated the code to that.
Member
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. Thanks! 👍 |
||
| val = [escape_func(r'\\\1', str(x)) for x in val | ||
| if x is not None] | ||
| if val != []: | ||
| val = ','.join(val) | ||
| val = ','.join(val) | ||
| else: | ||
| val = escape_func(r'\\\1', str(val)) | ||
|
|
||
|
|
@@ -199,7 +203,7 @@ def generate_fontconfig_pattern(d): | |
| # Family is added first w/o a keyword | ||
| family = d.get_family() | ||
| if family is not None and family != []: | ||
| props.append("%s" % (_escape_val(family, family_escape))) | ||
| props.append(_escape_val(family, family_escape)) | ||
|
|
||
| # The other keys are added as key=value | ||
| for key in ['style', 'variant', 'weight', 'stretch', 'file', 'size']: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.