Skip to content
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

image formatter supports background color #1374

Merged
merged 1 commit into from Feb 14, 2021
Merged

image formatter supports background color #1374

merged 1 commit into from Feb 14, 2021

Conversation

hmedina
Copy link
Contributor

@hmedina hmedina commented Jan 29, 2020

Extend Image formatters in img.py to support background colors.

  • New function to get the background color for a given token type, optionally None
  • The self.drawables list used the fill keyword, stuffed into a **kwrgs, for the color of the token; since tokens can have foreground and background colors, that list now uses two explicit names, passing one to the PIL/Pillow text draw call, the other to the rectangle draw call.
  • When iterating over the drawables list, the presence of a background color triggers the drawing of a rectangle beneath the text.
  • Dimensions of background rectangle calculated by PIL based on the rendered text and font.
  • If input string is multiline, PIL will use multiline for draw and size internally.

Extend Image formatters in img.py to support background colors.

* New function to get the background color for a given token type, optionally None
* The self.drawables list used the fill keyword, stuffed into a **kwrgs, for the color of the token; since tokens can have foreground and background colors, that list now uses two explicit names, passing one to the PIL/Pillow text draw call, the other to the rectangle draw call.
* When iterating over the `drawables` list, the presence of a background color triggers the drawing of a rectangle beneath the text.
* Dimensions of background rectangle calculated by PIL based on the rendered text and font.
* If input string is multiline, PIL will use multiline for draw and size internally.
@Anteru
Copy link
Collaborator

Anteru commented Feb 7, 2021

Sorry for taking this long to get around to this :( One question on the **kw replacement: Did you audit all places to make sure there is nothing else passed via **kw? Otherwise this looks good.

@Anteru Anteru self-assigned this Feb 7, 2021
@Anteru Anteru added this to the 2.8 milestone Feb 7, 2021
Copy link
Member

@birkenfeld birkenfeld left a comment

Choose a reason for hiding this comment

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

LGTM.

@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Feb 14, 2021
@Anteru Anteru merged commit e59ec24 into pygments:master Feb 14, 2021
@Anteru
Copy link
Collaborator

Anteru commented Feb 14, 2021

Merged, thanks!

@Anteru Anteru removed the changelog-update Items which need to get mentioned in the changelog label Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants