Debian Codegraph @

src/scale.rs

raw symbols SCIP
1 #[cfg(all(feature = "libm", not(feature = "std")))]
2 use craterust-analyzer cargo ab_glyph 0.2.32 crate/::nostd_float::FloatExt;
3 use craterust-analyzer cargo ab_glyph 0.2.32 crate/::{Fontrust-analyzer cargo ab_glyph 0.2.32 font/Font#, Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#, GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#, OutlinedGlyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#, Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect#};
4
5 /// Pixel scale.
6 ///
7 /// This is the pixel-height of text.
8 ///
9 /// Usually one uses `x == y`, but one may use a different ratio to stretch a
10 /// font horizontally or vertically.
11 ///
12 /// To convert pt size into pixel-scale see [`Font::pt_to_px_scale`].
13 ///
14 /// # Example
15 /// ```
16 /// use ab_glyph::PxScale;
17 ///
18 /// let uniform_scale_24px = PxScale::from(24.0);
19 /// ```
20 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
21 pub struct PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# {
22 /// Horizontal scale in pixels.
23 pub xrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#x.: f32,
24 /// Vertical scale in pixels.
25 ///
26 /// By definition, this is the pixel-height of a font.
27 pub yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y.: f32,
28 }
29
30 impl PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# {
31 /// Returns a `PxScale` with both x & y scale values set to the nearest integer.
32 #[inline]
33 pub fn roundrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[PxScale]round().(self) -> Selfrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[PxScale] {
34 Selfrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[PxScale] {
35 xrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#x.: self.xrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#x..roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().(),
36 yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y.: self.yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y..roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().(),
37 }
38 }
39 }
40
41 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<f32> for PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# {
42 /// Uniform scaling where x & y are the same.
43 #[inline]
44 fn fromrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[PxScale][`From<f32>`]from().(s: f32) -> Selfrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[PxScale][`From<f32>`] {
45 PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# { xrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#x.: s, yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y.: s }
46 }
47 }
48
49 /// 2D scale factors for use with unscaled metrics.
50 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
51 pub struct PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor# {
52 pub horizontalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#horizontal.: f32,
53 pub verticalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#vertical.: f32,
54 }
55
56 /// A [`Font`] with an associated pixel scale. This can be used to provide
57 /// pixel scale values for glyph advances, heights etc.
58 ///
59 /// # Example
60 /// ```
61 /// use ab_glyph::{Font, FontRef, PxScale, ScaleFont};
62 ///
63 /// # fn main() -> Result<(), ab_glyph::InvalidFont> {
64 /// let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;
65 ///
66 /// // Associate the font with a scale of 45px
67 /// let scaled_font = font.as_scaled(PxScale::from(45.0));
68 ///
69 /// assert_eq!(scaled_font.height(), 45.0);
70 /// assert_eq!(scaled_font.h_advance(scaled_font.glyph_id('b')), 21.225);
71 ///
72 /// // Replace associated scale with another
73 /// let scaled_font = scaled_font.with_scale(180.0);
74 ///
75 /// assert_eq!(scaled_font.height(), 180.0);
76 /// assert_eq!(scaled_font.h_advance(scaled_font.glyph_id('b')), 84.9);
77 /// # Ok(()) }
78 /// ```
79 pub trait ScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#<F: Fontrust-analyzer cargo ab_glyph 0.2.32 font/Font#> {
80 /// Returns the pixel scale associated with this font.
81 fn scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().(&self) -> PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#;
82
83 /// Returns a font reference.
84 fn fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().(&self) -> &F;
85
86 /// Scale factor for unscaled font horizontal values.
87 #[inline]
88 fn h_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_scale_factor().(&self) -> f32 {
89 self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().().xrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().height_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#height_unscaled().()
90 }
91
92 /// Scale factor for unscaled font vertical values.
93 #[inline]
94 fn v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().(&self) -> f32 {
95 self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().().yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().height_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#height_unscaled().()
96 }
97
98 #[inline]
99 fn scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale_factor().(&self) -> PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor# {
100 PxScaleFactorrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor# {
101 horizontalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#horizontal.: self.h_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_scale_factor().(),
102 verticalrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFactor#vertical.: self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().(),
103 }
104 }
105
106 /// Pixel scaled glyph ascent. See [glyph layout concepts](Font#glyph-layout-concepts).
107 #[inline]
108 fn ascentrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#ascent().(&self) -> f32 {
109 self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().ascent_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#ascent_unscaled().()
110 }
111
112 /// Pixel scaled glyph descent. See [glyph layout concepts](Font#glyph-layout-concepts).
113 #[inline]
114 fn descentrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#descent().(&self) -> f32 {
115 self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().descent_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#descent_unscaled().()
116 }
117
118 /// Pixel scaled height `ascent - descent`. See [glyph layout concepts](Font#glyph-layout-concepts).
119 ///
120 /// By definition of [`PxScale`], this is `self.scale().y`.
121 #[inline]
122 fn heightrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#height().(&self) -> f32 {
123 self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().().yrust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#y.
124 }
125
126 /// Pixel scaled line gap. See [glyph layout concepts](Font#glyph-layout-concepts).
127 #[inline]
128 fn line_gaprust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#line_gap().(&self) -> f32 {
129 self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().line_gap_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#line_gap_unscaled().()
130 }
131
132 /// Lookup a `GlyphId` matching a given `char`.
133 #[inline]
134 fn glyph_idrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#glyph_id().(&self, c: char) -> GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId# {
135 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().glyph_idrust-analyzer cargo ab_glyph 0.2.32 font/Font#glyph_id().(c)
136 }
137
138 /// Construct a [`Glyph`] with the font's pixel scale at
139 /// position `point(0.0, 0.0)`.
140 ///
141 /// # Example
142 /// ```
143 /// # use ab_glyph::*;
144 /// # let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf")).unwrap();
145 /// let scaled_font = font.as_scaled(50.0);
146 ///
147 /// let a1 = scaled_font.scaled_glyph('a');
148 /// let a2 = font.glyph_id('a').with_scale(50.0); // equivalent
149 ///
150 /// # assert_eq!(a1.id, a2.id);
151 /// assert_eq!(a1.scale, PxScale::from(50.0));
152 /// assert_eq!(a1.position, point(0.0, 0.0));
153 /// ```
154 #[inline]
155 fn scaled_glyphrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scaled_glyph().(&self, c: char) -> Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph# {
156 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().glyph_idrust-analyzer cargo ab_glyph 0.2.32 font/Font#glyph_id().(c).with_scalerust-analyzer cargo ab_glyph 0.2.32 glyph/impl#[GlyphId]with_scale().(self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().())
157 }
158
159 /// Pixel scaled horizontal advance for a given glyph.
160 /// See [glyph layout concepts](Font#glyph-layout-concepts).
161 #[inline]
162 fn h_advancerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_advance().(&self, id: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#) -> f32 {
163 self.h_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().h_advance_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#h_advance_unscaled().(id)
164 }
165
166 /// Pixel scaled horizontal side bearing for a given glyph.
167 /// See [glyph layout concepts](Font#glyph-layout-concepts).
168 #[inline]
169 fn h_side_bearingrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_side_bearing().(&self, id: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#) -> f32 {
170 self.h_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().h_side_bearing_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#h_side_bearing_unscaled().(id)
171 }
172
173 /// Pixel scaled vertical advance for a given glyph.
174 #[inline]
175 fn v_advancerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_advance().(&self, id: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#) -> f32 {
176 self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().v_advance_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#v_advance_unscaled().(id)
177 }
178
179 /// Pixel scaled vertical side bearing for a given glyph.
180 #[inline]
181 fn v_side_bearingrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_side_bearing().(&self, id: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#) -> f32 {
182 self.v_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#v_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().v_side_bearing_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#v_side_bearing_unscaled().(id)
183 }
184
185 /// Returns additional pixel scaled kerning to apply for a particular pair of glyphs.
186 #[inline]
187 fn kernrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#kern().(&self, first: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#, second: GlyphIdrust-analyzer cargo ab_glyph 0.2.32 glyph/GlyphId#) -> f32 {
188 self.h_scale_factorrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#h_scale_factor().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().kern_unscaledrust-analyzer cargo ab_glyph 0.2.32 font/Font#kern_unscaled().(first, second)
189 }
190
191 /// Returns the layout bounds of this glyph.
192 ///
193 /// Horizontally: Glyph position +/- h_advance/h_side_bearing.
194 /// Vertically: Glyph position +/- ascent/descent.
195 ///
196 /// These are *not* the same as [`OutlinedGlyph::px_bounds`]. If you are drawing pixels
197 /// you should use `px_bounds` and not this method as outlines are not bound by layout
198 /// values.
199 ///
200 /// Note this method does not make use of the associated scale, as `Glyph`
201 /// already includes one of it's own.
202 #[inline]
203 fn glyph_boundsrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#glyph_bounds().(&self, glyph: &Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#) -> Rectrust-analyzer cargo ab_glyph 0.2.32 outlined/Rect# {
204 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().glyph_boundsrust-analyzer cargo ab_glyph 0.2.32 font/Font#glyph_bounds().(glyph)
205 }
206
207 /// The number of glyphs present in this font. Glyph identifiers for this
208 /// font will always be in the range `0..self.glyph_count()`
209 #[inline]
210 fn glyph_countrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#glyph_count().(&self) -> usize {
211 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().glyph_countrust-analyzer cargo ab_glyph 0.2.32 font/Font#glyph_count().()
212 }
213
214 /// Returns an iterator of all distinct `(GlyphId, char)` pairs. Not ordered.
215 ///
216 /// Same as [`Font::codepoint_ids`].
217 fn codepoint_idsrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#codepoint_ids().(&self) -> craterust-analyzer cargo ab_glyph 0.2.32 crate/::CodepointIdIterrust-analyzer cargo ab_glyph 0.2.32 codepoint_ids/CodepointIdIter#<'_>;
218
219 /// Compute glyph outline ready for drawing.
220 ///
221 /// Note this method does not make use of the associated scale, as `Glyph`
222 /// already includes one of it's own.
223 #[inline]
224 fn outline_glyphrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#outline_glyph().(&self, glyph: Glyphrust-analyzer cargo ab_glyph 0.2.32 glyph/Glyph#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OutlinedGlyphrust-analyzer cargo ab_glyph 0.2.32 outlined/OutlinedGlyph#> {
225 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().().outline_glyphrust-analyzer cargo ab_glyph 0.2.32 font/Font#outline_glyph().(glyph)
226 }
227 }
228
229 impl<F: Fontrust-analyzer cargo ab_glyph 0.2.32 font/Font#, SF: ScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#<F>> ScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#<F> for &SF {
230 #[inline]
231 fn scalerust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`&SF`][`ScaleFont<F>`]scale().(&self) -> PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# {
232 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).scalerust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#scale().()
233 }
234
235 #[inline]
236 fn fontrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`&SF`][`ScaleFont<F>`]font().(&self) -> &F {
237 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).fontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#font().()
238 }
239
240 #[inline]
241 fn codepoint_idsrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`&SF`][`ScaleFont<F>`]codepoint_ids().(&self) -> craterust-analyzer cargo ab_glyph 0.2.32 crate/::CodepointIdIterrust-analyzer cargo ab_glyph 0.2.32 codepoint_ids/CodepointIdIter#<'_> {
242 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).codepoint_idsrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#codepoint_ids().()
243 }
244 }
245
246 /// A [`Font`] and an associated pixel scale.
247 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
248 pub struct PxScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#<F> {
249 pub fontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#font.: F,
250 pub scalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#scale.: PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#,
251 }
252
253 impl<F> PxScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#<F> {
254 #[inline]
255 pub fn with_scalerust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`PxScaleFont<F>`]with_scale().<S: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale#>>(mut self, scale: S) -> Selfrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`PxScaleFont<F>`] {
256 self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#scale. = scale.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
257 self
258 }
259 }
260
261 impl<F: Fontrust-analyzer cargo ab_glyph 0.2.32 font/Font#> ScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/ScaleFont#<F> for PxScaleFontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#<F> {
262 #[inline]
263 fn scalerust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`PxScaleFont<F>`][`ScaleFont<F>`]scale().(&self) -> PxScalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScale# {
264 self.scalerust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#scale.
265 }
266
267 #[inline]
268 fn fontrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`PxScaleFont<F>`][`ScaleFont<F>`]font().(&self) -> &F {
269 &self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#font.
270 }
271
272 #[inline]
273 fn codepoint_idsrust-analyzer cargo ab_glyph 0.2.32 scale/impl#[`PxScaleFont<F>`][`ScaleFont<F>`]codepoint_ids().(&self) -> craterust-analyzer cargo ab_glyph 0.2.32 crate/::CodepointIdIterrust-analyzer cargo ab_glyph 0.2.32 codepoint_ids/CodepointIdIter#<'_> {
274 self.fontrust-analyzer cargo ab_glyph 0.2.32 scale/PxScaleFont#font..codepoint_idsrust-analyzer cargo ab_glyph 0.2.32 font/Font#codepoint_ids().()
275 }
276 }