Commit graph

594 commits

Author SHA1 Message Date
dtzxporter
cc75bb66b4 Adds a separate wrapping option to allow word to glyph fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
b7f150615d Add a test for word wrapping fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
e83f55bfeb Re-generate word tests so they don't wrap because that's not what they are testing. 2024-02-02 10:40:30 -07:00
dtzxporter
07a65cf81f Fallback to glyph wrapping when a word can't fit on a line by itself. 2024-02-02 10:40:30 -07:00
dtzxporter
d036f50b60 Fix benchmark issue. 2024-02-02 10:40:30 -07:00
Jeremy Soller
1b025ae56e
Update swash to 0.1.12 2024-02-01 12:43:08 -07:00
Jeremy Soller
4a66d19006
Update swash 2024-02-01 11:35:25 -07:00
Jeremy Soller
9bbf9e5c23
Fix no_std tests 2024-02-01 11:35:18 -07:00
Jeremy Soller
b2fb02c7ad Require modit 0.1.4 2024-01-31 14:03:19 -07:00
Jeremy Soller
db2f3b94ef Fix missing line separators in delete changes 2024-01-31 13:53:36 -07:00
Mohammad AlSaleh
0cea55630c Use weight absolute difference in monospace fallback matching
When matching on weights smaller than normal, "equal or smaller"
 weight restriction may cause monospace fallback to fail, depending
 on font support at such weights for the text to be shaped.

 So remove that restriction, and calculate weight differences instead
 of offsets.

 In case of no exact weight match, and with all other factors being
 equal, smaller weights will be picked before bigger ones. So, this
 should generally not cause any behavioral changes when matching on
 normal weight or bigger.

 Should fix pop-os/cosmic-term#104.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-31 06:32:37 -07:00
Mohammad AlSaleh
1a18296a67 Update to swash 0.1.9
Fixes #220.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-30 14:06:35 -07:00
Mohammad AlSaleh
e0ae465f91 Only use relevant info from Attrs as a key in font_matches_cache
`Attrs` contains info like color and metadata which are not relevant
 to font matching.

 So, add a new struct `FontMatchAttrs` which only contains the relevant
 info, and use it as a key in `FontSystem`'s `font_matches_cache`.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-23 23:05:52 -07:00
Mohammad AlSaleh
235ec02a20 Add a size limit to font_matches_cache and clear it when it's reached
In `FontSystem`, `font_matches_cache` is an ever growing cache.

 It can also be a fast growing one in stress tests like running this
 in `cosmic-term`:

     mpv -speed 3 -vo tct <some_video>

 So this commit adds a size limit to that cache, and clears the cache
 when that limit is reached, which shouldn't be a common occurrence in
 normal usage.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-23 23:05:52 -07:00
Mohammad AlSaleh
db1530c4ec Use supported codepoints instead of scripts in Monospace fallback
This should/could improve fallback order.

 This could also probably be utilized for non-Monospace fallback too.
 But I didn't want to touch that code to avoid accidentally breaking
 anything.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-19 09:37:11 -07:00
Mohammad AlSaleh
845a66ceff Multiply by a glyph-to-default rounded factor when resizing fonts
When matching to a default monospace width, big fonts like those
 containing symbols and emojis got too small from font resizing.

 Adding a glyph-to-default rounded factor to the calculation should fix
 that issue without losing monospatiality.

 Fixes pop-os/cosmic-term#69.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-19 09:35:46 -07:00
Jeremy Soller
6aadfaddac
Fix subtraction overflow when comparing weights 2024-01-18 06:58:47 -07:00
Jeremy Soller
8457e68d98 Fix tests 2024-01-17 13:31:03 -07:00
Jeremy Soller
a11f68f13d Format 2024-01-17 13:31:03 -07:00
Mohammad AlSaleh
329941c4a6 Try harder to succeed at fall-backing to a Monospace font
A combination of some ideas:

 * Try all Monospace fonts before giving up.
 * Relax exact weight restriction on font matching when trying Monospace
   fall-back. Try smaller weights if needed.
 * Make the fall-back try order weight-offset aware, AND script-aware.
 * And finally, add the option to adjust the font size of glyphs using
   fall-back Monospace fonts, so the width of them matches the default
   font width.

   For my use-case, the current fall-back attempt always fails with
   Arabic script. And none of the Arabic-supporting Monospace fonts in
   my system also support medium weight. So, if my default font is set
   to medium weight, script-aware fall-back alone will still not work.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-17 13:31:03 -07:00
Jeremy Soller
054b7da828 Editor::insert_at: ensure there are enough lines in the buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
40e503737b Handle multiple BiDi paragraphs in ShapeLine gracefully 2024-01-17 13:31:03 -07:00
Jeremy Soller
5f4bc87ccf Remove patch to load Redox system fonts, as fontdb does it now 2024-01-17 13:31:03 -07:00
Jeremy Soller
bd5f2f95e8 Add capability to synthesize italic 2024-01-17 13:31:03 -07:00
Jeremy Soller
46d60a3723 Implement Clone for Buffer and use Arc::make_mut 2024-01-17 13:31:03 -07:00
Jeremy Soller
0a11fb1045 Make Editor::buffer_ref accessible, rename lifetimes 2024-01-17 13:31:03 -07:00
Jeremy Soller
cbbf6f0d8f Allow Editor to use reference or Arc of Buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
ae030e9885 Move color and x_opt out of Cursor 2024-01-17 13:31:03 -07:00
Jeremy Soller
04d53ac5f4 Add Scroll::new 2024-01-17 13:31:03 -07:00
Jeremy Soller
d0b4b4635e Refactor of scroll and shaping
- Scroll is identified by line index and layout index, instead of just
  layout index
- Shaping has the option to prune, where caches outside of the scroll
  view are cleared
- Syntax editor no longer requires layout of all lines, only of lines
  inside scroll
- BufferLine has a metadata field that can be used by other abstractions
  to know when text was changed
2024-01-17 13:31:03 -07:00
Jeremy Soller
e7261fc06e Editor: remove unused cursor_x_opt 2024-01-17 13:31:03 -07:00
Jeremy Soller
b877f873df BufferLine: remove wrap from struct, as wrap is passed to layout 2024-01-17 13:31:03 -07:00
Jeremy Soller
816ea4fae7 BufferLine: use layout_in_buffer to implement layout 2024-01-17 13:31:03 -07:00
Jeremy Soller
80d120dfa5 Ensure that all shaping and layout uses scratch buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
5d1aa67804 Improve reliability of layout_cursor 2024-01-17 13:31:03 -07:00
Jeremy Soller
018a2e9d2a Move cursor motions to new Motion enum, move handling to Buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
6528e9f804 multiview example 2024-01-17 13:31:03 -07:00
Jeremy Soller
c247e0527c Only apply attrs to range in syntect editor if it does not match default 2024-01-17 13:31:03 -07:00
Jeremy Soller
19b4d8336e Use crate::HashMap in SwashCache 2023-12-19 17:02:28 -07:00
Jeremy Soller
430b3abc9f Fix no_std build 2023-12-19 17:02:15 -07:00
David Stern
73acfb0962 Cache rustybuzz shape plans. 2023-12-18 18:19:27 -05:00
Jeremy Soller
94e6cdefda
Add select by word and double/triple click actions 2023-12-12 10:29:14 -07:00
Jeremy Soller
6566350276
ViEditor::finish_change will store change to history 2023-12-12 09:52:22 -07:00
Jeremy Soller
3187e916ab
ViEditor: cleanup logging 2023-12-08 12:03:55 -07:00
Jeremy Soller
b7bdd62eb3
ViEditor: update modit and improve put implementation 2023-12-05 10:05:26 -07:00
Jeremy Soller
de6f2c7fbe
Editor: make delete_range and insert_at methods public 2023-12-05 10:04:50 -07:00
Jeremy Soller
afc5b525f1
Buffer: fix max scroll going one line beyond end 2023-11-30 14:51:22 -07:00
Jeremy Soller
1cf36f8a5d
Editor: set selection to none when deleted 2023-11-30 14:42:39 -07:00
Jeremy Soller
9278e7d0c4
ViEditor: Implement put/yank registers 2023-11-30 13:42:52 -07:00
Jeremy Soller
04c96f39c5
Allow Clone of layout structs 2023-11-30 13:00:02 -07:00