#![forbid(unsafe_code)]
#![deny(missing_docs)]
pub mod cache;
pub mod font;
pub mod ime;
pub mod shaping;
pub use cache::{
CachedShape, FontSizeBits, LineHeightBits, MaxWidthBits, ShapeCacheKey, TextHash,
TextShapeCache, DEFAULT_MEMORY_BUDGET,
};
pub use cosmic_text::{Attrs, Buffer, Family, FontSystem, Metrics, Shaping};
pub use font::{FontFaceInfo, FontId, FontManager, FontSource, FontStyle};
pub use ime::{ImePositioner, ScrollKinematics, Viewport};
pub use shaping::{
measure_text, measure_text_with_attrs, shape_text, ShapedGlyph, ShapedLine, Shaper, TextMetrics,
};
#[cfg(test)]
use winit::dpi::{LogicalPosition, LogicalSize};
#[deprecated(
since = "0.5.0",
note = "use `ImePositioner::compute_bounds` for velocity-damped, viewport-clamped IME bounds"
)]
#[cfg(test)]
fn compute_ime_bounds(x: f64, y: f64, height: f64) -> (LogicalPosition<f64>, LogicalSize<f64>) {
(LogicalPosition::new(x, y), LogicalSize::new(2.0, height))
}
#[cfg(test)]
mod tests {
#![allow(deprecated)]
use super::compute_ime_bounds;
#[test]
fn returns_correct_position_and_size() {
let (pos, size) = compute_ime_bounds(10.0, 20.0, 30.0);
assert_eq!(pos.x, 10.0);
assert_eq!(pos.y, 20.0);
assert_eq!(size.width, 2.0);
assert_eq!(size.height, 30.0);
}
#[test]
fn zero_height() {
let (pos, size) = compute_ime_bounds(5.0, 5.0, 0.0);
assert_eq!(pos.x, 5.0);
assert_eq!(pos.y, 5.0);
assert_eq!(size.width, 2.0);
assert_eq!(size.height, 0.0);
}
#[test]
fn negative_coordinates() {
let (pos, size) = compute_ime_bounds(-10.0, -20.0, 30.0);
assert_eq!(pos.x, -10.0);
assert_eq!(pos.y, -20.0);
assert_eq!(size.width, 2.0);
assert_eq!(size.height, 30.0);
}
}