#width #xlib #context #font #multi-threading #call #query

textwidth

Get the width of a piece of text for a font through xlib

3 stable releases

2.1.0 Oct 21, 2020
2.0.0 Oct 21, 2020
1.1.0 Jul 1, 2018
1.0.0 Jul 1, 2018

#5 in #xlib

21 downloads per month

MIT license

8KB
159 lines

textwidth

Documentation

A simple library to query a textwidth of a given font+size.

This is only supported on Linux and similar environments. Others are not planned as the author does not have one. PRs welcome.

⚠️ You have to call setup_multithreading if you plan on using multiple Context in a multi-threaded way, or if you are using x11/xlib in a multi-threaded fashion.

Example

use textwidth::Context;

let ctx = Context::with_misc().unwrap();
assert!(ctx.text_width("Hello World") > 0);

Dependencies

~0.7–1.2MB
~27K SLoC