Crate win_term

Crate win_term 

Source
Expand description

Small Windows-only helper to estimate console pixel sizes.

§Why this exists

GetCurrentConsoleFontEx and other font-metric APIs are unreliable on many Windows terminal hosts and emulators (they may return unusable values or not reflect user DPI/zoom). This crate provides a “good enough” estimation by using conservative defaults and the current DPI to compute per-character pixel sizes, then converting console character dimensions into pixels.

Short summary

  • get_size_of_the_font() returns an estimated font cell size in pixels.
  • get_size_of_the_terminal() returns a pixel-size estimate for the console by multiplying the estimated font size by console character dimensions.

Limitations: values are approximations and may be incorrect for custom fonts, per-window zoom, or terminal emulators that do not expose accurate metrics.

Structs§

FontSize
Struct to hold font size information in terms of width and height.
TerminalSize
Struct to hold terminal size information in terms of width and height.

Enums§

TerminalError
Enum to represent possible errors that can occur while getting terminal or font size.

Functions§

get_size_of_the_font
Estimate the console font cell size in pixels.
get_size_of_the_terminal
Estimate the terminal window size in pixels.