diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-12 18:38:43 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-12 18:38:43 -0700 |
| commit | 7138ace1c1f97f85509278e50b72eb62ed0fd315 (patch) | |
| tree | b9afd2669631846080f215ac88f3dc0d0857a125 /src/main.rs | |
| parent | 7c457902864fd3e54832dd22bf33f324b6ec3cdb (diff) | |
move some of the font rendering into its own file
Force-Push: yes Change-Id: I628d0d05bf75ac781cf6eb6524972b4e61d25e61
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) }; |