Add Auto strategy to text::Shaping
This commit is contained in:
parent
d31a7b6ae8
commit
bc7d64987e
8 changed files with 47 additions and 11 deletions
|
|
@ -323,8 +323,15 @@ fn to_align(alignment: Alignment) -> Option<cosmic_text::Align> {
|
|||
}
|
||||
|
||||
/// Converts some [`Shaping`] strategy to a [`cosmic_text::Shaping`] strategy.
|
||||
pub fn to_shaping(shaping: Shaping) -> cosmic_text::Shaping {
|
||||
pub fn to_shaping(shaping: Shaping, text: &str) -> cosmic_text::Shaping {
|
||||
match shaping {
|
||||
Shaping::Auto => {
|
||||
if text.is_ascii() {
|
||||
cosmic_text::Shaping::Basic
|
||||
} else {
|
||||
cosmic_text::Shaping::Advanced
|
||||
}
|
||||
}
|
||||
Shaping::Basic => cosmic_text::Shaping::Basic,
|
||||
Shaping::Advanced => cosmic_text::Shaping::Advanced,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl Cache {
|
|||
font_system,
|
||||
key.content,
|
||||
&text::to_attributes(key.font),
|
||||
text::to_shaping(key.shaping),
|
||||
text::to_shaping(key.shaping, key.content),
|
||||
);
|
||||
|
||||
let bounds = text::align(&mut buffer, font_system, key.align_x);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ impl core::text::Paragraph for Paragraph {
|
|||
font_system.raw(),
|
||||
text.content,
|
||||
&text::to_attributes(text.font),
|
||||
text::to_shaping(text.shaping),
|
||||
text::to_shaping(text.shaping, text.content),
|
||||
);
|
||||
|
||||
let min_bounds =
|
||||
|
|
@ -158,7 +158,7 @@ impl core::text::Paragraph for Paragraph {
|
|||
(span.text.as_ref(), attrs.metadata(i))
|
||||
}),
|
||||
&text::to_attributes(text.font),
|
||||
text::to_shaping(text.shaping),
|
||||
cosmic_text::Shaping::Advanced,
|
||||
None,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue