1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-30 06:03:39 +03:00
Commit Graph

294 Commits

Author SHA1 Message Date
Wez Furlong
8582165ffc
add display_pixel_geometry config option for subpixel geometry
refs: #3422
2023-04-01 11:05:09 -07:00
Wez Furlong
1531dd8471
update tests for updated JetBrainsMono 2023-03-25 07:21:36 -07:00
Wez Furlong
843b9e8fc4
update bundled JetBrainsMono to 2.304 2023-03-25 07:18:29 -07:00
Jalil David Salamé Messina
d541e2e13d fix(clippy): Remove closures where possible
- Removes closures and function calls for types that implement default:

  ```rust
  // Change
  let _my_str = get_str().unwrap_or(String::new);
  // To
  let _my_str = get_str().unwrap_or_default();
  ```

- Uses the `.cloned()/.copied()` methods where possible
- Use function pointer instead of simple closure

May improve performace, as closures generate more code, and this might
unlock some inlining opportunities.
2023-03-19 08:41:38 -07:00
Jalil David Salamé Messina
191aacc7d7 fix(clippy): Use faster methods on Iterators
- Use `find` instead of `position(..).next()`
- Use `any` instead of `position(..).next().is_some()/.is_none()`
- Use `first/next` instead of `get(0)/nth(0)`
- Prefer `for` loops over `while let` loops on iterators

May improve performance.
2023-03-19 07:29:23 -07:00
Jalil David Salamé Messina
cb9dc3a800 fix(clippy): Remove unnecessary clone/to_string calls 2023-03-16 07:40:12 -07:00
Pavel Roskin
a7cc87f30f gdi.rs: Avoid non-idiomatic iterations over Option, they cause warnings 2023-03-05 13:16:49 -08:00
Wez Furlong
4ec428ff75
config: allow using bright but not bold text when brightening text
In https://github.com/wez/wezterm/issues/2932 the user desired to have
brightened text without the boldness, as they were accustomed to that
behavior in a couple of other terminal emulators.

This commit changes the `bold_brightens_ansi_colors` from a simple
boolean to a tristate that allows for not changing the brightness,
changing the brightness, and changing the brightness while adjusting
the boldness down to normal levels.

boolean values are accepted for backwards compatibility.
2023-01-09 15:19:17 -07:00
Wez Furlong
ab8a4f129c
command palette: first pass
This commit introduces a rough first pass at a command palette modal.
It is an adaptation of the emoji character selector and needs
refinement.

Importantly, the default pane selector key assignment now calls
into this new command palette instead.

refs: https://github.com/wez/wezterm/issues/1485
2022-12-22 20:24:57 -07:00
Wez Furlong
9923ae20b5
env_logger -> 0.10
closes: https://github.com/wez/wezterm/pull/2803
2022-11-27 21:37:25 -07:00
Wez Furlong
68c754b1f3
fonts: improve error message slightly
refs: https://github.com/wez/wezterm/issues/2772
2022-11-22 15:46:21 -07:00
Wez Furlong
0516b61f62
lfucache: improve LFU algorithm and structure
Do it "more properly": use intrusive list linkage to manage three
indices:

* hash lookup
* recency
* frequency

eviction is frequency based, but in order to avoid things that were
super hot in the past and that are no longer hot clogging up the cache,
eviction will incrementally age out least recently used entries that
haven't been active in the span of some number of get/put operations.

Aging scales down the frequency value to reduce its strength, so an aged
item isn't necessarily immediately a candidate for removal, it just
makes it more likely to be picked up by the frequency based removal as
it goes unused for an extended period.
2022-11-14 10:00:49 -07:00
Wez Furlong
b1faba9d8a deps: upgrade finl_unicode to 1.2 2022-10-23 12:07:00 -07:00
Wez Furlong
7cc91696e9 fonts: fix shaping for U+28 U+FF9F
This sequence forms a grapheme with cell_width=2, but harfbuzz returns
it as two distinct clusters, causing our prior logic to shape them
independently from different fonts, but our logic for assessing width
would resolve them both to the same cell and double-count their width,
leading to issues with the rendered result.

This commit revises our clustering logic to add a pass that compares
the harfbuzz cluster positions with the cell-based positions from
the presentation_width that may have been provided.  We use the starting
cell positions from that to order and de-dup so that clusters aren't
split in the wrong place.

refs: https://github.com/wez/wezterm/issues/2572
2022-10-15 08:42:07 -07:00
Wez Furlong
85db555b37 deps: update finl_unicode 2022-09-16 07:47:33 -07:00
Wez Furlong
10cd78a81a fonts: remove last resort font
I was going to upgrade to the unicode 15 font, but in testing this I
decided that the logic is slightly complex and the glyphs are often
difficult to see at most terminal font sizes, which generates questions
from users, so just fall back to notdef.
2022-09-15 08:23:58 -07:00
Wez Furlong
72674f5d28 perf: reduce number of calls to Line::get_cell
The clustered line storage impl of get_cell() is O(column-index)
as cells have to be iterated in order.

The render pass was calling it 3 times to resolve information
about the cursor; reduce that to just once.

It was also calling it once per cell to determine whether the
cell needed to be replaced with a custom glyph if custom block
glyphs were enabled, making it accidentally quadratic!

While it wasn't especially expensive, it did show up in profiling,
so this commit removes that call: we can cache the block glyph
key in the shaper info which is a better place for it anyway,
so that's what we do.

Similarly, there was some extraneous work to call get_cell
when computing some shaper info; remove that too!

That one might be slightly contentious: the is-followed-by-space
logic used to check the successor cell by index to see if it
was a space, but now looks at the successor shaped glyph to see
if it was a space. That might actually be a better choice, but
it may have some ripple effects.
2022-09-10 09:11:22 -07:00
Wez Furlong
96c4e7e9b9 Switch to finl_unicode for grapheme clustering
According to its benchmarks, it's almost 2x faster than
unicode_segmentation.  It doesn't appear to make a visible
difference to `time cat bigfile`, but I'll take anything
that gives more headroom for such little effort of switching.
2022-09-10 07:15:49 -07:00
Wez Furlong
ad35b9dc21 Add compile time features to allow building without vendored fonts
closes: #2305
2022-09-09 08:53:39 -07:00
Wez Furlong
86c9d78148 shaper: restart presentation=None from font_idx=0
When falling back to presentation-ambivalent font lookup, restart
our shaper run from font_idx=0 rather than the current font index.

For:

```
wezterm  ls-fonts --text "$(printf \\U1faf0)"
```

the current font index was the last resort font so we'd never
search over anything useful in the second pass.

Looking back at 4fc8dfb374, I can't
see a good reason for starting at the later offset.
2022-09-05 17:10:04 -07:00
Jan Katins
29f5d066b8 Fix typo in harfbuzz.rs 2022-09-05 06:01:59 -07:00
Wez Furlong
68380188e8 fix hangul NFC shaping
We were getting data like this back from harfbuzz:

shaped font_idx=0 "파인더에서 만든 폴더" as: [.notdef=0+448|.notdef=0+448|.notdef=6+448|.notde=6+448|.notdef=6+448|.notdef=15+448|.notdef=15+448|.notdef=21+448|.notdef=21+448|.notdef=27+448|.notdef=27+448|space=33+448|.notdef=34+448|.notdef=34+448|.notdef=34+448|.notdef=43+448|.notdef=43+448|.notdef=43+448|space=52+448|.notdef=53+448|.notdef=53+448|.notdef=53+448|.notdef=62+448|.notdef=62+448]

which had a series of discontiguous and repeated runs for the same
cluster/region, but due to a logic error, we weren't coalescing them
together and were passing somewhat nonsensical ranges to the
next font for shaping.

This commit "simply" ensures that we code the checks for codepoint==0
(the `.nodef` seen above) and the results are at least correct
for this particular case.

refs: https://github.com/wez/wezterm/issues/2482
2022-09-04 21:24:30 -07:00
Wez Furlong
c38816fc6e fontconfig: allow proportional fallbacks for codepoints
refs: https://github.com/wez/wezterm/discussions/2468#discussioncomment-3528085
2022-09-04 07:05:58 -07:00
liushuyu
9a6cee2b59 font: fix the function signature for log_buffer_message ...
... this will fix the build on non-x86 architectures
2022-09-04 06:41:25 -07:00
Wez Furlong
c4d19afa75 adventures in shaping
This commit is a result of debugging a problem with a particular font
where a VS2 variation of a glyph produced incorrect shaping.

Further investigation showed that this was specific to using freetype
font functions and that switching to opentype functions produces the
correct shaping information in that case.

Further-further investigation showed that this difference in behavior
was really due to the font file being out of spec and freetype returning
unexpected data as a result.

This commit allows switching to using harfbuzz's own opentype font+face
(rather than freetype) and/or switching the freetype-based font to using
opentype font functions.  These two options don't yield equivalent
results in the wezterm integration: a couple of our shaping tests
fail due to the x-advances not being the same. Those can be drastically
different in some cases (eg: I seem to get 0 for certain bitmap strikes,
and for Roboto the value is off by a factor of about 1.5).

This is incomplete and not something I want to turn on by default at
the moment, but I don't want to lose this work, hence this commit.

refs: https://github.com/wez/wezterm/issues/2475
refs: https://github.com/harfbuzz/harfbuzz/issues/3806
2022-09-03 08:34:19 -07:00
Wez Furlong
2af5a05d19 harfbuzz: allow creating an OT Face + Font
We've been using hb with freetype faces. This gives us the option
of using harfbuzz's own opentype based face and function set.

It doesn't change any behavior: this is just newly available code.

refs: https://github.com/wez/wezterm/issues/2475
2022-09-03 08:25:43 -07:00
Wez Furlong
ed731a0d8d Add CharSelect modal for emoji/nerdfont/unicode input
CTRL-SHIFT-U is a new default key assignment for this new modal.
It opens up a fuzzy searchable browser that defaults to showing
emoji/emoticons.  The category can by cycled through the suggested
emoji categories using CTRL-r.  Unlike the system emoji palette,
wezterm includes a category for nerdfont symbols, and another
that is a list of all unicode codepoint names, so you should be
able to browse for pretty much any codepoint you can think of.

The modal also allows fuzzy searching based on:

* The official unicode name
* The github shortcode
* codepoint value in hex

so if you know the codepoint value but not the name, you can
still find a way to input what you're looking for.

Pressing Enter will copy the selected item to the clipboard
send it to the active pane, and cancel the modal. You can therefore
repeat the insert by simply pasting.

I plan to add frecency to this in a later commit: that way the
frequently/recently used selections will show in a category of
their own and make it easier to re-input them.

refs: https://github.com/wez/wezterm/issues/2163
2022-08-31 18:15:28 -07:00
Wez Furlong
53aef1ac6e fix build; last commit passed cargo check but not cargo build!? 2022-07-14 09:49:07 -07:00
Wez Furlong
df6a6667a4 fonts: allow glyph not found warnings to show after config reload
refs: #2188
2022-07-14 09:07:15 -07:00
Wez Furlong
49e3fd4c9e fonts: limit missing glyph notification to once per hour
refs: https://github.com/wez/wezterm/issues/2188
2022-07-14 07:26:04 -07:00
Wez Furlong
c97e8e564e fonts: allow setting assume_emoji_presentation per font
This allows the user to specify what happens if they have an emoji
font that doesn't match our built-in heuristics.
2022-07-08 21:14:16 -07:00
Wez Furlong
b98fb8410b fonts: assume emoji presentation for fonts with "moji" in their name
previously, we'd match "emoji", but that wouldn't match openmoji.
2022-07-08 21:01:35 -07:00
Wez Furlong
21e6fcedd9 fonts: add negative cache into LoadedFont
Continuing from 427e4a0a84, we
can't just omit the negative cache as that leads to problems
like <https://github.com/wez/wezterm/issues/2165>, so this
commit restores it but moves it into LoadedFont, so that we
should stop looking for a given styled font after the first
attempt.

refs: https://github.com/wez/wezterm/issues/2165
2022-06-23 06:36:03 -07:00
Wez Furlong
427e4a0a84 fonts: remove no_glyphs cache from FontConfigInner
This avoids a confusing situation where we'd not bother to resolve
a font for a given codepoint for say bold text if we had previously
resolved it for normal text.

This hashset would be more useful if we maintained a mapping of
codepoint to font at that layer, but we don't.

The simplest thing to do for this is to allow the search to continue
and succeed.

refs: https://github.com/wez/wezterm/issues/2158
refs: https://github.com/wez/wezterm/issues/1913
2022-06-22 06:17:16 -07:00
Wez Furlong
50ead11ccb fonts: assume emoji presentation based on name
wezterm makes two passes over fonts when resolving emoji, based on
the presentation of the text.  If the text has a defined presentation
via a variation selector, then the first pass will only consider
fonts that match that presentation.

If no fonts match, a second pass is made to locate any font with
the appropriate glyphs.

Previously, the font was assumed to have emoji presentation if it
had color glyphs.  That meant that if you chose a monochrome emoji
font then it would be skipped for regular emoji presentation and
we'd end up matching against the default fallback for the Noto Color
Emoji font.

This commit changes the behavior to consider any explicitly listed
font with "Emoji" in the name as having emoji presentation.

This is also an imperfect heuristic, but perhaps it is good enough?

refs: #1959
2022-06-19 06:54:22 -07:00
Wez Furlong
af815a2e1b fonts: add freetype_pcf_long_family_names option
Freetype has a compile-time feature that, when enabled, rewrites the
font names of PCF fonts to include the foundry and wide status of the
font in order to disambiguate the various versions of fonts all named
"Fixed".

That option is enabled by default in some linux distributions but not
all; it's not enabled in Fedora, for example.

When that feature is enabled it causes problems for the Terminus font as
the PCF version of the fonts are no longer resolvable via the simple
"Terminus" name but via "xos4 Terminus" instead.

wezterm builds its own version of freetype (for consistency and cross
platform support reasons), and is unaware of the choice used by the
distro.

The result of that is that fontconfig may see PCF fonts as having
different font names than how wezterm sees them.

A concrete problem is on such a system, when requesting "xos4 Terminus",
fontconfig will present a match with that name, but when wezterm opens
the font and sees that it has name "Terminus" (because of the difference
in this feature in the freetype libraries in use), wezterm will reject
that match.

This commit enables that option in the freetype library and adds a
wezterm config level option (freetype_pcf_long_family_names) that can be
used to control the underlying pcf font driver configuration.

The upshot of this is that this commit doesn't change any default
behavior, but allows users of those systems to set
`freetype_pcf_long_family_names = true` to turn that behavior on.

My personal opinion on this is that users probably shouldn't use this if
they can avoid it (and PCF fonts in general), and instead install the
OTB version of the Terminus font, which doesn't have this legacy baggage
associated with it!

refs: https://github.com/wez/wezterm/issues/2100
2022-06-09 20:09:47 -07:00
Wez Furlong
e7258e0e03 fonts: fix automatic bold synthesis
For fonts like Lucida Console on Windows which do not have a bold
variant, we were not synthesizing bold.

The reason was that the config-level "make bold" logic works by adding
200 to the weight which takes normal -> demibold, but the bold synthesis
logic is enabled only for bold and higher.

This commit changes the threshold for synthesis to demibold or higher.

refs: https://github.com/wez/wezterm/issues/2074
2022-06-05 06:35:31 -07:00
Wez Furlong
e298bb7a11 shaping: fix repeated glyphs for Unicode NFD text
harfbuzz can return incomplete overlapping runs when it processes
text in unicode NFD.  Add another check for the case where we've
accumulated the bytes in the range 0-12 and then harfbuzz returns
another range of 6-12.  We coalesce the two together so that we can
pass the full unresolved sequence to the next fallback pass.

refs: https://github.com/wez/wezterm/issues/2032
2022-05-25 06:51:31 -07:00
Wez Furlong
5bf736bd21 add PaneSelect key assignment
This is still a bit of a WIP, but this commit:

* Introduces a new "Modal" concept to the GUI layer. The intent is
  that modal intercepts key and mouse events while active, and renders
  over the top of the rest of the normal display.
  I think there might be a couple of cases where key events skirt
  through this, but this is good enough as a first step.
  Also, the render is forced into layer 1 which has some funny side
  effects: if the modal choses to render transparent, it will poke
  a hole in the window because all the rendering happens together:
  there aren't distinct layer compositing passes.

* Add a new PaneSelect action that is implemented as a modal.
  It uses quickselect style alphabet -> pane label generation and
  renders the labels over ~the middle of each pane using an
  enlarged version of the window frame font.  Typing the label
  will activate that pane.  Escape will cancel the modal.

More styling and docs will follow in a later commit.

refs: #1975
2022-05-23 08:16:52 -07:00
Wez Furlong
0e0bac2576 deps: prune some unused deps 2022-05-19 06:48:09 -07:00
Wez Furlong
e0785311c1 deps: ordered-float
closes: https://github.com/wez/wezterm/pull/1946
2022-05-01 21:43:22 -07:00
Wez Furlong
c1d7ca96db fonts: include glyph names in ls-fonts --text output 2022-04-12 08:34:32 -07:00
Wez Furlong
b35e3b2aad deps: remove pretty_env_loggger
Go directly to the underlying env_logger crate, as pretty_env_logger
hasn't been updated in some time, and I'd like to be able to redirect
the log output to a file more directly, and that feature is in a newer
version of the env logger than pretty_env_logger was pulling in.
2022-04-07 08:24:07 -07:00
Wez Furlong
1b0f5cf256 fonts: treat "charcell" spacing as monospace
Some versions of fontconfig classify some fonts as having charcell
spacing.  We need to consider those as monospace as well.

refs: https://github.com/wez/wezterm/issues/1820
2022-04-06 08:11:34 -07:00
Wez Furlong
11a19a589a fonts: remember bdfs with multiple sizes found in font_dirs
We were using a simple hashmap of name -> parsed file, but for
something like Terminus where there are ~10 files per weight
but for different pixel sizes, we'd end up forgetting files
beyond the first.

This commit tracks the full list in the font db.

related to #1820 in the sense that I needed this to confirm that
we do handle BDFs, but it is not the issue reported there because
that was sourcing fonts via fontconfig on linux.
2022-04-05 20:46:28 -07:00
Wez Furlong
14323a08d1 fonts: adjust descender for scaled fallback fonts
The gist of the issue is that when setting eg: scale=1.2 to draw
a larger CJK glyph, it is drawn at the same descender level, which
makes it more likely to leave the top of the cell.

This commit adjusts the y position by the difference between the
original and the scaled descender so that is less likely to cause
problems.

refs: https://github.com/wez/wezterm/issues/1803
2022-04-03 09:39:48 -07:00
Wez Furlong
a2004a2a7d fonts: workaround broken symbol fonts with 0 advances
The broot icon font has glyphs with horizontal advance set to 0.  That
would cause us to consider the glyph to be zero width, so handle that as
a special case.  Note that it is legit for certain cells to end up with
a zero advance/width during shaping if they represent combining
characters: this is more common in Arabic scripts.

refs: https://github.com/wez/wezterm/issues/1787
2022-03-28 18:05:13 -07:00
Wez Furlong
b65cf803d7 fonts: show aliases in ls-fonts --list-system output 2022-03-27 20:21:09 -07:00
Wez Furlong
6dd3d55b0b fonts: show aliases in ls-fonts output 2022-03-27 19:56:11 -07:00
Wez Furlong
3e91f23452 fix build/tests 2022-03-26 17:00:03 -07:00