Skip to main content

epaint/text/
mod.rs

1//! Everything related to text, fonts, text layout, cursors etc.
2
3pub mod cursor;
4mod font;
5mod fonts;
6mod text_layout;
7mod text_layout_types;
8
9/// One `\t` character is this many spaces wide.
10pub const TAB_SIZE: usize = 4;
11
12pub use {
13    fonts::{
14        FontData, FontDefinitions, FontFamily, FontId, FontInsert, FontPriority, FontTweak, Fonts,
15        FontsImpl, FontsView, InsertFontFamily,
16    },
17    text_layout::*,
18    text_layout_types::*,
19};
20
21/// Suggested character to use to replace those in password text fields.
22pub const PASSWORD_REPLACEMENT_CHAR: char = '•';
23
24/// Controls how we render text
25#[derive(Clone, Copy, Debug, PartialEq)]
26#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
27pub struct TextOptions {
28    /// Maximum size of the font texture.
29    pub max_texture_side: usize,
30
31    /// Controls how to convert glyph coverage to alpha.
32    pub alpha_from_coverage: crate::AlphaFromCoverage,
33
34    /// Whether to enable font hinting
35    ///
36    /// (round some font coordinates to pixels for sharper text).
37    ///
38    /// Default is `true`.
39    pub font_hinting: bool,
40}
41
42impl Default for TextOptions {
43    fn default() -> Self {
44        Self {
45            max_texture_side: 2048, // Small but portable
46            alpha_from_coverage: crate::AlphaFromCoverage::default(),
47            font_hinting: true,
48        }
49    }
50}