Commit graph

158 commits

Author SHA1 Message Date
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
46d60a3723 Implement Clone for Buffer and use Arc::make_mut 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
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
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
afc5b525f1
Buffer: fix max scroll going one line beyond end 2023-11-30 14:51:22 -07:00
Jeremy Soller
19ae07bd3b
Fix some clippy lints 2023-11-15 09:21:13 -07:00
Jeremy Soller
241c4ca357
Buffer::set_rich_text: Only add attrs if they don't match the defaults 2023-11-02 10:24:28 -06:00
Jeremy Soller
d53932bd7c Add function to set metrics and size simultaneously 2023-10-31 20:40:46 -06:00
Jeremy Soller
ad10e7373b
Require default Attrs to be specified in set_rich_text 2023-10-27 13:08:27 -06:00
Jeremy Soller
1eab951e27
Merge pull request #149 from tigregalis/set-rich-text
Add `Buffer::set_rich_text` method
2023-09-11 10:58:39 -06:00
John Nunley
64e469718b Use a scratch buffer to reduce allocations
This commit adds a new ShapeBuffer type, which contains some buffers tha
are commonly re-created during the shaping process. New APIs are added
that take this structure, and old APIs are turned into wrappers around
the new API.

The goal is to reduce the number of per-layout allocations that happen
in a typical layout call.
2023-08-16 14:09:54 -07:00
John Nunley
440d24ffa0
Add more Debug implementations
I generally like to implement Debug on these kind of types.
2023-07-07 21:44:21 -07:00
tigregalis
fb8bb60972 update comments 2023-06-30 20:40:12 +08:00
tigregalis
7db01ebf3a use core::mem::{replace, take} not std:: 2023-06-30 20:31:29 +08:00
tigregalis
48f6aefb80 remove unnecessary into_iter in doctests 2023-06-27 21:59:58 +08:00
tigregalis
4a05c9c1cf add BorrowedWithFontSystem<_>::set_rich_text 2023-06-27 21:53:27 +08:00
tigregalis
f092bdde73 add Buffer::set_rich_text method 2023-06-27 21:53:05 +08:00
Héctor Ramón Jiménez
eb09cf0259
Introduce PhysicalGlyph for offsetting and scaling 2023-06-20 06:07:24 +02:00
Jeremy Soller
e8b10fd675
Base selection on the top of the line 2023-06-16 07:03:43 -06:00
Jeremy Soller
10bf182c5d
Fix line wrap and scroll 2023-06-16 06:51:11 -06:00
Héctor Ramón Jiménez
431163dc35
Consider the centering_offset for visibility in LayoutRunIter 2023-06-16 02:25:45 +02:00
Héctor Ramón Jiménez
c2bef6a345
Align glyphs in a LayoutRun to baseline 2023-06-16 02:15:44 +02:00
Jeremy Soller
b5f45f81f6
Merge pull request #124 from tigregalis/iter-bidi-para
Replace use of `str::Lines` with `unicode-bidi`-based iterator
2023-06-09 07:03:07 -06:00
tigregalis
6e336ad1cd replace use of str::lines with BidiParagraphs 2023-06-09 11:26:07 +08:00
tigregalis
2ed9c34796 use Buffer::new_empty in Buffer::new 2023-06-09 11:11:42 +08:00
tigregalis
cfb6760fa2 introduce Buffer::new_empty 2023-06-09 11:09:16 +08:00
Dima Rets
0eb08d218c allow setting cursor color 2023-06-08 20:04:56 +01:00
Héctor Ramón Jiménez
87d75531b7
Allow Shaping::Basic only if swash feature is enabled 2023-04-21 20:47:02 +02:00
Héctor Ramón Jiménez
0f055c0a13
Replace skip_shaping boolean with Shaping enum 2023-04-21 20:24:44 +02:00
Héctor Ramón Jiménez
ad111a1df1
Add skip_shaping flag to avoid expensive shaping when not needed 2023-04-19 00:24:43 +02:00
13r0ck
e790e8e718 use checked_sub to fix panic on window resize.
bug link: https://github.com/iced-rs/iced/issues/1773
2023-03-30 12:40:14 -06:00
Edgar Geier
3331f41d7a
Improve documentation 2023-03-12 10:39:57 +01:00
Edgar Geier
384c5c1fdc
Remove Mutex from FontSystem 2023-03-12 10:39:56 +01:00
Edgar Geier
46e9ef0246
Make BorrowedWithFontSystem borrow FontSystem mutably 2023-03-12 10:39:56 +01:00
Edgar Geier
057b5b6fa9
Extract borrow of FontSystem from Buffer 2023-03-12 10:39:54 +01:00
Jeremy Soller
bd27ca8ad8
Merge pull request #88 from geieredgar/clippy-fixes
Fix clippy warnings
2023-03-02 14:53:08 -07:00
Edgar Geier
6c501c6640
Fix clippy warnings 2023-03-01 22:58:41 +01:00
Edgar Geier
4e93853765
Remove lifetime from SwashCache 2023-03-01 22:41:59 +01:00
Héctor Ramón Jiménez
22b8a534fa
Avoid division by zero in LayoutRunIter 2023-02-28 20:40:31 +01:00
Héctor Ramón Jiménez
4320ae6329
Use f32 instead of i32 for lengths
This allows users to use logical coordinates instead of physical ones.
2023-02-28 03:39:31 +01:00
grovesNL
6a656e9a0f Exclude line y offset in height comparison
We start `line_y` at an initial offset, so we need to account for this
later when checking if the total height is beyond the buffer height.
2023-02-24 11:27:45 -03:30
notgull
86d7ba959e Forgot about set_metrics 2023-02-18 18:00:57 -08:00
notgull
c4ee3ba64e Early panic on divide by zero 2023-02-18 17:59:30 -08:00
grovesNL
a3e035881b Fill out some more docs 2023-01-29 22:29:17 -03:30
grovesNL
be9b4cb36c Avoid negative width/height in Buffer::set_size
Negative width/height may cause unexpected effects on the layout, which
we can avoid by clamping.
2023-01-26 22:16:23 -03:30
Audrey Dutcher
a5903bb3bf Don't do profile timing on wasm32 2023-01-23 14:18:44 -07:00