Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help figuring out how horizontal scrolling work #355

Open
antouhou opened this issue Jan 28, 2025 · 0 comments
Open

Need help figuring out how horizontal scrolling work #355

antouhou opened this issue Jan 28, 2025 · 0 comments

Comments

@antouhou
Copy link

Hi! I hope that this message finds someone who can explain to me how horizontal scroll work :)

Here's my code:

use cosmic_text::{FontSystem, Metrics, Buffer, Wrap, Attrs, Family, Shaping, Scroll};

fn main() {
    let mut font_system = FontSystem::new();
    let metrics = Metrics::new(14.0, 20.0);

    let mut buffer = Buffer::new(&mut font_system, metrics);

    let mut buffer = buffer.borrow_with(&mut font_system);
    
    buffer.set_wrap(Wrap::None);
    buffer.set_size(Some(100.0), Some(50.0));

    buffer.set_text(
        "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.",
        Attrs::new().family(Family::SansSerif),
        Shaping::Advanced
    );

    let scroll = Scroll::new(0, 15.0, 200.0);
    buffer.set_scroll(scroll);

    // Perform shaping as desired
    buffer.shape_until_scroll(false);

    for run in buffer.layout_runs() {
        println!("Layout run: {:?}", run);
    }
}

However, it doesn't seem like setting horizontal scroll changes anything anywhere. Changing vertical scroll works fine. Is there something I'm missing here? Rendering the buffer to the screen also applies vertical scroll correctly, but does nothing with horizontal one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant