Add function to get layout runs

This commit is contained in:
Jeremy Soller 2022-10-25 11:40:10 -06:00
parent 5603e30a29
commit 330a736136
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
6 changed files with 254 additions and 238 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use cosmic_text::{FontSystem, TextAction, TextBuffer, TextMetrics};
use cosmic_text::{FontSystem, SwashCache, TextAction, TextBuffer, TextMetrics};
use orbclient::{Color, EventOption, Renderer, Window, WindowFlag};
use std::{env, fs, thread, time::{Duration, Instant}};
@ -83,6 +83,8 @@ fn main() {
default_text.to_string()
};
let mut swash_cache = SwashCache::new();
let line_x = 8 * display_scale;
let mut buffer = TextBuffer::new(
font_matches,
@ -110,7 +112,7 @@ fn main() {
window.set(bg_color);
buffer.draw(font_color.data, |x, y, w, h, color| {
buffer.draw(&mut swash_cache, font_color.data, |x, y, w, h, color| {
window.rect(line_x + x, y, w, h, Color { data: color });
});