Skip to content

Ligatures should be disabled when letter spacing is enabled #515

@taj-p

Description

@taj-p

As the title suggests, ligatures should be disabled when letter spacing is requested. Otherwise, the clusters that are sent to breaking represent ligatures that cannot be broken up.

For example, in the below test, we produce this image. Note how "ffi" in office are out of place and how the "fi" and "fl" ligatures are not broken up like "ff".

Image
#[test]
fn interaction_letter_spacing_ligatures() {
    let mut env = TestEnv::new(test_name!(), None);
    let text = samples::LIGATURES;

    // Without letter spacing - ligatures should form (if font supports them)
    let features_on = FontFeatures::List(Cow::Borrowed(&[FontFeature {
        tag: Tag::new(b"liga"),
        value: 1,
    }]));

    let mut builder_no_spacing = env.ranged_builder(text);
    builder_no_spacing.push_default(StyleProperty::FontFeatures(features_on.clone()));
    builder_no_spacing.push_default(StyleProperty::LetterSpacing(0.0));
    let mut layout_no_spacing = builder_no_spacing.build(text);
    layout_no_spacing.break_all_lines(None);
    layout_no_spacing.align(None, Alignment::Start, AlignmentOptions::default());

    env.with_name("no_spacing")
        .check_layout_snapshot(&layout_no_spacing);

    // With letter spacing - ligatures SHOULD break
    let mut builder_with_spacing = env.ranged_builder(text);
    builder_with_spacing.push_default(StyleProperty::FontFeatures(features_on));
    builder_with_spacing.push_default(StyleProperty::LetterSpacing(2.0));
    let mut layout_with_spacing = builder_with_spacing.build(text);
    layout_with_spacing.break_all_lines(None);
    layout_with_spacing.align(None, Alignment::Start, AlignmentOptions::default());

    env.with_name("with_spacing")
        .check_layout_snapshot(&layout_with_spacing);
}

Seen in #503

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions