Add Auto strategy to text::Shaping
This commit is contained in:
parent
d31a7b6ae8
commit
bc7d64987e
8 changed files with 47 additions and 11 deletions
|
|
@ -130,8 +130,17 @@ impl From<Alignment> for alignment::Horizontal {
|
|||
}
|
||||
|
||||
/// The shaping strategy of some text.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Shaping {
|
||||
/// Auto-detect the best shaping strategy from the text.
|
||||
///
|
||||
/// This strategy will use [`Basic`](Self::Basic) shaping if the
|
||||
/// text consists of only ASCII characters; otherwise, it will
|
||||
/// use [`Advanced`](Self::Advanced) shaping.
|
||||
///
|
||||
/// This is the default, if neither the `basic-shaping` nor `advanced-shaping`
|
||||
/// features are enabled.
|
||||
Auto,
|
||||
/// No shaping and no font fallback.
|
||||
///
|
||||
/// This shaping strategy is very cheap, but it will not display complex
|
||||
|
|
@ -140,8 +149,8 @@ pub enum Shaping {
|
|||
/// You should use this strategy when you have complete control of the text
|
||||
/// and the font you are displaying in your application.
|
||||
///
|
||||
/// This is the default.
|
||||
#[default]
|
||||
/// This will be the default if the `basic-shaping` feature is enabled and
|
||||
/// the `advanced-shaping` feature is disabled.
|
||||
Basic,
|
||||
/// Advanced text shaping and font fallback.
|
||||
///
|
||||
|
|
@ -150,9 +159,23 @@ pub enum Shaping {
|
|||
/// may be needed to display all of the glyphs.
|
||||
///
|
||||
/// Advanced shaping is expensive! You should only enable it when necessary.
|
||||
///
|
||||
/// This will be the default if the `advanced-shaping` feature is enabled.
|
||||
Advanced,
|
||||
}
|
||||
|
||||
impl Default for Shaping {
|
||||
fn default() -> Self {
|
||||
if cfg!(feature = "advanced-shaping") {
|
||||
Self::Advanced
|
||||
} else if cfg!(feature = "basic-shaping") {
|
||||
Self::Basic
|
||||
} else {
|
||||
Self::Auto
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The wrapping strategy of some text.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
pub enum Wrapping {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue