Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 49 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ all-features = true
maintenance = { status = "actively-developed" }

[features]
default = ["wgpu", "tiny-skia", "crisp", "hinting", "web-colors", "thread-pool", "linux-theme-detection", "x11", "wayland"]
default = [
"wgpu",
"tiny-skia",
"crisp",
"hinting",
"web-colors",
"thread-pool",
"linux-theme-detection",
"x11",
"wayland",
]
# Enables the `wgpu` GPU-accelerated renderer with all its default features (Vulkan, Metal, DX12, OpenGL, and WebGPU)
wgpu = ["wgpu-bare", "iced_renderer/wgpu"]
# Enables the `wgpu` GPU-accelerated renderer with the minimum required features (no backends!)
Expand Down Expand Up @@ -136,24 +146,24 @@ strip = "debuginfo"

[workspace]
members = [
"beacon",
"core",
"debug",
"devtools",
"futures",
"graphics",
"highlighter",
"program",
"renderer",
"runtime",
"selector",
"test",
"tester",
"tiny_skia",
"wgpu",
"widget",
"winit",
"examples/*",
"beacon",
"core",
"debug",
"devtools",
"futures",
"graphics",
"highlighter",
"program",
"renderer",
"runtime",
"selector",
"test",
"tester",
"tiny_skia",
"wgpu",
"widget",
"winit",
"examples/*",
]

[workspace.package]
Expand Down Expand Up @@ -193,9 +203,12 @@ bitflags = "2.0"
bytemuck = { version = "1.0", features = ["derive"] }
bytes = "1.6"
cargo-hot = { version = "0.1", package = "cargo-hot-protocol" }
cosmic-text = "0.18"
cryoglyph = { git = "https://github.com/iced-rs/cryoglyph.git", rev = "1d68895e9c4c9b73739f826e81c2e3012c155cce" }
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
cosmic-text = { git = "https://github.com/pop-os/cosmic-text.git", rev = "9a2ab09f06905e91f41d64ac6eee887726e7fd76" }
cryoglyph = { git = "https://github.com/hojjatabdollahi/cryoglyph.git", rev = "ccd3f6ea81fc6cf83e0b2cf34bb8cbb1779f6cd3" }
futures = { version = "0.3", default-features = false, features = [
"std",
"async-await",
] }
glam = "0.25"
guillotiere = "0.6"
half = "2.2"
Expand Down Expand Up @@ -226,18 +239,28 @@ smol_str = "0.2"
softbuffer = { version = "0.4", default-features = false }
sysinfo = "0.33"
thiserror = "2"
tiny-skia = { version = "0.11", default-features = false, features = ["std", "simd"] }
tiny-skia = { version = "0.11", default-features = false, features = [
"std",
"simd",
] }
tokio = "1.0"
tracing = "0.1"
two-face = { version = "0.4", default-features = false, features = ["syntect-default-fancy"] }
two-face = { version = "0.4", default-features = false, features = [
"syntect-default-fancy",
] }
unicode-segmentation = "1.0"
url = "2.5"
wasm-bindgen-futures = "0.4"
wasmtimer = "0.4.2"
web-sys = "=0.3.85"
web-time = "1.1"
wgpu = { version = "28.0", default-features = false, features = ["std", "wgsl"] }
winit = { git = "https://github.com/iced-rs/winit.git", rev = "05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed", default-features = false, features = ["rwh_06"] }
wgpu = { version = "28.0", default-features = false, features = [
"std",
"wgsl",
] }
winit = { git = "https://github.com/iced-rs/winit.git", rev = "05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed", default-features = false, features = [
"rwh_06",
] }

[workspace.lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 }
Expand Down
22 changes: 20 additions & 2 deletions core/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,34 @@ impl Hash for LineHeight {
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Hit {
/// The point was within the bounds of the returned character index.
CharOffset(usize),
CharOffset(usize, Affinity),
}

impl Hit {
/// Computes the cursor position of the [`Hit`] .
pub fn cursor(self) -> usize {
match self {
Self::CharOffset(i) => i,
Self::CharOffset(i, _) => i,
}
}

/// Returns the cursor [`Affinity`] of the [`Hit`].
pub fn affinity(&self) -> Affinity {
match self {
Self::CharOffset(_, a) => *a,
}
}
}

/// Cursor affinity for BiDi text. At the boundary between runs of different
/// directions, the same byte index can map to different visual positions.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Affinity {
/// Associate with the run before the cursor index.
#[default]
Before,
/// Associate with the run after the cursor index.
After,
}

/// The difference detected in some text.
Expand Down
28 changes: 27 additions & 1 deletion core/src/text/paragraph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Draw paragraphs.
use crate::alignment;
use crate::text::{
Alignment, Difference, Ellipsis, Hit, LineHeight, Shaping, Span, Text, Wrapping,
Affinity, Alignment, Difference, Ellipsis, Hit, LineHeight, Shaping, Span, Text, Wrapping,
};
use crate::{Pixels, Point, Rectangle, Size};

Expand Down Expand Up @@ -73,6 +73,32 @@ pub trait Paragraph: Sized + Default {
/// Returns the distance to the given grapheme index in the [`Paragraph`].
fn grapheme_position(&self, line: usize, index: usize) -> Option<Point>;

/// Returns the visual position of a cursor at the given byte index and [`Affinity`].
fn cursor_position(
&self,
_line: usize,
_byte_index: usize,
_affinity: Affinity,
) -> Option<Point> {
None
}

/// Returns highlight rectangles for a text selection. For mixed BiDi text,
/// this may return multiple rectangles.
fn highlight(
&self,
_line: usize,
_start: (usize, Affinity),
_end: (usize, Affinity),
) -> Vec<Rectangle> {
Vec::new()
}

/// Returns `true` if the line is RTL, `false` for LTR.
fn is_rtl(&self, _line: usize) -> Option<bool> {
None
}

/// Returns the minimum width that can fit the contents of the [`Paragraph`].
fn min_width(&self) -> f32 {
self.min_bounds().width
Expand Down
3 changes: 2 additions & 1 deletion graphics/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ pub fn align(
if needs_relayout {
log::trace!("Relayouting paragraph...");

buffer.set_size(font_system, Some(min_bounds.width), Some(min_bounds.height));
buffer.set_size(Some(min_bounds.width), Some(min_bounds.height));
buffer.shape_until_scroll(font_system, false);
}

min_bounds
Expand Down
7 changes: 3 additions & 4 deletions graphics/src/text/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ impl Cache {

let max_height = key.bounds.height.max(key.line_height);

buffer.set_size(font_system, Some(key.bounds.width), Some(max_height));
buffer.set_size(Some(key.bounds.width), Some(max_height));

buffer.set_wrap(font_system, text::to_wrap(key.wrapping));
buffer.set_ellipsize(font_system, text::to_ellipsize(key.ellipsis, max_height));
buffer.set_wrap(text::to_wrap(key.wrapping));
buffer.set_ellipsize(text::to_ellipsize(key.ellipsis, max_height));

buffer.set_text(
font_system,
key.content,
&text::to_attributes(key.font),
text::to_shaping(key.shaping, key.content),
Expand Down
Loading
Loading