phronmophobic / membrane.term

A terminal emulator in pure clojure
Eclipse Public License 1.0
53 stars 1 forks source link

WIP: Consider scaling oversized glyphs #19

Open lread opened 2 years ago

lread commented 2 years ago

Extracted from #2

Problem

Although we do now show Unicode characters #18, some character glyphs do not display ideally for command line customizations like powerlevel10k.

Here's an example from of a powerlevel10k using their recommended MesloLGS NF font (NF = Nerd Font, there's a bunch of them that are typically popular monospace fonts with special glyphs added). I chose a larger font size to allow us to see more detail of any oddities.

clojure -M:membrane.term --font-family 'MesloLGS NF' --font-size 20

<Insert screenshot here, after PR for #2 merged>

Out of Scope

Emoji glyphs require special handling and are covered in #20.

Analysis

Sample Glyphs

Some fonts, for whatever reason, contain glyphs that exceed the font's advanced width, line height, or both.

Let's use the lovely opentype.js glyph inspector to showcase some examples from the MesloLGS NF font.

The following glyph is sometimes used in powerlevel10k prompts: image Notice how it crosses above the ascender and below the descender lines.

The Apple glyph is also used in the powerlevel10k prompt: image It's height is fine, but its width exceeds the font's advance-width.

Some glyphs exceed both line-height and advance-width: image

Some glyphs don't exceed a height or width but extend across the font's cell boundaries. Line drawing glyphs are good examples of these: image

What do other terminals do?

Terminals handle these glyphs with varying degrees of success.

Strategy

I've experimented with scaling large glyphs to our monospace cell dimensions while preserving the glyph's aspect ratio. This looked promising but I discovered it messed with line drawing glyphs enough to make them not line up.

Next Steps