1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use crate::;
use SharedString;
/// An opaque identifier for a font face that the [`TextSystem`](crate::TextSystem) has resolved.
///
/// Get one with [`TextSystem::resolve_font`](crate::TextSystem::resolve_font). The id is valid for the lifetime of
/// the [`TextSystem`](crate::TextSystem) that produced it and is used for metrics and glyph rasterization.
;
/// The face to use for text: a font family plus its weight, width, style, features, and fallbacks.
///
/// Build one with [`font`] and then adjust it with the builder methods, or set
/// the public fields directly. The [`TextSystem`](crate::TextSystem) caches lookups by `Font`, so
/// equal fonts share one lookup.
///
/// The default is the family `.SystemUIFont`, which the platform maps to its
/// system interface font. Use a named family when the look must be the same
/// on every platform.
///
/// # Examples
///
/// ```
/// # use gpui::{Font, FontStyle, FontWeight, font};
/// let heading = font("Lilex").bold();
/// assert_eq!(heading.weight, FontWeight::BOLD);
///
/// let quote = Font {
/// style: FontStyle::Italic,
/// ..font("Source Serif 4")
/// };
/// assert_eq!(quote.style, FontStyle::Italic);
/// ```
///
/// See [text](crate::_documentation::guides::text) for how fonts are chosen and
/// how to add your own.
/// Returns a [`Font`] for `family`, with normal weight, width, and style.
///
/// Pass a family name from [`TextSystem::all_font_names`](crate::TextSystem::all_font_names) or one you added with
/// [`TextSystem::add_fonts`](crate::TextSystem::add_fonts). Chain [`Font::bold`] or [`Font::italic`] to change
/// the style.
///
/// # Examples
///
/// ```
/// # use gpui::{FontStyle, FontWeight, font};
/// let body = font("Lilex");
/// assert_eq!(body.family.as_ref(), "Lilex");
/// assert_eq!(body.weight, FontWeight::NORMAL);
/// assert_eq!(body.style, FontStyle::Normal);
/// ```