Update cosmic-text
to latest
This commit is contained in:
parent
ea5f122f78
commit
2af2f357c5
4 changed files with 28 additions and 30 deletions
|
@ -19,8 +19,6 @@ fn main() {
|
|||
pollster::block_on(run());
|
||||
}
|
||||
|
||||
static mut FONT_SYSTEM: Option<FontSystem> = None;
|
||||
|
||||
async fn run() {
|
||||
// Set up window
|
||||
let (width, height) = (800, 600);
|
||||
|
@ -64,24 +62,19 @@ async fn run() {
|
|||
surface.configure(&device, &config);
|
||||
|
||||
// Set up text renderer
|
||||
unsafe {
|
||||
FONT_SYSTEM = Some(FontSystem::new());
|
||||
}
|
||||
let mut cache = SwashCache::new(unsafe { FONT_SYSTEM.as_ref().unwrap() });
|
||||
let mut font_system = FontSystem::new();
|
||||
let mut cache = SwashCache::new();
|
||||
let mut atlas = TextAtlas::new(&device, &queue, swapchain_format);
|
||||
let mut text_renderer =
|
||||
TextRenderer::new(&mut atlas, &device, MultisampleState::default(), None);
|
||||
let mut buffer = Buffer::new(
|
||||
unsafe { FONT_SYSTEM.as_ref().unwrap() },
|
||||
Metrics::new(30, 42),
|
||||
);
|
||||
let mut buffer = Buffer::new(&mut font_system, Metrics::new(30.0, 42.0));
|
||||
|
||||
let physical_width = (width as f64 * scale_factor) as i32;
|
||||
let physical_height = (height as f64 * scale_factor) as i32;
|
||||
let physical_width = (width as f64 * scale_factor) as f32;
|
||||
let physical_height = (height as f64 * scale_factor) as f32;
|
||||
|
||||
buffer.set_size(physical_width, physical_height);
|
||||
buffer.set_text("Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", Attrs::new().family(Family::SansSerif));
|
||||
buffer.shape_until_scroll();
|
||||
buffer.set_size(&mut font_system, physical_width, physical_height);
|
||||
buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", Attrs::new().family(Family::SansSerif));
|
||||
buffer.shape_until_scroll(&mut font_system);
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
let _ = (&instance, &adapter);
|
||||
|
@ -102,6 +95,7 @@ async fn run() {
|
|||
.prepare(
|
||||
&device,
|
||||
&queue,
|
||||
&mut font_system,
|
||||
&mut atlas,
|
||||
Resolution {
|
||||
width: config.width,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue