| Crates.io | win-term |
| lib.rs | win-term |
| version | 0.2.0 |
| created_at | 2024-08-30 17:19:53.780787+00 |
| updated_at | 2026-01-15 20:21:00.958379+00 |
| description | Fetch terminal size in pixel |
| homepage | https://github.com/Gipson62/win-term |
| repository | https://github.com/Gipson62/win-term |
| max_upload_size | |
| id | 1357934 |
| size | 13,534 |
========
Small Windows-only crate to estimate console sizes in pixels.
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.
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);
}
}
License: MIT