lukas-reineke / headlines.nvim

This plugin adds horizontal highlights for text filetypes, like markdown, orgmode, and neorg.
MIT License
688 stars 28 forks source link

Use a more commonly supported character for `fat_headline_lower_string` #89

Open davidstosik opened 2 months ago

davidstosik commented 2 months ago

Update: this PR now uses matching "Upper Half Block" and "Lower Half Block" to generate vertically centered half headlines.

What

This PR replaces the character πŸ¬‚ (Block Sextant-12 (U+1FB02)) with β–€ (Upper Half Block (U+2580)) to be used for the fat_headline_lower_string configuration everywhere.

Why

The Block Sextant-12 character is part of a Unicode block named Symbols for Legacy Computing. (Emphasis on "legacy" mine. 😬)

This character seems to not be supported by a lot of fonts and many terminals, as well as other applications (one might even see a "missing character" square while browsing this PR and links I provided).

I have for example confirmed that it would not work with the following:

Upper Half Block is slightly thicker than Block Sextant-12, but it also appears to be more widely supported across terminals and fonts.

I think a default configuration that will work in most environments would provide a better user experience, and would likely prevent many developers from spending hours diving into the unknown territories of font rendering, Unicode blocks, NeoVim LUA configuration, etc.

How

A simple script that replaces all instances of the Block Sextant-12 character in the repository:

 ag -l \U0001fb02 | xargs -n1 sed -i '' -e "s/\U0001fb02/β–€/"

Anything else?

Alternative

An alternative to Upper Half Block would be the thinner β–” (Upper One Eighth Block (U+2594)).

Matching "lower" and "upper"

If it is important for the width of the fat headline top and bottom padding be identical, then we could also change fat_headline_upper_string to use a character of the same width. Respectively, in order of appearance above:

Screenshots

Using the evening colorscheme, iTerm2 with MonaspiceNe Nerd Font.

What Screenshot
Before image
This PR image
Alt:
upper one eighth
image
Alt:
matching half blocks
image
Alt:
matching 1/8 blocks
image
davidstosik commented 2 months ago

For reference:

davidstosik commented 2 months ago

And a proof that most fonts don't support Block Sextant-12: copy the first paragraph in my PR description above, paste it in https://www.programmingfonts.org/#firacode, then scroll through fonts.

image

Or even just do it in any text editor, like for example macOS' TextEdit:

image

(You can check out Google Fonts too.)

davidstosik commented 2 months ago

TIL that macOS' Font Book can search fonts by supported characters.

πŸ¬‚ (Block Sextant-12) β–€ (Upper Half Block)
image image
davidstosik commented 2 months ago

Here's a final comment: Nerd Fonts don't seem to be designed to add a glyph for the block sextant-12 character code, so it'll boil down to whether the original, unpatched font supported it to begin with.

image

davidstosik commented 1 month ago

@lukas-reineke Pinging you in case you've missed this. πŸ™πŸ»

lukas-reineke commented 1 month ago

Sorry for the delay. I'm not against changing this, but I think top and bottom should match, so your matching half blocks example is probably best.

davidstosik commented 11 hours ago

@lukas-reineke Done. 999ad2e04cc00b81701bcdbce4c7b887c0021888