Skip to content

Commit f68213f

Browse files
feat: hyphenation
1 parent 1d03372 commit f68213f

File tree

11 files changed

+114
-4
lines changed

11 files changed

+114
-4
lines changed

Cargo.lock

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ vello_encoding = "0.7"
152152
resvg = "0.47"
153153
usvg = "0.47"
154154
parley = "0.6"
155+
hyphenation = { version = "0.8.3", features = ["embed_all"] }
155156
skrifa = "0.40"
156157
polycool = "0.4"
157158
# Linebender ecosystem (END)

editor/src/messages/portfolio/document/overlays/utility_functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ pub fn text_width(text: &str, font_size: f64) -> f64 {
239239
max_height: None,
240240
tilt: 0.0,
241241
align: TextAlign::Left,
242+
hyphenate: false,
242243
};
243244

244245
// Load Source Sans Pro font data

editor/src/messages/portfolio/document/overlays/utility_types_native.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ impl OverlayContextInternal {
11111111
max_height: None,
11121112
tilt: 0.,
11131113
align: TextAlign::Left, // We'll handle alignment manually via pivot
1114+
hyphenate: false,
11141115
};
11151116

11161117
// Load Source Sans Pro font data

editor/src/messages/tool/common_functionality/graph_modification_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ pub fn get_text(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInter
422422
let Some(&TaggedValue::TextAlign(align)) = inputs[graphene_std::text::text::AlignInput::INDEX].as_value() else {
423423
return None;
424424
};
425+
let Some(&TaggedValue::Bool(hyphenate)) = inputs[graphene_std::text::text::HyphenateInput::INDEX].as_value() else {
426+
return None;
427+
};
425428
let Some(&TaggedValue::Bool(per_glyph_instances)) = inputs[graphene_std::text::text::SeparateGlyphElementsInput::INDEX].as_value() else {
426429
return None;
427430
};
@@ -434,6 +437,7 @@ pub fn get_text(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInter
434437
character_spacing,
435438
tilt,
436439
align,
440+
hyphenate,
437441
};
438442
Some((text, font, typesetting, per_glyph_instances))
439443
}

editor/src/messages/tool/tool_messages/text_tool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ impl Fsm for TextToolFsmState {
904904
max_height: constraint_size.map(|size| size.y),
905905
tilt: tool_options.tilt,
906906
align: tool_options.align,
907+
hyphenate: false,
907908
},
908909
font: Font::new(tool_options.font.font_family.clone(), tool_options.font.font_style.clone()),
909910
color: tool_options.fill.active_color(),

node-graph/libraries/core-types/src/text.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct TypesettingConfig {
4343
pub max_height: Option<f64>,
4444
pub tilt: f64,
4545
pub align: TextAlign,
46+
pub hyphenate: bool,
4647
}
4748

4849
impl Default for TypesettingConfig {
@@ -55,6 +56,7 @@ impl Default for TypesettingConfig {
5556
max_height: None,
5657
tilt: 0.,
5758
align: TextAlign::default(),
59+
hyphenate: false,
5860
}
5961
}
6062
}

node-graph/nodes/gstd/src/text.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn text<'i: 'n>(
5959
/// To have an effect on a single line of text, *Max Width* must be set.
6060
#[widget(ParsedWidgetOverride::Custom = "text_align")]
6161
align: TextAlign,
62+
hyphenate: bool,
6263
/// Whether to split every letterform into its own vector path element. Otherwise, a single compound path is produced.
6364
separate_glyph_elements: bool,
6465
) -> Table<Vector> {
@@ -70,6 +71,7 @@ fn text<'i: 'n>(
7071
max_height: has_max_height.then_some(max_height),
7172
tilt,
7273
align,
74+
hyphenate,
7375
};
7476

7577
to_path(&text, &font, &editor_resources.font_cache, typesetting, separate_glyph_elements)

node-graph/nodes/text/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ node-macro = { workspace = true }
2020
dyn-any = { workspace = true }
2121
glam = { workspace = true }
2222
parley = { workspace = true }
23+
hyphenation = { workspace = true }
2324
skrifa = { workspace = true }
2425
log = { workspace = true }
2526

node-graph/nodes/text/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct TypesettingConfig {
4747
pub max_height: Option<f64>,
4848
pub tilt: f64,
4949
pub align: TextAlign,
50+
pub hyphenate: bool,
5051
}
5152

5253
impl Default for TypesettingConfig {
@@ -59,6 +60,7 @@ impl Default for TypesettingConfig {
5960
max_height: None,
6061
tilt: 0.,
6162
align: TextAlign::default(),
63+
hyphenate: false,
6264
}
6365
}
6466
}

0 commit comments

Comments
 (0)