Skip to content

Improve readability of _mathtext_data.stix_virtual_fonts table #25990

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

Closed

Conversation

lucavribeiro
Copy link

PR summary

Hi! I made some changes on mathtext_data file to improve readability (using Unicode character name in order to make to code clearer) as asked (issue 25738).

So, i changed the table from like this:

(0x0393, 0x0393, 'it', 0x213e),  # \Gamma (not in beta STIX fonts)
(0x03a0, 0x03a0, 'it', 0x213f),  # \Pi

To this:

 ("\N{GREEK CAPITAL LETTER GAMMA}", "\N{GREEK CAPITAL LETTER GAMMA}",
     'it', 0x213e),
 ("\N{GREEK CAPITAL LETTER PI}", "\N{GREEK CAPITAL LETTER PI}",
     'it', 0x213f),

PR checklist

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Using ord function to convert the unicode to an integer
(0x03a3, 0x03a3, 'rm', 0x2140), # \Sigma
(0x03b3, 0x03b3, 'rm', 0x213d), # \gamma
(0x03c0, 0x03c0, 'rm', 0x213c), # \pi
(ord("\N{GREEK CAPITAL LETTER GAMMA}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also replace the codepoints above (0x0030 = "0" (no real need to write that as "\N{DIGIT ZERO}")), as well as the last items of the tuple when applicable (0x213e = "\N{DOUBLE-STRUCK CAPITAL GAMMA}" but 0x1d7d8 is just an internal codepoint for the font with no associated name).

Copy link
Author

Choose a reason for hiding this comment

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

Hi, thanks for the feedback! I included replacements for these codepoints and for the last items that i could find as well in my last commit

replaced digits and letters
@QuLogic
Copy link
Member

QuLogic commented May 30, 2023

As noted in the issue, I don't think you want to write ord everywhere, and instead replace that with a dict/list comprehension that calls it in one place for everything.

@lucavribeiro lucavribeiro marked this pull request as draft May 30, 2023 22:01
@lucavribeiro lucavribeiro marked this pull request as ready for review May 30, 2023 23:31
@lucavribeiro
Copy link
Author

Thanks for the feedback @QuLogic! I've updated the code to include the list and dict comprehension now. For the unicodes list i had to include "\N{}" in the strings so it wouldn't throw an error when it loops because of "0", "9" and the letters strings. Btw, i really couldn't identify why there is a linting problem

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

I don't think there's a need for list_uni or uni_map; that's basically a longer way of writing ord. Rather, just write out the text in each of the tables, and do one dict/list comprehension at the end over everything in stix_virtual_fonts. If you need to mix characters and ordinals, then perhaps only do that on the lists that need it directly.

@lucavribeiro lucavribeiro marked this pull request as draft July 8, 2023 12:48
@devRD devRD mentioned this pull request Sep 19, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[MNT]: Improve readability of _mathtext_data.stix_virtual_fonts table
4 participants