win-term

Crates.iowin-term
lib.rswin-term
version0.2.0
created_at2024-08-30 17:19:53.780787+00
updated_at2026-01-15 20:21:00.958379+00
descriptionFetch terminal size in pixel
homepagehttps://github.com/Gipson62/win-term
repositoryhttps://github.com/Gipson62/win-term
max_upload_size
id1357934
size13,534
Gipson62 (Gipson62)

documentation

README

win-term

========

Small Windows-only crate to estimate console sizes in pixels.

Why this exists

On many Windows hosts and terminal emulators, native font-metric APIs like GetCurrentConsoleFontEx either return unusable values or do not reflect user DPI/zoom. This crate provides a pragmatic, "good enough" estimate by scaling conservative default font dimensions with the console window DPI and converting console character dimensions to pixels.

Quick usage

use win_term::{get_size_of_the_font, get_size_of_the_terminal};

fn main() {
	if let Ok(font) = get_size_of_the_font() {
		println!("Font cell: {}x{} px", font.width, font.height);
	}
	if let Ok(term) = get_size_of_the_terminal() {
		println!("Terminal: {}x{} px", term.width, term.height);
	}
}

Limitations

  • Results are estimates and may be incorrect for custom fonts, per-window zoom, or terminal emulators that don't expose accurate metrics.
  • This crate is Windows-only and intended for simple, pragmatic use cases.

License: MIT

Commit count: 4

cargo fmt