Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Bold text rendering support #35

Closed
wants to merge 2 commits into from
Closed

Bold text rendering support #35

wants to merge 2 commits into from

Conversation

andyone
Copy link

@andyone andyone commented Jul 4, 2018

Hi! First, thanks for superb utility!

I found that currently termtosvg doesn't support the bold text. It adds styles, but text rendered with normal width.

Now, if the character has bold modification flag it adds font-weight="bold" attribute to SVG node.

@andyone
Copy link
Author

andyone commented Jul 4, 2018

Ouch! I forgot about tests.

@andyone
Copy link
Author

andyone commented Jul 5, 2018

All should be fine now 😊

@nbedos
Copy link
Owner

nbedos commented Jul 5, 2018

Hi, thanks for contributing! There's a catch with bold characters: there are two ways to display them:

  • Display the character in bold font
  • Display the character using a 'bright' color alternative

Bright colors are colors ranging from color8 to color15, they are used as a replacement for color0 to color7 for bold characters.

termtosvg currently uses bright colors, but I don't know what the right behavior is though. I'm not even sure there is one. Maybe using a bold font if the color palette does not include bright colors, and use bright colors otherwise? What's your color configuration like?

I will look at this in more detail in the next few days.

@andyone
Copy link
Author

andyone commented Jul 6, 2018

Display the character using a 'bright' color alternative

This is a fallback mechanism for terminals which don't support bold fonts (some old ones). At this moment according to this page, only Eterm render bold text using bright colors.

Rendering bold text using bright colors it's a real problem if you want to use light colors and bold text at the same time (like me).

Maybe using a bold font if the color palette does not include bright colors, and use bright colors otherwise?

I think termtosvg should avoid rendering bold text using bright colors. It's a very old trick for terminals which nobody uses nowadays.

@nbedos
Copy link
Owner

nbedos commented Jul 6, 2018

I think termtosvg should avoid rendering bold text using bright colors. It's a very old trick for terminals which nobody uses nowadays.

I'm relying on bright colors for my own color theme so it would be nice if my own tool could handle them. :D Urxvt (which I'm using) displays bold characters using a bold font and a bright color so that's probably the right thing to do. I didn't notice this earlier because I have disabled the bold font in my configuration. Your patch allows

  • having bold characters without bright colors (using an 8 color theme)
  • having bold characters with bright colors (using a 16 color theme)

So it should make everyone happy, except maybe people who don't want a bold font. I'd rather not clutter the configuration file with unused options so I'll consider this later if it's requested.

nbedos added a commit that referenced this pull request Jul 6, 2018
@nbedos
Copy link
Owner

nbedos commented Jul 6, 2018

Manually merged in master: f623de9

Thanks again!

@nbedos nbedos closed this Jul 6, 2018
@nbedos nbedos added the merged This pull request was merged label Jul 6, 2018
@nbedos
Copy link
Owner

nbedos commented Jul 7, 2018

FYI this feature is included in the release candidate I've just uploaded to test.pypi.org. You can get it with the following command:

pip install --extra-index-url https://test.pypi.org/simple/ 'termtosvg>=0.4.0rc0'

The corresponding git tag is 0.4.0rc0

If you give it a try and find a bug please open an issue about it. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
merged This pull request was merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants