diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs index 523ec45..ddb58cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,8 +7,7 @@ use x11::xrender::XRenderColor; use x11::xft::{ XftFontOpenName, XftDrawCreate, XftDrawDestroy, - XftColor, - XftDrawStringUtf8 + XftColor }; use xcb::{ Xid }; use xcb::x::{ @@ -40,7 +39,7 @@ struct Dock { configuration: DockConfiguration, window: Window, bounds: Arc<Rectangle<u16>>, - font: *mut x11::xft::XftFont, + font: Font, } impl HasWindow for Dock { @@ -120,14 +119,8 @@ impl Dock { ], })?; - let xlib_display = display.connection().get_xlib_display(); - let screen_index = display.screen_index(); - - let font = unsafe { - XftFontOpenName(xlib_display, screen_index, - c"FantasqueSansM Nerd Font Mono:style=Regular:size=18" - .as_ptr().cast()) - }; + let font = Font::new(Arc::clone(&display), + "FantasqueSansM Nerd Font Mono:style=Regular:size=18")?; let dock = Dock { window, configuration, @@ -339,12 +332,8 @@ impl Dock { pixel: self.configuration.foreground_pixel as u64, color: self.configuration.foreground_render_color, }; - let text = c"amazing cool fiction technically reads playful unknown telephonic works from-post"; - unsafe { - XftDrawStringUtf8(xft_context, &xft_color, self.font, 12, 25, - text.as_ptr().cast(), - text.count_bytes() as i32) - }; + let text = "playful cool fic tech nonfic"; + self.font.draw(xft_context, &xft_color, 12, 25, text)?; unsafe { XftDrawDestroy(xft_context) }; |