@@ -9,22 +9,22 @@ use core_maths::CoreFloat;
99
1010use core:: fmt;
1111
12- /// Primary attributes for font matching: [`Stretch `], [`Style `] and [`Weight `].
12+ /// Primary attributes for font matching: [`FontStretch `], [`FontStyle `] and [`FontWeight `].
1313///
1414/// These are used to [configure] a [`Query`].
1515///
1616/// [configure]: crate::Query::set_attributes
1717/// [`Query`]: crate::Query
1818#[ derive( Copy , Clone , PartialEq , Default , Debug ) ]
1919pub struct Attributes {
20- pub stretch : Stretch ,
21- pub style : Style ,
22- pub weight : Weight ,
20+ pub stretch : FontStretch ,
21+ pub style : FontStyle ,
22+ pub weight : FontWeight ,
2323}
2424
2525impl Attributes {
2626 /// Creates new attributes from the given stretch, style and weight.
27- pub fn new ( stretch : Stretch , style : Style , weight : Weight ) -> Self {
27+ pub fn new ( stretch : FontStretch , style : FontStyle , weight : FontWeight ) -> Self {
2828 Self {
2929 stretch,
3030 style,
@@ -46,7 +46,7 @@ impl fmt::Display for Attributes {
4646/// Visual width of a font-- a relative change from the normal aspect
4747/// ratio, typically in the range `0.5` to `2.0`.
4848///
49- /// The default value is [`Stretch ::NORMAL`] or `1.0`.
49+ /// The default value is [`FontStretch ::NORMAL`] or `1.0`.
5050///
5151/// In variable fonts, this can be controlled with the `wdth` [axis].
5252///
@@ -57,9 +57,9 @@ impl fmt::Display for Attributes {
5757/// [axis]: crate::AxisInfo
5858/// [`font-width`]: https://www.w3.org/TR/css-fonts-4/#font-width-prop
5959#[ derive( Copy , Clone , PartialEq , PartialOrd , Debug ) ]
60- pub struct Stretch ( f32 ) ;
60+ pub struct FontStretch ( f32 ) ;
6161
62- impl Stretch {
62+ impl FontStretch {
6363 /// Width that is 50% of normal.
6464 pub const ULTRA_CONDENSED : Self = Self ( 0.5 ) ;
6565
@@ -88,16 +88,16 @@ impl Stretch {
8888 pub const ULTRA_EXPANDED : Self = Self ( 2.0 ) ;
8989}
9090
91- impl Stretch {
91+ impl FontStretch {
9292 /// Creates a new stretch attribute with the given ratio.
9393 ///
9494 /// This can also be created [from a percentage](Self::from_percentage).
9595 ///
9696 /// # Example
9797 ///
9898 /// ```
99- /// # use fontique::Stretch ;
100- /// assert_eq!(Stretch ::from_ratio(1.5), Stretch ::EXTRA_EXPANDED);
99+ /// # use fontique::FontStretch ;
100+ /// assert_eq!(FontStretch ::from_ratio(1.5), FontStretch ::EXTRA_EXPANDED);
101101 /// ```
102102 pub fn from_ratio ( ratio : f32 ) -> Self {
103103 Self ( ratio)
@@ -110,8 +110,8 @@ impl Stretch {
110110 /// # Example
111111 ///
112112 /// ```
113- /// # use fontique::Stretch ;
114- /// assert_eq!(Stretch ::from_percentage(87.5), Stretch ::SEMI_CONDENSED);
113+ /// # use fontique::FontStretch ;
114+ /// assert_eq!(FontStretch ::from_percentage(87.5), FontStretch ::SEMI_CONDENSED);
115115 /// ```
116116 pub fn from_percentage ( percentage : f32 ) -> Self {
117117 Self ( percentage / 100.0 )
@@ -124,8 +124,8 @@ impl Stretch {
124124 /// # Example
125125 ///
126126 /// ```
127- /// # use fontique::Stretch ;
128- /// assert_eq!(Stretch ::NORMAL.ratio(), 1.0);
127+ /// # use fontique::FontStretch ;
128+ /// assert_eq!(FontStretch ::NORMAL.ratio(), 1.0);
129129 /// ```
130130 pub fn ratio ( self ) -> f32 {
131131 self . 0
@@ -140,21 +140,21 @@ impl Stretch {
140140
141141 /// Returns `true` if the stretch is [normal].
142142 ///
143- /// [normal]: Stretch ::NORMAL
143+ /// [normal]: FontStretch ::NORMAL
144144 pub fn is_normal ( self ) -> bool {
145145 self == Self :: NORMAL
146146 }
147147
148148 /// Returns `true` if the stretch is condensed (less than [normal]).
149149 ///
150- /// [normal]: Stretch ::NORMAL
150+ /// [normal]: FontStretch ::NORMAL
151151 pub fn is_condensed ( self ) -> bool {
152152 self < Self :: NORMAL
153153 }
154154
155155 /// Returns `true` if the stretch is expanded (greater than [normal]).
156156 ///
157- /// [normal]: Stretch ::NORMAL
157+ /// [normal]: FontStretch ::NORMAL
158158 pub fn is_expanded ( self ) -> bool {
159159 self > Self :: NORMAL
160160 }
@@ -164,10 +164,10 @@ impl Stretch {
164164 /// # Examples
165165 ///
166166 /// ```
167- /// # use fontique::Stretch ;
168- /// assert_eq!(Stretch ::parse("semi-condensed"), Some(Stretch ::SEMI_CONDENSED));
169- /// assert_eq!(Stretch ::parse("80%"), Some(Stretch ::from_percentage(80.0)));
170- /// assert_eq!(Stretch ::parse("wideload"), None);
167+ /// # use fontique::FontStretch ;
168+ /// assert_eq!(FontStretch ::parse("semi-condensed"), Some(FontStretch ::SEMI_CONDENSED));
169+ /// assert_eq!(FontStretch ::parse("80%"), Some(FontStretch ::from_percentage(80.0)));
170+ /// assert_eq!(FontStretch ::parse("wideload"), None);
171171 /// ```
172172 pub fn parse ( s : & str ) -> Option < Self > {
173173 let s = s. trim ( ) ;
@@ -191,7 +191,7 @@ impl Stretch {
191191 }
192192}
193193
194- impl fmt:: Display for Stretch {
194+ impl fmt:: Display for FontStretch {
195195 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
196196 let value = self . 0 * 1000.0 ;
197197 if value. fract ( ) == 0.0 {
@@ -216,15 +216,15 @@ impl fmt::Display for Stretch {
216216 }
217217}
218218
219- impl Default for Stretch {
219+ impl Default for FontStretch {
220220 fn default ( ) -> Self {
221221 Self :: NORMAL
222222 }
223223}
224224
225225/// Visual weight class of a font, typically on a scale from 1.0 to 1000.0.
226226///
227- /// The default value is [`Weight ::NORMAL`] or `400.0`.
227+ /// The default value is [`FontWeight ::NORMAL`] or `400.0`.
228228///
229229/// In variable fonts, this can be controlled with the `wght` [axis].
230230///
@@ -235,9 +235,9 @@ impl Default for Stretch {
235235/// [axis]: crate::AxisInfo
236236/// [`font-weight`]: https://www.w3.org/TR/css-fonts-4/#font-weight-prop
237237#[ derive( Copy , Clone , PartialEq , PartialOrd , Debug ) ]
238- pub struct Weight ( f32 ) ;
238+ pub struct FontWeight ( f32 ) ;
239239
240- impl Weight {
240+ impl FontWeight {
241241 /// Weight value of 100.
242242 pub const THIN : Self = Self ( 100.0 ) ;
243243
@@ -272,7 +272,7 @@ impl Weight {
272272 pub const EXTRA_BLACK : Self = Self ( 950.0 ) ;
273273}
274274
275- impl Weight {
275+ impl FontWeight {
276276 /// Creates a new weight attribute with the given value.
277277 pub fn new ( weight : f32 ) -> Self {
278278 Self ( weight)
@@ -288,11 +288,11 @@ impl Weight {
288288 /// # Examples
289289 ///
290290 /// ```
291- /// # use fontique::Weight ;
292- /// assert_eq!(Weight ::parse("normal"), Some(Weight ::NORMAL));
293- /// assert_eq!(Weight ::parse("bold"), Some(Weight ::BOLD));
294- /// assert_eq!(Weight ::parse("850"), Some(Weight ::new(850.0)));
295- /// assert_eq!(Weight ::parse("invalid"), None);
291+ /// # use fontique::FontWeight ;
292+ /// assert_eq!(FontWeight ::parse("normal"), Some(FontWeight ::NORMAL));
293+ /// assert_eq!(FontWeight ::parse("bold"), Some(FontWeight ::BOLD));
294+ /// assert_eq!(FontWeight ::parse("850"), Some(FontWeight ::new(850.0)));
295+ /// assert_eq!(FontWeight ::parse("invalid"), None);
296296 /// ```
297297 pub fn parse ( s : & str ) -> Option < Self > {
298298 let s = s. trim ( ) ;
@@ -304,13 +304,13 @@ impl Weight {
304304 }
305305}
306306
307- impl Default for Weight {
307+ impl Default for FontWeight {
308308 fn default ( ) -> Self {
309309 Self :: NORMAL
310310 }
311311}
312312
313- impl fmt:: Display for Weight {
313+ impl fmt:: Display for FontWeight {
314314 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
315315 let value = self . 0 ;
316316 if value. fract ( ) == 0.0 {
@@ -335,7 +335,7 @@ impl fmt::Display for Weight {
335335
336336/// Visual style or 'slope' of a font.
337337///
338- /// The default value is [`Style ::Normal`].
338+ /// The default value is [`FontStyle ::Normal`].
339339///
340340/// In variable fonts, this can be controlled with the `ital`
341341/// and `slnt` [axes] for italic and oblique styles, respectively.
@@ -347,7 +347,7 @@ impl fmt::Display for Weight {
347347/// [axes]: crate::AxisInfo
348348/// [`font-style`]: https://www.w3.org/TR/css-fonts-4/#font-style-prop
349349#[ derive( Copy , Clone , PartialEq , Default , Debug ) ]
350- pub enum Style {
350+ pub enum FontStyle {
351351 /// An upright or "roman" style.
352352 #[ default]
353353 Normal ,
@@ -359,7 +359,7 @@ pub enum Style {
359359 Oblique ( Option < f32 > ) ,
360360}
361361
362- impl Style {
362+ impl FontStyle {
363363 /// Parses a font style from a CSS value.
364364 pub fn parse ( mut s : & str ) -> Option < Self > {
365365 s = s. trim ( ) ;
@@ -399,7 +399,7 @@ impl Style {
399399 }
400400}
401401
402- impl fmt:: Display for Style {
402+ impl fmt:: Display for FontStyle {
403403 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
404404 let value = match self {
405405 Self :: Normal => "normal" ,
0 commit comments